// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import { urlSafeEncode } from 'aws-amplify/adapter-core/internals'; import { generateCodeVerifier, generateState } from 'aws-amplify/adapter-core'; export const createAuthFlowProofs = ({ customState, }: { customState?: string; }): { codeVerifier: ReturnType; state: string; } => { const codeVerifier = generateCodeVerifier(128); const randomState = generateState(); const state = customState ? `${randomState}-${urlSafeEncode(customState)}` : randomState; return { codeVerifier, state }; };