@privy-io/expo 0.72.0 → 0.73.0
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/chunk-P6K2IBL3.js +12 -0
- package/dist/chunk-SIDTGGPG.js +1 -0
- package/dist/esm/chunk-P6K2IBL3.js +12 -0
- package/dist/esm/chunk-SIDTGGPG.js +1 -0
- 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 +13 -3
- package/dist/index.js +1 -1
- package/dist/passkey.js +1 -1
- package/dist/smart-wallets.js +1 -1
- package/dist/ui.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-F5FQ4MOJ.js +0 -1
- package/dist/chunk-HUHULZRX.js +0 -1
- package/dist/esm/chunk-F5FQ4MOJ.js +0 -1
- package/dist/esm/chunk-HUHULZRX.js +0 -1
package/dist/extended-chains.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkP6K2IBL3js = require('./chunk-P6K2IBL3.js');var _chunkK5SPDXVFjs = require('./chunk-K5SPDXVF.js');var _react = require('react');var _jssdkcore = require('@privy-io/js-sdk-core');var f=()=>{let e=_chunkP6K2IBL3js.m.call(void 0, );return _react.useMemo.call(void 0, ()=>({createWallet(n){return _chunkK5SPDXVFjs.e.call(void 0, this,null,function*(){let s=yield _jssdkcore.create.call(void 0, e,{request:{chain_type:n.chainType}}),{user:o}=yield e.user.get();return{user:o,wallet:s}})}}),[e])};var C=()=>{let e=_chunkP6K2IBL3js.m.call(void 0, );return _react.useMemo.call(void 0, ()=>({signRawHash(k){return _chunkK5SPDXVFjs.e.call(void 0, this,arguments,function*({address:n,chainType:s,hash:o}){let l=_chunkP6K2IBL3js.b.call(void 0, );if(!l)throw new (0, _jssdkcore.PrivyClientError)({code:"embedded_wallet_before_logged_in",error:"User must be authenticated before signing a raw hash"});let p=l.linked_accounts.filter(_jssdkcore.isEmbeddedWalletAccount).filter(_jssdkcore.isUnifiedWallet).filter(t=>t.chain_type===s).find(t=>t.address===n);if(!p)throw new (0, _jssdkcore.PrivyClientError)({code:"embedded_wallet_does_not_exist",error:"No embedded wallet found for the given address and chain type"});let r=yield _jssdkcore.rawSign.call(void 0, e,(...t)=>e.embeddedWallet.signWithUserSigner(...t),{wallet_id:p.id,params:{hash:o}});if(r.data&&"signature"in r.data&&r.data.encoding==="hex")return{signature:r.data.signature};throw new Error("Failed to sign")})}}),[e])};exports.useCreateWallet = f; exports.useSignRawHash = C;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Privy from '@privy-io/js-sdk-core';
|
|
2
|
-
import Privy__default, { EmbeddedWalletConfig, DepositConfig, GenerateDepositAddressInput, DepositAddressQuote, GetDepositInput, DepositAddressOrder, WaitForDepositInput, DepositAddressPollingResult, WaitForCompletionInput, UnsignedTransactionRequest, OnNeedsRecovery, MfaMethod, SessionSignerInput, PrivyEmbeddedWalletProvider, PrivyEmbeddedSolanaWalletProvider, EmbeddedBitcoinWalletProvider, GenerateAuthorizationSignatureInput, GenerateAuthorizationSignatureOutput, Storage, Chain, OAuthProviderID, Logger } from '@privy-io/js-sdk-core';
|
|
2
|
+
import Privy__default, { EmbeddedWalletConfig, DepositConfig, GenerateDepositAddressInput, DepositAddressQuote, GetDepositInput, DepositAddressOrder, WaitForDepositInput, DepositAddressPollingResult, WaitForCompletionInput, UnsignedTransactionRequest, OnNeedsRecovery, MfaMethod, SessionSignerInput, PrivyEmbeddedWalletProvider, PrivyEmbeddedSolanaWalletProvider, EmbeddedBitcoinWalletProvider, GenerateAuthorizationSignatureInput, GenerateAuthorizationSignatureOutput, Storage, Chain, OAuthProviderID, PrivyPlugin, Logger } from '@privy-io/js-sdk-core';
|
|
3
3
|
export * from '@privy-io/js-sdk-core';
|
|
4
|
-
export { DepositAddressOrder, DepositAddressPollingResult, DepositAddressQuote, DepositConfig, GenerateDepositAddressInput, GetDepositInput, WaitForCompletionInput, WaitForDepositInput } from '@privy-io/js-sdk-core';
|
|
4
|
+
export { DataSuffixPlugin, DepositAddressOrder, DepositAddressPollingResult, DepositAddressQuote, DepositConfig, GenerateDepositAddressInput, GetDepositInput, WaitForCompletionInput, WaitForDepositInput, createDataSuffixPlugin as dataSuffix } from '@privy-io/js-sdk-core';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { E as ErrorCallback, A as AuthLinkSuccessCallback, G as GenerateSiweMessage, S as SiweFlowState, a as AuthSuccessCallback, O as OtpLinkHookOptions, b as OtpLinkHookResult, c as OtpLoginHookOptions, d as OtpLoginHookResult, F as FarcasterFlowState, L as LinkFarcasterInput, e as SubmitFarcasterOptions, f as LoginWithFarcasterInput, g as EmbeddedWalletState, P as PublicKeyCredentialRequestOptionsJSON, h as EmbeddedSolanaWalletState, i as OtpFlowState, j as OAuthFlowState, W as WalletRecoveryCallbacks, k as SolanaWalletRecoveryCallbacks, R as RecoveryFlowState, l as PasskeyFlowState } from './types-045de424.js';
|
|
7
7
|
export { Z as CreateEthereumEmbeddedWalletOpts, Y as CreateOrRecoverEmbeddedWalletProps, $ as CreateSolanaEmbeddedWalletOpts, a2 as CustomAuthFlowState, a6 as EmbeddedSolanaWalletActions, a7 as EmbeddedSolanaWalletStatus, q as EmbeddedWallet, a4 as EmbeddedWalletActions, a5 as EmbeddedWalletStatus, o as LinkedAccountWithMetadata, a3 as MfaConfig, N as PrivyAppleOauthAccount, t as PrivyBitcoinSegwitEmbeddedWalletAccount, u as PrivyBitcoinTaprootEmbeddedWalletAccount, X as PrivyCrossAppWalletAccount, Q as PrivyCustomJwtAccount, D as PrivyDiscordOauthAccount, w as PrivyEmailAccount, p as PrivyEmbeddedWalletAccount, y as PrivyEthereumAccount, r as PrivyEthereumEmbeddedWalletAccount, T as PrivyFarcasterAccount, H as PrivyGithubOauthAccount, B as PrivyGoogleOauthAccount, J as PrivyInstagramOauthAccount, n as PrivyLinkedAccount, M as PrivyLinkedInOauthAccount, U as PrivyPasskeyAccount, x as PrivyPhoneAccount, v as PrivySmartWalletAccount, z as PrivySolanaAccount, s as PrivySolanaEmbeddedWalletAccount, I as PrivySpotifyOauthAccount, V as PrivyTelegramAccount, K as PrivyTiktokOauthAccount, C as PrivyTwitterOauthAccount, m as PrivyUser, _ as RecoverEthereumEmbeddedWalletOpts, a0 as RecoverSolanaEmbeddedWalletOpts, a1 as SetRecoveryProps, ae as hasError, a8 as isConnected, aa as isConnecting, ad as isCreating, ab as isDisconnected, ac as isNotCreated, a9 as isReconnecting, af as needsRecovery } from './types-045de424.js';
|
|
@@ -1732,6 +1732,16 @@ type PrivyOptions = {
|
|
|
1732
1732
|
* Privy client ID _(can be found in privy developer dashboard, in the clients section for each app)_
|
|
1733
1733
|
*/
|
|
1734
1734
|
clientId?: string;
|
|
1735
|
+
/**
|
|
1736
|
+
* Plugins that extend Privy client behavior.
|
|
1737
|
+
*
|
|
1738
|
+
* @example
|
|
1739
|
+
* const client = createPrivyClient({
|
|
1740
|
+
* appId: '<your-privy-app-id>',
|
|
1741
|
+
* plugins: [dataSuffix('0x1234')],
|
|
1742
|
+
* });
|
|
1743
|
+
*/
|
|
1744
|
+
plugins?: readonly PrivyPlugin[];
|
|
1735
1745
|
/**
|
|
1736
1746
|
* By default, the Privy SDK will store any persisted state in SecureStorage.
|
|
1737
1747
|
* This behavior can be overridden by defining in a storage prop
|
|
@@ -1804,7 +1814,7 @@ type PrivyOptions = {
|
|
|
1804
1814
|
*
|
|
1805
1815
|
* const token = await privy.getAccessToken();
|
|
1806
1816
|
*/
|
|
1807
|
-
declare const createPrivyClient: ({ appId, clientId, storage, supportedChains, baseUrl, logLevel, logger, sessions, }: PrivyOptions) => Privy__default;
|
|
1817
|
+
declare const createPrivyClient: ({ appId, clientId, storage, supportedChains, baseUrl, logLevel, logger, sessions, plugins, }: PrivyOptions) => Privy__default;
|
|
1808
1818
|
|
|
1809
1819
|
/**
|
|
1810
1820
|
* Hook to migrate wallets for apps moving from on-device to TEEs.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var _chunkSIDTGGPGjs = require('./chunk-SIDTGGPG.js');var _chunkP6K2IBL3js = require('./chunk-P6K2IBL3.js');var _chunkK5SPDXVFjs = require('./chunk-K5SPDXVF.js');var _jssdkcore = require('@privy-io/js-sdk-core'); _createStarExport(_jssdkcore);var _react = require('react'); var _react2 = _interopRequireDefault(_react);var qt=({loading:t,error:e,unauthenticated:o,children:i})=>{let{isReady:u,error:p}=_chunkP6K2IBL3js.$.call(void 0, ),U=_chunkP6K2IBL3js.e.call(void 0, );if(!u)return _react2.default.createElement(_react2.default.Fragment,null,t);if(p&&e){let n=typeof e=="function"?e(p):e;return _react2.default.createElement(_react2.default.Fragment,null,n)}return U?_react2.default.createElement(_react2.default.Fragment,null,i):_react2.default.createElement(_react2.default.Fragment,null,o)};function g(t){return _chunkSIDTGGPGjs.a.call(void 0, t)}function F(t){let{state:e,start:o}=_chunkSIDTGGPGjs.a.call(void 0, _chunkK5SPDXVFjs.c.call(void 0, _chunkK5SPDXVFjs.b.call(void 0, {},t),{action:"link"}));return{state:e,link:o}}var H=t=>{let{client:e}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),o=_react.useRef.call(void 0, t);return _react.useEffect.call(void 0, ()=>{o.current=t},[t]),{unlinkOAuth:_react.useCallback.call(void 0, U=>_chunkK5SPDXVFjs.e.call(void 0, void 0,[U],function*({provider:u,subject:p}){var n,A,s,O;try{let{user:h}=yield e.auth.oauth.unlink(u,p);return(A=(n=o.current)==null?void 0:n.onSuccess)==null||A.call(n,h),h}catch(h){let c=_chunkP6K2IBL3js.h.call(void 0, h);throw(O=(s=o.current)==null?void 0:s.onError)==null||O.call(s,c),c}}),[e.auth.oauth])}};var D=t=>{let{client:e}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),o=_react.useRef.call(void 0, t.onOAuthTokenGrant);o.current=t.onOAuthTokenGrant,_react.useEffect.call(void 0, ()=>{let{unsubscribe:i}=e.addOAuthTokensListener(u=>{o.current(u)});return i},[e])};exports.AuthBoundary = qt; exports.PrivyContext = _chunkP6K2IBL3js.ha; exports.PrivyProvider = _chunkP6K2IBL3js.ja; exports.SecureStorageAdapter = _chunkK5SPDXVFjs.h; exports.createPrivyClient = _chunkP6K2IBL3js.j; exports.dataSuffix = _jssdkcore.createDataSuffixPlugin; exports.getAccessToken = _chunkP6K2IBL3js.ia; exports.hasError = _chunkQSWCX5XIjs.g; exports.isConnected = _chunkQSWCX5XIjs.a; exports.isConnecting = _chunkQSWCX5XIjs.c; exports.isCreating = _chunkQSWCX5XIjs.f; exports.isDisconnected = _chunkQSWCX5XIjs.d; exports.isNotCreated = _chunkQSWCX5XIjs.e; exports.isReconnecting = _chunkQSWCX5XIjs.b; exports.needsRecovery = _chunkQSWCX5XIjs.h; exports.useAcceptTerms = _chunkP6K2IBL3js.aa; exports.useAuthorizationSignature = _chunkP6K2IBL3js.ba; exports.useCreateGuestAccount = _chunkP6K2IBL3js.P; exports.useDepositAddress = _chunkP6K2IBL3js.A; exports.useEmbeddedBitcoinWallet = _chunkP6K2IBL3js._; exports.useEmbeddedEthereumWallet = _chunkP6K2IBL3js.Y; exports.useEmbeddedSolanaWallet = _chunkP6K2IBL3js.Z; exports.useEmbeddedWallet = _chunkP6K2IBL3js.M; exports.useEmbeddedWalletStateChange = _chunkP6K2IBL3js.N; exports.useGetEncryptedAuthorizationKey = _chunkP6K2IBL3js.ca; exports.useHeadlessDelegatedActions = _chunkP6K2IBL3js.z; exports.useIdentityToken = _chunkP6K2IBL3js.O; exports.useImportWallet = _chunkP6K2IBL3js.X; exports.useLinkEmail = _chunkP6K2IBL3js.q; exports.useLinkSMS = _chunkP6K2IBL3js.t; exports.useLinkWithCrossApp = _chunkP6K2IBL3js.G; exports.useLinkWithFarcaster = _chunkP6K2IBL3js.v; exports.useLinkWithOAuth = F; exports.useLinkWithSiwe = _chunkP6K2IBL3js.k; exports.useLinkWithSiws = _chunkP6K2IBL3js.n; exports.useLoginWithCrossApp = _chunkP6K2IBL3js.F; exports.useLoginWithEmail = _chunkP6K2IBL3js.s; exports.useLoginWithFarcaster = _chunkP6K2IBL3js.x; exports.useLoginWithFarcasterV2 = _chunkP6K2IBL3js.y; exports.useLoginWithOAuth = _chunkSIDTGGPGjs.b; exports.useLoginWithSMS = _chunkP6K2IBL3js.u; exports.useLoginWithSiwe = _chunkP6K2IBL3js.l; exports.useLoginWithSiws = _chunkP6K2IBL3js.o; exports.useMfa = _chunkP6K2IBL3js.U; exports.useMfaEnrollment = _chunkP6K2IBL3js.V; exports.useMigrateWallets = _chunkP6K2IBL3js.ga; exports.useOAuthFlow = g; exports.useOAuthTokens = D; exports.useOnNeedsRecovery = _chunkP6K2IBL3js.f; exports.usePrivy = _chunkP6K2IBL3js.$; exports.usePrivyClient = _chunkP6K2IBL3js.m; exports.useRecoverEmbeddedWallet = _chunkP6K2IBL3js.L; exports.useRegisterMfaListener = _chunkP6K2IBL3js.Q; exports.useSendTransactionWithCrossApp = _chunkP6K2IBL3js.J; exports.useSessionSigners = _chunkP6K2IBL3js.B; exports.useSetEmbeddedWalletRecovery = _chunkP6K2IBL3js.K; exports.useSign7702Authorization = _chunkP6K2IBL3js.da; exports.useSignMessageWithCrossApp = _chunkP6K2IBL3js.H; exports.useSignTypedDataWithCrossApp = _chunkP6K2IBL3js.I; exports.useSigners = _chunkP6K2IBL3js.C; exports.useStoredUsers = _chunkP6K2IBL3js.ea; exports.useSwitchUser = _chunkP6K2IBL3js.fa; exports.useUnlinkEmail = _chunkP6K2IBL3js.r; exports.useUnlinkFarcaster = _chunkP6K2IBL3js.w; exports.useUnlinkOAuth = H; exports.useUnlinkPasskey = _chunkP6K2IBL3js.W; exports.useUnlinkWallet = _chunkP6K2IBL3js.p; exports.useUpdateEmail = _chunkP6K2IBL3js.D; exports.useUpdatePhone = _chunkP6K2IBL3js.E;
|
package/dist/passkey.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var _chunkP6K2IBL3js = require('./chunk-P6K2IBL3.js');var _chunkK5SPDXVFjs = require('./chunk-K5SPDXVF.js');var _react = require('react');var _jssdkcore = require('@privy-io/js-sdk-core');var Y=e=>{let{client:a,passkeyState:P,setPasskeyState:s}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),c=_react.useCallback.call(void 0, o=>{var n;let r=_chunkP6K2IBL3js.h.call(void 0, o);return s({status:"error",error:r}),(n=e==null?void 0:e.onError)==null||n.call(e,r),r},[e==null?void 0:e.onError]);return{linkWithPasskey:_react.useCallback.call(void 0, n=>_chunkK5SPDXVFjs.e.call(void 0, void 0,[n],function*({relyingParty:o,extra_options:r}){var u;try{if(!_chunkP6K2IBL3js.b.call(void 0, ))throw new (0, _jssdkcore.PrivyClientError)({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 _chunkP6K2IBL3js.R.call(void 0, _chunkP6K2IBL3js.T.call(void 0, k),r);s({status:"submitting-response"});let{user:l}=yield a.auth.passkey.linkWithPasskey(y,o);return s({status:"done"}),(u=e==null?void 0:e.onSuccess)==null||u.call(e,l),l}catch(t){throw c(t)}}),[a,c,e==null?void 0:e.onSuccess]),state:P}};var ie=e=>{let{client:a,passkeyState:P,setPasskeyState:s}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),c=_react.useCallback.call(void 0, o=>{var n;let r=_chunkP6K2IBL3js.h.call(void 0, o);return s({status:"error",error:r}),(n=e==null?void 0:e.onError)==null||n.call(e,r),r},[e==null?void 0:e.onError]);return{loginWithPasskey:_react.useCallback.call(void 0, n=>_chunkK5SPDXVFjs.e.call(void 0, void 0,[n],function*({relyingParty:o,extra_options:r}){var u,t,k,y;try{if(_chunkP6K2IBL3js.b.call(void 0, ))throw new (0, _jssdkcore.PrivyClientError)({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 _chunkP6K2IBL3js.S.call(void 0, {challenge:i.challenge,rpId:i.rp_id,extensions:{appid:(u=i.extensions)==null?void 0:u.app_id,credProps:(t=i.extensions)==null?void 0:t.cred_props,hmacCreateSecret:(k=i.extensions)==null?void 0:k.hmac_create_secret},timeout:i.timeout,allowCredentials:i.allow_credentials,userVerification:i.user_verification},r);s({status:"submitting-response"});let _=_chunkP6K2IBL3js.a.call(void 0, ),b=yield a.auth.passkey.loginWithPasskey(f,i.challenge,o,{embedded:_==null?void 0:_.embedded});return s({status:"done"}),(y=e==null?void 0:e.onSuccess)==null||y.call(e,b.user,b.is_new_user),b.user}catch(l){throw c(l)}}),[a,c,e==null?void 0:e.onSuccess]),state:P}};var pe=e=>{let{client:a,passkeyState:P,setPasskeyState:s}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),c=_react.useRef.call(void 0, e);_react.useEffect.call(void 0, ()=>{c.current=e},[e]);let d=_react.useCallback.call(void 0, r=>{var u,t;let n=_chunkP6K2IBL3js.h.call(void 0, r);return s({status:"error",error:n}),(t=(u=c.current)==null?void 0:u.onError)==null||t.call(u,n),n},[s]);return{signupWithPasskey:_react.useCallback.call(void 0, u=>_chunkK5SPDXVFjs.e.call(void 0, void 0,[u],function*({relyingParty:r,extra_options:n}){var t,k;try{if(_chunkP6K2IBL3js.b.call(void 0, ))throw new (0, _jssdkcore.PrivyClientError)({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:l}=yield a.auth.passkey.generateSignupOptions(r);s({status:"awaiting-passkey"});let i=yield _chunkP6K2IBL3js.R.call(void 0, _chunkP6K2IBL3js.T.call(void 0, l),n);s({status:"submitting-response"});let f=yield a.auth.passkey.signupWithPasskey(i,r);return s({status:"done"}),(k=(t=c.current)==null?void 0:t.onSuccess)==null||k.call(t,f.user,f.is_new_user),{user:f.user}}catch(y){throw d(y)}}),[a.auth.passkey,d,s]),state:P}};exports.hasError = _chunkQSWCX5XIjs.g; exports.isConnected = _chunkQSWCX5XIjs.a; exports.isConnecting = _chunkQSWCX5XIjs.c; exports.isCreating = _chunkQSWCX5XIjs.f; exports.isDisconnected = _chunkQSWCX5XIjs.d; exports.isNotCreated = _chunkQSWCX5XIjs.e; exports.isReconnecting = _chunkQSWCX5XIjs.b; exports.needsRecovery = _chunkQSWCX5XIjs.h; exports.useLinkWithPasskey = Y; exports.useLoginWithPasskey = ie; exports.useSignupWithPasskey = pe;
|
package/dist/smart-wallets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var _chunkP6K2IBL3js = require('./chunk-P6K2IBL3.js');var _chunkK5SPDXVFjs = require('./chunk-K5SPDXVF.js');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _jssdkcore = require('@privy-io/js-sdk-core');var _viem = require('viem');var _smartwallets = require('@privy-io/js-sdk-core/smart-wallets');var P=y=>_chunkK5SPDXVFjs.e.call(void 0, void 0,[y],function*({chain:t,privyAppId:e,user:a,embeddedWallet:r,smartWalletsConfig:n,client:i,dataSuffix:c}){if(!(n!=null&&n.enabled)||!r||!_chunkQSWCX5XIjs.a.call(void 0, r))return;let s=yield i.embeddedWallet.getProvider(r.account),o=n==null?void 0:n.configured_networks.find(B=>B.chain_id===`eip155:${t.id}`);if(!o)throw new (0, _jssdkcore.PrivyClientError)({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=_jssdkcore.getUserSmartWallet.call(void 0, a),C=l?l.smart_wallet_type:n.smart_wallet_type,W=l?l.smart_wallet_version:n.smart_wallet_version,F=_jssdkcore.getJsonRpcEndpointFromChain.call(void 0, t,{rpcUrls:[]},e),G=_viem.createPublicClient.call(void 0, {chain:t,transport:_viem.http.call(void 0, F)}),E=yield _smartwallets.signerToSmartAccountClient.call(void 0, {owner:s,smartWalletType:C,smartWalletVersion:W,chain:t,publicClient:G,paymasterContext:Q(o.paymaster_url,o.paymaster_context),bundlerUrl:o.bundler_url,paymasterUrl:o.paymaster_url});if(!E)throw new (0, _jssdkcore.PrivyClientError)({code:"smart_wallet_client_error",error:`Failed to create smart wallet client for chain ${t.name} (eip155:${t.id})`});return K(E,c)});function K(t,e){return e?t.extend(a=>({sendTransaction:r=>a.sendTransaction(_chunkK5SPDXVFjs.c.call(void 0, _chunkK5SPDXVFjs.b.call(void 0, {},r),{dataSuffix:e}))})):t}var V=/paymaster\.biconomy\.io\/api/i;function q(t){return V.test(t)}var z={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}},Q=(t,e)=>{if(t&&q(t))return z;if(e&&e.policy_id)return{policyId:e.policy_id}};var U=3,tt=500,et= exports.SmartWalletsProvider =({children:t})=>_react2.default.createElement(at,null,_react2.default.createElement(it,null,_react2.default.createElement(lt,null,t))),D=_react.createContext.call(void 0, {config:void 0}),b=()=>{let{config:t}=_react.useContext.call(void 0, D);return{config:t}},R=_react.createContext.call(void 0, {smartWalletClient:void 0}),rt=()=>{let{smartWalletClient:t}=_react.useContext.call(void 0, R);return{smartWalletClient:t}},$=_react.createContext.call(void 0, {client:void 0}),nt= exports.useSmartWallets =()=>{let{client:t}=_react.useContext.call(void 0, $),e=ot();return{client:t,getClientForChain:e}},at=({children:t})=>{let[e,a]=_react.useState.call(void 0, void 0),r=_chunkP6K2IBL3js.m.call(void 0, );return _react.useEffect.call(void 0, ()=>{!e&&r&&(()=>_chunkK5SPDXVFjs.e.call(void 0, 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]),_react2.default.createElement(D.Provider,{value:{config:e}},t)},it=({children:t})=>{let{config:e}=b(),{client:a,wallet:r}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),n=_chunkP6K2IBL3js.d.call(void 0, ),[i,c]=_react.useState.call(void 0, );return _react.useEffect.call(void 0, ()=>{(()=>_chunkK5SPDXVFjs.e.call(void 0, 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 (0, _jssdkcore.PrivyClientError)({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 P({chain:s,privyAppId:a.app.appId,user:n,embeddedWallet:r,smartWalletsConfig:e,client:a,dataSuffix:(l=_jssdkcore.getDataSuffixPlugin.call(void 0, a.plugins))==null?void 0:l.suffix});if(!o)throw new (0, _jssdkcore.PrivyClientError)({error:"Could not create smart wallet client",code:"smart_wallet_client_error"});c(o)}))()},[!!(e!=null&&e.enabled),!!a,!!n,r.status]),_react2.default.createElement(R.Provider,{value:{smartWalletClient:i}},t)},lt=({children:t})=>{let{client:e,wallet:a}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),r=_chunkP6K2IBL3js.d.call(void 0, ),{smartWalletClient:n}=rt(),{config:i}=b();return _react.useEffect.call(void 0, ()=>{let c=!1;return(()=>_chunkK5SPDXVFjs.e.call(void 0, void 0,null,function*(){var d;if(!(!n||!r||_jssdkcore.getUserSmartWallet.call(void 0, r)||!(i!=null&&i.enabled)||a.status!=="connected"))for(let s=0;s<U;s++){if(c||_jssdkcore.getUserSmartWallet.call(void 0, (d=_chunkP6K2IBL3js.b.call(void 0, ))!=null?d:r))return;let o=!1;for(let l=0;l<5;l++){if(c)return;if(yield e.embeddedWallet.ping(tt)){o=!0;break}yield _chunkP6K2IBL3js.i.call(void 0, 200*_chunkK5SPDXVFjs.a.call(void 0, 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===U-1?console.error("Error creating smart wallet:",l):yield _chunkP6K2IBL3js.i.call(void 0, 500*_chunkK5SPDXVFjs.a.call(void 0, 2,s))}}}))(),()=>{c=!0}},[!!n,!!r,!!_jssdkcore.getUserSmartWallet.call(void 0, r),i,a.status]),_react2.default.createElement($.Provider,{value:{client:_jssdkcore.getUserSmartWallet.call(void 0, r)?n:void 0}},t)},ot=()=>{let{client:t,wallet:e}=_react.useContext.call(void 0, _chunkP6K2IBL3js.ha),{config:a}=b();return _react.useCallback.call(void 0, n=>_chunkK5SPDXVFjs.e.call(void 0, void 0,[n],function*({chainId:r}){var s;let i=_chunkP6K2IBL3js.b.call(void 0, );if(!i)throw new (0, _jssdkcore.PrivyClientError)({error:"Must be logged in to get a smart wallet client",code:"smart_wallet_client_error"});if(!a||!a.enabled)throw new (0, _jssdkcore.PrivyClientError)({error:"Must have smart wallets enabled to get a smart wallet client",code:"smart_wallet_client_error"});let y=t.embeddedWallet.chains.find(o=>o.id===r);if(!y)throw new (0, _jssdkcore.PrivyClientError)({error:`Could not find chain with id: ${r}`,code:"chain_not_supported"});let d=yield P({chain:y,privyAppId:t.app.appId,user:i,embeddedWallet:e,smartWalletsConfig:a,client:t,dataSuffix:(s=_jssdkcore.getDataSuffixPlugin.call(void 0, t.plugins))==null?void 0:s.suffix});if(!d)throw new (0, _jssdkcore.PrivyClientError)({error:`Could not create smart wallet client for chain ${r}`,code:"smart_wallet_client_error"});return d}),[a,e,t])};exports.SmartWalletsProvider = et; exports.useSmartWallets = nt;
|