@privy-io/react-auth 1.54.3-beta-20240125155353 → 1.54.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ss=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var tc=(e,t,o)=>(ss(e,t,"read from private field"),o?o.call(e):t.get(e)),ci=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},ls=(e,t,o,r)=>(ss(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var oc=(e,t,o)=>(ss(e,t,"access private method"),o);import{getAddress as ns}from"@ethersproject/address";import{StaticJsonRpcProvider as Qb,Web3Provider as Kl}from"@ethersproject/providers";import{createStore as Zb}from"mipd";import{useCallback as Xb,useEffect as Xt,useMemo as e2,useRef as ii,useState as ue}from"react";import{FetchError as Jf}from"ofetch";var Ne=class extends Error{constructor(o,r,n){super(o);r instanceof Error&&(this.cause=r),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Lt=class extends Ne{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},C=class extends Ne{constructor(o,r,n){super(o,r,n);this.type="client_error"}},di=class extends C{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var z=class extends Ne{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},ne=e=>{if(e instanceof Ne)return e;if(!(e instanceof Jf))return tt(e);if(!e.response)return new Lt("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new Lt(t||"ApiError",e.response.status,o||r,e,n)},tt=e=>e instanceof Ne?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var un=class extends C{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},et=class extends C{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},pi=class extends C{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var ui=()=>"/api/v1/sessions",mi=()=>"/api/v1/sessions/logout",rc=()=>"/api/v1/sessions/fork",fi=()=>"/api/v1/sessions/fork/recover",nc=()=>"/api/v1/siwe/init",ic=()=>"/api/v1/siwe/authenticate",ac=()=>"/api/v1/siwe/link",sc=()=>"/api/v1/passwordless/init",lc=()=>"/api/v1/passwordless/authenticate",cc=()=>"/api/v1/passwordless/link",dc=()=>"/api/v1/passwordless_sms/init",pc=()=>"/api/v1/passwordless_sms/authenticate",uc=()=>"/api/v1/passwordless_sms/link",mc=()=>"/api/v1/oauth/init",fc=()=>"/api/v1/oauth/authenticate",hc=()=>"/api/v1/oauth/link",yc=()=>"/api/v1/siwe/unlink",gc=()=>"/api/v1/passwordless/unlink",vc=()=>"/api/v1/passwordless_sms/unlink",wc=()=>"/api/v1/oauth/unlink",Cc=()=>"/api/v1/analytics_events",bc=()=>"/api/v1/plugins/moonpay_on_ramp/sign",Ec=()=>"/api/v1/custom_jwt_account/authenticate",Pc=()=>"/api/v1/mfa/passwordless_sms/init";var Tc=()=>"/api/v1/mfa/passwordless_sms/enroll";var vr=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=Ec(),o=await this.api.post(t,{token:this.meta.token});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ne(t)}}async link(){throw new Error("Unimplemented")}};var Ko=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=lc(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=cc();return await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ne(t)}}async sendCodeEmail(t,o){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{let r=sc();return await this.api.post(r,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw ne(r)}}};import{base64url as Fc}from"jose";var xc="1.54.
|
|
1
|
+
var ss=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var tc=(e,t,o)=>(ss(e,t,"read from private field"),o?o.call(e):t.get(e)),ci=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},ls=(e,t,o,r)=>(ss(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var oc=(e,t,o)=>(ss(e,t,"access private method"),o);import{getAddress as ns}from"@ethersproject/address";import{StaticJsonRpcProvider as Qb,Web3Provider as Kl}from"@ethersproject/providers";import{createStore as Zb}from"mipd";import{useCallback as Xb,useEffect as Xt,useMemo as e2,useRef as ii,useState as ue}from"react";import{FetchError as Jf}from"ofetch";var Ne=class extends Error{constructor(o,r,n){super(o);r instanceof Error&&(this.cause=r),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Lt=class extends Ne{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},C=class extends Ne{constructor(o,r,n){super(o,r,n);this.type="client_error"}},di=class extends C{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var z=class extends Ne{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},ne=e=>{if(e instanceof Ne)return e;if(!(e instanceof Jf))return tt(e);if(!e.response)return new Lt("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new Lt(t||"ApiError",e.response.status,o||r,e,n)},tt=e=>e instanceof Ne?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var un=class extends C{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},et=class extends C{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},pi=class extends C{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var ui=()=>"/api/v1/sessions",mi=()=>"/api/v1/sessions/logout",rc=()=>"/api/v1/sessions/fork",fi=()=>"/api/v1/sessions/fork/recover",nc=()=>"/api/v1/siwe/init",ic=()=>"/api/v1/siwe/authenticate",ac=()=>"/api/v1/siwe/link",sc=()=>"/api/v1/passwordless/init",lc=()=>"/api/v1/passwordless/authenticate",cc=()=>"/api/v1/passwordless/link",dc=()=>"/api/v1/passwordless_sms/init",pc=()=>"/api/v1/passwordless_sms/authenticate",uc=()=>"/api/v1/passwordless_sms/link",mc=()=>"/api/v1/oauth/init",fc=()=>"/api/v1/oauth/authenticate",hc=()=>"/api/v1/oauth/link",yc=()=>"/api/v1/siwe/unlink",gc=()=>"/api/v1/passwordless/unlink",vc=()=>"/api/v1/passwordless_sms/unlink",wc=()=>"/api/v1/oauth/unlink",Cc=()=>"/api/v1/analytics_events",bc=()=>"/api/v1/plugins/moonpay_on_ramp/sign",Ec=()=>"/api/v1/custom_jwt_account/authenticate",Pc=()=>"/api/v1/mfa/passwordless_sms/init";var Tc=()=>"/api/v1/mfa/passwordless_sms/enroll";var vr=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=Ec(),o=await this.api.post(t,{token:this.meta.token});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ne(t)}}async link(){throw new Error("Unimplemented")}};var Ko=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=lc(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=cc();return await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ne(t)}}async sendCodeEmail(t,o){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{let r=sc();return await this.api.post(r,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw ne(r)}}};import{base64url as Fc}from"jose";var xc="1.54.3";var hi="4df5e2316331463a9130964bd6078dfa",Sc="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",_c="34357d3c125c2bcf2ce2bc3309d98715",yi="https://auth.privy.io",kc=2e4,ot=1400,Ac=2500,cs=xc;var Yo="privy:token",ds="privy-token",gi="privy:refresh_token",ps="privy-refresh-token",vi="privy-session",mn="privy:session_transfer_token",Zf="privy:wallet",fn="privy:caid",wr="privy:state_code",Cr="privy:code_verifier",wi=e=>`${Zf}:${e}`,us="privy:connectors",ms="privy:connections";var Jo=12e4,to=1,fs="0x1",br=3e4,Rc="https://api.moonpay.com/v1",Ic="https://api.moonpay.com/v1",Wc="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Mc="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",Lc="0x420000000000000000000000000000000000000F",Nc=["function getL1Fee(bytes memory _data) external view returns (uint256)"];async function Oc(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(o)}function Dc(e){return crypto.getRandomValues(new Uint8Array(e))}var Ci=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},hs=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}},ys=class{get(t){let o=sessionStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?sessionStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){sessionStorage.removeItem(t)}getKeys(){return Object.entries(sessionStorage).map(([t])=>t)}};function Uc(){try{let e="privy:__session_storage__test",t="blobby";return window.sessionStorage.setItem(e,t),window.sessionStorage.removeItem(e),!0}catch{return!1}}function Xf(){return typeof window<"u"&&window.localStorage?new hs:new Ci}function eh(){return typeof window<"u"&&window.sessionStorage?new ys:new Ci}var bt=eh(),ee=Xf();var th="S256",oh="S256",To=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=bt.get(Cr);if(!t)throw new C("Authentication error.");try{let o=fc(),r=await this.api.post(o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return bt.del(Cr),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(o){let r=ne(o);throw r.privyErrorCode?new C(r.message||"Invalid code during OAuth flow.",void 0,r.privyErrorCode):r.message==="User denied confirmation during OAuth flow"?new C("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new C("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=bt.get(Cr);if(!t)throw new C("Authentication error.");try{let o=hc(),r=await this.api.post(o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return bt.del(Cr),r}catch(o){throw ne(o)}}createCodeVerifier(){return Fc.encode(Dc(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,o=th){if(o==oh){let r=await Oc(t);return Fc.encode(r)}else return t}async getAuthorizationUrl(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.provider)throw new C("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();bt.put(Cr,t);let o=this.createStateCode();bt.put(wr,o);let r=await this.deriveCodeChallengeFromCodeVerifier(t);try{let n=mc();return await this.api.post(n,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:o})}catch(n){throw ne(n)}}};var pt=class{constructor(t){this.promise=null;this.fn=t}execute(t){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(t)}finally{this.promise=null}})()),this.promise}};var Qo=class{constructor(t,o){this.createSiweMessage=(t,o,r,n,i,a,l)=>`${r} wants you to sign in with your Ethereum account:
|
|
2
2
|
${o}
|
|
3
3
|
|
|
4
4
|
${l}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var oy=Object.create;var Qi=Object.defineProperty;var ry=Object.getOwnPropertyDescriptor;var ny=Object.getOwnPropertyNames;var iy=Object.getPrototypeOf,ay=Object.prototype.hasOwnProperty;var sy=(e,t)=>{for(var o in t)Qi(e,o,{get:t[o],enumerable:!0})},Dc=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ny(t))!ay.call(e,n)&&n!==o&&Qi(e,n,{get:()=>t[n],enumerable:!(r=ry(t,n))||r.enumerable});return e};var _=(e,t,o)=>(o=e!=null?oy(iy(e)):{},Dc(t||!e||!e.__esModule?Qi(o,"default",{value:e,enumerable:!0}):o,e)),ly=e=>Dc(Qi({},"__esModule",{value:!0}),e);var sl=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var Uc=(e,t,o)=>(sl(e,t,"read from private field"),o?o.call(e):t.get(e)),Zi=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},ll=(e,t,o,r)=>(sl(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var Fc=(e,t,o)=>(sl(e,t,"access private method"),o);var ww={};sy(ww,{AsExternalProvider:()=>Zt,Captcha:()=>Aa,ConnectorManager:()=>En,PrivyClient:()=>Pn,PrivyProvider:()=>Oh,PrivyProxyProvider:()=>ve,SUPPORTED_CHAINS:()=>li,VERSION:()=>aa,WalletConnector:()=>ct,errorIndicatesMaxMfaRetries:()=>Ja,errorIndicatesMfaTimeout:()=>zr,errorIndicatesMfaVerificationFailed:()=>Vr,getAccessToken:()=>Ye,useConnectWallet:()=>Vh,useCreateWallet:()=>qh,useLogin:()=>Uh,useLoginWithEmail:()=>Hh,useLoginWithSms:()=>Gh,useLogout:()=>Bh,useMfa:()=>Zr,useMfaEnrollment:()=>Zn,useModalStatus:()=>Kh,usePrivy:()=>H,useRegisterMfaListener:()=>Ma,useToken:()=>Jh,useWallets:()=>ii});module.exports=ly(ww);var ji=require("@ethersproject/address"),ci=require("@ethersproject/providers"),Wh=require("mipd"),V=require("react");var Bc=require("ofetch"),tt=class extends Error{constructor(o,r,n){super(o);r instanceof Error&&(this.cause=r),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},co=class extends tt{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},C=class extends tt{constructor(o,r,n){super(o,r,n);this.type="client_error"}},Xi=class extends C{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var q=class extends tt{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},ge=e=>{if(e instanceof tt)return e;if(!(e instanceof Bc.FetchError))return Pt(e);if(!e.response)return new co("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new co(t||"ApiError",e.response.status,o||r,e,n)},Pt=e=>e instanceof tt?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var mi=class extends C{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Et=class extends C{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},ea=class extends C{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var ta=()=>"/api/v1/sessions",oa=()=>"/api/v1/sessions/logout",Hc=()=>"/api/v1/sessions/fork",ra=()=>"/api/v1/sessions/fork/recover",Gc=()=>"/api/v1/siwe/init",zc=()=>"/api/v1/siwe/authenticate",Vc=()=>"/api/v1/siwe/link",$c=()=>"/api/v1/passwordless/init",qc=()=>"/api/v1/passwordless/authenticate",jc=()=>"/api/v1/passwordless/link",Kc=()=>"/api/v1/passwordless_sms/init",Yc=()=>"/api/v1/passwordless_sms/authenticate",Jc=()=>"/api/v1/passwordless_sms/link",Qc=()=>"/api/v1/oauth/init",Zc=()=>"/api/v1/oauth/authenticate",Xc=()=>"/api/v1/oauth/link",ed=()=>"/api/v1/siwe/unlink",td=()=>"/api/v1/passwordless/unlink",od=()=>"/api/v1/passwordless_sms/unlink",rd=()=>"/api/v1/oauth/unlink",nd=()=>"/api/v1/analytics_events",id=()=>"/api/v1/plugins/moonpay_on_ramp/sign",ad=()=>"/api/v1/custom_jwt_account/authenticate",sd=()=>"/api/v1/mfa/passwordless_sms/init";var ld=()=>"/api/v1/mfa/passwordless_sms/enroll";var sn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=ad(),o=await this.api.post(t,{token:this.meta.token});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ge(t)}}async link(){throw new Error("Unimplemented")}};var Nr=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=qc(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ge(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=jc();return await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ge(t)}}async sendCodeEmail(t,o){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{let r=$c();return await this.api.post(r,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw ge(r)}}};var yl=require("jose");var cd="1.54.2";var na="4df5e2316331463a9130964bd6078dfa",dd="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",pd="34357d3c125c2bcf2ce2bc3309d98715",ia="https://auth.privy.io",ud=2e4,Tt=1400,md=2500,aa=cd;var Or="privy:token",cl="privy-token",sa="privy:refresh_token",dl="privy-refresh-token",la="privy-session",fi="privy:session_transfer_token",dy="privy:wallet",hi="privy:caid",ln="privy:state_code",cn="privy:code_verifier",ca=e=>`${dy}:${e}`,pl="privy:connectors",ul="privy:connections";var Dr=12e4,Fo=1,ml="0x1",dn=3e4,fd="https://api.moonpay.com/v1",hd="https://api.moonpay.com/v1",yd="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",gd="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",vd="0x420000000000000000000000000000000000000F",wd=["function getL1Fee(bytes memory _data) external view returns (uint256)"];async function Cd(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(o)}function bd(e){return crypto.getRandomValues(new Uint8Array(e))}var da=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},fl=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}},hl=class{get(t){let o=sessionStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?sessionStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){sessionStorage.removeItem(t)}getKeys(){return Object.entries(sessionStorage).map(([t])=>t)}};function Ed(){try{let e="privy:__session_storage__test",t="blobby";return window.sessionStorage.setItem(e,t),window.sessionStorage.removeItem(e),!0}catch{return!1}}function py(){return typeof window<"u"&&window.localStorage?new fl:new da}function uy(){return typeof window<"u"&&window.sessionStorage?new hl:new da}var Kt=uy(),ae=py();var my="S256",fy="S256",cr=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=Kt.get(cn);if(!t)throw new C("Authentication error.");try{let o=Zc(),r=await this.api.post(o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Kt.del(cn),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(o){let r=ge(o);throw r.privyErrorCode?new C(r.message||"Invalid code during OAuth flow.",void 0,r.privyErrorCode):r.message==="User denied confirmation during OAuth flow"?new C("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new C("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=Kt.get(cn);if(!t)throw new C("Authentication error.");try{let o=Xc(),r=await this.api.post(o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Kt.del(cn),r}catch(o){throw ge(o)}}createCodeVerifier(){return yl.base64url.encode(bd(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,o=my){if(o==fy){let r=await Cd(t);return yl.base64url.encode(r)}else return t}async getAuthorizationUrl(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.provider)throw new C("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();Kt.put(cn,t);let o=this.createStateCode();Kt.put(ln,o);let r=await this.deriveCodeChallengeFromCodeVerifier(t);try{let n=Qc();return await this.api.post(n,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:o})}catch(n){throw ge(n)}}};var Nt=class{constructor(t){this.promise=null;this.fn=t}execute(t){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(t)}finally{this.promise=null}})()),this.promise}};var Ur=class{constructor(t,o){this.createSiweMessage=(t,o,r,n,i,a,l)=>`${r} wants you to sign in with your Ethereum account:
|
|
1
|
+
"use strict";var oy=Object.create;var Qi=Object.defineProperty;var ry=Object.getOwnPropertyDescriptor;var ny=Object.getOwnPropertyNames;var iy=Object.getPrototypeOf,ay=Object.prototype.hasOwnProperty;var sy=(e,t)=>{for(var o in t)Qi(e,o,{get:t[o],enumerable:!0})},Dc=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ny(t))!ay.call(e,n)&&n!==o&&Qi(e,n,{get:()=>t[n],enumerable:!(r=ry(t,n))||r.enumerable});return e};var _=(e,t,o)=>(o=e!=null?oy(iy(e)):{},Dc(t||!e||!e.__esModule?Qi(o,"default",{value:e,enumerable:!0}):o,e)),ly=e=>Dc(Qi({},"__esModule",{value:!0}),e);var sl=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var Uc=(e,t,o)=>(sl(e,t,"read from private field"),o?o.call(e):t.get(e)),Zi=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)},ll=(e,t,o,r)=>(sl(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var Fc=(e,t,o)=>(sl(e,t,"access private method"),o);var ww={};sy(ww,{AsExternalProvider:()=>Zt,Captcha:()=>Aa,ConnectorManager:()=>En,PrivyClient:()=>Pn,PrivyProvider:()=>Oh,PrivyProxyProvider:()=>ve,SUPPORTED_CHAINS:()=>li,VERSION:()=>aa,WalletConnector:()=>ct,errorIndicatesMaxMfaRetries:()=>Ja,errorIndicatesMfaTimeout:()=>zr,errorIndicatesMfaVerificationFailed:()=>Vr,getAccessToken:()=>Ye,useConnectWallet:()=>Vh,useCreateWallet:()=>qh,useLogin:()=>Uh,useLoginWithEmail:()=>Hh,useLoginWithSms:()=>Gh,useLogout:()=>Bh,useMfa:()=>Zr,useMfaEnrollment:()=>Zn,useModalStatus:()=>Kh,usePrivy:()=>H,useRegisterMfaListener:()=>Ma,useToken:()=>Jh,useWallets:()=>ii});module.exports=ly(ww);var ji=require("@ethersproject/address"),ci=require("@ethersproject/providers"),Wh=require("mipd"),V=require("react");var Bc=require("ofetch"),tt=class extends Error{constructor(o,r,n){super(o);r instanceof Error&&(this.cause=r),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},co=class extends tt{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},C=class extends tt{constructor(o,r,n){super(o,r,n);this.type="client_error"}},Xi=class extends C{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var q=class extends tt{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},ge=e=>{if(e instanceof tt)return e;if(!(e instanceof Bc.FetchError))return Pt(e);if(!e.response)return new co("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new co(t||"ApiError",e.response.status,o||r,e,n)},Pt=e=>e instanceof tt?e:e instanceof Error?new C(e.message,e):new C(`Internal error: ${e}`);var mi=class extends C{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Et=class extends C{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},ea=class extends C{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var ta=()=>"/api/v1/sessions",oa=()=>"/api/v1/sessions/logout",Hc=()=>"/api/v1/sessions/fork",ra=()=>"/api/v1/sessions/fork/recover",Gc=()=>"/api/v1/siwe/init",zc=()=>"/api/v1/siwe/authenticate",Vc=()=>"/api/v1/siwe/link",$c=()=>"/api/v1/passwordless/init",qc=()=>"/api/v1/passwordless/authenticate",jc=()=>"/api/v1/passwordless/link",Kc=()=>"/api/v1/passwordless_sms/init",Yc=()=>"/api/v1/passwordless_sms/authenticate",Jc=()=>"/api/v1/passwordless_sms/link",Qc=()=>"/api/v1/oauth/init",Zc=()=>"/api/v1/oauth/authenticate",Xc=()=>"/api/v1/oauth/link",ed=()=>"/api/v1/siwe/unlink",td=()=>"/api/v1/passwordless/unlink",od=()=>"/api/v1/passwordless_sms/unlink",rd=()=>"/api/v1/oauth/unlink",nd=()=>"/api/v1/analytics_events",id=()=>"/api/v1/plugins/moonpay_on_ramp/sign",ad=()=>"/api/v1/custom_jwt_account/authenticate",sd=()=>"/api/v1/mfa/passwordless_sms/init";var ld=()=>"/api/v1/mfa/passwordless_sms/enroll";var sn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");try{let t=ad(),o=await this.api.post(t,{token:this.meta.token});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ge(t)}}async link(){throw new Error("Unimplemented")}};var Nr=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=qc(),o=await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(t){throw ge(t)}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new C("Email and email code must be set prior to calling authenticate.");try{let t=jc();return await this.api.post(t,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ge(t)}}async sendCodeEmail(t,o){if(!this.api)throw new C("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new C("Email must be set when initialzing authentication.");try{let r=$c();return await this.api.post(r,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw ge(r)}}};var yl=require("jose");var cd="1.54.3";var na="4df5e2316331463a9130964bd6078dfa",dd="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",pd="34357d3c125c2bcf2ce2bc3309d98715",ia="https://auth.privy.io",ud=2e4,Tt=1400,md=2500,aa=cd;var Or="privy:token",cl="privy-token",sa="privy:refresh_token",dl="privy-refresh-token",la="privy-session",fi="privy:session_transfer_token",dy="privy:wallet",hi="privy:caid",ln="privy:state_code",cn="privy:code_verifier",ca=e=>`${dy}:${e}`,pl="privy:connectors",ul="privy:connections";var Dr=12e4,Fo=1,ml="0x1",dn=3e4,fd="https://api.moonpay.com/v1",hd="https://api.moonpay.com/v1",yd="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",gd="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",vd="0x420000000000000000000000000000000000000F",wd=["function getL1Fee(bytes memory _data) external view returns (uint256)"];async function Cd(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(o)}function bd(e){return crypto.getRandomValues(new Uint8Array(e))}var da=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,o){o!==void 0?this._cache[t]=o:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},fl=class{get(t){let o=localStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?localStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}},hl=class{get(t){let o=sessionStorage.getItem(t);return o===null?void 0:JSON.parse(o)}put(t,o){o!==void 0?sessionStorage.setItem(t,JSON.stringify(o)):this.del(t)}del(t){sessionStorage.removeItem(t)}getKeys(){return Object.entries(sessionStorage).map(([t])=>t)}};function Ed(){try{let e="privy:__session_storage__test",t="blobby";return window.sessionStorage.setItem(e,t),window.sessionStorage.removeItem(e),!0}catch{return!1}}function py(){return typeof window<"u"&&window.localStorage?new fl:new da}function uy(){return typeof window<"u"&&window.sessionStorage?new hl:new da}var Kt=uy(),ae=py();var my="S256",fy="S256",cr=class{constructor(t,o,r){this.meta={provider:t},this.meta.authorizationCode=o,this.meta.stateCode=r}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=Kt.get(cn);if(!t)throw new C("Authentication error.");try{let o=Zc(),r=await this.api.post(o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Kt.del(cn),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user}}catch(o){let r=ge(o);throw r.privyErrorCode?new C(r.message||"Invalid code during OAuth flow.",void 0,r.privyErrorCode):r.message==="User denied confirmation during OAuth flow"?new C("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new C("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new C("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new C("User denied confirmation during OAuth flow");let t=Kt.get(cn);if(!t)throw new C("Authentication error.");try{let o=Xc(),r=await this.api.post(o,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Kt.del(cn),r}catch(o){throw ge(o)}}createCodeVerifier(){return yl.base64url.encode(bd(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,o=my){if(o==fy){let r=await Cd(t);return yl.base64url.encode(r)}else return t}async getAuthorizationUrl(){if(!this.api)throw new C("Auth flow has no API instance");if(!this.meta.provider)throw new C("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();Kt.put(cn,t);let o=this.createStateCode();Kt.put(ln,o);let r=await this.deriveCodeChallengeFromCodeVerifier(t);try{let n=Qc();return await this.api.post(n,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:o})}catch(n){throw ge(n)}}};var Nt=class{constructor(t){this.promise=null;this.fn=t}execute(t){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(t)}finally{this.promise=null}})()),this.promise}};var Ur=class{constructor(t,o){this.createSiweMessage=(t,o,r,n,i,a,l)=>`${r} wants you to sign in with your Ethereum account:
|
|
2
2
|
${o}
|
|
3
3
|
|
|
4
4
|
${l}
|
package/package.json
CHANGED