@friggframework/core 2.0.0-next.70 → 2.0.0-next.71
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.
|
@@ -32,6 +32,7 @@ const createApp = (applyMiddleware) => {
|
|
|
32
32
|
flushDebugLog(boomError);
|
|
33
33
|
res.status(statusCode).json({ error: 'Internal Server Error' });
|
|
34
34
|
} else {
|
|
35
|
+
console.warn(`[Frigg] ${req.method} ${req.path} -> ${statusCode}: ${err.message}`);
|
|
35
36
|
res.status(statusCode).json({ error: err.message });
|
|
36
37
|
}
|
|
37
38
|
});
|
package/modules/module.js
CHANGED
|
@@ -42,7 +42,9 @@ class Module extends Delegate {
|
|
|
42
42
|
const apiParams = {
|
|
43
43
|
...this.definition.env,
|
|
44
44
|
delegate: this,
|
|
45
|
-
...(this.credential?.data
|
|
45
|
+
...(this.credential?.data
|
|
46
|
+
? this.apiParamsFromCredential(this.credential.data)
|
|
47
|
+
: {}), // Handle case when credential is undefined
|
|
46
48
|
...this.apiParamsFromEntity(this.entity),
|
|
47
49
|
};
|
|
48
50
|
this.api = new this.apiClass(apiParams);
|
|
@@ -100,10 +102,15 @@ class Module extends Delegate {
|
|
|
100
102
|
this.api,
|
|
101
103
|
this.userId
|
|
102
104
|
);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
const apiParams = this.apiParamsFromCredential(this.api);
|
|
106
|
+
|
|
107
|
+
if (!apiParams.refresh_token && this.api.isRefreshable) {
|
|
108
|
+
console.warn(
|
|
109
|
+
`[Frigg] No refresh_token in apiParams for module ${this.name}.`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Object.assign(credentialDetails.details, apiParams);
|
|
107
114
|
credentialDetails.details.authIsValid = true;
|
|
108
115
|
|
|
109
116
|
const persisted = await this.credentialRepository.upsertCredential(
|
|
@@ -30,7 +30,6 @@ const { ModuleConstants } = require('../ModuleConstants');
|
|
|
30
30
|
* await api.getTokenFromClientCredentials();
|
|
31
31
|
*/
|
|
32
32
|
class OAuth2Requester extends Requester {
|
|
33
|
-
|
|
34
33
|
static requesterType = ModuleConstants.authType.oauth2;
|
|
35
34
|
|
|
36
35
|
/**
|
|
@@ -118,6 +117,16 @@ class OAuth2Requester extends Requester {
|
|
|
118
117
|
const newRefreshToken = get(params, 'refresh_token', null);
|
|
119
118
|
if (newRefreshToken !== null) {
|
|
120
119
|
this.refresh_token = newRefreshToken;
|
|
120
|
+
} else {
|
|
121
|
+
if (this.refresh_token) {
|
|
122
|
+
console.log(
|
|
123
|
+
'[Frigg] No refresh_token in response, preserving existing'
|
|
124
|
+
);
|
|
125
|
+
} else {
|
|
126
|
+
console.log(
|
|
127
|
+
'[Frigg] Current refresh_token is null and no new refresh_token in response'
|
|
128
|
+
);
|
|
129
|
+
}
|
|
121
130
|
}
|
|
122
131
|
const accessExpiresIn = get(params, 'expires_in', null);
|
|
123
132
|
const refreshExpiresIn = get(
|
|
@@ -128,7 +137,9 @@ class OAuth2Requester extends Requester {
|
|
|
128
137
|
|
|
129
138
|
this.accessTokenExpire = new Date(Date.now() + accessExpiresIn * 1000);
|
|
130
139
|
if (refreshExpiresIn !== null) {
|
|
131
|
-
this.refreshTokenExpire = new Date(
|
|
140
|
+
this.refreshTokenExpire = new Date(
|
|
141
|
+
Date.now() + refreshExpiresIn * 1000
|
|
142
|
+
);
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
await this.notify(this.DLGT_TOKEN_UPDATE);
|
|
@@ -237,6 +248,7 @@ class OAuth2Requester extends Requester {
|
|
|
237
248
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
238
249
|
},
|
|
239
250
|
};
|
|
251
|
+
console.log('[Frigg] Refreshing access token with options');
|
|
240
252
|
const response = await this._post(options, false);
|
|
241
253
|
await this.setTokens(response);
|
|
242
254
|
return response;
|
|
@@ -284,7 +296,7 @@ class OAuth2Requester extends Requester {
|
|
|
284
296
|
*/
|
|
285
297
|
async refreshAuth() {
|
|
286
298
|
try {
|
|
287
|
-
console.log('[
|
|
299
|
+
console.log('[Frigg] Starting token refresh', {
|
|
288
300
|
grant_type: this.grant_type,
|
|
289
301
|
has_refresh_token: !!this.refresh_token,
|
|
290
302
|
has_client_id: !!this.client_id,
|
|
@@ -300,10 +312,10 @@ class OAuth2Requester extends Requester {
|
|
|
300
312
|
} else {
|
|
301
313
|
await this.getTokenFromClientCredentials();
|
|
302
314
|
}
|
|
303
|
-
console.log('[
|
|
315
|
+
console.log('[Frigg] Token refresh succeeded');
|
|
304
316
|
return true;
|
|
305
317
|
} catch (error) {
|
|
306
|
-
console.error('[
|
|
318
|
+
console.error('[Frigg] Token refresh failed', {
|
|
307
319
|
error_message: error?.message,
|
|
308
320
|
error_name: error?.name,
|
|
309
321
|
response_status: error?.response?.status,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.71",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@friggframework/eslint-config": "2.0.0-next.
|
|
42
|
-
"@friggframework/prettier-config": "2.0.0-next.
|
|
43
|
-
"@friggframework/test": "2.0.0-next.
|
|
41
|
+
"@friggframework/eslint-config": "2.0.0-next.71",
|
|
42
|
+
"@friggframework/prettier-config": "2.0.0-next.71",
|
|
43
|
+
"@friggframework/test": "2.0.0-next.71",
|
|
44
44
|
"@prisma/client": "^6.17.0",
|
|
45
45
|
"@types/lodash": "4.17.15",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "a0fd3deb90390dbb9d01d7ac8fdb5e5f5b8f9c78"
|
|
84
84
|
}
|