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