@aws-amplify/auth 6.4.3-unstable.fab71a7.0 → 6.5.1-unstable.6891c04.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.
@@ -17,6 +17,7 @@ class DefaultIdentityIdStore {
17
17
  }
18
18
  constructor(keyValueStorage) {
19
19
  this._authKeys = {};
20
+ this._hasGuestIdentityId = false;
20
21
  this.keyValueStorage = keyValueStorage;
21
22
  }
22
23
  async loadIdentityId() {
@@ -31,6 +32,7 @@ class DefaultIdentityIdStore {
31
32
  else {
32
33
  const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);
33
34
  if (storedIdentityId) {
35
+ this._hasGuestIdentityId = true;
34
36
  return {
35
37
  id: storedIdentityId,
36
38
  type: 'guest',
@@ -50,11 +52,15 @@ class DefaultIdentityIdStore {
50
52
  this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);
51
53
  // Clear in-memory storage of primary identityId
52
54
  this._primaryIdentityId = undefined;
55
+ this._hasGuestIdentityId = true;
53
56
  }
54
57
  else {
55
58
  this._primaryIdentityId = identity.id;
56
59
  // Clear locally stored guest id
57
- this.keyValueStorage.removeItem(this._authKeys.identityId);
60
+ if (this._hasGuestIdentityId) {
61
+ this.keyValueStorage.removeItem(this._authKeys.identityId);
62
+ this._hasGuestIdentityId = false;
63
+ }
58
64
  }
59
65
  }
60
66
  async clearIdentityId() {
@@ -1 +1 @@
1
- {"version":3,"file":"IdentityIdStore.js","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdStore.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DefaultIdentityIdStore = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst TokenStore_1 = require(\"../tokenProvider/TokenStore\");\nconst types_1 = require(\"./types\");\nconst logger = new core_1.ConsoleLogger('DefaultIdentityIdStore');\nclass DefaultIdentityIdStore {\n setAuthConfig(authConfigParam) {\n (0, utils_1.assertIdentityPoolIdConfig)(authConfigParam.Cognito);\n this.authConfig = authConfigParam;\n this._authKeys = createKeysForAuthStorage('Cognito', authConfigParam.Cognito.identityPoolId);\n }\n constructor(keyValueStorage) {\n this._authKeys = {};\n this.keyValueStorage = keyValueStorage;\n }\n async loadIdentityId() {\n (0, utils_1.assertIdentityPoolIdConfig)(this.authConfig?.Cognito);\n try {\n if (this._primaryIdentityId) {\n return {\n id: this._primaryIdentityId,\n type: 'primary',\n };\n }\n else {\n const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);\n if (storedIdentityId) {\n return {\n id: storedIdentityId,\n type: 'guest',\n };\n }\n return null;\n }\n }\n catch (err) {\n logger.log('Error getting stored IdentityId.', err);\n return null;\n }\n }\n async storeIdentityId(identity) {\n (0, utils_1.assertIdentityPoolIdConfig)(this.authConfig?.Cognito);\n if (identity.type === 'guest') {\n this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);\n // Clear in-memory storage of primary identityId\n this._primaryIdentityId = undefined;\n }\n else {\n this._primaryIdentityId = identity.id;\n // Clear locally stored guest id\n this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n }\n async clearIdentityId() {\n this._primaryIdentityId = undefined;\n await this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n}\nexports.DefaultIdentityIdStore = DefaultIdentityIdStore;\nconst createKeysForAuthStorage = (provider, identifier) => {\n return (0, TokenStore_1.getAuthStorageKeys)(types_1.IdentityIdStorageKeys)(`com.amplify.${provider}`, identifier);\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,MAAM,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BAAkB,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACtH,CAAC;;"}
1
+ {"version":3,"file":"IdentityIdStore.js","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdStore.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DefaultIdentityIdStore = void 0;\nconst core_1 = require(\"@aws-amplify/core\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst TokenStore_1 = require(\"../tokenProvider/TokenStore\");\nconst types_1 = require(\"./types\");\nconst logger = new core_1.ConsoleLogger('DefaultIdentityIdStore');\nclass DefaultIdentityIdStore {\n setAuthConfig(authConfigParam) {\n (0, utils_1.assertIdentityPoolIdConfig)(authConfigParam.Cognito);\n this.authConfig = authConfigParam;\n this._authKeys = createKeysForAuthStorage('Cognito', authConfigParam.Cognito.identityPoolId);\n }\n constructor(keyValueStorage) {\n this._authKeys = {};\n this._hasGuestIdentityId = false;\n this.keyValueStorage = keyValueStorage;\n }\n async loadIdentityId() {\n (0, utils_1.assertIdentityPoolIdConfig)(this.authConfig?.Cognito);\n try {\n if (this._primaryIdentityId) {\n return {\n id: this._primaryIdentityId,\n type: 'primary',\n };\n }\n else {\n const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);\n if (storedIdentityId) {\n this._hasGuestIdentityId = true;\n return {\n id: storedIdentityId,\n type: 'guest',\n };\n }\n return null;\n }\n }\n catch (err) {\n logger.log('Error getting stored IdentityId.', err);\n return null;\n }\n }\n async storeIdentityId(identity) {\n (0, utils_1.assertIdentityPoolIdConfig)(this.authConfig?.Cognito);\n if (identity.type === 'guest') {\n this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);\n // Clear in-memory storage of primary identityId\n this._primaryIdentityId = undefined;\n this._hasGuestIdentityId = true;\n }\n else {\n this._primaryIdentityId = identity.id;\n // Clear locally stored guest id\n if (this._hasGuestIdentityId) {\n this.keyValueStorage.removeItem(this._authKeys.identityId);\n this._hasGuestIdentityId = false;\n }\n }\n }\n async clearIdentityId() {\n this._primaryIdentityId = undefined;\n await this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n}\nexports.DefaultIdentityIdStore = DefaultIdentityIdStore;\nconst createKeysForAuthStorage = (provider, identifier) => {\n return (0, TokenStore_1.getAuthStorageKeys)(types_1.IdentityIdStorageKeys)(`com.amplify.${provider}`, identifier);\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACxC,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;AAClE,MAAM,sBAAsB,CAAC;AAC7B,IAAI,aAAa,CAAC,eAAe,EAAE;AACnC,QAAQ,IAAI,OAAO,CAAC,0BAA0B,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;AACzE,QAAQ,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC;AAC1C,QAAQ,IAAI,CAAC,SAAS,GAAG,wBAAwB,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,WAAW,CAAC,eAAe,EAAE;AACjC,QAAQ,IAAI,CAAC,SAAS,GAAG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C,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;AACjF;AACA,YAAY,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;AAChD,YAAY,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;AAC5C,SAAS;AACT,aAAa;AACb,YAAY,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC,EAAE,CAAC;AAClD;AACA,YAAY,IAAI,IAAI,CAAC,mBAAmB,EAAE;AAC1C,gBAAgB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC3E,gBAAgB,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;AACjD,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;AAC5C,QAAQ,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACzE,KAAK;AACL,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;AACxD,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK;AAC3D,IAAI,OAAO,IAAI,YAAY,CAAC,kBAAkB,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACtH,CAAC;;"}
@@ -6,6 +6,7 @@ export declare class DefaultIdentityIdStore implements IdentityIdStore {
6
6
  authConfig?: AuthConfig;
7
7
  _primaryIdentityId: string | undefined;
8
8
  _authKeys: AuthKeys<string>;
9
+ _hasGuestIdentityId: boolean;
9
10
  setAuthConfig(authConfigParam: AuthConfig): void;
10
11
  constructor(keyValueStorage: KeyValueStorageInterface);
11
12
  loadIdentityId(): Promise<Identity | null>;
@@ -14,6 +14,7 @@ class DefaultIdentityIdStore {
14
14
  }
15
15
  constructor(keyValueStorage) {
16
16
  this._authKeys = {};
17
+ this._hasGuestIdentityId = false;
17
18
  this.keyValueStorage = keyValueStorage;
18
19
  }
19
20
  async loadIdentityId() {
@@ -28,6 +29,7 @@ class DefaultIdentityIdStore {
28
29
  else {
29
30
  const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);
30
31
  if (storedIdentityId) {
32
+ this._hasGuestIdentityId = true;
31
33
  return {
32
34
  id: storedIdentityId,
33
35
  type: 'guest',
@@ -47,11 +49,15 @@ class DefaultIdentityIdStore {
47
49
  this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);
48
50
  // Clear in-memory storage of primary identityId
49
51
  this._primaryIdentityId = undefined;
52
+ this._hasGuestIdentityId = true;
50
53
  }
51
54
  else {
52
55
  this._primaryIdentityId = identity.id;
53
56
  // Clear locally stored guest id
54
- this.keyValueStorage.removeItem(this._authKeys.identityId);
57
+ if (this._hasGuestIdentityId) {
58
+ this.keyValueStorage.removeItem(this._authKeys.identityId);
59
+ this._hasGuestIdentityId = false;
60
+ }
55
61
  }
56
62
  }
57
63
  async clearIdentityId() {
@@ -1 +1 @@
1
- {"version":3,"file":"IdentityIdStore.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig } from '@aws-amplify/core/internals/utils';\nimport { getAuthStorageKeys } from '../tokenProvider/TokenStore';\nimport { IdentityIdStorageKeys } from './types';\nconst logger = new ConsoleLogger('DefaultIdentityIdStore');\nexport class DefaultIdentityIdStore {\n setAuthConfig(authConfigParam) {\n assertIdentityPoolIdConfig(authConfigParam.Cognito);\n this.authConfig = authConfigParam;\n this._authKeys = createKeysForAuthStorage('Cognito', authConfigParam.Cognito.identityPoolId);\n }\n constructor(keyValueStorage) {\n this._authKeys = {};\n this.keyValueStorage = keyValueStorage;\n }\n async loadIdentityId() {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n try {\n if (this._primaryIdentityId) {\n return {\n id: this._primaryIdentityId,\n type: 'primary',\n };\n }\n else {\n const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);\n if (storedIdentityId) {\n return {\n id: storedIdentityId,\n type: 'guest',\n };\n }\n return null;\n }\n }\n catch (err) {\n logger.log('Error getting stored IdentityId.', err);\n return null;\n }\n }\n async storeIdentityId(identity) {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n if (identity.type === 'guest') {\n this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);\n // Clear in-memory storage of primary identityId\n this._primaryIdentityId = undefined;\n }\n else {\n this._primaryIdentityId = identity.id;\n // Clear locally stored guest id\n this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n }\n async clearIdentityId() {\n this._primaryIdentityId = undefined;\n await this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n}\nconst createKeysForAuthStorage = (provider, identifier) => {\n return getAuthStorageKeys(IdentityIdStorageKeys)(`com.amplify.${provider}`, identifier);\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,wBAAwB,CAAC,CAAC;AACpD,MAAM,sBAAsB,CAAC;AACpC,IAAI,aAAa,CAAC,eAAe,EAAE;AACnC,QAAQ,0BAA0B,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAC5D,QAAQ,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC;AAC1C,QAAQ,IAAI,CAAC,SAAS,GAAG,wBAAwB,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,WAAW,CAAC,eAAe,EAAE;AACjC,QAAQ,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;AAC5B,QAAQ,IAA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BAAkB,GAAG,QAAQ,CAAC,EAAE,CAAC;AAClD;AACA,YAAY,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACvE,SAAS;AACT,KAAK;AACL,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;AAC5C,QAAQ,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACzE,KAAK;AACL,CAAC;AACD,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK;AAC3D,IAAI,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAC5F,CAAC;;;;"}
1
+ {"version":3,"file":"IdentityIdStore.mjs","sources":["../../../../../src/providers/cognito/credentialsProvider/IdentityIdStore.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger, } from '@aws-amplify/core';\nimport { assertIdentityPoolIdConfig } from '@aws-amplify/core/internals/utils';\nimport { getAuthStorageKeys } from '../tokenProvider/TokenStore';\nimport { IdentityIdStorageKeys } from './types';\nconst logger = new ConsoleLogger('DefaultIdentityIdStore');\nexport class DefaultIdentityIdStore {\n setAuthConfig(authConfigParam) {\n assertIdentityPoolIdConfig(authConfigParam.Cognito);\n this.authConfig = authConfigParam;\n this._authKeys = createKeysForAuthStorage('Cognito', authConfigParam.Cognito.identityPoolId);\n }\n constructor(keyValueStorage) {\n this._authKeys = {};\n this._hasGuestIdentityId = false;\n this.keyValueStorage = keyValueStorage;\n }\n async loadIdentityId() {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n try {\n if (this._primaryIdentityId) {\n return {\n id: this._primaryIdentityId,\n type: 'primary',\n };\n }\n else {\n const storedIdentityId = await this.keyValueStorage.getItem(this._authKeys.identityId);\n if (storedIdentityId) {\n this._hasGuestIdentityId = true;\n return {\n id: storedIdentityId,\n type: 'guest',\n };\n }\n return null;\n }\n }\n catch (err) {\n logger.log('Error getting stored IdentityId.', err);\n return null;\n }\n }\n async storeIdentityId(identity) {\n assertIdentityPoolIdConfig(this.authConfig?.Cognito);\n if (identity.type === 'guest') {\n this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);\n // Clear in-memory storage of primary identityId\n this._primaryIdentityId = undefined;\n this._hasGuestIdentityId = true;\n }\n else {\n this._primaryIdentityId = identity.id;\n // Clear locally stored guest id\n if (this._hasGuestIdentityId) {\n this.keyValueStorage.removeItem(this._authKeys.identityId);\n this._hasGuestIdentityId = false;\n }\n }\n }\n async clearIdentityId() {\n this._primaryIdentityId = undefined;\n await this.keyValueStorage.removeItem(this._authKeys.identityId);\n }\n}\nconst createKeysForAuthStorage = (provider, identifier) => {\n return getAuthStorageKeys(IdentityIdStorageKeys)(`com.amplify.${provider}`, identifier);\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,wBAAwB,CAAC,CAAC;AACpD,MAAM,sBAAsB,CAAC;AACpC,IAAI,aAAa,CAAC,eAAe,EAAE;AACnC,QAAQ,0BAA0B,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAC5D,QAAQ,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC;AAC1C,QAAQ,IAAI,CAAC,SAAS,GAAG,wBAAwB,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,WAAW,CAAC,eAAe,EAAE;AACjC,QAAQ,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;AAC5B,QAAQ,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;AACzC,QAAQ,IAAI,CAAC,eAAe,GAAG,eAAe,CAA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mBAAmB,GAAG,IAAI,CAAC;AAC5C,SAAS;AACT,aAAa;AACb,YAAY,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC,EAAE,CAAC;AAClD;AACA,YAAY,IAAI,IAAI,CAAC,mBAAmB,EAAE;AAC1C,gBAAgB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC3E,gBAAgB,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;AACjD,aAAa;AACb,SAAS;AACT,KAAK;AACL,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;AAC5C,QAAQ,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AACzE,KAAK;AACL,CAAC;AACD,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK;AAC3D,IAAI,OAAO,kBAAkB,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAC5F,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/auth",
3
- "version": "6.4.3-unstable.fab71a7.0+fab71a7",
3
+ "version": "6.5.1-unstable.6891c04.0+6891c04",
4
4
  "description": "Auth category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -94,13 +94,13 @@
94
94
  "tslib": "^2.5.0"
95
95
  },
96
96
  "peerDependencies": {
97
- "@aws-amplify/core": "6.4.3-unstable.fab71a7.0+fab71a7"
97
+ "@aws-amplify/core": "6.4.4-unstable.6891c04.0+6891c04"
98
98
  },
99
99
  "devDependencies": {
100
- "@aws-amplify/core": "6.4.3-unstable.fab71a7.0+fab71a7",
101
- "@aws-amplify/react-native": "1.1.6-unstable.fab71a7.0+fab71a7",
100
+ "@aws-amplify/core": "6.4.4-unstable.6891c04.0+6891c04",
101
+ "@aws-amplify/react-native": "1.1.7-unstable.6891c04.0+6891c04",
102
102
  "@jest/test-sequencer": "^29.7.0",
103
103
  "typescript": "5.0.2"
104
104
  },
105
- "gitHead": "fab71a7e68c7553715682c385690f877e0d1e694"
105
+ "gitHead": "6891c049b44e1e83506b122aca0798aaf3dceb5a"
106
106
  }
@@ -23,6 +23,8 @@ export class DefaultIdentityIdStore implements IdentityIdStore {
23
23
  // Used as in-memory storage
24
24
  _primaryIdentityId: string | undefined;
25
25
  _authKeys: AuthKeys<string> = {};
26
+ _hasGuestIdentityId = false;
27
+
26
28
  setAuthConfig(authConfigParam: AuthConfig) {
27
29
  assertIdentityPoolIdConfig(authConfigParam.Cognito);
28
30
  this.authConfig = authConfigParam;
@@ -48,7 +50,10 @@ export class DefaultIdentityIdStore implements IdentityIdStore {
48
50
  const storedIdentityId = await this.keyValueStorage.getItem(
49
51
  this._authKeys.identityId,
50
52
  );
53
+
51
54
  if (storedIdentityId) {
55
+ this._hasGuestIdentityId = true;
56
+
52
57
  return {
53
58
  id: storedIdentityId,
54
59
  type: 'guest',
@@ -71,10 +76,14 @@ export class DefaultIdentityIdStore implements IdentityIdStore {
71
76
  this.keyValueStorage.setItem(this._authKeys.identityId, identity.id);
72
77
  // Clear in-memory storage of primary identityId
73
78
  this._primaryIdentityId = undefined;
79
+ this._hasGuestIdentityId = true;
74
80
  } else {
75
81
  this._primaryIdentityId = identity.id;
76
82
  // Clear locally stored guest id
77
- this.keyValueStorage.removeItem(this._authKeys.identityId);
83
+ if (this._hasGuestIdentityId) {
84
+ this.keyValueStorage.removeItem(this._authKeys.identityId);
85
+ this._hasGuestIdentityId = false;
86
+ }
78
87
  }
79
88
  }
80
89