@privy-io/expo 0.65.5 → 0.66.1
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-PQQEZEVS.js +1 -0
- package/dist/chunk-W3BFEI4R.js +1 -0
- package/dist/esm/chunk-PQQEZEVS.js +1 -0
- package/dist/esm/chunk-W3BFEI4R.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 +18 -1
- 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 +8 -7
- package/dist/chunk-C5CDMLZ3.js +0 -1
- package/dist/chunk-N76NZVFW.js +0 -1
- package/dist/esm/chunk-C5CDMLZ3.js +0 -1
- package/dist/esm/chunk-N76NZVFW.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 _chunkW3BFEI4Rjs = require('./chunk-W3BFEI4R.js');var _chunkQTVIWU3Njs = require('./chunk-QTVIWU3N.js');var _react = require('react');var _jssdkcore = require('@privy-io/js-sdk-core');var f=()=>{let e=_chunkW3BFEI4Rjs.l.call(void 0, );return _react.useMemo.call(void 0, ()=>({createWallet(n){return _chunkQTVIWU3Njs.d.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=_chunkW3BFEI4Rjs.l.call(void 0, );return _react.useMemo.call(void 0, ()=>({signRawHash(k){return _chunkQTVIWU3Njs.d.call(void 0, this,arguments,function*({address:n,chainType:s,hash:o}){let l=_chunkW3BFEI4Rjs.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
|
@@ -9,6 +9,7 @@ import { User, AuthenticatedUser } from '@privy-io/api-types';
|
|
|
9
9
|
export { LinkedAccount, LinkedAccountBitcoinSegwitEmbeddedWallet, LinkedAccountBitcoinTaprootEmbeddedWallet, LinkedAccountEmbeddedWallet, LinkedAccountEthereumEmbeddedWallet, LinkedAccountSmartWallet, LinkedAccountSolanaEmbeddedWallet, User } from '@privy-io/api-types';
|
|
10
10
|
import { TypedDataDefinition } from 'viem';
|
|
11
11
|
import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
|
|
12
|
+
import { EncryptedAuthorizationKeyResponse } from '@privy-io/routes';
|
|
12
13
|
import { AppleAuthenticationCredential } from 'expo-apple-authentication';
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -1273,6 +1274,22 @@ interface UseAuthorizationSignatureInterface {
|
|
|
1273
1274
|
*/
|
|
1274
1275
|
declare const useAuthorizationSignature: () => UseAuthorizationSignatureInterface;
|
|
1275
1276
|
|
|
1277
|
+
interface UseGetEncryptedAuthorizationKeyInterface {
|
|
1278
|
+
/**
|
|
1279
|
+
* Fetches an encrypted authorization key by ID using the SDK's internal
|
|
1280
|
+
* Privy access token. Use this instead of calling the endpoint directly
|
|
1281
|
+
* from mobile, where HttpOnly cookies are not available.
|
|
1282
|
+
*/
|
|
1283
|
+
getEncryptedAuthorizationKey: ({ id }: {
|
|
1284
|
+
id: string;
|
|
1285
|
+
}) => Promise<EncryptedAuthorizationKeyResponse>;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Hook to fetch an encrypted authorization key using the SDK's internal Privy access token.
|
|
1289
|
+
* @returns The `getEncryptedAuthorizationKey` method which fetches a key by ID.
|
|
1290
|
+
*/
|
|
1291
|
+
declare const useGetEncryptedAuthorizationKey: () => UseGetEncryptedAuthorizationKeyInterface;
|
|
1292
|
+
|
|
1276
1293
|
type PrivyContext = {
|
|
1277
1294
|
client: Privy__default;
|
|
1278
1295
|
isReady: boolean;
|
|
@@ -1661,4 +1678,4 @@ declare const useMigrateWallets: () => {
|
|
|
1661
1678
|
}>;
|
|
1662
1679
|
};
|
|
1663
1680
|
|
|
1664
|
-
export { AddSessionSignersInput, AddSessionSignersOutput, AddSignersInput, AddSignersOutput, AuthBoundary, ConnectedEthereumWallet, CustomAuthProviderConfig, EmbeddedSolanaWalletState, EmbeddedWalletState, FarcasterV2State, LinkWithCrossAppInput, LinkWithCrossAppOutput, LinkWithEmailHookResult, LinkWithEmailOptions, LinkWithOAuthInput, LinkWithSMSHookResult, LinkWithSMSOptions, LoginWithCrossAppInput, LoginWithCrossAppOutput, LoginWithEmailHookResult, LoginWithEmailOptions, LoginWithFarcasterV2Input, LoginWithOAuthInput, LoginWithSMSHookResult, LoginWithSMSOptions, OAuthFlowHookResult, OAuthFlowState, OAuthTokens, OtpFlowState, PrivyAuthGuardProps, PrivyConfig, PrivyContext, PrivyOptions, PrivyProvider, PrivyProviderProps, RecoveryFlowState, RemoveSessionSignersInput, RemoveSessionSignersOutput, RemoveSignersInput, RemoveSignersOutput, SecureStorageAdapter, SendEmailCodeInput, SendPhoneCodeInput, SendTransactionWithCrossAppInput, SendTransactionWithCrossAppOutput, SignMessageWithCrossAppInput, SignMessageWithCrossAppOutput, SignTypedDataWithCrossAppInput, SignTypedDataWithCrossAppOutput, UnlinkOAuthInput, UpdateEmailInput, UpdatePhoneInput, UseCreateGuestAccount, UseCreateGuestAccountOptions, UseHeadlessDelegatedActionsInterface, UseLinkWithCrossAppInterface, UseLinkWithFarcaster, UseLinkWithFarcasterOptions, UseLinkWithOAuth, UseLinkWithSiwe, UseLinkWithSiweOptions, UseLinkWithSiwsInterface, UseLoginWithCrossAppInterface, UseLoginWithFarcaster, UseLoginWithFarcasterOptions, UseLoginWithFarcasterV2, UseLoginWithOAuth, UseLoginWithSiwe, UseLoginWithSiweOptions, UseLoginWithSiwsInterface, UseMfa, UseMfaEnrollment, UseOAuthTokens, UseOAuthTokensOptions, UseOnEmbeddedWalletStateChange, UseRecoverEmbeddedWallet, UseSendTransactionWithCrossAppInterface, UseSessionSignersInterface, UseSetEmbeddedWalletRecovery, UseSignMessageWithCrossAppInterface, UseSignTypedDataWithCrossAppInterface, UseSignersInterface, UseUnlinkEmailOptions, UseUnlinkFarcaster, UseUnlinkFarcasterOptions, UseUnlinkOAuth, UseUnlinkWallet, UseUnlinkWalletOptions, UseUpdateEmailInterface, UseUpdatePhoneInterface, createPrivyClient, getAccessToken, useAcceptTerms, useAuthorizationSignature, useCreateGuestAccount, useEmbeddedBitcoinWallet, useEmbeddedEthereumWallet, useEmbeddedSolanaWallet, useEmbeddedWallet, useEmbeddedWalletStateChange, useHeadlessDelegatedActions, useIdentityToken, useLinkEmail, useLinkSMS, useLinkWithCrossApp, useLinkWithFarcaster, useLinkWithOAuth, useLinkWithSiwe, useLinkWithSiws, useLoginWithCrossApp, useLoginWithEmail, useLoginWithFarcaster, useLoginWithFarcasterV2, useLoginWithOAuth, useLoginWithSMS, useLoginWithSiwe, useLoginWithSiws, useMfa, useMfaEnrollment, useMigrateWallets, useOAuthFlow, useOAuthTokens, useOnNeedsRecovery, usePrivy, usePrivyClient, useRecoverEmbeddedWallet, useRegisterMfaListener, useSendTransactionWithCrossApp, useSessionSigners, useSetEmbeddedWalletRecovery, useSignMessageWithCrossApp, useSignTypedDataWithCrossApp, useSigners, useUnlinkEmail, useUnlinkFarcaster, useUnlinkOAuth, useUnlinkWallet, useUpdateEmail, useUpdatePhone };
|
|
1681
|
+
export { AddSessionSignersInput, AddSessionSignersOutput, AddSignersInput, AddSignersOutput, AuthBoundary, ConnectedEthereumWallet, CustomAuthProviderConfig, EmbeddedSolanaWalletState, EmbeddedWalletState, FarcasterV2State, LinkWithCrossAppInput, LinkWithCrossAppOutput, LinkWithEmailHookResult, LinkWithEmailOptions, LinkWithOAuthInput, LinkWithSMSHookResult, LinkWithSMSOptions, LoginWithCrossAppInput, LoginWithCrossAppOutput, LoginWithEmailHookResult, LoginWithEmailOptions, LoginWithFarcasterV2Input, LoginWithOAuthInput, LoginWithSMSHookResult, LoginWithSMSOptions, OAuthFlowHookResult, OAuthFlowState, OAuthTokens, OtpFlowState, PrivyAuthGuardProps, PrivyConfig, PrivyContext, PrivyOptions, PrivyProvider, PrivyProviderProps, RecoveryFlowState, RemoveSessionSignersInput, RemoveSessionSignersOutput, RemoveSignersInput, RemoveSignersOutput, SecureStorageAdapter, SendEmailCodeInput, SendPhoneCodeInput, SendTransactionWithCrossAppInput, SendTransactionWithCrossAppOutput, SignMessageWithCrossAppInput, SignMessageWithCrossAppOutput, SignTypedDataWithCrossAppInput, SignTypedDataWithCrossAppOutput, UnlinkOAuthInput, UpdateEmailInput, UpdatePhoneInput, UseCreateGuestAccount, UseCreateGuestAccountOptions, UseGetEncryptedAuthorizationKeyInterface, UseHeadlessDelegatedActionsInterface, UseLinkWithCrossAppInterface, UseLinkWithFarcaster, UseLinkWithFarcasterOptions, UseLinkWithOAuth, UseLinkWithSiwe, UseLinkWithSiweOptions, UseLinkWithSiwsInterface, UseLoginWithCrossAppInterface, UseLoginWithFarcaster, UseLoginWithFarcasterOptions, UseLoginWithFarcasterV2, UseLoginWithOAuth, UseLoginWithSiwe, UseLoginWithSiweOptions, UseLoginWithSiwsInterface, UseMfa, UseMfaEnrollment, UseOAuthTokens, UseOAuthTokensOptions, UseOnEmbeddedWalletStateChange, UseRecoverEmbeddedWallet, UseSendTransactionWithCrossAppInterface, UseSessionSignersInterface, UseSetEmbeddedWalletRecovery, UseSignMessageWithCrossAppInterface, UseSignTypedDataWithCrossAppInterface, UseSignersInterface, UseUnlinkEmailOptions, UseUnlinkFarcaster, UseUnlinkFarcasterOptions, UseUnlinkOAuth, UseUnlinkWallet, UseUnlinkWalletOptions, UseUpdateEmailInterface, UseUpdatePhoneInterface, createPrivyClient, getAccessToken, useAcceptTerms, useAuthorizationSignature, useCreateGuestAccount, useEmbeddedBitcoinWallet, useEmbeddedEthereumWallet, useEmbeddedSolanaWallet, useEmbeddedWallet, useEmbeddedWalletStateChange, useGetEncryptedAuthorizationKey, useHeadlessDelegatedActions, useIdentityToken, useLinkEmail, useLinkSMS, useLinkWithCrossApp, useLinkWithFarcaster, useLinkWithOAuth, useLinkWithSiwe, useLinkWithSiws, useLoginWithCrossApp, useLoginWithEmail, useLoginWithFarcaster, useLoginWithFarcasterV2, useLoginWithOAuth, useLoginWithSMS, useLoginWithSiwe, useLoginWithSiws, useMfa, useMfaEnrollment, useMigrateWallets, useOAuthFlow, useOAuthTokens, useOnNeedsRecovery, usePrivy, usePrivyClient, useRecoverEmbeddedWallet, useRegisterMfaListener, useSendTransactionWithCrossApp, useSessionSigners, useSetEmbeddedWalletRecovery, useSignMessageWithCrossApp, useSignTypedDataWithCrossApp, useSigners, useUnlinkEmail, useUnlinkFarcaster, useUnlinkOAuth, useUnlinkWallet, useUpdateEmail, useUpdatePhone };
|
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 _chunkPQQEZEVSjs = require('./chunk-PQQEZEVS.js');var _chunkW3BFEI4Rjs = require('./chunk-W3BFEI4R.js');var _chunkQTVIWU3Njs = require('./chunk-QTVIWU3N.js');var _jssdkcore = require('@privy-io/js-sdk-core'); _createStarExport(_jssdkcore);var _react = require('react'); var _react2 = _interopRequireDefault(_react);var Gt=({loading:t,error:e,unauthenticated:o,children:i})=>{let{isReady:u,error:p}=_chunkW3BFEI4Rjs.X.call(void 0, ),d=_chunkW3BFEI4Rjs.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 d?_react2.default.createElement(_react2.default.Fragment,null,i):_react2.default.createElement(_react2.default.Fragment,null,o)};function T(t){return _chunkPQQEZEVSjs.a.call(void 0, t)}function F(t){let{state:e,start:o}=_chunkPQQEZEVSjs.a.call(void 0, _chunkQTVIWU3Njs.b.call(void 0, _chunkQTVIWU3Njs.a.call(void 0, {},t),{action:"link"}));return{state:e,link:o}}var H=t=>{let{client:e}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),o=_react.useRef.call(void 0, t);return _react.useEffect.call(void 0, ()=>{o.current=t},[t]),{unlinkOAuth:_react.useCallback.call(void 0, d=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[d],function*({provider:u,subject:p}){var n,a,s,c;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 m=_chunkW3BFEI4Rjs.g.call(void 0, h);throw(c=(s=o.current)==null?void 0:s.onError)==null||c.call(s,m),m}}),[e.auth.oauth])}};var b=t=>{let{client:e}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),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 = Gt; exports.PrivyContext = _chunkW3BFEI4Rjs.aa; exports.PrivyProvider = _chunkW3BFEI4Rjs.ca; exports.SecureStorageAdapter = _chunkQTVIWU3Njs.g; exports.createPrivyClient = _chunkW3BFEI4Rjs.i; exports.getAccessToken = _chunkW3BFEI4Rjs.ba; 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 = _chunkW3BFEI4Rjs.Y; exports.useAuthorizationSignature = _chunkW3BFEI4Rjs.Z; exports.useCreateGuestAccount = _chunkW3BFEI4Rjs.N; exports.useEmbeddedBitcoinWallet = _chunkW3BFEI4Rjs.W; exports.useEmbeddedEthereumWallet = _chunkW3BFEI4Rjs.U; exports.useEmbeddedSolanaWallet = _chunkW3BFEI4Rjs.V; exports.useEmbeddedWallet = _chunkW3BFEI4Rjs.K; exports.useEmbeddedWalletStateChange = _chunkW3BFEI4Rjs.L; exports.useGetEncryptedAuthorizationKey = _chunkW3BFEI4Rjs._; exports.useHeadlessDelegatedActions = _chunkW3BFEI4Rjs.y; exports.useIdentityToken = _chunkW3BFEI4Rjs.M; exports.useLinkEmail = _chunkW3BFEI4Rjs.p; exports.useLinkSMS = _chunkW3BFEI4Rjs.s; exports.useLinkWithCrossApp = _chunkW3BFEI4Rjs.E; exports.useLinkWithFarcaster = _chunkW3BFEI4Rjs.u; exports.useLinkWithOAuth = F; exports.useLinkWithSiwe = _chunkW3BFEI4Rjs.j; exports.useLinkWithSiws = _chunkW3BFEI4Rjs.m; exports.useLoginWithCrossApp = _chunkW3BFEI4Rjs.D; exports.useLoginWithEmail = _chunkW3BFEI4Rjs.r; exports.useLoginWithFarcaster = _chunkW3BFEI4Rjs.w; exports.useLoginWithFarcasterV2 = _chunkW3BFEI4Rjs.x; exports.useLoginWithOAuth = _chunkPQQEZEVSjs.b; exports.useLoginWithSMS = _chunkW3BFEI4Rjs.t; exports.useLoginWithSiwe = _chunkW3BFEI4Rjs.k; exports.useLoginWithSiws = _chunkW3BFEI4Rjs.n; exports.useMfa = _chunkW3BFEI4Rjs.S; exports.useMfaEnrollment = _chunkW3BFEI4Rjs.T; exports.useMigrateWallets = _chunkW3BFEI4Rjs.$; exports.useOAuthFlow = T; exports.useOAuthTokens = b; exports.useOnNeedsRecovery = _chunkW3BFEI4Rjs.f; exports.usePrivy = _chunkW3BFEI4Rjs.X; exports.usePrivyClient = _chunkW3BFEI4Rjs.l; exports.useRecoverEmbeddedWallet = _chunkW3BFEI4Rjs.J; exports.useRegisterMfaListener = _chunkW3BFEI4Rjs.O; exports.useSendTransactionWithCrossApp = _chunkW3BFEI4Rjs.H; exports.useSessionSigners = _chunkW3BFEI4Rjs.z; exports.useSetEmbeddedWalletRecovery = _chunkW3BFEI4Rjs.I; exports.useSignMessageWithCrossApp = _chunkW3BFEI4Rjs.F; exports.useSignTypedDataWithCrossApp = _chunkW3BFEI4Rjs.G; exports.useSigners = _chunkW3BFEI4Rjs.A; exports.useUnlinkEmail = _chunkW3BFEI4Rjs.q; exports.useUnlinkFarcaster = _chunkW3BFEI4Rjs.v; exports.useUnlinkOAuth = H; exports.useUnlinkWallet = _chunkW3BFEI4Rjs.o; exports.useUpdateEmail = _chunkW3BFEI4Rjs.B; exports.useUpdatePhone = _chunkW3BFEI4Rjs.C;
|
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 _chunkW3BFEI4Rjs = require('./chunk-W3BFEI4R.js');var _chunkQTVIWU3Njs = require('./chunk-QTVIWU3N.js');var _react = require('react');var _jssdkcore = require('@privy-io/js-sdk-core');var X=e=>{let{client:n,passkeyState:h,setPasskeyState:s}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),c=_react.useCallback.call(void 0, o=>{var r;let a=_chunkW3BFEI4Rjs.g.call(void 0, o);return s({status:"error",error:a}),(r=e==null?void 0:e.onError)==null||r.call(e,a),a},[e==null?void 0:e.onError]);return{linkWithPasskey:_react.useCallback.call(void 0, a=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[a],function*({relyingParty:o}){var r;try{if(!_chunkW3BFEI4Rjs.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:u}=yield n.auth.passkey.generateRegistrationOptions(o);s({status:"awaiting-passkey"});let k=yield _chunkW3BFEI4Rjs.P.call(void 0, _chunkW3BFEI4Rjs.R.call(void 0, u));s({status:"submitting-response"});let{user:y}=yield n.auth.passkey.linkWithPasskey(k,o);return s({status:"done"}),(r=e==null?void 0:e.onSuccess)==null||r.call(e,y),y}catch(t){throw c(t)}}),[n,c,e==null?void 0:e.onSuccess]),state:h}};var ne=e=>{let{client:n,passkeyState:h,setPasskeyState:s}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),c=_react.useCallback.call(void 0, o=>{var r;let a=_chunkW3BFEI4Rjs.g.call(void 0, o);return s({status:"error",error:a}),(r=e==null?void 0:e.onError)==null||r.call(e,a),a},[e==null?void 0:e.onError]);return{loginWithPasskey:_react.useCallback.call(void 0, a=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[a],function*({relyingParty:o}){var r,t,u,k;try{if(_chunkW3BFEI4Rjs.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 n.auth.passkey.generateAuthenticationOptions(o);s({status:"awaiting-passkey"});let P=yield _chunkW3BFEI4Rjs.Q.call(void 0, {challenge:i.challenge,rpId:i.rp_id,extensions:{appid:(r=i.extensions)==null?void 0:r.app_id,credProps:(t=i.extensions)==null?void 0:t.cred_props,hmacCreateSecret:(u=i.extensions)==null?void 0:u.hmac_create_secret},timeout:i.timeout,allowCredentials:i.allow_credentials,userVerification:i.user_verification});s({status:"submitting-response"});let w=_chunkW3BFEI4Rjs.a.call(void 0, ),_=yield n.auth.passkey.loginWithPasskey(P,i.challenge,o,{embedded:w==null?void 0:w.embedded});return s({status:"done"}),(k=e==null?void 0:e.onSuccess)==null||k.call(e,_.user,_.is_new_user),_.user}catch(y){throw c(y)}}),[n,c,e==null?void 0:e.onSuccess]),state:h}};var me=e=>{let{client:n,passkeyState:h,setPasskeyState:s}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),c=_react.useRef.call(void 0, e);_react.useEffect.call(void 0, ()=>{c.current=e},[e]);let f=_react.useCallback.call(void 0, a=>{var t,u;let r=_chunkW3BFEI4Rjs.g.call(void 0, a);return s({status:"error",error:r}),(u=(t=c.current)==null?void 0:t.onError)==null||u.call(t,r),r},[s]);return{signupWithPasskey:_react.useCallback.call(void 0, r=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[r],function*({relyingParty:a}){var t,u;try{if(_chunkW3BFEI4Rjs.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:y}=yield n.auth.passkey.generateSignupOptions(a);s({status:"awaiting-passkey"});let i=yield _chunkW3BFEI4Rjs.P.call(void 0, _chunkW3BFEI4Rjs.R.call(void 0, y));s({status:"submitting-response"});let P=yield n.auth.passkey.signupWithPasskey(i,a);return s({status:"done"}),(u=(t=c.current)==null?void 0:t.onSuccess)==null||u.call(t,P.user,P.is_new_user),{user:P.user}}catch(k){throw f(k)}}),[n.auth.passkey,f,s]),state:h}};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 = X; exports.useLoginWithPasskey = ne; exports.useSignupWithPasskey = me;
|
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 _chunkW3BFEI4Rjs = require('./chunk-W3BFEI4R.js');var _chunkQTVIWU3Njs = require('./chunk-QTVIWU3N.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 W=l=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[l],function*({chain:t,privyAppId:e,user:a,embeddedWallet:r,smartWalletsConfig:n,client:o}){if(!(n!=null&&n.enabled)||!r||!_chunkQSWCX5XIjs.a.call(void 0, r))return;let f=yield o.embeddedWallet.getProvider(r.account),i=n==null?void 0:n.configured_networks.find($=>$.chain_id===`eip155:${t.id}`);if(!i)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 s=_jssdkcore.getUserSmartWallet.call(void 0, a),y=s?s.smart_wallet_type:n.smart_wallet_type,w=s?s.smart_wallet_version:n.smart_wallet_version,N=_jssdkcore.getJsonRpcEndpointFromChain.call(void 0, t,{rpcUrls:[]},e),O=_viem.createPublicClient.call(void 0, {chain:t,transport:_viem.http.call(void 0, N)}),P=yield _smartwallets.signerToSmartAccountClient.call(void 0, {owner:f,smartWalletType:y,smartWalletVersion:w,chain:t,publicClient:O,paymasterContext:j(i.paymaster_url,i.paymaster_context),bundlerUrl:i.bundler_url,paymasterUrl:i.paymaster_url});if(!P)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 P}),B=/paymaster\.biconomy\.io\/api/i;function D(t){return B.test(t)}var Y={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}},j=(t,e)=>{if(t&&D(t))return Y;if(e&&e.policy_id)return{policyId:e.policy_id}};var J=({children:t})=>_react2.default.createElement(z,null,_react2.default.createElement(H,null,_react2.default.createElement(K,null,t))),T=_react.createContext.call(void 0, {config:void 0}),v=()=>{let{config:t}=_react.useContext.call(void 0, T);return{config:t}},k=_react.createContext.call(void 0, {smartWalletClient:void 0}),V=()=>{let{smartWalletClient:t}=_react.useContext.call(void 0, k);return{smartWalletClient:t}},U=_react.createContext.call(void 0, {client:void 0}),q= exports.useSmartWallets =()=>{let{client:t}=_react.useContext.call(void 0, U),e=Q();return{client:t,getClientForChain:e}},z=({children:t})=>{let[e,a]=_react.useState.call(void 0, void 0),r=_chunkW3BFEI4Rjs.l.call(void 0, );return _react.useEffect.call(void 0, ()=>{!e&&r&&(()=>_chunkQTVIWU3Njs.d.call(void 0, void 0,null,function*(){try{if(!r){console.warn("No client found");return}let o=yield r.app.getSmartWalletConfig();a(o)}catch(o){console.warn("Error generating smart wallet config: ",o)}}))()},[r,e]),_react2.default.createElement(T.Provider,{value:{config:e}},t)},H=({children:t})=>{let{config:e}=v(),{client:a,wallet:r}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),n=_chunkW3BFEI4Rjs.d.call(void 0, ),[o,l]=_react.useState.call(void 0, );return _react.useEffect.call(void 0, ()=>{(()=>_chunkQTVIWU3Njs.d.call(void 0, void 0,null,function*(){if(!n&&o&&l(void 0),!(e!=null&&e.enabled)||!n||r.status!=="connected"||n&&o&&r.status==="connected")return;let i=a.embeddedWallet.chains.find(y=>e.configured_networks.map(w=>w.chain_id).includes(`eip155:${y.id}`));if(!i)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 s=yield W({chain:i,privyAppId:a.app.appId,user:n,embeddedWallet:r,smartWalletsConfig:e,client:a});if(!s)throw new (0, _jssdkcore.PrivyClientError)({error:"Could not create smart wallet client",code:"smart_wallet_client_error"});l(s)}))()},[!!(e!=null&&e.enabled),!!a,!!n,r.status]),_react2.default.createElement(k.Provider,{value:{smartWalletClient:o}},t)},K=({children:t})=>{let{client:e}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),a=_chunkW3BFEI4Rjs.d.call(void 0, ),{smartWalletClient:r}=V(),{config:n}=v();return _react.useEffect.call(void 0, ()=>{(()=>_chunkQTVIWU3Njs.d.call(void 0, void 0,null,function*(){if(!(!r||!a||_jssdkcore.getUserSmartWallet.call(void 0, a)||!(n!=null&&n.enabled)))try{let{message:l}=yield e.auth.smartWallet.init({address:r.account.address,chainId:`eip155:${r.chain.id}`}),d=yield r.signMessage({message:l});yield e.auth.smartWallet.link(l,d,n.smart_wallet_type,n.smart_wallet_version)}catch(l){console.error("Error creating smart wallet:",l)}}))()},[!!r,!!a,!!_jssdkcore.getUserSmartWallet.call(void 0, a),n]),_react2.default.createElement(U.Provider,{value:{client:_jssdkcore.getUserSmartWallet.call(void 0, a)?r:void 0}},t)},Q=()=>{let{client:t,wallet:e}=_react.useContext.call(void 0, _chunkW3BFEI4Rjs.aa),{config:a}=v();return _react.useCallback.call(void 0, n=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[n],function*({chainId:r}){let o=_chunkW3BFEI4Rjs.b.call(void 0, );if(!o)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 d=t.embeddedWallet.chains.find(i=>i.id===r);if(!d)throw new (0, _jssdkcore.PrivyClientError)({error:`Could not find chain with id: ${r}`,code:"chain_not_supported"});let f=yield W({chain:d,privyAppId:t.app.appId,user:o,embeddedWallet:e,smartWalletsConfig:a,client:t});if(!f)throw new (0, _jssdkcore.PrivyClientError)({error:`Could not create smart wallet client for chain ${r}`,code:"smart_wallet_client_error"});return f}),[a,e,t])};exports.SmartWalletsProvider = J; exports.useSmartWallets = q;
|