@aws-amplify/core 6.7.0 → 6.7.1-token-exp-tolerance.3d6e9db.0

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.
@@ -3,5 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.version = void 0;
5
5
  // generated by genversion
6
- exports.version = '6.10.0';
6
+ exports.version = '6.10.1-token-exp-tolerance.3d6e9db.0+3d6e9db';
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.10.0';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,QAAQ;;"}
1
+ {"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.10.1-token-exp-tolerance.3d6e9db.0+3d6e9db';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,8CAA8C;;"}
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.AuthClass = exports.isTokenExpired = void 0;
5
- function isTokenExpired({ expiresAt, clockDrift, }) {
5
+ function isTokenExpired({ expiresAt, clockDrift, tolerance = 5000, }) {
6
6
  const currentTime = Date.now();
7
- return currentTime + clockDrift > expiresAt;
7
+ return currentTime + clockDrift + tolerance > expiresAt;
8
8
  }
9
9
  exports.isTokenExpired = isTokenExpired;
10
10
  class AuthClass {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/singleton/Auth/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AuthClass = exports.isTokenExpired = void 0;\nfunction isTokenExpired({ expiresAt, clockDrift, }) {\n const currentTime = Date.now();\n return currentTime + clockDrift > expiresAt;\n}\nexports.isTokenExpired = isTokenExpired;\nclass AuthClass {\n /**\n * Configure Auth category\n *\n * @internal\n *\n * @param authResourcesConfig - Resources configurations required by Auth providers.\n * @param authOptions - Client options used by library\n *\n * @returns void\n */\n configure(authResourcesConfig, authOptions) {\n this.authConfig = authResourcesConfig;\n this.authOptions = authOptions;\n }\n /**\n * Fetch the auth tokens, and the temporary AWS credentials and identity if they are configured. By default it\n * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh\n * with `{ forceRefresh: true }` input.\n *\n * @param options - Options configuring the fetch behavior.\n *\n * @returns Promise of current auth session {@link AuthSession}.\n */\n async fetchAuthSession(options = {}) {\n let credentialsAndIdentityId;\n let userSub;\n // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available\n const tokens = await this.getTokens(options);\n if (tokens) {\n userSub = tokens.accessToken?.payload?.sub;\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n tokens,\n authenticated: true,\n forceRefresh: options.forceRefresh,\n });\n }\n else {\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n authenticated: false,\n forceRefresh: options.forceRefresh,\n });\n }\n return {\n tokens,\n credentials: credentialsAndIdentityId?.credentials,\n identityId: credentialsAndIdentityId?.identityId,\n userSub,\n };\n }\n async clearCredentials() {\n await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId();\n }\n async getTokens(options) {\n return ((await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined);\n }\n}\nexports.AuthClass = AuthClass;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AACpD,SAAS,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,GAAG,EAAE;AACpD,IAAI,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACnC,IAAI,OAAO,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAChD,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AACxC,MAAM,SAAS,CAAC;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,mBAAmB,EAAE,WAAW,EAAE;AAChD,QAAQ,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC;AAC9C,QAAQ,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;AACvC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,CAAC,OAAO,GAAG,EAAE,EAAE;AACzC,QAAQ,IAAI,wBAAwB,CAAC;AACrC,QAAQ,IAAI,OAAO,CAAC;AACpB;AACA,QAAQ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACrD,QAAQ,IAAI,MAAM,EAAE;AACpB,YAAY,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC;AACvD;AACA,YAAY,wBAAwB;AACpC,gBAAgB,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,2BAA2B,CAAC;AACzF,oBAAoB,UAAU,EAAE,IAAI,CAAC,UAAU;AAC/C,oBAAoB,MAAM;AAC1B,oBAAoB,aAAa,EAAE,IAAI;AACvC,oBAAoB,YAAY,EAAE,OAAO,CAAC,YAAY;AACtD,iBAAiB,CAAC,CAAC;AACnB,SAAS;AACT,aAAa;AACb;AACA,YAAY,wBAAwB;AACpC,gBAAgB,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,2BAA2B,CAAC;AACzF,oBAAoB,UAAU,EAAE,IAAI,CAAC,UAAU;AAC/C,oBAAoB,aAAa,EAAE,KAAK;AACxC,oBAAoB,YAAY,EAAE,OAAO,CAAC,YAAY;AACtD,iBAAiB,CAAC,CAAC;AACnB,SAAS;AACT,QAAQ,OAAO;AACf,YAAY,MAAM;AAClB,YAAY,WAAW,EAAE,wBAAwB,EAAE,WAAW;AAC9D,YAAY,UAAU,EAAE,wBAAwB,EAAE,UAAU;AAC5D,YAAY,OAAO;AACnB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,CAAC;AACrF,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;AAC7B,QAAQ,QAAQ,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;AAC1F,KAAK;AACL,CAAC;AACD,OAAO,CAAC,SAAS,GAAG,SAAS;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/singleton/Auth/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.AuthClass = exports.isTokenExpired = void 0;\nfunction isTokenExpired({ expiresAt, clockDrift, tolerance = 5000, }) {\n const currentTime = Date.now();\n return currentTime + clockDrift + tolerance > expiresAt;\n}\nexports.isTokenExpired = isTokenExpired;\nclass AuthClass {\n /**\n * Configure Auth category\n *\n * @internal\n *\n * @param authResourcesConfig - Resources configurations required by Auth providers.\n * @param authOptions - Client options used by library\n *\n * @returns void\n */\n configure(authResourcesConfig, authOptions) {\n this.authConfig = authResourcesConfig;\n this.authOptions = authOptions;\n }\n /**\n * Fetch the auth tokens, and the temporary AWS credentials and identity if they are configured. By default it\n * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh\n * with `{ forceRefresh: true }` input.\n *\n * @param options - Options configuring the fetch behavior.\n *\n * @returns Promise of current auth session {@link AuthSession}.\n */\n async fetchAuthSession(options = {}) {\n let credentialsAndIdentityId;\n let userSub;\n // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available\n const tokens = await this.getTokens(options);\n if (tokens) {\n userSub = tokens.accessToken?.payload?.sub;\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n tokens,\n authenticated: true,\n forceRefresh: options.forceRefresh,\n });\n }\n else {\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n authenticated: false,\n forceRefresh: options.forceRefresh,\n });\n }\n return {\n tokens,\n credentials: credentialsAndIdentityId?.credentials,\n identityId: credentialsAndIdentityId?.identityId,\n userSub,\n };\n }\n async clearCredentials() {\n await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId();\n }\n async getTokens(options) {\n return ((await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined);\n }\n}\nexports.AuthClass = AuthClass;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC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AY,wBAAwB;AACpC,gBAAgB,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,2BAA2B,CAAC;AACzF,oBAAoB,UAAU,EAAE,IAAI,CAAC,UAAU;AAC/C,oBAAoB,aAAa,EAAE,KAAK;AACxC,oBAAoB,YAAY,EAAE,OAAO,CAAC,YAAY;AACtD,iBAAiB,CAAC,CAAC;AACnB,SAAS;AACT,QAAQ,OAAO;AACf,YAAY,MAAM;AAClB,YAAY,WAAW,EAAE,wBAAwB,EAAE,WAAW;AAC9D,YAAY,UAAU,EAAE,wBAAwB,EAAE,UAAU;AAC5D,YAAY,OAAO;AACnB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,CAAC;AACrF,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;AAC7B,QAAQ,QAAQ,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;AAC1F,KAAK;AACL,CAAC;AACD,OAAO,CAAC,SAAS,GAAG,SAAS;;"}
@@ -1 +1 @@
1
- export declare const version = "6.10.0";
1
+ export declare const version = "6.10.1-token-exp-tolerance.3d6e9db.0+3d6e9db";
@@ -1,5 +1,5 @@
1
1
  // generated by genversion
2
- const version = '6.10.0';
2
+ const version = '6.10.1-token-exp-tolerance.3d6e9db.0+3d6e9db';
3
3
 
4
4
  export { version };
5
5
  //# sourceMappingURL=version.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.10.0';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.10.1-token-exp-tolerance.3d6e9db.0+3d6e9db';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
@@ -30,7 +30,7 @@ export interface AmplifyOutputsAuthProperties {
30
30
  unauthenticated_identities_enabled?: boolean;
31
31
  mfa_configuration?: string;
32
32
  mfa_methods?: string[];
33
- groups?: Record<UserGroupName, UserGroupPrecedence>[];
33
+ groups?: Partial<Record<UserGroupName, UserGroupPrecedence>>[];
34
34
  }
35
35
  export interface AmplifyOutputsStorageBucketProperties {
36
36
  /** Friendly bucket name provided in Amplify Outputs */
@@ -1,7 +1,8 @@
1
1
  import { AuthConfig, AuthSession, AuthTokens, FetchAuthSessionOptions, LibraryAuthOptions } from './types';
2
- export declare function isTokenExpired({ expiresAt, clockDrift, }: {
2
+ export declare function isTokenExpired({ expiresAt, clockDrift, tolerance, }: {
3
3
  expiresAt: number;
4
4
  clockDrift: number;
5
+ tolerance?: number;
5
6
  }): boolean;
6
7
  export declare class AuthClass {
7
8
  private authConfig?;
@@ -1,6 +1,6 @@
1
- function isTokenExpired({ expiresAt, clockDrift, }) {
1
+ function isTokenExpired({ expiresAt, clockDrift, tolerance = 5000, }) {
2
2
  const currentTime = Date.now();
3
- return currentTime + clockDrift > expiresAt;
3
+ return currentTime + clockDrift + tolerance > expiresAt;
4
4
  }
5
5
  class AuthClass {
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/singleton/Auth/index.ts"],"sourcesContent":["export function isTokenExpired({ expiresAt, clockDrift, }) {\n const currentTime = Date.now();\n return currentTime + clockDrift > expiresAt;\n}\nexport class AuthClass {\n /**\n * Configure Auth category\n *\n * @internal\n *\n * @param authResourcesConfig - Resources configurations required by Auth providers.\n * @param authOptions - Client options used by library\n *\n * @returns void\n */\n configure(authResourcesConfig, authOptions) {\n this.authConfig = authResourcesConfig;\n this.authOptions = authOptions;\n }\n /**\n * Fetch the auth tokens, and the temporary AWS credentials and identity if they are configured. By default it\n * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh\n * with `{ forceRefresh: true }` input.\n *\n * @param options - Options configuring the fetch behavior.\n *\n * @returns Promise of current auth session {@link AuthSession}.\n */\n async fetchAuthSession(options = {}) {\n let credentialsAndIdentityId;\n let userSub;\n // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available\n const tokens = await this.getTokens(options);\n if (tokens) {\n userSub = tokens.accessToken?.payload?.sub;\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n tokens,\n authenticated: true,\n forceRefresh: options.forceRefresh,\n });\n }\n else {\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n authenticated: false,\n forceRefresh: options.forceRefresh,\n });\n }\n return {\n tokens,\n credentials: credentialsAndIdentityId?.credentials,\n identityId: credentialsAndIdentityId?.identityId,\n userSub,\n };\n }\n async clearCredentials() {\n await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId();\n }\n async getTokens(options) {\n return ((await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined);\n }\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,GAAG,EAAE;AAC3D,IAAI,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACnC,IAAI,OAAO,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAChD,CAAC;AACM,MAAM,SAAS,CAAC;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,mBAAmB,EAAE,WAAW,EAAE;AAChD,QAAQ,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC;AAC9C,QAAQ,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;AACvC,KAAK;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,EAAE;AAC7B,QAAQ,QAAQ,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;AAC1F,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/singleton/Auth/index.ts"],"sourcesContent":["export function isTokenExpired({ expiresAt, clockDrift, tolerance = 5000, }) {\n const currentTime = Date.now();\n return currentTime + clockDrift + tolerance > expiresAt;\n}\nexport class AuthClass {\n /**\n * Configure Auth category\n *\n * @internal\n *\n * @param authResourcesConfig - Resources configurations required by Auth providers.\n * @param authOptions - Client options used by library\n *\n * @returns void\n */\n configure(authResourcesConfig, authOptions) {\n this.authConfig = authResourcesConfig;\n this.authOptions = authOptions;\n }\n /**\n * Fetch the auth tokens, and the temporary AWS credentials and identity if they are configured. By default it\n * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh\n * with `{ forceRefresh: true }` input.\n *\n * @param options - Options configuring the fetch behavior.\n *\n * @returns Promise of current auth session {@link AuthSession}.\n */\n async fetchAuthSession(options = {}) {\n let credentialsAndIdentityId;\n let userSub;\n // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available\n const tokens = await this.getTokens(options);\n if (tokens) {\n userSub = tokens.accessToken?.payload?.sub;\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n tokens,\n authenticated: true,\n forceRefresh: options.forceRefresh,\n });\n }\n else {\n // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n credentialsAndIdentityId =\n await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n authConfig: this.authConfig,\n authenticated: false,\n forceRefresh: options.forceRefresh,\n });\n }\n return {\n tokens,\n credentials: credentialsAndIdentityId?.credentials,\n identityId: credentialsAndIdentityId?.identityId,\n userSub,\n };\n }\n async clearCredentials() {\n await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId();\n }\n async getTokens(options) {\n return ((await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined);\n }\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,GAAG,IAAI,GAAG,EAAE;AAC7E,IAAI,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACnC,IAAI,OAAO,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAC5D,CAAC;AACM,MAAM,SAAS,CAAC;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,CAAC,mBAAmB,EAAE,WAAW,EAAE;AAChD,QAAQ,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC;AAC9C,QAAQ,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;AACvC,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,CAAC,OAAO,GAAG,EAAE,EAAE;AACzC,QAAQ,IAAI,wBAAwB,CAAC;AACrC,QAAQ,IAAI,OAAO,CAAC;AACpB;AACA,QAAQ,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACrD,QAAQ,IAAI,MAAM,EAAE;AACpB,YAAY,OAAO,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC;AACvD;AACA,YAAY,wBAAwB;AACpC,gBAAgB,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,2BAA2B,CAAC;AACzF,oBAAoB,UAAU,EAAE,IAAI,CAAC,UAAU;AAC/C,oBAAoB,MAAM;AAC1B,oBAAoB,aAAa,EAAE,IAAI;AACvC,oBAAoB,YAAY,EAAE,OAAO,CAAC,YAAY;AACtD,iBAAiB,CAAC,CAAC;AACnB,SAAS;AACT,aAAa;AACb;AACA,YAAY,wBAAwB;AACpC,gBAAgB,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,2BAA2B,CAAC;AACzF,oBAAoB,UAAU,EAAE,IAAI,CAAC,UAAU;AAC/C,oBAAoB,aAAa,EAAE,KAAK;AACxC,oBAAoB,YAAY,EAAE,OAAO,CAAC,YAAY;AACtD,iBAAiB,CAAC,CAAC;AACnB,SAAS;AACT,QAAQ,OAAO;AACf,YAAY,MAAM;AAClB,YAAY,WAAW,EAAE,wBAAwB,EAAE,WAAW;AAC9D,YAAY,UAAU,EAAE,wBAAwB,EAAE,UAAU;AAC5D,YAAY,OAAO;AACnB,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,MAAM,IAAI,CAAC,WAAW,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,CAAC;AACrF,KAAK;AACL,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE;AAC7B,QAAQ,QAAQ,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;AAC1F,KAAK;AACL;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/core",
3
- "version": "6.7.0",
3
+ "version": "6.7.1-token-exp-tolerance.3d6e9db.0+3d6e9db",
4
4
  "description": "Core category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -60,7 +60,7 @@
60
60
  "uuid": "^9.0.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@aws-amplify/react-native": "1.1.6",
63
+ "@aws-amplify/react-native": "1.1.7-token-exp-tolerance.3d6e9db.0+3d6e9db",
64
64
  "@types/js-cookie": "3.0.2",
65
65
  "genversion": "^2.2.0",
66
66
  "typescript": "5.0.2"
@@ -192,5 +192,5 @@
192
192
  ]
193
193
  }
194
194
  },
195
- "gitHead": "9fb4fc24621febe0faad226ab2edb696b8a0bc9c"
195
+ "gitHead": "3d6e9db23bb9f1c8db7b2026a68b93187e56b77a"
196
196
  }
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '6.10.0';
2
+ export const version = '6.10.1-token-exp-tolerance.3d6e9db.0+3d6e9db';
@@ -42,7 +42,7 @@ export interface AmplifyOutputsAuthProperties {
42
42
  unauthenticated_identities_enabled?: boolean;
43
43
  mfa_configuration?: string;
44
44
  mfa_methods?: string[];
45
- groups?: Record<UserGroupName, UserGroupPrecedence>[];
45
+ groups?: Partial<Record<UserGroupName, UserGroupPrecedence>>[];
46
46
  }
47
47
 
48
48
  export interface AmplifyOutputsStorageBucketProperties {
@@ -12,13 +12,15 @@ import {
12
12
  export function isTokenExpired({
13
13
  expiresAt,
14
14
  clockDrift,
15
+ tolerance = 5000,
15
16
  }: {
16
17
  expiresAt: number;
17
18
  clockDrift: number;
19
+ tolerance?: number;
18
20
  }): boolean {
19
21
  const currentTime = Date.now();
20
22
 
21
- return currentTime + clockDrift > expiresAt;
23
+ return currentTime + clockDrift + tolerance > expiresAt;
22
24
  }
23
25
 
24
26
  export class AuthClass {