@privy-io/react-auth 1.59.1 → 1.59.2-beta-20240307215727
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 +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var $s=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var qc=(e,t,o)=>($s(e,t,"read from private field"),o?o.call(e):t.get(e)),Wi=(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)},qs=(e,t,o,r)=>($s(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var jc=(e,t,o)=>($s(e,t,"access private method"),o);import{getAddress as Vs}from"@ethersproject/address";import{StaticJsonRpcProvider as u4,Web3Provider as Hc}from"@ethersproject/providers";import{createStore as m4}from"mipd";import{useCallback as f4,useEffect as Ao,useMemo as h4,useRef as In,useState as ke}from"react";import{FetchError as Iy}from"ofetch";var Ge=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}]`:""}`}},Qt=class extends Ge{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},P=class extends Ge{constructor(o,r,n){super(o,r,n);this.type="client_error"}},Li=class extends P{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var J=class extends Ge{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},ae=e=>{if(e instanceof Ge)return e;if(!(e instanceof Iy))return Qe(e);if(!e.response)return new Qt("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new Qt(t||"ApiError",e.response.status,o||r,e,n)},Qe=e=>e instanceof Ge?e:e instanceof Error?new P(e.message,e):new P(`Internal error: ${e}`);var Ir=class extends P{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},mt=class extends P{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},Oi=class extends P{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Ni="/api/v1/sessions",Di="/api/v1/sessions/logout",Kc="/api/v1/sessions/fork",Ui="/api/v1/sessions/fork/recover",Yc="/api/v1/siwe/init",Jc="/api/v1/siwe/authenticate",Zc="/api/v1/siwe/link",Qc="/api/v1/siwe/unlink",Xc="/api/v1/farcaster/init",ed="/api/v1/farcaster/authenticate",td="/api/v1/farcaster/link",od="/api/v1/farcaster/status",rd="/api/v1/farcaster/unlink",nd="/api/v1/passwordless/init",id="/api/v1/passwordless/authenticate",ad="/api/v1/passwordless/link",sd="/api/v1/passwordless/unlink",ld="/api/v1/passwordless/update",cd="/api/v1/passwordless_sms/init",dd="/api/v1/passwordless_sms/link",pd="/api/v1/passwordless_sms/unlink",ud="/api/v1/passwordless_sms/authenticate",md="/api/v1/oauth/init",fd="/api/v1/oauth/authenticate",hd="/api/v1/oauth/link",yd="/api/v1/oauth/unlink";var gd="/api/v1/mfa/passwordless_sms/init",vd="/api/v1/mfa/passwordless_sms/enroll";var wd="/api/v1/users/me/accept_terms",Cd="/api/v1/analytics_events",bd="/api/v1/plugins/moonpay_on_ramp/sign",Ed="/api/v1/custom_jwt_account/authenticate";var Mr=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let t=await this.api.post(Ed,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ae(t)}}async link(){throw new Error("Unimplemented")}};var Mo=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(id,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(ad,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ae(t)}}async sendCodeEmail(t,o){if(!this.api)throw new P("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new P("Email must be set when initialzing authentication.");try{return await this.api.post(nd,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw ae(r)}}},Fi=class extends Mo{constructor(o,r,n){super(r,n);this.meta={email:r,captchaToken:n,oldAddress:o}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new P("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(ld,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(o){throw ae(o)}}};import{isMobile as My}from"react-device-detect";var Xe=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 On=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Xe(this._startChannelOnce.bind(this)),this.pollForReady=new Xe(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");try{let t=await this.api.post(ed,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new P("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{return await this.api.post(td,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw ae(t)}}async _startChannelOnce(){if(!this.api)throw new P("Auth flow has no API instance");let t=await this.api.post(Xc,{token:this.captchaToken});My&&t.connect_uri&&window.open(t.connect_uri,"_blank","noopener noreferrer"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new P("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");let t=await this.api.get(od,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};import{base64url as Nd}from"jose";var Pd="1.59.1";var Bi="4df5e2316331463a9130964bd6078dfa",Td="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",xd="34357d3c125c2bcf2ce2bc3309d98715",Hi="https://auth.privy.io",Sd=2e4,et=1400,_d=2500,js=Pd;var ar="privy:token",Ks="privy-token",Gi="privy:refresh_token",Ys="privy-refresh-token",Vi="privy-session",Nn="privy:session_transfer_token",Ly="privy:wallet",Dn="privy:caid",sr="privy:state_code",Wr="privy:code_verifier",Un="privy:headless_oauth",zi=e=>`${Ly}:${e}`,Js="privy:connectors",Zs="privy:connections";var lr=12e4,wo=1,Qs="0x1",Lr=3e4,Ad="https://api.moonpay.com/v1",kd="https://api.moonpay.com/v1",Rd="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Id="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",Md="0x420000000000000000000000000000000000000F",Wd=["function getL1Fee(bytes memory _data) external view returns (uint256)"];async function Ld(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(o)}function Od(e){return crypto.getRandomValues(new Uint8Array(e))}var $i=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)}},Xs=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)}},el=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 tl(){try{let e="privy:__session_storage__test",t="blobby";return window.sessionStorage.setItem(e,t),window.sessionStorage.removeItem(e),!0}catch{return!1}}function Oy(){return typeof window<"u"&&window.localStorage?new Xs:new $i}function Ny(){return typeof window<"u"&&window.sessionStorage?new el:new $i}var Ve=Ny(),se=Oy();function qi(){return!!Ve.get(Un)}var Dy="S256",Uy="S256",Xt=class{constructor(t){let o=typeof t.headless=="boolean"?t.headless:qi();this.meta={...t,headless:o}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Ve.get(Wr);if(!t)throw new P("Authentication error.");try{let o=await this.api.post(fd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Ve.del(Wr),this.meta.headless&&Ve.del(Un),{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(o){let r=ae(o);throw r.privyErrorCode?new P(r.message||"Invalid code during OAuth flow.",void 0,r.privyErrorCode):r.message==="User denied confirmation during OAuth flow"?new P("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new P("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Ve.get(Wr);if(!t)throw new P("Authentication error.");try{let o=await this.api.post(hd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Ve.del(Wr),o}catch(o){throw ae(o)}}createCodeVerifier(){return Nd.encode(Od(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,o=Dy){if(o==Uy){let r=await Ld(t);return Nd.encode(r)}else return t}async getAuthorizationUrl(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.provider)throw new P("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();Ve.put(Wr,t);let o=this.createStateCode();Ve.put(sr,o);let r=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&Ve.put(Un,!0);try{return await this.api.post(md,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:o})}catch(n){throw ae(n)}}};function ol(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Dd(e,t){let o={detail:"",retryable:!1},r=ol(t);return e?.privyErrorCode==="linked_to_another_user"&&(o.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(o.retryable=!0,o.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(o.detail=`Retry and check ${r} to finish connecting your account.`,o.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(o.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="oauth_account_suspended"&&(o.detail=`Your ${r} account is suspended. Please try another login method.`),o}function Bn(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),o=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");return!t||!o||!r?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:o,provider:r,headless:qi()}}function Hn(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Ve.del(sr),window.history.pushState({},"",e)}var cr=class{constructor(t,o){this.createSiweMessage=(t,o,r,n,i,a,l)=>`${r} wants you to sign in with your Ethereum account:
|
|
1
|
+
var $s=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var qc=(e,t,o)=>($s(e,t,"read from private field"),o?o.call(e):t.get(e)),Wi=(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)},qs=(e,t,o,r)=>($s(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var jc=(e,t,o)=>($s(e,t,"access private method"),o);import{getAddress as Vs}from"@ethersproject/address";import{StaticJsonRpcProvider as u4,Web3Provider as Hc}from"@ethersproject/providers";import{createStore as m4}from"mipd";import{useCallback as f4,useEffect as Ao,useMemo as h4,useRef as In,useState as ke}from"react";import{FetchError as Iy}from"ofetch";var Ge=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}]`:""}`}},Qt=class extends Ge{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},P=class extends Ge{constructor(o,r,n){super(o,r,n);this.type="client_error"}},Li=class extends P{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var J=class extends Ge{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},ae=e=>{if(e instanceof Ge)return e;if(!(e instanceof Iy))return Qe(e);if(!e.response)return new Qt("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new Qt(t||"ApiError",e.response.status,o||r,e,n)},Qe=e=>e instanceof Ge?e:e instanceof Error?new P(e.message,e):new P(`Internal error: ${e}`);var Ir=class extends P{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},mt=class extends P{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},Oi=class extends P{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Ni="/api/v1/sessions",Di="/api/v1/sessions/logout",Kc="/api/v1/sessions/fork",Ui="/api/v1/sessions/fork/recover",Yc="/api/v1/siwe/init",Jc="/api/v1/siwe/authenticate",Zc="/api/v1/siwe/link",Qc="/api/v1/siwe/unlink",Xc="/api/v1/farcaster/init",ed="/api/v1/farcaster/authenticate",td="/api/v1/farcaster/link",od="/api/v1/farcaster/status",rd="/api/v1/farcaster/unlink",nd="/api/v1/passwordless/init",id="/api/v1/passwordless/authenticate",ad="/api/v1/passwordless/link",sd="/api/v1/passwordless/unlink",ld="/api/v1/passwordless/update",cd="/api/v1/passwordless_sms/init",dd="/api/v1/passwordless_sms/link",pd="/api/v1/passwordless_sms/unlink",ud="/api/v1/passwordless_sms/authenticate",md="/api/v1/oauth/init",fd="/api/v1/oauth/authenticate",hd="/api/v1/oauth/link",yd="/api/v1/oauth/unlink";var gd="/api/v1/mfa/passwordless_sms/init",vd="/api/v1/mfa/passwordless_sms/enroll";var wd="/api/v1/users/me/accept_terms",Cd="/api/v1/analytics_events",bd="/api/v1/plugins/moonpay_on_ramp/sign",Ed="/api/v1/custom_jwt_account/authenticate";var Mr=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let t=await this.api.post(Ed,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ae(t)}}async link(){throw new Error("Unimplemented")}};var Mo=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(id,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(ad,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ae(t)}}async sendCodeEmail(t,o){if(!this.api)throw new P("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new P("Email must be set when initialzing authentication.");try{return await this.api.post(nd,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw ae(r)}}},Fi=class extends Mo{constructor(o,r,n){super(r,n);this.meta={email:r,captchaToken:n,oldAddress:o}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new P("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(ld,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(o){throw ae(o)}}};import{isMobile as My}from"react-device-detect";var Xe=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 On=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Xe(this._startChannelOnce.bind(this)),this.pollForReady=new Xe(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");try{let t=await this.api.post(ed,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new P("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ae(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{return await this.api.post(td,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw ae(t)}}async _startChannelOnce(){if(!this.api)throw new P("Auth flow has no API instance");let t=await this.api.post(Xc,{token:this.captchaToken});My&&t.connect_uri&&window.open(t.connect_uri,"_blank","noopener noreferrer"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new P("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");let t=await this.api.get(od,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};import{base64url as Nd}from"jose";var Pd="1.59.2-beta-20240307215727";var Bi="4df5e2316331463a9130964bd6078dfa",Td="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",xd="34357d3c125c2bcf2ce2bc3309d98715",Hi="https://auth.privy.io",Sd=2e4,et=1400,_d=2500,js=Pd;var ar="privy:token",Ks="privy-token",Gi="privy:refresh_token",Ys="privy-refresh-token",Vi="privy-session",Nn="privy:session_transfer_token",Ly="privy:wallet",Dn="privy:caid",sr="privy:state_code",Wr="privy:code_verifier",Un="privy:headless_oauth",zi=e=>`${Ly}:${e}`,Js="privy:connectors",Zs="privy:connections";var lr=12e4,wo=1,Qs="0x1",Lr=3e4,Ad="https://api.moonpay.com/v1",kd="https://api.moonpay.com/v1",Rd="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Id="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",Md="0x420000000000000000000000000000000000000F",Wd=["function getL1Fee(bytes memory _data) external view returns (uint256)"];async function Ld(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(o)}function Od(e){return crypto.getRandomValues(new Uint8Array(e))}var $i=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)}},Xs=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)}},el=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 tl(){try{let e="privy:__session_storage__test",t="blobby";return window.sessionStorage.setItem(e,t),window.sessionStorage.removeItem(e),!0}catch{return!1}}function Oy(){return typeof window<"u"&&window.localStorage?new Xs:new $i}function Ny(){return typeof window<"u"&&window.sessionStorage?new el:new $i}var Ve=Ny(),se=Oy();function qi(){return!!Ve.get(Un)}var Dy="S256",Uy="S256",Xt=class{constructor(t){let o=typeof t.headless=="boolean"?t.headless:qi();this.meta={...t,headless:o}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Ve.get(Wr);if(!t)throw new P("Authentication error.");try{let o=await this.api.post(fd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Ve.del(Wr),this.meta.headless&&Ve.del(Un),{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(o){let r=ae(o);throw r.privyErrorCode?new P(r.message||"Invalid code during OAuth flow.",void 0,r.privyErrorCode):r.message==="User denied confirmation during OAuth flow"?new P("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new P("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Ve.get(Wr);if(!t)throw new P("Authentication error.");try{let o=await this.api.post(hd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Ve.del(Wr),o}catch(o){throw ae(o)}}createCodeVerifier(){return Nd.encode(Od(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,o=Dy){if(o==Uy){let r=await Ld(t);return Nd.encode(r)}else return t}async getAuthorizationUrl(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.provider)throw new P("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();Ve.put(Wr,t);let o=this.createStateCode();Ve.put(sr,o);let r=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&Ve.put(Un,!0);try{return await this.api.post(md,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:o})}catch(n){throw ae(n)}}};function ol(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Dd(e,t){let o={detail:"",retryable:!1},r=ol(t);return e?.privyErrorCode==="linked_to_another_user"&&(o.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(o.retryable=!0,o.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(o.detail=`Retry and check ${r} to finish connecting your account.`,o.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(o.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="oauth_account_suspended"&&(o.detail=`Your ${r} account is suspended. Please try another login method.`),o}function Bn(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),o=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");return!t||!o||!r?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:o,provider:r,headless:qi()}}function Hn(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Ve.del(sr),window.history.pushState({},"",e)}var cr=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}
|
|
@@ -1595,7 +1595,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
1595
1595
|
margin-bottom: auto;
|
|
1596
1596
|
}
|
|
1597
1597
|
}
|
|
1598
|
-
`;import{Fragment as w0,jsx as Le,jsxs as ui}from"react/jsx-runtime";var g0=()=>
|
|
1598
|
+
`;import{Fragment as w0,jsx as Le,jsxs as ui}from"react/jsx-runtime";var g0=()=>ui(v0,{children:[Le(Jn,{title:"Create a Phantom wallet",description:"Follow the instructions below to get started."}),Le(Rt,{children:Le(oo,{style:{width:"152px",height:"152px"}})}),ui(rf,{children:[Le(is,{children:ui("div",{children:[Le("span",{children:"Install the "}),Le("a",{href:nf.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",target:"_blank",children:"Phantom browser extension"})]})}),Le(sc,{}),Le(is,{children:"Set up your first wallet"}),Le(sc,{}),Le(is,{children:"Store your recovery phrase in a safe place!"})]}),Le(ka,{onClick:()=>window.location.reload(),children:"Reload the page to use your wallet"})]}),af=()=>{let{navigateBack:e}=S();return ui(w0,{children:[Le(A,{backFn:e},"header"),Le(Z,{}),Le(g0,{}),Le(Q,{}),ui(te,{children:[Le("span",{children:"Still not sure? "}),Le("a",{target:"_blank",href:"https://ethereum.org/en/wallets/",children:"Learn more"})]})]})},v0=y0(Rt)`
|
|
1599
1599
|
gap: 30px;
|
|
1600
1600
|
|
|
1601
1601
|
> :first-child > svg {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var P1=Object.create;var Ca=Object.defineProperty;var T1=Object.getOwnPropertyDescriptor;var x1=Object.getOwnPropertyNames;var S1=Object.getPrototypeOf,_1=Object.prototype.hasOwnProperty;var A1=(e,t)=>{for(var o in t)Ca(e,o,{get:t[o],enumerable:!0})},_d=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x1(t))!_1.call(e,n)&&n!==o&&Ca(e,n,{get:()=>t[n],enumerable:!(r=T1(t,n))||r.enumerable});return e};var h=(e,t,o)=>(o=e!=null?P1(S1(e)):{},_d(t||!e||!e.__esModule?Ca(o,"default",{value:e,enumerable:!0}):o,e)),k1=e=>_d(Ca({},"__esModule",{value:!0}),e);var Dl=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var Ad=(e,t,o)=>(Dl(e,t,"read from private field"),o?o.call(e):t.get(e)),ba=(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)},Ul=(e,t,o,r)=>(Dl(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var kd=(e,t,o)=>(Dl(e,t,"access private method"),o);var q0={};A1(q0,{AsExternalProvider:()=>vo,Captcha:()=>vs,ConnectorManager:()=>Nn,PrivyClient:()=>Dn,PrivyProvider:()=>$g,PrivyProxyProvider:()=>ke,SUPPORTED_CHAINS:()=>Wn,VERSION:()=>Ra,WalletConnector:()=>Pt,addRpcUrlOverrideToChain:()=>v1,errorIndicatesMaxMfaRetries:()=>Bs,errorIndicatesMfaTimeout:()=>en,errorIndicatesMfaVerificationFailed:()=>tn,getAccessToken:()=>Ye,useConnectWallet:()=>o1,useCreateWallet:()=>n1,useFundWallet:()=>i1,useLinkAccount:()=>e1,useLogin:()=>jg,useLoginWithEmail:()=>Zg,useLoginWithOAuth:()=>Jg,useLoginWithSms:()=>Qg,useLogout:()=>Yg,useMfa:()=>dn,useMfaEnrollment:()=>fi,useModalStatus:()=>h1,usePrivy:()=>G,useRegisterMfaListener:()=>Es,useSendTransaction:()=>s1,useSetWalletPassword:()=>c1,useSignMessage:()=>p1,useSignTypedData:()=>m1,useToken:()=>g1,useWallets:()=>Ei});module.exports=k1(q0);var ga=require("@ethersproject/address"),Si=require("@ethersproject/providers"),Bg=require("mipd"),Q=require("react");var Rd=require("ofetch"),ct=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}]`:""}`}},No=class extends ct{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},T=class extends ct{constructor(o,r,n){super(o,r,n);this.type="client_error"}},Ea=class extends T{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var X=class extends ct{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},me=e=>{if(e instanceof ct)return e;if(!(e instanceof Rd.FetchError))return wt(e);if(!e.response)return new No("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new No(t||"ApiError",e.response.status,o||r,e,n)},wt=e=>e instanceof ct?e:e instanceof Error?new T(e.message,e):new T(`Internal error: ${e}`);var Cn=class extends T{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Ft=class extends T{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},Pa=class extends T{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Ta="/api/v1/sessions",xa="/api/v1/sessions/logout",Id="/api/v1/sessions/fork",Sa="/api/v1/sessions/fork/recover",Md="/api/v1/siwe/init",Wd="/api/v1/siwe/authenticate",Ld="/api/v1/siwe/link",Od="/api/v1/siwe/unlink",Nd="/api/v1/farcaster/init",Dd="/api/v1/farcaster/authenticate",Ud="/api/v1/farcaster/link",Fd="/api/v1/farcaster/status",Bd="/api/v1/farcaster/unlink",Hd="/api/v1/passwordless/init",Gd="/api/v1/passwordless/authenticate",Vd="/api/v1/passwordless/link",zd="/api/v1/passwordless/unlink",$d="/api/v1/passwordless/update",qd="/api/v1/passwordless_sms/init",jd="/api/v1/passwordless_sms/link",Kd="/api/v1/passwordless_sms/unlink",Yd="/api/v1/passwordless_sms/authenticate",Jd="/api/v1/oauth/init",Zd="/api/v1/oauth/authenticate",Qd="/api/v1/oauth/link",Xd="/api/v1/oauth/unlink";var ep="/api/v1/mfa/passwordless_sms/init",tp="/api/v1/mfa/passwordless_sms/enroll";var op="/api/v1/users/me/accept_terms",rp="/api/v1/analytics_events",np="/api/v1/plugins/moonpay_on_ramp/sign",ip="/api/v1/custom_jwt_account/authenticate";var bn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{let t=await this.api.post(ip,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw me(t)}}async link(){throw new Error("Unimplemented")}};var Cr=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Gd,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw me(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Vd,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw me(t)}}async sendCodeEmail(t,o){if(!this.api)throw new T("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new T("Email must be set when initialzing authentication.");try{return await this.api.post(Hd,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw me(r)}}},_a=class extends Cr{constructor(o,r,n){super(r,n);this.meta={email:r,captchaToken:n,oldAddress:o}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new T("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post($d,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(o){throw me(o)}}};var ap=require("react-device-detect");var Ct=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 ki=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Ct(this._startChannelOnce.bind(this)),this.pollForReady=new Ct(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");try{let t=await this.api.post(Dd,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new T("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw me(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(Ud,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw me(t)}}async _startChannelOnce(){if(!this.api)throw new T("Auth flow has no API instance");let t=await this.api.post(Nd,{token:this.captchaToken});ap.isMobile&&t.connect_uri&&window.open(t.connect_uri,"_blank","noopener noreferrer"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new T("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");let t=await this.api.get(Fd,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};var jl=require("jose");var sp="1.59.1";var Aa="4df5e2316331463a9130964bd6078dfa",lp="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",cp="34357d3c125c2bcf2ce2bc3309d98715",ka="https://auth.privy.io",dp=2e4,bt=1400,pp=2500,Ra=sp;var $r="privy:token",Fl="privy-token",Ia="privy:refresh_token",Bl="privy-refresh-token",Ma="privy-session",Ri="privy:session_transfer_token",I1="privy:wallet",Ii="privy:caid",qr="privy:state_code",En="privy:code_verifier",Mi="privy:headless_oauth",Wa=e=>`${I1}:${e}`,Hl="privy:connectors",Gl="privy:connections";var jr=12e4,or=1,Vl="0x1",Pn=3e4,up="https://api.moonpay.com/v1",mp="https://api.moonpay.com/v1",fp="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",hp="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",yp="0x420000000000000000000000000000000000000F",gp=["function getL1Fee(bytes memory _data) external view returns (uint256)"];async function vp(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(o)}function wp(e){return crypto.getRandomValues(new Uint8Array(e))}var La=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)}},zl=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)}},$l=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 ql(){try{let e="privy:__session_storage__test",t="blobby";return window.sessionStorage.setItem(e,t),window.sessionStorage.removeItem(e),!0}catch{return!1}}function M1(){return typeof window<"u"&&window.localStorage?new zl:new La}function W1(){return typeof window<"u"&&window.sessionStorage?new $l:new La}var dt=W1(),fe=M1();function Oa(){return!!dt.get(Mi)}var L1="S256",O1="S256",Do=class{constructor(t){let o=typeof t.headless=="boolean"?t.headless:Oa();this.meta={...t,headless:o}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new T("User denied confirmation during OAuth flow");let t=dt.get(En);if(!t)throw new T("Authentication error.");try{let o=await this.api.post(Zd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return dt.del(En),this.meta.headless&&dt.del(Mi),{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(o){let r=me(o);throw r.privyErrorCode?new T(r.message||"Invalid code during OAuth flow.",void 0,r.privyErrorCode):r.message==="User denied confirmation during OAuth flow"?new T("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new T("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new T("User denied confirmation during OAuth flow");let t=dt.get(En);if(!t)throw new T("Authentication error.");try{let o=await this.api.post(Qd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return dt.del(En),o}catch(o){throw me(o)}}createCodeVerifier(){return jl.base64url.encode(wp(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,o=L1){if(o==O1){let r=await vp(t);return jl.base64url.encode(r)}else return t}async getAuthorizationUrl(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.provider)throw new T("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();dt.put(En,t);let o=this.createStateCode();dt.put(qr,o);let r=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&dt.put(Mi,!0);try{return await this.api.post(Jd,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:o})}catch(n){throw me(n)}}};function Kl(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Cp(e,t){let o={detail:"",retryable:!1},r=Kl(t);return e?.privyErrorCode==="linked_to_another_user"&&(o.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(o.retryable=!0,o.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(o.detail=`Retry and check ${r} to finish connecting your account.`,o.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(o.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="oauth_account_suspended"&&(o.detail=`Your ${r} account is suspended. Please try another login method.`),o}function Li(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),o=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");return!t||!o||!r?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:o,provider:r,headless:Oa()}}function Oi(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),dt.del(qr),window.history.pushState({},"",e)}var Kr=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 P1=Object.create;var Ca=Object.defineProperty;var T1=Object.getOwnPropertyDescriptor;var x1=Object.getOwnPropertyNames;var S1=Object.getPrototypeOf,_1=Object.prototype.hasOwnProperty;var A1=(e,t)=>{for(var o in t)Ca(e,o,{get:t[o],enumerable:!0})},_d=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x1(t))!_1.call(e,n)&&n!==o&&Ca(e,n,{get:()=>t[n],enumerable:!(r=T1(t,n))||r.enumerable});return e};var h=(e,t,o)=>(o=e!=null?P1(S1(e)):{},_d(t||!e||!e.__esModule?Ca(o,"default",{value:e,enumerable:!0}):o,e)),k1=e=>_d(Ca({},"__esModule",{value:!0}),e);var Dl=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var Ad=(e,t,o)=>(Dl(e,t,"read from private field"),o?o.call(e):t.get(e)),ba=(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)},Ul=(e,t,o,r)=>(Dl(e,t,"write to private field"),r?r.call(e,o):t.set(e,o),o);var kd=(e,t,o)=>(Dl(e,t,"access private method"),o);var q0={};A1(q0,{AsExternalProvider:()=>vo,Captcha:()=>vs,ConnectorManager:()=>Nn,PrivyClient:()=>Dn,PrivyProvider:()=>$g,PrivyProxyProvider:()=>ke,SUPPORTED_CHAINS:()=>Wn,VERSION:()=>Ra,WalletConnector:()=>Pt,addRpcUrlOverrideToChain:()=>v1,errorIndicatesMaxMfaRetries:()=>Bs,errorIndicatesMfaTimeout:()=>en,errorIndicatesMfaVerificationFailed:()=>tn,getAccessToken:()=>Ye,useConnectWallet:()=>o1,useCreateWallet:()=>n1,useFundWallet:()=>i1,useLinkAccount:()=>e1,useLogin:()=>jg,useLoginWithEmail:()=>Zg,useLoginWithOAuth:()=>Jg,useLoginWithSms:()=>Qg,useLogout:()=>Yg,useMfa:()=>dn,useMfaEnrollment:()=>fi,useModalStatus:()=>h1,usePrivy:()=>G,useRegisterMfaListener:()=>Es,useSendTransaction:()=>s1,useSetWalletPassword:()=>c1,useSignMessage:()=>p1,useSignTypedData:()=>m1,useToken:()=>g1,useWallets:()=>Ei});module.exports=k1(q0);var ga=require("@ethersproject/address"),Si=require("@ethersproject/providers"),Bg=require("mipd"),Q=require("react");var Rd=require("ofetch"),ct=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}]`:""}`}},No=class extends ct{constructor(o,r,n,i,a){super(n,i,a);this.type=o;this.status=r}},T=class extends ct{constructor(o,r,n){super(o,r,n);this.type="client_error"}},Ea=class extends T{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var X=class extends ct{constructor(o,r,n){super(o,r,n);this.type="connector_error"}},me=e=>{if(e instanceof ct)return e;if(!(e instanceof Rd.FetchError))return wt(e);if(!e.response)return new No("api_error",null,e.message,e);let{type:t,message:o,error:r,code:n}=e.data;return new No(t||"ApiError",e.response.status,o||r,e,n)},wt=e=>e instanceof ct?e:e instanceof Error?new T(e.message,e):new T(`Internal error: ${e}`);var Cn=class extends T{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Ft=class extends T{constructor(t="Embedded wallet error",o){super(t,o,"unknown_embedded_wallet_error")}},Pa=class extends T{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Ta="/api/v1/sessions",xa="/api/v1/sessions/logout",Id="/api/v1/sessions/fork",Sa="/api/v1/sessions/fork/recover",Md="/api/v1/siwe/init",Wd="/api/v1/siwe/authenticate",Ld="/api/v1/siwe/link",Od="/api/v1/siwe/unlink",Nd="/api/v1/farcaster/init",Dd="/api/v1/farcaster/authenticate",Ud="/api/v1/farcaster/link",Fd="/api/v1/farcaster/status",Bd="/api/v1/farcaster/unlink",Hd="/api/v1/passwordless/init",Gd="/api/v1/passwordless/authenticate",Vd="/api/v1/passwordless/link",zd="/api/v1/passwordless/unlink",$d="/api/v1/passwordless/update",qd="/api/v1/passwordless_sms/init",jd="/api/v1/passwordless_sms/link",Kd="/api/v1/passwordless_sms/unlink",Yd="/api/v1/passwordless_sms/authenticate",Jd="/api/v1/oauth/init",Zd="/api/v1/oauth/authenticate",Qd="/api/v1/oauth/link",Xd="/api/v1/oauth/unlink";var ep="/api/v1/mfa/passwordless_sms/init",tp="/api/v1/mfa/passwordless_sms/enroll";var op="/api/v1/users/me/accept_terms",rp="/api/v1/analytics_events",np="/api/v1/plugins/moonpay_on_ramp/sign",ip="/api/v1/custom_jwt_account/authenticate";var bn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{let t=await this.api.post(ip,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw me(t)}}async link(){throw new Error("Unimplemented")}};var Cr=class{constructor(t,o){this.meta={email:t,captchaToken:o}}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Gd,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw me(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Vd,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw me(t)}}async sendCodeEmail(t,o){if(!this.api)throw new T("Auth flow has no API instance");if(t&&(this.meta.email=t),o&&(this.meta.captchaToken=o),!this.meta.email)throw new T("Email must be set when initialzing authentication.");try{return await this.api.post(Hd,{email:this.meta.email,token:this.meta.captchaToken})}catch(r){throw me(r)}}},_a=class extends Cr{constructor(o,r,n){super(r,n);this.meta={email:r,captchaToken:n,oldAddress:o}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new T("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post($d,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(o){throw me(o)}}};var ap=require("react-device-detect");var Ct=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 ki=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Ct(this._startChannelOnce.bind(this)),this.pollForReady=new Ct(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");try{let t=await this.api.post(Dd,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new T("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw me(t)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(Ud,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw me(t)}}async _startChannelOnce(){if(!this.api)throw new T("Auth flow has no API instance");let t=await this.api.post(Nd,{token:this.captchaToken});ap.isMobile&&t.connect_uri&&window.open(t.connect_uri,"_blank","noopener noreferrer"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new T("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");let t=await this.api.get(Fd,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};var jl=require("jose");var sp="1.59.2-beta-20240307215727";var Aa="4df5e2316331463a9130964bd6078dfa",lp="fe9c30fc-3bc5-4064-91e2-6ab5887f8f4d",cp="34357d3c125c2bcf2ce2bc3309d98715",ka="https://auth.privy.io",dp=2e4,bt=1400,pp=2500,Ra=sp;var $r="privy:token",Fl="privy-token",Ia="privy:refresh_token",Bl="privy-refresh-token",Ma="privy-session",Ri="privy:session_transfer_token",I1="privy:wallet",Ii="privy:caid",qr="privy:state_code",En="privy:code_verifier",Mi="privy:headless_oauth",Wa=e=>`${I1}:${e}`,Hl="privy:connectors",Gl="privy:connections";var jr=12e4,or=1,Vl="0x1",Pn=3e4,up="https://api.moonpay.com/v1",mp="https://api.moonpay.com/v1",fp="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",hp="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",yp="0x420000000000000000000000000000000000000F",gp=["function getL1Fee(bytes memory _data) external view returns (uint256)"];async function vp(e){let t=new TextEncoder().encode(e),o=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(o)}function wp(e){return crypto.getRandomValues(new Uint8Array(e))}var La=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)}},zl=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)}},$l=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 ql(){try{let e="privy:__session_storage__test",t="blobby";return window.sessionStorage.setItem(e,t),window.sessionStorage.removeItem(e),!0}catch{return!1}}function M1(){return typeof window<"u"&&window.localStorage?new zl:new La}function W1(){return typeof window<"u"&&window.sessionStorage?new $l:new La}var dt=W1(),fe=M1();function Oa(){return!!dt.get(Mi)}var L1="S256",O1="S256",Do=class{constructor(t){let o=typeof t.headless=="boolean"?t.headless:Oa();this.meta={...t,headless:o}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new T("User denied confirmation during OAuth flow");let t=dt.get(En);if(!t)throw new T("Authentication error.");try{let o=await this.api.post(Zd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return dt.del(En),this.meta.headless&&dt.del(Mi),{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(o){let r=me(o);throw r.privyErrorCode?new T(r.message||"Invalid code during OAuth flow.",void 0,r.privyErrorCode):r.message==="User denied confirmation during OAuth flow"?new T("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new T("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new T("User denied confirmation during OAuth flow");let t=dt.get(En);if(!t)throw new T("Authentication error.");try{let o=await this.api.post(Qd,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return dt.del(En),o}catch(o){throw me(o)}}createCodeVerifier(){return jl.base64url.encode(wp(36))}createStateCode(){return this.createCodeVerifier()}async deriveCodeChallengeFromCodeVerifier(t,o=L1){if(o==O1){let r=await vp(t);return jl.base64url.encode(r)}else return t}async getAuthorizationUrl(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.provider)throw new T("Provider must be set when initializing OAuth authentication.");let t=this.createCodeVerifier();dt.put(En,t);let o=this.createStateCode();dt.put(qr,o);let r=await this.deriveCodeChallengeFromCodeVerifier(t);this.meta.headless&&dt.put(Mi,!0);try{return await this.api.post(Jd,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:r,state_code:o})}catch(n){throw me(n)}}};function Kl(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Cp(e,t){let o={detail:"",retryable:!1},r=Kl(t);return e?.privyErrorCode==="linked_to_another_user"&&(o.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(o.retryable=!0,o.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(o.detail=`Retry and check ${r} to finish connecting your account.`,o.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(o.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="oauth_account_suspended"&&(o.detail=`Your ${r} account is suspended. Please try another login method.`),o}function Li(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),o=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");return!t||!o||!r?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:o,provider:r,headless:Oa()}}function Oi(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),dt.del(qr),window.history.pushState({},"",e)}var Kr=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}
|
|
@@ -1595,7 +1595,7 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
1595
1595
|
margin-bottom: auto;
|
|
1596
1596
|
}
|
|
1597
1597
|
}
|
|
1598
|
-
`;var Te=require("react/jsx-runtime"),n2=()=>
|
|
1598
|
+
`;var Te=require("react/jsx-runtime"),n2=()=>(0,Te.jsxs)(i2,{children:[(0,Te.jsx)(Hi,{title:"Create a Phantom wallet",description:"Follow the instructions below to get started."}),(0,Te.jsx)(ao,{children:(0,Te.jsx)(Uo,{style:{width:"152px",height:"152px"}})}),(0,Te.jsxs)(Sh,{children:[(0,Te.jsx)(Zs,{children:(0,Te.jsxs)("div",{children:[(0,Te.jsx)("span",{children:"Install the "}),(0,Te.jsx)("a",{href:_h.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",target:"_blank",children:"Phantom browser extension"})]})}),(0,Te.jsx)(Bc,{}),(0,Te.jsx)(Zs,{children:"Set up your first wallet"}),(0,Te.jsx)(Bc,{}),(0,Te.jsx)(Zs,{children:"Store your recovery phrase in a safe place!"})]}),(0,Te.jsx)(Ss,{onClick:()=>window.location.reload(),children:"Reload the page to use your wallet"})]}),kh=()=>{let{navigateBack:e}=_();return(0,Te.jsxs)(Te.Fragment,{children:[(0,Te.jsx)(k,{backFn:e},"header"),(0,Te.jsx)(ee,{}),(0,Te.jsx)(n2,{}),(0,Te.jsx)(te,{}),(0,Te.jsxs)(ne,{children:[(0,Te.jsx)("span",{children:"Still not sure? "}),(0,Te.jsx)("a",{target:"_blank",href:"https://ethereum.org/en/wallets/",children:"Learn more"})]})]})},i2=(0,Ah.default)(ao)`
|
|
1599
1599
|
gap: 30px;
|
|
1600
1600
|
|
|
1601
1601
|
> :first-child > svg {
|
package/package.json
CHANGED