UNPKG

@aws-amplify/core

Version:

Core category of aws-amplify

29 lines (27 loc) • 1.35 kB
'use strict'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchAuthSession = fetchAuthSession; const resolveCtxArgs_1 = require("../../context/resolveCtxArgs"); const isUnconfiguredNoCtxCall_1 = require("./isUnconfiguredNoCtxCall"); function fetchAuthSession(...args) { // Back-compat: before the context migration, `fetchAuthSession()` on an // unconfigured Amplify resolved with an empty session (the unconfigured // `AuthClass` optional-chains its missing providers) rather than throwing. // Preserve that for the no-context form; the typed guards in // `resolveCtxArgs` still apply to explicit / mis-ordered context arguments. if ((0, isUnconfiguredNoCtxCall_1.isUnconfiguredNoCtxCall)(args)) { return Promise.resolve({ tokens: undefined, credentials: undefined, identityId: undefined, userSub: undefined, }); } // `resolveCtxArgs` handles the global-context fallback plus the // mis-ordered / undefined-context guards used across all category APIs. const [ctx, options] = (0, resolveCtxArgs_1.resolveCtxArgs)(args); return ctx.fetchAuthSession(options); } //# sourceMappingURL=fetchAuthSession.js.map