@clerk/backend
Advanced tools
Comparing version 0.18.0 to 0.18.1-staging.0
@@ -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 Ue="/",Wt=new RegExp(Ue+"{1,}","g");function l(...t){return t.filter(e=>e).join(Ue).replace(Wt,Ue)}var Ce="/allowlist_identifiers",de=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Ce})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Ce,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ce,e)})}};var Ee="/clients",ce=class extends m{async getClientList(){return this.request({method:"GET",path:Ee})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Ee,e)})}verifyClient(e){return this.request({method:"POST",path:l(Ee,"verify"),bodyParams:{token:e}})}};var pe="/email_addresses",me=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(pe,e)})}async createEmailAddress(e){return this.request({method:"POST",path:pe,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(pe,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(pe,e)})}};var jt="/emails",ge=class extends m{async createEmail(e){return this.request({method:"POST",path:jt,bodyParams:e})}};var fe=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var qe="/invitations",ye=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 w="/organizations",he=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var be="/phone_numbers",Se=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(be,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:be,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(be,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(be,e)})}};var Oe="/redirect_urls",ke=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:Oe})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Oe,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Oe,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Oe,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 Ye="/sign_in_tokens",_e=class extends m{async createSignInToken(e){return this.request({method:"POST",path:Ye,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(Ye,e,"revoke")})}};var Dt="/sms_messages",Ae=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:Dt,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 tr from"deepmerge";import tt from"snakecase-keys";var C="https://api.clerk.dev",J="v1",Xe="@clerk/backend";var Ft={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},Vt={Session:"__session",ClientUat:"__client_uat"},Qe={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",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},$t={AuthStatus:Qe.AuthStatus},Bt={Json:"application/json"},Gt={Attributes:Ft,Cookies:Vt,Headers:Qe,SearchParams:$t,ContentTypes:Bt};import Ht from"#crypto";import Yt from"#fetch";var Xt=Yt.bind(globalThis),Qt={crypto:Ht,fetch:Xt},N=Qt;function Pe(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var D=class{constructor(e,r,n,i,s){this.id=e;this.identifier=r;this.createdAt=n;this.updatedAt=i;this.invitationId=s}static fromJSON(e){return new D(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var E=class{constructor(e,r,n,i,s,o,u,a,d){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=o;this.abandonAt=u;this.createdAt=a;this.updatedAt=d}static fromJSON(e){return new E(e.id,e.client_id,e.user_id,e.status,e.last_active_at,e.expire_at,e.abandon_at,e.created_at,e.updated_at)}};var F=class{constructor(e,r,n,i,s,o,u,a){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=o;this.createdAt=u;this.updatedAt=a}static fromJSON(e){return new F(e.id,e.session_ids,e.sessions.map(r=>E.fromJSON(r)),e.sign_in_id,e.sign_up_id,e.last_active_session_id,e.created_at,e.updated_at)}};var V=class{constructor(e,r,n,i){this.object=e;this.id=r;this.slug=n;this.deleted=i}static fromJSON(e){return new V(e.object,e.id||null,e.slug||null,e.deleted)}};var $=class{constructor(e,r,n,i,s,o,u){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=o;this.status=u}static fromJSON(e){return new $(e.id,e.from_email_name,e.email_address_id,e.to_email_address,e.subject,e.body,e.status)}};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,o=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=o}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,o,u,a,d,g,f={},b,y){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=o;this.firstName=u;this.lastName=a;this.picture=d;this.username=g;this.publicMetadata=f;this.label=b;this.verification=y}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.username,e.public_metadata,e.label,e.verification&&R.fromJSON(e.verification))}};var G=class{constructor(e,r,n,i,s,o,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=o;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 Ze=(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))(Ze||{});var H=class{constructor(e,r,n={},i,s,o){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=o}static fromJSON(e){return new H(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var M=class{constructor(e,r,n,i,s,o,u,a,d={},g={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.experimental_imageUrl=s;this.createdBy=o;this.createdAt=u;this.updatedAt=a;this.publicMetadata=d;this.privateMetadata=g;this.maxAllowedMemberships=f}static fromJSON(e){return new M(e.id,e.name,e.slug,e.logo_url,e.image_url,e.created_by,e.created_at,e.updated_at,e.public_metadata,e.private_metadata,e.max_allowed_memberships)}};var Y=class{constructor(e,r,n,i,s,o,u,a={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=o;this.status=u;this.publicMetadata=a}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,o,u,a){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=o;this.organization=u;this.publicUserData=a}static fromJSON(e){return new X(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,M.fromJSON(e.organization),oe.fromJSON(e.public_user_data))}},oe=class{constructor(e,r,n,i,s,o){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.experimental_imageUrl=s;this.userId=o}static fromJSON(e){return new oe(e.identifier,e.first_name,e.last_name,e.profile_image_url,e.image_url,e.user_id)}};var z=class{constructor(e,r,n,i,s,o){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=o}static fromJSON(e){return new z(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&R.fromJSON(e.verification),e.linked_to.map(r=>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,o,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=o;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,o){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=o}static fromJSON(e){return new ee(e.id,e.from_phone_number,e.to_phone_number,e.message,e.status,e.phone_number_id)}};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,o,u,a,d,g,f,b,y,S,P,x,O,k,_,A,I={},h={},p={},j=[],ue=[],ve=[],zt=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=o;this.createdAt=u;this.updatedAt=a;this.profileImageUrl=d;this.experimental_imageUrl=g;this.gender=f;this.birthday=b;this.primaryEmailAddressId=y;this.primaryPhoneNumberId=S;this.primaryWeb3WalletId=P;this.lastSignInAt=x;this.externalId=O;this.username=k;this.firstName=_;this.lastName=A;this.publicMetadata=I;this.privateMetadata=h;this.unsafeMetadata=p;this.emailAddresses=j;this.phoneNumbers=ue;this.web3Wallets=ve;this.externalAccounts=zt}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=>z.fromJSON(r)),(e.web3_wallets||[]).map(r=>re.fromJSON(r)),(e.external_accounts||[]).map(r=>B.fromJSON(r)))}};function et(t){return Array.isArray(t)?t.map(e=>Ke(e)):Zt(t)?t.data.map(e=>Ke(e)):Ke(t)}function Zt(t){return t.data!==void 0}function er(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 M.fromJSON(t);case"organization_invitation":return Y.fromJSON(t);case"organization_membership":return X.fromJSON(t);case"phone_number":return z.fromJSON(t);case"redirect_url":return Q.fromJSON(t);case"sign_in_token":return Z.fromJSON(t);case"session":return E.fromJSON(t);case"sms_message":return ee.fromJSON(t);case"token":return te.fromJSON(t);case"total_count":return er(t);case"user":return ne.fromJSON(t);default:return t}}var rr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new ae(s||"",{data:n,status:i||""})};function rt(t){return rr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=C,apiVersion:o=J,userAgent:u=Xe,httpOptions:a={}}=t,{path:d,method:g,queryParams:f,headerParams:b,bodyParams:y}=r,S=i||n;Pe(S);let P=l(s,o,d),x=new URL(P);if(f){let I=tt({...f});for(let[h,p]of Object.entries(I))p&&[p].flat().forEach(j=>x.searchParams.append(h,j))}let O={Authorization:`Bearer ${S}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...b},_=g!=="GET"&&y&&Object.keys(y).length>0?{body:JSON.stringify(tt(y,{deep:!1}))}:null,A;try{A=await N.fetch(x.href,tr(a,{method:g,headers:O,..._}));let h=await(O&&O["Content-Type"]==="application/json"?A.json():A.text());if(!A.ok)throw h;return{data:et(h),errors:null}}catch(I){return I instanceof Error?{data:null,errors:[{code:"unexpected_error",message:I.message||"Unexpected error"}]}:{data:null,errors:nr(I),status:A?.status,statusText:A?.statusText}}})}function nr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(ir):[]}return[]}function ir(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var ae=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,ae.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function ie(t){let e=rt(t);return{allowlistIdentifiers:new de(e),clients:new ce(e),emailAddresses:new me(e),emails:new ge(e),interstitial:new fe(e),invitations:new ye(e),organizations:new he(e),phoneNumbers:new Se(e),redirectUrls:new ke(e),sessions:new Ie(e),signInTokens:new _e(e),smsMessages:new Ae(e),users:new we(e)}}var it=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 st(t,e,r){let{act:n,sid:i,org_id:s,org_role:o,org_slug:u,sub:a}=t,{apiKey:d,secretKey:g,apiUrl:f,apiVersion:b,token:y,session:S,user:P,organization:x}=e,{sessions:O}=ie({apiKey:d,secretKey:g,apiUrl:f,apiVersion:b}),k=sr({sessionId:i,sessionToken:y,fetcher:(..._)=>O.getToken(..._)});return{actor:n,sessionClaims:t,sessionId:i,session:S,userId:a,user:P,orgId:s,orgRole:o,orgSlug:u,organization:x,getToken:k,debug:it({...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:it(t)}}function nt(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function us(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return nt(e),nt(r),{...t,user:e,organization:r}}var ds=t=>{let{debug:e,getToken:r,...n}=t;return n},sr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function or(t){return new Promise(e=>setTimeout(e,t))}var ar=5;async function le(t,e=1,r=ar){try{return await t()}catch(n){if(e>=r)throw n;return await or(2**e*100),le(t,e+1)}}function L(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function at(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function lt(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function lr(){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:Me}=lr();var ut="pk_live_",ur="pk_test_";function W(t){if(t=t||"",!dr(t))return null;let e=t.startsWith(ut)?"production":"development",r=dt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function dr(t){t=t||"";let e=t.startsWith(ut)||t.startsWith(ur),r=dt(t.split("_")[2]||"").endsWith("$");return e&&r}var dt=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 cr(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 Le(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Me(t.frontendApi)?"":cr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:o,isSatellite:u=!1,domain:a,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 Ue="/",Wt=new RegExp(Ue+"{1,}","g");function l(...t){return t.filter(e=>e).join(Ue).replace(Wt,Ue)}var Ce="/allowlist_identifiers",de=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:Ce})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:Ce,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(Ce,e)})}};var Ee="/clients",ce=class extends m{async getClientList(){return this.request({method:"GET",path:Ee})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Ee,e)})}verifyClient(e){return this.request({method:"POST",path:l(Ee,"verify"),bodyParams:{token:e}})}};var pe="/email_addresses",me=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(pe,e)})}async createEmailAddress(e){return this.request({method:"POST",path:pe,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(pe,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(pe,e)})}};var jt="/emails",ge=class extends m{async createEmail(e){return this.request({method:"POST",path:jt,bodyParams:e})}};var fe=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var qe="/invitations",ye=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 w="/organizations",he=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var be="/phone_numbers",Se=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(be,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:be,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(be,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(be,e)})}};var Oe="/redirect_urls",ke=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:Oe})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(Oe,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:Oe,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(Oe,e)})}};var se="/sessions",_e=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 Ye="/sign_in_tokens",Ie=class extends m{async createSignInToken(e){return this.request({method:"POST",path:Ye,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(Ye,e,"revoke")})}};var Dt="/sms_messages",Ae=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:Dt,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 tr from"deepmerge";import tt from"snakecase-keys";var C="https://api.clerk.dev",J="v1",Xe="@clerk/backend";var Ft={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},Vt={Session:"__session",ClientUat:"__client_uat"},Qe={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",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},$t={AuthStatus:Qe.AuthStatus},Bt={Json:"application/json"},Gt={Attributes:Ft,Cookies:Vt,Headers:Qe,SearchParams:$t,ContentTypes:Bt};import Ht from"#crypto";import Yt from"#fetch";var Xt=Yt.bind(globalThis),Qt={crypto:Ht,fetch:Xt},v=Qt;function Pe(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var D=class{constructor(e,r,n,i,s){this.id=e;this.identifier=r;this.createdAt=n;this.updatedAt=i;this.invitationId=s}static fromJSON(e){return new D(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var E=class{constructor(e,r,n,i,s,o,u,a,d){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=o;this.abandonAt=u;this.createdAt=a;this.updatedAt=d}static fromJSON(e){return new E(e.id,e.client_id,e.user_id,e.status,e.last_active_at,e.expire_at,e.abandon_at,e.created_at,e.updated_at)}};var F=class{constructor(e,r,n,i,s,o,u,a){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=o;this.createdAt=u;this.updatedAt=a}static fromJSON(e){return new F(e.id,e.session_ids,e.sessions.map(r=>E.fromJSON(r)),e.sign_in_id,e.sign_up_id,e.last_active_session_id,e.created_at,e.updated_at)}};var V=class{constructor(e,r,n,i){this.object=e;this.id=r;this.slug=n;this.deleted=i}static fromJSON(e){return new V(e.object,e.id||null,e.slug||null,e.deleted)}};var $=class{constructor(e,r,n,i,s,o,u,a,d,g,f){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=o;this.bodyPlain=u;this.status=a;this.slug=d;this.data=g;this.deliveredByClerk=f}static fromJSON(e){return new $(e.id,e.from_email_name,e.email_address_id,e.to_email_address,e.subject,e.body,e.body_plain,e.status,e.slug,e.data,e.delivered_by_clerk)}};var 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,o=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=o}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,o,u,a,d,g,f={},b,y){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=o;this.firstName=u;this.lastName=a;this.picture=d;this.username=g;this.publicMetadata=f;this.label=b;this.verification=y}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.username,e.public_metadata,e.label,e.verification&&R.fromJSON(e.verification))}};var G=class{constructor(e,r,n,i,s,o,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=o;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 Ze=(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))(Ze||{});var H=class{constructor(e,r,n={},i,s,o){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=o}static fromJSON(e){return new H(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var M=class{constructor(e,r,n,i,s,o,u,a,d={},g={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.experimental_imageUrl=s;this.createdBy=o;this.createdAt=u;this.updatedAt=a;this.publicMetadata=d;this.privateMetadata=g;this.maxAllowedMemberships=f}static fromJSON(e){return new M(e.id,e.name,e.slug,e.logo_url,e.image_url,e.created_by,e.created_at,e.updated_at,e.public_metadata,e.private_metadata,e.max_allowed_memberships)}};var Y=class{constructor(e,r,n,i,s,o,u,a={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=o;this.status=u;this.publicMetadata=a}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,o,u,a){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=o;this.organization=u;this.publicUserData=a}static fromJSON(e){return new X(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,M.fromJSON(e.organization),oe.fromJSON(e.public_user_data))}},oe=class{constructor(e,r,n,i,s,o){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.experimental_imageUrl=s;this.userId=o}static fromJSON(e){return new oe(e.identifier,e.first_name,e.last_name,e.profile_image_url,e.image_url,e.user_id)}};var z=class{constructor(e,r,n,i,s,o){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=o}static fromJSON(e){return new z(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&R.fromJSON(e.verification),e.linked_to.map(r=>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,o,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=o;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,o,u){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=o;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,o,u,a,d,g,f,b,y,S,P,x,O,k,I,A,_={},h={},p={},j=[],ue=[],Ne=[],zt=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=o;this.createdAt=u;this.updatedAt=a;this.profileImageUrl=d;this.experimental_imageUrl=g;this.gender=f;this.birthday=b;this.primaryEmailAddressId=y;this.primaryPhoneNumberId=S;this.primaryWeb3WalletId=P;this.lastSignInAt=x;this.externalId=O;this.username=k;this.firstName=I;this.lastName=A;this.publicMetadata=_;this.privateMetadata=h;this.unsafeMetadata=p;this.emailAddresses=j;this.phoneNumbers=ue;this.web3Wallets=Ne;this.externalAccounts=zt}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=>z.fromJSON(r)),(e.web3_wallets||[]).map(r=>re.fromJSON(r)),(e.external_accounts||[]).map(r=>B.fromJSON(r)))}};function et(t){return Array.isArray(t)?t.map(e=>Ke(e)):Zt(t)?t.data.map(e=>Ke(e)):Ke(t)}function Zt(t){return Array.isArray(t.data)&&t.data!==void 0}function er(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 M.fromJSON(t);case"organization_invitation":return Y.fromJSON(t);case"organization_membership":return X.fromJSON(t);case"phone_number":return z.fromJSON(t);case"redirect_url":return Q.fromJSON(t);case"sign_in_token":return Z.fromJSON(t);case"session":return E.fromJSON(t);case"sms_message":return ee.fromJSON(t);case"token":return te.fromJSON(t);case"total_count":return er(t);case"user":return ne.fromJSON(t);default:return t}}var rr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new ae(s||"",{data:n,status:i||""})};function rt(t){return rr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=C,apiVersion:o=J,userAgent:u=Xe,httpOptions:a={}}=t,{path:d,method:g,queryParams:f,headerParams:b,bodyParams:y}=r,S=i||n;Pe(S);let P=l(s,o,d),x=new URL(P);if(f){let _=tt({...f});for(let[h,p]of Object.entries(_))p&&[p].flat().forEach(j=>x.searchParams.append(h,j))}let O={Authorization:`Bearer ${S}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...b},I=g!=="GET"&&y&&Object.keys(y).length>0?{body:JSON.stringify(tt(y,{deep:!1}))}:null,A;try{A=await v.fetch(x.href,tr(a,{method:g,headers:O,...I}));let h=await(O&&O["Content-Type"]==="application/json"?A.json():A.text());if(!A.ok)throw h;return{data:et(h),errors:null}}catch(_){return _ instanceof Error?{data:null,errors:[{code:"unexpected_error",message:_.message||"Unexpected error"}]}:{data:null,errors:nr(_),status:A?.status,statusText:A?.statusText}}})}function nr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(ir):[]}return[]}function ir(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var ae=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,ae.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function ie(t){let e=rt(t);return{allowlistIdentifiers:new de(e),clients:new ce(e),emailAddresses:new me(e),emails:new ge(e),interstitial:new fe(e),invitations:new ye(e),organizations:new he(e),phoneNumbers:new Se(e),redirectUrls:new ke(e),sessions:new _e(e),signInTokens:new Ie(e),smsMessages:new Ae(e),users:new we(e)}}var it=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 st(t,e,r){let{act:n,sid:i,org_id:s,org_role:o,org_slug:u,sub:a}=t,{apiKey:d,secretKey:g,apiUrl:f,apiVersion:b,token:y,session:S,user:P,organization:x}=e,{sessions:O}=ie({apiKey:d,secretKey:g,apiUrl:f,apiVersion:b}),k=sr({sessionId:i,sessionToken:y,fetcher:(...I)=>O.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:S,userId:a,user:P,orgId:s,orgRole:o,orgSlug:u,organization:x,getToken:k,debug:it({...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:it(t)}}function nt(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function us(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return nt(e),nt(r),{...t,user:e,organization:r}}var ds=t=>{let{debug:e,getToken:r,...n}=t;return n},sr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function or(t){return new Promise(e=>setTimeout(e,t))}var ar=5;async function le(t,e=1,r=ar){try{return await t()}catch(n){if(e>=r)throw n;return await or(2**e*100),le(t,e+1)}}function L(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function at(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function lt(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function lr(){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:Me}=lr();var ut="pk_live_",ur="pk_test_";function W(t){if(t=t||"",!dr(t))return null;let e=t.startsWith(ut)?"production":"development",r=dt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function dr(t){t=t||"";let e=t.startsWith(ut)||t.startsWith(ur),r=dt(t.split("_")[2]||"").endsWith("$");return e&&r}var dt=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 cr(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 Le(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Me(t.frontendApi)?"":cr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:o,isSatellite:u=!1,domain:a,signInUrl:d}=t;return` | ||
<head> | ||
@@ -64,3 +64,3 @@ <meta charset="UTF-8" /> | ||
</body> | ||
`}async function ct(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=xe(t),r=await le(()=>N.fetch(xe(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 xe(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t,d=new URL(e);return d.pathname=l(d.pathname,J,"/public/interstitial"),d.searchParams.append("clerk_js_version",pt(r,n)),i?d.searchParams.append("publishable_key",i):d.searchParams.append("frontend_api",r),s&&d.searchParams.append("proxy_url",s),o&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",a||""),Me(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var pt=(t,e)=>!e&<(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",pr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=pt(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var mt=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(mt||{});async function We(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:o,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,headerToken:b,loadSession:y,loadUser:S,loadOrganization:P,signInUrl:x}=t,{sid:O,org_id:k,sub:_}=e,{sessions:A,users:I,organizations:h}=ie({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,j,ue]=await Promise.all([y?A.getSession(O):Promise.resolve(void 0),S?I.getUser(_):Promise.resolve(void 0),P&&k?h.getOrganization({organizationId:k}):Promise.resolve(void 0)]),Lt=st(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:o||b||"",session:p,user:j,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,signInUrl:x,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Lt}}function v(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:o,domain:u,signInUrl:a,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:o,domain:u,signInUrl:a}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:o,domain:u,proxyUrl:s,signInUrl:a,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function gt(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function je({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){if(i&&i!==t.protocol)return!0;let s=mr(r||e);return s.port=n||s.port,s.port!==t.port||s.hostname!==t.hostname}function mr(t){return new URL(`https://${t}`)}var Re={parse(t,e){return gr(t,ft,e)},stringify(t,e){return fr(t,ft,e)}},ft={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function gr(t,e,r={}){if(!e.codes){e.codes={};for(let a=0;a<e.chars.length;++a)e.codes[e.chars[a]]=a}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,o=0,u=0;for(let a=0;a<n;++a){let d=e.codes[t[a]];if(d===void 0)throw new SyntaxError("Invalid character "+t[a]);o=o<<e.bits|d,s+=e.bits,s>=8&&(s-=8,i[u++]=255&o>>s)}if(s>=e.bits||255&o<<8-s)throw new SyntaxError("Unexpected end of data");return i}function fr(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",o=0,u=0;for(let a=0;a<t.length;++a)for(u=u<<8|255&t[a],o+=8;o>e.bits;)o-=e.bits,s+=e.chars[i&u>>o];if(o&&(s+=e.chars[i&u<<e.bits-o]),n)for(;s.length*e.bits&7;)s+="=";return s}var yr=2*1e3,Ve={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},De="RSASSA-PKCS1-v1_5",Fe="ECDSA",hr={RS256:De,RS384:De,RS512:De,ES256:Fe,ES384:Fe,ES512:Fe},br=Object.keys(Ve);async function Sr(t,e){let{header:r,signature:n,raw:i}=t,o=new TextEncoder().encode([i.header,i.payload].join(".")),u=await N.crypto.subtle.importKey("jwk",e,{name:hr[r.alg],hash:Ve[r.alg]},!1,["verify"]);return N.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,o)}function $e(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,o=JSON.parse(s.decode(Re.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Re.parse(n,{loose:!0}))),a=Re.parse(i,{loose:!0});return{header:o,payload:u,signature:a,raw:{header:r,payload:n,signature:i,text:t}}}async function yt(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=yr,issuer:i,key:s}){let o=$e(t),{header:u,payload:a}=o,{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(!Ve[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: ${br}.`});let{azp:f,sub:b,aud:y,iss:S,iat:P,exp:x,nbf:O}=a;if(typeof b!="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(b)}.`});if(typeof y=="string"){if(y!==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(y)}. Expected "${e}".`})}else if(Array.isArray(y)&&y.length>0&&y.every(h=>typeof h=="string")&&!y.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(y)}. Does not include "${e}".`});if(f&&r&&r.length>0&&!r.includes(f))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(S))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"&&S&&S!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(o.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 k=new Date(Date.now()),_=new Date(0);if(_.setUTCSeconds(x),_.getTime()<=k.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${_}, Current date: ${k}.`});if(O!==void 0){if(typeof O!="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(O)}. Expected number.`});let h=new Date(0);if(h.setUTCSeconds(O),h.getTime()>k.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: ${h}; Current date: ${k};`})}if(P!==void 0){if(typeof P!="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(P)}. Expected number.`});let h=new Date(0);if(h.setUTCSeconds(P),h.getTime()>k.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${h}; Current date: ${k};`})}let I;try{I=await Sr(o,s)}catch(h){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${h}`})}if(!I)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return a}var Je={},bt=0;function Ne(t){return Je[t]}function St(t,e=1e3*60*60){Je[t.kid]=t,bt=Date.now(),e>=0&&setTimeout(()=>{t?delete Je[t.kid]:Je={}},e)}var ht="local",kr="-----BEGIN PUBLIC KEY-----",Ir="-----END PUBLIC KEY-----",_r="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Ar="IDAQAB";function Ot(t){if(!Ne(ht)){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(kr,"").replace(Ir,"").replace(_r,"").replace(Ar,"").replace(/\+/g,"-").replace(/\//g,"_");St({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ne(ht)}async function Be({apiKey:t,secretKey:e,apiUrl:r=C,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:o=1e3*60*60,skipJwksCache:u}){let a=!Ne(s)&&xr();if(u||a){let g,f=e||t;if(f)g=()=>Pr(r,f,n);else if(i)g=()=>wr(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:b}=await le(g);if(!b||!b.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"});b.forEach(y=>St(y,o))}let d=Ne(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 wr(t){let e=new URL(t);e.pathname=l(e.pathname,".well-known/jwks.json");let r=await N.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 Pr(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 N.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 xr(){return Date.now()-bt>=300*1e3}async function kt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:o,clockSkewInSeconds:u,issuer:a,jwksCacheTtlInMs:d,jwtKey:g,skipJwksCache:f}=e,{header:b}=$e(t),{kid:y}=b,S;if(g)S=Ot(g);else if(typeof a=="string")S=await Be({issuer:a,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});else if(r||n)S=await Be({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});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 yt(t,{authorizedParties:o,clockSkewInSeconds:u,key:S,issuer:a})}var Rr=t=>!!t?.get("__clerk_satellite_url"),It=t=>t?.get("__clerk_synced")==="true",_t=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(L(r||e)&&!n?.startsWith("Mozilla/"))return v(t,"header-missing-non-browser")},At=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&je({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return v(t,"header-missing-cors")},wt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(L(r||e)&&!n&&Rr(i))return U(t,"primary-responds-to-syncing")},Pt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(L(r||e)&&!n)return U(t,"uat-missing")},xt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u,isSatellite:a,searchParams:d}=t,g=n&&je({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u}),f=r||e;if(!a&&!It(d)&&L(f)&&g)return U(t,"cross-origin-referrer")},Tt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(at(r||e)&&!n&&!i)return v(t,"cookie-and-uat-missing")},Rt=t=>{let{clientUat:e}=t;if(e==="0")return v(t,"standard-signed-out")},Jt=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 Ut(t,e);return await We(t,r)},vt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await Ut(t,e),i=await We(t,n),o=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||o?U(t,"cookie-outdated"):i};async function Ge(t,e){for(let r of e){let n=await r(t);if(n)return n}return v(t,"unexpected-error")}async function Ut(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"),kt(e,{...t,issuer:i})}var Ct=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=L(i||s);if(r&&(!e||e==="0")&&!It(n)&&!u)return U(t,"satellite-needs-syncing")};function Jr(t,e){if(!t&&L(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function Nr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Et(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||C,t.apiVersion=t.apiVersion||J,Pe(t.secretKey||t.apiKey),t.isSatellite&&(Jr(t.signInUrl,t.secretKey||t.apiKey),Nr(t.proxyUrl||t.domain));async function e(){try{return await Ge(t,[Nt])}catch(i){return n(i,"header")}}async function r(){try{return await Ge(t,[At,_t,Ct,wt,Tt,Pt,xt,Jt,Rt,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"?gt(t,i.reason,i.getFullMessage()):U(t,i.reason,i.getFullMessage()):v(t,i.reason,i.getFullMessage())):v(t,"unexpected-error",i.message)}return t.headerToken?e():r()}var He=t=>{let{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:o,publishableKey:u,isSatellite:a,domain:d}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:o,publishableKey:u,isSatellite:a,domain:d}};function qt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=C,apiVersion:o=J,frontendApi:u="",proxyUrl:a="",publishableKey:d="",isSatellite:g=!1,domain:f=""}=t.options;return{authenticateRequest:({apiKey:O,secretKey:k,frontendApi:_,proxyUrl:A,publishableKey:I,jwtKey:h,isSatellite:p,domain:j,searchParams:ue,...ve})=>Et({...ve,apiKey:O||r,secretKey:k||n,apiUrl:s,apiVersion:o,frontendApi:_||u,proxyUrl:A||a,publishableKey:I||d,isSatellite:p||g,domain:j||f,jwtKey:h||i,searchParams:ue}),localInterstitial:Le,remotePublicInterstitial:({frontendApi:O,publishableKey:k,proxyUrl:_,isSatellite:A,domain:I,...h})=>ct({...h,apiUrl:s,frontendApi:O||u,publishableKey:k||d,proxyUrl:_||a,isSatellite:A||g,domain:I||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:xe,debugRequestState:He}}var Kt=(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()},Mt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function vr({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=W(i)?.frontendApi);let s=Ur(n);return{redirectToSignUp:({returnBackUrl:a}={})=>{if(!e&&!s)throw new Error(Mt);let d=`${s}/sign-up`;return t(Kt(e||d,a))},redirectToSignIn:({returnBackUrl:a}={})=>{if(!r&&!s)throw new Error(Mt);let d=`${s}/sign-in`;return t(Kt(r||d,a))}}}function Ur(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function _o(t){let e={...t},r=ie(e),n=qt({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}export{D as AllowlistIdentifier,mt as AuthStatus,_o 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,Ze as ObjectType,M as Organization,Y as OrganizationInvitation,X as OrganizationMembership,oe as OrganizationMembershipPublicUserData,z as PhoneNumber,Q as RedirectUrl,ee as SMSMessage,E as Session,Z as SignInToken,te as Token,ne as User,R as Verification,Gt as constants,qt as createAuthenticateRequest,He as debugRequestState,$e as decodeJwt,et as deserialize,Sr as hasValidSignature,Le as loadInterstitialFromLocal,ds as makeAuthObjectSerializable,nt as prunePrivateMetadata,vr as redirect,us as sanitizeAuthObject,st as signedInAuthObject,ot as signedOutAuthObject,yt as verifyJwt,kt as verifyToken}; | ||
`}async function ct(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=xe(t),r=await le(()=>v.fetch(xe(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 xe(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t,d=new URL(e);return d.pathname=l(d.pathname,J,"/public/interstitial"),d.searchParams.append("clerk_js_version",pt(r,n)),i?d.searchParams.append("publishable_key",i):d.searchParams.append("frontend_api",r),s&&d.searchParams.append("proxy_url",s),o&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",a||""),Me(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var pt=(t,e)=>!e&<(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",pr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=pt(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var mt=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(mt||{});async function We(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:o,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,headerToken:b,loadSession:y,loadUser:S,loadOrganization:P,signInUrl:x}=t,{sid:O,org_id:k,sub:I}=e,{sessions:A,users:_,organizations:h}=ie({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,j,ue]=await Promise.all([y?A.getSession(O):Promise.resolve(void 0),S?_.getUser(I):Promise.resolve(void 0),P&&k?h.getOrganization({organizationId:k}):Promise.resolve(void 0)]),Lt=st(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:o||b||"",session:p,user:j,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,signInUrl:x,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Lt}}function N(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:o,domain:u,signInUrl:a,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:o,domain:u,signInUrl:a}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:o,domain:u,proxyUrl:s,signInUrl:a,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function gt(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function je({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){if(i&&i!==t.protocol)return!0;let s=mr(r||e);return s.port=n||s.port,s.port!==t.port||s.hostname!==t.hostname}function mr(t){return new URL(`https://${t}`)}var Re={parse(t,e){return gr(t,ft,e)},stringify(t,e){return fr(t,ft,e)}},ft={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function gr(t,e,r={}){if(!e.codes){e.codes={};for(let a=0;a<e.chars.length;++a)e.codes[e.chars[a]]=a}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,o=0,u=0;for(let a=0;a<n;++a){let d=e.codes[t[a]];if(d===void 0)throw new SyntaxError("Invalid character "+t[a]);o=o<<e.bits|d,s+=e.bits,s>=8&&(s-=8,i[u++]=255&o>>s)}if(s>=e.bits||255&o<<8-s)throw new SyntaxError("Unexpected end of data");return i}function fr(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",o=0,u=0;for(let a=0;a<t.length;++a)for(u=u<<8|255&t[a],o+=8;o>e.bits;)o-=e.bits,s+=e.chars[i&u>>o];if(o&&(s+=e.chars[i&u<<e.bits-o]),n)for(;s.length*e.bits&7;)s+="=";return s}var yr=2*1e3,Ve={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},De="RSASSA-PKCS1-v1_5",Fe="ECDSA",hr={RS256:De,RS384:De,RS512:De,ES256:Fe,ES384:Fe,ES512:Fe},br=Object.keys(Ve);async function Sr(t,e){let{header:r,signature:n,raw:i}=t,o=new TextEncoder().encode([i.header,i.payload].join(".")),u=await v.crypto.subtle.importKey("jwk",e,{name:hr[r.alg],hash:Ve[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,o)}function $e(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,o=JSON.parse(s.decode(Re.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Re.parse(n,{loose:!0}))),a=Re.parse(i,{loose:!0});return{header:o,payload:u,signature:a,raw:{header:r,payload:n,signature:i,text:t}}}async function yt(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=yr,issuer:i,key:s}){let o=$e(t),{header:u,payload:a}=o,{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(!Ve[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: ${br}.`});let{azp:f,sub:b,aud:y,iss:S,iat:P,exp:x,nbf:O}=a;if(typeof b!="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(b)}.`});if(typeof y=="string"){if(y!==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(y)}. Expected "${e}".`})}else if(Array.isArray(y)&&y.length>0&&y.every(h=>typeof h=="string")&&!y.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(y)}. Does not include "${e}".`});if(f&&r&&r.length>0&&!r.includes(f))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(S))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"&&S&&S!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(o.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 k=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(x),I.getTime()<=k.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${k}.`});if(O!==void 0){if(typeof O!="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(O)}. Expected number.`});let h=new Date(0);if(h.setUTCSeconds(O),h.getTime()>k.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: ${h}; Current date: ${k};`})}if(P!==void 0){if(typeof P!="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(P)}. Expected number.`});let h=new Date(0);if(h.setUTCSeconds(P),h.getTime()>k.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${h}; Current date: ${k};`})}let _;try{_=await Sr(o,s)}catch(h){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${h}`})}if(!_)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return a}var Je={},bt=0;function ve(t){return Je[t]}function St(t,e=1e3*60*60){Je[t.kid]=t,bt=Date.now(),e>=0&&setTimeout(()=>{t?delete Je[t.kid]:Je={}},e)}var ht="local",kr="-----BEGIN PUBLIC KEY-----",_r="-----END PUBLIC KEY-----",Ir="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Ar="IDAQAB";function Ot(t){if(!ve(ht)){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(kr,"").replace(_r,"").replace(Ir,"").replace(Ar,"").replace(/\+/g,"-").replace(/\//g,"_");St({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return ve(ht)}async function Be({apiKey:t,secretKey:e,apiUrl:r=C,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:o=1e3*60*60,skipJwksCache:u}){let a=!ve(s)&&xr();if(u||a){let g,f=e||t;if(f)g=()=>Pr(r,f,n);else if(i)g=()=>wr(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:b}=await le(g);if(!b||!b.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"});b.forEach(y=>St(y,o))}let d=ve(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 wr(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 Pr(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 xr(){return Date.now()-bt>=300*1e3}async function kt(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:o,clockSkewInSeconds:u,issuer:a,jwksCacheTtlInMs:d,jwtKey:g,skipJwksCache:f}=e,{header:b}=$e(t),{kid:y}=b,S;if(g)S=Ot(g);else if(typeof a=="string")S=await Be({issuer:a,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});else if(r||n)S=await Be({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});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 yt(t,{authorizedParties:o,clockSkewInSeconds:u,key:S,issuer:a})}var Rr=t=>!!t?.get("__clerk_satellite_url"),_t=t=>t?.get("__clerk_synced")==="true",It=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(L(r||e)&&!n?.startsWith("Mozilla/"))return N(t,"header-missing-non-browser")},At=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&je({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return N(t,"header-missing-cors")},wt=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(L(r||e)&&!n&&Rr(i))return U(t,"primary-responds-to-syncing")},Pt=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(L(r||e)&&!n)return U(t,"uat-missing")},xt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u,isSatellite:a,searchParams:d}=t,g=n&&je({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u}),f=r||e;if(!a&&!_t(d)&&L(f)&&g)return U(t,"cross-origin-referrer")},Tt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(at(r||e)&&!n&&!i)return N(t,"cookie-and-uat-missing")},Rt=t=>{let{clientUat:e}=t;if(e==="0")return N(t,"standard-signed-out")},Jt=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return U(t,"cookie-missing")},vt=async t=>{let{headerToken:e}=t,r=await Ut(t,e);return await We(t,r)},Nt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await Ut(t,e),i=await We(t,n),o=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||o?U(t,"cookie-outdated"):i};async function Ge(t,e){for(let r of e){let n=await r(t);if(n)return n}return N(t,"unexpected-error")}async function Ut(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"),kt(e,{...t,issuer:i})}var Ct=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=L(i||s);if(r&&(!e||e==="0")&&!_t(n)&&!u)return U(t,"satellite-needs-syncing")};function Jr(t,e){if(!t&&L(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function vr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Et(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||C,t.apiVersion=t.apiVersion||J,Pe(t.secretKey||t.apiKey),t.isSatellite&&(Jr(t.signInUrl,t.secretKey||t.apiKey),vr(t.proxyUrl||t.domain));async function e(){try{return await Ge(t,[vt])}catch(i){return n(i,"header")}}async function r(){try{return await Ge(t,[At,It,Ct,wt,Tt,Pt,xt,Jt,Rt,Nt])}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"?gt(t,i.reason,i.getFullMessage()):U(t,i.reason,i.getFullMessage()):N(t,i.reason,i.getFullMessage())):N(t,"unexpected-error",i.message)}return t.headerToken?e():r()}var He=t=>{let{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:o,publishableKey:u,isSatellite:a,domain:d}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:o,publishableKey:u,isSatellite:a,domain:d}};function qt(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=C,apiVersion:o=J,frontendApi:u="",proxyUrl:a="",publishableKey:d="",isSatellite:g=!1,domain:f=""}=t.options;return{authenticateRequest:({apiKey:O,secretKey:k,frontendApi:I,proxyUrl:A,publishableKey:_,jwtKey:h,isSatellite:p,domain:j,searchParams:ue,...Ne})=>Et({...Ne,apiKey:O||r,secretKey:k||n,apiUrl:s,apiVersion:o,frontendApi:I||u,proxyUrl:A||a,publishableKey:_||d,isSatellite:p||g,domain:j||f,jwtKey:h||i,searchParams:ue}),localInterstitial:Le,remotePublicInterstitial:({frontendApi:O,publishableKey:k,proxyUrl:I,isSatellite:A,domain:_,...h})=>ct({...h,apiUrl:s,frontendApi:O||u,publishableKey:k||d,proxyUrl:I||a,isSatellite:A||g,domain:_||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:xe,debugRequestState:He}}var Kt=(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()},Mt="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Nr({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=W(i)?.frontendApi);let s=Ur(n);return{redirectToSignUp:({returnBackUrl:a}={})=>{if(!e&&!s)throw new Error(Mt);let d=`${s}/sign-up`;return t(Kt(e||d,a))},redirectToSignIn:({returnBackUrl:a}={})=>{if(!r&&!s)throw new Error(Mt);let d=`${s}/sign-in`;return t(Kt(r||d,a))}}}function Ur(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function Io(t){let e={...t},r=ie(e),n=qt({options:e,apiClient:r});return{...r,...n,__unstable_options:e}}export{D as AllowlistIdentifier,mt as AuthStatus,Io 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,Ze as ObjectType,M as Organization,Y as OrganizationInvitation,X as OrganizationMembership,oe as OrganizationMembershipPublicUserData,z as PhoneNumber,Q as RedirectUrl,ee as SMSMessage,E as Session,Z as SignInToken,te as Token,ne as User,R as Verification,Gt as constants,qt as createAuthenticateRequest,He as debugRequestState,$e as decodeJwt,et as deserialize,Sr as hasValidSignature,Le as loadInterstitialFromLocal,ds as makeAuthObjectSerializable,nt as prunePrivateMetadata,Nr as redirect,us as sanitizeAuthObject,st as signedInAuthObject,ot as signedOutAuthObject,yt as verifyJwt,kt as verifyToken}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var Yt=Object.create;var de=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty;var tr=(t,e)=>{for(var r in e)de(t,r,{get:e[r],enumerable:!0})},lt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qt(e))!er.call(t,i)&&i!==r&&de(t,i,{get:()=>e[i],enumerable:!(n=Xt(e,i))||n.enumerable});return t};var ce=(t,e,r)=>(r=t!=null?Yt(Zt(t)):{},lt(e||!t||!t.__esModule?de(r,"default",{value:t,enumerable:!0}):r,t)),rr=t=>lt(de({},"__esModule",{value:!0}),t);var Br={};tr(Br,{AllowlistIdentifier:()=>j,AuthStatus:()=>Xe,Clerk:()=>$r,Client:()=>D,DeletedObject:()=>F,Email:()=>V,EmailAddress:()=>C,ExternalAccount:()=>$,IdentificationLink:()=>U,Invitation:()=>B,OauthAccessToken:()=>G,ObjectType:()=>je,Organization:()=>E,OrganizationInvitation:()=>H,OrganizationMembership:()=>Y,OrganizationMembershipPublicUserData:()=>ne,PhoneNumber:()=>q,RedirectUrl:()=>X,SMSMessage:()=>Z,Session:()=>v,SignInToken:()=>Q,Token:()=>ee,User:()=>te,Verification:()=>P,constants:()=>pt,createAuthenticateRequest:()=>at,debugRequestState:()=>qe,decodeJwt:()=>Ue,deserialize:()=>Fe,hasValidSignature:()=>Pt,loadInterstitialFromLocal:()=>Ne,makeAuthObjectSerializable:()=>br,prunePrivateMetadata:()=>$e,redirect:()=>Bt,sanitizeAuthObject:()=>hr,signedInAuthObject:()=>Be,signedOutAuthObject:()=>Ge,verifyJwt:()=>nt,verifyToken:()=>st});module.exports=rr(Br);var m=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var Me="/",nr=new RegExp(Me+"{1,}","g");function l(...t){return t.filter(e=>e).join(Me).replace(nr,Me)}var ze="/allowlist_identifiers",pe=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:ze})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:ze,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(ze,e)})}};var Le="/clients",me=class extends m{async getClientList(){return this.request({method:"GET",path:Le})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Le,e)})}verifyClient(e){return this.request({method:"POST",path:l(Le,"verify"),bodyParams:{token:e}})}};var ge="/email_addresses",fe=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(ge,e)})}async createEmailAddress(e){return this.request({method:"POST",path:ge,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(ge,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(ge,e)})}};var ir="/emails",ye=class extends m{async createEmail(e){return this.request({method:"POST",path:ir,bodyParams:e})}};var he=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var We="/invitations",be=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 w="/organizations",Se=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var Oe="/phone_numbers",ke=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(Oe,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:Oe,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(Oe,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(Oe,e)})}};var 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 oe="/sessions",Ae=class extends m{async getSessionList(e){return this.request({method:"GET",path:oe,queryParams:e})}async getSession(e){return this.requireId(e),this.request({method:"GET",path:l(oe,e)})}async revokeSession(e){return this.requireId(e),this.request({method:"POST",path:l(oe,e,"revoke")})}async verifySession(e,r){return this.requireId(e),this.request({method:"POST",path:l(oe,e,"verify"),bodyParams:{token:r}})}async getToken(e,r){return this.requireId(e),(await this.request({method:"POST",path:l(oe,e,"tokens",r||"")})).jwt}};var ut="/sign_in_tokens",we=class extends m{async createSignInToken(e){return this.request({method:"POST",path:ut,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(ut,e,"revoke")})}};var sr="/sms_messages",Pe=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:sr,bodyParams:e})}};var R="/users",xe=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 ft=ce(require("deepmerge")),Ve=ce(require("snakecase-keys"));var z="https://api.clerk.dev",J="v1",dt="@clerk/backend";var or={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},ar={Session:"__session",ClientUat:"__client_uat"},ct={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",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},lr={AuthStatus:ct.AuthStatus},ur={Json:"application/json"},pt={Attributes:or,Cookies:ar,Headers:ct,SearchParams:lr,ContentTypes:ur};var mt=ce(require("#crypto")),gt=ce(require("#fetch")),dr=gt.default.bind(globalThis),cr={crypto:mt.default,fetch:dr},N=cr;function Te(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var j=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 j(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var v=class{constructor(e,r,n,i,s,o,u,a,d){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=o;this.abandonAt=u;this.createdAt=a;this.updatedAt=d}static fromJSON(e){return new v(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,o,u,a){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=o;this.createdAt=u;this.updatedAt=a}static fromJSON(e){return new D(e.id,e.session_ids,e.sessions.map(r=>v.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,o,u){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=o;this.status=u}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.status)}};var U=class{constructor(e,r){this.id=e;this.type=r}static fromJSON(e){return new U(e.id,e.type)}};var P=class{constructor(e,r,n=null,i=null,s=null,o=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=o}static fromJSON(e){return new P(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 C=class{constructor(e,r,n,i){this.id=e;this.emailAddress=r;this.verification=n;this.linkedTo=i}static fromJSON(e){return new C(e.id,e.email_address,e.verification&&P.fromJSON(e.verification),e.linked_to.map(r=>U.fromJSON(r)))}};var $=class{constructor(e,r,n,i,s,o,u,a,d,g,f={},b,y){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=o;this.firstName=u;this.lastName=a;this.picture=d;this.username=g;this.publicMetadata=f;this.label=b;this.verification=y}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.username,e.public_metadata,e.label,e.verification&&P.fromJSON(e.verification))}};var B=class{constructor(e,r,n,i,s,o,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=o;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 je=(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))(je||{});var G=class{constructor(e,r,n={},i,s,o){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=o}static fromJSON(e){return new G(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var E=class{constructor(e,r,n,i,s,o,u,a,d={},g={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.experimental_imageUrl=s;this.createdBy=o;this.createdAt=u;this.updatedAt=a;this.publicMetadata=d;this.privateMetadata=g;this.maxAllowedMemberships=f}static fromJSON(e){return new E(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,o,u,a={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=o;this.status=u;this.publicMetadata=a}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,o,u,a){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=o;this.organization=u;this.publicUserData=a}static fromJSON(e){return new Y(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,E.fromJSON(e.organization),ne.fromJSON(e.public_user_data))}},ne=class{constructor(e,r,n,i,s,o){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.experimental_imageUrl=s;this.userId=o}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,o){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=o}static fromJSON(e){return new q(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&P.fromJSON(e.verification),e.linked_to.map(r=>U.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,o,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=o;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,o){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=o}static fromJSON(e){return new Z(e.id,e.from_phone_number,e.to_phone_number,e.message,e.status,e.phone_number_id)}};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&&P.fromJSON(e.verification))}};var te=class{constructor(e,r,n,i,s,o,u,a,d,g,f,b,y,S,x,T,O,k,_,A,I={},h={},p={},re=[],ue=[],Ke=[],Gt=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=o;this.createdAt=u;this.updatedAt=a;this.profileImageUrl=d;this.experimental_imageUrl=g;this.gender=f;this.birthday=b;this.primaryEmailAddressId=y;this.primaryPhoneNumberId=S;this.primaryWeb3WalletId=x;this.lastSignInAt=T;this.externalId=O;this.username=k;this.firstName=_;this.lastName=A;this.publicMetadata=I;this.privateMetadata=h;this.unsafeMetadata=p;this.emailAddresses=re;this.phoneNumbers=ue;this.web3Wallets=Ke;this.externalAccounts=Gt}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=>C.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 Fe(t){return Array.isArray(t)?t.map(e=>De(e)):pr(t)?t.data.map(e=>De(e)):De(t)}function pr(t){return t.data!==void 0}function mr(t){return t.total_count}function De(t){if(typeof t!="string"&&"object"in t&&"deleted"in t)return F.fromJSON(t);switch(t.object){case"allowlist_identifier":return j.fromJSON(t);case"client":return D.fromJSON(t);case"email_address":return C.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 E.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 v.fromJSON(t);case"sms_message":return Z.fromJSON(t);case"token":return ee.fromJSON(t);case"total_count":return mr(t);case"user":return te.fromJSON(t);default:return t}}var gr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new ae(s||"",{data:n,status:i||""})};function yt(t){return gr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=z,apiVersion:o=J,userAgent:u=dt,httpOptions:a={}}=t,{path:d,method:g,queryParams:f,headerParams:b,bodyParams:y}=r,S=i||n;Te(S);let x=l(s,o,d),T=new URL(x);if(f){let I=(0,Ve.default)({...f});for(let[h,p]of Object.entries(I))p&&[p].flat().forEach(re=>T.searchParams.append(h,re))}let O={Authorization:`Bearer ${S}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...b},_=g!=="GET"&&y&&Object.keys(y).length>0?{body:JSON.stringify((0,Ve.default)(y,{deep:!1}))}:null,A;try{A=await N.fetch(T.href,(0,ft.default)(a,{method:g,headers:O,..._}));let h=await(O&&O["Content-Type"]==="application/json"?A.json():A.text());if(!A.ok)throw h;return{data:Fe(h),errors:null}}catch(I){return I instanceof Error?{data:null,errors:[{code:"unexpected_error",message:I.message||"Unexpected error"}]}:{data:null,errors:fr(I),status:A?.status,statusText:A?.statusText}}})}function fr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(yr):[]}return[]}function yr(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var ae=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,ae.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function se(t){let e=yt(t);return{allowlistIdentifiers:new pe(e),clients:new me(e),emailAddresses:new fe(e),emails:new ye(e),interstitial:new he(e),invitations:new be(e),organizations:new Se(e),phoneNumbers:new ke(e),redirectUrls:new _e(e),sessions:new Ae(e),signInTokens:new we(e),smsMessages:new Pe(e),users:new xe(e)}}var ht=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 Be(t,e,r){let{act:n,sid:i,org_id:s,org_role:o,org_slug:u,sub:a}=t,{apiKey:d,secretKey:g,apiUrl:f,apiVersion:b,token:y,session:S,user:x,organization:T}=e,{sessions:O}=se({apiKey:d,secretKey:g,apiUrl:f,apiVersion:b}),k=Sr({sessionId:i,sessionToken:y,fetcher:(..._)=>O.getToken(..._)});return{actor:n,sessionClaims:t,sessionId:i,session:S,userId:a,user:x,orgId:s,orgRole:o,orgSlug:u,organization:T,getToken:k,debug:ht({...e,...r})}}function Ge(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:ht(t)}}function $e(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function hr(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return $e(e),$e(r),{...t,user:e,organization:r}}var br=t=>{let{debug:e,getToken:r,...n}=t;return n},Sr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function Or(t){return new Promise(e=>setTimeout(e,t))}var kr=5;async function le(t,e=1,r=kr){try{return await t()}catch(n){if(e>=r)throw n;return await Or(2**e*100),le(t,e+1)}}function L(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function bt(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function St(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function Ir(){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:He}=Ir();var Ot="pk_live_",_r="pk_test_";function W(t){if(t=t||"",!Ar(t))return null;let e=t.startsWith(Ot)?"production":"development",r=kt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function Ar(t){t=t||"";let e=t.startsWith(Ot)||t.startsWith(_r),r=kt(t.split("_")[2]||"").endsWith("$");return e&&r}var kt=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 wr(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 Ne(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=He(t.frontendApi)?"":wr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:o,isSatellite:u=!1,domain:a,signInUrl:d}=t;return` | ||
"use strict";var Yt=Object.create;var de=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,er=Object.prototype.hasOwnProperty;var tr=(t,e)=>{for(var r in e)de(t,r,{get:e[r],enumerable:!0})},lt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qt(e))!er.call(t,i)&&i!==r&&de(t,i,{get:()=>e[i],enumerable:!(n=Xt(e,i))||n.enumerable});return t};var ce=(t,e,r)=>(r=t!=null?Yt(Zt(t)):{},lt(e||!t||!t.__esModule?de(r,"default",{value:t,enumerable:!0}):r,t)),rr=t=>lt(de({},"__esModule",{value:!0}),t);var Br={};tr(Br,{AllowlistIdentifier:()=>j,AuthStatus:()=>Xe,Clerk:()=>$r,Client:()=>D,DeletedObject:()=>F,Email:()=>V,EmailAddress:()=>C,ExternalAccount:()=>$,IdentificationLink:()=>U,Invitation:()=>B,OauthAccessToken:()=>G,ObjectType:()=>je,Organization:()=>E,OrganizationInvitation:()=>H,OrganizationMembership:()=>Y,OrganizationMembershipPublicUserData:()=>ne,PhoneNumber:()=>q,RedirectUrl:()=>X,SMSMessage:()=>Z,Session:()=>N,SignInToken:()=>Q,Token:()=>ee,User:()=>te,Verification:()=>P,constants:()=>pt,createAuthenticateRequest:()=>at,debugRequestState:()=>qe,decodeJwt:()=>Ue,deserialize:()=>Fe,hasValidSignature:()=>Pt,loadInterstitialFromLocal:()=>ve,makeAuthObjectSerializable:()=>br,prunePrivateMetadata:()=>$e,redirect:()=>Bt,sanitizeAuthObject:()=>hr,signedInAuthObject:()=>Be,signedOutAuthObject:()=>Ge,verifyJwt:()=>nt,verifyToken:()=>st});module.exports=rr(Br);var m=class{constructor(e){this.request=e}requireId(e){if(!e)throw new Error("A valid resource ID is required.")}};var Me="/",nr=new RegExp(Me+"{1,}","g");function l(...t){return t.filter(e=>e).join(Me).replace(nr,Me)}var ze="/allowlist_identifiers",pe=class extends m{async getAllowlistIdentifierList(){return this.request({method:"GET",path:ze})}async createAllowlistIdentifier(e){return this.request({method:"POST",path:ze,bodyParams:e})}async deleteAllowlistIdentifier(e){return this.requireId(e),this.request({method:"DELETE",path:l(ze,e)})}};var Le="/clients",me=class extends m{async getClientList(){return this.request({method:"GET",path:Le})}async getClient(e){return this.requireId(e),this.request({method:"GET",path:l(Le,e)})}verifyClient(e){return this.request({method:"POST",path:l(Le,"verify"),bodyParams:{token:e}})}};var ge="/email_addresses",fe=class extends m{async getEmailAddress(e){return this.requireId(e),this.request({method:"GET",path:l(ge,e)})}async createEmailAddress(e){return this.request({method:"POST",path:ge,bodyParams:e})}async updateEmailAddress(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(ge,e),bodyParams:r})}async deleteEmailAddress(e){return this.requireId(e),this.request({method:"DELETE",path:l(ge,e)})}};var ir="/emails",ye=class extends m{async createEmail(e){return this.request({method:"POST",path:ir,bodyParams:e})}};var he=class extends m{async getInterstitial(){return this.request({path:"internal/interstitial",method:"GET",headerParams:{"Content-Type":"text/html"}})}};var We="/invitations",be=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 w="/organizations",Se=class extends m{async getOrganizationList(e){return this.request({method:"GET",path:w,queryParams:e})}async createOrganization(e){return this.request({method:"POST",path:w,bodyParams:e})}async getOrganization(e){let r="organizationId"in e?e.organizationId:e.slug;return this.requireId(r),this.request({method:"GET",path:l(w,r)})}async updateOrganization(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e),bodyParams:r})}async updateOrganizationMetadata(e,r){return this.requireId(e),this.request({method:"PATCH",path:l(w,e,"metadata"),bodyParams:r})}async deleteOrganization(e){return this.request({method:"DELETE",path:l(w,e)})}async getOrganizationMembershipList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"memberships"),queryParams:{limit:n,offset:i}})}async createOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"memberships"),bodyParams:{userId:n,role:i}})}async updateOrganizationMembership(e){let{organizationId:r,userId:n,role:i}=e;return this.requireId(r),this.request({method:"PATCH",path:l(w,r,"memberships",n),bodyParams:{role:i}})}async updateOrganizationMembershipMetadata(e){let{organizationId:r,userId:n,publicMetadata:i,privateMetadata:s}=e;return this.request({method:"PATCH",path:l(w,r,"memberships",n,"metadata"),bodyParams:{publicMetadata:i,privateMetadata:s}})}async deleteOrganizationMembership(e){let{organizationId:r,userId:n}=e;return this.requireId(r),this.request({method:"DELETE",path:l(w,r,"memberships",n)})}async getPendingOrganizationInvitationList(e){let{organizationId:r,limit:n,offset:i}=e;return this.requireId(r),this.request({method:"GET",path:l(w,r,"invitations","pending"),queryParams:{limit:n,offset:i}})}async createOrganizationInvitation(e){let{organizationId:r,...n}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations"),bodyParams:{...n}})}async revokeOrganizationInvitation(e){let{organizationId:r,invitationId:n,requestingUserId:i}=e;return this.requireId(r),this.request({method:"POST",path:l(w,r,"invitations",n,"revoke"),bodyParams:{requestingUserId:i}})}};var Oe="/phone_numbers",ke=class extends m{async getPhoneNumber(e){return this.requireId(e),this.request({method:"GET",path:l(Oe,e)})}async createPhoneNumber(e){return this.request({method:"POST",path:Oe,bodyParams:e})}async updatePhoneNumber(e,r={}){return this.requireId(e),this.request({method:"PATCH",path:l(Oe,e),bodyParams:r})}async deletePhoneNumber(e){return this.requireId(e),this.request({method:"DELETE",path:l(Oe,e)})}};var _e="/redirect_urls",Ie=class extends m{async getRedirectUrlList(){return this.request({method:"GET",path:_e})}async getRedirectUrl(e){return this.requireId(e),this.request({method:"GET",path:l(_e,e)})}async createRedirectUrl(e){return this.request({method:"POST",path:_e,bodyParams:e})}async deleteRedirectUrl(e){return this.requireId(e),this.request({method:"DELETE",path:l(_e,e)})}};var oe="/sessions",Ae=class extends m{async getSessionList(e){return this.request({method:"GET",path:oe,queryParams:e})}async getSession(e){return this.requireId(e),this.request({method:"GET",path:l(oe,e)})}async revokeSession(e){return this.requireId(e),this.request({method:"POST",path:l(oe,e,"revoke")})}async verifySession(e,r){return this.requireId(e),this.request({method:"POST",path:l(oe,e,"verify"),bodyParams:{token:r}})}async getToken(e,r){return this.requireId(e),(await this.request({method:"POST",path:l(oe,e,"tokens",r||"")})).jwt}};var ut="/sign_in_tokens",we=class extends m{async createSignInToken(e){return this.request({method:"POST",path:ut,bodyParams:e})}async revokeSignInToken(e){return this.requireId(e),this.request({method:"POST",path:l(ut,e,"revoke")})}};var sr="/sms_messages",Pe=class extends m{async createSMSMessage(e){return this.request({method:"POST",path:sr,bodyParams:e})}};var R="/users",xe=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 ft=ce(require("deepmerge")),Ve=ce(require("snakecase-keys"));var z="https://api.clerk.dev",J="v1",dt="@clerk/backend";var or={AuthStatus:"__clerkAuthStatus",AuthReason:"__clerkAuthReason",AuthMessage:"__clerkAuthMessage"},ar={Session:"__session",ClientUat:"__client_uat"},ct={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",ForwardedHost:"x-forwarded-host",Referrer:"referer",UserAgent:"user-agent",Origin:"origin",Host:"host",ContentType:"content-type"},lr={AuthStatus:ct.AuthStatus},ur={Json:"application/json"},pt={Attributes:or,Cookies:ar,Headers:ct,SearchParams:lr,ContentTypes:ur};var mt=ce(require("#crypto")),gt=ce(require("#fetch")),dr=gt.default.bind(globalThis),cr={crypto:mt.default,fetch:dr},v=cr;function Te(t){if(!t||typeof t!="string")throw Error("Missing Clerk Secret Key or API Key. Go to https://dashboard.clerk.com and get your key for your instance.")}var j=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 j(e.id,e.identifier,e.created_at,e.updated_at,e.invitation_id)}};var N=class{constructor(e,r,n,i,s,o,u,a,d){this.id=e;this.clientId=r;this.userId=n;this.status=i;this.lastActiveAt=s;this.expireAt=o;this.abandonAt=u;this.createdAt=a;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,o,u,a){this.id=e;this.sessionIds=r;this.sessions=n;this.signInId=i;this.signUpId=s;this.lastActiveSessionId=o;this.createdAt=u;this.updatedAt=a}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,o,u,a,d,g,f){this.id=e;this.fromEmailName=r;this.emailAddressId=n;this.toEmailAddress=i;this.subject=s;this.body=o;this.bodyPlain=u;this.status=a;this.slug=d;this.data=g;this.deliveredByClerk=f}static fromJSON(e){return new V(e.id,e.from_email_name,e.email_address_id,e.to_email_address,e.subject,e.body,e.body_plain,e.status,e.slug,e.data,e.delivered_by_clerk)}};var U=class{constructor(e,r){this.id=e;this.type=r}static fromJSON(e){return new U(e.id,e.type)}};var P=class{constructor(e,r,n=null,i=null,s=null,o=null){this.status=e;this.strategy=r;this.externalVerificationRedirectURL=n;this.attempts=i;this.expireAt=s;this.nonce=o}static fromJSON(e){return new P(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 C=class{constructor(e,r,n,i){this.id=e;this.emailAddress=r;this.verification=n;this.linkedTo=i}static fromJSON(e){return new C(e.id,e.email_address,e.verification&&P.fromJSON(e.verification),e.linked_to.map(r=>U.fromJSON(r)))}};var $=class{constructor(e,r,n,i,s,o,u,a,d,g,f={},b,y){this.id=e;this.provider=r;this.identificationId=n;this.externalId=i;this.approvedScopes=s;this.emailAddress=o;this.firstName=u;this.lastName=a;this.picture=d;this.username=g;this.publicMetadata=f;this.label=b;this.verification=y}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.username,e.public_metadata,e.label,e.verification&&P.fromJSON(e.verification))}};var B=class{constructor(e,r,n,i,s,o,u){this.id=e;this.emailAddress=r;this.publicMetadata=n;this.createdAt=i;this.updatedAt=s;this.status=o;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 je=(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))(je||{});var G=class{constructor(e,r,n={},i,s,o){this.provider=e;this.token=r;this.publicMetadata=n;this.label=i;this.scopes=s;this.tokenSecret=o}static fromJSON(e){return new G(e.provider,e.token,e.public_metadata,e.label,e.scopes,e.token_secret)}};var E=class{constructor(e,r,n,i,s,o,u,a,d={},g={},f){this.id=e;this.name=r;this.slug=n;this.logoUrl=i;this.experimental_imageUrl=s;this.createdBy=o;this.createdAt=u;this.updatedAt=a;this.publicMetadata=d;this.privateMetadata=g;this.maxAllowedMemberships=f}static fromJSON(e){return new E(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,o,u,a={}){this.id=e;this.emailAddress=r;this.role=n;this.organizationId=i;this.createdAt=s;this.updatedAt=o;this.status=u;this.publicMetadata=a}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,o,u,a){this.id=e;this.role=r;this.publicMetadata=n;this.privateMetadata=i;this.createdAt=s;this.updatedAt=o;this.organization=u;this.publicUserData=a}static fromJSON(e){return new Y(e.id,e.role,e.public_metadata,e.private_metadata,e.created_at,e.updated_at,E.fromJSON(e.organization),ne.fromJSON(e.public_user_data))}},ne=class{constructor(e,r,n,i,s,o){this.identifier=e;this.firstName=r;this.lastName=n;this.profileImageUrl=i;this.experimental_imageUrl=s;this.userId=o}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,o){this.id=e;this.phoneNumber=r;this.reservedForSecondFactor=n;this.defaultSecondFactor=i;this.verification=s;this.linkedTo=o}static fromJSON(e){return new q(e.id,e.phone_number,e.reserved_for_second_factor,e.default_second_factor,e.verification&&P.fromJSON(e.verification),e.linked_to.map(r=>U.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,o,u){this.id=e;this.userId=r;this.token=n;this.status=i;this.url=s;this.createdAt=o;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,o,u){this.id=e;this.fromPhoneNumber=r;this.toPhoneNumber=n;this.message=i;this.status=s;this.phoneNumberId=o;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&&P.fromJSON(e.verification))}};var te=class{constructor(e,r,n,i,s,o,u,a,d,g,f,b,y,S,x,T,O,k,I,A,_={},h={},p={},re=[],ue=[],Ke=[],Gt=[]){this.id=e;this.passwordEnabled=r;this.totpEnabled=n;this.backupCodeEnabled=i;this.twoFactorEnabled=s;this.banned=o;this.createdAt=u;this.updatedAt=a;this.profileImageUrl=d;this.experimental_imageUrl=g;this.gender=f;this.birthday=b;this.primaryEmailAddressId=y;this.primaryPhoneNumberId=S;this.primaryWeb3WalletId=x;this.lastSignInAt=T;this.externalId=O;this.username=k;this.firstName=I;this.lastName=A;this.publicMetadata=_;this.privateMetadata=h;this.unsafeMetadata=p;this.emailAddresses=re;this.phoneNumbers=ue;this.web3Wallets=Ke;this.externalAccounts=Gt}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=>C.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 Fe(t){return Array.isArray(t)?t.map(e=>De(e)):pr(t)?t.data.map(e=>De(e)):De(t)}function pr(t){return Array.isArray(t.data)&&t.data!==void 0}function mr(t){return t.total_count}function De(t){if(typeof t!="string"&&"object"in t&&"deleted"in t)return F.fromJSON(t);switch(t.object){case"allowlist_identifier":return j.fromJSON(t);case"client":return D.fromJSON(t);case"email_address":return C.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 E.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 mr(t);case"user":return te.fromJSON(t);default:return t}}var gr=t=>async(...e)=>{let{data:r,errors:n,status:i,statusText:s}=await t(...e);if(n===null)return r;throw new ae(s||"",{data:n,status:i||""})};function yt(t){return gr(async r=>{let{apiKey:n,secretKey:i,apiUrl:s=z,apiVersion:o=J,userAgent:u=dt,httpOptions:a={}}=t,{path:d,method:g,queryParams:f,headerParams:b,bodyParams:y}=r,S=i||n;Te(S);let x=l(s,o,d),T=new URL(x);if(f){let _=(0,Ve.default)({...f});for(let[h,p]of Object.entries(_))p&&[p].flat().forEach(re=>T.searchParams.append(h,re))}let O={Authorization:`Bearer ${S}`,"Content-Type":"application/json","Clerk-Backend-SDK":u,...b},I=g!=="GET"&&y&&Object.keys(y).length>0?{body:JSON.stringify((0,Ve.default)(y,{deep:!1}))}:null,A;try{A=await v.fetch(T.href,(0,ft.default)(a,{method:g,headers:O,...I}));let h=await(O&&O["Content-Type"]==="application/json"?A.json():A.text());if(!A.ok)throw h;return{data:Fe(h),errors:null}}catch(_){return _ instanceof Error?{data:null,errors:[{code:"unexpected_error",message:_.message||"Unexpected error"}]}:{data:null,errors:fr(_),status:A?.status,statusText:A?.statusText}}})}function fr(t){if(t&&typeof t=="object"&&"errors"in t){let e=t.errors;return e.length>0?e.map(yr):[]}return[]}function yr(t){return{code:t.code,message:t.message,longMessage:t.long_message,meta:{paramName:t?.meta?.param_name,sessionId:t?.meta?.session_id}}}var ae=class extends Error{constructor(r,{data:n,status:i}){super(r);Object.setPrototypeOf(this,ae.prototype),this.clerkError=!0,this.message=r,this.status=i,this.errors=n}};function se(t){let e=yt(t);return{allowlistIdentifiers:new pe(e),clients:new me(e),emailAddresses:new fe(e),emails:new ye(e),interstitial:new he(e),invitations:new be(e),organizations:new Se(e),phoneNumbers:new ke(e),redirectUrls:new Ie(e),sessions:new Ae(e),signInTokens:new we(e),smsMessages:new Pe(e),users:new xe(e)}}var ht=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 Be(t,e,r){let{act:n,sid:i,org_id:s,org_role:o,org_slug:u,sub:a}=t,{apiKey:d,secretKey:g,apiUrl:f,apiVersion:b,token:y,session:S,user:x,organization:T}=e,{sessions:O}=se({apiKey:d,secretKey:g,apiUrl:f,apiVersion:b}),k=Sr({sessionId:i,sessionToken:y,fetcher:(...I)=>O.getToken(...I)});return{actor:n,sessionClaims:t,sessionId:i,session:S,userId:a,user:x,orgId:s,orgRole:o,orgSlug:u,organization:T,getToken:k,debug:ht({...e,...r})}}function Ge(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:ht(t)}}function $e(t){return t&&(delete t.privateMetadata,delete t.private_metadata),t}function hr(t){let e=t.user?{...t.user}:t.user,r=t.organization?{...t.organization}:t.organization;return $e(e),$e(r),{...t,user:e,organization:r}}var br=t=>{let{debug:e,getToken:r,...n}=t;return n},Sr=t=>{let{fetcher:e,sessionToken:r,sessionId:n}=t||{};return async(i={})=>n?i.template?e(n,i.template):r:null};function Or(t){return new Promise(e=>setTimeout(e,t))}var kr=5;async function le(t,e=1,r=kr){try{return await t()}catch(n){if(e>=r)throw n;return await Or(2**e*100),le(t,e+1)}}function L(t){return t.startsWith("test_")||t.startsWith("sk_test_")}function bt(t){return t.startsWith("live_")||t.startsWith("sk_live_")}function St(t){return t.endsWith(".lclstage.dev")||t.endsWith(".stgstage.dev")||t.endsWith(".clerkstage.dev")||t.endsWith(".accountsstage.dev")}function _r(){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:He}=_r();var Ot="pk_live_",Ir="pk_test_";function W(t){if(t=t||"",!Ar(t))return null;let e=t.startsWith(Ot)?"production":"development",r=kt(t.split("_")[2]);return r.endsWith("$")?(r=r.slice(0,-1),{instanceType:e,frontendApi:r}):null}function Ar(t){t=t||"";let e=t.startsWith(Ot)||t.startsWith(Ir),r=kt(t.split("_")[2]||"").endsWith("$");return e&&r}var kt=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 wr(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 ve(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=He(t.frontendApi)?"":wr(t.domain),{debugData:r,frontendApi:n,pkgVersion:i,publishableKey:s,proxyUrl:o,isSatellite:u=!1,domain:a,signInUrl:d}=t;return` | ||
<head> | ||
@@ -64,3 +64,3 @@ <meta charset="UTF-8" /> | ||
</body> | ||
`}async function It(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Re(t),r=await le(()=>N.fetch(Re(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 Re(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=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),o&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",a||""),He(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var _t=(t,e)=>!e&&St(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",Pr=(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 Xe=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(Xe||{});async function Qe(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:o,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,headerToken:b,loadSession:y,loadUser:S,loadOrganization:x,signInUrl:T}=t,{sid:O,org_id:k,sub:_}=e,{sessions:A,users:I,organizations:h}=se({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,re,ue]=await Promise.all([y?A.getSession(O):Promise.resolve(void 0),S?I.getUser(_):Promise.resolve(void 0),x&&k?h.getOrganization({organizationId:k}):Promise.resolve(void 0)]),Ht=Be(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:o||b||"",session:p,user:re,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,signInUrl:T,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Ht}}function K(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:o,domain:u,signInUrl:a,isSignedIn:!1,isInterstitial:!1,isUnknown:!1,toAuth:()=>Ge({...t,status:"signed-out",reason:e,message:r})}}function M(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:o,domain:u,proxyUrl:s,signInUrl:a,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function At(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function Ze({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){if(i&&i!==t.protocol)return!0;let s=xr(r||e);return s.port=n||s.port,s.port!==t.port||s.hostname!==t.hostname}function xr(t){return new URL(`https://${t}`)}var ve={parse(t,e){return Tr(t,wt,e)},stringify(t,e){return Rr(t,wt,e)}},wt={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function Tr(t,e,r={}){if(!e.codes){e.codes={};for(let a=0;a<e.chars.length;++a)e.codes[e.chars[a]]=a}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,o=0,u=0;for(let a=0;a<n;++a){let d=e.codes[t[a]];if(d===void 0)throw new SyntaxError("Invalid character "+t[a]);o=o<<e.bits|d,s+=e.bits,s>=8&&(s-=8,i[u++]=255&o>>s)}if(s>=e.bits||255&o<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Rr(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",o=0,u=0;for(let a=0;a<t.length;++a)for(u=u<<8|255&t[a],o+=8;o>e.bits;)o-=e.bits,s+=e.chars[i&u>>o];if(o&&(s+=e.chars[i&u<<e.bits-o]),n)for(;s.length*e.bits&7;)s+="=";return s}var Jr=2*1e3,rt={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},et="RSASSA-PKCS1-v1_5",tt="ECDSA",Nr={RS256:et,RS384:et,RS512:et,ES256:tt,ES384:tt,ES512:tt},vr=Object.keys(rt);async function Pt(t,e){let{header:r,signature:n,raw:i}=t,o=new TextEncoder().encode([i.header,i.payload].join(".")),u=await N.crypto.subtle.importKey("jwk",e,{name:Nr[r.alg],hash:rt[r.alg]},!1,["verify"]);return N.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,o)}function Ue(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,o=JSON.parse(s.decode(ve.parse(r,{loose:!0}))),u=JSON.parse(s.decode(ve.parse(n,{loose:!0}))),a=ve.parse(i,{loose:!0});return{header:o,payload:u,signature:a,raw:{header:r,payload:n,signature:i,text:t}}}async function nt(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=Jr,issuer:i,key:s}){let o=Ue(t),{header:u,payload:a}=o,{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(!rt[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: ${vr}.`});let{azp:f,sub:b,aud:y,iss:S,iat:x,exp:T,nbf:O}=a;if(typeof b!="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(b)}.`});if(typeof y=="string"){if(y!==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(y)}. Expected "${e}".`})}else if(Array.isArray(y)&&y.length>0&&y.every(h=>typeof h=="string")&&!y.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(y)}. Does not include "${e}".`});if(f&&r&&r.length>0&&!r.includes(f))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(S))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"&&S&&S!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(o.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 k=new Date(Date.now()),_=new Date(0);if(_.setUTCSeconds(T),_.getTime()<=k.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${_}, Current date: ${k}.`});if(O!==void 0){if(typeof O!="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(O)}. Expected number.`});let h=new Date(0);if(h.setUTCSeconds(O),h.getTime()>k.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: ${h}; Current date: ${k};`})}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 h=new Date(0);if(h.setUTCSeconds(x),h.getTime()>k.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${h}; Current date: ${k};`})}let I;try{I=await Pt(o,s)}catch(h){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${h}`})}if(!I)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return a}var Ce={},Tt=0;function Ee(t){return Ce[t]}function Rt(t,e=1e3*60*60){Ce[t.kid]=t,Tt=Date.now(),e>=0&&setTimeout(()=>{t?delete Ce[t.kid]:Ce={}},e)}var xt="local",Cr="-----BEGIN PUBLIC KEY-----",Er="-----END PUBLIC KEY-----",qr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Kr="IDAQAB";function Jt(t){if(!Ee(xt)){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(Cr,"").replace(Er,"").replace(qr,"").replace(Kr,"").replace(/\+/g,"-").replace(/\//g,"_");Rt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ee(xt)}async function it({apiKey:t,secretKey:e,apiUrl:r=z,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:o=1e3*60*60,skipJwksCache:u}){let a=!Ee(s)&&Lr();if(u||a){let g,f=e||t;if(f)g=()=>zr(r,f,n);else if(i)g=()=>Mr(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:b}=await le(g);if(!b||!b.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"});b.forEach(y=>Rt(y,o))}let d=Ee(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 Mr(t){let e=new URL(t);e.pathname=l(e.pathname,".well-known/jwks.json");let r=await N.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 zr(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 N.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 Lr(){return Date.now()-Tt>=300*1e3}async function st(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:o,clockSkewInSeconds:u,issuer:a,jwksCacheTtlInMs:d,jwtKey:g,skipJwksCache:f}=e,{header:b}=Ue(t),{kid:y}=b,S;if(g)S=Jt(g);else if(typeof a=="string")S=await it({issuer:a,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});else if(r||n)S=await it({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});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 nt(t,{authorizedParties:o,clockSkewInSeconds:u,key:S,issuer:a})}var jr=t=>!!t?.get("__clerk_satellite_url"),Nt=t=>t?.get("__clerk_synced")==="true",vt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(L(r||e)&&!n?.startsWith("Mozilla/"))return K(t,"header-missing-non-browser")},Ut=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&Ze({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return K(t,"header-missing-cors")},Ct=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(L(r||e)&&!n&&jr(i))return M(t,"primary-responds-to-syncing")},Et=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(L(r||e)&&!n)return M(t,"uat-missing")},qt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u,isSatellite:a,searchParams:d}=t,g=n&&Ze({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u}),f=r||e;if(!a&&!Nt(d)&&L(f)&&g)return M(t,"cross-origin-referrer")},Kt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(bt(r||e)&&!n&&!i)return K(t,"cookie-and-uat-missing")},Mt=t=>{let{clientUat:e}=t;if(e==="0")return K(t,"standard-signed-out")},zt=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return M(t,"cookie-missing")},Lt=async t=>{let{headerToken:e}=t,r=await jt(t,e);return await Qe(t,r)},Wt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await jt(t,e),i=await Qe(t,n),o=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||o?M(t,"cookie-outdated"):i};async function ot(t,e){for(let r of e){let n=await r(t);if(n)return n}return K(t,"unexpected-error")}async function jt(t,e){let{isSatellite:r,proxyUrl:n}=t,i;return r?i=null:n?i=n:i=s=>s.startsWith("https://clerk.")||s.includes(".clerk.accounts"),st(e,{...t,issuer:i})}var Dt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=L(i||s);if(r&&(!e||e==="0")&&!Nt(n)&&!u)return M(t,"satellite-needs-syncing")};function Dr(t,e){if(!t&&L(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function Fr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Ft(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||z,t.apiVersion=t.apiVersion||J,Te(t.secretKey||t.apiKey),t.isSatellite&&(Dr(t.signInUrl,t.secretKey||t.apiKey),Fr(t.proxyUrl||t.domain));async function e(){try{return await ot(t,[Lt])}catch(i){return n(i,"header")}}async function r(){try{return await ot(t,[Ut,vt,Dt,Ct,Kt,Et,qt,zt,Mt,Wt])}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()):M(t,i.reason,i.getFullMessage()):K(t,i.reason,i.getFullMessage())):K(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:o,publishableKey:u,isSatellite:a,domain:d}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:o,publishableKey:u,isSatellite:a,domain:d}};function at(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=z,apiVersion:o=J,frontendApi:u="",proxyUrl:a="",publishableKey:d="",isSatellite:g=!1,domain:f=""}=t.options;return{authenticateRequest:({apiKey:O,secretKey:k,frontendApi:_,proxyUrl:A,publishableKey:I,jwtKey:h,isSatellite:p,domain:re,searchParams:ue,...Ke})=>Ft({...Ke,apiKey:O||r,secretKey:k||n,apiUrl:s,apiVersion:o,frontendApi:_||u,proxyUrl:A||a,publishableKey:I||d,isSatellite:p||g,domain:re||f,jwtKey:h||i,searchParams:ue}),localInterstitial:Ne,remotePublicInterstitial:({frontendApi:O,publishableKey:k,proxyUrl:_,isSatellite:A,domain:I,...h})=>It({...h,apiUrl:s,frontendApi:O||u,publishableKey:k||d,proxyUrl:_||a,isSatellite:A||g,domain:I||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Re,debugRequestState:qe}}var Vt=(t,e)=>{let r;if(t.startsWith("http"))r=new URL(t);else{if(!e||!e.startsWith("http"))throw new Error("destination url or return back url should be an absolute path url!");let n=new URL(e);r=new URL(t,n.origin)}return e&&r.searchParams.set("redirect_url",e),r.toString()},$t="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Bt({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=W(i)?.frontendApi);let s=Vr(n);return{redirectToSignUp:({returnBackUrl:a}={})=>{if(!e&&!s)throw new Error($t);let d=`${s}/sign-up`;return t(Vt(e||d,a))},redirectToSignIn:({returnBackUrl:a}={})=>{if(!r&&!s)throw new Error($t);let d=`${s}/sign-in`;return t(Vt(r||d,a))}}}function Vr(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function $r(t){let e={...t},r=se(e),n=at({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 _t(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let e=Re(t),r=await le(()=>v.fetch(Re(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 Re(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"";let{apiUrl:e,frontendApi:r,pkgVersion:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t,d=new URL(e);return d.pathname=l(d.pathname,J,"/public/interstitial"),d.searchParams.append("clerk_js_version",It(r,n)),i?d.searchParams.append("publishable_key",i):d.searchParams.append("frontend_api",r),s&&d.searchParams.append("proxy_url",s),o&&d.searchParams.append("is_satellite","true"),d.searchParams.append("sign_in_url",a||""),He(t.frontendApi)||d.searchParams.append("use_domain_for_script","true"),u&&d.searchParams.append("domain",u),d.href}var It=(t,e)=>!e&&St(t)?"staging":e?e.includes("next")?"next":e.split(".")[0]||"latest":"latest",Pr=(t,e)=>{let r=t.replace(/http(s)?:\/\//,""),n=It(t,e);return`https://${r}/npm/@clerk/clerk-js@${n}/dist/clerk.browser.js`};var Xe=(i=>(i.SignedIn="signed-in",i.SignedOut="signed-out",i.Interstitial="interstitial",i.Unknown="unknown",i))(Xe||{});async function Qe(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,cookieToken:o,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,headerToken:b,loadSession:y,loadUser:S,loadOrganization:x,signInUrl:T}=t,{sid:O,org_id:k,sub:I}=e,{sessions:A,users:_,organizations:h}=se({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s}),[p,re,ue]=await Promise.all([y?A.getSession(O):Promise.resolve(void 0),S?_.getUser(I):Promise.resolve(void 0),x&&k?h.getOrganization({organizationId:k}):Promise.resolve(void 0)]),Ht=Be(e,{secretKey:n,apiKey:r,apiUrl:i,apiVersion:s,token:o||b||"",session:p,user:re,organization:ue},{...t,status:"signed-in"});return{status:"signed-in",reason:null,message:null,frontendApi:u,proxyUrl:a,publishableKey:d,domain:g,isSatellite:f,signInUrl:T,isSignedIn:!0,isInterstitial:!1,isUnknown:!1,toAuth:()=>Ht}}function K(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t;return{status:"signed-out",reason:e,message:r,frontendApi:n,proxyUrl:s,publishableKey:i,isSatellite:o,domain:u,signInUrl:a,isSignedIn:!1,isInterstitial:!1,isUnknown:!1,toAuth:()=>Ge({...t,status:"signed-out",reason:e,message:r})}}function M(t,e,r=""){let{frontendApi:n,publishableKey:i,proxyUrl:s,isSatellite:o,domain:u,signInUrl:a}=t;return{status:"interstitial",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:o,domain:u,proxyUrl:s,signInUrl:a,isSignedIn:!1,isInterstitial:!0,isUnknown:!1,toAuth:()=>null}}function At(t,e,r=""){let{frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u}=t;return{status:"unknown",reason:e,message:r,frontendApi:n,publishableKey:i,isSatellite:s,domain:o,signInUrl:u,isSignedIn:!1,isInterstitial:!1,isUnknown:!0,toAuth:()=>null}}function Ze({originURL:t,host:e,forwardedHost:r,forwardedPort:n,forwardedProto:i}){if(i&&i!==t.protocol)return!0;let s=xr(r||e);return s.port=n||s.port,s.port!==t.port||s.hostname!==t.hostname}function xr(t){return new URL(`https://${t}`)}var Ne={parse(t,e){return Tr(t,wt,e)},stringify(t,e){return Rr(t,wt,e)}},wt={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6};function Tr(t,e,r={}){if(!e.codes){e.codes={};for(let a=0;a<e.chars.length;++a)e.codes[e.chars[a]]=a}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,o=0,u=0;for(let a=0;a<n;++a){let d=e.codes[t[a]];if(d===void 0)throw new SyntaxError("Invalid character "+t[a]);o=o<<e.bits|d,s+=e.bits,s>=8&&(s-=8,i[u++]=255&o>>s)}if(s>=e.bits||255&o<<8-s)throw new SyntaxError("Unexpected end of data");return i}function Rr(t,e,r={}){let{pad:n=!0}=r,i=(1<<e.bits)-1,s="",o=0,u=0;for(let a=0;a<t.length;++a)for(u=u<<8|255&t[a],o+=8;o>e.bits;)o-=e.bits,s+=e.chars[i&u>>o];if(o&&(s+=e.chars[i&u<<e.bits-o]),n)for(;s.length*e.bits&7;)s+="=";return s}var Jr=2*1e3,rt={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512",ES256:"SHA-256",ES384:"SHA-384",ES512:"SHA-512"},et="RSASSA-PKCS1-v1_5",tt="ECDSA",vr={RS256:et,RS384:et,RS512:et,ES256:tt,ES384:tt,ES512:tt},Nr=Object.keys(rt);async function Pt(t,e){let{header:r,signature:n,raw:i}=t,o=new TextEncoder().encode([i.header,i.payload].join(".")),u=await v.crypto.subtle.importKey("jwk",e,{name:vr[r.alg],hash:rt[r.alg]},!1,["verify"]);return v.crypto.subtle.verify("RSASSA-PKCS1-v1_5",u,n,o)}function Ue(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,o=JSON.parse(s.decode(Ne.parse(r,{loose:!0}))),u=JSON.parse(s.decode(Ne.parse(n,{loose:!0}))),a=Ne.parse(i,{loose:!0});return{header:o,payload:u,signature:a,raw:{header:r,payload:n,signature:i,text:t}}}async function nt(t,{audience:e,authorizedParties:r,clockSkewInSeconds:n=Jr,issuer:i,key:s}){let o=Ue(t),{header:u,payload:a}=o,{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(!rt[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: ${Nr}.`});let{azp:f,sub:b,aud:y,iss:S,iat:x,exp:T,nbf:O}=a;if(typeof b!="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(b)}.`});if(typeof y=="string"){if(y!==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(y)}. Expected "${e}".`})}else if(Array.isArray(y)&&y.length>0&&y.every(h=>typeof h=="string")&&!y.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(y)}. Does not include "${e}".`});if(f&&r&&r.length>0&&!r.includes(f))throw new c({reason:"token-invalid-authorized-parties",message:`Invalid JWT Authorized party claim (azp) ${JSON.stringify(f)}. Expected "${r}".`});if(typeof i=="function"&&!i(S))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"&&S&&S!==i)throw new c({reason:"token-invalid-issuer",message:`Invalid JWT issuer claim (iss) ${JSON.stringify(o.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 k=new Date(Date.now()),I=new Date(0);if(I.setUTCSeconds(T),I.getTime()<=k.getTime()-n)throw new c({reason:"token-expired",message:`JWT is expired. Expiry date: ${I}, Current date: ${k}.`});if(O!==void 0){if(typeof O!="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(O)}. Expected number.`});let h=new Date(0);if(h.setUTCSeconds(O),h.getTime()>k.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: ${h}; Current date: ${k};`})}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 h=new Date(0);if(h.setUTCSeconds(x),h.getTime()>k.getTime()+n)throw new c({reason:"token-not-active-yet",message:`JWT issued at date claim (iat) is in the future. Issued at date: ${h}; Current date: ${k};`})}let _;try{_=await Pt(o,s)}catch(h){throw new c({action:"Make sure that this is a valid Clerk generate JWT.",reason:"token-verification-failed",message:`Error verifying JWT signature. ${h}`})}if(!_)throw new c({reason:"token-invalid-signature",message:"JWT signature is invalid."});return a}var Ce={},Tt=0;function Ee(t){return Ce[t]}function Rt(t,e=1e3*60*60){Ce[t.kid]=t,Tt=Date.now(),e>=0&&setTimeout(()=>{t?delete Ce[t.kid]:Ce={}},e)}var xt="local",Cr="-----BEGIN PUBLIC KEY-----",Er="-----END PUBLIC KEY-----",qr="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA",Kr="IDAQAB";function Jt(t){if(!Ee(xt)){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(Cr,"").replace(Er,"").replace(qr,"").replace(Kr,"").replace(/\+/g,"-").replace(/\//g,"_");Rt({kid:"local",kty:"RSA",alg:"RS256",n:e,e:"AQAB"},-1)}return Ee(xt)}async function it({apiKey:t,secretKey:e,apiUrl:r=z,apiVersion:n=J,issuer:i,kid:s,jwksCacheTtlInMs:o=1e3*60*60,skipJwksCache:u}){let a=!Ee(s)&&Lr();if(u||a){let g,f=e||t;if(f)g=()=>zr(r,f,n);else if(i)g=()=>Mr(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:b}=await le(g);if(!b||!b.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"});b.forEach(y=>Rt(y,o))}let d=Ee(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 Mr(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 zr(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 Lr(){return Date.now()-Tt>=300*1e3}async function st(t,e){let{apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,authorizedParties:o,clockSkewInSeconds:u,issuer:a,jwksCacheTtlInMs:d,jwtKey:g,skipJwksCache:f}=e,{header:b}=Ue(t),{kid:y}=b,S;if(g)S=Jt(g);else if(typeof a=="string")S=await it({issuer:a,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});else if(r||n)S=await it({apiKey:r,secretKey:n,apiUrl:i,apiVersion:s,kid:y,jwksCacheTtlInMs:d,skipJwksCache:f});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 nt(t,{authorizedParties:o,clockSkewInSeconds:u,key:S,issuer:a})}var jr=t=>!!t?.get("__clerk_satellite_url"),vt=t=>t?.get("__clerk_synced")==="true",Nt=t=>{let{apiKey:e,secretKey:r,userAgent:n}=t;if(L(r||e)&&!n?.startsWith("Mozilla/"))return K(t,"header-missing-non-browser")},Ut=t=>{let{origin:e,host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}=t;if(e&&Ze({originURL:new URL(e),host:r,forwardedHost:n,forwardedPort:i,forwardedProto:s}))return K(t,"header-missing-cors")},Ct=t=>{let{apiKey:e,secretKey:r,isSatellite:n,searchParams:i}=t;if(L(r||e)&&!n&&jr(i))return M(t,"primary-responds-to-syncing")},Et=t=>{let{apiKey:e,secretKey:r,clientUat:n}=t;if(L(r||e)&&!n)return M(t,"uat-missing")},qt=t=>{let{apiKey:e,secretKey:r,referrer:n,host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u,isSatellite:a,searchParams:d}=t,g=n&&Ze({originURL:new URL(n),host:i,forwardedHost:s,forwardedPort:o,forwardedProto:u}),f=r||e;if(!a&&!vt(d)&&L(f)&&g)return M(t,"cross-origin-referrer")},Kt=t=>{let{apiKey:e,secretKey:r,clientUat:n,cookieToken:i}=t;if(bt(r||e)&&!n&&!i)return K(t,"cookie-and-uat-missing")},Mt=t=>{let{clientUat:e}=t;if(e==="0")return K(t,"standard-signed-out")},zt=t=>{let{clientUat:e,cookieToken:r}=t;if(e&&Number.parseInt(e)>0&&!r)return M(t,"cookie-missing")},Lt=async t=>{let{headerToken:e}=t,r=await jt(t,e);return await Qe(t,r)},Wt=async t=>{let{cookieToken:e,clientUat:r}=t,n=await jt(t,e),i=await Qe(t,n),o=i.toAuth().sessionClaims.iat<Number.parseInt(r);return!r||o?M(t,"cookie-outdated"):i};async function ot(t,e){for(let r of e){let n=await r(t);if(n)return n}return K(t,"unexpected-error")}async function jt(t,e){let{isSatellite:r,proxyUrl:n}=t,i;return r?i=null:n?i=n:i=s=>s.startsWith("https://clerk.")||s.includes(".clerk.accounts"),st(e,{...t,issuer:i})}var Dt=t=>{let{clientUat:e,isSatellite:r,searchParams:n,secretKey:i,apiKey:s}=t,u=L(i||s);if(r&&(!e||e==="0")&&!vt(n)&&!u)return M(t,"satellite-needs-syncing")};function Dr(t,e){if(!t&&L(e))throw new Error("Missing signInUrl. Pass a signInUrl for dev instances if an app is satellite")}function Fr(t){if(!t)throw new Error("Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl")}async function Ft(t){t.frontendApi=W(t.publishableKey)?.frontendApi||t.frontendApi||"",t.apiUrl=t.apiUrl||z,t.apiVersion=t.apiVersion||J,Te(t.secretKey||t.apiKey),t.isSatellite&&(Dr(t.signInUrl,t.secretKey||t.apiKey),Fr(t.proxyUrl||t.domain));async function e(){try{return await ot(t,[Lt])}catch(i){return n(i,"header")}}async function r(){try{return await ot(t,[Ut,Nt,Dt,Ct,Kt,Et,qt,zt,Mt,Wt])}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()):M(t,i.reason,i.getFullMessage()):K(t,i.reason,i.getFullMessage())):K(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:o,publishableKey:u,isSatellite:a,domain:d}=t;return{frontendApi:e,isSignedIn:r,proxyUrl:n,isInterstitial:i,reason:s,message:o,publishableKey:u,isSatellite:a,domain:d}};function at(t){let{apiClient:e}=t,{apiKey:r="",secretKey:n="",jwtKey:i="",apiUrl:s=z,apiVersion:o=J,frontendApi:u="",proxyUrl:a="",publishableKey:d="",isSatellite:g=!1,domain:f=""}=t.options;return{authenticateRequest:({apiKey:O,secretKey:k,frontendApi:I,proxyUrl:A,publishableKey:_,jwtKey:h,isSatellite:p,domain:re,searchParams:ue,...Ke})=>Ft({...Ke,apiKey:O||r,secretKey:k||n,apiUrl:s,apiVersion:o,frontendApi:I||u,proxyUrl:A||a,publishableKey:_||d,isSatellite:p||g,domain:re||f,jwtKey:h||i,searchParams:ue}),localInterstitial:ve,remotePublicInterstitial:({frontendApi:O,publishableKey:k,proxyUrl:I,isSatellite:A,domain:_,...h})=>_t({...h,apiUrl:s,frontendApi:O||u,publishableKey:k||d,proxyUrl:I||a,isSatellite:A||g,domain:_||f}),remotePrivateInterstitial:()=>e.interstitial.getInterstitial(),remotePublicInterstitialUrl:Re,debugRequestState:qe}}var Vt=(t,e)=>{let r;if(t.startsWith("http"))r=new URL(t);else{if(!e||!e.startsWith("http"))throw new Error("destination url or return back url should be an absolute path url!");let n=new URL(e);r=new URL(t,n.origin)}return e&&r.searchParams.set("redirect_url",e),r.toString()},$t="Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.";function Bt({redirectAdapter:t,signUpUrl:e,signInUrl:r,frontendApi:n,publishableKey:i}){n||(n=W(i)?.frontendApi);let s=Vr(n);return{redirectToSignUp:({returnBackUrl:a}={})=>{if(!e&&!s)throw new Error($t);let d=`${s}/sign-up`;return t(Vt(e||d,a))},redirectToSignIn:({returnBackUrl:a}={})=>{if(!r&&!s)throw new Error($t);let d=`${s}/sign-in`;return t(Vt(r||d,a))}}}function Vr(t){return t?`https://${t.replace(/(clerk\.accounts\.|clerk\.)/,"accounts.")}`:""}function $r(t){let e={...t},r=se(e),n=at({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 |
@@ -9,6 +9,10 @@ import type { EmailJSON } from './JSON'; | ||
readonly body?: string | undefined; | ||
readonly bodyPlain?: string | null | undefined; | ||
readonly status?: string | undefined; | ||
constructor(id: string, fromEmailName: string, emailAddressId: string | null, toEmailAddress?: string | undefined, subject?: string | undefined, body?: string | undefined, status?: string | undefined); | ||
readonly slug?: string | null | undefined; | ||
readonly data?: Record<string, any> | null | undefined; | ||
readonly deliveredByClerk?: boolean | undefined; | ||
constructor(id: string, fromEmailName: string, emailAddressId: string | null, toEmailAddress?: string | undefined, subject?: string | undefined, body?: string | undefined, bodyPlain?: string | null | undefined, status?: string | undefined, slug?: string | null | undefined, data?: Record<string, any> | null | undefined, deliveredByClerk?: boolean | undefined); | ||
static fromJSON(data: EmailJSON): Email; | ||
} | ||
//# sourceMappingURL=Email.d.ts.map |
@@ -59,3 +59,7 @@ import type { InvitationStatus, OrganizationInvitationStatus, OrganizationMembershipRole, SignInStatus, SignUpAttributeRequirements, SignUpStatus } from './Enums'; | ||
body?: string; | ||
body_plain?: string | null; | ||
status?: string; | ||
slug?: string | null; | ||
data?: Record<string, any> | null; | ||
delivered_by_clerk?: boolean; | ||
} | ||
@@ -206,2 +210,3 @@ export interface EmailAddressJSON extends ClerkResourceJSON { | ||
status: string; | ||
data?: Record<string, any> | null; | ||
} | ||
@@ -208,0 +213,0 @@ export interface UserJSON extends ClerkResourceJSON { |
@@ -9,5 +9,6 @@ import type { SMSMessageJSON } from './JSON'; | ||
readonly phoneNumberId: string | null; | ||
constructor(id: string, fromPhoneNumber: string, toPhoneNumber: string, message: string, status: string, phoneNumberId: string | null); | ||
readonly data?: Record<string, any> | null | undefined; | ||
constructor(id: string, fromPhoneNumber: string, toPhoneNumber: string, message: string, status: string, phoneNumberId: string | null, data?: Record<string, any> | null | undefined); | ||
static fromJSON(data: SMSMessageJSON): SMSMessage; | ||
} | ||
//# sourceMappingURL=SMSMessage.d.ts.map |
{ | ||
"name": "@clerk/backend", | ||
"version": "0.18.0", | ||
"version": "0.18.1-staging.0", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "description": "Clerk Backend SDK - REST Client for Backend API & JWT verification utilities", | ||
"dependencies": { | ||
"@clerk/types": "^3.36.0", | ||
"@clerk/types": "^3.37.0-staging.0", | ||
"@peculiar/webcrypto": "1.4.1", | ||
@@ -84,3 +84,3 @@ "@types/node": "16.18.6", | ||
}, | ||
"gitHead": "fdd347a7332d07e9fabebfe9d661924564997d37" | ||
"gitHead": "0d086be3cf7d3824ff3a0e9c9f2ac1ebbedc19a2" | ||
} |
@@ -219,2 +219,22 @@ <p align="center"> | ||
## Support | ||
You can get in touch with us in any of the following ways: | ||
- Join our official community [Discord server](https://clerk.com/discord) | ||
- Open a [GitHub support issue](https://github.com/clerkinc/javascript/issues/new?assignees=&labels=question&template=ask_a_question.md&title=Support%3A+) | ||
- Contact options listed on [our Support page](https://clerk.com/support?utm_source=github&utm_medium=clerk_backend) | ||
## Contributing | ||
We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](https://github.com/clerkinc/javascript/blob/main/docs/CONTRIBUTING.md). | ||
## Security | ||
`@clerk/backend` follows good practices of security, but 100% security cannot be assured. | ||
`@clerk/backend` is provided **"as is"** without any **warranty**. Use at your own risk. | ||
_For more information and to report security issues, please refer to our [security documentation](https://github.com/clerkinc/javascript/blob/main/docs/SECURITY.md)._ | ||
## License | ||
@@ -221,0 +241,0 @@ |
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
592067
244
149
1944