@aws-amplify/auth
Version:
Auth category of aws-amplify
1 lines • 1.9 kB
Source Map (JSON)
{"version":3,"file":"dispatchSignedInHubEvent.mjs","sources":["../../../../../src/providers/cognito/utils/dispatchSignedInHubEvent.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Hub } from '@aws-amplify/core';\nimport { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';\nimport { getCurrentUser } from '../apis/getCurrentUser';\nimport { UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION, USER_UNAUTHENTICATED_EXCEPTION, } from '../../../errors/constants';\nimport { AuthError } from '../../../errors/AuthError';\nexport const ERROR_MESSAGE = 'Unable to get user session following successful sign-in.';\nexport const dispatchSignedInHubEvent = async () => {\n try {\n Hub.dispatch('auth', {\n event: 'signedIn',\n data: await getCurrentUser(),\n }, 'Auth', AMPLIFY_SYMBOL);\n }\n catch (error) {\n if (error.name === USER_UNAUTHENTICATED_EXCEPTION) {\n throw new AuthError({\n name: UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION,\n message: ERROR_MESSAGE,\n recoverySuggestion: 'This most likely is due to auth tokens not being persisted. If you are using cookie store, please ensure cookies can be correctly set from your server.',\n });\n }\n throw error;\n }\n};\n"],"names":[],"mappings":";;;;;;AAAA;AACA;AAMY,MAAC,aAAa,GAAG;AACjB,MAAC,wBAAwB,GAAG,YAAY;AACpD,IAAI,IAAI;AACR,QAAQ,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE;AAC7B,YAAY,KAAK,EAAE,UAAU;AAC7B,YAAY,IAAI,EAAE,MAAM,cAAc,EAAE;AACxC,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC;AAClC;AACA,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,8BAA8B,EAAE;AAC3D,YAAY,MAAM,IAAI,SAAS,CAAC;AAChC,gBAAgB,IAAI,EAAE,yCAAyC;AAC/D,gBAAgB,OAAO,EAAE,aAAa;AACtC,gBAAgB,kBAAkB,EAAE,yJAAyJ;AAC7L,aAAa,CAAC;AACd;AACA,QAAQ,MAAM,KAAK;AACnB;AACA;;;;"}