@privy-io/react-auth 1.4.0-beta.1 → 1.4.0-beta.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/README.md +24 -2
- package/dist/index.js +12 -12
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @privy-io/react-auth
|
|
2
2
|
|
|
3
|
+
The Privy React Auth SDK allows you to authenticate your users with Privy in your React app.
|
|
4
|
+
|
|
5
|
+
Check out our [demo](https://demo.privy.io/)!
|
|
6
|
+
|
|
3
7
|
> **⚠️ _NOTE:_** Privy is in beta. APIs and feature sets will change. We use [Semantic Versioning](https://semver.org/) to track breaking changes.
|
|
4
8
|
|
|
5
9
|
## Installing
|
|
@@ -8,6 +12,24 @@
|
|
|
8
12
|
npm i @privy-io/react-auth
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
##
|
|
15
|
+
## Basic Usage
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
Setup your integration by wrapping any React components that will use the Privy SDK with the `PrivyProvider`. This gives your wrapped components access to the Privy SDK and authentication context.
|
|
18
|
+
```tsx
|
|
19
|
+
// Import the PrivyProvider
|
|
20
|
+
import { PrivyProvider } from '@privy-io/react-auth'
|
|
21
|
+
|
|
22
|
+
// Wrap any components that will use the Privy SDK with the PrivyProvider – for example, in your `app` or `index` file
|
|
23
|
+
<PrivyProvider appId="APP_ID_FROM_CONSOLE" onSuccess={(user) => console.log(`User ${user.id} logged in!`)}>
|
|
24
|
+
<Component {...pageProps} />
|
|
25
|
+
</PrivyProvider>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Now, from within your React components, you can access the Privy SDK via the `usePrivy` hook!
|
|
29
|
+
```tsx
|
|
30
|
+
// Import the usePrivy hook
|
|
31
|
+
import { usePrivy } from '@privy-io/react-auth'
|
|
32
|
+
|
|
33
|
+
// Call usePrivy() from inside your React components
|
|
34
|
+
const { ready, authenticated, user, login, logout } = usePrivy();
|
|
35
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var o3=Object.create;var N1=Object.defineProperty;var r3=Object.getOwnPropertyDescriptor;var C3=Object.getOwnPropertyNames;var n3=Object.getPrototypeOf,s3=Object.prototype.hasOwnProperty;var d3=(l,e)=>{for(var a in e)N1(l,a,{get:e[a],enumerable:!0})},G2=(l,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C3(e))!s3.call(l,o)&&o!==a&&N1(l,o,{get:()=>e[o],enumerable:!(i=r3(e,o))||i.enumerable});return l};var k=(l,e,a)=>(a=l!=null?o3(n3(l)):{},G2(e||!l||!l.__esModule?N1(a,"default",{value:l,enumerable:!0}):a,l)),c3=l=>G2(N1({},"__esModule",{value:!0}),l);var k5={};d3(k5,{PrivyProvider:()=>a3,usePrivy:()=>E});module.exports=c3(k5);var Q=require("react");var D1=k(require("axios"));var B2=k(require("axios")),r1=class extends Error{constructor(a,i){super(a);i instanceof Error&&(this.cause=i)}toString(){return`${this.type}: ${this.message}`}},O1=class extends r1{constructor(a,i,o,C){super(o,C);this.type=a;this.status=i}},f=class extends r1{constructor(a,i){super(a,i);this.type="client_error"}};var G=class extends r1{constructor(a,i){super(a,i);this.type="connector_error"}},B=l=>{if(!B2.default.isAxiosError(l))return d1(l);if(!l.response)return new O1("api_error",null,l.message,l);let{type:e,message:a,error:i}=l.response.data;return new O1(e||"ApiError",l.response.status,a||i,l)},d1=l=>l instanceof r1?l:l instanceof Error?new f(l.message,l):new f(`Internal error: ${l}`);var U1=class{constructor(e,a,i){this.appId=e,this.session=a,this.defaults=i}async get(e,a){try{return await D1.default.get(e,this.buildConfig(a))}catch(i){throw B(i)}}async post(e,a,i){try{return await D1.default.post(e,a,this.buildConfig(i))}catch(o){throw B(o)}}async delete(e,a){try{return await D1.default.delete(e,this.buildConfig(a))}catch(i){throw B(i)}}buildConfig(e){return e=e||{},e.headers=e.headers||{},e.headers["privy-app-id"]=this.appId,this.session.token!==null&&(e.headers.authorization=`Bearer ${this.session.token}`),{...this.defaults,...e}}};var j2="https://api.privy.io/v0",z2=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",c2="70f97dc579834350a5baec117b3c5ae3",$2=1e4,C1=1200,q2=3e4;var Y2=k(require("jwt-decode")),u1=class{static parse(e){try{return new u1(e)}catch{return null}}constructor(e){this.value=e,this._decoded=(0,Y2.default)(e)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}isExpired(e=0){let a=Date.now(),i=(this.expiration-e)*1e3;return a>=i}};var m1=class{constructor(e){this.promise=null;this.fn=e}execute(e){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}};var p2=class{constructor(){this._cache={}}get(e){return this._cache[e]}put(e,a){a!==void 0?this._cache[e]=a:this.del(e)}del(e){delete this._cache[e]}},h2=class{get(e){let a=localStorage.getItem(e);return a===null?void 0:JSON.parse(a)}put(e,a){a!==void 0?localStorage.setItem(e,JSON.stringify(a)):this.del(e)}del(e){localStorage.removeItem(e)}};function p3(){return typeof window<"u"&&window.localStorage?new h2:new p2}var q=p3();var h3=l=>{var e;return(e=l.map(a=>{if(a.type==="wallet")return{address:a.address,type:a.type,verifiedAt:new Date(a.verified_at*1e3),chainType:a.chain_type}}).filter(a=>a))==null?void 0:e[0]},f3=l=>{var e;return(e=l.map(a=>{if(a.type==="email")return{address:a.address,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]},u3=l=>{var e;return(e=l.map(a=>{if(a.type==="google_oauth")return{subject:a.subject,email:a.subject,name:a.name,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]},m3=l=>{var e;return(e=l.map(a=>{if(a.type==="twitter_oauth")return{subject:a.subject,username:a.username,name:a.name,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]},b3=l=>{var e;return(e=l.map(a=>{if(a.type==="discord_oauth")return{subject:a.subject,username:a.username,email:a.email,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]};function f2(l){if(!l)return null;let e=f3(l.linked_accounts),a=h3(l.linked_accounts),i=u3(l.linked_accounts),o=m3(l.linked_accounts),C=b3(l.linked_accounts);return{id:l.id,createdAt:new Date(l.created_at*1e3),linkedAccounts:[...a?[a]:[],...e?[e]:[],...i?[i]:[],...o?[o]:[],...C?[C]:[]],email:e&&{address:e==null?void 0:e.address},wallet:a&&{address:a.address,chainType:a.chainType,chainId:a.chainId,walletType:a.walletType},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:o&&{subject:o.subject,username:o.username,name:o.name},discord:C&&{subject:C.subject,username:C.username,email:C.email}}}var K2=()=>"/api/v1/sessions",J2=()=>"/api/v1/sessions/logout",X2=()=>"/api/v1/siwe/init",Q2=()=>"/api/v1/siwe/authenticate",t4=()=>"/api/v1/passwordless/init",e4=()=>"/api/v1/passwordless/authenticate",l4=()=>"/api/v1/oauth/init",a4=()=>"/api/v1/oauth/authenticate";var k3=30,u2="privy:token",m2="privy:refresh_token",F1=class{constructor(){this.authenticateOnce=new m1(async e=>this._authenticate(e)),this.refreshOnce=new m1(this._refresh.bind(this)),this.destroyOnce=new m1(this._destroy.bind(this))}get token(){let e=q.get(u2);return typeof e=="string"?e:null}get refreshToken(){let e=q.get(m2);return typeof e=="string"?e:null}hasRefreshCredentials(){return typeof this.token=="string"&&typeof this.refreshToken=="string"}hasActiveToken(){let e=u1.parse(this.token);return e!==null&&!e.isExpired(k3)}authenticate(e){return this.authenticateOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(e){try{let{token:a,refresh_token:i,user:o}=await e.authenticate();return a&&this.storeToken(a),i&&this.storeRefreshToken(i),f2(o)}catch(a){throw console.warn("Error authenticating session"),d1(a)}}async _refresh(){if(!this.api)throw new f("Session has no API instance");let e=this.token,a=this.refreshToken;if(!e||!a)return null;try{let i=await this.api.post(K2(),{refresh_token:a});return this.storeToken(i.data.token),this.storeRefreshToken(i.data.refresh_token),f2(i.data.user)}catch(i){throw d1(i)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(J2(),{})),this.destroyLocalState()}catch(a){throw console.warn("Error destroying session"),d1(a)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null)}storeToken(e){typeof e=="string"?q.put(u2,e):q.del(u2)}storeRefreshToken(e){typeof e=="string"?q.put(m2,e):q.del(m2)}};var r4=require("@ethersproject/address"),Z2=k(require("@walletconnect/web3-provider"));var b1=class{constructor(e){this.removeListener=(e,a)=>{if(this._provider)return this._provider.removeListener(e,a)};this.setProvider=e=>{this._provider=e,this._subscriptions.forEach(a=>{var i;(i=this._provider)==null||i.on(a.eventName,a.listener)})};this._provider=e,this._subscriptions=[]}on(e,a){if(this._provider)return this._provider.on(e,a);this._subscriptions.push({eventName:e,listener:a})}request(e){if(!this._provider)throw new G(`A wallet request of type ${e.method} was made to a disconnected wallet: `);return this._provider.request(e)}},k1=class extends b1{constructor(a){super(a)}},V1=class extends b1{constructor(e){super(e)}sendAsync(e,a){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var C4=require("ethers");var i4=["metamask","coinbase_wallet","wallet_connect"];var o4=require("ethers");var H1=class extends G{constructor(){super("Wallet timeout");this.type="wallet_error"}},k2=l=>{if(l instanceof G)return l;if((l==null?void 0:l.code)&&(l==null?void 0:l.reason)){let e=new g1(l);return l.code===o4.ethers.errors.ACTION_REJECTED&&(e.details=M1.E4001_USER_REJECTED_REQUEST),e}return l!=null&&l.code?new g1(l):new G("Unknown connector error",l)},b2=class extends r1{constructor(a,i,o){super(a);this.type="provider_error";this.code=i,this.data=o}},g1=class extends b2{constructor(a){var C,c;let i=a;super(i.message,i.code,i.data);let o=Object.values(M1).find(p=>p.eipCode===i.code);this.details=o||M1.UNKNOWN_ERROR,i.code===-32002&&(C=i.message)!=null&&C.includes("already pending for origin")&&((c=i.message)!=null&&c.includes("wallet_requestPermissions")?this.details=M1.E32002_CONNECTION_ALREADY_PENDING:this.details=M1.E32002_REQUEST_ALREADY_PENDING)}},M3={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0}},g3={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Z3={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},M1={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Z3,...g3},M2={...M3,...M1};var g2="privy:wallet_type",G1=(l=new H1,e=q2)=>new Promise((a,i)=>setTimeout(()=>{i(l)},e)),L2=()=>{if(!window.ethereum)return!1;if(window.ethereum.isMetaMask)return!0;if(window.ethereum.providers){for(let l of window.ethereum.providers)if(l.isMetaMask)return!0}return!1},y2=()=>{if(!window.ethereum)return!1;if(window.ethereum.isCoinbaseWallet)return!0;if(window.ethereum.providers){for(let l of window.ethereum.providers)if(l.isCoinbaseWallet)return!0}return!1},B1=class{constructor(){this.walletType=null;this.getEthereumProvider=()=>this.ethProvider;this.createSiweMessage=(e,a,i,o,C,c,p)=>`${i} wants you to sign in with your Ethereum account:
|
|
1
|
+
"use strict";var o3=Object.create;var N1=Object.defineProperty;var r3=Object.getOwnPropertyDescriptor;var C3=Object.getOwnPropertyNames;var n3=Object.getPrototypeOf,s3=Object.prototype.hasOwnProperty;var c3=(l,e)=>{for(var a in e)N1(l,a,{get:e[a],enumerable:!0})},G2=(l,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C3(e))!s3.call(l,o)&&o!==a&&N1(l,o,{get:()=>e[o],enumerable:!(i=r3(e,o))||i.enumerable});return l};var k=(l,e,a)=>(a=l!=null?o3(n3(l)):{},G2(e||!l||!l.__esModule?N1(a,"default",{value:l,enumerable:!0}):a,l)),d3=l=>G2(N1({},"__esModule",{value:!0}),l);var k5={};c3(k5,{PrivyProvider:()=>a3,usePrivy:()=>E});module.exports=d3(k5);var Q=require("react");var D1=k(require("axios"));var B2=k(require("axios")),r1=class extends Error{constructor(a,i){super(a);i instanceof Error&&(this.cause=i)}toString(){return`${this.type}: ${this.message}`}},O1=class extends r1{constructor(a,i,o,C){super(o,C);this.type=a;this.status=i}},f=class extends r1{constructor(a,i){super(a,i);this.type="client_error"}};var G=class extends r1{constructor(a,i){super(a,i);this.type="connector_error"}},B=l=>{if(!B2.default.isAxiosError(l))return c1(l);if(!l.response)return new O1("api_error",null,l.message,l);let{type:e,message:a,error:i}=l.response.data;return new O1(e||"ApiError",l.response.status,a||i,l)},c1=l=>l instanceof r1?l:l instanceof Error?new f(l.message,l):new f(`Internal error: ${l}`);var U1=class{constructor(e,a,i){this.appId=e,this.session=a,this.defaults=i}async get(e,a){try{return await D1.default.get(e,this.buildConfig(a))}catch(i){throw B(i)}}async post(e,a,i){try{return await D1.default.post(e,a,this.buildConfig(i))}catch(o){throw B(o)}}async delete(e,a){try{return await D1.default.delete(e,this.buildConfig(a))}catch(i){throw B(i)}}buildConfig(e){return e=e||{},e.headers=e.headers||{},e.headers["privy-app-id"]=this.appId,this.session.token!==null&&(e.headers.authorization=`Bearer ${this.session.token}`),{...this.defaults,...e}}};var j2="https://api.privy.io/v0",z2=process.env.NEXT_PUBLIC_PRIVY_AUTH_URL||"https://auth.privy.io",d2="70f97dc579834350a5baec117b3c5ae3",$2=1e4,C1=1200,q2=3e4;var Y2=k(require("jwt-decode")),u1=class{static parse(e){try{return new u1(e)}catch{return null}}constructor(e){this.value=e,this._decoded=(0,Y2.default)(e)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}isExpired(e=0){let a=Date.now(),i=(this.expiration-e)*1e3;return a>=i}};var m1=class{constructor(e){this.promise=null;this.fn=e}execute(e){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}};var p2=class{constructor(){this._cache={}}get(e){return this._cache[e]}put(e,a){a!==void 0?this._cache[e]=a:this.del(e)}del(e){delete this._cache[e]}},h2=class{get(e){let a=localStorage.getItem(e);return a===null?void 0:JSON.parse(a)}put(e,a){a!==void 0?localStorage.setItem(e,JSON.stringify(a)):this.del(e)}del(e){localStorage.removeItem(e)}};function p3(){return typeof window<"u"&&window.localStorage?new h2:new p2}var q=p3();var h3=l=>{var e;return(e=l.map(a=>{if(a.type==="wallet")return{address:a.address,type:a.type,verifiedAt:new Date(a.verified_at*1e3),chainType:a.chain_type}}).filter(a=>a))==null?void 0:e[0]},f3=l=>{var e;return(e=l.map(a=>{if(a.type==="email")return{address:a.address,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]},u3=l=>{var e;return(e=l.map(a=>{if(a.type==="google_oauth")return{subject:a.subject,email:a.subject,name:a.name,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]},m3=l=>{var e;return(e=l.map(a=>{if(a.type==="twitter_oauth")return{subject:a.subject,username:a.username,name:a.name,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]},b3=l=>{var e;return(e=l.map(a=>{if(a.type==="discord_oauth")return{subject:a.subject,username:a.username,email:a.email,type:a.type,verifiedAt:new Date(a.verified_at*1e3)}}).filter(a=>a))==null?void 0:e[0]};function f2(l){if(!l)return null;let e=f3(l.linked_accounts),a=h3(l.linked_accounts),i=u3(l.linked_accounts),o=m3(l.linked_accounts),C=b3(l.linked_accounts);return{id:l.id,createdAt:new Date(l.created_at*1e3),linkedAccounts:[...a?[a]:[],...e?[e]:[],...i?[i]:[],...o?[o]:[],...C?[C]:[]],email:e&&{address:e==null?void 0:e.address},wallet:a&&{address:a.address,chainType:a.chainType,chainId:a.chainId,walletType:a.walletType},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:o&&{subject:o.subject,username:o.username,name:o.name},discord:C&&{subject:C.subject,username:C.username,email:C.email}}}var K2=()=>"/api/v1/sessions",J2=()=>"/api/v1/sessions/logout",X2=()=>"/api/v1/siwe/init",Q2=()=>"/api/v1/siwe/authenticate",t4=()=>"/api/v1/passwordless/init",e4=()=>"/api/v1/passwordless/authenticate",l4=()=>"/api/v1/oauth/init",a4=()=>"/api/v1/oauth/authenticate";var k3=30,u2="privy:token",m2="privy:refresh_token",F1=class{constructor(){this.authenticateOnce=new m1(async e=>this._authenticate(e)),this.refreshOnce=new m1(this._refresh.bind(this)),this.destroyOnce=new m1(this._destroy.bind(this))}get token(){let e=q.get(u2);return typeof e=="string"?e:null}get refreshToken(){let e=q.get(m2);return typeof e=="string"?e:null}hasRefreshCredentials(){return typeof this.token=="string"&&typeof this.refreshToken=="string"}hasActiveToken(){let e=u1.parse(this.token);return e!==null&&!e.isExpired(k3)}authenticate(e){return this.authenticateOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}async _authenticate(e){try{let{token:a,refresh_token:i,user:o}=await e.authenticate();return a&&this.storeToken(a),i&&this.storeRefreshToken(i),f2(o)}catch(a){throw console.warn("Error authenticating session"),c1(a)}}async _refresh(){if(!this.api)throw new f("Session has no API instance");let e=this.token,a=this.refreshToken;if(!e||!a)return null;try{let i=await this.api.post(K2(),{refresh_token:a});return this.storeToken(i.data.token),this.storeRefreshToken(i.data.refresh_token),f2(i.data.user)}catch(i){throw c1(i)}}async _destroy(){var e;try{await((e=this.api)==null?void 0:e.post(J2(),{})),this.destroyLocalState()}catch(a){throw console.warn("Error destroying session"),c1(a)}}destroyLocalState(){this.storeToken(null),this.storeRefreshToken(null)}storeToken(e){typeof e=="string"?q.put(u2,e):q.del(u2)}storeRefreshToken(e){typeof e=="string"?q.put(m2,e):q.del(m2)}};var r4=require("@ethersproject/address"),Z2=k(require("@walletconnect/web3-provider"));var b1=class{constructor(e){this.removeListener=(e,a)=>{if(this._provider)return this._provider.removeListener(e,a)};this.setProvider=e=>{this._provider=e,this._subscriptions.forEach(a=>{var i;(i=this._provider)==null||i.on(a.eventName,a.listener)})};this._provider=e,this._subscriptions=[]}on(e,a){if(this._provider)return this._provider.on(e,a);this._subscriptions.push({eventName:e,listener:a})}request(e){if(!this._provider)throw new G(`A wallet request of type ${e.method} was made to a disconnected wallet: `);return this._provider.request(e)}},k1=class extends b1{constructor(a){super(a)}},V1=class extends b1{constructor(e){super(e)}sendAsync(e,a){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var C4=require("ethers");var i4=["metamask","coinbase_wallet","wallet_connect"];var o4=require("ethers");var H1=class extends G{constructor(){super("Wallet timeout");this.type="wallet_error"}},k2=l=>{if(l instanceof G)return l;if((l==null?void 0:l.code)&&(l==null?void 0:l.reason)){let e=new g1(l);return l.code===o4.ethers.errors.ACTION_REJECTED&&(e.details=M1.E4001_USER_REJECTED_REQUEST),e}return l!=null&&l.code?new g1(l):new G("Unknown connector error",l)},b2=class extends r1{constructor(a,i,o){super(a);this.type="provider_error";this.code=i,this.data=o}},g1=class extends b2{constructor(a){var C,d;let i=a;super(i.message,i.code,i.data);let o=Object.values(M1).find(p=>p.eipCode===i.code);this.details=o||M1.UNKNOWN_ERROR,i.code===-32002&&(C=i.message)!=null&&C.includes("already pending for origin")&&((d=i.message)!=null&&d.includes("wallet_requestPermissions")?this.details=M1.E32002_CONNECTION_ALREADY_PENDING:this.details=M1.E32002_REQUEST_ALREADY_PENDING)}},M3={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0}},g3={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet modal? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},Z3={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},M1={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...Z3,...g3},M2={...M3,...M1};var g2="privy:wallet_type",G1=(l=new H1,e=q2)=>new Promise((a,i)=>setTimeout(()=>{i(l)},e)),L2=()=>{if(!window.ethereum)return!1;if(window.ethereum.isMetaMask)return!0;if(window.ethereum.providers){for(let l of window.ethereum.providers)if(l.isMetaMask)return!0}return!1},y2=()=>{if(!window.ethereum)return!1;if(window.ethereum.isCoinbaseWallet)return!0;if(window.ethereum.providers){for(let l of window.ethereum.providers)if(l.isCoinbaseWallet)return!0}return!1},B1=class{constructor(){this.walletType=null;this.getEthereumProvider=()=>this.ethProvider;this.createSiweMessage=(e,a,i,o,C,d,p)=>`${i} wants you to sign in with your Ethereum account:
|
|
2
2
|
${a}
|
|
3
3
|
|
|
4
4
|
${p}
|
|
@@ -6,10 +6,10 @@ ${p}
|
|
|
6
6
|
URI: ${o}
|
|
7
7
|
Version: 1
|
|
8
8
|
Chain ID: ${e}
|
|
9
|
-
Nonce: ${
|
|
9
|
+
Nonce: ${d}
|
|
10
10
|
Issued At: ${C}
|
|
11
11
|
Resources:
|
|
12
|
-
- https://privy.io`;this.ethProvider=new b1}initialize(){let e=q.get(g2);i4.includes(e)&&(this.walletType=e,this.connect({showPrompt:!1}))}destroy(){this.walletType=null,q.del(g2)}async connect(e){var a,i;switch(this.walletType){case"metamask":this.ethProvider.setProvider(window.ethereum),(a=window.ethereum.providers)==null||a.forEach(async C=>{C.isMetaMask&&this.ethProvider.setProvider(C)});break;case"coinbase_wallet":this.ethProvider.setProvider(window.ethereum),(i=window.ethereum.providers)==null||i.forEach(async C=>{C.isCoinbaseWallet&&this.ethProvider.setProvider(C)});break;case"wallet_connect":let o=new Z2.default({infuraId:
|
|
12
|
+
- https://privy.io`;this.ethProvider=new b1}initialize(){let e=q.get(g2);i4.includes(e)&&(this.walletType=e,this.connect({showPrompt:!1}))}destroy(){this.walletType=null,q.del(g2)}async connect(e){var a,i;switch(this.walletType){case"metamask":this.ethProvider.setProvider(window.ethereum),(a=window.ethereum.providers)==null||a.forEach(async C=>{C.isMetaMask&&this.ethProvider.setProvider(C)});break;case"coinbase_wallet":this.ethProvider.setProvider(window.ethereum),(i=window.ethereum.providers)==null||i.forEach(async C=>{C.isCoinbaseWallet&&this.ethProvider.setProvider(C)});break;case"wallet_connect":let o=new Z2.default({infuraId:d2});this.ethProvider.setProvider(o);break;default:throw new G(`Unsupported wallet: ${this.walletType}`)}return!await this.isConnected()&&e.showPrompt&&await this.promptConnection(this.walletType),this.address()}async isConnected(){switch(this.walletType){case"metamask":return await this.address()!==null;case"coinbase_wallet":return await this.address()!==null;case"wallet_connect":return this.ethProvider.connected;default:throw new G(`Unsupported wallet: ${this.walletType}`)}}async promptConnection(e){try{switch(e){case"metamask":await Promise.race([this.ethProvider.request({method:"eth_requestAccounts"}),G1()]);break;case"coinbase_wallet":await Promise.race([this.ethProvider.request({method:"eth_requestAccounts"}),G1()]);break;case"wallet_connect":let a=new Z2.default({infuraId:d2});this.ethProvider.setProvider(a),await Promise.race([a.enable(),G1()]),q.put(g2,e);break;default:throw new G(`Unsupported wallet: ${this.walletType}`)}}catch(a){throw k2(a)}}async sign(e){let i=new C4.providers.Web3Provider(new k1(this.getEthereumProvider())).getSigner();return Promise.race([i.signMessage(e),G1()]).catch(o=>{throw k2(o)})}prepareMessage(e,a,i){let o=window.location.host,C=window.location.origin,d=`${o} requests that you authenticate with Privy.`,p=new Date().toISOString();return this.createSiweMessage(e,a,o,C,p,i,d)}async chainId(){let e=await this.getEthereumProvider().request({method:"eth_chainId"}),a=Number(e);return String(a)}async address(){let e=await this.getEthereumProvider().request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0?(0,r4.getAddress)(e[0]):null}};var w2,j1=class{constructor(e){let a=e.apiURL||j2,i=e.timeout||$2;this.appId=e.appId,this.connector=new B1,this.connector.initialize(),w2||(w2=new F1),this.session=w2,this.api=new U1(e.appId,this.session,{baseURL:a,timeout:i}),this.session.api=this.api}async authenticate(){if(!this.authFlow)throw new f("No auth flow in progress.");return await this.session.authenticate(this.authFlow)}async logout(){await this.session.destroy(),this.connector.destroy(),this.authFlow=void 0}startAuthFlow(e){e.api=this.api,this.authFlow=e}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(){return this.session.hasActiveToken()?this.session.token:this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getAppSettings(){try{let e=await this.api.get(`/api/v1/apps/${this.appId}`);return{id:e.data.id,name:e.data.name,verificationKey:e.data.verification_key,logoUrl:e.data.logo_url||void 0,theme:e.data.theme,accentColor:e.data.accent_color||void 0,createdAt:new Date(e.data.created_at*1e3),updatedAt:new Date(e.data.updated_at*1e3)}}catch(e){throw c1(e)}}};var l3=require("@ethersproject/providers");var z1=require("react");var w=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};var v2=(0,z1.createContext)({ready:!1,authenticated:!1,user:null,login:w,linkEmail:w,linkWallet:w,logout:w,getAccessToken:w,getEthereumProvider:w,getEthersProvider:w,getWeb3jsProvider:w}),E=()=>(0,z1.useContext)(v2);var w1=class{constructor(e){this.connector=e,this.meta={wallet:this.connector.walletType}}async authenticate(){if(!this.api)throw new f("Auth flow has no API instance");if(!this.connector.walletType)throw new f("Wallet must be specified");try{let e=await this.connector.connect({showPrompt:!0}),a=await this.connector.chainId(),i=await this.api.post(X2(),{address:e}),o=this.connector.prepareMessage(a,e,i.data.nonce),C=await this.connector.sign(o),d=await this.api.post(Q2(),{message:o,signature:C});return{user:d.data.user,token:d.data.token,refresh_token:d.data.refresh_token}}catch(e){throw B(e)}}getEthereumProvider(){return this.connector.getEthereumProvider()}};var v1=class{constructor(e){this.meta={email:e}}async authenticate(){if(!this.api)throw new f("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new f("Email and email code must be set prior to calling authenticate.");try{let e=e4(),a=await this.api.post(e,{email:this.meta.email,code:this.meta.emailCode});return{user:a.data.user,token:a.data.token,refresh_token:a.data.refresh_token}}catch(e){throw B(e)}}async sendCodeEmail(e){if(!this.api)throw new f("Auth flow has no API instance");if(e&&(this.meta.email=e),!this.meta.email)throw new f("Email must be set when initialzing authentication.");try{let a=t4();return(await this.api.post(a,{email:this.meta.email})).data}catch(a){throw B(a)}}};var x1=class{constructor(e,a,i){this.meta={provider:e},this.meta.authorizationCode=a,this.meta.stateCode=i}async authenticate(){if(!this.api)throw new f("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new f("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");try{let e=a4(),a=await this.api.post(e,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode});return{user:a.data.user,token:a.data.token,refresh_token:a.data.refresh_token}}catch(e){throw B(e)}}async getAuthorizationUrl(){if(!this.api)throw new f("Auth flow has no API instance");if(!this.meta.provider)throw new f("Provider must be set when initialzing OAuth authentication.");try{let e=l4();return(await this.api.post(e,{provider:this.meta.provider,redirect_to:window.location.href})).data}catch(e){throw B(e)}}};var $1=require("react-device-detect"),n4=l=>{let e=new URL(window.location.href);if(!window.ethereum&&$1.isMobile){let a;switch(l){case"metamask":$1.isIOS?a="dapp://"+e.hostname+e.pathname:a="https://metamask.app.link/dapp/"+e.hostname+e.pathname;break;case"coinbase_wallet":a="https://go.cb-w.com/dapp?cb_url="+encodeURIComponent(e.href.replace(/\/$/g,""));break;case"wallet_connect":break;default:break}a&&window.location.assign(a)}};var t3=k(require("react-dom")),F2=k(require("styled-components"));var j=require("react");var q1=require("react");var x2=(0,q1.createContext)({showPrivyModal:!1,getAuthMeta:w,closePrivyModal:w,initLoginWithWallet:w,loginWithWallet:w,loginWithCode:w,loginWithEmail:w,resendEmailCode:w,initLoginWithOAuth:w}),Z=()=>(0,q1.useContext)(x2);var c4=require("react/jsx-runtime");function s4(l){return(0,c4.jsx)("link",{rel:"prefetch",href:l.src})}var Y1=require("react/jsx-runtime"),d4=(0,j.createContext)({app:null,currentScreen:"LANDING",lastScreen:"LANDING",navigate:w,navigateBack:w,showSocials:!1}),p4=l=>{let e=l.client,{authenticated:a}=E(),{showPrivyModal:i}=Z(),[o,C]=(0,j.useState)(null),[d,p]=(0,j.useState)(null),[c,b]=(0,j.useState)({accentColor:"#696ffd",theme:"System"});(0,j.useEffect)(()=>{async function M(){let A=await e.getAppSettings();b(A)}M()},[]),(0,j.useEffect)(()=>{a||C(null)},[a]),(0,j.useEffect)(()=>{i||(p("LANDING"),C("LANDING"))},[i]);let h={app:c,currentScreen:o||"LANDING",lastScreen:d||"LANDING",navigate:M=>{p(o),C(M)},navigateBack:()=>{C(d)},showSocials:l.showSocials||!1};return(0,Y1.jsxs)(d4.Provider,{value:h,children:[c&&c.logoUrl&&(0,Y1.jsx)(s4,{src:c.logoUrl}),l.children]})},u=()=>(0,j.useContext)(d4);var e2=require("react"),l2=k(require("styled-components"));var u4=k(require("styled-components"));var E2=require("react/jsx-runtime"),h4=({style:l,...e})=>(0,E2.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...l},...e,children:(0,E2.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})});var A2=require("react/jsx-runtime"),f4=({style:l,...e})=>(0,A2.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...l},...e,children:(0,A2.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})});var x=require("react/jsx-runtime"),_2=()=>(0,x.jsx)("div",{}),m4=({backFn:l})=>(0,x.jsx)("div",{children:(0,x.jsx)(f4,{style:{color:"#6B7280"},onClick:l})}),b4=()=>{let{closePrivyModal:l}=Z();return(0,x.jsx)("div",{children:(0,x.jsx)(h4,{style:{color:"#6B7280"},onClick:l})})},L3=()=>{let{app:l}=u();return l!=null&&l.logoUrl?(0,x.jsx)("div",{children:(0,x.jsx)("img",{src:l.logoUrl,alt:`${l==null?void 0:l.name} logo`,style:{objectFit:"contain",width:"120px",height:"30px"}})}):null};var P=({backFn:l})=>(0,x.jsxs)(M4,{children:[l?(0,x.jsx)(m4,{backFn:l}):(0,x.jsx)(_2,{}),(0,x.jsx)(L3,{},"app-name"),(0,x.jsx)(b4,{})]}),k4=({backFn:l})=>(0,x.jsxs)(M4,{children:[l?(0,x.jsx)(m4,{backFn:l}):(0,x.jsx)(_2,{}),(0,x.jsx)(_2,{}),(0,x.jsx)(b4,{})]}),M4=u4.default.div`
|
|
13
13
|
height: 64px;
|
|
14
14
|
display: flex;
|
|
15
15
|
align-items: center;
|
|
@@ -129,7 +129,7 @@ Resources:
|
|
|
129
129
|
border-color: var(--fail-light);
|
|
130
130
|
border-bottom-color: var(--fail-light);
|
|
131
131
|
}
|
|
132
|
-
`;var v4=l=>!!String(l).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);var U=require("react/jsx-runtime"),Q1=()=>{let[l,e]=(0,L1.useState)(""),[a,i]=(0,L1.useState)(!1),[o,C]=(0,L1.useState)(null),{authenticated:
|
|
132
|
+
`;var v4=l=>!!String(l).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);var U=require("react/jsx-runtime"),Q1=()=>{let[l,e]=(0,L1.useState)(""),[a,i]=(0,L1.useState)(!1),[o,C]=(0,L1.useState)(null),{authenticated:d}=E(),{loginWithEmail:p}=Z(),{navigate:c}=u();(0,L1.useEffect)(()=>{let h=document.querySelector("#email-input");h==null||h.focus()},[]);let b=v4(l);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(v3,{children:[(0,U.jsx)(Z4,{}),(0,U.jsx)("input",{id:"email-input",type:"email",placeholder:"your@mail.com",onChange:h=>e(h.target.value),onKeyUp:h=>{h.key==="Enter"&&(i(!0),p(l).then(()=>{c("AWAITING_EMAIL_CODE")}).catch(M=>{(M==null?void 0:M.status)===422?C(M.message):C("Issue submitting email"),i(!1)}))},value:l,autoComplete:"email"})]}),o?(0,U.jsx)(A3,{fail:!!o,children:o||""}):null,!d&&!o?(0,U.jsx)(x3,{children:(0,U.jsx)("span",{children:"You\u2019ll be able to connect a wallet later."})}):null,(0,U.jsx)(E3,{disabled:a||!b,onClick:()=>{i(!0),p(l).then(()=>{c("AWAITING_EMAIL_CODE")}).catch(h=>{(h==null?void 0:h.status)===422?C(h.message):C("Issue submitting email"),i(!1)})},children:a?(0,U.jsx)(I2,{color:"var(--disabled-fg)",style:{height:"1rem",width:"1rem",borderWidth:"2px"}}):"Continue"})]})},v3=T1.default.label`
|
|
133
133
|
display: flex;
|
|
134
134
|
flex-direction: row;
|
|
135
135
|
align-items: center;
|
|
@@ -199,7 +199,7 @@ Resources:
|
|
|
199
199
|
opacity: ${l=>l.success||l.fail?"1":"0"};
|
|
200
200
|
|
|
201
201
|
transition: ${l=>l.fail?"":"all 150ms ease-in-out"};
|
|
202
|
-
`;var y1=k(require("styled-components"));var R2=require("react/jsx-runtime"),x4=({style:l,...e})=>(0,R2.jsx)("svg",{width:"24",height:"20",viewBox:"0 0 24 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...l},...e,children:(0,R2.jsx)("path",{d:"M7.54311 19.7551C16.5973 19.7551 21.5516 12.2467 21.5516 5.74656C21.5516 5.53533 21.5516 5.32409 21.542 5.11286C22.5021 4.42156 23.3375 3.54783 24 2.55888C23.1166 2.95254 22.1661 3.21178 21.1675 3.3366C22.1853 2.73171 22.963 1.76196 23.3375 0.609788C22.3869 1.17627 21.3308 1.57953 20.2074 1.80037C19.3049 0.840223 18.0279 0.244934 16.6165 0.244934C13.8993 0.244934 11.6909 2.45326 11.6909 5.17047C11.6909 5.55453 11.7389 5.92898 11.8157 6.29384C7.72554 6.09221 4.09619 4.12391 1.66703 1.14747C1.24457 1.87718 1.00453 2.72211 1.00453 3.62464C1.00453 5.3337 1.87826 6.84112 3.19366 7.72445C2.38714 7.69565 1.62862 7.47481 0.966125 7.10996C0.966125 7.12916 0.966125 7.14837 0.966125 7.17717C0.966125 9.55833 2.66558 11.5554 4.91232 12.0067C4.49945 12.1219 4.06739 12.1795 3.61612 12.1795C3.29927 12.1795 2.99203 12.1507 2.69438 12.0931C3.31848 14.0518 5.14275 15.4728 7.29347 15.5112C5.60362 16.8362 3.4817 17.6235 1.17736 17.6235C0.783698 17.6235 0.390039 17.6043 0.00598145 17.5563C2.17591 18.9389 4.76829 19.7551 7.54311 19.7551Z",fill:"white"})});var n1=require("react/jsx-runtime"),E4=({style:l,...e})=>(0,n1.jsxs)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...l},...e,children:[(0,n1.jsx)("g",{"clip-path":"url(#clip0)",children:(0,n1.jsx)("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#ffffff"})}),(0,n1.jsx)("defs",{children:(0,n1.jsx)("clipPath",{id:"clip0",children:(0,n1.jsx)("rect",{width:"71",height:"55",fill:"white"})})})]});var
|
|
202
|
+
`;var y1=k(require("styled-components"));var R2=require("react/jsx-runtime"),x4=({style:l,...e})=>(0,R2.jsx)("svg",{width:"24",height:"20",viewBox:"0 0 24 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...l},...e,children:(0,R2.jsx)("path",{d:"M7.54311 19.7551C16.5973 19.7551 21.5516 12.2467 21.5516 5.74656C21.5516 5.53533 21.5516 5.32409 21.542 5.11286C22.5021 4.42156 23.3375 3.54783 24 2.55888C23.1166 2.95254 22.1661 3.21178 21.1675 3.3366C22.1853 2.73171 22.963 1.76196 23.3375 0.609788C22.3869 1.17627 21.3308 1.57953 20.2074 1.80037C19.3049 0.840223 18.0279 0.244934 16.6165 0.244934C13.8993 0.244934 11.6909 2.45326 11.6909 5.17047C11.6909 5.55453 11.7389 5.92898 11.8157 6.29384C7.72554 6.09221 4.09619 4.12391 1.66703 1.14747C1.24457 1.87718 1.00453 2.72211 1.00453 3.62464C1.00453 5.3337 1.87826 6.84112 3.19366 7.72445C2.38714 7.69565 1.62862 7.47481 0.966125 7.10996C0.966125 7.12916 0.966125 7.14837 0.966125 7.17717C0.966125 9.55833 2.66558 11.5554 4.91232 12.0067C4.49945 12.1219 4.06739 12.1795 3.61612 12.1795C3.29927 12.1795 2.99203 12.1507 2.69438 12.0931C3.31848 14.0518 5.14275 15.4728 7.29347 15.5112C5.60362 16.8362 3.4817 17.6235 1.17736 17.6235C0.783698 17.6235 0.390039 17.6043 0.00598145 17.5563C2.17591 18.9389 4.76829 19.7551 7.54311 19.7551Z",fill:"white"})});var n1=require("react/jsx-runtime"),E4=({style:l,...e})=>(0,n1.jsxs)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...l},...e,children:[(0,n1.jsx)("g",{"clip-path":"url(#clip0)",children:(0,n1.jsx)("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#ffffff"})}),(0,n1.jsx)("defs",{children:(0,n1.jsx)("clipPath",{id:"clip0",children:(0,n1.jsx)("rect",{width:"71",height:"55",fill:"white"})})})]});var d1=require("react/jsx-runtime"),A4=({style:l,...e})=>(0,d1.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...l},...e,children:[(0,d1.jsx)("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),(0,d1.jsx)("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),(0,d1.jsx)("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),(0,d1.jsx)("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});var N=require("react/jsx-runtime"),_4=()=>{let{initLoginWithOAuth:l}=Z();return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(T3,{children:[(0,N.jsx)(I3,{onClick:()=>{l("google")},children:(0,N.jsx)(A4,{})}),(0,N.jsx)(P3,{onClick:()=>{l("twitter")},children:(0,N.jsx)(x4,{})}),(0,N.jsx)(S3,{onClick:()=>{l("discord")},children:(0,N.jsx)(E4,{})})]}),(0,N.jsx)(_3,{children:(0,N.jsx)("span",{children:"You\u2019ll be able to connect a wallet later."})})]})},_3=y1.default.div`
|
|
203
203
|
font-size: 13px;
|
|
204
204
|
color: #6b7280;
|
|
205
205
|
`,T3=y1.default.div`
|
|
@@ -260,7 +260,7 @@ Resources:
|
|
|
260
260
|
@media (max-width: 440px) {
|
|
261
261
|
height: 68px;
|
|
262
262
|
}
|
|
263
|
-
`;var m=require("react/jsx-runtime");var S4=()=>{let[l,e]=(0,e2.useState)(0),{ready:a,authenticated:i,user:o}=E(),{navigate:C,showSocials:
|
|
263
|
+
`;var m=require("react/jsx-runtime");var S4=()=>{let[l,e]=(0,e2.useState)(0),{ready:a,authenticated:i,user:o}=E(),{navigate:C,showSocials:d}=u();(0,e2.useEffect)(()=>{var A,s,g,H,W;let h=(o==null?void 0:o.google)||(o==null?void 0:o.twitter)||(o==null?void 0:o.discord),M=(o==null?void 0:o.google)&&(o==null?void 0:o.twitter)&&(o==null?void 0:o.discord);a&&i&&(h?(A=o.wallet)!=null&&A.address||C("LANDING"):((s=o==null?void 0:o.email)==null?void 0:s.address)&&!((g=o.wallet)!=null&&g.address)?C("CONNECT_WALLET_OPTIONAL"):((H=o==null?void 0:o.wallet)==null?void 0:H.address)&&!((W=o.email)!=null&&W.address)?C("CONNECT_EMAIL_OPTIONAL"):M&&(console.error("Launched modal, but nothing left to connect."),C("FULLY_LINKED_SCREEN")))},[]);let p=l==0,c=l==1,b=l==2;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(P,{},"header"),(0,m.jsxs)(R3,{children:[(0,m.jsx)(t2,{children:(0,m.jsx)("h2",{children:"Connect with"})}),(0,m.jsxs)(N2,{active:p,onClick:()=>{p||e(0)},children:[(0,m.jsx)(t2,{active:p,children:(0,m.jsx)("h3",{children:"Wallet"})}),p?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(J1,{}),(0,m.jsx)(X1,{})]}):null]}),(0,m.jsxs)(N2,{active:c,onClick:()=>{c||e(1)},children:[(0,m.jsx)(t2,{active:c,children:(0,m.jsx)("h3",{children:"Email"})}),c?(0,m.jsx)(Q1,{}):null]}),d&&(0,m.jsxs)(N2,{active:b,onClick:()=>{b||e(2)},children:[(0,m.jsx)(t2,{active:b,children:(0,m.jsx)("h3",{children:"Socials"})}),b?(0,m.jsx)(_4,{}):null]})]}),(0,m.jsx)(X,{protectedByPrivy:!0})]})},R3=l2.default.div`
|
|
264
264
|
display: flex;
|
|
265
265
|
flex-direction: column;
|
|
266
266
|
align-items: flex-start;
|
|
@@ -294,7 +294,7 @@ Resources:
|
|
|
294
294
|
border-radius: 10px;
|
|
295
295
|
|
|
296
296
|
cursor: ${l=>l.active?"inherit":"pointer"};
|
|
297
|
-
`;var s1=require("react");var P1=k(require("styled-components"));var _=require("react/jsx-runtime"),W3=1400;var I4=()=>{var D;let{navigate:l,app:e}=u(),{closePrivyModal:a,resendEmailCode:i,getAuthMeta:o,loginWithCode:C}=Z(),{authenticated:
|
|
297
|
+
`;var s1=require("react");var P1=k(require("styled-components"));var _=require("react/jsx-runtime"),W3=1400;var I4=()=>{var D;let{navigate:l,app:e}=u(),{closePrivyModal:a,resendEmailCode:i,getAuthMeta:o,loginWithCode:C}=Z(),{authenticated:d,user:p}=E(),[c,b]=(0,s1.useState)(["","","","",""]),[h,M]=(0,s1.useState)(!1),[A,s]=(0,s1.useState)(null),[g,H]=(0,s1.useState)(null);(0,s1.useEffect)(()=>{if(d&&h){let T=setTimeout(()=>{var y;(y=p==null?void 0:p.wallet)!=null&&y.address?a():l("CONNECT_WALLET_OPTIONAL")},C1);return()=>clearTimeout(T)}},[d,h,p]),(0,s1.useEffect)(()=>{if(A&&g===0){let T=setTimeout(()=>{b(["","","","",""]),s(null);let y=document.querySelector("input[name=code-0]");y==null||y.focus()},W3);return()=>clearTimeout(T)}},[A]);let W=T=>{var H2;let y=T.currentTarget.value.replace(" ","");if(y==="")return;if(isNaN(Number(y))){s("Code should be numeric"),H(1);return}s(null),H(null);let K=Number((H2=T.currentTarget.name)==null?void 0:H2.charAt(5)),n2=[...y||[""]].slice(0,5-K),s2=[...c.slice(0,K),...n2,...c.slice(K+n2.length)];b(s2);let i3=n2.length,V2=Math.min(Math.max(K+i3,0),4);if(!isNaN(Number(T.currentTarget.value))){let J=document.querySelector(`input[name=code-${V2}]`);J==null||J.focus()}if(s2.every(J=>J&&!isNaN(+J))){let J=document.querySelector(`input[name=code-${V2}]`);J==null||J.blur(),C(s2.join("")).then(()=>M(!0)).catch(c2=>{(c2==null?void 0:c2.status)===422?s("Invalid or expired verification code"):s("Issue verifying code"),H(0)})}T.preventDefault()},W1=T=>{g===1&&(s(null),H(null));let y=[...c.slice(0,T),"",...c.slice(T+1)];if(b(y),T>0){let K=document.querySelector(`input[name=code-${T-1}]`);K==null||K.focus()}};return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(P,{},"header"),(0,_.jsxs)(N3,{children:[(0,_.jsxs)("p",{children:["Please check ",(D=o())==null?void 0:D.email," for an email from ",(e==null?void 0:e.name)||"privy.io"," and enter your code below."]}),(0,_.jsxs)(O3,{children:[(0,_.jsx)("div",{children:c.map((T,y)=>(0,_.jsx)("input",{name:`code-${y}`,type:"text",value:c[y],onChange:W,onKeyUp:K=>{K.key==="Backspace"&&W1(y)},inputMode:"numeric",autoFocus:y===0,pattern:"[0-9]",className:`${h?"success":""} ${A?"fail":""}`,autoComplete:"one-time-code"},y))}),(0,_.jsx)(D3,{fail:!!A,success:h,children:(0,_.jsx)("span",{children:A||(h?"Success!":"")})})]}),(0,_.jsxs)(U3,{children:[(0,_.jsx)("span",{children:"Didn\u2019t get an email?"}),(0,_.jsx)("button",{onClick:i,children:"Resend Code"})]})]}),(0,_.jsx)(X,{protectedByPrivy:!0})]})},N3=P1.default.div`
|
|
298
298
|
display: flex;
|
|
299
299
|
flex-direction: column;
|
|
300
300
|
align-items: flex-start;
|
|
@@ -569,7 +569,7 @@ Resources:
|
|
|
569
569
|
|
|
570
570
|
border: 1px solid #e0e7ff;
|
|
571
571
|
border-radius: var(--border-radius-sm);
|
|
572
|
-
`;var f1=require("react");var S1=k(require("styled-components"));var I=require("react/jsx-runtime"),D2=2,q4={metamask:{name:"MetaMask",component:e1},coinbase_wallet:{name:"Coinbase Wallet",component:Z1},wallet_connect:{name:"WalletConnect",component:K1}},Y4=()=>{var W1;let[l,e]=(0,f1.useState)(!1),[a,i]=(0,f1.useState)(void 0),{navigate:o,navigateBack:C}=u(),{getAuthMeta:
|
|
572
|
+
`;var f1=require("react");var S1=k(require("styled-components"));var I=require("react/jsx-runtime"),D2=2,q4={metamask:{name:"MetaMask",component:e1},coinbase_wallet:{name:"Coinbase Wallet",component:Z1},wallet_connect:{name:"WalletConnect",component:K1}},Y4=()=>{var W1;let[l,e]=(0,f1.useState)(!1),[a,i]=(0,f1.useState)(void 0),{navigate:o,navigateBack:C}=u(),{getAuthMeta:d,closePrivyModal:p,loginWithWallet:c}=Z(),[b,h]=(0,f1.useState)(0),{user:M}=E();(0,f1.useEffect)(()=>{i(void 0),c().then(()=>e(!0)).catch(D=>{console.error(D),(D==null?void 0:D.status)===422?i(M2.ERROR_USER_EXISTS):D instanceof g1&&!D.details.default?i(D.details):i(M2.ERROR_WALLET_CONNECTION)})},[b]),(0,f1.useEffect)(()=>{var D;if((D=M==null?void 0:M.wallet)!=null&&D.address){e(!0);let T=setTimeout(()=>{var y;(y=M==null?void 0:M.email)!=null&&y.address?p():o("CONNECT_EMAIL_OPTIONAL")},C1);return()=>clearTimeout(T)}},[M]);let A=((W1=d())==null?void 0:W1.wallet)||"metamask",s=q4[A].name,g=q4[A].component,H=l?`Successfully connected with ${s}`:a?a.message:`Waiting for ${s}`,W="";if(l)W="You\u2019re good to go!";else if(b>=D2&&a)W="Unable to connect wallet";else if(a)W=a.detail;else switch(A){case"wallet_connect":W="Open your mobile wallet app to continue";break;default:W="Don\u2019t see your wallet modal? Check your other browser windows."}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(k4,{backFn:C}),(0,I.jsxs)(Q3,{children:[(0,I.jsx)(e5,{children:(0,I.jsxs)("div",{children:[(0,I.jsx)(y4,{success:l,fail:!!a}),(0,I.jsx)(g,{style:{width:"38px",height:"38px"}})]})}),(0,I.jsxs)(t5,{children:[(0,I.jsx)("h3",{children:H}),(0,I.jsx)("p",{children:W})]}),l?null:(0,I.jsx)(l5,{onClick:()=>{h(b+1),i(void 0)},visible:(a==null?void 0:a.retryable)&&b<D2,disabled:!((a==null?void 0:a.retryable)&&b<D2),children:"Retry"})]}),(0,I.jsx)(X,{})]})},Q3=S1.default.div`
|
|
573
573
|
display: flex;
|
|
574
574
|
flex-direction: column;
|
|
575
575
|
align-items: center;
|
|
@@ -646,7 +646,7 @@ Resources:
|
|
|
646
646
|
color: var(--primary-color);
|
|
647
647
|
background-color: #696efd1a;
|
|
648
648
|
border-radius: var(--border-radius-sm);
|
|
649
|
-
`;var R1=k(require("styled-components"));var v=require("react/jsx-runtime"),J4=()=>{let{navigate:l}=u();return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(P,{},"header"),(0,v.jsx)(C5,{children:(0,v.jsxs)(n5,{children:[(0,v.jsxs)(s5,{children:[(0,v.jsx)("h3",{children:"Create a wallet with Coinbase"}),(0,v.jsx)(i2,{style:{width:"152px",height:"152px"}})]}),(0,v.jsxs)(h1,{children:[(0,v.jsx)(V,{children:"Open the camera on your phone"}),(0,v.jsx)(i1,{}),(0,v.jsx)(V,{children:"Scan the QR code with your camera"}),(0,v.jsx)(i1,{}),(0,v.jsx)(V,{children:"Click the link and download the app"})]}),(0,v.jsx)(
|
|
649
|
+
`;var R1=k(require("styled-components"));var v=require("react/jsx-runtime"),J4=()=>{let{navigate:l}=u();return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(P,{},"header"),(0,v.jsx)(C5,{children:(0,v.jsxs)(n5,{children:[(0,v.jsxs)(s5,{children:[(0,v.jsx)("h3",{children:"Create a wallet with Coinbase"}),(0,v.jsx)(i2,{style:{width:"152px",height:"152px"}})]}),(0,v.jsxs)(h1,{children:[(0,v.jsx)(V,{children:"Open the camera on your phone"}),(0,v.jsx)(i1,{}),(0,v.jsx)(V,{children:"Scan the QR code with your camera"}),(0,v.jsx)(i1,{}),(0,v.jsx)(V,{children:"Click the link and download the app"})]}),(0,v.jsx)(c5,{onClick:()=>l("LANDING"),children:"Done! I have my wallet"})]})}),(0,v.jsxs)(p1,{children:[(0,v.jsx)("span",{children:"Still not sure? "}),(0,v.jsx)("a",{target:"_blank",href:"https://join.tell.ie/blog/explaining-web3-wallets",children:"Learn more"})]})]})},C5=R1.default.div`
|
|
650
650
|
display: flex;
|
|
651
651
|
flex-grow: 1;
|
|
652
652
|
flex-direction: column;
|
|
@@ -671,14 +671,14 @@ Resources:
|
|
|
671
671
|
align-items: center;
|
|
672
672
|
justify-content: center;
|
|
673
673
|
width: 100%;
|
|
674
|
-
`,
|
|
674
|
+
`,c5=R1.default.button`
|
|
675
675
|
padding: 12px 16px;
|
|
676
676
|
font-weight: 500;
|
|
677
677
|
text-align: center;
|
|
678
678
|
color: var(--primary-color);
|
|
679
679
|
background-color: #696efd1a;
|
|
680
680
|
border-radius: var(--border-radius-sm);
|
|
681
|
-
`;var X4=require("react");var U2=k(require("styled-components"));var o1=require("react/jsx-runtime"),Q4=()=>{let{closePrivyModal:l}=Z(),{authenticated:e,ready:a}=E(),{navigate:i}=u();return(0,X4.useEffect)(()=>{a&&!e&&i("LANDING")},[e,a]),(0,o1.jsxs)(o1.Fragment,{children:[(0,o1.jsx)(P,{},"header"),(0,o1.jsxs)(
|
|
681
|
+
`;var X4=require("react");var U2=k(require("styled-components"));var o1=require("react/jsx-runtime"),Q4=()=>{let{closePrivyModal:l}=Z(),{authenticated:e,ready:a}=E(),{navigate:i}=u();return(0,X4.useEffect)(()=>{a&&!e&&i("LANDING")},[e,a]),(0,o1.jsxs)(o1.Fragment,{children:[(0,o1.jsx)(P,{},"header"),(0,o1.jsxs)(d5,{children:[(0,o1.jsx)("h3",{children:"You're all logged in!"}),(0,o1.jsx)(p5,{onClick:()=>{l()},children:"Go back to the app"})]})]})},d5=U2.default.div`
|
|
682
682
|
display: flex;
|
|
683
683
|
flex-direction: column;
|
|
684
684
|
align-items: flex-start;
|
|
@@ -824,4 +824,4 @@ Resources:
|
|
|
824
824
|
border-radius: 24px 24px 0 0;
|
|
825
825
|
height: auto;
|
|
826
826
|
}
|
|
827
|
-
`;var t1=require("react/jsx-runtime");function m5(l){return typeof l=="string"&&l.length===25}var a3=l=>{if(!m5(l.appId))throw new f("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let i=new j1({appId:l.appId,apiURL:z2});a(i)},[]),e===null?(0,t1.jsx)(t1.Fragment,{}):(0,t1.jsx)(b5,{...l,client:e})},b5=l=>{let e=l.client,[a,i]=(0,Q.useState)(!1),[o,C]=(0,Q.useState)(!1),[
|
|
827
|
+
`;var t1=require("react/jsx-runtime");function m5(l){return typeof l=="string"&&l.length===25}var a3=l=>{if(!m5(l.appId))throw new f("Cannot initialize the Privy provider with an invalid Privy app ID");let[e,a]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let i=new j1({appId:l.appId,apiURL:z2});a(i)},[]),e===null?(0,t1.jsx)(t1.Fragment,{}):(0,t1.jsx)(b5,{...l,client:e})},b5=l=>{let e=l.client,[a,i]=(0,Q.useState)(!1),[o,C]=(0,Q.useState)(!1),[d,p]=(0,Q.useState)(!1),[c,b]=(0,Q.useState)(null),h=async()=>{let s=new URLSearchParams(window.location.search),g=s.get("privy_oauth_code"),H=s.get("privy_oauth_state"),W=s.get("privy_oauth_provider");g&&H&&W&&(e.startAuthFlow(new x1(W,g,H)),await e.authenticate())};(0,Q.useEffect)(()=>{async function s(){await h();let g=await e.getAuthenticatedUser();p(!!g),b(g),C(!0)}s()},[]),(0,Q.useEffect)(()=>{o&&d&&c===null&&e.getAuthenticatedUser().then(b)},[o,d,c]);let M={ready:o,authenticated:d,user:c,linkWallet:()=>{i(!0)},linkEmail:()=>{i(!0)},login:()=>{i(!0)},logout:async()=>{await e.logout(),b(null),p(!1),i(!1)},getAccessToken:()=>e.getAccessToken(),getEthereumProvider:()=>e.connector.getEthereumProvider(),getEthersProvider:()=>new l3.Web3Provider(new k1(e.connector.getEthereumProvider())),getWeb3jsProvider:()=>new V1(e.connector.getEthereumProvider())},A={showPrivyModal:a,getAuthMeta:()=>{var s;return(s=e.authFlow)==null?void 0:s.meta},closePrivyModal:()=>{var s;o&&d&&c&&((s=l.onSuccess)==null||s.call(l,c)),i(!1)},initLoginWithWallet:s=>{s||(s="metamask"),n4(s),e.connector.walletType=s,e.startAuthFlow(new w1(e.connector))},initLoginWithOAuth:async s=>{e.startAuthFlow(new x1(s));let g=await e.authFlow.getAuthorizationUrl();g&&g.url&&window.location.assign(g.url)},loginWithWallet:async()=>{if(!(e.authFlow instanceof w1))throw new f("Must initialize SIWE flow first.");let s=await e.authenticate();b(s||c||null),p(!0)},loginWithEmail:async s=>{let g=new v1(s);e.startAuthFlow(g),await g.sendCodeEmail()},resendEmailCode:async()=>{var s;await((s=e.authFlow)==null?void 0:s.sendCodeEmail())},loginWithCode:async s=>{if(!(e.authFlow instanceof v1))throw new f("Must initialize email code flow first");e.authFlow.meta.emailCode=s.trim();let g=await e.authenticate();b(g||c||null),p(!0)}};return(0,t1.jsxs)(v2.Provider,{value:M,children:[l.children,(0,t1.jsx)(x2.Provider,{value:A,children:(0,t1.jsx)(p4,{client:e,showSocials:l.showSocials||!1,children:(0,t1.jsx)(e3,{})})})]})};0&&(module.exports={PrivyProvider,usePrivy});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privy-io/react-auth",
|
|
3
|
-
"version": "1.4.0-beta.
|
|
3
|
+
"version": "1.4.0-beta.3",
|
|
4
4
|
"description": "React client for the Privy Auth API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"exports": "./dist/index.js",
|
|
21
|
-
"main": "./dist/index
|
|
21
|
+
"main": "./dist/index",
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
|
+
"typings": "dist/index",
|
|
23
24
|
"files": [
|
|
24
25
|
"dist/**/*",
|
|
25
26
|
"LICENSE",
|