UNPKG

@aws-amplify/core

Version:

Core category of aws-amplify

31 lines (29 loc) • 1.34 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.isUnconfiguredNoCtxCall = isUnconfiguredNoCtxCall; const contextBrand_1 = require("../../context/contextBrand"); const globalContext_1 = require("../../context/globalContext"); /** * Returns `true` when a call would fall back to the global `AmplifyContext` * but none has been set yet (i.e. `Amplify.configure()` has not run). * * The pre-context library did not throw for this case — it operated on the * unconfigured singleton, whose `AuthClass` optional-chains its (missing) * providers. `fetchAuthSession`/`clearCredentials` use this predicate to * preserve that behavior for the no-context form. * * The `resolveCtxArgs` guard cases are deliberately excluded so their typed * errors keep throwing: * - a branded context anywhere in `args` (explicit-context or mis-ordered); * - an explicitly-`undefined` leading context followed by more arguments. * * @internal */ function isUnconfiguredNoCtxCall(args) { return (!(0, globalContext_1.hasGlobalContext)() && !args.some(contextBrand_1.isAmplifyContext) && !(args.length > 1 && args[0] === undefined)); } //# sourceMappingURL=isUnconfiguredNoCtxCall.js.map