insomnia-plugin-aws-amplify 1.2.0 → 1.2.2
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/app.js +12 -1
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -247292,6 +247292,12 @@ var root = async (context, ...args) => {
|
|
|
247292
247292
|
if (!authStore) {
|
|
247293
247293
|
return 'No cached auth data found - please hit the "Authenticate" button';
|
|
247294
247294
|
}
|
|
247295
|
+
const nowMs = new Date().getTime();
|
|
247296
|
+
const expiresAt = authStore.expiresAt ?? 0;
|
|
247297
|
+
if (expiresAt < nowMs) {
|
|
247298
|
+
console.info("Auth token expired, re-authenticating");
|
|
247299
|
+
await authenticate(context);
|
|
247300
|
+
}
|
|
247295
247301
|
return authStore.error ?? authStore[ReturnValue];
|
|
247296
247302
|
};
|
|
247297
247303
|
var authenticate = async (context) => {
|
|
@@ -247309,7 +247315,12 @@ var authenticate = async (context) => {
|
|
|
247309
247315
|
UserPoolId,
|
|
247310
247316
|
ClientId
|
|
247311
247317
|
);
|
|
247312
|
-
|
|
247318
|
+
const ONE_HOUR_MS = 1e3 * 60 * 60;
|
|
247319
|
+
const expiresAt = new Date().getTime() + ONE_HOUR_MS;
|
|
247320
|
+
authStore = {
|
|
247321
|
+
...loginResponse,
|
|
247322
|
+
expiresAt
|
|
247323
|
+
};
|
|
247313
247324
|
} catch (error) {
|
|
247314
247325
|
console.error(error);
|
|
247315
247326
|
authStore.error = error instanceof Error ? error.message : "Unknown authentication error occured";
|