backend-manager 3.2.37 → 3.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -564,8 +564,6 @@ BackendAssistant.prototype.authenticate = async function (options) {
|
|
|
564
564
|
options = options || {};
|
|
565
565
|
options.resolve = typeof options.resolve === 'undefined' ? true : options.resolve;
|
|
566
566
|
|
|
567
|
-
const logOptions = {environment: options.log ? 'production' : 'development'}
|
|
568
|
-
|
|
569
567
|
function _resolve(user) {
|
|
570
568
|
user = user || {};
|
|
571
569
|
user.authenticated = typeof user.authenticated === 'undefined'
|
|
@@ -583,11 +581,11 @@ BackendAssistant.prototype.authenticate = async function (options) {
|
|
|
583
581
|
if (req?.headers?.authorization && req?.headers?.authorization?.startsWith('Bearer ')) {
|
|
584
582
|
// Read the ID Token from the Authorization header.
|
|
585
583
|
idToken = req.headers.authorization.split('Bearer ')[1];
|
|
586
|
-
self.log('Found "Authorization" header', idToken
|
|
584
|
+
self.log('Found "Authorization" header', idToken);
|
|
587
585
|
} else if (req?.cookies?.__session) {
|
|
588
586
|
// Read the ID Token from cookie.
|
|
589
587
|
idToken = req.cookies.__session;
|
|
590
|
-
self.log('Found "__session" cookie', idToken
|
|
588
|
+
self.log('Found "__session" cookie', idToken);
|
|
591
589
|
} else if (data.backendManagerKey || data.authenticationToken) {
|
|
592
590
|
// Check with custom BEM Token
|
|
593
591
|
let storedApiKey;
|
|
@@ -600,7 +598,7 @@ BackendAssistant.prototype.authenticate = async function (options) {
|
|
|
600
598
|
|
|
601
599
|
idToken = data.backendManagerKey || data.authenticationToken;
|
|
602
600
|
|
|
603
|
-
self.log('Found "backendManagerKey" or "authenticationToken" parameter', {storedApiKey: storedApiKey, idToken: idToken}
|
|
601
|
+
self.log('Found "backendManagerKey" or "authenticationToken" parameter', {storedApiKey: storedApiKey, idToken: idToken});
|
|
604
602
|
|
|
605
603
|
if (storedApiKey && (storedApiKey === data.backendManagerKey || storedApiKey === data.authenticationToken)) {
|
|
606
604
|
self.request.user.authenticated = true;
|
|
@@ -609,7 +607,7 @@ BackendAssistant.prototype.authenticate = async function (options) {
|
|
|
609
607
|
}
|
|
610
608
|
} else if (options.apiKey || data.apiKey) {
|
|
611
609
|
const apiKey = options.apiKey || data.apiKey;
|
|
612
|
-
self.log('Found "options.apiKey"', apiKey
|
|
610
|
+
self.log('Found "options.apiKey"', apiKey);
|
|
613
611
|
|
|
614
612
|
if (apiKey.includes('test')) {
|
|
615
613
|
return _resolve(self.request.user);
|
|
@@ -634,7 +632,7 @@ BackendAssistant.prototype.authenticate = async function (options) {
|
|
|
634
632
|
// 'Make sure you authenticate your request by providing either the following HTTP header:',
|
|
635
633
|
// 'Authorization: Bearer <Firebase ID Token>',
|
|
636
634
|
// 'or by passing a "__session" cookie',
|
|
637
|
-
// 'or by passing backendManagerKey or authenticationToken in the body or query'
|
|
635
|
+
// 'or by passing backendManagerKey or authenticationToken in the body or query');
|
|
638
636
|
|
|
639
637
|
return _resolve(self.request.user);
|
|
640
638
|
}
|
|
@@ -643,7 +641,7 @@ BackendAssistant.prototype.authenticate = async function (options) {
|
|
|
643
641
|
try {
|
|
644
642
|
const decodedIdToken = await admin.auth().verifyIdToken(idToken);
|
|
645
643
|
if (options.debug) {
|
|
646
|
-
self.log('Token correctly decoded', decodedIdToken.email, decodedIdToken.user_id
|
|
644
|
+
self.log('Token correctly decoded', decodedIdToken.email, decodedIdToken.user_id);
|
|
647
645
|
}
|
|
648
646
|
await admin.firestore().doc(`users/${decodedIdToken.user_id}`)
|
|
649
647
|
.get()
|
|
@@ -655,12 +653,12 @@ BackendAssistant.prototype.authenticate = async function (options) {
|
|
|
655
653
|
self.request.user.auth.uid = decodedIdToken.user_id;
|
|
656
654
|
self.request.user.auth.email = decodedIdToken.email;
|
|
657
655
|
if (options.debug) {
|
|
658
|
-
self.log('Found user doc', self.request.user
|
|
656
|
+
self.log('Found user doc', self.request.user)
|
|
659
657
|
}
|
|
660
658
|
})
|
|
661
659
|
return _resolve(self.request.user);
|
|
662
660
|
} catch (error) {
|
|
663
|
-
self.error('Error while verifying Firebase ID token:', error
|
|
661
|
+
self.error('Error while verifying Firebase ID token:', error);
|
|
664
662
|
return _resolve(self.request.user);
|
|
665
663
|
}
|
|
666
664
|
};
|
|
@@ -86,13 +86,15 @@ OpenAI.prototype.request = function (options) {
|
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
assistant.log('callOpenAI():', ...arguments);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
function _load(input) {
|
|
93
93
|
// console.log('*** input!!!', input.content.slice(0, 50), input.path);
|
|
94
94
|
// console.log('*** input.content', input.content.slice(0, 50));
|
|
95
95
|
// console.log('*** input.path', input.path);
|
|
96
|
+
_log('Loading', input);
|
|
97
|
+
|
|
96
98
|
return powertools.template(
|
|
97
99
|
input.path ? jetpack.read(input.path) : input.content,
|
|
98
100
|
input.settings,
|
|
@@ -100,6 +102,7 @@ OpenAI.prototype.request = function (options) {
|
|
|
100
102
|
.trim();
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
// Log
|
|
103
106
|
_log('Starting', self.key);
|
|
104
107
|
_log('Starting', options);
|
|
105
108
|
|
|
@@ -111,6 +114,7 @@ OpenAI.prototype.request = function (options) {
|
|
|
111
114
|
? { type: 'json_object' }
|
|
112
115
|
: undefined;
|
|
113
116
|
|
|
117
|
+
// Log
|
|
114
118
|
_log('Prompt', prompt);
|
|
115
119
|
_log('Message', message);
|
|
116
120
|
_log('User', user);
|