UNPKG

@aws-amplify/auth

Version:
1 lines 1.46 kB
{"version":3,"file":"retryOnResourceNotFoundException.mjs","sources":["../../../../../src/providers/cognito/utils/retryOnResourceNotFoundException.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { AuthError } from '../../../errors/AuthError';\n/**\n * It will retry the function if the error is a `ResourceNotFoundException` and\n * will clean the device keys stored in the storage mechanism.\n *\n */\nexport async function retryOnResourceNotFoundException(func, args, username, tokenOrchestrator) {\n try {\n return await func(...args);\n }\n catch (error) {\n if (error instanceof AuthError &&\n error.name === 'ResourceNotFoundException' &&\n error.message.includes('Device does not exist.')) {\n await tokenOrchestrator.clearDeviceMetadata(username);\n return func(...args);\n }\n throw error;\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACO,eAAe,gCAAgC,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE;AAChG,IAAI,IAAI;AACR,QAAQ,OAAO,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;AAClC;AACA,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,IAAI,KAAK,YAAY,SAAS;AACtC,YAAY,KAAK,CAAC,IAAI,KAAK,2BAA2B;AACtD,YAAY,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE;AAC9D,YAAY,MAAM,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC;AACjE,YAAY,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC;AAChC;AACA,QAAQ,MAAM,KAAK;AACnB;AACA;;;;"}