@clerk/backend
Advanced tools
Comparing version 0.22.0-staging.eed840e to 0.22.0-staging.fd15b34
@@ -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 Ce="/",Dt=new RegExp(Ce+"{1,}","g");function l(...t){return t.filter(e=>e).join(Ce).replace(Dt,Ce)}var Ee="/allowlist_identifiers",de=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Ee})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Ee,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ee,e)})}};var Me="/clients",ce=class extends m{async getClientList(){return this.request({method:"GET",path:Me})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Me,e)})}verifyClient(e){return this.request({method:"POST",path:l(Me,"verify"),bodyParams:{token:e}})}};var Ft="/domains",pe=class extends m{async deleteDomain(e){return this.request({method:"DELETE",path:l(Ft,e)})}};var me="/email_addresses",ge=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(me,e)})}async createEmailAddress(e){return this.request({method:"POST",path:me,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(me,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(me,e)})}};var Vt="/emails",fe=class extends m{async createEmail(e){return this.request({method:"POST",path:Vt,bodyParams:e})}};var ye=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var qe="/invitations",he=class extends m{async getInvitationList(){return this.request({method:"GET",path:qe})}async createInvitation(e){return this.request({method:"POST",path:qe,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(qe,e,"revoke")})}};var A="/organizations",be=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:A,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:A,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(A,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(A,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,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(A,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(A,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var Se="/phone_numbers",Oe=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(Se,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:Se,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(Se,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(Se,e)})}};var ke="/redirect_urls",Pe=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:ke})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(ke,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:ke,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(ke,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 Xe="/sign_in_tokens",_e=class extends m{async createSignInToken(e){return this.request({method:"POST",path:Xe,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(Xe,e,"revoke")})}};var $t="/sms_messages",Ae=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:$t,bodyParams:e})}};var T="/users",we=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 ir from"deepmerge";import rt from"snakecase-keys";var E="https://api.clerk.dev",J="v1",Qe="@clerk/backend";var Bt={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},Gt={Session:"__session",ClientUat:"__client_uat"},Ze={AuthStatus:"x-clerk-auth-status",AuthReason:"x-clerk-auth-reason",AuthMessage:"x-clerk-auth-message",EnableDebug:"x-clerk-debug",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"},Ht={AuthStatus:Ze.AuthStatus},Yt={Json:"application/json"},Xt={Attributes:Bt,Cookies:Gt,Headers:Ze,SearchParams:Ht,ContentTypes:Yt};import Qt from"#crypto";import Zt from"#fetch";var er=Zt.bind(globalThis),tr={crypto:Qt,fetch:er},v=tr;function xe(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,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 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,d,f,y){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=f;this.deliveredByClerk=y}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 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 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&&R.fromJSON(e.verification),e.linked_to.map(r=>q.fromJSON(r)))}};var B=class{constructor(e,r,n,i,s,a,u,o,d,f,y,P={},h,O){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=f;this.username=y;this.publicMetadata=P;this.label=h;this.verification=O}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 et=(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))(et||{});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,d={},f={},y){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=f;this.maxAllowedMemberships=y}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&&R.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&&R.fromJSON(e.verification))}};var ne=class{constructor(e,r,n,i,s,a,u,o,d,f,y,P,h,O,w,x,b,S,I,_,k={},g={},p={},W=[],ue=[],Ne=[],jt=[]){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=f;this.gender=y;this.birthday=P;this.primaryEmailAddressId=h;this.primaryPhoneNumberId=O;this.primaryWeb3WalletId=w;this.lastSignInAt=x;this.externalId=b;this.username=S;this.firstName=I;this.lastName=_;this.publicMetadata=k;this.privateMetadata=g;this.unsafeMetadata=p;this.emailAddresses=W;this.phoneNumbers=ue;this.web3Wallets=Ne;this.externalAccounts=jt}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 tt(t){return Array.isArray(t)?t.map(e=>Ke(e)):rr(t)?t.data.map(e=>Ke(e)):Ke(t)}function rr(t){return Array.isArray(t.data)&&t.data!==void 0}function nr(t){return t.total_count}function Ke(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 nr(t);case"user":return ne.fromJSON(t);default:return t}}var sr=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 nt(t){return sr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=E,apiVersion:a=J,userAgent:u=Qe,httpOptions:o={}}=t,{path:d,method:f,queryParams:y,headerParams:P,bodyParams:h}=r,O=i||n;xe(O);let w=l(s,a,d),x=new URL(w);if(y){let k=rt({...y});for(let[g,p]of Object.entries(k))p&&[p].flat().forEach(W=>x.searchParams.append(g,W))}let b={Authorization:`Bearer ${O}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...P},I=f!=="GET"&&h&&Object.keys(h).length>0?{body:JSON.stringify(rt(h,{deep:!1}))}:null,_;try{_=await v.fetch(x.href,ir(o,{method:f,headers:b,...I}));let g=await(b&&b["Content-Type"]==="application/json"?_.json():_.text());if(!_.ok)throw g;return{data:tt(g),errors:null}}catch(k){return k instanceof Error?{data:null,errors:[{code:"unexpected_error",message:k.message||"Unexpected error"}]}:{data:null,errors:ar(k),status:_?.status,statusText:_?.statusText}}})}function ar(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(or):[]}return[]}function or(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=nt(t);return{allowlistIdentifiers:new de(e),clients:new ce(e),emailAddresses:new ge(e),emails:new fe(e),interstitial:new ye(e),invitations:new he(e),organizations:new be(e),phoneNumbers:new Oe(e),redirectUrls:new Pe(e),sessions:new Ie(e),signInTokens:new _e(e),smsMessages:new Ae(e),users:new we(e),domains:new pe(e)}}var st=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 at(t,e,r){let{act:n,sid:i,org_id:s,org_role:a,org_slug:u,sub:o}=t,{apiKey:d,secretKey:f,apiUrl:y,apiVersion:P,token:h,session:O,user:w,organization:x}=e,{sessions:b}=ie({apiKey:d,secretKey:f,apiUrl:y,apiVersion:P}),S=lr({sessionId:i,sessionToken:h,fetcher:(...I)=>b.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:O,userId:o,user:w,orgId:s,orgRole:a,orgSlug:u,organization:x,getToken:S,debug:st({...e,...r})}}function ot(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:st(t)}}function it(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function Os(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return it(e),it(r),{...t,user:e,organization:r}}var ks=t=>{let{debug:e,getToken:r,...n}=t;return n},lr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function ur(t){return new Promise(e=>setTimeout(e,t))}var dr=5;async function le(t,e=1,r=dr){try{return await t()}catch(n){if(e>=r)throw n;return await ur(2**e*100),le(t,e+1)}}function N(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function lt(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function ut(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function cr(){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}=cr();var dt="pk_live_",pr="pk_test_";function j(t){if(t=t||"",!mr(t))return null;let e=t.startsWith(dt)?"production":"development",r=ct(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function mr(t){t=t||"";let e=t.startsWith(dt)||t.startsWith(pr),r=ct(t.split("_")[2]||"").endsWith("$");return e&&r}var ct=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var c=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,c.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 gr(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 je(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=ze(t.frontendApi)?"":gr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u=!1,domain:o,signInUrl:d}=t;return` | ||
var m=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var Ce="/",Vt=new RegExp(Ce+"{1,}","g");function l(...t){return t.filter(e=>e).join(Ce).replace(Vt,Ce)}var Ee="/allowlist_identifiers",de=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Ee})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Ee,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ee,e)})}};var Me="/clients",ce=class extends m{async getClientList(){return this.request({method:"GET",path:Me})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Me,e)})}verifyClient(e){return this.request({method:"POST",path:l(Me,"verify"),bodyParams:{token:e}})}};var $t="/domains",pe=class extends m{async deleteDomain(e){return this.request({method:"DELETE",path:l($t,e)})}};var me="/email_addresses",ge=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(me,e)})}async createEmailAddress(e){return this.request({method:"POST",path:me,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(me,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(me,e)})}};var Bt="/emails",fe=class extends m{async createEmail(e){return this.request({method:"POST",path:Bt,bodyParams:e})}};var ye=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var qe="/invitations",he=class extends m{async getInvitationList(){return this.request({method:"GET",path:qe})}async createInvitation(e){return this.request({method:"POST",path:qe,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(qe,e,"revoke")})}};var A="/organizations",be=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:A,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:A,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(A,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(A,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,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(A,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(A,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var Se="/phone_numbers",Oe=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(Se,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:Se,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(Se,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(Se,e)})}};var ke="/redirect_urls",Pe=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:ke})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(ke,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:ke,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(ke,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 Xe="/sign_in_tokens",_e=class extends m{async createSignInToken(e){return this.request({method:"POST",path:Xe,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(Xe,e,"revoke")})}};var Gt="/sms_messages",Ae=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:Gt,bodyParams:e})}};var T="/users",we=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 ar from"deepmerge";import rt from"snakecase-keys";var E="https://api.clerk.dev",J="v1",Qe="@clerk/backend";var Ht={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},Yt={Session:"__session",ClientUat:"__client_uat"},Ze={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"},Xt={AuthStatus:Ze.AuthStatus},Qt={Json:"application/json"},Zt={Attributes:Ht,Cookies:Yt,Headers:Ze,SearchParams:Xt,ContentTypes:Qt};import er from"#crypto";import tr from"#fetch";var rr=tr.bind(globalThis),nr={crypto:er,fetch:rr},v=nr;function xe(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,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 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,d,g,y){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=y}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 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 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&&R.fromJSON(e.verification),e.linked_to.map(r=>q.fromJSON(r)))}};var B=class{constructor(e,r,n,i,s,a,u,o,d,g,y,P={},h,O){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=y;this.publicMetadata=P;this.label=h;this.verification=O}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 et=(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))(et||{});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,d={},g={},y){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=y}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&&R.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&&R.fromJSON(e.verification))}};var ne=class{constructor(e,r,n,i,s,a,u,o,d,g,y,P,h,O,w,x,b,S,I,_,k={},f={},p={},W=[],ue=[],Ne=[],Dt=[]){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=y;this.birthday=P;this.primaryEmailAddressId=h;this.primaryPhoneNumberId=O;this.primaryWeb3WalletId=w;this.lastSignInAt=x;this.externalId=b;this.username=S;this.firstName=I;this.lastName=_;this.publicMetadata=k;this.privateMetadata=f;this.unsafeMetadata=p;this.emailAddresses=W;this.phoneNumbers=ue;this.web3Wallets=Ne;this.externalAccounts=Dt}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 tt(t){return Array.isArray(t)?t.map(e=>Ke(e)):ir(t)?t.data.map(e=>Ke(e)):Ke(t)}function ir(t){return Array.isArray(t.data)&&t.data!==void 0}function sr(t){return t.total_count}function Ke(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 sr(t);case"user":return ne.fromJSON(t);default:return t}}var or=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 nt(t){return or(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=E,apiVersion:a=J,userAgent:u=Qe,httpOptions:o={}}=t,{path:d,method:g,queryParams:y,headerParams:P,bodyParams:h}=r,O=i||n;xe(O);let w=l(s,a,d),x=new URL(w);if(y){let k=rt({...y});for(let[f,p]of Object.entries(k))p&&[p].flat().forEach(W=>x.searchParams.append(f,W))}let b={Authorization:`Bearer ${O}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...P},I=g!=="GET"&&h&&Object.keys(h).length>0?{body:JSON.stringify(rt(h,{deep:!1}))}:null,_;try{_=await v.fetch(x.href,ar(o,{method:g,headers:b,...I}));let f=await(b&&b["Content-Type"]==="application/json"?_.json():_.text());if(!_.ok)throw f;return{data:tt(f),errors:null}}catch(k){return k instanceof Error?{data:null,errors:[{code:"unexpected_error",message:k.message||"Unexpected error"}]}:{data:null,errors:lr(k),status:_?.status,statusText:_?.statusText}}})}function lr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(ur):[]}return[]}function ur(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=nt(t);return{allowlistIdentifiers:new de(e),clients:new ce(e),emailAddresses:new ge(e),emails:new fe(e),interstitial:new ye(e),invitations:new he(e),organizations:new be(e),phoneNumbers:new Oe(e),redirectUrls:new Pe(e),sessions:new Ie(e),signInTokens:new _e(e),smsMessages:new Ae(e),users:new we(e),domains:new pe(e)}}var st=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 at(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:y,apiVersion:P,token:h,session:O,user:w,organization:x}=e,{sessions:b}=ie({apiKey:d,secretKey:g,apiUrl:y,apiVersion:P}),S=dr({sessionId:i,sessionToken:h,fetcher:(...I)=>b.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:O,userId:o,user:w,orgId:s,orgRole:a,orgSlug:u,organization:x,getToken:S,debug:st({...e,...r})}}function ot(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:st(t)}}function it(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function Is(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return it(e),it(r),{...t,user:e,organization:r}}var _s=t=>{let{debug:e,getToken:r,...n}=t;return n},dr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function cr(t){return new Promise(e=>setTimeout(e,t))}var pr=5;async function le(t,e=1,r=pr){try{return await t()}catch(n){if(e>=r)throw n;return await cr(2**e*100),le(t,e+1)}}function N(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function lt(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function ut(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function mr(){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}=mr();var dt="pk_live_",gr="pk_test_";function j(t){if(t=t||"",!fr(t))return null;let e=t.startsWith(dt)?"production":"development",r=ct(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function fr(t){t=t||"";let e=t.startsWith(dt)||t.startsWith(gr),r=ct(t.split("_")[2]||"").endsWith("$");return e&&r}var ct=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var c=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,c.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 yr(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 je(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=ze(t.frontendApi)?"":yr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u=!1,domain:o,signInUrl:d}=t;return` | ||
<head> | ||
@@ -58,3 +58,3 @@ <meta charset="UTF-8" /> | ||
script.async = true; | ||
script.src = '${fr(a||e||n,i)}'; | ||
script.src = '${hr(a||e||n,i)}'; | ||
script.crossOrigin = 'anonymous'; | ||
@@ -66,3 +66,3 @@ script.addEventListener('load', startClerk); | ||
</body> | ||
`}async function pt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Te(t),r=await le(()=>v.fetch(Te(t)));if(!r.ok)throw new c({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 Te(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",mt(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 mt=(t,e)=>!e&&ut(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",fr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=mt(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var gt=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(gt||{});async function We(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:d,domain:f,isSatellite:y,headerToken:P,loadSession:h,loadUser:O,loadOrganization:w,signInUrl:x}=t,{sid:b,org_id:S,sub:I}=e,{sessions:_,users:k,organizations:g}=ie({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,W,ue]=await Promise.all([h?_.getSession(b):Promise.resolve(void 0),O?k.getUser(I):Promise.resolve(void 0),w&&S?g.getOrganization({organizationId:S}):Promise.resolve(void 0)]),Wt=at(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||P||"",session:p,user:W,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:d,domain:f,isSatellite:y,signInUrl:x,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Wt}}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:()=>ot({...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 ft(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 De({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){if(i&&i!==t.protocol)return!0;let s=i||t.protocol,a=yr(r||e,s);return a.port=n||a.port,yt(a)!==yt(t)||a.hostname!==t.hostname}function yr(t,e="https:"){return new URL(`${e}//${t}`)}var hr={"http:":"80","https:":"443"};function yt(t){return t.port||br(t.protocol)}function br(t){return hr[t]}var Je={parse(t,e){return Sr(t,ht,e)},stringify(t,e){return Or(t,ht,e)}},ht={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function Sr(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 Or(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 kr=2*1e3,$e={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},Fe="RSASSA-PKCS1-v1_5",Ve="ECDSA",Pr={RS256:Fe,RS384:Fe,RS512:Fe,ES256:Ve,ES384:Ve,ES512:Ve},Ir=Object.keys($e);async function _r(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:Pr[r.alg],hash:$e[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function Be(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new c({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(Je.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Je.parse(n,{loose:!0}))),o=Je.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function bt(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=kr,issuer:i,key:s}){let a=Be(t),{header:u,payload:o}=a,{typ:d,alg:f}=u;if(typeof d<"u"&&d!=="JWT")throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(d)}. Expected "JWT".`});if(!$e[f])throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(f)}. Supported: ${Ir}.`});let{azp:y,sub:P,aud:h,iss:O,iat:w,exp:x,nbf:b}=o;if(typeof P!="string")throw new c({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(P)}.`});if(typeof h=="string"){if(h!==e)throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(h)}. Expected "${e}".`})}else if(Array.isArray(h)&&h.length>0&&h.every(g=>typeof g=="string")&&!h.includes(e))throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(h)}. Does not include "${e}".`});if(y&&r&&r.length>0&&!r.includes(y))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(y)}. Expected "${r}".`});if(typeof i=="function"&&!i(O))throw new c({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&O&&O!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof x!="number")throw new c({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 S=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(x),I.getTime()<=S.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${S}.`});if(b!==void 0){if(typeof b!="number")throw new c({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(b)}. Expected number.`});let g=new Date(0);if(g.setUTCSeconds(b),g.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${g}; Current date: ${S};`})}if(w!==void 0){if(typeof w!="number")throw new c({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(w)}. Expected number.`});let g=new Date(0);if(g.setUTCSeconds(w),g.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${g}; Current date: ${S};`})}let k;try{k=await _r(a,s)}catch(g){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${g}`})}if(!k)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var ve={},Ot=0;function Ue(t){return ve[t]}function kt(t,e=1e3*60*60){ve[t.kid]=t,Ot=Date.now(),e>=0&&setTimeout(()=>{t?delete ve[t.kid]:ve={}},e)}var St="local",wr="-----BEGIN PUBLIC KEY-----",xr="-----END PUBLIC KEY-----",Tr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Rr="IDAQAB";function Pt(t){if(!Ue(St)){if(!t)throw new c({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(wr,"").replace(xr,"").replace(Tr,"").replace(Rr,"").replace(/\+/g,"-").replace(/\//g,"_");kt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ue(St)}async function Ge({apiKey:t,secretKey:e,apiUrl:r=E,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Ue(s)&&Ur();if(u||o){let f,y=e||t;if(y)f=()=>vr(r,y,n);else if(i)f=()=>Jr(i);else throw new c({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:P}=await le(f);if(!P||!P.length)throw new c({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"});P.forEach(h=>kt(h,a))}let d=Ue(s);if(!d)throw new c({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 Jr(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 c({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 vr(t,e,r){if(!e)throw new c({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 c({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 Ur(){return Date.now()-Ot>=300*1e3}async function It(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:a,clockSkewInSeconds:u,issuer:o,jwksCacheTtlInMs:d,jwtKey:f,skipJwksCache:y}=e,{header:P}=Be(t),{kid:h}=P,O;if(f)O=Pt(f);else if(typeof o=="string")O=await Ge({issuer:o,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else if(r||n)O=await Ge({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else throw new c({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await bt(t,{authorizedParties:a,clockSkewInSeconds:u,key:O,issuer:o})}var Cr=t=>!!t?.get("__clerk_satellite_url"),Er=t=>t?.get("__clerk_synced")==="true",Mr=t=>t?.get("__clerk_referrer_primary")==="true",_t=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(N(r||e)&&!n?.startsWith("Mozilla/"))return C(t,"header-missing-non-browser")},At=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&De({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return C(t,"header-missing-cors")},wt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(N(r||e)&&!n&&Cr(i))return U(t,"primary-responds-to-syncing")},xt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(N(r||e)&&!n)return U(t,"uat-missing")},Tt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&De({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(N(r||e)&&o)return U(t,"cross-origin-referrer")},Rt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&Mr(i)&&N(s))return U(t,"satellite-returns-from-primary")},Jt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(lt(r||e)&&!n&&!i)return C(t,"cookie-and-uat-missing")},vt=t=>{let{clientUat:e}=t;if(e==="0")return C(t,"standard-signed-out")},Ut=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},Nt=async t=>{let{headerToken:e}=t,r=await Et(t,e);return await We(t,r)},Ct=async t=>{let{cookieToken:e,clientUat:r}=t,n=await Et(t,e),i=await We(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function He(t,e){for(let r of e){let n=await r(t);if(n)return n}return C(t,"unexpected-error")}async function Et(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"),It(e,{...t,issuer:i})}var Mt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=N(i||s);if(r&&(!e||e==="0")&&!Er(n)&&!u)return U(t,"satellite-needs-syncing")};function qr(t,e){if(!t&&N(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function Kr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function qt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||E,t.apiVersion=t.apiVersion||J,xe(t.secretKey||t.apiKey),t.isSatellite&&(qr(t.signInUrl,t.secretKey||t.apiKey),Kr(t.proxyUrl||t.domain));async function e(){try{return await He(t,[Nt])}catch(i){return n(i,"header")}}async function r(){try{return await He(t,[At,_t,Mt,Rt,wt,Jt,xt,Tt,Ut,vt,Ct])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof c?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?ft(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 Ye=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 Kt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=E,apiVersion:a=J,frontendApi:u="",proxyUrl:o="",publishableKey:d="",isSatellite:f=!1,domain:y=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:S,frontendApi:I,proxyUrl:_,publishableKey:k,jwtKey:g,isSatellite:p,domain:W,searchParams:ue,...Ne})=>qt({...Ne,apiKey:b||r,secretKey:S||n,apiUrl:s,apiVersion:a,frontendApi:I||u,proxyUrl:_||o,publishableKey:k||d,isSatellite:p||f,domain:W||y,jwtKey:g||i,searchParams:ue}),localInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...g})=>je({...g,frontendApi:b||u,proxyUrl:I||o,publishableKey:S||d,isSatellite:_||f,domain:k||y}),remotePublicInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...g})=>pt({...g,apiUrl:s,frontendApi:b||u,publishableKey:S||d,proxyUrl:I||o,isSatellite:_||f,domain:k||y}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Te,debugRequestState:Ye}}var zt=(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()},Lt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function zr({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=Lr(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error(Lt);let d=`${s}/sign-up`;return t(zt(e||d,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error(Lt);let d=`${s}/sign-in`;return t(zt(r||d,o))}}}function Lr(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function Na(t){let e={...t},r=ie(e),n=Kt({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}export{D as AllowlistIdentifier,gt as AuthStatus,Na 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,et 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,R as Verification,Xt as constants,Kt as createAuthenticateRequest,Ye as debugRequestState,Be as decodeJwt,tt as deserialize,_r as hasValidSignature,je as loadInterstitialFromLocal,ks as makeAuthObjectSerializable,it as prunePrivateMetadata,zr as redirect,Os as sanitizeAuthObject,at as signedInAuthObject,ot as signedOutAuthObject,bt as verifyJwt,It as verifyToken}; | ||
`}async function pt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Te(t),r=await le(()=>v.fetch(Te(t)));if(!r.ok)throw new c({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 Te(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",mt(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 mt=(t,e)=>!e&&ut(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",hr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=mt(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var gt=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(gt||{});async function We(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:y,headerToken:P,loadSession:h,loadUser:O,loadOrganization:w,signInUrl:x}=t,{sid:b,org_id:S,sub:I}=e,{sessions:_,users:k,organizations:f}=ie({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,W,ue]=await Promise.all([h?_.getSession(b):Promise.resolve(void 0),O?k.getUser(I):Promise.resolve(void 0),w&&S?f.getOrganization({organizationId:S}):Promise.resolve(void 0)]),Ft=at(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||P||"",session:p,user:W,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:y,signInUrl:x,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Ft}}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:()=>ot({...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 ft(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 De({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){let s=ht(i),a=ht(n),u=(i||"").split(",").length>(n||"").split(",").length;s&&u&&(a=bt(s));let o=Or(t.protocol);if(s&&s!==o)return!0;let g=br(r||e,s||o);return g.port=a||g.port,yt(g)!==yt(t)||g.hostname!==t.hostname}function br(t,e="https"){return new URL(`${e}://${t}`)}var Sr={http:"80",https:"443"};function yt(t){return t.port||bt(t.protocol)}function bt(t){return Sr[t]}function ht(t){return t?.split(",")[0]?.trim()||""}function Or(t){return t?.replace(/:$/,"")||""}var Je={parse(t,e){return kr(t,St,e)},stringify(t,e){return Pr(t,St,e)}},St={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function kr(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 Pr(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 Ir=2*1e3,$e={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},Fe="RSASSA-PKCS1-v1_5",Ve="ECDSA",_r={RS256:Fe,RS384:Fe,RS512:Fe,ES256:Ve,ES384:Ve,ES512:Ve},Ar=Object.keys($e);async function wr(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:_r[r.alg],hash:$e[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function Be(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new c({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(Je.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Je.parse(n,{loose:!0}))),o=Je.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function Ot(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=Ir,issuer:i,key:s}){let a=Be(t),{header:u,payload:o}=a,{typ:d,alg:g}=u;if(typeof d<"u"&&d!=="JWT")throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(d)}. Expected "JWT".`});if(!$e[g])throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(g)}. Supported: ${Ar}.`});let{azp:y,sub:P,aud:h,iss:O,iat:w,exp:x,nbf:b}=o;if(typeof P!="string")throw new c({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(P)}.`});if(typeof h=="string"){if(h!==e)throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(h)}. Expected "${e}".`})}else if(Array.isArray(h)&&h.length>0&&h.every(f=>typeof f=="string")&&!h.includes(e))throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(h)}. Does not include "${e}".`});if(y&&r&&r.length>0&&!r.includes(y))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(y)}. Expected "${r}".`});if(typeof i=="function"&&!i(O))throw new c({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&O&&O!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof x!="number")throw new c({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 S=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(x),I.getTime()<=S.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${S}.`});if(b!==void 0){if(typeof b!="number")throw new c({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(b)}. Expected number.`});let f=new Date(0);if(f.setUTCSeconds(b),f.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${f}; Current date: ${S};`})}if(w!==void 0){if(typeof w!="number")throw new c({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(w)}. Expected number.`});let f=new Date(0);if(f.setUTCSeconds(w),f.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${f}; Current date: ${S};`})}let k;try{k=await wr(a,s)}catch(f){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${f}`})}if(!k)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var ve={},Pt=0;function Ue(t){return ve[t]}function It(t,e=1e3*60*60){ve[t.kid]=t,Pt=Date.now(),e>=0&&setTimeout(()=>{t?delete ve[t.kid]:ve={}},e)}var kt="local",Tr="-----BEGIN PUBLIC KEY-----",Rr="-----END PUBLIC KEY-----",Jr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",vr="IDAQAB";function _t(t){if(!Ue(kt)){if(!t)throw new c({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(Tr,"").replace(Rr,"").replace(Jr,"").replace(vr,"").replace(/\+/g,"-").replace(/\//g,"_");It({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ue(kt)}async function Ge({apiKey:t,secretKey:e,apiUrl:r=E,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Ue(s)&&Cr();if(u||o){let g,y=e||t;if(y)g=()=>Nr(r,y,n);else if(i)g=()=>Ur(i);else throw new c({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:P}=await le(g);if(!P||!P.length)throw new c({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"});P.forEach(h=>It(h,a))}let d=Ue(s);if(!d)throw new c({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 Ur(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 c({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 Nr(t,e,r){if(!e)throw new c({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 c({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 Cr(){return Date.now()-Pt>=300*1e3}async function At(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:a,clockSkewInSeconds:u,issuer:o,jwksCacheTtlInMs:d,jwtKey:g,skipJwksCache:y}=e,{header:P}=Be(t),{kid:h}=P,O;if(g)O=_t(g);else if(typeof o=="string")O=await Ge({issuer:o,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else if(r||n)O=await Ge({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else throw new c({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await Ot(t,{authorizedParties:a,clockSkewInSeconds:u,key:O,issuer:o})}var Mr=t=>!!t?.get("__clerk_satellite_url"),qr=t=>t?.get("__clerk_synced")==="true",Kr=t=>t?.get("__clerk_referrer_primary")==="true",zr=/^Mozilla\/|(Amazon CloudFront)/,wt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(N(r||e)&&!zr.test(n||""))return C(t,"header-missing-non-browser")},xt=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&De({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return C(t,"header-missing-cors")},Tt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(N(r||e)&&!n&&Mr(i))return U(t,"primary-responds-to-syncing")},Rt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(N(r||e)&&!n)return U(t,"uat-missing")},Jt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&De({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(N(r||e)&&o)return U(t,"cross-origin-referrer")},vt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&Kr(i)&&N(s))return U(t,"satellite-returns-from-primary")},Ut=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(lt(r||e)&&!n&&!i)return C(t,"cookie-and-uat-missing")},Nt=t=>{let{clientUat:e}=t;if(e==="0")return C(t,"standard-signed-out")},Ct=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},Et=async t=>{let{headerToken:e}=t,r=await qt(t,e);return await We(t,r)},Mt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await qt(t,e),i=await We(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function He(t,e){for(let r of e){let n=await r(t);if(n)return n}return C(t,"unexpected-error")}async function qt(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"),At(e,{...t,issuer:i})}var Kt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=N(i||s);if(r&&(!e||e==="0")&&!qr(n)&&!u)return U(t,"satellite-needs-syncing")};function Lr(t,e){if(!t&&N(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function jr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function zt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||E,t.apiVersion=t.apiVersion||J,xe(t.secretKey||t.apiKey),t.isSatellite&&(Lr(t.signInUrl,t.secretKey||t.apiKey),jr(t.proxyUrl||t.domain));async function e(){try{return await He(t,[Et])}catch(i){return n(i,"header")}}async function r(){try{return await He(t,[xt,wt,Kt,vt,Tt,Ut,Rt,Jt,Ct,Nt,Mt])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof c?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?ft(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 Ye=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 Lt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=E,apiVersion:a=J,frontendApi:u="",proxyUrl:o="",publishableKey:d="",isSatellite:g=!1,domain:y=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:S,frontendApi:I,proxyUrl:_,publishableKey:k,jwtKey:f,isSatellite:p,domain:W,searchParams:ue,...Ne})=>zt({...Ne,apiKey:b||r,secretKey:S||n,apiUrl:s,apiVersion:a,frontendApi:I||u,proxyUrl:_||o,publishableKey:k||d,isSatellite:p||g,domain:W||y,jwtKey:f||i,searchParams:ue}),localInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...f})=>je({...f,frontendApi:b||u,proxyUrl:I||o,publishableKey:S||d,isSatellite:_||g,domain:k||y}),remotePublicInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...f})=>pt({...f,apiUrl:s,frontendApi:b||u,publishableKey:S||d,proxyUrl:I||o,isSatellite:_||g,domain:k||y}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Te,debugRequestState:Ye}}var jt=(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()},Wt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Wr({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=Dr(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error(Wt);let d=`${s}/sign-up`;return t(jt(e||d,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error(Wt);let d=`${s}/sign-in`;return t(jt(r||d,o))}}}function Dr(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function Ma(t){let e={...t},r=ie(e),n=Lt({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}export{D as AllowlistIdentifier,gt as AuthStatus,Ma 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,et 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,R as Verification,Zt as constants,Lt as createAuthenticateRequest,Ye as debugRequestState,Be as decodeJwt,tt as deserialize,wr as hasValidSignature,je as loadInterstitialFromLocal,_s as makeAuthObjectSerializable,it as prunePrivateMetadata,Wr as redirect,Is as sanitizeAuthObject,at as signedInAuthObject,ot as signedOutAuthObject,Ot as verifyJwt,At as verifyToken}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var Qt=Object.create;var de=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var nr=(t,e)=>{for(var r in e)de(t,r,{get:e[r],enumerable:!0})},ut=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of er(e))!rr.call(t,i)&&i!==r&&de(t,i,{get:()=>e[i],enumerable:!(n=Zt(e,i))||n.enumerable});return t};var ce=(t,e,r)=>(r=t!=null?Qt(tr(t)):{},ut(e||!t||!t.__esModule?de(r,"default",{value:t,enumerable:!0}):r,t)),ir=t=>ut(de({},"__esModule",{value:!0}),t);var en={};nr(en,{AllowlistIdentifier:()=>W,AuthStatus:()=>Qe,Clerk:()=>Zr,Client:()=>D,DeletedObject:()=>F,Email:()=>V,EmailAddress:()=>E,ExternalAccount:()=>$,IdentificationLink:()=>C,Invitation:()=>B,OauthAccessToken:()=>G,ObjectType:()=>De,Organization:()=>M,OrganizationInvitation:()=>H,OrganizationMembership:()=>Y,OrganizationMembershipPublicUserData:()=>ne,PhoneNumber:()=>q,RedirectUrl:()=>X,SMSMessage:()=>Z,Session:()=>N,SignInToken:()=>Q,Token:()=>ee,User:()=>te,Verification:()=>w,constants:()=>mt,createAuthenticateRequest:()=>lt,debugRequestState:()=>qe,decodeJwt:()=>Ce,deserialize:()=>Ve,hasValidSignature:()=>Tt,loadInterstitialFromLocal:()=>Ue,makeAuthObjectSerializable:()=>kr,prunePrivateMetadata:()=>Be,redirect:()=>Ht,sanitizeAuthObject:()=>Or,signedInAuthObject:()=>Ge,signedOutAuthObject:()=>He,verifyJwt:()=>it,verifyToken:()=>at});module.exports=ir(en);var m=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var ze="/",sr=new RegExp(ze+"{1,}","g");function l(...t){return t.filter(e=>e).join(ze).replace(sr,ze)}var Le="/allowlist_identifiers",pe=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Le})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Le,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Le,e)})}};var je="/clients",me=class extends m{async getClientList(){return this.request({method:"GET",path:je})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(je,e)})}verifyClient(e){return this.request({method:"POST",path:l(je,"verify"),bodyParams:{token:e}})}};var ar="/domains",ge=class extends m{async deleteDomain(e){return this.request({method:"DELETE",path:l(ar,e)})}};var fe="/email_addresses",ye=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(fe,e)})}async createEmailAddress(e){return this.request({method:"POST",path:fe,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(fe,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(fe,e)})}};var or="/emails",he=class extends m{async createEmail(e){return this.request({method:"POST",path:or,bodyParams:e})}};var be=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var We="/invitations",Se=class extends m{async getInvitationList(){return this.request({method:"GET",path:We})}async createInvitation(e){return this.request({method:"POST",path:We,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(We,e,"revoke")})}};var A="/organizations",Oe=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:A,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:A,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(A,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(A,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,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(A,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(A,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var ke="/phone_numbers",Pe=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(ke,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:ke,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(ke,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(ke,e)})}};var Ie="/redirect_urls",_e=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:Ie})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Ie,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Ie,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ie,e)})}};var ae="/sessions",Ae=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 dt="/sign_in_tokens",we=class extends m{async createSignInToken(e){return this.request({method:"POST",path:dt,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(dt,e,"revoke")})}};var lr="/sms_messages",xe=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:lr,bodyParams:e})}};var R="/users",Te=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 yt=ce(require("deepmerge")),$e=ce(require("snakecase-keys"));var L="https://api.clerk.dev",J="v1",ct="@clerk/backend";var ur={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},dr={Session:"__session",ClientUat:"__client_uat"},pt={AuthStatus:"x-clerk-auth-status",AuthReason:"x-clerk-auth-reason",AuthMessage:"x-clerk-auth-message",EnableDebug:"x-clerk-debug",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"},cr={AuthStatus:pt.AuthStatus},pr={Json:"application/json"},mt={Attributes:ur,Cookies:dr,Headers:pt,SearchParams:cr,ContentTypes:pr};var gt=ce(require("#crypto")),ft=ce(require("#fetch")),mr=ft.default.bind(globalThis),gr={crypto:gt.default,fetch:mr},v=gr;function Re(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,f,y){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=f;this.deliveredByClerk=y}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 w=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 w(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&&w.fromJSON(e.verification),e.linked_to.map(r=>C.fromJSON(r)))}};var $=class{constructor(e,r,n,i,s,a,u,o,d,f,y,P={},h,O){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=f;this.username=y;this.publicMetadata=P;this.label=h;this.verification=O}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&&w.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 De=(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))(De||{});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={},f={},y){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=f;this.maxAllowedMemberships=y}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&&w.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&&w.fromJSON(e.verification))}};var te=class{constructor(e,r,n,i,s,a,u,o,d,f,y,P,h,O,x,T,b,S,I,_,k={},g={},p={},re=[],ue=[],Ke=[],Yt=[]){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=f;this.gender=y;this.birthday=P;this.primaryEmailAddressId=h;this.primaryPhoneNumberId=O;this.primaryWeb3WalletId=x;this.lastSignInAt=T;this.externalId=b;this.username=S;this.firstName=I;this.lastName=_;this.publicMetadata=k;this.privateMetadata=g;this.unsafeMetadata=p;this.emailAddresses=re;this.phoneNumbers=ue;this.web3Wallets=Ke;this.externalAccounts=Yt}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 Ve(t){return Array.isArray(t)?t.map(e=>Fe(e)):fr(t)?t.data.map(e=>Fe(e)):Fe(t)}function fr(t){return Array.isArray(t.data)&&t.data!==void 0}function yr(t){return t.total_count}function Fe(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 yr(t);case"user":return te.fromJSON(t);default:return t}}var hr=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 ht(t){return hr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=L,apiVersion:a=J,userAgent:u=ct,httpOptions:o={}}=t,{path:d,method:f,queryParams:y,headerParams:P,bodyParams:h}=r,O=i||n;Re(O);let x=l(s,a,d),T=new URL(x);if(y){let k=(0,$e.default)({...y});for(let[g,p]of Object.entries(k))p&&[p].flat().forEach(re=>T.searchParams.append(g,re))}let b={Authorization:`Bearer ${O}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...P},I=f!=="GET"&&h&&Object.keys(h).length>0?{body:JSON.stringify((0,$e.default)(h,{deep:!1}))}:null,_;try{_=await v.fetch(T.href,(0,yt.default)(o,{method:f,headers:b,...I}));let g=await(b&&b["Content-Type"]==="application/json"?_.json():_.text());if(!_.ok)throw g;return{data:Ve(g),errors:null}}catch(k){return k instanceof Error?{data:null,errors:[{code:"unexpected_error",message:k.message||"Unexpected error"}]}:{data:null,errors:br(k),status:_?.status,statusText:_?.statusText}}})}function br(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(Sr):[]}return[]}function Sr(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=ht(t);return{allowlistIdentifiers:new pe(e),clients:new me(e),emailAddresses:new ye(e),emails:new he(e),interstitial:new be(e),invitations:new Se(e),organizations:new Oe(e),phoneNumbers:new Pe(e),redirectUrls:new _e(e),sessions:new Ae(e),signInTokens:new we(e),smsMessages:new xe(e),users:new Te(e),domains:new ge(e)}}var bt=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 Ge(t,e,r){let{act:n,sid:i,org_id:s,org_role:a,org_slug:u,sub:o}=t,{apiKey:d,secretKey:f,apiUrl:y,apiVersion:P,token:h,session:O,user:x,organization:T}=e,{sessions:b}=se({apiKey:d,secretKey:f,apiUrl:y,apiVersion:P}),S=Pr({sessionId:i,sessionToken:h,fetcher:(...I)=>b.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:O,userId:o,user:x,orgId:s,orgRole:a,orgSlug:u,organization:T,getToken:S,debug:bt({...e,...r})}}function He(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:bt(t)}}function Be(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function Or(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return Be(e),Be(r),{...t,user:e,organization:r}}var kr=t=>{let{debug:e,getToken:r,...n}=t;return n},Pr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function Ir(t){return new Promise(e=>setTimeout(e,t))}var _r=5;async function le(t,e=1,r=_r){try{return await t()}catch(n){if(e>=r)throw n;return await Ir(2**e*100),le(t,e+1)}}function K(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function St(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function Ot(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function Ar(){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:Ye}=Ar();var kt="pk_live_",wr="pk_test_";function j(t){if(t=t||"",!xr(t))return null;let e=t.startsWith(kt)?"production":"development",r=Pt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function xr(t){t=t||"";let e=t.startsWith(kt)||t.startsWith(wr),r=Pt(t.split("_")[2]||"").endsWith("$");return e&&r}var Pt=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var c=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,c.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 Tr(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 Ue(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Ye(t.frontendApi)?"":Tr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u=!1,domain:o,signInUrl:d}=t;return` | ||
"use strict";var er=Object.create;var de=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var nr=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty;var sr=(t,e)=>{for(var r in e)de(t,r,{get:e[r],enumerable:!0})},ut=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rr(e))!ir.call(t,i)&&i!==r&&de(t,i,{get:()=>e[i],enumerable:!(n=tr(e,i))||n.enumerable});return t};var ce=(t,e,r)=>(r=t!=null?er(nr(t)):{},ut(e||!t||!t.__esModule?de(r,"default",{value:t,enumerable:!0}):r,t)),ar=t=>ut(de({},"__esModule",{value:!0}),t);var nn={};sr(nn,{AllowlistIdentifier:()=>W,AuthStatus:()=>Qe,Clerk:()=>rn,Client:()=>D,DeletedObject:()=>F,Email:()=>V,EmailAddress:()=>E,ExternalAccount:()=>$,IdentificationLink:()=>C,Invitation:()=>B,OauthAccessToken:()=>G,ObjectType:()=>De,Organization:()=>M,OrganizationInvitation:()=>H,OrganizationMembership:()=>Y,OrganizationMembershipPublicUserData:()=>ne,PhoneNumber:()=>q,RedirectUrl:()=>X,SMSMessage:()=>Z,Session:()=>N,SignInToken:()=>Q,Token:()=>ee,User:()=>te,Verification:()=>w,constants:()=>mt,createAuthenticateRequest:()=>lt,debugRequestState:()=>qe,decodeJwt:()=>Ce,deserialize:()=>Ve,hasValidSignature:()=>Jt,loadInterstitialFromLocal:()=>Ue,makeAuthObjectSerializable:()=>Ir,prunePrivateMetadata:()=>Be,redirect:()=>Xt,sanitizeAuthObject:()=>Pr,signedInAuthObject:()=>Ge,signedOutAuthObject:()=>He,verifyJwt:()=>it,verifyToken:()=>at});module.exports=ar(nn);var m=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var ze="/",or=new RegExp(ze+"{1,}","g");function l(...t){return t.filter(e=>e).join(ze).replace(or,ze)}var Le="/allowlist_identifiers",pe=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Le})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Le,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Le,e)})}};var je="/clients",me=class extends m{async getClientList(){return this.request({method:"GET",path:je})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(je,e)})}verifyClient(e){return this.request({method:"POST",path:l(je,"verify"),bodyParams:{token:e}})}};var lr="/domains",ge=class extends m{async deleteDomain(e){return this.request({method:"DELETE",path:l(lr,e)})}};var fe="/email_addresses",ye=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(fe,e)})}async createEmailAddress(e){return this.request({method:"POST",path:fe,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(fe,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(fe,e)})}};var ur="/emails",he=class extends m{async createEmail(e){return this.request({method:"POST",path:ur,bodyParams:e})}};var be=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var We="/invitations",Se=class extends m{async getInvitationList(){return this.request({method:"GET",path:We})}async createInvitation(e){return this.request({method:"POST",path:We,bodyParams:e})}async revokeInvitation(e){return this.requireId(e),this.request({method:"POST",path:l(We,e,"revoke")})}};var A="/organizations",Oe=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:A,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:A,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(A,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(A,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(A,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,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(A,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(A,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(A,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(A,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(A,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var ke="/phone_numbers",Pe=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(ke,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:ke,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(ke,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(ke,e)})}};var Ie="/redirect_urls",_e=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:Ie})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Ie,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Ie,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ie,e)})}};var ae="/sessions",Ae=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 dt="/sign_in_tokens",we=class extends m{async createSignInToken(e){return this.request({method:"POST",path:dt,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(dt,e,"revoke")})}};var dr="/sms_messages",xe=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:dr,bodyParams:e})}};var R="/users",Te=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 yt=ce(require("deepmerge")),$e=ce(require("snakecase-keys"));var L="https://api.clerk.dev",J="v1",ct="@clerk/backend";var cr={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},pr={Session:"__session",ClientUat:"__client_uat"},pt={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"},mr={AuthStatus:pt.AuthStatus},gr={Json:"application/json"},mt={Attributes:cr,Cookies:pr,Headers:pt,SearchParams:mr,ContentTypes:gr};var gt=ce(require("#crypto")),ft=ce(require("#fetch")),fr=ft.default.bind(globalThis),yr={crypto:gt.default,fetch:fr},v=yr;function Re(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,y){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=y}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 w=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 w(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&&w.fromJSON(e.verification),e.linked_to.map(r=>C.fromJSON(r)))}};var $=class{constructor(e,r,n,i,s,a,u,o,d,g,y,P={},h,O){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=y;this.publicMetadata=P;this.label=h;this.verification=O}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&&w.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 De=(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))(De||{});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={},y){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=y}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&&w.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&&w.fromJSON(e.verification))}};var te=class{constructor(e,r,n,i,s,a,u,o,d,g,y,P,h,O,x,T,b,S,I,_,k={},f={},p={},re=[],ue=[],Ke=[],Qt=[]){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=y;this.birthday=P;this.primaryEmailAddressId=h;this.primaryPhoneNumberId=O;this.primaryWeb3WalletId=x;this.lastSignInAt=T;this.externalId=b;this.username=S;this.firstName=I;this.lastName=_;this.publicMetadata=k;this.privateMetadata=f;this.unsafeMetadata=p;this.emailAddresses=re;this.phoneNumbers=ue;this.web3Wallets=Ke;this.externalAccounts=Qt}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 Ve(t){return Array.isArray(t)?t.map(e=>Fe(e)):hr(t)?t.data.map(e=>Fe(e)):Fe(t)}function hr(t){return Array.isArray(t.data)&&t.data!==void 0}function br(t){return t.total_count}function Fe(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 br(t);case"user":return te.fromJSON(t);default:return t}}var Sr=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 ht(t){return Sr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=L,apiVersion:a=J,userAgent:u=ct,httpOptions:o={}}=t,{path:d,method:g,queryParams:y,headerParams:P,bodyParams:h}=r,O=i||n;Re(O);let x=l(s,a,d),T=new URL(x);if(y){let k=(0,$e.default)({...y});for(let[f,p]of Object.entries(k))p&&[p].flat().forEach(re=>T.searchParams.append(f,re))}let b={Authorization:`Bearer ${O}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...P},I=g!=="GET"&&h&&Object.keys(h).length>0?{body:JSON.stringify((0,$e.default)(h,{deep:!1}))}:null,_;try{_=await v.fetch(T.href,(0,yt.default)(o,{method:g,headers:b,...I}));let f=await(b&&b["Content-Type"]==="application/json"?_.json():_.text());if(!_.ok)throw f;return{data:Ve(f),errors:null}}catch(k){return k instanceof Error?{data:null,errors:[{code:"unexpected_error",message:k.message||"Unexpected error"}]}:{data:null,errors:Or(k),status:_?.status,statusText:_?.statusText}}})}function Or(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(kr):[]}return[]}function kr(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=ht(t);return{allowlistIdentifiers:new pe(e),clients:new me(e),emailAddresses:new ye(e),emails:new he(e),interstitial:new be(e),invitations:new Se(e),organizations:new Oe(e),phoneNumbers:new Pe(e),redirectUrls:new _e(e),sessions:new Ae(e),signInTokens:new we(e),smsMessages:new xe(e),users:new Te(e),domains:new ge(e)}}var bt=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 Ge(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:y,apiVersion:P,token:h,session:O,user:x,organization:T}=e,{sessions:b}=se({apiKey:d,secretKey:g,apiUrl:y,apiVersion:P}),S=_r({sessionId:i,sessionToken:h,fetcher:(...I)=>b.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:O,userId:o,user:x,orgId:s,orgRole:a,orgSlug:u,organization:T,getToken:S,debug:bt({...e,...r})}}function He(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:bt(t)}}function Be(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function Pr(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return Be(e),Be(r),{...t,user:e,organization:r}}var Ir=t=>{let{debug:e,getToken:r,...n}=t;return n},_r=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function Ar(t){return new Promise(e=>setTimeout(e,t))}var wr=5;async function le(t,e=1,r=wr){try{return await t()}catch(n){if(e>=r)throw n;return await Ar(2**e*100),le(t,e+1)}}function K(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function St(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function Ot(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function xr(){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:Ye}=xr();var kt="pk_live_",Tr="pk_test_";function j(t){if(t=t||"",!Rr(t))return null;let e=t.startsWith(kt)?"production":"development",r=Pt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function Rr(t){t=t||"";let e=t.startsWith(kt)||t.startsWith(Tr),r=Pt(t.split("_")[2]||"").endsWith("$");return e&&r}var Pt=t=>typeof atob<"u"&&typeof atob=="function"?atob(t):typeof globalThis<"u"&&globalThis.Buffer?new globalThis.Buffer(t,"base64").toString():t;var c=class extends Error{constructor({action:r,message:n,reason:i}){super(n);Object.setPrototypeOf(this,c.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 Jr(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 Ue(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Ye(t.frontendApi)?"":Jr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:a,isSatellite:u=!1,domain:o,signInUrl:d}=t;return` | ||
<head> | ||
@@ -58,3 +58,3 @@ <meta charset="UTF-8" /> | ||
script.async = true; | ||
script.src = '${Rr(a||e||n,i)}'; | ||
script.src = '${vr(a||e||n,i)}'; | ||
script.crossOrigin = 'anonymous'; | ||
@@ -66,3 +66,3 @@ script.addEventListener('load', startClerk); | ||
</body> | ||
`}async function It(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 c({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,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",_t(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||""),Ye(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var _t=(t,e)=>!e&&Ot(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",Rr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=_t(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var Qe=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(Qe||{});async function Ze(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:d,domain:f,isSatellite:y,headerToken:P,loadSession:h,loadUser:O,loadOrganization:x,signInUrl:T}=t,{sid:b,org_id:S,sub:I}=e,{sessions:_,users:k,organizations:g}=se({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,re,ue]=await Promise.all([h?_.getSession(b):Promise.resolve(void 0),O?k.getUser(I):Promise.resolve(void 0),x&&S?g.getOrganization({organizationId:S}):Promise.resolve(void 0)]),Xt=Ge(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||P||"",session:p,user:re,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:d,domain:f,isSatellite:y,signInUrl:T,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Xt}}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:()=>He({...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 At(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 et({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){if(i&&i!==t.protocol)return!0;let s=i||t.protocol,a=Jr(r||e,s);return a.port=n||a.port,wt(a)!==wt(t)||a.hostname!==t.hostname}function Jr(t,e="https:"){return new URL(`${e}//${t}`)}var vr={"http:":"80","https:":"443"};function wt(t){return t.port||Ur(t.protocol)}function Ur(t){return vr[t]}var Ne={parse(t,e){return Nr(t,xt,e)},stringify(t,e){return Cr(t,xt,e)}},xt={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function Nr(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 Cr(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 Er=2*1e3,nt={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},tt="RSASSA-PKCS1-v1_5",rt="ECDSA",Mr={RS256:tt,RS384:tt,RS512:tt,ES256:rt,ES384:rt,ES512:rt},qr=Object.keys(nt);async function Tt(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:Mr[r.alg],hash:nt[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function Ce(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new c({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(Ne.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Ne.parse(n,{loose:!0}))),o=Ne.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function it(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=Er,issuer:i,key:s}){let a=Ce(t),{header:u,payload:o}=a,{typ:d,alg:f}=u;if(typeof d<"u"&&d!=="JWT")throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(d)}. Expected "JWT".`});if(!nt[f])throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(f)}. Supported: ${qr}.`});let{azp:y,sub:P,aud:h,iss:O,iat:x,exp:T,nbf:b}=o;if(typeof P!="string")throw new c({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(P)}.`});if(typeof h=="string"){if(h!==e)throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(h)}. Expected "${e}".`})}else if(Array.isArray(h)&&h.length>0&&h.every(g=>typeof g=="string")&&!h.includes(e))throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(h)}. Does not include "${e}".`});if(y&&r&&r.length>0&&!r.includes(y))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(y)}. Expected "${r}".`});if(typeof i=="function"&&!i(O))throw new c({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&O&&O!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof T!="number")throw new c({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 S=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(T),I.getTime()<=S.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${S}.`});if(b!==void 0){if(typeof b!="number")throw new c({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(b)}. Expected number.`});let g=new Date(0);if(g.setUTCSeconds(b),g.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${g}; Current date: ${S};`})}if(x!==void 0){if(typeof x!="number")throw new c({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(x)}. Expected number.`});let g=new Date(0);if(g.setUTCSeconds(x),g.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${g}; Current date: ${S};`})}let k;try{k=await Tt(a,s)}catch(g){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${g}`})}if(!k)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var Ee={},Jt=0;function Me(t){return Ee[t]}function vt(t,e=1e3*60*60){Ee[t.kid]=t,Jt=Date.now(),e>=0&&setTimeout(()=>{t?delete Ee[t.kid]:Ee={}},e)}var Rt="local",zr="-----BEGIN PUBLIC KEY-----",Lr="-----END PUBLIC KEY-----",jr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Wr="IDAQAB";function Ut(t){if(!Me(Rt)){if(!t)throw new c({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(zr,"").replace(Lr,"").replace(jr,"").replace(Wr,"").replace(/\+/g,"-").replace(/\//g,"_");vt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Me(Rt)}async function st({apiKey:t,secretKey:e,apiUrl:r=L,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Me(s)&&Vr();if(u||o){let f,y=e||t;if(y)f=()=>Fr(r,y,n);else if(i)f=()=>Dr(i);else throw new c({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:P}=await le(f);if(!P||!P.length)throw new c({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"});P.forEach(h=>vt(h,a))}let d=Me(s);if(!d)throw new c({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 Dr(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 c({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 Fr(t,e,r){if(!e)throw new c({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 c({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 Vr(){return Date.now()-Jt>=300*1e3}async function at(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:a,clockSkewInSeconds:u,issuer:o,jwksCacheTtlInMs:d,jwtKey:f,skipJwksCache:y}=e,{header:P}=Ce(t),{kid:h}=P,O;if(f)O=Ut(f);else if(typeof o=="string")O=await st({issuer:o,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else if(r||n)O=await st({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else throw new c({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await it(t,{authorizedParties:a,clockSkewInSeconds:u,key:O,issuer:o})}var Br=t=>!!t?.get("__clerk_satellite_url"),Gr=t=>t?.get("__clerk_synced")==="true",Hr=t=>t?.get("__clerk_referrer_primary")==="true",Nt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(K(r||e)&&!n?.startsWith("Mozilla/"))return z(t,"header-missing-non-browser")},Ct=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&et({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return z(t,"header-missing-cors")},Et=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(K(r||e)&&!n&&Br(i))return U(t,"primary-responds-to-syncing")},Mt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(K(r||e)&&!n)return U(t,"uat-missing")},qt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&et({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(K(r||e)&&o)return U(t,"cross-origin-referrer")},Kt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&Hr(i)&&K(s))return U(t,"satellite-returns-from-primary")},zt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(St(r||e)&&!n&&!i)return z(t,"cookie-and-uat-missing")},Lt=t=>{let{clientUat:e}=t;if(e==="0")return z(t,"standard-signed-out")},jt=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},Wt=async t=>{let{headerToken:e}=t,r=await Ft(t,e);return await Ze(t,r)},Dt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await Ft(t,e),i=await Ze(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function ot(t,e){for(let r of e){let n=await r(t);if(n)return n}return z(t,"unexpected-error")}async function Ft(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"),at(e,{...t,issuer:i})}var Vt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=K(i||s);if(r&&(!e||e==="0")&&!Gr(n)&&!u)return U(t,"satellite-needs-syncing")};function Yr(t,e){if(!t&&K(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function Xr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function $t(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||L,t.apiVersion=t.apiVersion||J,Re(t.secretKey||t.apiKey),t.isSatellite&&(Yr(t.signInUrl,t.secretKey||t.apiKey),Xr(t.proxyUrl||t.domain));async function e(){try{return await ot(t,[Wt])}catch(i){return n(i,"header")}}async function r(){try{return await ot(t,[Ct,Nt,Vt,Kt,Et,zt,Mt,qt,jt,Lt,Dt])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof c?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?At(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 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 lt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=L,apiVersion:a=J,frontendApi:u="",proxyUrl:o="",publishableKey:d="",isSatellite:f=!1,domain:y=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:S,frontendApi:I,proxyUrl:_,publishableKey:k,jwtKey:g,isSatellite:p,domain:re,searchParams:ue,...Ke})=>$t({...Ke,apiKey:b||r,secretKey:S||n,apiUrl:s,apiVersion:a,frontendApi:I||u,proxyUrl:_||o,publishableKey:k||d,isSatellite:p||f,domain:re||y,jwtKey:g||i,searchParams:ue}),localInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...g})=>Ue({...g,frontendApi:b||u,proxyUrl:I||o,publishableKey:S||d,isSatellite:_||f,domain:k||y}),remotePublicInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...g})=>It({...g,apiUrl:s,frontendApi:b||u,publishableKey:S||d,proxyUrl:I||o,isSatellite:_||f,domain:k||y}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Je,debugRequestState:qe}}var Bt=(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()},Gt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Ht({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=Qr(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error(Gt);let d=`${s}/sign-up`;return t(Bt(e||d,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error(Gt);let d=`${s}/sign-in`;return t(Bt(r||d,o))}}}function Qr(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function Zr(t){let e={...t},r=se(e),n=lt({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 It(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 c({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,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",_t(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||""),Ye(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var _t=(t,e)=>!e&&Ot(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",vr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=_t(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var Qe=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(Qe||{});async function Ze(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:a,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:y,headerToken:P,loadSession:h,loadUser:O,loadOrganization:x,signInUrl:T}=t,{sid:b,org_id:S,sub:I}=e,{sessions:_,users:k,organizations:f}=se({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,re,ue]=await Promise.all([h?_.getSession(b):Promise.resolve(void 0),O?k.getUser(I):Promise.resolve(void 0),x&&S?f.getOrganization({organizationId:S}):Promise.resolve(void 0)]),Zt=Ge(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:a||P||"",session:p,user:re,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:o,publishableKey:d,domain:g,isSatellite:y,signInUrl:T,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Zt}}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:()=>He({...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 At(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 et({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){let s=xt(i),a=xt(n),u=(i||"").split(",").length>(n||"").split(",").length;s&&u&&(a=Tt(s));let o=Cr(t.protocol);if(s&&s!==o)return!0;let g=Ur(r||e,s||o);return g.port=a||g.port,wt(g)!==wt(t)||g.hostname!==t.hostname}function Ur(t,e="https"){return new URL(`${e}://${t}`)}var Nr={http:"80",https:"443"};function wt(t){return t.port||Tt(t.protocol)}function Tt(t){return Nr[t]}function xt(t){return t?.split(",")[0]?.trim()||""}function Cr(t){return t?.replace(/:$/,"")||""}var Ne={parse(t,e){return Er(t,Rt,e)},stringify(t,e){return Mr(t,Rt,e)}},Rt={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function Er(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 Mr(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 qr=2*1e3,nt={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},tt="RSASSA-PKCS1-v1_5",rt="ECDSA",Kr={RS256:tt,RS384:tt,RS512:tt,ES256:rt,ES384:rt,ES512:rt},zr=Object.keys(nt);async function Jt(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:Kr[r.alg],hash:nt[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,a)}function Ce(t){let e=(t||"").toString().split(".");if(e.length!==3)throw new c({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(Ne.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Ne.parse(n,{loose:!0}))),o=Ne.parse(i,{loose:!0});return{header:a,payload:u,signature:o,raw:{header:r,payload:n,signature:i,text:t}}}async function it(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=qr,issuer:i,key:s}){let a=Ce(t),{header:u,payload:o}=a,{typ:d,alg:g}=u;if(typeof d<"u"&&d!=="JWT")throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid",message:`Invalid JWT type ${JSON.stringify(d)}. Expected "JWT".`});if(!nt[g])throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-invalid-algorithm",message:`Invalid JWT algorithm ${JSON.stringify(g)}. Supported: ${zr}.`});let{azp:y,sub:P,aud:h,iss:O,iat:x,exp:T,nbf:b}=o;if(typeof P!="string")throw new c({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(P)}.`});if(typeof h=="string"){if(h!==e)throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim (aud) ${JSON.stringify(h)}. Expected "${e}".`})}else if(Array.isArray(h)&&h.length>0&&h.every(f=>typeof f=="string")&&!h.includes(e))throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Invalid JWT audience claim array (aud) ${JSON.stringify(h)}. Does not include "${e}".`});if(y&&r&&r.length>0&&!r.includes(y))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(y)}. Expected "${r}".`});if(typeof i=="function"&&!i(O))throw new c({reason:"token-invalid-issuer",message:"Failed JWT issuer resolver. Make sure that the resolver returns a truthy value."});if(typeof i=="string"&&O&&O!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(a.payload.iss)}. Expected "${i}".`});if(typeof T!="number")throw new c({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 S=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(T),I.getTime()<=S.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${S}.`});if(b!==void 0){if(typeof b!="number")throw new c({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(b)}. Expected number.`});let f=new Date(0);if(f.setUTCSeconds(b),f.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT cannot be used prior to not before date claim (nbf). Not before date: ${f}; Current date: ${S};`})}if(x!==void 0){if(typeof x!="number")throw new c({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(x)}. Expected number.`});let f=new Date(0);if(f.setUTCSeconds(x),f.getTime()>S.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${f}; Current date: ${S};`})}let k;try{k=await Jt(a,s)}catch(f){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${f}`})}if(!k)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return o}var Ee={},Ut=0;function Me(t){return Ee[t]}function Nt(t,e=1e3*60*60){Ee[t.kid]=t,Ut=Date.now(),e>=0&&setTimeout(()=>{t?delete Ee[t.kid]:Ee={}},e)}var vt="local",jr="-----BEGIN PUBLIC KEY-----",Wr="-----END PUBLIC KEY-----",Dr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Fr="IDAQAB";function Ct(t){if(!Me(vt)){if(!t)throw new c({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(jr,"").replace(Wr,"").replace(Dr,"").replace(Fr,"").replace(/\+/g,"-").replace(/\//g,"_");Nt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Me(vt)}async function st({apiKey:t,secretKey:e,apiUrl:r=L,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:a=1e3*60*60,skipJwksCache:u}){let o=!Me(s)&&Br();if(u||o){let g,y=e||t;if(y)g=()=>$r(r,y,n);else if(i)g=()=>Vr(i);else throw new c({action:"Contact support@clerk.com",message:"Failed to load JWKS from Clerk Backend or Frontend API.",reason:"jwk-remote-failed-to-load"});let{keys:P}=await le(g);if(!P||!P.length)throw new c({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"});P.forEach(h=>Nt(h,a))}let d=Me(s);if(!d)throw new c({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 Vr(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 c({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 $r(t,e,r){if(!e)throw new c({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 c({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 Br(){return Date.now()-Ut>=300*1e3}async function at(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:a,clockSkewInSeconds:u,issuer:o,jwksCacheTtlInMs:d,jwtKey:g,skipJwksCache:y}=e,{header:P}=Ce(t),{kid:h}=P,O;if(g)O=Ct(g);else if(typeof o=="string")O=await st({issuer:o,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else if(r||n)O=await st({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:h,jwksCacheTtlInMs:d,skipJwksCache:y});else throw new c({action:"Set the CLERK_JWT_KEY environment variable.",message:"Failed to resolve JWK during verification.",reason:"jwk-failed-to-resolve"});return await it(t,{authorizedParties:a,clockSkewInSeconds:u,key:O,issuer:o})}var Hr=t=>!!t?.get("__clerk_satellite_url"),Yr=t=>t?.get("__clerk_synced")==="true",Xr=t=>t?.get("__clerk_referrer_primary")==="true",Qr=/^Mozilla\/|(Amazon CloudFront)/,Et=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(K(r||e)&&!Qr.test(n||""))return z(t,"header-missing-non-browser")},Mt=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&et({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return z(t,"header-missing-cors")},qt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(K(r||e)&&!n&&Hr(i))return U(t,"primary-responds-to-syncing")},Kt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(K(r||e)&&!n)return U(t,"uat-missing")},zt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u}=t,o=n&&et({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:a,forwardedProto:u});if(K(r||e)&&o)return U(t,"cross-origin-referrer")},Lt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t,s=r||e;if(n&&Xr(i)&&K(s))return U(t,"satellite-returns-from-primary")},jt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(St(r||e)&&!n&&!i)return z(t,"cookie-and-uat-missing")},Wt=t=>{let{clientUat:e}=t;if(e==="0")return z(t,"standard-signed-out")},Dt=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},Ft=async t=>{let{headerToken:e}=t,r=await $t(t,e);return await Ze(t,r)},Vt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await $t(t,e),i=await Ze(t,n),a=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||a?U(t,"cookie-outdated"):i};async function ot(t,e){for(let r of e){let n=await r(t);if(n)return n}return z(t,"unexpected-error")}async function $t(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"),at(e,{...t,issuer:i})}var Bt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=K(i||s);if(r&&(!e||e==="0")&&!Yr(n)&&!u)return U(t,"satellite-needs-syncing")};function Zr(t,e){if(!t&&K(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function en(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Gt(t){t.frontendApi=j(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||L,t.apiVersion=t.apiVersion||J,Re(t.secretKey||t.apiKey),t.isSatellite&&(Zr(t.signInUrl,t.secretKey||t.apiKey),en(t.proxyUrl||t.domain));async function e(){try{return await ot(t,[Ft])}catch(i){return n(i,"header")}}async function r(){try{return await ot(t,[Mt,Et,Bt,Lt,qt,jt,Kt,zt,Dt,Wt,Vt])}catch(i){return n(i,"cookie")}}function n(i,s){return i instanceof c?(i.tokenCarrier=s,["token-expired","token-not-active-yet"].includes(i.reason)?s==="header"?At(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 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 lt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=L,apiVersion:a=J,frontendApi:u="",proxyUrl:o="",publishableKey:d="",isSatellite:g=!1,domain:y=""}=t.options;return{authenticateRequest:({apiKey:b,secretKey:S,frontendApi:I,proxyUrl:_,publishableKey:k,jwtKey:f,isSatellite:p,domain:re,searchParams:ue,...Ke})=>Gt({...Ke,apiKey:b||r,secretKey:S||n,apiUrl:s,apiVersion:a,frontendApi:I||u,proxyUrl:_||o,publishableKey:k||d,isSatellite:p||g,domain:re||y,jwtKey:f||i,searchParams:ue}),localInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...f})=>Ue({...f,frontendApi:b||u,proxyUrl:I||o,publishableKey:S||d,isSatellite:_||g,domain:k||y}),remotePublicInterstitial:({frontendApi:b,publishableKey:S,proxyUrl:I,isSatellite:_,domain:k,...f})=>It({...f,apiUrl:s,frontendApi:b||u,publishableKey:S||d,proxyUrl:I||o,isSatellite:_||g,domain:k||y}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Je,debugRequestState:qe}}var Ht=(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()},Yt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Xt({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=j(i)?.frontendApi);let s=tn(n);return{redirectToSignUp:({returnBackUrl:o}={})=>{if(!e&&!s)throw new Error(Yt);let d=`${s}/sign-up`;return t(Ht(e||d,o))},redirectToSignIn:({returnBackUrl:o}={})=>{if(!r&&!s)throw new Error(Yt);let d=`${s}/sign-in`;return t(Ht(r||d,o))}}}function tn(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function rn(t){let e={...t},r=se(e),n=lt({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 |
@@ -20,2 +20,3 @@ export declare const API_URL = "https://api.clerk.dev"; | ||
readonly EnableDebug: "x-clerk-debug"; | ||
readonly ClerkRedirectTo: "x-clerk-redirect-to"; | ||
readonly Authorization: "authorization"; | ||
@@ -22,0 +23,0 @@ readonly ForwardedPort: "x-forwarded-port"; |
{ | ||
"name": "@clerk/backend", | ||
"version": "0.22.0-staging.eed840e", | ||
"version": "0.22.0-staging.fd15b34", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "description": "Clerk Backend SDK - REST Client for Backend API & JWT verification utilities", | ||
"dependencies": { | ||
"@clerk/types": "^3.41.0", | ||
"@clerk/types": "3.41.1-staging.fd15b34", | ||
"@peculiar/webcrypto": "1.4.1", | ||
@@ -31,0 +31,0 @@ "@types/node": "16.18.6", |
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
604948
1967
+ Added@clerk/types@3.41.1-staging.fd15b34(transitive)
- Removed@clerk/types@3.65.4(transitive)