UNPKG

@aws-amplify/core

Version:

Core category of aws-amplify

32 lines (30 loc) • 1.28 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.selectSsrKeyValueStorage = selectSsrKeyValueStorage; const storage_1 = require("../storage"); /** * Selects the key-value storage backing the default auth providers based on * the `ssr` library option: * * - `ssr: true` → a **fresh** cookie-based storage (`sameSite: 'lax'`), so * tokens survive server-side rendering round-trips. Callers that also need * a cookie-backed identity-id store (e.g. the `aws-amplify` umbrella's * default Cognito credentials provider) should reuse the returned instance * for it. * - otherwise → the shared {@link defaultStorage} (`localStorage`-backed) * singleton. * * Extracted from the `aws-amplify` umbrella's library-options resolution so * the SSR storage choice lives in a single place. * * @param ssr - The `LibraryOptions.ssr` flag. * @returns The key-value storage to back token/credentials providers with. * * @internal */ function selectSsrKeyValueStorage(ssr) { return ssr ? new storage_1.CookieStorage({ sameSite: 'lax' }) : storage_1.defaultStorage; } //# sourceMappingURL=selectSsrKeyValueStorage.js.map