{"version":3,"file":"index.mjs","sources":["../../../../src/singleton/Auth/index.ts"],"sourcesContent":["export class AuthClass {\n    /**\n     * Configure Auth category\n     *\n     * @internal\n     *\n     * @param authResourcesConfig - Resources configurations required by Auth providers.\n     * @param authOptions - Client options used by library\n     *\n     * @returns void\n     */\n    configure(authResourcesConfig, authOptions) {\n        this.authConfig = authResourcesConfig;\n        this.authOptions = authOptions;\n    }\n    /**\n     * Fetch the auth tokens, and the temporary AWS credentials and identity if they are configured. By default it\n     * does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh\n     * with `{ forceRefresh: true }` input.\n     *\n     * @param options - Options configuring the fetch behavior.\n     *\n     * @returns Promise of current auth session {@link AuthSession}.\n     */\n    async fetchAuthSession(options = {}) {\n        let credentialsAndIdentityId;\n        let userSub;\n        // Get tokens will throw if session cannot be refreshed (network or service error) or return null if not available\n        const tokens = await this.getTokens(options);\n        if (tokens) {\n            userSub = tokens.accessToken?.payload?.sub;\n            // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n            credentialsAndIdentityId =\n                await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n                    authConfig: this.authConfig,\n                    tokens,\n                    authenticated: true,\n                    forceRefresh: options.forceRefresh,\n                });\n        }\n        else {\n            // getCredentialsAndIdentityId will throw if cannot get credentials (network or service error)\n            credentialsAndIdentityId =\n                await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({\n                    authConfig: this.authConfig,\n                    authenticated: false,\n                    forceRefresh: options.forceRefresh,\n                });\n        }\n        return {\n            tokens,\n            credentials: credentialsAndIdentityId?.credentials,\n            identityId: credentialsAndIdentityId?.identityId,\n            userSub,\n        };\n    }\n    async clearCredentials() {\n        await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId();\n    }\n    async getTokens(options) {\n        return ((await this.authOptions?.tokenProvider?.getTokens(options)) ?? undefined);\n    }\n}\n"],"names":[],"mappings":"AAAO,MAAM,SAAS,CAAC;AACvB;AACA;AACA;AACA;A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