Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clerk/backend

Package Overview
Dependencies
Maintainers
7
Versions
2058
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clerk/backend - npm Package Compare versions

Comparing version 0.23.1-snapshot.e5d9418 to 0.23.1-snapshot.fe3ca7b

20

dist/esm/index.js

@@ -1,2 +0,2 @@

var m=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var qe="/",Gt=new RegExp(qe+"{1,}","g");function l(...t){return t.filter(e=>e).join(qe).replace(Gt,qe)}var Ke="/allowlist_identifiers",ce=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Ke})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Ke,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ke,e)})}};var ze="/clients",pe=class extends m{async getClientList(){return this.request({method:"GET",path:ze})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(ze,e)})}verifyClient(e){return this.request({method:"POST",path:l(ze,"verify"),bodyParams:{token:e}})}};var Ht="/domains",me=class extends m{async deleteDomain(e){return this.request({method:"DELETE",path:l(Ht,e)})}};var ge="/email_addresses",fe=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(ge,e)})}async createEmailAddress(e){return this.request({method:"POST",path:ge,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(ge,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(ge,e)})}};var Yt="/emails",ye=class extends m{async createEmail(e){return this.request({method:"POST",path:Yt,bodyParams:e})}};var he=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var Le="/invitations",be=class extends m{async getInvitationList(){return this.request({method:"GET",path:Le})}async createInvitation(e){return this.request({method:"POST",path:Le,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(Le,e,"revoke")})}};var w="/organizations",Se=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var Oe="/phone_numbers",ke=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(Oe,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:Oe,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(Oe,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(Oe,e)})}};var Pe="/redirect_urls",_e=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:Pe})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Pe,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Pe,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Pe,e)})}};var se="/sessions",Ie=class extends m{async getSessionList(e){return this.request({method:"GET",path:se,queryParams:e})}async getSession(e){return this.requireId(e),this.request({method:"GET",path:l(se,e)})}async revokeSession(e){return this.requireId(e),this.request({method:"POST",path:l(se,e,"revoke")})}async verifySession(e,r){return this.requireId(e),this.request({method:"POST",path:l(se,e,"verify"),bodyParams:{token:r}})}async getToken(e,r){return this.requireId(e),(await this.request({method:"POST",path:l(se,e,"tokens",r||"")})).jwt}};var et="/sign_in_tokens",Ae=class extends m{async createSignInToken(e){return this.request({method:"POST",path:et,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(et,e,"revoke")})}};var Xt="/sms_messages",we=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:Xt,bodyParams:e})}};var T="/users",xe=class extends m{async getUserList(e={}){return this.request({method:"GET",path:T,queryParams:e})}async getUser(e){return this.requireId(e),this.request({method:"GET",path:l(T,e)})}async createUser(e){return this.request({method:"POST",path:T,bodyParams:e})}async updateUser(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(T,e),bodyParams:r})}async updateUserMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(T,e,"metadata"),bodyParams:r})}async deleteUser(e){return this.requireId(e),this.request({method:"DELETE",path:l(T,e)})}async getCount(e={}){return this.request({method:"GET",path:l(T,"count"),queryParams:e})}async getUserOauthAccessToken(e,r){return this.requireId(e),this.request({method:"GET",path:l(T,e,"oauth_access_tokens",r)})}async disableUserMFA(e){return this.requireId(e),this.request({method:"DELETE",path:l(T,e,"mfa")})}async getOrganizationMembershipList(e){let{userId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(T,r,"organization_memberships"),queryParams:{limit:n,offset:i}})}async verifyPassword(e){let{userId:r,password:n}=e;return this.requireId(r),this.request({method:"POST",path:l(T,r,"verify_password"),bodyParams:{password:n}})}async verifyTOTP(e){let{userId:r,code:n}=e;return this.requireId(r),this.request({method:"POST",path:l(T,r,"verify_totp"),bodyParams:{code:n}})}};import ur from"deepmerge";import st from"snakecase-keys";var C="https://api.clerk.dev",J="v1",tt="@clerk/backend";var Qt={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},Zt={Session:"__session",ClientUat:"__client_uat",SessionUat:"__session_uat"},rt={AuthStatus:"x-clerk-auth-status",AuthReason:"x-clerk-auth-reason",AuthMessage:"x-clerk-auth-message",EnableDebug:"x-clerk-debug",ClerkRedirectTo:"x-clerk-redirect-to",Authorization:"authorization",ForwardedPort:"x-forwarded-port",ForwardedProto:"x-forwarded-proto",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},er={AuthStatus:rt.AuthStatus},tr={Json:"application/json"},rr={Attributes:Qt,Cookies:Zt,Headers:rt,SearchParams:er,ContentTypes:tr};import nr from"#crypto";import ir from"#fetch";var sr=ir.bind(globalThis),ar={crypto:nr,fetch:sr},v=ar;function Te(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var D=class{constructor(e,r,n,i,s){this.id=e;this.identifier=r;this.createdAt=n;this.updatedAt=i;this.invitationId=s}static fromJSON(e){return new D(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var E=class{constructor(e,r,n,i,s,a,u,o,d){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=a;this.abandonAt=u;this.createdAt=o;this.updatedAt=d}static fromJSON(e){return new E(e.id,e.client_id,e.user_id,e.status,e.last_active_at,e.expire_at,e.abandon_at,e.created_at,e.updated_at)}};var F=class{constructor(e,r,n,i,s,a,u,o){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=a;this.createdAt=u;this.updatedAt=o}static fromJSON(e){return new F(e.id,e.session_ids,e.sessions.map(r=>E.fromJSON(r)),e.sign_in_id,e.sign_up_id,e.last_active_session_id,e.created_at,e.updated_at)}};var V=class{constructor(e,r,n,i){this.object=e;this.id=r;this.slug=n;this.deleted=i}static fromJSON(e){return new V(e.object,e.id||null,e.slug||null,e.deleted)}};var $=class{constructor(e,r,n,i,s,a,u,o,d,g,f){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=a;this.bodyPlain=u;this.status=o;this.slug=d;this.data=g;this.deliveredByClerk=f}static fromJSON(e){return new $(e.id,e.from_email_name,e.email_address_id,e.to_email_address,e.subject,e.body,e.body_plain,e.status,e.slug,e.data,e.delivered_by_clerk)}};var M=class{constructor(e,r){this.id=e;this.type=r}static fromJSON(e){return new M(e.id,e.type)}};var R=class{constructor(e,r,n=null,i=null,s=null,a=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=a}static fromJSON(e){return new R(e.status,e.strategy,e.external_verification_redirect_url?new URL(e.external_verification_redirect_url):null,e.attempts,e.expire_at,e.nonce)}};var q=class{constructor(e,r,n,i){this.id=e;this.emailAddress=r;this.verification=n;this.linkedTo=i}static fromJSON(e){return new q(e.id,e.email_address,e.verification&&R.fromJSON(e.verification),e.linked_to.map(r=>M.fromJSON(r)))}};var B=class{constructor(e,r,n,i,s,a,u,o,d,g,f,h={},k,P){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=a;this.firstName=u;this.lastName=o;this.picture=d;this.imageUrl=g;this.username=f;this.publicMetadata=h;this.label=k;this.verification=P}static fromJSON(e){return new B(e.id,e.provider,e.identification_id,e.provider_user_id,e.approved_scopes,e.email_address,e.first_name,e.last_name,e.avatar_url,e.image_url,e.username,e.public_metadata,e.label,e.verification&&R.fromJSON(e.verification))}};var G=class{constructor(e,r,n,i,s,a,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=a;this.revoked=u}static fromJSON(e){return new G(e.id,e.email_address,e.public_metadata,e.created_at,e.updated_at,e.status,e.revoked)}};var nt=(c=>(c.AllowlistIdentifier="allowlist_identifier",c.Client="client",c.Email="email",c.EmailAddress="email_address",c.ExternalAccount="external_account",c.FacebookAccount="facebook_account",c.GoogleAccount="google_account",c.Invitation="invitation",c.OauthAccessToken="oauth_access_token",c.Organization="organization",c.OrganizationInvitation="organization_invitation",c.OrganizationMembership="organization_membership",c.PhoneNumber="phone_number",c.RedirectUrl="redirect_url",c.Session="session",c.SignInAttempt="sign_in_attempt",c.SignInToken="sign_in_token",c.SignUpAttempt="sign_up_attempt",c.SmsMessage="sms_message",c.User="user",c.Web3Wallet="web3_wallet",c.Token="token",c.TotalCount="total_count",c))(nt||{});var H=class{constructor(e,r,n={},i,s,a){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=a}static fromJSON(e){return new H(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var K=class{constructor(e,r,n,i,s,a,u,o,d={},g={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.imageUrl=s;this.createdBy=a;this.createdAt=u;this.updatedAt=o;this.publicMetadata=d;this.privateMetadata=g;this.maxAllowedMemberships=f}static fromJSON(e){return new K(e.id,e.name,e.slug,e.logo_url,e.image_url,e.created_by,e.created_at,e.updated_at,e.public_metadata,e.private_metadata,e.max_allowed_memberships)}};var Y=class{constructor(e,r,n,i,s,a,u,o={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=a;this.status=u;this.publicMetadata=o}static fromJSON(e){return new Y(e.id,e.email_address,e.role,e.organization_id,e.created_at,e.updated_at,e.status,e.public_metadata)}};var X=class{constructor(e,r,n={},i={},s,a,u,o){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=a;this.organization=u;this.publicUserData=o}static fromJSON(e){return new X(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,K.fromJSON(e.organization),ae.fromJSON(e.public_user_data))}},ae=class{constructor(e,r,n,i,s,a){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.imageUrl=s;this.userId=a}static fromJSON(e){return new ae(e.identifier,e.first_name,e.last_name,e.profile_image_url,e.image_url,e.user_id)}};var z=class{constructor(e,r,n,i,s,a){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=a}static fromJSON(e){return new z(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&R.fromJSON(e.verification),e.linked_to.map(r=>M.fromJSON(r)))}};var Q=class{constructor(e,r,n,i){this.id=e;this.url=r;this.createdAt=n;this.updatedAt=i}static fromJSON(e){return new Q(e.id,e.url,e.created_at,e.updated_at)}};var Z=class{constructor(e,r,n,i,s,a,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=a;this.updatedAt=u}static fromJSON(e){return new Z(e.id,e.user_id,e.token,e.status,e.url,e.created_at,e.updated_at)}};var ee=class{constructor(e,r,n,i,s,a,u){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=a;this.data=u}static fromJSON(e){return new ee(e.id,e.from_phone_number,e.to_phone_number,e.message,e.status,e.phone_number_id,e.data)}};var te=class{constructor(e){this.jwt=e}static fromJSON(e){return new te(e.jwt)}};var re=class{constructor(e,r,n){this.id=e;this.web3Wallet=r;this.verification=n}static fromJSON(e){return new re(e.id,e.web3_wallet,e.verification&&R.fromJSON(e.verification))}};var ne=class{constructor(e,r,n,i,s,a,u,o,d,g,f,h,k,P,O,x,A,b,_,I,S={},y={},c={},W=[],de=[],Ee=[],Me=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=a;this.createdAt=u;this.updatedAt=o;this.profileImageUrl=d;this.imageUrl=g;this.gender=f;this.birthday=h;this.primaryEmailAddressId=k;this.primaryPhoneNumberId=P;this.primaryWeb3WalletId=O;this.lastSignInAt=x;this.externalId=A;this.username=b;this.firstName=_;this.lastName=I;this.publicMetadata=S;this.privateMetadata=y;this.unsafeMetadata=c;this.emailAddresses=W;this.phoneNumbers=de;this.web3Wallets=Ee;this.externalAccounts=Me}static fromJSON(e){return new ne(e.id,e.password_enabled,e.totp_enabled,e.backup_code_enabled,e.two_factor_enabled,e.banned,e.created_at,e.updated_at,e.profile_image_url,e.image_url,e.gender,e.birthday,e.primary_email_address_id,e.primary_phone_number_id,e.primary_web3_wallet_id,e.last_sign_in_at,e.external_id,e.username,e.first_name,e.last_name,e.public_metadata,e.private_metadata,e.unsafe_metadata,(e.email_addresses||[]).map(r=>q.fromJSON(r)),(e.phone_numbers||[]).map(r=>z.fromJSON(r)),(e.web3_wallets||[]).map(r=>re.fromJSON(r)),(e.external_accounts||[]).map(r=>B.fromJSON(r)))}};function it(t){return Array.isArray(t)?t.map(e=>je(e)):or(t)?t.data.map(e=>je(e)):je(t)}function or(t){return Array.isArray(t.data)&&t.data!==void 0}function lr(t){return t.total_count}function je(t){if(typeof t!="string"&&"object"in t&&"deleted"in t)return V.fromJSON(t);switch(t.object){case"allowlist_identifier":return D.fromJSON(t);case"client":return F.fromJSON(t);case"email_address":return q.fromJSON(t);case"email":return $.fromJSON(t);case"invitation":return G.fromJSON(t);case"oauth_access_token":return H.fromJSON(t);case"organization":return K.fromJSON(t);case"organization_invitation":return Y.fromJSON(t);case"organization_membership":return X.fromJSON(t);case"phone_number":return z.fromJSON(t);case"redirect_url":return Q.fromJSON(t);case"sign_in_token":return Z.fromJSON(t);case"session":return E.fromJSON(t);case"sms_message":return ee.fromJSON(t);case"token":return te.fromJSON(t);case"total_count":return lr(t);case"user":return ne.fromJSON(t);default:return t}}var dr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new oe(s||"",{data:n,status:i||""})};function at(t){return dr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=C,apiVersion:a=J,userAgent:u=tt,httpOptions:o={}}=t,{path:d,method:g,queryParams:f,headerParams:h,bodyParams:k}=r,P=i||n;Te(P);let O=l(s,a,d),x=new URL(O);if(f){let S=st({...f});for(let[y,c]of Object.entries(S))c&&[c].flat().forEach(W=>x.searchParams.append(y,W))}let A={Authorization:`Bearer ${P}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...h},_=g!=="GET"&&k&&Object.keys(k).length>0?{body:JSON.stringify(st(k,{deep:!1}))}:null,I;try{I=await v.fetch(x.href,ur(o,{method:g,headers:A,..._}));let y=await(A&&A["Content-Type"]==="application/json"?I.json():I.text());if(!I.ok)throw y;return{data:it(y),errors:null}}catch(S){return S instanceof Error?{data:null,errors:[{code:"unexpected_error",message:S.message||"Unexpected error"}]}:{data:null,errors:cr(S),status:I?.status,statusText:I?.statusText}}})}function cr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(pr):[]}return[]}function pr(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var oe=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,oe.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function ie(t){let e=at(t);return{allowlistIdentifiers:new ce(e),clients:new pe(e),emailAddresses:new fe(e),emails:new ye(e),interstitial:new he(e),invitations:new be(e),organizations:new Se(e),phoneNumbers:new ke(e),redirectUrls:new _e(e),sessions:new Ie(e),signInTokens:new Ae(e),smsMessages:new we(e),users:new xe(e),domains:new me(e)}}var lt=t=>()=>{let e={...t};return e.apiKey=(e.apiKey||"").substring(0,7),e.secretKey=(e.secretKey||"").substring(0,7),e.jwtKey=(e.jwtKey||"").substring(0,7),{...e}};function ut(t,e,r){let{act:n,sid:i,org_id:s,org_role:a,org_slug:u,sub:o}=t,{apiKey:d,secretKey:g,apiUrl:f,apiVersion:h,token:k,session:P,user:O,organization:x}=e,{sessions:A}=ie({apiKey:d,secretKey:g,apiUrl:f,apiVersion:h}),b=mr({sessionId:i,sessionToken:k,fetcher:(..._)=>A.getToken(..._)});return{actor:n,sessionClaims:t,sessionId:i,session:P,userId:o,user:O,orgId:s,orgRole:a,orgSlug:u,organization:x,getToken:b,debug:lt({...e,...r})}}function dt(t){return{sessionClaims:null,sessionId:null,session:null,userId:null,user:null,actor:null,orgId:null,orgRole:null,orgSlug:null,organization:null,getToken:()=>Promise.resolve(null),debug:lt(t)}}function ot(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function As(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return ot(e),ot(r),{...t,user:e,organization:r}}var ws=t=>{let{debug:e,getToken:r,...n}=t;return n},mr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function gr(t){return new Promise(e=>setTimeout(e,t))}var fr=5;async function le(t,e=1,r=fr){try{return await t()}catch(n){if(e>=r)throw n;return await gr(2**e*100),le(t,e+1)}}function L(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function ct(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function pt(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function yr(){let t=[".lcl.dev",".stg.dev",".lclstage.dev",".stgstage.dev",".dev.lclclerk.com",".stg.lclclerk.com",".accounts.lclclerk.com","accountsstage.dev","accounts.dev"],e=new Map;return{isDevOrStagingUrl:r=>{if(!r)return!1;let n=typeof r=="string"?r:r.hostname,i=e.get(n);return i===void 0&&(i=t.some(s=>n.endsWith(s)),e.set(n,i)),i}}}var{isDevOrStagingUrl:We}=yr();var mt="pk_live_",hr="pk_test_";function j(t){if(t=t||"",!br(t))return null;let e=t.startsWith(mt)?"production":"development",r=gt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function br(t){t=t||"";let e=t.startsWith(mt)||t.startsWith(hr),r=gt(t.split("_")[2]||"").endsWith("$");return e&&r}var gt=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var p=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,p.prototype),this.reason=i,this.message=n,this.action=r}getFullMessage(){return`${[this.message,this.action].filter(r=>r).join(" ")} (reason=${this.reason}, token-carrier=${this.tokenCarrier})`}};function Sr(t){if(!t)return"";let e;if(t.match(/^(clerk\.)+\w*$/))e=/(clerk\.)*(?=clerk\.)/;else{if(t.match(/\.clerk.accounts/))return t;e=/^(clerk\.)*/gi}return`clerk.${t.replace(e,"")}`}function De(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=We(t.frontendApi)?"":Sr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u=!1,domain:o,signInUrl:d}=t;return`
var g=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var qe="/",Gt=new RegExp(qe+"{1,}","g");function l(...t){return t.filter(e=>e).join(qe).replace(Gt,qe)}var Ke="/allowlist_identifiers",ce=class extends g{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Ke})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Ke,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ke,e)})}};var ze="/clients",pe=class extends g{async getClientList(){return this.request({method:"GET",path:ze})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(ze,e)})}verifyClient(e){return this.request({method:"POST",path:l(ze,"verify"),bodyParams:{token:e}})}};var Ht="/domains",me=class extends g{async deleteDomain(e){return this.request({method:"DELETE",path:l(Ht,e)})}};var ge="/email_addresses",fe=class extends g{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(ge,e)})}async createEmailAddress(e){return this.request({method:"POST",path:ge,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(ge,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(ge,e)})}};var Yt="/emails",ye=class extends g{async createEmail(e){return this.request({method:"POST",path:Yt,bodyParams:e})}};var he=class extends g{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var Le="/invitations",be=class extends g{async getInvitationList(){return this.request({method:"GET",path:Le})}async createInvitation(e){return this.request({method:"POST",path:Le,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(Le,e,"revoke")})}};var w="/organizations",Se=class extends g{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var Oe="/phone_numbers",ke=class extends g{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(Oe,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:Oe,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(Oe,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(Oe,e)})}};var Pe="/redirect_urls",Ie=class extends g{async getRedirectUrlList(){return this.request({method:"GET",path:Pe})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Pe,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Pe,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Pe,e)})}};var se="/sessions",_e=class extends g{async getSessionList(e){return this.request({method:"GET",path:se,queryParams:e})}async getSession(e){return this.requireId(e),this.request({method:"GET",path:l(se,e)})}async revokeSession(e){return this.requireId(e),this.request({method:"POST",path:l(se,e,"revoke")})}async verifySession(e,r){return this.requireId(e),this.request({method:"POST",path:l(se,e,"verify"),bodyParams:{token:r}})}async getToken(e,r){return this.requireId(e),(await this.request({method:"POST",path:l(se,e,"tokens",r||"")})).jwt}};var et="/sign_in_tokens",Ae=class extends g{async createSignInToken(e){return this.request({method:"POST",path:et,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(et,e,"revoke")})}};var Xt="/sms_messages",we=class extends g{async createSMSMessage(e){return this.request({method:"POST",path:Xt,bodyParams:e})}};var T="/users",xe=class extends g{async getUserList(e={}){return this.request({method:"GET",path:T,queryParams:e})}async getUser(e){return this.requireId(e),this.request({method:"GET",path:l(T,e)})}async createUser(e){return this.request({method:"POST",path:T,bodyParams:e})}async updateUser(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(T,e),bodyParams:r})}async updateUserMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(T,e,"metadata"),bodyParams:r})}async deleteUser(e){return this.requireId(e),this.request({method:"DELETE",path:l(T,e)})}async getCount(e={}){return this.request({method:"GET",path:l(T,"count"),queryParams:e})}async getUserOauthAccessToken(e,r){return this.requireId(e),this.request({method:"GET",path:l(T,e,"oauth_access_tokens",r)})}async disableUserMFA(e){return this.requireId(e),this.request({method:"DELETE",path:l(T,e,"mfa")})}async getOrganizationMembershipList(e){let{userId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(T,r,"organization_memberships"),queryParams:{limit:n,offset:i}})}async verifyPassword(e){let{userId:r,password:n}=e;return this.requireId(r),this.request({method:"POST",path:l(T,r,"verify_password"),bodyParams:{password:n}})}async verifyTOTP(e){let{userId:r,code:n}=e;return this.requireId(r),this.request({method:"POST",path:l(T,r,"verify_totp"),bodyParams:{code:n}})}};import ur from"deepmerge";import st from"snakecase-keys";var E="https://api.clerk.dev",R="v1",tt="@clerk/backend";var Qt={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},Zt={Session:"__session",ClientUat:"__client_uat"},rt={AuthStatus:"x-clerk-auth-status",AuthReason:"x-clerk-auth-reason",AuthMessage:"x-clerk-auth-message",EnableDebug:"x-clerk-debug",ClerkRedirectTo:"x-clerk-redirect-to",Authorization:"authorization",ForwardedPort:"x-forwarded-port",ForwardedProto:"x-forwarded-proto",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},er={AuthStatus:rt.AuthStatus},tr={Json:"application/json"},rr={Attributes:Qt,Cookies:Zt,Headers:rt,SearchParams:er,ContentTypes:tr};import nr from"#crypto";import ir from"#fetch";var sr=ir.bind(globalThis),ar={crypto:nr,fetch:sr},v=ar;function Te(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var D=class{constructor(e,r,n,i,s){this.id=e;this.identifier=r;this.createdAt=n;this.updatedAt=i;this.invitationId=s}static fromJSON(e){return new D(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var M=class{constructor(e,r,n,i,s,a,u,o,c){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=a;this.abandonAt=u;this.createdAt=o;this.updatedAt=c}static fromJSON(e){return new M(e.id,e.client_id,e.user_id,e.status,e.last_active_at,e.expire_at,e.abandon_at,e.created_at,e.updated_at)}};var F=class{constructor(e,r,n,i,s,a,u,o){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=a;this.createdAt=u;this.updatedAt=o}static fromJSON(e){return new F(e.id,e.session_ids,e.sessions.map(r=>M.fromJSON(r)),e.sign_in_id,e.sign_up_id,e.last_active_session_id,e.created_at,e.updated_at)}};var V=class{constructor(e,r,n,i){this.object=e;this.id=r;this.slug=n;this.deleted=i}static fromJSON(e){return new V(e.object,e.id||null,e.slug||null,e.deleted)}};var $=class{constructor(e,r,n,i,s,a,u,o,c,d,f){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=a;this.bodyPlain=u;this.status=o;this.slug=c;this.data=d;this.deliveredByClerk=f}static fromJSON(e){return new $(e.id,e.from_email_name,e.email_address_id,e.to_email_address,e.subject,e.body,e.body_plain,e.status,e.slug,e.data,e.delivered_by_clerk)}};var q=class{constructor(e,r){this.id=e;this.type=r}static fromJSON(e){return new q(e.id,e.type)}};var J=class{constructor(e,r,n=null,i=null,s=null,a=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=a}static fromJSON(e){return new J(e.status,e.strategy,e.external_verification_redirect_url?new URL(e.external_verification_redirect_url):null,e.attempts,e.expire_at,e.nonce)}};var K=class{constructor(e,r,n,i){this.id=e;this.emailAddress=r;this.verification=n;this.linkedTo=i}static fromJSON(e){return new K(e.id,e.email_address,e.verification&&J.fromJSON(e.verification),e.linked_to.map(r=>q.fromJSON(r)))}};var B=class{constructor(e,r,n,i,s,a,u,o,c,d,f,h={},k,P){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=a;this.firstName=u;this.lastName=o;this.picture=c;this.imageUrl=d;this.username=f;this.publicMetadata=h;this.label=k;this.verification=P}static fromJSON(e){return new B(e.id,e.provider,e.identification_id,e.provider_user_id,e.approved_scopes,e.email_address,e.first_name,e.last_name,e.avatar_url,e.image_url,e.username,e.public_metadata,e.label,e.verification&&J.fromJSON(e.verification))}};var G=class{constructor(e,r,n,i,s,a,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=a;this.revoked=u}static fromJSON(e){return new G(e.id,e.email_address,e.public_metadata,e.created_at,e.updated_at,e.status,e.revoked)}};var nt=(p=>(p.AllowlistIdentifier="allowlist_identifier",p.Client="client",p.Email="email",p.EmailAddress="email_address",p.ExternalAccount="external_account",p.FacebookAccount="facebook_account",p.GoogleAccount="google_account",p.Invitation="invitation",p.OauthAccessToken="oauth_access_token",p.Organization="organization",p.OrganizationInvitation="organization_invitation",p.OrganizationMembership="organization_membership",p.PhoneNumber="phone_number",p.RedirectUrl="redirect_url",p.Session="session",p.SignInAttempt="sign_in_attempt",p.SignInToken="sign_in_token",p.SignUpAttempt="sign_up_attempt",p.SmsMessage="sms_message",p.User="user",p.Web3Wallet="web3_wallet",p.Token="token",p.TotalCount="total_count",p))(nt||{});var H=class{constructor(e,r,n={},i,s,a){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=a}static fromJSON(e){return new H(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var z=class{constructor(e,r,n,i,s,a,u,o,c={},d={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.imageUrl=s;this.createdBy=a;this.createdAt=u;this.updatedAt=o;this.publicMetadata=c;this.privateMetadata=d;this.maxAllowedMemberships=f}static fromJSON(e){return new z(e.id,e.name,e.slug,e.logo_url,e.image_url,e.created_by,e.created_at,e.updated_at,e.public_metadata,e.private_metadata,e.max_allowed_memberships)}};var Y=class{constructor(e,r,n,i,s,a,u,o={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=a;this.status=u;this.publicMetadata=o}static fromJSON(e){return new Y(e.id,e.email_address,e.role,e.organization_id,e.created_at,e.updated_at,e.status,e.public_metadata)}};var X=class{constructor(e,r,n={},i={},s,a,u,o){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=a;this.organization=u;this.publicUserData=o}static fromJSON(e){return new X(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,z.fromJSON(e.organization),ae.fromJSON(e.public_user_data))}},ae=class{constructor(e,r,n,i,s,a){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.imageUrl=s;this.userId=a}static fromJSON(e){return new ae(e.identifier,e.first_name,e.last_name,e.profile_image_url,e.image_url,e.user_id)}};var L=class{constructor(e,r,n,i,s,a){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=a}static fromJSON(e){return new L(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&J.fromJSON(e.verification),e.linked_to.map(r=>q.fromJSON(r)))}};var Q=class{constructor(e,r,n,i){this.id=e;this.url=r;this.createdAt=n;this.updatedAt=i}static fromJSON(e){return new Q(e.id,e.url,e.created_at,e.updated_at)}};var Z=class{constructor(e,r,n,i,s,a,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=a;this.updatedAt=u}static fromJSON(e){return new Z(e.id,e.user_id,e.token,e.status,e.url,e.created_at,e.updated_at)}};var ee=class{constructor(e,r,n,i,s,a,u){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=a;this.data=u}static fromJSON(e){return new ee(e.id,e.from_phone_number,e.to_phone_number,e.message,e.status,e.phone_number_id,e.data)}};var te=class{constructor(e){this.jwt=e}static fromJSON(e){return new te(e.jwt)}};var re=class{constructor(e,r,n){this.id=e;this.web3Wallet=r;this.verification=n}static fromJSON(e){return new re(e.id,e.web3_wallet,e.verification&&J.fromJSON(e.verification))}};var ne=class{constructor(e,r,n,i,s,a,u,o,c,d,f,h,k,P,O,x,A,b,I,_,S={},y={},p={},W=[],de=[],Ee=[],Me=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=a;this.createdAt=u;this.updatedAt=o;this.profileImageUrl=c;this.imageUrl=d;this.gender=f;this.birthday=h;this.primaryEmailAddressId=k;this.primaryPhoneNumberId=P;this.primaryWeb3WalletId=O;this.lastSignInAt=x;this.externalId=A;this.username=b;this.firstName=I;this.lastName=_;this.publicMetadata=S;this.privateMetadata=y;this.unsafeMetadata=p;this.emailAddresses=W;this.phoneNumbers=de;this.web3Wallets=Ee;this.externalAccounts=Me}static fromJSON(e){return new ne(e.id,e.password_enabled,e.totp_enabled,e.backup_code_enabled,e.two_factor_enabled,e.banned,e.created_at,e.updated_at,e.profile_image_url,e.image_url,e.gender,e.birthday,e.primary_email_address_id,e.primary_phone_number_id,e.primary_web3_wallet_id,e.last_sign_in_at,e.external_id,e.username,e.first_name,e.last_name,e.public_metadata,e.private_metadata,e.unsafe_metadata,(e.email_addresses||[]).map(r=>K.fromJSON(r)),(e.phone_numbers||[]).map(r=>L.fromJSON(r)),(e.web3_wallets||[]).map(r=>re.fromJSON(r)),(e.external_accounts||[]).map(r=>B.fromJSON(r)))}};function it(t){return Array.isArray(t)?t.map(e=>je(e)):or(t)?t.data.map(e=>je(e)):je(t)}function or(t){return Array.isArray(t.data)&&t.data!==void 0}function lr(t){return t.total_count}function je(t){if(typeof t!="string"&&"object"in t&&"deleted"in t)return V.fromJSON(t);switch(t.object){case"allowlist_identifier":return D.fromJSON(t);case"client":return F.fromJSON(t);case"email_address":return K.fromJSON(t);case"email":return $.fromJSON(t);case"invitation":return G.fromJSON(t);case"oauth_access_token":return H.fromJSON(t);case"organization":return z.fromJSON(t);case"organization_invitation":return Y.fromJSON(t);case"organization_membership":return X.fromJSON(t);case"phone_number":return L.fromJSON(t);case"redirect_url":return Q.fromJSON(t);case"sign_in_token":return Z.fromJSON(t);case"session":return M.fromJSON(t);case"sms_message":return ee.fromJSON(t);case"token":return te.fromJSON(t);case"total_count":return lr(t);case"user":return ne.fromJSON(t);default:return t}}var dr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new oe(s||"",{data:n,status:i||""})};function at(t){return dr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=E,apiVersion:a=R,userAgent:u=tt,httpOptions:o={}}=t,{path:c,method:d,queryParams:f,headerParams:h,bodyParams:k}=r,P=i||n;Te(P);let O=l(s,a,c),x=new URL(O);if(f){let S=st({...f});for(let[y,p]of Object.entries(S))p&&[p].flat().forEach(W=>x.searchParams.append(y,W))}let A={Authorization:`Bearer ${P}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...h},I=d!=="GET"&&k&&Object.keys(k).length>0?{body:JSON.stringify(st(k,{deep:!1}))}:null,_;try{_=await v.fetch(x.href,ur(o,{method:d,headers:A,...I}));let y=await(A&&A["Content-Type"]==="application/json"?_.json():_.text());if(!_.ok)throw y;return{data:it(y),errors:null}}catch(S){return S instanceof Error?{data:null,errors:[{code:"unexpected_error",message:S.message||"Unexpected error"}]}:{data:null,errors:cr(S),status:_?.status,statusText:_?.statusText}}})}function cr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(pr):[]}return[]}function pr(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var oe=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,oe.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function ie(t){let e=at(t);return{allowlistIdentifiers:new ce(e),clients:new pe(e),emailAddresses:new fe(e),emails:new ye(e),interstitial:new he(e),invitations:new be(e),organizations:new Se(e),phoneNumbers:new ke(e),redirectUrls:new Ie(e),sessions:new _e(e),signInTokens:new Ae(e),smsMessages:new we(e),users:new xe(e),domains:new me(e)}}var lt=t=>()=>{let e={...t};return e.apiKey=(e.apiKey||"").substring(0,7),e.secretKey=(e.secretKey||"").substring(0,7),e.jwtKey=(e.jwtKey||"").substring(0,7),{...e}};function ut(t,e,r){let{act:n,sid:i,org_id:s,org_role:a,org_slug:u,sub:o}=t,{apiKey:c,secretKey:d,apiUrl:f,apiVersion:h,token:k,session:P,user:O,organization:x}=e,{sessions:A}=ie({apiKey:c,secretKey:d,apiUrl:f,apiVersion:h}),b=mr({sessionId:i,sessionToken:k,fetcher:(...I)=>A.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:P,userId:o,user:O,orgId:s,orgRole:a,orgSlug:u,organization:x,getToken:b,debug:lt({...e,...r})}}function dt(t){return{sessionClaims:null,sessionId:null,session:null,userId:null,user:null,actor:null,orgId:null,orgRole:null,orgSlug:null,organization:null,getToken:()=>Promise.resolve(null),debug:lt(t)}}function ot(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function As(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return ot(e),ot(r),{...t,user:e,organization:r}}var ws=t=>{let{debug:e,getToken:r,...n}=t;return n},mr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function gr(t){return new Promise(e=>setTimeout(e,t))}var fr=5;async function le(t,e=1,r=fr){try{return await t()}catch(n){if(e>=r)throw n;return await gr(2**e*100),le(t,e+1)}}function N(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function ct(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function pt(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function yr(){let t=[".lcl.dev",".stg.dev",".lclstage.dev",".stgstage.dev",".dev.lclclerk.com",".stg.lclclerk.com",".accounts.lclclerk.com","accountsstage.dev","accounts.dev"],e=new Map;return{isDevOrStagingUrl:r=>{if(!r)return!1;let n=typeof r=="string"?r:r.hostname,i=e.get(n);return i===void 0&&(i=t.some(s=>n.endsWith(s)),e.set(n,i)),i}}}var{isDevOrStagingUrl:We}=yr();var mt="pk_live_",hr="pk_test_";function j(t){if(t=t||"",!br(t))return null;let e=t.startsWith(mt)?"production":"development",r=gt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function br(t){t=t||"";let e=t.startsWith(mt)||t.startsWith(hr),r=gt(t.split("_")[2]||"").endsWith("$");return e&&r}var gt=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var m=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,m.prototype),this.reason=i,this.message=n,this.action=r}getFullMessage(){return`${[this.message,this.action].filter(r=>r).join(" ")} (reason=${this.reason}, token-carrier=${this.tokenCarrier})`}};function Sr(t){if(!t)return"";let e;if(t.match(/^(clerk\.)+\w*$/))e=/(clerk\.)*(?=clerk\.)/;else{if(t.match(/\.clerk.accounts/))return t;e=/^(clerk\.)*/gi}return`clerk.${t.replace(e,"")}`}function De(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=We(t.frontendApi)?"":Sr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,clerkJSUrl:s,clerkJSVersion:a,publishableKey:u,proxyUrl:o,isSatellite:c=!1,domain:d,signInUrl:f}=t;return`
<head>

@@ -9,4 +9,4 @@ <meta charset="UTF-8" />

window.__clerk_debug = ${JSON.stringify(r||{})};
${a?`window.__clerk_proxy_url = '${a}'`:""}
${o?`window.__clerk_domain = '${o}'`:""}
${o?`window.__clerk_proxy_url = '${o}'`:""}
${d?`window.__clerk_domain = '${d}'`:""}
window.startClerk = async () => {

@@ -35,5 +35,5 @@ function formRedirect(){

await Clerk.load({
isSatellite: ${u},
isSatellite: ${c},
isInterstitial: ${!0},
signInUrl: ${d?`'${d}'`:void 0}
signInUrl: ${f?`'${f}'`:void 0}
});

@@ -55,8 +55,8 @@ if(Clerk.loaded){

const script = document.createElement('script');
${s?`script.setAttribute('data-clerk-publishable-key', '${s}');`:`script.setAttribute('data-clerk-frontend-api', '${n}');`}
${u?`script.setAttribute('data-clerk-publishable-key', '${u}');`:`script.setAttribute('data-clerk-frontend-api', '${n}');`}
${o?`script.setAttribute('data-clerk-domain', '${o}');`:""}
${a?`script.setAttribute('data-clerk-proxy-url', '${a}')`:""};
${d?`script.setAttribute('data-clerk-domain', '${d}');`:""}
${o?`script.setAttribute('data-clerk-proxy-url', '${o}')`:""};
script.async = true;
script.src = '${Or(a||e||n,i)}';
script.src = '${s||Or(o||e||n,{pkgVersion:i,clerkJSVersion:a})}';
script.crossOrigin = 'anonymous';

@@ -68,3 +68,3 @@ script.addEventListener('load', startClerk);

</body>
`}async function ft(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Re(t),r=await le(()=>v.fetch(Re(t)));if(!r.ok)throw new p({action:"Contact support@clerk.com",message:`Error loading Clerk Interstitial from ${e} with code=${r.status}`,reason:"interstitial-remote-failed-to-load"});return r.text()}function Re(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t,d=new URL(e);return d.pathname=l(d.pathname,J,"/public/interstitial"),d.searchParams.append("clerk_js_version",yt(r,n)),i?d.searchParams.append("publishable_key",i):d.searchParams.append("frontend_api",r),s&&d.searchParams.append("proxy_url",s),a&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",o||""),We(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var yt=(t,e)=>!e&&pt(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",Or=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=yt(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var ht=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(ht||{});async function Fe(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:f,headerToken:h,loadSession:k,loadUser:P,loadOrganization:O,signInUrl:x}=t,{sid:A,org_id:b,sub:_}=e,{sessions:I,users:S,organizations:y}=ie({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[c,W,de]=await Promise.all([k?I.getSession(A):Promise.resolve(void 0),P?S.getUser(_):Promise.resolve(void 0),O&&b?y.getOrganization({organizationId:b}):Promise.resolve(void 0)]),Bt=ut(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||h||"",session:c,user:W,organization:de},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:f,signInUrl:x,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Bt}}function N(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:a,domain:u,signInUrl:o,isSignedIn:!1,isInterstitial:!1,isUnknown:!1,toAuth:()=>dt({...t,status:"signed-out",reason:e,message:r})}}function U(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:a,domain:u,proxyUrl:s,signInUrl:o,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function bt(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function Ve({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){let s=Ot(i),a=Ot(n),u=(i||"").split(",").length>(n||"").split(",").length;s&&u&&(a=kt(s));let o=_r(t.protocol);if(s&&s!==o)return!0;let g=kr(r||e,s||o);return g.port=a||g.port,St(g)!==St(t)||g.hostname!==t.hostname}function kr(t,e="https"){return new URL(`${e}://${t}`)}var Pr={http:"80",https:"443"};function St(t){return t.port||kt(t.protocol)}function kt(t){return Pr[t]}function Ot(t){return t?.split(",")[0]?.trim()||""}function _r(t){return t?.replace(/:$/,"")||""}var ve={parse(t,e){return Ir(t,Pt,e)},stringify(t,e){return Ar(t,Pt,e)}},Pt={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function Ir(t,e,r={}){if(!e.codes){e.codes={};for(let o=0;o<e.chars.length;++o)e.codes[e.chars[o]]=o}if(!r.loose&&t.length*e.bits&7)throw new SyntaxError("Invalid padding");let n=t.length;for(;t[n-1]==="=";)if(--n,!r.loose&&!((t.length-n)*e.bits&7))throw new SyntaxError("Invalid padding");let i=new(r.out??Uint8Array)(n*e.bits/8|0),s=0,a=0,u=0;for(let o=0;o<n;++o){let d=e.codes[t[o]];if(d===void 0)throw new SyntaxError("Invalid character "+t[o]);a=a<<e.bits|d,s+=e.bits,s>=8&&(s-=8,i[u++]=255&a>>s)}if(s>=e.bits||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Ar(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",a=0,u=0;for(let o=0;o<t.length;++o)for(u=u<<8|255&t[o],a+=8;a>e.bits;)a-=e.bits,s+=e.chars[i&u>>a];if(a&&(s+=e.chars[i&u<<e.bits-a]),n)for(;s.length*e.bits&7;)s+="=";return s}var wr=t=>Array.isArray(t)&&t.length>0&&t.every(e=>typeof e=="string"),_t=(t,e)=>{let r=[e].flat().filter(s=>!!s),n=[t].flat().filter(s=>!!s);if(r.length>0&&n.length>0){if(typeof t=="string"){if(!r.includes(t))throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}else if(wr(t)&&!t.some(s=>r.includes(s)))throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}};var xr=2*1e3,Ge={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},$e="RSASSA-PKCS1-v1_5",Be="ECDSA",Tr={RS256:$e,RS384:$e,RS512:$e,ES256:Be,ES384:Be,ES512:Be},Rr=Object.keys(Ge);async function It(t,e){let{header:r,signature:n,raw:i}=t,a=new TextEncoder().encode([i.header,i.payload].join(".")),u=await v.crypto.subtle.importKey("jwk",e,{name:Tr[r.alg],hash:Ge[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function Ue(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new p({reason:"token-invalid",message:"Invalid JWT form. A JWT consists of three parts separated by dots."});let[r,n,i]=e,s=new TextDecoder,a=JSON.parse(s.decode(ve.parse(r,{loose:!0}))),u=JSON.parse(s.decode(ve.parse(n,{loose:!0}))),o=ve.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function He(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=xr,issuer:i,key:s}){let a=Ue(t),{header:u,payload:o}=a,{typ:d,alg:g}=u;if(typeof d<"u"&&d!=="JWT")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(d)}. Expected "JWT".`});if(!Ge[g])throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(g)}. Supported: ${Rr}.`});let{azp:f,sub:h,aud:k,iss:P,iat:O,exp:x,nbf:A}=o;if(typeof h!="string")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Subject claim (sub) is required and must be a string. Received ${JSON.stringify(h)}.`});if(_t([k],[e]),f&&r&&r.length>0&&!r.includes(f))throw new p({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(P))throw new p({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&P&&P!==i)throw new p({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof x!="number")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT expiry date claim (exp) ${JSON.stringify(x)}. Expected number.`});let b=new Date(Date.now()),_=new Date(0);if(_.setUTCSeconds(x),_.getTime()<=b.getTime()-n)throw new p({reason:"token-expired",message:`JWT is expired. Expiry date: ${_}, Current date: ${b}.`});if(A!==void 0){if(typeof A!="number")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT not before date claim (nbf) ${JSON.stringify(A)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(A),y.getTime()>b.getTime()+n)throw new p({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${y}; Current date: ${b};`})}if(O!==void 0){if(typeof O!="number")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT issued at date claim (iat) ${JSON.stringify(O)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(O),y.getTime()>b.getTime()+n)throw new p({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${y}; Current date: ${b};`})}let S;try{S=await It(a,s)}catch(y){throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${y}`})}if(!S)throw new p({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var Ne={},wt=0;function Ce(t){return Ne[t]}function xt(t,e=1e3*60*60){Ne[t.kid]=t,wt=Date.now(),e>=0&&setTimeout(()=>{t?delete Ne[t.kid]:Ne={}},e)}var At="local",vr="-----BEGIN PUBLIC KEY-----",Ur="-----END PUBLIC KEY-----",Nr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Cr="IDAQAB";function Tt(t){if(!Ce(At)){if(!t)throw new p({action:"Set the CLERK_JWT_KEY environment variable.",message:"Missing local JWK.",reason:"jwk-local-missing"});let e=t.replace(/(\r\n|\n|\r)/gm,"").replace(vr,"").replace(Ur,"").replace(Nr,"").replace(Cr,"").replace(/\+/g,"-").replace(/\//g,"_");xt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ce(At)}async function Ye({apiKey:t,secretKey:e,apiUrl:r=C,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Ce(s)&&qr();if(u||o){let g,f=e||t;if(f)g=()=>Mr(r,f,n);else if(i)g=()=>Er(i);else throw new p({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:h}=await le(g);if(!h||!h.length)throw new p({action:"Contact support@clerk.com",message:"The JWKS endpoint did not contain any signing keys. Contact support@clerk.com.",reason:"jwk-remote-failed-to-load"});h.forEach(k=>xt(k,a))}let d=Ce(s);if(!d)throw new p({action:"Contact support@clerk.com",message:`Unable to find a signing key in JWKS that matches kid='${s}'.`,reason:"jwk-remote-missing"});return d}async function Er(t){let e=new URL(t);e.pathname=l(e.pathname,".well-known/jwks.json");let r=await v.fetch(e.href);if(!r.ok)throw new p({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${e.href} with code=${r.status}`,reason:"jwk-remote-failed-to-load"});return r.json()}async function Mr(t,e,r){if(!e)throw new p({action:"Set the CLERK_SECRET_KEY or CLERK_API_KEY environment variable.",message:"Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.",reason:"jwk-remote-failed-to-load"});let n=new URL(t);n.pathname=l(n.pathname,r,"/jwks");let i=await v.fetch(n.href,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok)throw new p({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${n.href} with code=${i.status}`,reason:"jwk-remote-failed-to-load"});return i.json()}function qr(){return Date.now()-wt>=300*1e3}async function Rt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,audience:a,authorizedParties:u,clockSkewInSeconds:o,issuer:d,jwksCacheTtlInMs:g,jwtKey:f,skipJwksCache:h}=e,{header:k}=Ue(t),{kid:P}=k,O;if(f)O=Tt(f);else if(typeof d=="string")O=await Ye({issuer:d,kid:P,jwksCacheTtlInMs:g,skipJwksCache:h});else if(r||n)O=await Ye({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:P,jwksCacheTtlInMs:g,skipJwksCache:h});else throw new p({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await He(t,{audience:a,authorizedParties:u,clockSkewInSeconds:o,key:O,issuer:d})}var zr=t=>!!t?.get("__clerk_satellite_url"),Lr=t=>t?.get("__clerk_synced")==="true",jr=t=>t?.get("__clerk_referrer_primary")==="true",Wr=/^Mozilla\/|(Amazon CloudFront)/,Jt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(L(r||e)&&!Wr.test(n||""))return N(t,"header-missing-non-browser")},vt=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&Ve({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return N(t,"header-missing-cors")},Ut=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(L(r||e)&&!n&&zr(i))return U(t,"primary-responds-to-syncing")},Nt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(L(r||e)&&!n)return U(t,"uat-missing")},Ct=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&Ve({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(L(r||e)&&o)return U(t,"cross-origin-referrer")},Et=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&jr(i)&&L(s))return U(t,"satellite-returns-from-primary")},Mt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(ct(r||e)&&!n&&!i)return N(t,"cookie-and-uat-missing")},qt=t=>{let{clientUat:e}=t;if(e==="0")return N(t,"standard-signed-out")},Kt=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},zt=async t=>{let{headerToken:e}=t,r=await jt(t,e);return await Fe(t,r)},Lt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await jt(t,e),i=await Fe(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function Xe(t,e){for(let r of e){let n=await r(t);if(n)return n}return N(t,"unexpected-error")}async function jt(t,e){let{isSatellite:r,proxyUrl:n}=t,i;return r?i=null:n?i=n:i=s=>s.startsWith("https://clerk.")||s.includes(".clerk.accounts"),Rt(e,{...t,issuer:i})}var Wt=t=>{let{sessionUat:e,clientUat:r,isSatellite:n,searchParams:i}=t;if(n&&(!r||r==="0"||!e)&&!Lr(i))return U(t,"satellite-needs-syncing")};function Dr(t,e){if(!t&&L(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function Fr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Dt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||C,t.apiVersion=t.apiVersion||J,Te(t.secretKey||t.apiKey),t.isSatellite&&(Dr(t.signInUrl,t.secretKey||t.apiKey),Fr(t.proxyUrl||t.domain));async function e(){try{return await Xe(t,[zt])}catch(i){return n(i,"header")}}async function r(){try{return await Xe(t,[vt,Jt,Et,Wt,Ut,Mt,Nt,Ct,Kt,qt,Lt])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof p?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?bt(t,i.reason,i.getFullMessage()):U(t,i.reason,i.getFullMessage()):N(t,i.reason,i.getFullMessage())):N(t,"unexpected-error",i.message)}return t.headerToken?e():r()}var Qe=t=>{let{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:d}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:d}};function Ft(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=C,apiVersion:a=J,frontendApi:u="",proxyUrl:o="",publishableKey:d="",isSatellite:g=!1,domain:f="",audience:h=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:_,audience:I,frontendApi:S,proxyUrl:y,publishableKey:c,jwtKey:W,isSatellite:de,domain:Ee,searchParams:Me,...Ze})=>Dt({...Ze,apiKey:b||r,secretKey:_||n,audience:I||h,apiUrl:s,apiVersion:a,frontendApi:S||u,proxyUrl:y||o,publishableKey:c||d,isSatellite:de||g,domain:Ee||f,jwtKey:W||i,searchParams:Me}),localInterstitial:({frontendApi:b,publishableKey:_,proxyUrl:I,isSatellite:S,domain:y,...c})=>De({...c,frontendApi:b||u,proxyUrl:I||o,publishableKey:_||d,isSatellite:S||g,domain:y||f}),remotePublicInterstitial:({frontendApi:b,publishableKey:_,proxyUrl:I,isSatellite:S,domain:y,...c})=>ft({...c,apiUrl:s,frontendApi:b||u,publishableKey:_||d,proxyUrl:I||o,isSatellite:S||g,domain:y||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Re,debugRequestState:Qe}}var Vt=(t,e)=>{let r;if(t.startsWith("http"))r=new URL(t);else{if(!e||!e.startsWith("http"))throw new Error("destination url or return back url should be an absolute path url!");let n=new URL(e);r=new URL(t,n.origin)}return e&&r.searchParams.set("redirect_url",e),r.toString()},$t="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Vr({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=$r(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error($t);let d=`${s}/sign-up`;return t(Vt(e||d,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error($t);let d=`${s}/sign-in`;return t(Vt(r||d,o))}}}function $r(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function Da(t){let e={...t},r=ie(e),n=Ft({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}export{D as AllowlistIdentifier,ht as AuthStatus,Da as Clerk,F as Client,V as DeletedObject,$ as Email,q as EmailAddress,B as ExternalAccount,M as IdentificationLink,G as Invitation,H as OauthAccessToken,nt as ObjectType,K as Organization,Y as OrganizationInvitation,X as OrganizationMembership,ae as OrganizationMembershipPublicUserData,z as PhoneNumber,Q as RedirectUrl,ee as SMSMessage,E as Session,Z as SignInToken,te as Token,ne as User,R as Verification,rr as constants,Ft as createAuthenticateRequest,Qe as debugRequestState,Ue as decodeJwt,it as deserialize,It as hasValidSignature,De as loadInterstitialFromLocal,ws as makeAuthObjectSerializable,ot as prunePrivateMetadata,Vr as redirect,As as sanitizeAuthObject,ut as signedInAuthObject,dt as signedOutAuthObject,He as verifyJwt,Rt as verifyToken};
`}async function ft(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Je(t),r=await le(()=>v.fetch(Je(t)));if(!r.ok)throw new m({action:"Contact support@clerk.com",message:`Error loading Clerk Interstitial from ${e} with code=${r.status}`,reason:"interstitial-remote-failed-to-load"});return r.text()}function Je(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,clerkJSVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u,domain:o,signInUrl:c}=t,d=new URL(e);return d.pathname=l(d.pathname,R,"/public/interstitial"),d.searchParams.append("clerk_js_version",i||yt(r,n)),s?d.searchParams.append("publishable_key",s):d.searchParams.append("frontend_api",r),a&&d.searchParams.append("proxy_url",a),u&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",c||""),We(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),o&&d.searchParams.append("domain",o),d.href}var yt=(t,e)=>!e&&pt(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",Or=(t,{pkgVersion:e,clerkJSVersion:r})=>{let n=t.replace(/http(s)?:\/\//,""),i=yt(t,e);return`https://${n}/npm/@clerk/clerk-js@${r||i}/dist/clerk.browser.js`};var ht=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(ht||{});async function Fe(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:c,domain:d,isSatellite:f,headerToken:h,loadSession:k,loadUser:P,loadOrganization:O,signInUrl:x}=t,{sid:A,org_id:b,sub:I}=e,{sessions:_,users:S,organizations:y}=ie({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,W,de]=await Promise.all([k?_.getSession(A):Promise.resolve(void 0),P?S.getUser(I):Promise.resolve(void 0),O&&b?y.getOrganization({organizationId:b}):Promise.resolve(void 0)]),Bt=ut(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||h||"",session:p,user:W,organization:de},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:c,domain:d,isSatellite:f,signInUrl:x,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Bt}}function C(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:a,domain:u,signInUrl:o,isSignedIn:!1,isInterstitial:!1,isUnknown:!1,toAuth:()=>dt({...t,status:"signed-out",reason:e,message:r})}}function U(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:a,domain:u,proxyUrl:s,signInUrl:o,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function bt(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function Ve({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){let s=Ot(i),a=Ot(n),u=(i||"").split(",").length>(n||"").split(",").length;s&&u&&(a=kt(s));let o=Ir(t.protocol);if(s&&s!==o)return!0;let d=kr(r||e,s||o);return d.port=a||d.port,St(d)!==St(t)||d.hostname!==t.hostname}function kr(t,e="https"){return new URL(`${e}://${t}`)}var Pr={http:"80",https:"443"};function St(t){return t.port||kt(t.protocol)}function kt(t){return Pr[t]}function Ot(t){return t?.split(",")[0]?.trim()||""}function Ir(t){return t?.replace(/:$/,"")||""}var ve={parse(t,e){return _r(t,Pt,e)},stringify(t,e){return Ar(t,Pt,e)}},Pt={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function _r(t,e,r={}){if(!e.codes){e.codes={};for(let o=0;o<e.chars.length;++o)e.codes[e.chars[o]]=o}if(!r.loose&&t.length*e.bits&7)throw new SyntaxError("Invalid padding");let n=t.length;for(;t[n-1]==="=";)if(--n,!r.loose&&!((t.length-n)*e.bits&7))throw new SyntaxError("Invalid padding");let i=new(r.out??Uint8Array)(n*e.bits/8|0),s=0,a=0,u=0;for(let o=0;o<n;++o){let c=e.codes[t[o]];if(c===void 0)throw new SyntaxError("Invalid character "+t[o]);a=a<<e.bits|c,s+=e.bits,s>=8&&(s-=8,i[u++]=255&a>>s)}if(s>=e.bits||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Ar(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",a=0,u=0;for(let o=0;o<t.length;++o)for(u=u<<8|255&t[o],a+=8;a>e.bits;)a-=e.bits,s+=e.chars[i&u>>a];if(a&&(s+=e.chars[i&u<<e.bits-a]),n)for(;s.length*e.bits&7;)s+="=";return s}var wr=t=>Array.isArray(t)&&t.length>0&&t.every(e=>typeof e=="string"),It=(t,e)=>{let r=[e].flat().filter(s=>!!s),n=[t].flat().filter(s=>!!s);if(r.length>0&&n.length>0){if(typeof t=="string"){if(!r.includes(t))throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}else if(wr(t)&&!t.some(s=>r.includes(s)))throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}};var xr=2*1e3,Ge={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},$e="RSASSA-PKCS1-v1_5",Be="ECDSA",Tr={RS256:$e,RS384:$e,RS512:$e,ES256:Be,ES384:Be,ES512:Be},Jr=Object.keys(Ge);async function _t(t,e){let{header:r,signature:n,raw:i}=t,a=new TextEncoder().encode([i.header,i.payload].join(".")),u=await v.crypto.subtle.importKey("jwk",e,{name:Tr[r.alg],hash:Ge[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function Ue(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new m({reason:"token-invalid",message:"Invalid JWT form. A JWT consists of three parts separated by dots."});let[r,n,i]=e,s=new TextDecoder,a=JSON.parse(s.decode(ve.parse(r,{loose:!0}))),u=JSON.parse(s.decode(ve.parse(n,{loose:!0}))),o=ve.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function He(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=xr,issuer:i,key:s}){let a=Ue(t),{header:u,payload:o}=a,{typ:c,alg:d}=u;if(typeof c<"u"&&c!=="JWT")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(c)}. Expected "JWT".`});if(!Ge[d])throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(d)}. Supported: ${Jr}.`});let{azp:f,sub:h,aud:k,iss:P,iat:O,exp:x,nbf:A}=o;if(typeof h!="string")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Subject claim (sub) is required and must be a string. Received ${JSON.stringify(h)}.`});if(It([k],[e]),f&&r&&r.length>0&&!r.includes(f))throw new m({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(P))throw new m({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&P&&P!==i)throw new m({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof x!="number")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT expiry date claim (exp) ${JSON.stringify(x)}. Expected number.`});let b=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(x),I.getTime()<=b.getTime()-n)throw new m({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${b}.`});if(A!==void 0){if(typeof A!="number")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT not before date claim (nbf) ${JSON.stringify(A)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(A),y.getTime()>b.getTime()+n)throw new m({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${y}; Current date: ${b};`})}if(O!==void 0){if(typeof O!="number")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT issued at date claim (iat) ${JSON.stringify(O)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(O),y.getTime()>b.getTime()+n)throw new m({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${y}; Current date: ${b};`})}let S;try{S=await _t(a,s)}catch(y){throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${y}`})}if(!S)throw new m({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var Ne={},wt=0;function Ce(t){return Ne[t]}function xt(t,e=1e3*60*60){Ne[t.kid]=t,wt=Date.now(),e>=0&&setTimeout(()=>{t?delete Ne[t.kid]:Ne={}},e)}var At="local",vr="-----BEGIN PUBLIC KEY-----",Ur="-----END PUBLIC KEY-----",Nr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Cr="IDAQAB";function Tt(t){if(!Ce(At)){if(!t)throw new m({action:"Set the CLERK_JWT_KEY environment variable.",message:"Missing local JWK.",reason:"jwk-local-missing"});let e=t.replace(/(\r\n|\n|\r)/gm,"").replace(vr,"").replace(Ur,"").replace(Nr,"").replace(Cr,"").replace(/\+/g,"-").replace(/\//g,"_");xt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ce(At)}async function Ye({apiKey:t,secretKey:e,apiUrl:r=E,apiVersion:n=R,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Ce(s)&&qr();if(u||o){let d,f=e||t;if(f)d=()=>Mr(r,f,n);else if(i)d=()=>Er(i);else throw new m({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:h}=await le(d);if(!h||!h.length)throw new m({action:"Contact support@clerk.com",message:"The JWKS endpoint did not contain any signing keys. Contact support@clerk.com.",reason:"jwk-remote-failed-to-load"});h.forEach(k=>xt(k,a))}let c=Ce(s);if(!c)throw new m({action:"Contact support@clerk.com",message:`Unable to find a signing key in JWKS that matches kid='${s}'.`,reason:"jwk-remote-missing"});return c}async function Er(t){let e=new URL(t);e.pathname=l(e.pathname,".well-known/jwks.json");let r=await v.fetch(e.href);if(!r.ok)throw new m({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${e.href} with code=${r.status}`,reason:"jwk-remote-failed-to-load"});return r.json()}async function Mr(t,e,r){if(!e)throw new m({action:"Set the CLERK_SECRET_KEY or CLERK_API_KEY environment variable.",message:"Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.",reason:"jwk-remote-failed-to-load"});let n=new URL(t);n.pathname=l(n.pathname,r,"/jwks");let i=await v.fetch(n.href,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok)throw new m({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${n.href} with code=${i.status}`,reason:"jwk-remote-failed-to-load"});return i.json()}function qr(){return Date.now()-wt>=300*1e3}async function Jt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,audience:a,authorizedParties:u,clockSkewInSeconds:o,issuer:c,jwksCacheTtlInMs:d,jwtKey:f,skipJwksCache:h}=e,{header:k}=Ue(t),{kid:P}=k,O;if(f)O=Tt(f);else if(typeof c=="string")O=await Ye({issuer:c,kid:P,jwksCacheTtlInMs:d,skipJwksCache:h});else if(r||n)O=await Ye({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:P,jwksCacheTtlInMs:d,skipJwksCache:h});else throw new m({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await He(t,{audience:a,authorizedParties:u,clockSkewInSeconds:o,key:O,issuer:c})}var zr=t=>!!t?.get("__clerk_satellite_url"),Lr=t=>t?.get("__clerk_synced")==="true",jr=t=>t?.get("__clerk_referrer_primary")==="true",Wr=/^Mozilla\/|(Amazon CloudFront)/,Rt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(N(r||e)&&!Wr.test(n||""))return C(t,"header-missing-non-browser")},vt=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&Ve({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return C(t,"header-missing-cors")},Ut=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(N(r||e)&&!n&&zr(i))return U(t,"primary-responds-to-syncing")},Nt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(N(r||e)&&!n)return U(t,"uat-missing")},Ct=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&Ve({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(N(r||e)&&o)return U(t,"cross-origin-referrer")},Et=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&jr(i)&&N(s))return U(t,"satellite-returns-from-primary")},Mt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(ct(r||e)&&!n&&!i)return C(t,"cookie-and-uat-missing")},qt=t=>{let{clientUat:e}=t;if(e==="0")return C(t,"standard-signed-out")},Kt=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},zt=async t=>{let{headerToken:e}=t,r=await jt(t,e);return await Fe(t,r)},Lt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await jt(t,e),i=await Fe(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function Xe(t,e){for(let r of e){let n=await r(t);if(n)return n}return C(t,"unexpected-error")}async function jt(t,e){let{isSatellite:r,proxyUrl:n}=t,i;return r?i=null:n?i=n:i=s=>s.startsWith("https://clerk.")||s.includes(".clerk.accounts"),Jt(e,{...t,issuer:i})}var Wt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=N(i||s);if(r&&(!e||e==="0")&&!Lr(n)&&!u)return U(t,"satellite-needs-syncing")};function Dr(t,e){if(!t&&N(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function Fr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Dt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||E,t.apiVersion=t.apiVersion||R,Te(t.secretKey||t.apiKey),t.isSatellite&&(Dr(t.signInUrl,t.secretKey||t.apiKey),Fr(t.proxyUrl||t.domain));async function e(){try{return await Xe(t,[zt])}catch(i){return n(i,"header")}}async function r(){try{return await Xe(t,[vt,Rt,Wt,Et,Ut,Mt,Nt,Ct,Kt,qt,Lt])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof m?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?bt(t,i.reason,i.getFullMessage()):U(t,i.reason,i.getFullMessage()):C(t,i.reason,i.getFullMessage())):C(t,"unexpected-error",i.message)}return t.headerToken?e():r()}var Qe=t=>{let{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:c}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:c}};function Ft(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=E,apiVersion:a=R,frontendApi:u="",proxyUrl:o="",publishableKey:c="",isSatellite:d=!1,domain:f="",audience:h=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:I,audience:_,frontendApi:S,proxyUrl:y,publishableKey:p,jwtKey:W,isSatellite:de,domain:Ee,searchParams:Me,...Ze})=>Dt({...Ze,apiKey:b||r,secretKey:I||n,audience:_||h,apiUrl:s,apiVersion:a,frontendApi:S||u,proxyUrl:y||o,publishableKey:p||c,isSatellite:de||d,domain:Ee||f,jwtKey:W||i,searchParams:Me}),localInterstitial:({frontendApi:b,publishableKey:I,proxyUrl:_,isSatellite:S,domain:y,...p})=>De({...p,frontendApi:b||u,proxyUrl:_||o,publishableKey:I||c,isSatellite:S||d,domain:y||f}),remotePublicInterstitial:({frontendApi:b,publishableKey:I,proxyUrl:_,isSatellite:S,domain:y,...p})=>ft({...p,apiUrl:s,frontendApi:b||u,publishableKey:I||c,proxyUrl:_||o,isSatellite:S||d,domain:y||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Je,debugRequestState:Qe}}var Vt=(t,e)=>{let r;if(t.startsWith("http"))r=new URL(t);else{if(!e||!e.startsWith("http"))throw new Error("destination url or return back url should be an absolute path url!");let n=new URL(e);r=new URL(t,n.origin)}return e&&r.searchParams.set("redirect_url",e),r.toString()},$t="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Vr({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=$r(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error($t);let c=`${s}/sign-up`;return t(Vt(e||c,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error($t);let c=`${s}/sign-in`;return t(Vt(r||c,o))}}}function $r(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function Da(t){let e={...t},r=ie(e),n=Ft({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}export{D as AllowlistIdentifier,ht as AuthStatus,Da as Clerk,F as Client,V as DeletedObject,$ as Email,K as EmailAddress,B as ExternalAccount,q as IdentificationLink,G as Invitation,H as OauthAccessToken,nt as ObjectType,z as Organization,Y as OrganizationInvitation,X as OrganizationMembership,ae as OrganizationMembershipPublicUserData,L as PhoneNumber,Q as RedirectUrl,ee as SMSMessage,M as Session,Z as SignInToken,te as Token,ne as User,J as Verification,rr as constants,Ft as createAuthenticateRequest,Qe as debugRequestState,Ue as decodeJwt,it as deserialize,_t as hasValidSignature,De as loadInterstitialFromLocal,ws as makeAuthObjectSerializable,ot as prunePrivateMetadata,Vr as redirect,As as sanitizeAuthObject,ut as signedInAuthObject,dt as signedOutAuthObject,He as verifyJwt,Jt as verifyToken};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

"use strict";var rr=Object.create;var pe=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var sr=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var or=(t,e)=>{for(var r in e)pe(t,r,{get:e[r],enumerable:!0})},pt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ir(e))!ar.call(t,i)&&i!==r&&pe(t,i,{get:()=>e[i],enumerable:!(n=nr(e,i))||n.enumerable});return t};var me=(t,e,r)=>(r=t!=null?rr(sr(t)):{},pt(e||!t||!t.__esModule?pe(r,"default",{value:t,enumerable:!0}):r,t)),lr=t=>pt(pe({},"__esModule",{value:!0}),t);var on={};or(on,{AllowlistIdentifier:()=>W,AuthStatus:()=>et,Clerk:()=>an,Client:()=>D,DeletedObject:()=>F,Email:()=>V,EmailAddress:()=>E,ExternalAccount:()=>$,IdentificationLink:()=>C,Invitation:()=>B,OauthAccessToken:()=>G,ObjectType:()=>$e,Organization:()=>M,OrganizationInvitation:()=>H,OrganizationMembership:()=>Y,OrganizationMembershipPublicUserData:()=>ne,PhoneNumber:()=>q,RedirectUrl:()=>X,SMSMessage:()=>Z,Session:()=>N,SignInToken:()=>Q,Token:()=>ee,User:()=>te,Verification:()=>x,constants:()=>yt,createAuthenticateRequest:()=>dt,debugRequestState:()=>ze,decodeJwt:()=>de,deserialize:()=>Ge,hasValidSignature:()=>at,loadInterstitialFromLocal:()=>Ce,makeAuthObjectSerializable:()=>Ar,prunePrivateMetadata:()=>Ye,redirect:()=>er,sanitizeAuthObject:()=>Ir,signedInAuthObject:()=>Xe,signedOutAuthObject:()=>Qe,verifyJwt:()=>Me,verifyToken:()=>lt});module.exports=lr(on);var m=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var We="/",ur=new RegExp(We+"{1,}","g");function l(...t){return t.filter(e=>e).join(We).replace(ur,We)}var De="/allowlist_identifiers",ge=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:De})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:De,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(De,e)})}};var Fe="/clients",fe=class extends m{async getClientList(){return this.request({method:"GET",path:Fe})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Fe,e)})}verifyClient(e){return this.request({method:"POST",path:l(Fe,"verify"),bodyParams:{token:e}})}};var dr="/domains",ye=class extends m{async deleteDomain(e){return this.request({method:"DELETE",path:l(dr,e)})}};var he="/email_addresses",be=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(he,e)})}async createEmailAddress(e){return this.request({method:"POST",path:he,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(he,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(he,e)})}};var cr="/emails",Se=class extends m{async createEmail(e){return this.request({method:"POST",path:cr,bodyParams:e})}};var Oe=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var Ve="/invitations",ke=class extends m{async getInvitationList(){return this.request({method:"GET",path:Ve})}async createInvitation(e){return this.request({method:"POST",path:Ve,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(Ve,e,"revoke")})}};var w="/organizations",Pe=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var _e="/phone_numbers",Ie=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(_e,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:_e,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(_e,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(_e,e)})}};var Ae="/redirect_urls",we=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:Ae})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Ae,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Ae,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ae,e)})}};var ae="/sessions",xe=class extends m{async getSessionList(e){return this.request({method:"GET",path:ae,queryParams:e})}async getSession(e){return this.requireId(e),this.request({method:"GET",path:l(ae,e)})}async revokeSession(e){return this.requireId(e),this.request({method:"POST",path:l(ae,e,"revoke")})}async verifySession(e,r){return this.requireId(e),this.request({method:"POST",path:l(ae,e,"verify"),bodyParams:{token:r}})}async getToken(e,r){return this.requireId(e),(await this.request({method:"POST",path:l(ae,e,"tokens",r||"")})).jwt}};var mt="/sign_in_tokens",Te=class extends m{async createSignInToken(e){return this.request({method:"POST",path:mt,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(mt,e,"revoke")})}};var pr="/sms_messages",Re=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:pr,bodyParams:e})}};var R="/users",Je=class extends m{async getUserList(e={}){return this.request({method:"GET",path:R,queryParams:e})}async getUser(e){return this.requireId(e),this.request({method:"GET",path:l(R,e)})}async createUser(e){return this.request({method:"POST",path:R,bodyParams:e})}async updateUser(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(R,e),bodyParams:r})}async updateUserMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(R,e,"metadata"),bodyParams:r})}async deleteUser(e){return this.requireId(e),this.request({method:"DELETE",path:l(R,e)})}async getCount(e={}){return this.request({method:"GET",path:l(R,"count"),queryParams:e})}async getUserOauthAccessToken(e,r){return this.requireId(e),this.request({method:"GET",path:l(R,e,"oauth_access_tokens",r)})}async disableUserMFA(e){return this.requireId(e),this.request({method:"DELETE",path:l(R,e,"mfa")})}async getOrganizationMembershipList(e){let{userId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(R,r,"organization_memberships"),queryParams:{limit:n,offset:i}})}async verifyPassword(e){let{userId:r,password:n}=e;return this.requireId(r),this.request({method:"POST",path:l(R,r,"verify_password"),bodyParams:{password:n}})}async verifyTOTP(e){let{userId:r,code:n}=e;return this.requireId(r),this.request({method:"POST",path:l(R,r,"verify_totp"),bodyParams:{code:n}})}};var St=me(require("deepmerge")),He=me(require("snakecase-keys"));var z="https://api.clerk.dev",J="v1",gt="@clerk/backend";var mr={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},gr={Session:"__session",ClientUat:"__client_uat",SessionUat:"__session_uat"},ft={AuthStatus:"x-clerk-auth-status",AuthReason:"x-clerk-auth-reason",AuthMessage:"x-clerk-auth-message",EnableDebug:"x-clerk-debug",ClerkRedirectTo:"x-clerk-redirect-to",Authorization:"authorization",ForwardedPort:"x-forwarded-port",ForwardedProto:"x-forwarded-proto",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},fr={AuthStatus:ft.AuthStatus},yr={Json:"application/json"},yt={Attributes:mr,Cookies:gr,Headers:ft,SearchParams:fr,ContentTypes:yr};var ht=me(require("#crypto")),bt=me(require("#fetch")),hr=bt.default.bind(globalThis),br={crypto:ht.default,fetch:hr},v=br;function ve(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var W=class{constructor(e,r,n,i,s){this.id=e;this.identifier=r;this.createdAt=n;this.updatedAt=i;this.invitationId=s}static fromJSON(e){return new W(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var N=class{constructor(e,r,n,i,s,a,u,o,d){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=a;this.abandonAt=u;this.createdAt=o;this.updatedAt=d}static fromJSON(e){return new N(e.id,e.client_id,e.user_id,e.status,e.last_active_at,e.expire_at,e.abandon_at,e.created_at,e.updated_at)}};var D=class{constructor(e,r,n,i,s,a,u,o){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=a;this.createdAt=u;this.updatedAt=o}static fromJSON(e){return new D(e.id,e.session_ids,e.sessions.map(r=>N.fromJSON(r)),e.sign_in_id,e.sign_up_id,e.last_active_session_id,e.created_at,e.updated_at)}};var F=class{constructor(e,r,n,i){this.object=e;this.id=r;this.slug=n;this.deleted=i}static fromJSON(e){return new F(e.object,e.id||null,e.slug||null,e.deleted)}};var V=class{constructor(e,r,n,i,s,a,u,o,d,g,f){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=a;this.bodyPlain=u;this.status=o;this.slug=d;this.data=g;this.deliveredByClerk=f}static fromJSON(e){return new V(e.id,e.from_email_name,e.email_address_id,e.to_email_address,e.subject,e.body,e.body_plain,e.status,e.slug,e.data,e.delivered_by_clerk)}};var C=class{constructor(e,r){this.id=e;this.type=r}static fromJSON(e){return new C(e.id,e.type)}};var x=class{constructor(e,r,n=null,i=null,s=null,a=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=a}static fromJSON(e){return new x(e.status,e.strategy,e.external_verification_redirect_url?new URL(e.external_verification_redirect_url):null,e.attempts,e.expire_at,e.nonce)}};var E=class{constructor(e,r,n,i){this.id=e;this.emailAddress=r;this.verification=n;this.linkedTo=i}static fromJSON(e){return new E(e.id,e.email_address,e.verification&&x.fromJSON(e.verification),e.linked_to.map(r=>C.fromJSON(r)))}};var $=class{constructor(e,r,n,i,s,a,u,o,d,g,f,h={},k,P){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=a;this.firstName=u;this.lastName=o;this.picture=d;this.imageUrl=g;this.username=f;this.publicMetadata=h;this.label=k;this.verification=P}static fromJSON(e){return new $(e.id,e.provider,e.identification_id,e.provider_user_id,e.approved_scopes,e.email_address,e.first_name,e.last_name,e.avatar_url,e.image_url,e.username,e.public_metadata,e.label,e.verification&&x.fromJSON(e.verification))}};var B=class{constructor(e,r,n,i,s,a,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=a;this.revoked=u}static fromJSON(e){return new B(e.id,e.email_address,e.public_metadata,e.created_at,e.updated_at,e.status,e.revoked)}};var $e=(c=>(c.AllowlistIdentifier="allowlist_identifier",c.Client="client",c.Email="email",c.EmailAddress="email_address",c.ExternalAccount="external_account",c.FacebookAccount="facebook_account",c.GoogleAccount="google_account",c.Invitation="invitation",c.OauthAccessToken="oauth_access_token",c.Organization="organization",c.OrganizationInvitation="organization_invitation",c.OrganizationMembership="organization_membership",c.PhoneNumber="phone_number",c.RedirectUrl="redirect_url",c.Session="session",c.SignInAttempt="sign_in_attempt",c.SignInToken="sign_in_token",c.SignUpAttempt="sign_up_attempt",c.SmsMessage="sms_message",c.User="user",c.Web3Wallet="web3_wallet",c.Token="token",c.TotalCount="total_count",c))($e||{});var G=class{constructor(e,r,n={},i,s,a){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=a}static fromJSON(e){return new G(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var M=class{constructor(e,r,n,i,s,a,u,o,d={},g={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.imageUrl=s;this.createdBy=a;this.createdAt=u;this.updatedAt=o;this.publicMetadata=d;this.privateMetadata=g;this.maxAllowedMemberships=f}static fromJSON(e){return new M(e.id,e.name,e.slug,e.logo_url,e.image_url,e.created_by,e.created_at,e.updated_at,e.public_metadata,e.private_metadata,e.max_allowed_memberships)}};var H=class{constructor(e,r,n,i,s,a,u,o={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=a;this.status=u;this.publicMetadata=o}static fromJSON(e){return new H(e.id,e.email_address,e.role,e.organization_id,e.created_at,e.updated_at,e.status,e.public_metadata)}};var Y=class{constructor(e,r,n={},i={},s,a,u,o){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=a;this.organization=u;this.publicUserData=o}static fromJSON(e){return new Y(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,M.fromJSON(e.organization),ne.fromJSON(e.public_user_data))}},ne=class{constructor(e,r,n,i,s,a){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.imageUrl=s;this.userId=a}static fromJSON(e){return new ne(e.identifier,e.first_name,e.last_name,e.profile_image_url,e.image_url,e.user_id)}};var q=class{constructor(e,r,n,i,s,a){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=a}static fromJSON(e){return new q(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&x.fromJSON(e.verification),e.linked_to.map(r=>C.fromJSON(r)))}};var X=class{constructor(e,r,n,i){this.id=e;this.url=r;this.createdAt=n;this.updatedAt=i}static fromJSON(e){return new X(e.id,e.url,e.created_at,e.updated_at)}};var Q=class{constructor(e,r,n,i,s,a,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=a;this.updatedAt=u}static fromJSON(e){return new Q(e.id,e.user_id,e.token,e.status,e.url,e.created_at,e.updated_at)}};var Z=class{constructor(e,r,n,i,s,a,u){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=a;this.data=u}static fromJSON(e){return new Z(e.id,e.from_phone_number,e.to_phone_number,e.message,e.status,e.phone_number_id,e.data)}};var ee=class{constructor(e){this.jwt=e}static fromJSON(e){return new ee(e.jwt)}};var ie=class{constructor(e,r,n){this.id=e;this.web3Wallet=r;this.verification=n}static fromJSON(e){return new ie(e.id,e.web3_wallet,e.verification&&x.fromJSON(e.verification))}};var te=class{constructor(e,r,n,i,s,a,u,o,d,g,f,h,k,P,O,T,A,b,_,I,S={},y={},c={},re=[],ce=[],Le=[],je=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=a;this.createdAt=u;this.updatedAt=o;this.profileImageUrl=d;this.imageUrl=g;this.gender=f;this.birthday=h;this.primaryEmailAddressId=k;this.primaryPhoneNumberId=P;this.primaryWeb3WalletId=O;this.lastSignInAt=T;this.externalId=A;this.username=b;this.firstName=_;this.lastName=I;this.publicMetadata=S;this.privateMetadata=y;this.unsafeMetadata=c;this.emailAddresses=re;this.phoneNumbers=ce;this.web3Wallets=Le;this.externalAccounts=je}static fromJSON(e){return new te(e.id,e.password_enabled,e.totp_enabled,e.backup_code_enabled,e.two_factor_enabled,e.banned,e.created_at,e.updated_at,e.profile_image_url,e.image_url,e.gender,e.birthday,e.primary_email_address_id,e.primary_phone_number_id,e.primary_web3_wallet_id,e.last_sign_in_at,e.external_id,e.username,e.first_name,e.last_name,e.public_metadata,e.private_metadata,e.unsafe_metadata,(e.email_addresses||[]).map(r=>E.fromJSON(r)),(e.phone_numbers||[]).map(r=>q.fromJSON(r)),(e.web3_wallets||[]).map(r=>ie.fromJSON(r)),(e.external_accounts||[]).map(r=>$.fromJSON(r)))}};function Ge(t){return Array.isArray(t)?t.map(e=>Be(e)):Sr(t)?t.data.map(e=>Be(e)):Be(t)}function Sr(t){return Array.isArray(t.data)&&t.data!==void 0}function Or(t){return t.total_count}function Be(t){if(typeof t!="string"&&"object"in t&&"deleted"in t)return F.fromJSON(t);switch(t.object){case"allowlist_identifier":return W.fromJSON(t);case"client":return D.fromJSON(t);case"email_address":return E.fromJSON(t);case"email":return V.fromJSON(t);case"invitation":return B.fromJSON(t);case"oauth_access_token":return G.fromJSON(t);case"organization":return M.fromJSON(t);case"organization_invitation":return H.fromJSON(t);case"organization_membership":return Y.fromJSON(t);case"phone_number":return q.fromJSON(t);case"redirect_url":return X.fromJSON(t);case"sign_in_token":return Q.fromJSON(t);case"session":return N.fromJSON(t);case"sms_message":return Z.fromJSON(t);case"token":return ee.fromJSON(t);case"total_count":return Or(t);case"user":return te.fromJSON(t);default:return t}}var kr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new oe(s||"",{data:n,status:i||""})};function Ot(t){return kr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=z,apiVersion:a=J,userAgent:u=gt,httpOptions:o={}}=t,{path:d,method:g,queryParams:f,headerParams:h,bodyParams:k}=r,P=i||n;ve(P);let O=l(s,a,d),T=new URL(O);if(f){let S=(0,He.default)({...f});for(let[y,c]of Object.entries(S))c&&[c].flat().forEach(re=>T.searchParams.append(y,re))}let A={Authorization:`Bearer ${P}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...h},_=g!=="GET"&&k&&Object.keys(k).length>0?{body:JSON.stringify((0,He.default)(k,{deep:!1}))}:null,I;try{I=await v.fetch(T.href,(0,St.default)(o,{method:g,headers:A,..._}));let y=await(A&&A["Content-Type"]==="application/json"?I.json():I.text());if(!I.ok)throw y;return{data:Ge(y),errors:null}}catch(S){return S instanceof Error?{data:null,errors:[{code:"unexpected_error",message:S.message||"Unexpected error"}]}:{data:null,errors:Pr(S),status:I?.status,statusText:I?.statusText}}})}function Pr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(_r):[]}return[]}function _r(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var oe=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,oe.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function se(t){let e=Ot(t);return{allowlistIdentifiers:new ge(e),clients:new fe(e),emailAddresses:new be(e),emails:new Se(e),interstitial:new Oe(e),invitations:new ke(e),organizations:new Pe(e),phoneNumbers:new Ie(e),redirectUrls:new we(e),sessions:new xe(e),signInTokens:new Te(e),smsMessages:new Re(e),users:new Je(e),domains:new ye(e)}}var kt=t=>()=>{let e={...t};return e.apiKey=(e.apiKey||"").substring(0,7),e.secretKey=(e.secretKey||"").substring(0,7),e.jwtKey=(e.jwtKey||"").substring(0,7),{...e}};function Xe(t,e,r){let{act:n,sid:i,org_id:s,org_role:a,org_slug:u,sub:o}=t,{apiKey:d,secretKey:g,apiUrl:f,apiVersion:h,token:k,session:P,user:O,organization:T}=e,{sessions:A}=se({apiKey:d,secretKey:g,apiUrl:f,apiVersion:h}),b=wr({sessionId:i,sessionToken:k,fetcher:(..._)=>A.getToken(..._)});return{actor:n,sessionClaims:t,sessionId:i,session:P,userId:o,user:O,orgId:s,orgRole:a,orgSlug:u,organization:T,getToken:b,debug:kt({...e,...r})}}function Qe(t){return{sessionClaims:null,sessionId:null,session:null,userId:null,user:null,actor:null,orgId:null,orgRole:null,orgSlug:null,organization:null,getToken:()=>Promise.resolve(null),debug:kt(t)}}function Ye(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function Ir(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return Ye(e),Ye(r),{...t,user:e,organization:r}}var Ar=t=>{let{debug:e,getToken:r,...n}=t;return n},wr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function xr(t){return new Promise(e=>setTimeout(e,t))}var Tr=5;async function le(t,e=1,r=Tr){try{return await t()}catch(n){if(e>=r)throw n;return await xr(2**e*100),le(t,e+1)}}function L(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function Pt(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function _t(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function Rr(){let t=[".lcl.dev",".stg.dev",".lclstage.dev",".stgstage.dev",".dev.lclclerk.com",".stg.lclclerk.com",".accounts.lclclerk.com","accountsstage.dev","accounts.dev"],e=new Map;return{isDevOrStagingUrl:r=>{if(!r)return!1;let n=typeof r=="string"?r:r.hostname,i=e.get(n);return i===void 0&&(i=t.some(s=>n.endsWith(s)),e.set(n,i)),i}}}var{isDevOrStagingUrl:Ze}=Rr();var It="pk_live_",Jr="pk_test_";function j(t){if(t=t||"",!vr(t))return null;let e=t.startsWith(It)?"production":"development",r=At(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function vr(t){t=t||"";let e=t.startsWith(It)||t.startsWith(Jr),r=At(t.split("_")[2]||"").endsWith("$");return e&&r}var At=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var p=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,p.prototype),this.reason=i,this.message=n,this.action=r}getFullMessage(){return`${[this.message,this.action].filter(r=>r).join(" ")} (reason=${this.reason}, token-carrier=${this.tokenCarrier})`}};function Ur(t){if(!t)return"";let e;if(t.match(/^(clerk\.)+\w*$/))e=/(clerk\.)*(?=clerk\.)/;else{if(t.match(/\.clerk.accounts/))return t;e=/^(clerk\.)*/gi}return`clerk.${t.replace(e,"")}`}function Ce(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Ze(t.frontendApi)?"":Ur(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u=!1,domain:o,signInUrl:d}=t;return`
"use strict";var rr=Object.create;var pe=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var sr=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var or=(t,e)=>{for(var r in e)pe(t,r,{get:e[r],enumerable:!0})},pt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ir(e))!ar.call(t,i)&&i!==r&&pe(t,i,{get:()=>e[i],enumerable:!(n=nr(e,i))||n.enumerable});return t};var me=(t,e,r)=>(r=t!=null?rr(sr(t)):{},pt(e||!t||!t.__esModule?pe(r,"default",{value:t,enumerable:!0}):r,t)),lr=t=>pt(pe({},"__esModule",{value:!0}),t);var on={};or(on,{AllowlistIdentifier:()=>W,AuthStatus:()=>et,Clerk:()=>an,Client:()=>D,DeletedObject:()=>F,Email:()=>V,EmailAddress:()=>E,ExternalAccount:()=>$,IdentificationLink:()=>C,Invitation:()=>B,OauthAccessToken:()=>G,ObjectType:()=>$e,Organization:()=>M,OrganizationInvitation:()=>H,OrganizationMembership:()=>Y,OrganizationMembershipPublicUserData:()=>ne,PhoneNumber:()=>q,RedirectUrl:()=>X,SMSMessage:()=>Z,Session:()=>N,SignInToken:()=>Q,Token:()=>ee,User:()=>te,Verification:()=>x,constants:()=>yt,createAuthenticateRequest:()=>dt,debugRequestState:()=>ze,decodeJwt:()=>de,deserialize:()=>Ge,hasValidSignature:()=>at,loadInterstitialFromLocal:()=>Ce,makeAuthObjectSerializable:()=>Ar,prunePrivateMetadata:()=>Ye,redirect:()=>er,sanitizeAuthObject:()=>_r,signedInAuthObject:()=>Xe,signedOutAuthObject:()=>Qe,verifyJwt:()=>Me,verifyToken:()=>lt});module.exports=lr(on);var g=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var We="/",ur=new RegExp(We+"{1,}","g");function l(...t){return t.filter(e=>e).join(We).replace(ur,We)}var De="/allowlist_identifiers",ge=class extends g{async getAllowlistIdentifierList(){return this.request({method:"GET",path:De})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:De,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(De,e)})}};var Fe="/clients",fe=class extends g{async getClientList(){return this.request({method:"GET",path:Fe})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Fe,e)})}verifyClient(e){return this.request({method:"POST",path:l(Fe,"verify"),bodyParams:{token:e}})}};var dr="/domains",ye=class extends g{async deleteDomain(e){return this.request({method:"DELETE",path:l(dr,e)})}};var he="/email_addresses",be=class extends g{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(he,e)})}async createEmailAddress(e){return this.request({method:"POST",path:he,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(he,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(he,e)})}};var cr="/emails",Se=class extends g{async createEmail(e){return this.request({method:"POST",path:cr,bodyParams:e})}};var Oe=class extends g{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var Ve="/invitations",ke=class extends g{async getInvitationList(){return this.request({method:"GET",path:Ve})}async createInvitation(e){return this.request({method:"POST",path:Ve,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(Ve,e,"revoke")})}};var w="/organizations",Pe=class extends g{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var Ie="/phone_numbers",_e=class extends g{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(Ie,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:Ie,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(Ie,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ie,e)})}};var Ae="/redirect_urls",we=class extends g{async getRedirectUrlList(){return this.request({method:"GET",path:Ae})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Ae,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Ae,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ae,e)})}};var ae="/sessions",xe=class extends g{async getSessionList(e){return this.request({method:"GET",path:ae,queryParams:e})}async getSession(e){return this.requireId(e),this.request({method:"GET",path:l(ae,e)})}async revokeSession(e){return this.requireId(e),this.request({method:"POST",path:l(ae,e,"revoke")})}async verifySession(e,r){return this.requireId(e),this.request({method:"POST",path:l(ae,e,"verify"),bodyParams:{token:r}})}async getToken(e,r){return this.requireId(e),(await this.request({method:"POST",path:l(ae,e,"tokens",r||"")})).jwt}};var mt="/sign_in_tokens",Te=class extends g{async createSignInToken(e){return this.request({method:"POST",path:mt,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(mt,e,"revoke")})}};var pr="/sms_messages",Je=class extends g{async createSMSMessage(e){return this.request({method:"POST",path:pr,bodyParams:e})}};var J="/users",Re=class extends g{async getUserList(e={}){return this.request({method:"GET",path:J,queryParams:e})}async getUser(e){return this.requireId(e),this.request({method:"GET",path:l(J,e)})}async createUser(e){return this.request({method:"POST",path:J,bodyParams:e})}async updateUser(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(J,e),bodyParams:r})}async updateUserMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(J,e,"metadata"),bodyParams:r})}async deleteUser(e){return this.requireId(e),this.request({method:"DELETE",path:l(J,e)})}async getCount(e={}){return this.request({method:"GET",path:l(J,"count"),queryParams:e})}async getUserOauthAccessToken(e,r){return this.requireId(e),this.request({method:"GET",path:l(J,e,"oauth_access_tokens",r)})}async disableUserMFA(e){return this.requireId(e),this.request({method:"DELETE",path:l(J,e,"mfa")})}async getOrganizationMembershipList(e){let{userId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(J,r,"organization_memberships"),queryParams:{limit:n,offset:i}})}async verifyPassword(e){let{userId:r,password:n}=e;return this.requireId(r),this.request({method:"POST",path:l(J,r,"verify_password"),bodyParams:{password:n}})}async verifyTOTP(e){let{userId:r,code:n}=e;return this.requireId(r),this.request({method:"POST",path:l(J,r,"verify_totp"),bodyParams:{code:n}})}};var St=me(require("deepmerge")),He=me(require("snakecase-keys"));var L="https://api.clerk.dev",R="v1",gt="@clerk/backend";var mr={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},gr={Session:"__session",ClientUat:"__client_uat"},ft={AuthStatus:"x-clerk-auth-status",AuthReason:"x-clerk-auth-reason",AuthMessage:"x-clerk-auth-message",EnableDebug:"x-clerk-debug",ClerkRedirectTo:"x-clerk-redirect-to",Authorization:"authorization",ForwardedPort:"x-forwarded-port",ForwardedProto:"x-forwarded-proto",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},fr={AuthStatus:ft.AuthStatus},yr={Json:"application/json"},yt={Attributes:mr,Cookies:gr,Headers:ft,SearchParams:fr,ContentTypes:yr};var ht=me(require("#crypto")),bt=me(require("#fetch")),hr=bt.default.bind(globalThis),br={crypto:ht.default,fetch:hr},v=br;function ve(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var W=class{constructor(e,r,n,i,s){this.id=e;this.identifier=r;this.createdAt=n;this.updatedAt=i;this.invitationId=s}static fromJSON(e){return new W(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var N=class{constructor(e,r,n,i,s,a,u,o,c){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=a;this.abandonAt=u;this.createdAt=o;this.updatedAt=c}static fromJSON(e){return new N(e.id,e.client_id,e.user_id,e.status,e.last_active_at,e.expire_at,e.abandon_at,e.created_at,e.updated_at)}};var D=class{constructor(e,r,n,i,s,a,u,o){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=a;this.createdAt=u;this.updatedAt=o}static fromJSON(e){return new D(e.id,e.session_ids,e.sessions.map(r=>N.fromJSON(r)),e.sign_in_id,e.sign_up_id,e.last_active_session_id,e.created_at,e.updated_at)}};var F=class{constructor(e,r,n,i){this.object=e;this.id=r;this.slug=n;this.deleted=i}static fromJSON(e){return new F(e.object,e.id||null,e.slug||null,e.deleted)}};var V=class{constructor(e,r,n,i,s,a,u,o,c,d,f){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=a;this.bodyPlain=u;this.status=o;this.slug=c;this.data=d;this.deliveredByClerk=f}static fromJSON(e){return new V(e.id,e.from_email_name,e.email_address_id,e.to_email_address,e.subject,e.body,e.body_plain,e.status,e.slug,e.data,e.delivered_by_clerk)}};var C=class{constructor(e,r){this.id=e;this.type=r}static fromJSON(e){return new C(e.id,e.type)}};var x=class{constructor(e,r,n=null,i=null,s=null,a=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=a}static fromJSON(e){return new x(e.status,e.strategy,e.external_verification_redirect_url?new URL(e.external_verification_redirect_url):null,e.attempts,e.expire_at,e.nonce)}};var E=class{constructor(e,r,n,i){this.id=e;this.emailAddress=r;this.verification=n;this.linkedTo=i}static fromJSON(e){return new E(e.id,e.email_address,e.verification&&x.fromJSON(e.verification),e.linked_to.map(r=>C.fromJSON(r)))}};var $=class{constructor(e,r,n,i,s,a,u,o,c,d,f,h={},k,P){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=a;this.firstName=u;this.lastName=o;this.picture=c;this.imageUrl=d;this.username=f;this.publicMetadata=h;this.label=k;this.verification=P}static fromJSON(e){return new $(e.id,e.provider,e.identification_id,e.provider_user_id,e.approved_scopes,e.email_address,e.first_name,e.last_name,e.avatar_url,e.image_url,e.username,e.public_metadata,e.label,e.verification&&x.fromJSON(e.verification))}};var B=class{constructor(e,r,n,i,s,a,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=a;this.revoked=u}static fromJSON(e){return new B(e.id,e.email_address,e.public_metadata,e.created_at,e.updated_at,e.status,e.revoked)}};var $e=(p=>(p.AllowlistIdentifier="allowlist_identifier",p.Client="client",p.Email="email",p.EmailAddress="email_address",p.ExternalAccount="external_account",p.FacebookAccount="facebook_account",p.GoogleAccount="google_account",p.Invitation="invitation",p.OauthAccessToken="oauth_access_token",p.Organization="organization",p.OrganizationInvitation="organization_invitation",p.OrganizationMembership="organization_membership",p.PhoneNumber="phone_number",p.RedirectUrl="redirect_url",p.Session="session",p.SignInAttempt="sign_in_attempt",p.SignInToken="sign_in_token",p.SignUpAttempt="sign_up_attempt",p.SmsMessage="sms_message",p.User="user",p.Web3Wallet="web3_wallet",p.Token="token",p.TotalCount="total_count",p))($e||{});var G=class{constructor(e,r,n={},i,s,a){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=a}static fromJSON(e){return new G(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var M=class{constructor(e,r,n,i,s,a,u,o,c={},d={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.imageUrl=s;this.createdBy=a;this.createdAt=u;this.updatedAt=o;this.publicMetadata=c;this.privateMetadata=d;this.maxAllowedMemberships=f}static fromJSON(e){return new M(e.id,e.name,e.slug,e.logo_url,e.image_url,e.created_by,e.created_at,e.updated_at,e.public_metadata,e.private_metadata,e.max_allowed_memberships)}};var H=class{constructor(e,r,n,i,s,a,u,o={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=a;this.status=u;this.publicMetadata=o}static fromJSON(e){return new H(e.id,e.email_address,e.role,e.organization_id,e.created_at,e.updated_at,e.status,e.public_metadata)}};var Y=class{constructor(e,r,n={},i={},s,a,u,o){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=a;this.organization=u;this.publicUserData=o}static fromJSON(e){return new Y(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,M.fromJSON(e.organization),ne.fromJSON(e.public_user_data))}},ne=class{constructor(e,r,n,i,s,a){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.imageUrl=s;this.userId=a}static fromJSON(e){return new ne(e.identifier,e.first_name,e.last_name,e.profile_image_url,e.image_url,e.user_id)}};var q=class{constructor(e,r,n,i,s,a){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=a}static fromJSON(e){return new q(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&x.fromJSON(e.verification),e.linked_to.map(r=>C.fromJSON(r)))}};var X=class{constructor(e,r,n,i){this.id=e;this.url=r;this.createdAt=n;this.updatedAt=i}static fromJSON(e){return new X(e.id,e.url,e.created_at,e.updated_at)}};var Q=class{constructor(e,r,n,i,s,a,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=a;this.updatedAt=u}static fromJSON(e){return new Q(e.id,e.user_id,e.token,e.status,e.url,e.created_at,e.updated_at)}};var Z=class{constructor(e,r,n,i,s,a,u){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=a;this.data=u}static fromJSON(e){return new Z(e.id,e.from_phone_number,e.to_phone_number,e.message,e.status,e.phone_number_id,e.data)}};var ee=class{constructor(e){this.jwt=e}static fromJSON(e){return new ee(e.jwt)}};var ie=class{constructor(e,r,n){this.id=e;this.web3Wallet=r;this.verification=n}static fromJSON(e){return new ie(e.id,e.web3_wallet,e.verification&&x.fromJSON(e.verification))}};var te=class{constructor(e,r,n,i,s,a,u,o,c,d,f,h,k,P,O,T,A,b,I,_,S={},y={},p={},re=[],ce=[],Le=[],je=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=a;this.createdAt=u;this.updatedAt=o;this.profileImageUrl=c;this.imageUrl=d;this.gender=f;this.birthday=h;this.primaryEmailAddressId=k;this.primaryPhoneNumberId=P;this.primaryWeb3WalletId=O;this.lastSignInAt=T;this.externalId=A;this.username=b;this.firstName=I;this.lastName=_;this.publicMetadata=S;this.privateMetadata=y;this.unsafeMetadata=p;this.emailAddresses=re;this.phoneNumbers=ce;this.web3Wallets=Le;this.externalAccounts=je}static fromJSON(e){return new te(e.id,e.password_enabled,e.totp_enabled,e.backup_code_enabled,e.two_factor_enabled,e.banned,e.created_at,e.updated_at,e.profile_image_url,e.image_url,e.gender,e.birthday,e.primary_email_address_id,e.primary_phone_number_id,e.primary_web3_wallet_id,e.last_sign_in_at,e.external_id,e.username,e.first_name,e.last_name,e.public_metadata,e.private_metadata,e.unsafe_metadata,(e.email_addresses||[]).map(r=>E.fromJSON(r)),(e.phone_numbers||[]).map(r=>q.fromJSON(r)),(e.web3_wallets||[]).map(r=>ie.fromJSON(r)),(e.external_accounts||[]).map(r=>$.fromJSON(r)))}};function Ge(t){return Array.isArray(t)?t.map(e=>Be(e)):Sr(t)?t.data.map(e=>Be(e)):Be(t)}function Sr(t){return Array.isArray(t.data)&&t.data!==void 0}function Or(t){return t.total_count}function Be(t){if(typeof t!="string"&&"object"in t&&"deleted"in t)return F.fromJSON(t);switch(t.object){case"allowlist_identifier":return W.fromJSON(t);case"client":return D.fromJSON(t);case"email_address":return E.fromJSON(t);case"email":return V.fromJSON(t);case"invitation":return B.fromJSON(t);case"oauth_access_token":return G.fromJSON(t);case"organization":return M.fromJSON(t);case"organization_invitation":return H.fromJSON(t);case"organization_membership":return Y.fromJSON(t);case"phone_number":return q.fromJSON(t);case"redirect_url":return X.fromJSON(t);case"sign_in_token":return Q.fromJSON(t);case"session":return N.fromJSON(t);case"sms_message":return Z.fromJSON(t);case"token":return ee.fromJSON(t);case"total_count":return Or(t);case"user":return te.fromJSON(t);default:return t}}var kr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new oe(s||"",{data:n,status:i||""})};function Ot(t){return kr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=L,apiVersion:a=R,userAgent:u=gt,httpOptions:o={}}=t,{path:c,method:d,queryParams:f,headerParams:h,bodyParams:k}=r,P=i||n;ve(P);let O=l(s,a,c),T=new URL(O);if(f){let S=(0,He.default)({...f});for(let[y,p]of Object.entries(S))p&&[p].flat().forEach(re=>T.searchParams.append(y,re))}let A={Authorization:`Bearer ${P}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...h},I=d!=="GET"&&k&&Object.keys(k).length>0?{body:JSON.stringify((0,He.default)(k,{deep:!1}))}:null,_;try{_=await v.fetch(T.href,(0,St.default)(o,{method:d,headers:A,...I}));let y=await(A&&A["Content-Type"]==="application/json"?_.json():_.text());if(!_.ok)throw y;return{data:Ge(y),errors:null}}catch(S){return S instanceof Error?{data:null,errors:[{code:"unexpected_error",message:S.message||"Unexpected error"}]}:{data:null,errors:Pr(S),status:_?.status,statusText:_?.statusText}}})}function Pr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(Ir):[]}return[]}function Ir(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var oe=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,oe.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function se(t){let e=Ot(t);return{allowlistIdentifiers:new ge(e),clients:new fe(e),emailAddresses:new be(e),emails:new Se(e),interstitial:new Oe(e),invitations:new ke(e),organizations:new Pe(e),phoneNumbers:new _e(e),redirectUrls:new we(e),sessions:new xe(e),signInTokens:new Te(e),smsMessages:new Je(e),users:new Re(e),domains:new ye(e)}}var kt=t=>()=>{let e={...t};return e.apiKey=(e.apiKey||"").substring(0,7),e.secretKey=(e.secretKey||"").substring(0,7),e.jwtKey=(e.jwtKey||"").substring(0,7),{...e}};function Xe(t,e,r){let{act:n,sid:i,org_id:s,org_role:a,org_slug:u,sub:o}=t,{apiKey:c,secretKey:d,apiUrl:f,apiVersion:h,token:k,session:P,user:O,organization:T}=e,{sessions:A}=se({apiKey:c,secretKey:d,apiUrl:f,apiVersion:h}),b=wr({sessionId:i,sessionToken:k,fetcher:(...I)=>A.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:P,userId:o,user:O,orgId:s,orgRole:a,orgSlug:u,organization:T,getToken:b,debug:kt({...e,...r})}}function Qe(t){return{sessionClaims:null,sessionId:null,session:null,userId:null,user:null,actor:null,orgId:null,orgRole:null,orgSlug:null,organization:null,getToken:()=>Promise.resolve(null),debug:kt(t)}}function Ye(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function _r(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return Ye(e),Ye(r),{...t,user:e,organization:r}}var Ar=t=>{let{debug:e,getToken:r,...n}=t;return n},wr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function xr(t){return new Promise(e=>setTimeout(e,t))}var Tr=5;async function le(t,e=1,r=Tr){try{return await t()}catch(n){if(e>=r)throw n;return await xr(2**e*100),le(t,e+1)}}function K(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function Pt(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function It(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function Jr(){let t=[".lcl.dev",".stg.dev",".lclstage.dev",".stgstage.dev",".dev.lclclerk.com",".stg.lclclerk.com",".accounts.lclclerk.com","accountsstage.dev","accounts.dev"],e=new Map;return{isDevOrStagingUrl:r=>{if(!r)return!1;let n=typeof r=="string"?r:r.hostname,i=e.get(n);return i===void 0&&(i=t.some(s=>n.endsWith(s)),e.set(n,i)),i}}}var{isDevOrStagingUrl:Ze}=Jr();var _t="pk_live_",Rr="pk_test_";function j(t){if(t=t||"",!vr(t))return null;let e=t.startsWith(_t)?"production":"development",r=At(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function vr(t){t=t||"";let e=t.startsWith(_t)||t.startsWith(Rr),r=At(t.split("_")[2]||"").endsWith("$");return e&&r}var At=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var m=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,m.prototype),this.reason=i,this.message=n,this.action=r}getFullMessage(){return`${[this.message,this.action].filter(r=>r).join(" ")} (reason=${this.reason}, token-carrier=${this.tokenCarrier})`}};function Ur(t){if(!t)return"";let e;if(t.match(/^(clerk\.)+\w*$/))e=/(clerk\.)*(?=clerk\.)/;else{if(t.match(/\.clerk.accounts/))return t;e=/^(clerk\.)*/gi}return`clerk.${t.replace(e,"")}`}function Ce(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Ze(t.frontendApi)?"":Ur(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,clerkJSUrl:s,clerkJSVersion:a,publishableKey:u,proxyUrl:o,isSatellite:c=!1,domain:d,signInUrl:f}=t;return`
<head>

@@ -9,4 +9,4 @@ <meta charset="UTF-8" />

window.__clerk_debug = ${JSON.stringify(r||{})};
${a?`window.__clerk_proxy_url = '${a}'`:""}
${o?`window.__clerk_domain = '${o}'`:""}
${o?`window.__clerk_proxy_url = '${o}'`:""}
${d?`window.__clerk_domain = '${d}'`:""}
window.startClerk = async () => {

@@ -35,5 +35,5 @@ function formRedirect(){

await Clerk.load({
isSatellite: ${u},
isSatellite: ${c},
isInterstitial: ${!0},
signInUrl: ${d?`'${d}'`:void 0}
signInUrl: ${f?`'${f}'`:void 0}
});

@@ -55,8 +55,8 @@ if(Clerk.loaded){

const script = document.createElement('script');
${s?`script.setAttribute('data-clerk-publishable-key', '${s}');`:`script.setAttribute('data-clerk-frontend-api', '${n}');`}
${u?`script.setAttribute('data-clerk-publishable-key', '${u}');`:`script.setAttribute('data-clerk-frontend-api', '${n}');`}
${o?`script.setAttribute('data-clerk-domain', '${o}');`:""}
${a?`script.setAttribute('data-clerk-proxy-url', '${a}')`:""};
${d?`script.setAttribute('data-clerk-domain', '${d}');`:""}
${o?`script.setAttribute('data-clerk-proxy-url', '${o}')`:""};
script.async = true;
script.src = '${Nr(a||e||n,i)}';
script.src = '${s||Nr(o||e||n,{pkgVersion:i,clerkJSVersion:a})}';
script.crossOrigin = 'anonymous';

@@ -68,3 +68,3 @@ script.addEventListener('load', startClerk);

</body>
`}async function wt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Ue(t),r=await le(()=>v.fetch(Ue(t)));if(!r.ok)throw new p({action:"Contact support@clerk.com",message:`Error loading Clerk Interstitial from ${e} with code=${r.status}`,reason:"interstitial-remote-failed-to-load"});return r.text()}function Ue(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t,d=new URL(e);return d.pathname=l(d.pathname,J,"/public/interstitial"),d.searchParams.append("clerk_js_version",xt(r,n)),i?d.searchParams.append("publishable_key",i):d.searchParams.append("frontend_api",r),s&&d.searchParams.append("proxy_url",s),a&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",o||""),Ze(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var xt=(t,e)=>!e&&_t(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",Nr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=xt(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var et=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(et||{});async function tt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:f,headerToken:h,loadSession:k,loadUser:P,loadOrganization:O,signInUrl:T}=t,{sid:A,org_id:b,sub:_}=e,{sessions:I,users:S,organizations:y}=se({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[c,re,ce]=await Promise.all([k?I.getSession(A):Promise.resolve(void 0),P?S.getUser(_):Promise.resolve(void 0),O&&b?y.getOrganization({organizationId:b}):Promise.resolve(void 0)]),tr=Xe(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||h||"",session:c,user:re,organization:ce},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:f,signInUrl:T,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>tr}}function K(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:a,domain:u,signInUrl:o,isSignedIn:!1,isInterstitial:!1,isUnknown:!1,toAuth:()=>Qe({...t,status:"signed-out",reason:e,message:r})}}function U(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:a,domain:u,proxyUrl:s,signInUrl:o,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function Tt(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function rt({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){let s=Jt(i),a=Jt(n),u=(i||"").split(",").length>(n||"").split(",").length;s&&u&&(a=vt(s));let o=Mr(t.protocol);if(s&&s!==o)return!0;let g=Cr(r||e,s||o);return g.port=a||g.port,Rt(g)!==Rt(t)||g.hostname!==t.hostname}function Cr(t,e="https"){return new URL(`${e}://${t}`)}var Er={http:"80",https:"443"};function Rt(t){return t.port||vt(t.protocol)}function vt(t){return Er[t]}function Jt(t){return t?.split(",")[0]?.trim()||""}function Mr(t){return t?.replace(/:$/,"")||""}var Ee={parse(t,e){return qr(t,Ut,e)},stringify(t,e){return Kr(t,Ut,e)}},Ut={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function qr(t,e,r={}){if(!e.codes){e.codes={};for(let o=0;o<e.chars.length;++o)e.codes[e.chars[o]]=o}if(!r.loose&&t.length*e.bits&7)throw new SyntaxError("Invalid padding");let n=t.length;for(;t[n-1]==="=";)if(--n,!r.loose&&!((t.length-n)*e.bits&7))throw new SyntaxError("Invalid padding");let i=new(r.out??Uint8Array)(n*e.bits/8|0),s=0,a=0,u=0;for(let o=0;o<n;++o){let d=e.codes[t[o]];if(d===void 0)throw new SyntaxError("Invalid character "+t[o]);a=a<<e.bits|d,s+=e.bits,s>=8&&(s-=8,i[u++]=255&a>>s)}if(s>=e.bits||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Kr(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",a=0,u=0;for(let o=0;o<t.length;++o)for(u=u<<8|255&t[o],a+=8;a>e.bits;)a-=e.bits,s+=e.chars[i&u>>a];if(a&&(s+=e.chars[i&u<<e.bits-a]),n)for(;s.length*e.bits&7;)s+="=";return s}var zr=t=>Array.isArray(t)&&t.length>0&&t.every(e=>typeof e=="string"),Nt=(t,e)=>{let r=[e].flat().filter(s=>!!s),n=[t].flat().filter(s=>!!s);if(r.length>0&&n.length>0){if(typeof t=="string"){if(!r.includes(t))throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}else if(zr(t)&&!t.some(s=>r.includes(s)))throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}};var Lr=2*1e3,st={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},nt="RSASSA-PKCS1-v1_5",it="ECDSA",jr={RS256:nt,RS384:nt,RS512:nt,ES256:it,ES384:it,ES512:it},Wr=Object.keys(st);async function at(t,e){let{header:r,signature:n,raw:i}=t,a=new TextEncoder().encode([i.header,i.payload].join(".")),u=await v.crypto.subtle.importKey("jwk",e,{name:jr[r.alg],hash:st[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function de(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new p({reason:"token-invalid",message:"Invalid JWT form. A JWT consists of three parts separated by dots."});let[r,n,i]=e,s=new TextDecoder,a=JSON.parse(s.decode(Ee.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Ee.parse(n,{loose:!0}))),o=Ee.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function Me(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=Lr,issuer:i,key:s}){let a=de(t),{header:u,payload:o}=a,{typ:d,alg:g}=u;if(typeof d<"u"&&d!=="JWT")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(d)}. Expected "JWT".`});if(!st[g])throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(g)}. Supported: ${Wr}.`});let{azp:f,sub:h,aud:k,iss:P,iat:O,exp:T,nbf:A}=o;if(typeof h!="string")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Subject claim (sub) is required and must be a string. Received ${JSON.stringify(h)}.`});if(Nt([k],[e]),f&&r&&r.length>0&&!r.includes(f))throw new p({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(P))throw new p({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&P&&P!==i)throw new p({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof T!="number")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT expiry date claim (exp) ${JSON.stringify(T)}. Expected number.`});let b=new Date(Date.now()),_=new Date(0);if(_.setUTCSeconds(T),_.getTime()<=b.getTime()-n)throw new p({reason:"token-expired",message:`JWT is expired. Expiry date: ${_}, Current date: ${b}.`});if(A!==void 0){if(typeof A!="number")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT not before date claim (nbf) ${JSON.stringify(A)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(A),y.getTime()>b.getTime()+n)throw new p({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${y}; Current date: ${b};`})}if(O!==void 0){if(typeof O!="number")throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT issued at date claim (iat) ${JSON.stringify(O)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(O),y.getTime()>b.getTime()+n)throw new p({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${y}; Current date: ${b};`})}let S;try{S=await at(a,s)}catch(y){throw new p({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${y}`})}if(!S)throw new p({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var qe={},Et=0;function Ke(t){return qe[t]}function Mt(t,e=1e3*60*60){qe[t.kid]=t,Et=Date.now(),e>=0&&setTimeout(()=>{t?delete qe[t.kid]:qe={}},e)}var Ct="local",Fr="-----BEGIN PUBLIC KEY-----",Vr="-----END PUBLIC KEY-----",$r="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Br="IDAQAB";function qt(t){if(!Ke(Ct)){if(!t)throw new p({action:"Set the CLERK_JWT_KEY environment variable.",message:"Missing local JWK.",reason:"jwk-local-missing"});let e=t.replace(/(\r\n|\n|\r)/gm,"").replace(Fr,"").replace(Vr,"").replace($r,"").replace(Br,"").replace(/\+/g,"-").replace(/\//g,"_");Mt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ke(Ct)}async function ot({apiKey:t,secretKey:e,apiUrl:r=z,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Ke(s)&&Yr();if(u||o){let g,f=e||t;if(f)g=()=>Hr(r,f,n);else if(i)g=()=>Gr(i);else throw new p({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:h}=await le(g);if(!h||!h.length)throw new p({action:"Contact support@clerk.com",message:"The JWKS endpoint did not contain any signing keys. Contact support@clerk.com.",reason:"jwk-remote-failed-to-load"});h.forEach(k=>Mt(k,a))}let d=Ke(s);if(!d)throw new p({action:"Contact support@clerk.com",message:`Unable to find a signing key in JWKS that matches kid='${s}'.`,reason:"jwk-remote-missing"});return d}async function Gr(t){let e=new URL(t);e.pathname=l(e.pathname,".well-known/jwks.json");let r=await v.fetch(e.href);if(!r.ok)throw new p({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${e.href} with code=${r.status}`,reason:"jwk-remote-failed-to-load"});return r.json()}async function Hr(t,e,r){if(!e)throw new p({action:"Set the CLERK_SECRET_KEY or CLERK_API_KEY environment variable.",message:"Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.",reason:"jwk-remote-failed-to-load"});let n=new URL(t);n.pathname=l(n.pathname,r,"/jwks");let i=await v.fetch(n.href,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok)throw new p({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${n.href} with code=${i.status}`,reason:"jwk-remote-failed-to-load"});return i.json()}function Yr(){return Date.now()-Et>=300*1e3}async function lt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,audience:a,authorizedParties:u,clockSkewInSeconds:o,issuer:d,jwksCacheTtlInMs:g,jwtKey:f,skipJwksCache:h}=e,{header:k}=de(t),{kid:P}=k,O;if(f)O=qt(f);else if(typeof d=="string")O=await ot({issuer:d,kid:P,jwksCacheTtlInMs:g,skipJwksCache:h});else if(r||n)O=await ot({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:P,jwksCacheTtlInMs:g,skipJwksCache:h});else throw new p({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await Me(t,{audience:a,authorizedParties:u,clockSkewInSeconds:o,key:O,issuer:d})}var Qr=t=>!!t?.get("__clerk_satellite_url"),Zr=t=>t?.get("__clerk_synced")==="true",en=t=>t?.get("__clerk_referrer_primary")==="true",tn=/^Mozilla\/|(Amazon CloudFront)/,Kt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(L(r||e)&&!tn.test(n||""))return K(t,"header-missing-non-browser")},zt=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&rt({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return K(t,"header-missing-cors")},Lt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(L(r||e)&&!n&&Qr(i))return U(t,"primary-responds-to-syncing")},jt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(L(r||e)&&!n)return U(t,"uat-missing")},Wt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&rt({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(L(r||e)&&o)return U(t,"cross-origin-referrer")},Dt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&en(i)&&L(s))return U(t,"satellite-returns-from-primary")},Ft=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(Pt(r||e)&&!n&&!i)return K(t,"cookie-and-uat-missing")},Vt=t=>{let{clientUat:e}=t;if(e==="0")return K(t,"standard-signed-out")},$t=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},Bt=async t=>{let{headerToken:e}=t,r=await Ht(t,e);return await tt(t,r)},Gt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await Ht(t,e),i=await tt(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function ut(t,e){for(let r of e){let n=await r(t);if(n)return n}return K(t,"unexpected-error")}async function Ht(t,e){let{isSatellite:r,proxyUrl:n}=t,i;return r?i=null:n?i=n:i=s=>s.startsWith("https://clerk.")||s.includes(".clerk.accounts"),lt(e,{...t,issuer:i})}var Yt=t=>{let{sessionUat:e,clientUat:r,isSatellite:n,searchParams:i}=t;if(n&&(!r||r==="0"||!e)&&!Zr(i))return U(t,"satellite-needs-syncing")};function rn(t,e){if(!t&&L(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function nn(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Xt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||z,t.apiVersion=t.apiVersion||J,ve(t.secretKey||t.apiKey),t.isSatellite&&(rn(t.signInUrl,t.secretKey||t.apiKey),nn(t.proxyUrl||t.domain));async function e(){try{return await ut(t,[Bt])}catch(i){return n(i,"header")}}async function r(){try{return await ut(t,[zt,Kt,Dt,Yt,Lt,Ft,jt,Wt,$t,Vt,Gt])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof p?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?Tt(t,i.reason,i.getFullMessage()):U(t,i.reason,i.getFullMessage()):K(t,i.reason,i.getFullMessage())):K(t,"unexpected-error",i.message)}return t.headerToken?e():r()}var ze=t=>{let{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:d}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:d}};function dt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=z,apiVersion:a=J,frontendApi:u="",proxyUrl:o="",publishableKey:d="",isSatellite:g=!1,domain:f="",audience:h=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:_,audience:I,frontendApi:S,proxyUrl:y,publishableKey:c,jwtKey:re,isSatellite:ce,domain:Le,searchParams:je,...ct})=>Xt({...ct,apiKey:b||r,secretKey:_||n,audience:I||h,apiUrl:s,apiVersion:a,frontendApi:S||u,proxyUrl:y||o,publishableKey:c||d,isSatellite:ce||g,domain:Le||f,jwtKey:re||i,searchParams:je}),localInterstitial:({frontendApi:b,publishableKey:_,proxyUrl:I,isSatellite:S,domain:y,...c})=>Ce({...c,frontendApi:b||u,proxyUrl:I||o,publishableKey:_||d,isSatellite:S||g,domain:y||f}),remotePublicInterstitial:({frontendApi:b,publishableKey:_,proxyUrl:I,isSatellite:S,domain:y,...c})=>wt({...c,apiUrl:s,frontendApi:b||u,publishableKey:_||d,proxyUrl:I||o,isSatellite:S||g,domain:y||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Ue,debugRequestState:ze}}var Qt=(t,e)=>{let r;if(t.startsWith("http"))r=new URL(t);else{if(!e||!e.startsWith("http"))throw new Error("destination url or return back url should be an absolute path url!");let n=new URL(e);r=new URL(t,n.origin)}return e&&r.searchParams.set("redirect_url",e),r.toString()},Zt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function er({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=sn(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error(Zt);let d=`${s}/sign-up`;return t(Qt(e||d,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error(Zt);let d=`${s}/sign-in`;return t(Qt(r||d,o))}}}function sn(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function an(t){let e={...t},r=se(e),n=dt({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}0&&(module.exports={AllowlistIdentifier,AuthStatus,Clerk,Client,DeletedObject,Email,EmailAddress,ExternalAccount,IdentificationLink,Invitation,OauthAccessToken,ObjectType,Organization,OrganizationInvitation,OrganizationMembership,OrganizationMembershipPublicUserData,PhoneNumber,RedirectUrl,SMSMessage,Session,SignInToken,Token,User,Verification,constants,createAuthenticateRequest,debugRequestState,decodeJwt,deserialize,hasValidSignature,loadInterstitialFromLocal,makeAuthObjectSerializable,prunePrivateMetadata,redirect,sanitizeAuthObject,signedInAuthObject,signedOutAuthObject,verifyJwt,verifyToken});
`}async function wt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Ue(t),r=await le(()=>v.fetch(Ue(t)));if(!r.ok)throw new m({action:"Contact support@clerk.com",message:`Error loading Clerk Interstitial from ${e} with code=${r.status}`,reason:"interstitial-remote-failed-to-load"});return r.text()}function Ue(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,clerkJSVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u,domain:o,signInUrl:c}=t,d=new URL(e);return d.pathname=l(d.pathname,R,"/public/interstitial"),d.searchParams.append("clerk_js_version",i||xt(r,n)),s?d.searchParams.append("publishable_key",s):d.searchParams.append("frontend_api",r),a&&d.searchParams.append("proxy_url",a),u&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",c||""),Ze(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),o&&d.searchParams.append("domain",o),d.href}var xt=(t,e)=>!e&&It(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",Nr=(t,{pkgVersion:e,clerkJSVersion:r})=>{let n=t.replace(/http(s)?:\/\//,""),i=xt(t,e);return`https://${n}/npm/@clerk/clerk-js@${r||i}/dist/clerk.browser.js`};var et=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(et||{});async function tt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:c,domain:d,isSatellite:f,headerToken:h,loadSession:k,loadUser:P,loadOrganization:O,signInUrl:T}=t,{sid:A,org_id:b,sub:I}=e,{sessions:_,users:S,organizations:y}=se({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,re,ce]=await Promise.all([k?_.getSession(A):Promise.resolve(void 0),P?S.getUser(I):Promise.resolve(void 0),O&&b?y.getOrganization({organizationId:b}):Promise.resolve(void 0)]),tr=Xe(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||h||"",session:p,user:re,organization:ce},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:c,domain:d,isSatellite:f,signInUrl:T,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>tr}}function z(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:a,domain:u,signInUrl:o,isSignedIn:!1,isInterstitial:!1,isUnknown:!1,toAuth:()=>Qe({...t,status:"signed-out",reason:e,message:r})}}function U(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:a,domain:u,signInUrl:o}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:a,domain:u,proxyUrl:s,signInUrl:o,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function Tt(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:a,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function rt({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){let s=Rt(i),a=Rt(n),u=(i||"").split(",").length>(n||"").split(",").length;s&&u&&(a=vt(s));let o=Mr(t.protocol);if(s&&s!==o)return!0;let d=Cr(r||e,s||o);return d.port=a||d.port,Jt(d)!==Jt(t)||d.hostname!==t.hostname}function Cr(t,e="https"){return new URL(`${e}://${t}`)}var Er={http:"80",https:"443"};function Jt(t){return t.port||vt(t.protocol)}function vt(t){return Er[t]}function Rt(t){return t?.split(",")[0]?.trim()||""}function Mr(t){return t?.replace(/:$/,"")||""}var Ee={parse(t,e){return qr(t,Ut,e)},stringify(t,e){return Kr(t,Ut,e)}},Ut={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function qr(t,e,r={}){if(!e.codes){e.codes={};for(let o=0;o<e.chars.length;++o)e.codes[e.chars[o]]=o}if(!r.loose&&t.length*e.bits&7)throw new SyntaxError("Invalid padding");let n=t.length;for(;t[n-1]==="=";)if(--n,!r.loose&&!((t.length-n)*e.bits&7))throw new SyntaxError("Invalid padding");let i=new(r.out??Uint8Array)(n*e.bits/8|0),s=0,a=0,u=0;for(let o=0;o<n;++o){let c=e.codes[t[o]];if(c===void 0)throw new SyntaxError("Invalid character "+t[o]);a=a<<e.bits|c,s+=e.bits,s>=8&&(s-=8,i[u++]=255&a>>s)}if(s>=e.bits||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Kr(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",a=0,u=0;for(let o=0;o<t.length;++o)for(u=u<<8|255&t[o],a+=8;a>e.bits;)a-=e.bits,s+=e.chars[i&u>>a];if(a&&(s+=e.chars[i&u<<e.bits-a]),n)for(;s.length*e.bits&7;)s+="=";return s}var zr=t=>Array.isArray(t)&&t.length>0&&t.every(e=>typeof e=="string"),Nt=(t,e)=>{let r=[e].flat().filter(s=>!!s),n=[t].flat().filter(s=>!!s);if(r.length>0&&n.length>0){if(typeof t=="string"){if(!r.includes(t))throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}else if(zr(t)&&!t.some(s=>r.includes(s)))throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(t)}. Is not included in "${JSON.stringify(r)}".`})}};var Lr=2*1e3,st={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},nt="RSASSA-PKCS1-v1_5",it="ECDSA",jr={RS256:nt,RS384:nt,RS512:nt,ES256:it,ES384:it,ES512:it},Wr=Object.keys(st);async function at(t,e){let{header:r,signature:n,raw:i}=t,a=new TextEncoder().encode([i.header,i.payload].join(".")),u=await v.crypto.subtle.importKey("jwk",e,{name:jr[r.alg],hash:st[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function de(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new m({reason:"token-invalid",message:"Invalid JWT form. A JWT consists of three parts separated by dots."});let[r,n,i]=e,s=new TextDecoder,a=JSON.parse(s.decode(Ee.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Ee.parse(n,{loose:!0}))),o=Ee.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function Me(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=Lr,issuer:i,key:s}){let a=de(t),{header:u,payload:o}=a,{typ:c,alg:d}=u;if(typeof c<"u"&&c!=="JWT")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(c)}. Expected "JWT".`});if(!st[d])throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(d)}. Supported: ${Wr}.`});let{azp:f,sub:h,aud:k,iss:P,iat:O,exp:T,nbf:A}=o;if(typeof h!="string")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Subject claim (sub) is required and must be a string. Received ${JSON.stringify(h)}.`});if(Nt([k],[e]),f&&r&&r.length>0&&!r.includes(f))throw new m({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(P))throw new m({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&P&&P!==i)throw new m({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof T!="number")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT expiry date claim (exp) ${JSON.stringify(T)}. Expected number.`});let b=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(T),I.getTime()<=b.getTime()-n)throw new m({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${b}.`});if(A!==void 0){if(typeof A!="number")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT not before date claim (nbf) ${JSON.stringify(A)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(A),y.getTime()>b.getTime()+n)throw new m({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${y}; Current date: ${b};`})}if(O!==void 0){if(typeof O!="number")throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT issued at date claim (iat) ${JSON.stringify(O)}. Expected number.`});let y=new Date(0);if(y.setUTCSeconds(O),y.getTime()>b.getTime()+n)throw new m({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${y}; Current date: ${b};`})}let S;try{S=await at(a,s)}catch(y){throw new m({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${y}`})}if(!S)throw new m({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var qe={},Et=0;function Ke(t){return qe[t]}function Mt(t,e=1e3*60*60){qe[t.kid]=t,Et=Date.now(),e>=0&&setTimeout(()=>{t?delete qe[t.kid]:qe={}},e)}var Ct="local",Fr="-----BEGIN PUBLIC KEY-----",Vr="-----END PUBLIC KEY-----",$r="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Br="IDAQAB";function qt(t){if(!Ke(Ct)){if(!t)throw new m({action:"Set the CLERK_JWT_KEY environment variable.",message:"Missing local JWK.",reason:"jwk-local-missing"});let e=t.replace(/(\r\n|\n|\r)/gm,"").replace(Fr,"").replace(Vr,"").replace($r,"").replace(Br,"").replace(/\+/g,"-").replace(/\//g,"_");Mt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ke(Ct)}async function ot({apiKey:t,secretKey:e,apiUrl:r=L,apiVersion:n=R,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Ke(s)&&Yr();if(u||o){let d,f=e||t;if(f)d=()=>Hr(r,f,n);else if(i)d=()=>Gr(i);else throw new m({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:h}=await le(d);if(!h||!h.length)throw new m({action:"Contact support@clerk.com",message:"The JWKS endpoint did not contain any signing keys. Contact support@clerk.com.",reason:"jwk-remote-failed-to-load"});h.forEach(k=>Mt(k,a))}let c=Ke(s);if(!c)throw new m({action:"Contact support@clerk.com",message:`Unable to find a signing key in JWKS that matches kid='${s}'.`,reason:"jwk-remote-missing"});return c}async function Gr(t){let e=new URL(t);e.pathname=l(e.pathname,".well-known/jwks.json");let r=await v.fetch(e.href);if(!r.ok)throw new m({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${e.href} with code=${r.status}`,reason:"jwk-remote-failed-to-load"});return r.json()}async function Hr(t,e,r){if(!e)throw new m({action:"Set the CLERK_SECRET_KEY or CLERK_API_KEY environment variable.",message:"Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.",reason:"jwk-remote-failed-to-load"});let n=new URL(t);n.pathname=l(n.pathname,r,"/jwks");let i=await v.fetch(n.href,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});if(!i.ok)throw new m({action:"Contact support@clerk.com",message:`Error loading Clerk JWKS from ${n.href} with code=${i.status}`,reason:"jwk-remote-failed-to-load"});return i.json()}function Yr(){return Date.now()-Et>=300*1e3}async function lt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,audience:a,authorizedParties:u,clockSkewInSeconds:o,issuer:c,jwksCacheTtlInMs:d,jwtKey:f,skipJwksCache:h}=e,{header:k}=de(t),{kid:P}=k,O;if(f)O=qt(f);else if(typeof c=="string")O=await ot({issuer:c,kid:P,jwksCacheTtlInMs:d,skipJwksCache:h});else if(r||n)O=await ot({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:P,jwksCacheTtlInMs:d,skipJwksCache:h});else throw new m({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await Me(t,{audience:a,authorizedParties:u,clockSkewInSeconds:o,key:O,issuer:c})}var Qr=t=>!!t?.get("__clerk_satellite_url"),Zr=t=>t?.get("__clerk_synced")==="true",en=t=>t?.get("__clerk_referrer_primary")==="true",tn=/^Mozilla\/|(Amazon CloudFront)/,Kt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(K(r||e)&&!tn.test(n||""))return z(t,"header-missing-non-browser")},zt=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&rt({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return z(t,"header-missing-cors")},Lt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(K(r||e)&&!n&&Qr(i))return U(t,"primary-responds-to-syncing")},jt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(K(r||e)&&!n)return U(t,"uat-missing")},Wt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&rt({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(K(r||e)&&o)return U(t,"cross-origin-referrer")},Dt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&en(i)&&K(s))return U(t,"satellite-returns-from-primary")},Ft=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(Pt(r||e)&&!n&&!i)return z(t,"cookie-and-uat-missing")},Vt=t=>{let{clientUat:e}=t;if(e==="0")return z(t,"standard-signed-out")},$t=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},Bt=async t=>{let{headerToken:e}=t,r=await Ht(t,e);return await tt(t,r)},Gt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await Ht(t,e),i=await tt(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function ut(t,e){for(let r of e){let n=await r(t);if(n)return n}return z(t,"unexpected-error")}async function Ht(t,e){let{isSatellite:r,proxyUrl:n}=t,i;return r?i=null:n?i=n:i=s=>s.startsWith("https://clerk.")||s.includes(".clerk.accounts"),lt(e,{...t,issuer:i})}var Yt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=K(i||s);if(r&&(!e||e==="0")&&!Zr(n)&&!u)return U(t,"satellite-needs-syncing")};function rn(t,e){if(!t&&K(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function nn(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Xt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||L,t.apiVersion=t.apiVersion||R,ve(t.secretKey||t.apiKey),t.isSatellite&&(rn(t.signInUrl,t.secretKey||t.apiKey),nn(t.proxyUrl||t.domain));async function e(){try{return await ut(t,[Bt])}catch(i){return n(i,"header")}}async function r(){try{return await ut(t,[zt,Kt,Yt,Dt,Lt,Ft,jt,Wt,$t,Vt,Gt])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof m?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?Tt(t,i.reason,i.getFullMessage()):U(t,i.reason,i.getFullMessage()):z(t,i.reason,i.getFullMessage())):z(t,"unexpected-error",i.message)}return t.headerToken?e():r()}var ze=t=>{let{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:c}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:a,publishableKey:u,isSatellite:o,domain:c}};function dt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=L,apiVersion:a=R,frontendApi:u="",proxyUrl:o="",publishableKey:c="",isSatellite:d=!1,domain:f="",audience:h=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:I,audience:_,frontendApi:S,proxyUrl:y,publishableKey:p,jwtKey:re,isSatellite:ce,domain:Le,searchParams:je,...ct})=>Xt({...ct,apiKey:b||r,secretKey:I||n,audience:_||h,apiUrl:s,apiVersion:a,frontendApi:S||u,proxyUrl:y||o,publishableKey:p||c,isSatellite:ce||d,domain:Le||f,jwtKey:re||i,searchParams:je}),localInterstitial:({frontendApi:b,publishableKey:I,proxyUrl:_,isSatellite:S,domain:y,...p})=>Ce({...p,frontendApi:b||u,proxyUrl:_||o,publishableKey:I||c,isSatellite:S||d,domain:y||f}),remotePublicInterstitial:({frontendApi:b,publishableKey:I,proxyUrl:_,isSatellite:S,domain:y,...p})=>wt({...p,apiUrl:s,frontendApi:b||u,publishableKey:I||c,proxyUrl:_||o,isSatellite:S||d,domain:y||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Ue,debugRequestState:ze}}var Qt=(t,e)=>{let r;if(t.startsWith("http"))r=new URL(t);else{if(!e||!e.startsWith("http"))throw new Error("destination url or return back url should be an absolute path url!");let n=new URL(e);r=new URL(t,n.origin)}return e&&r.searchParams.set("redirect_url",e),r.toString()},Zt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function er({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=sn(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error(Zt);let c=`${s}/sign-up`;return t(Qt(e||c,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error(Zt);let c=`${s}/sign-in`;return t(Qt(r||c,o))}}}function sn(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function an(t){let e={...t},r=se(e),n=dt({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}0&&(module.exports={AllowlistIdentifier,AuthStatus,Clerk,Client,DeletedObject,Email,EmailAddress,ExternalAccount,IdentificationLink,Invitation,OauthAccessToken,ObjectType,Organization,OrganizationInvitation,OrganizationMembership,OrganizationMembershipPublicUserData,PhoneNumber,RedirectUrl,SMSMessage,Session,SignInToken,Token,User,Verification,constants,createAuthenticateRequest,debugRequestState,decodeJwt,deserialize,hasValidSignature,loadInterstitialFromLocal,makeAuthObjectSerializable,prunePrivateMetadata,redirect,sanitizeAuthObject,signedInAuthObject,signedOutAuthObject,verifyJwt,verifyToken});
//# sourceMappingURL=index.js.map

@@ -14,3 +14,2 @@ export declare const API_URL = "https://api.clerk.dev";

readonly ClientUat: "__client_uat";
readonly SessionUat: "__session_uat";
};

@@ -17,0 +16,0 @@ readonly Headers: {

@@ -7,2 +7,4 @@ import type { MultiDomainAndOrProxyPrimitives } from '@clerk/types';

publishableKey: string;
clerkJSUrl?: string;
clerkJSVersion?: string;
pkgVersion?: string;

@@ -9,0 +11,0 @@ debugData?: DebugRequestSate;

@@ -13,3 +13,2 @@ import type { RequestState } from './authStatus';

clientUat?: string;
sessionUat?: string;
headerToken?: string;

@@ -16,0 +15,0 @@ origin?: string;

{
"name": "@clerk/backend",
"version": "0.23.1-snapshot.e5d9418",
"version": "0.23.1-snapshot.fe3ca7b",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Clerk Backend SDK - REST Client for Backend API & JWT verification utilities",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc