samlify ERR_EXCEPTION_OF_ASSERTION_DECRYPTION - node.js

When I trying to make a Okta validation with a SAML using samlify on my project
import * as samlify from 'samlify';
import * as fs from 'fs';
import * as validator from '#authenio/samlify-node-xmllint';
const binding = samlify.Constants.namespace.binding;
samlify.setSchemaValidator(validator);
const filePathIdpMeta = __dirname + '/../' + 'meta1123/meta/Testv2-xml-idp.xml';
const filePathSPMeta = __dirname + '/../' + 'meta1123/meta/Testv2-xml-sp.xml';
const filePathSpKey = __dirname + '/../' + 'meta1123/key/encryptKey.pem';
console.info("----PATHS----")
console.info(filePathIdpMeta);
console.info(filePathSPMeta);
console.info(filePathSpKey);
const idp = samlify.IdentityProvider({
metadata: fs.readFileSync(filePathIdpMeta),
messageSigningOrder: 'sign-then-encrypt',
isAssertionEncrypted: true,
wantAuthnRequestsSigned: false
})
Currently I getting the following error:
http://www.w3.org/2001/04/xmlenc#rsa-1_5 is no longer recommended due to security reasons. Please deprecate its use as soon as possible.
Error: Not found: child not in parent
at assertPreInsertionValidity1to5 (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/node_modules/#xmldom/xmldom/lib/dom.js:798:9)
at _insertBefore (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/node_modules/#xmldom/xmldom/lib/dom.js:938:2)
at Document.replaceChild (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/node_modules/#xmldom/xmldom/lib/dom.js:1054:3)
at /home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/libsaml.ts:681:15
at Object.decrypt (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/#authenio/xml-encryption/lib/xmlenc.js:202:16)
at /home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/libsaml.ts:670:23
at new Promise (<anonymous>)
at Object.decryptAssertion (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/libsaml.ts:655:14)
at /home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/flow.ts:225:34
at step (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/build/src/flow.js:33:23) {
code: 8
}
[FATAL] when parsing login response sent from okta Error: ERR_EXCEPTION_OF_ASSERTION_DECRYPTION
at /home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/libsaml.ts:675:27
at Object.decrypt (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/#authenio/xml-encryption/lib/xmlenc.js:214:12)
at /home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/libsaml.ts:670:23
at new Promise (<anonymous>)
at Object.decryptAssertion (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/libsaml.ts:655:14)
at /home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/src/flow.ts:225:34
at step (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/build/src/flow.js:33:23)
at Object.next (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/build/src/flow.js:14:53)
at fulfilled (/home/my_local_path/Service_Providers/sp-oauth0/node_modules/samlify/build/src/flow.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

Related

Firebase Cloud messaging NodeJS PROJECT_NOT_PERMITTED

I am trying to send a push notification from my nodejs app to my android app using firebase-admin
I followed the instructions as follows
import firebaseAdmin from 'firebase-admin';
import serviceAccount from '../../common/constants/pushKey.json';
firebaseAdmin.initializeApp({
credential: firebaseAdmin.credential.cert(serviceAccount),
});
and the pushKey is the json generated from
project settings -> service accounts -> firebase admin sdk -> generate new private key
However when calling
firebaseAdmin.messaging().sendToDevice(token, payload)
I get the following error
<TITLE>PROJECT_NOT_PERMITTED</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>PROJECT_NOT_PERMITTED</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
". Status code: 401.
at FirebaseMessagingError.<anonymous> (/Users/chris/Documents/ZebedeeApps/booty/node_modules/core-js/internals/wrap-error-constructor-with-cause.js:37:62)
at FirebaseMessagingError.Error (/Users/chris/Documents/ZebedeeApps/booty/node_modules/core-js/modules/es.error.cause.js:28:43)
at FirebaseMessagingError.FirebaseError [as constructor] (/Users/chris/Documents/ZebedeeApps/booty/node_modules/firebase-admin/lib/utils/error.js:44:28)
at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/Users/chris/Documents/ZebedeeApps/booty/node_modules/firebase-admin/lib/utils/error.js:90:28)
at new FirebaseMessagingError (/Users/chris/Documents/ZebedeeApps/booty/node_modules/firebase-admin/lib/utils/error.js:279:16)
at Object.createFirebaseError (/Users/chris/Documents/ZebedeeApps/booty/node_modules/firebase-admin/lib/messaging/messaging-errors-internal.js:57:12)
at /Users/chris/Documents/ZebedeeApps/booty/node_modules/firebase-admin/lib/messaging/messaging-api-request-internal.js:79:51
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
errorInfo: {
code: 'messaging/authentication-error',
message: 'An error occurred when trying to authenticate to the FCM servers. Make sure the credential used to authenticate this SDK has the proper permissions. See https://firebase.google.com/docs/admin/setup for setup instructions. Raw server response: "<HTML>\n' +
'<HEAD>\n' +
'<TITLE>PROJECT_NOT_PERMITTED</TITLE>\n' +
'</HEAD>\n' +
'<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n' +
'<H1>PROJECT_NOT_PERMITTED</H1>\n' +
'<H2>Error 401</H2>\n' +
'</BODY>\n' +
'</HTML>\n' +
'". Status code: 401.'
},
codePrefix: 'messaging'
}
Any ideas?
Needs to enable Cloud Messaging API (Legacy) : https://stackoverflow.com/a/72901323/6890201
Firebase configuration

Creating a Google Cloud Task from a Firebase Function throws Error: 3 INVALID_ARGUMENT: Task.payload_type is not set

I am trying to create a Task in a Google Cloud Tasks Queue from a firebase function that calls when an entry in a firebase Realtime Database is created. However when the function is supposed to create the task it throws the following Error:
Error: 3 INVALID_ARGUMENT: Task.payload_type is not set.
at Object.callErrorFromStatus (D:\programming\AndroidStudioProjects\TWILY\firebaseBackend\functions\node_modules\#grpc\grpc-js\build\src\call.js:31:26)
at Object.onReceiveStatus (D:\programming\AndroidStudioProjects\TWILY\firebaseBackend\functions\node_modules\#grpc\grpc-js\build\src\client.js:180:52)
at Object.onReceiveStatus (D:\programming\AndroidStudioProjects\TWILY\firebaseBackend\functions\node_modules\#grpc\grpc-js\build\src\client-interceptors.js:336:141)
at Object.onReceiveStatus (D:\programming\AndroidStudioProjects\TWILY\firebaseBackend\functions\node_modules\#grpc\grpc-js\build\src\client-interceptors.js:299:181)
at D:\programming\AndroidStudioProjects\TWILY\firebaseBackend\functions\node_modules\#grpc\grpc-js\build\src\call-stream.js:160:78
at processTicksAndRejections (internal/process/task_queues.js:77:11)
The relevant code is as follows:
const project = JSON.parse(process.env.FIREBASE_CONFIG).projectId;
const location = "europe-west1";
const queue = "message-queue";
const tasksClient = new CloudTasksClient();
const queuePath = tasksClient.queuePath(project, location, queue);
console.log(queuePath);
const url = `https://${location}-${project}.cloudfunctions.net/sendMessageCallback`;
const task = {
httpRequest: {
httpMethod: "POST",
url: url,
body: Buffer.from("Hello there").toString("base64"),
headers: {
"Content-Type": "text/plain",
},
},
scheduleTime: {
seconds: scheduleSendSeconds,
},
};
const taskRequest = {parent: queuePath};
taskRequest["task-" + scheduleSendMillis.toString()] = task;
console.log(taskRequest);
return tasksClient.createTask(taskRequest);
I have not been able to find out anything about the supposedly required Task.payload_type field.
What am I missing here?
I am posting an answer as this will not format well as a comment.
Is there a reason you are modifying the task key name:
const taskRequest = {parent: queuePath};
taskRequest["task-" + scheduleSendMillis.toString()] = task;
Instead of doing this:
const taskRequest = {parent: parent, task: task};
I belive that is the source of the error related to Task.payload_type

Hyperledger composer TypeError: Cannot create property 'wallet' on string 'resumedevelop'

I want to subscribe event.
so I make a event.js File
event.js
'use strict';
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
const winston = require('winston');
var chalk = require('chalk');
let config = require('config').get('event-app');
let participantId = config.get('participantId');
let participantPwd = config.get('participantPwd');
const LOG = winston.loggers.get('application');
var connection = new BusinessNetworkConnection();
return connection.connect('admin#resumedevelop', 'resumedevelop', 'admin', 'adminpw')
.then(function (definition) {
// Retrieved Business Network Definition
console.log(definition === connection.getBusinessNetwork()); // true
});
"resumedevelop" is networkName
I run a BusinessNetwork
and attempt to
command "node event.js"
as a result,
(node:28771) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot create property 'wallet' on string 'resumedevelop'
please give me advice.. !
Looking at the API reference for BusinessNetworkConnection I would say that the error is telling you that you are passing a string as the 2nd parameter when an object is expected.
But I would also observe that the Network name, and Credentials (or more likely certificates) are part of the Business Network Card that you are supplying as the first parameter, so you don't need to specify those extra parameters.

Firebase functions logs error working with Cloud Firestore and Node JS

The Firebase functions by Nodejs is not retrieving the results from the data stored in the Cloud Firestore Database. Giving a:
TypeError of Undefined user_id
NodeJS Code
'use-strict'
const admin = require('firebase-admin');
const functions = require('firebase-functions');
const serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.firestore.document("Users/{user_id}/Notifications/{notification_id}").onWrite(event => {
const user_id = event.params.user_id;
const notification_id = event.params.notification_id;
console.console.log("User ID: " + user_id + " | Notification ID: " + notification_id);
});
Error in Logs of Firebase Functions
TypeError: Cannot read property 'user_id' of undefined at
exports.sendNotification.functions.firestore.document.onWrite.event
(/user_code/index.js:10:33) at Object.<anonymous>
(/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
at next (native) at /user_code/node_modules/firebase-functions/lib/cloud-
functions.js:28:71 at __awaiter (/user_code/node_modules/firebase-
functions/lib/cloud-functions.js:24:12) at cloudFunction
(/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36) at
/var/tmp/worker/worker.js:700:26 at process._tickDomainCallback
(internal/process/next_tick.js:135:7)
Database Rules
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true; } } }
It looks like you're using version 1.0 of the firebase-functions module in your Cloud Functions code. The API has changed in 1.0. Please consult the migration guide to understand what changed in 1.0.
There is no longer a params property on the first argument passed to the the callback for an onWrite trigger. It was split into two arguments, a Change, and an EventContext object. The EventContext argument has a params property you should use now.

Is this an issue with the server code, or the app code?

When rendering my app on the server I get and Invariant error with the provider element. Error is Invariant Violation: React.Children.only expected to receive a single React element child. I also get this warning Warning: Failed prop type: Invalid propchildrenof typearraysupplied to Provider, expected a single ReactElement. in Provider
const store = createStoreWithMiddleware(reducers);
const provider = react.createElement(Provider, { store: store }, RouterContext);
const ReactApp = renderToString(provider);
const reactRouter = require('react-router');
const RouterContext = reactRouter.RouterContext;
The <Provider> component accepts only a single element as its children. You can change your code to pass an element, not an array:
const RouterContext = react.createElement(reactRouter.RouterContext, renderProps);
const provider = react.createElement(Provider, { store: store }, RouterContext);

Resources