UNPKG

@clerk/shared

Version:

Internal package utils used by the Clerk SDKs

1 lines 2.35 kB
{"version":3,"file":"navigateToNextStepSignUp.mjs","names":[],"sources":["../../../src/internal/clerk-js/navigateToNextStepSignUp.ts"],"sourcesContent":["import type { SignUpResource } from '../../types';\nimport { completeSignUpFlow } from './completeSignUpFlow';\n\ntype NavigateToNextStepSignUpProps = {\n signUp: SignUpResource;\n continueSignUpUrl: string;\n verifyEmailAddressUrl: string;\n verifyPhoneNumberUrl: string;\n signUpProtectCheckUrl: string;\n navigate: (to: string, options?: { searchParams?: URLSearchParams }) => Promise<unknown>;\n};\n\n/**\n * Routes a sign-up that's still in `missing_requirements` to the appropriate\n * next step:\n *\n * - If the sign-up is protect-gated, go to the protect-check challenge.\n * - Otherwise, if there are missing fields, go straight to the continue page so\n * the user can fill them in.\n * - Otherwise, hand off to `completeSignUpFlow` which routes unverified email\n * or phone identifications to their respective verify pages.\n *\n * Used by both the OAuth callback handler and the sign-in `signUpIfMissing`\n * transfer flow so they stay in lockstep.\n *\n * @internal\n */\nexport const navigateToNextStepSignUp = ({\n signUp,\n continueSignUpUrl,\n verifyEmailAddressUrl,\n verifyPhoneNumberUrl,\n signUpProtectCheckUrl,\n navigate,\n}: NavigateToNextStepSignUpProps): Promise<unknown> | undefined => {\n // A protect-gated sign-up always carries 'protect_check' in missing_fields, so this gate\n // check must run BEFORE the generic missing-fields short-circuit below — otherwise the\n // callback would land on /continue instead of the challenge.\n if (signUp.protectCheck || signUp.missingFields.includes('protect_check')) {\n return navigate(signUpProtectCheckUrl);\n }\n\n if (signUp.missingFields.length) {\n return navigate(continueSignUpUrl);\n }\n\n return completeSignUpFlow({\n signUp,\n verifyEmailPath: verifyEmailAddressUrl,\n verifyPhonePath: verifyPhoneNumberUrl,\n protectCheckPath: signUpProtectCheckUrl,\n navigate,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,MAAa,4BAA4B,EACvC,QACA,mBACA,uBACA,sBACA,uBACA,eACiE;CAIjE,IAAI,OAAO,gBAAgB,OAAO,cAAc,SAAS,eAAe,GACtE,OAAO,SAAS,qBAAqB;CAGvC,IAAI,OAAO,cAAc,QACvB,OAAO,SAAS,iBAAiB;CAGnC,OAAO,mBAAmB;EACxB;EACA,iBAAiB;EACjB,iBAAiB;EACjB,kBAAkB;EAClB;CACF,CAAC;AACH"}