@aws-amplify/core
Version:
Core category of aws-amplify
28 lines (25 loc) • 1.21 kB
JavaScript
import { resolveCtxArgs } from '../../context/resolveCtxArgs.mjs';
import { isUnconfiguredNoCtxCall } from './isUnconfiguredNoCtxCall.mjs';
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
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 (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] = resolveCtxArgs(args);
return ctx.fetchAuthSession(options);
}
export { fetchAuthSession };
//# sourceMappingURL=fetchAuthSession.mjs.map