@privy-io/expo 0.78.1 → 0.78.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cards.js +2 -2
- package/dist/{chunk-WCCFBSK7.js → chunk-2INMFYSV.js} +1 -1
- package/dist/chunk-APBCP6B2.js +12 -0
- package/dist/{chunk-XPHUZG6U.js → chunk-MFUJ4B5H.js} +1 -1
- package/dist/esm/cards.js +1 -1
- package/dist/esm/{chunk-WCCFBSK7.js → chunk-2INMFYSV.js} +1 -1
- package/dist/esm/chunk-APBCP6B2.js +12 -0
- package/dist/esm/{chunk-XPHUZG6U.js → chunk-MFUJ4B5H.js} +1 -1
- package/dist/esm/extended-chains.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/passkey.js +1 -1
- package/dist/esm/smart-wallets.js +1 -1
- package/dist/esm/ui.js +1 -1
- package/dist/extended-chains.js +1 -1
- package/dist/index.d.ts +68 -31
- package/dist/index.js +1 -1
- package/dist/passkey.js +1 -1
- package/dist/smart-wallets.js +1 -1
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-7VW6NBHO.js +0 -12
- package/dist/esm/chunk-7VW6NBHO.js +0 -12
package/dist/esm/passkey.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as K,b as N,c as V,d as D,e as F,f as T,g as M,h as j}from"./chunk-QSWCX5XI.js";import{
|
|
1
|
+
import{a as K,b as N,c as V,d as D,e as F,f as T,g as M,h as j}from"./chunk-QSWCX5XI.js";import{U as _,V as x,W as b,a as w,d as g,h,pa as P}from"./chunk-APBCP6B2.js";import"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{e as p}from"./chunk-C5WYSLQF.js";import{useCallback as W,useContext as R}from"react";import{PrivyClientError as v}from"@privy-io/js-sdk-core";var Y=e=>{let{client:a,passkeyState:d,setPasskeyState:s}=R(P),c=W(o=>{var n;let t=h(o);return s({status:"error",error:t}),(n=e==null?void 0:e.onError)==null||n.call(e,t),t},[e==null?void 0:e.onError]);return{linkWithPasskey:W(n=>p(void 0,[n],function*({relyingParty:o,extra_options:t}){var u;try{if(!g())throw new v({code:"attempted_link_passkey_before_logged_in",error:"Must be logged in to link a passkey."});s({status:"generating-challenege"});let{options:k}=yield a.auth.passkey.generateRegistrationOptions(o);s({status:"awaiting-passkey"});let y=yield _(b(k),t);s({status:"submitting-response"});let{user:m}=yield a.auth.passkey.linkWithPasskey(y,o);return s({status:"done"}),(u=e==null?void 0:e.onSuccess)==null||u.call(e,m),m}catch(r){throw c(r)}}),[a,c,e==null?void 0:e.onSuccess]),state:d}};import{useCallback as O,useContext as H}from"react";import{PrivyClientError as I}from"@privy-io/js-sdk-core";var ie=e=>{let{client:a,passkeyState:d,setPasskeyState:s}=H(P),c=O(o=>{var n;let t=h(o);return s({status:"error",error:t}),(n=e==null?void 0:e.onError)==null||n.call(e,t),t},[e==null?void 0:e.onError]);return{loginWithPasskey:O(n=>p(void 0,[n],function*({relyingParty:o,extra_options:t}){var u,r,k,y;try{if(g())throw new I({code:"attempted_login_with_passkey_while_already_logged_in",error:"Already logged in, use `useLinkWithPasskey` if you are trying to link a passkey to an existing account"});s({status:"generating-challenege"});let{options:i}=yield a.auth.passkey.generateAuthenticationOptions(o);s({status:"awaiting-passkey"});let f=yield x({challenge:i.challenge,rpId:i.rp_id,extensions:{appid:(u=i.extensions)==null?void 0:u.app_id,credProps:(r=i.extensions)==null?void 0:r.cred_props,hmacCreateSecret:(k=i.extensions)==null?void 0:k.hmac_create_secret},timeout:i.timeout,allowCredentials:i.allow_credentials,userVerification:i.user_verification},t);s({status:"submitting-response"});let l=w(),C=yield a.auth.passkey.loginWithPasskey(f,i.challenge,o,{embedded:l==null?void 0:l.embedded});return s({status:"done"}),(y=e==null?void 0:e.onSuccess)==null||y.call(e,C.user,C.is_new_user),C.user}catch(m){throw c(m)}}),[a,c,e==null?void 0:e.onSuccess]),state:d}};import{useCallback as U,useContext as L,useEffect as A,useRef as q}from"react";import{PrivyClientError as J}from"@privy-io/js-sdk-core";var ge=e=>{let{client:a,passkeyState:d,setPasskeyState:s}=L(P),c=q(e);A(()=>{c.current=e},[e]);let S=U(t=>{var u,r;let n=h(t);return s({status:"error",error:n}),(r=(u=c.current)==null?void 0:u.onError)==null||r.call(u,n),n},[s]);return{signupWithPasskey:U(u=>p(void 0,[u],function*({relyingParty:t,extra_options:n}){var r,k;try{if(g())throw new J({code:"attempted_login_with_passkey_while_already_logged_in",error:"Already logged in, use `useLinkWithPasskey` if you are trying to link a passkey to an existing account"});s({status:"generating-challenege"});let{options:m}=yield a.auth.passkey.generateSignupOptions(t);s({status:"awaiting-passkey"});let i=yield _(b(m),n);s({status:"submitting-response"});let f=w(),l=yield a.auth.passkey.signupWithPasskey(i,t,{embedded:f==null?void 0:f.embedded});return s({status:"done"}),(k=(r=c.current)==null?void 0:r.onSuccess)==null||k.call(r,l.user,l.is_new_user),{user:l.user}}catch(y){throw S(y)}}),[a.auth.passkey,S,s]),state:d}};export{M as hasError,K as isConnected,V as isConnecting,T as isCreating,D as isDisconnected,F as isNotCreated,N as isReconnecting,j as needsRecovery,Y as useLinkWithPasskey,ie as useLoginWithPasskey,ge as useSignupWithPasskey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as L}from"./chunk-QSWCX5XI.js";import{b as k,c as N,d as g,f as v,k as P,o as U,pa as S}from"./chunk-APBCP6B2.js";import"./chunk-F7DR7TVR.js";import"./chunk-3HF374LL.js";import{a as _,b as I,c as M,e as d}from"./chunk-C5WYSLQF.js";import p,{createContext as T,useCallback as et,useContext as f,useEffect as E,useState as D}from"react";import{getDataSuffixPlugin as F,getUserSmartWallet as h,PrivyClientError as u}from"@privy-io/js-sdk-core";import{createPublicClient as H,http as X}from"viem";import{getJsonRpcEndpointFromChain as j,getUserSmartWallet as q,PrivyClientError as O}from"@privy-io/js-sdk-core";import{signerToSmartAccountClient as J}from"@privy-io/js-sdk-core/smart-wallets";var x=w=>d(void 0,[w],function*({chain:t,privyAppId:e,user:a,embeddedWallet:r,smartWalletsConfig:n,client:i,dataSuffix:c}){if(!(n!=null&&n.enabled)||!r||!L(r))return;let s=yield i.embeddedWallet.getEthereumProvider({wallet:r.account,entropyId:r.account.address,entropyIdVerifier:"ethereum-address-verifier",onMfaEnrollmentRequired:y=>d(void 0,null,function*(){return yield k()(y)}),onMfaVerificationRequired:y=>d(void 0,null,function*(){return yield N()(y)})}),o=n==null?void 0:n.configured_networks.find(y=>y.chain_id===`eip155:${t.id}`);if(!o)throw new O({code:"chain_not_supported",error:`The chain ${t.name} (eip155:${t.id}) must be configured in the smart wallet configuration in your dashboard`});let l=q(a),C=l?l.smart_wallet_type:n.smart_wallet_type,W=l?l.smart_wallet_version:n.smart_wallet_version,V=j(t,{rpcUrls:[]},e),Y=H({chain:t,transport:X(V)}),A=yield J({owner:s,smartWalletType:C,smartWalletVersion:W,chain:t,publicClient:Y,paymasterContext:tt(o.paymaster_url,o.paymaster_context),bundlerUrl:o.bundler_url,paymasterUrl:o.paymaster_url});if(!A)throw new O({code:"smart_wallet_client_error",error:`Failed to create smart wallet client for chain ${t.name} (eip155:${t.id})`});return K(A,c)});function K(t,e){return e?t.extend(a=>({sendTransaction:r=>a.sendTransaction(M(I({},r),{dataSuffix:e}))})):t}var z=/paymaster\.biconomy\.io\/api/i;function Q(t){return z.test(t)}var Z={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}},tt=(t,e)=>{if(t&&Q(t))return Z;if(e&&e.policy_id)return{policyId:e.policy_id}};var R=3,rt=500,nt=({children:t})=>p.createElement(lt,null,p.createElement(ot,null,p.createElement(st,null,t))),$=T({config:void 0}),b=()=>{let{config:t}=f($);return{config:t}},G=T({smartWalletClient:void 0}),at=()=>{let{smartWalletClient:t}=f(G);return{smartWalletClient:t}},B=T({client:void 0}),it=()=>{let{client:t}=f(B),e=ct();return{client:t,getClientForChain:e}},lt=({children:t})=>{let[e,a]=D(void 0),r=U();return E(()=>{!e&&r&&(()=>d(void 0,null,function*(){try{if(!r){console.warn("No client found");return}let i=yield r.app.getSmartWalletConfig();a(i)}catch(i){console.warn("Error generating smart wallet config: ",i)}}))()},[r,e]),p.createElement($.Provider,{value:{config:e}},t)},ot=({children:t})=>{let{config:e}=b(),{client:a,wallet:r}=f(S),n=v(),[i,c]=D();return E(()=>{(()=>d(void 0,null,function*(){var l;if(!n&&i&&c(void 0),!(e!=null&&e.enabled)||!n||r.status!=="connected"||n&&i&&r.status==="connected")return;let s=a.embeddedWallet.chains.find(C=>e.configured_networks.map(W=>W.chain_id).includes(`eip155:${C.id}`));if(!s)throw new u({error:"Could not find smart wallets chain configurations for any Privy client configured chains. Please configure smart wallets for your chains in the Privy dashboard.",code:"chain_not_supported"});let o=yield x({chain:s,privyAppId:a.app.appId,user:n,embeddedWallet:r,smartWalletsConfig:e,client:a,dataSuffix:(l=F(a.plugins))==null?void 0:l.suffix});if(!o)throw new u({error:"Could not create smart wallet client",code:"smart_wallet_client_error"});c(o)}))()},[!!(e!=null&&e.enabled),!!a,!!n,r.status]),p.createElement(G.Provider,{value:{smartWalletClient:i}},t)},st=({children:t})=>{let{client:e,wallet:a}=f(S),r=v(),{smartWalletClient:n}=at(),{config:i}=b();return E(()=>{let c=!1;return(()=>d(void 0,null,function*(){var m;if(!(!n||!r||h(r)||!(i!=null&&i.enabled)||a.status!=="connected"))for(let s=0;s<R;s++){if(c||h((m=g())!=null?m:r))return;let o=!1;for(let l=0;l<5;l++){if(c)return;if(yield e.embeddedWallet.ping(rt)){o=!0;break}yield P(200*_(2,l))}if(o)try{let{message:l}=yield e.auth.smartWallet.init({address:n.account.address,chainId:`eip155:${n.chain.id}`}),C=yield n.signMessage({message:l});yield e.auth.smartWallet.link(l,C,i.smart_wallet_type,i.smart_wallet_version);return}catch(l){s===R-1?console.error("Error creating smart wallet:",l):yield P(500*_(2,s))}}}))(),()=>{c=!0}},[!!n,!!r,!!h(r),i,a.status]),p.createElement(B.Provider,{value:{client:h(r)?n:void 0}},t)},ct=()=>{let{client:t,wallet:e}=f(S),{config:a}=b();return et(n=>d(void 0,[n],function*({chainId:r}){var s;let i=g();if(!i)throw new u({error:"Must be logged in to get a smart wallet client",code:"smart_wallet_client_error"});if(!a||!a.enabled)throw new u({error:"Must have smart wallets enabled to get a smart wallet client",code:"smart_wallet_client_error"});let w=t.embeddedWallet.chains.find(o=>o.id===r);if(!w)throw new u({error:`Could not find chain with id: ${r}`,code:"chain_not_supported"});let m=yield x({chain:w,privyAppId:t.app.appId,user:i,embeddedWallet:e,smartWalletsConfig:a,client:t,dataSuffix:(s=F(t.plugins))==null?void 0:s.suffix});if(!m)throw new u({error:`Could not create smart wallet client for chain ${r}`,code:"smart_wallet_client_error"});return m}),[a,e,t])};export{nt as SmartWalletsProvider,it as useSmartWallets};
|