@privy-io/expo 0.64.2 → 0.65.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkW7HLQLVJjs = require('./chunk-W7HLQLVJ.js');var _chunkQTVIWU3Njs = require('./chunk-QTVIWU3N.js');var _react = require('react');var _jssdkcore = require('@privy-io/js-sdk-core');var f=()=>{let e=_chunkW7HLQLVJjs.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=_chunkW7HLQLVJjs.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=_chunkW7HLQLVJjs.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;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT67KH2PCjs = require('./chunk-T67KH2PC.js');var _chunkQTVIWU3Njs = require('./chunk-QTVIWU3N.js');var _react = require('react');var _jssdkcore = require('@privy-io/js-sdk-core');var f=()=>{let e=_chunkT67KH2PCjs.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=_chunkT67KH2PCjs.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=_chunkT67KH2PCjs.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
@@ -1260,9 +1260,12 @@ interface UseAuthorizationSignatureInterface {
1260
1260
  /**
1261
1261
  * Generate an authorization signature for an API request with the user's authorization key.
1262
1262
  * @see {@link https://docs.privy.io/api-reference/authorization-signatures |Authorization signatures}
1263
+ * @param input The request payload to sign. Can be a structured request object (which will be
1264
+ * canonicalized to JSON before signing) or a pre-serialized binary payload (`Uint8Array`) that
1265
+ * will be signed directly.
1263
1266
  * @returns The user's authorization signature over the API request.
1264
1267
  */
1265
- generateAuthorizationSignature: (input: GenerateAuthorizationSignatureInput) => Promise<GenerateAuthorizationSignatureOutput>;
1268
+ generateAuthorizationSignature: (input: GenerateAuthorizationSignatureInput | Uint8Array) => Promise<GenerateAuthorizationSignatureOutput>;
1266
1269
  }
1267
1270
  /**
1268
1271
  * Hook to sign an API request with the user's authorization key.
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 _chunkU7DX6CURjs = require('./chunk-U7DX6CUR.js');var _chunkW7HLQLVJjs = require('./chunk-W7HLQLVJ.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 bt=({loading:t,error:e,unauthenticated:o,children:i})=>{let{isReady:u,error:p}=_chunkW7HLQLVJjs.X.call(void 0, ),d=_chunkW7HLQLVJjs.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 _chunkU7DX6CURjs.a.call(void 0, t)}function F(t){let{state:e,start:o}=_chunkU7DX6CURjs.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, _chunkW7HLQLVJjs.$),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=_chunkW7HLQLVJjs.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, _chunkW7HLQLVJjs.$),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 = bt; exports.PrivyContext = _chunkW7HLQLVJjs.$; exports.PrivyProvider = _chunkW7HLQLVJjs.ba; exports.SecureStorageAdapter = _chunkQTVIWU3Njs.g; exports.createPrivyClient = _chunkW7HLQLVJjs.i; exports.getAccessToken = _chunkW7HLQLVJjs.aa; 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 = _chunkW7HLQLVJjs.Y; exports.useAuthorizationSignature = _chunkW7HLQLVJjs.Z; exports.useCreateGuestAccount = _chunkW7HLQLVJjs.N; exports.useEmbeddedBitcoinWallet = _chunkW7HLQLVJjs.W; exports.useEmbeddedEthereumWallet = _chunkW7HLQLVJjs.U; exports.useEmbeddedSolanaWallet = _chunkW7HLQLVJjs.V; exports.useEmbeddedWallet = _chunkW7HLQLVJjs.K; exports.useEmbeddedWalletStateChange = _chunkW7HLQLVJjs.L; exports.useHeadlessDelegatedActions = _chunkW7HLQLVJjs.y; exports.useIdentityToken = _chunkW7HLQLVJjs.M; exports.useLinkEmail = _chunkW7HLQLVJjs.p; exports.useLinkSMS = _chunkW7HLQLVJjs.s; exports.useLinkWithCrossApp = _chunkW7HLQLVJjs.E; exports.useLinkWithFarcaster = _chunkW7HLQLVJjs.u; exports.useLinkWithOAuth = F; exports.useLinkWithSiwe = _chunkW7HLQLVJjs.j; exports.useLinkWithSiws = _chunkW7HLQLVJjs.m; exports.useLoginWithCrossApp = _chunkW7HLQLVJjs.D; exports.useLoginWithEmail = _chunkW7HLQLVJjs.r; exports.useLoginWithFarcaster = _chunkW7HLQLVJjs.w; exports.useLoginWithFarcasterV2 = _chunkW7HLQLVJjs.x; exports.useLoginWithOAuth = _chunkU7DX6CURjs.b; exports.useLoginWithSMS = _chunkW7HLQLVJjs.t; exports.useLoginWithSiwe = _chunkW7HLQLVJjs.k; exports.useLoginWithSiws = _chunkW7HLQLVJjs.n; exports.useMfa = _chunkW7HLQLVJjs.S; exports.useMfaEnrollment = _chunkW7HLQLVJjs.T; exports.useMigrateWallets = _chunkW7HLQLVJjs._; exports.useOAuthFlow = T; exports.useOAuthTokens = b; exports.useOnNeedsRecovery = _chunkW7HLQLVJjs.f; exports.usePrivy = _chunkW7HLQLVJjs.X; exports.usePrivyClient = _chunkW7HLQLVJjs.l; exports.useRecoverEmbeddedWallet = _chunkW7HLQLVJjs.J; exports.useRegisterMfaListener = _chunkW7HLQLVJjs.O; exports.useSendTransactionWithCrossApp = _chunkW7HLQLVJjs.H; exports.useSessionSigners = _chunkW7HLQLVJjs.z; exports.useSetEmbeddedWalletRecovery = _chunkW7HLQLVJjs.I; exports.useSignMessageWithCrossApp = _chunkW7HLQLVJjs.F; exports.useSignTypedDataWithCrossApp = _chunkW7HLQLVJjs.G; exports.useSigners = _chunkW7HLQLVJjs.A; exports.useUnlinkEmail = _chunkW7HLQLVJjs.q; exports.useUnlinkFarcaster = _chunkW7HLQLVJjs.v; exports.useUnlinkOAuth = H; exports.useUnlinkWallet = _chunkW7HLQLVJjs.o; exports.useUpdateEmail = _chunkW7HLQLVJjs.B; exports.useUpdatePhone = _chunkW7HLQLVJjs.C;
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 _chunkOVWIP2ZLjs = require('./chunk-OVWIP2ZL.js');var _chunkT67KH2PCjs = require('./chunk-T67KH2PC.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 bt=({loading:t,error:e,unauthenticated:o,children:i})=>{let{isReady:u,error:p}=_chunkT67KH2PCjs.X.call(void 0, ),d=_chunkT67KH2PCjs.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 _chunkOVWIP2ZLjs.a.call(void 0, t)}function F(t){let{state:e,start:o}=_chunkOVWIP2ZLjs.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, _chunkT67KH2PCjs.$),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=_chunkT67KH2PCjs.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, _chunkT67KH2PCjs.$),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 = bt; exports.PrivyContext = _chunkT67KH2PCjs.$; exports.PrivyProvider = _chunkT67KH2PCjs.ba; exports.SecureStorageAdapter = _chunkQTVIWU3Njs.g; exports.createPrivyClient = _chunkT67KH2PCjs.i; exports.getAccessToken = _chunkT67KH2PCjs.aa; 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 = _chunkT67KH2PCjs.Y; exports.useAuthorizationSignature = _chunkT67KH2PCjs.Z; exports.useCreateGuestAccount = _chunkT67KH2PCjs.N; exports.useEmbeddedBitcoinWallet = _chunkT67KH2PCjs.W; exports.useEmbeddedEthereumWallet = _chunkT67KH2PCjs.U; exports.useEmbeddedSolanaWallet = _chunkT67KH2PCjs.V; exports.useEmbeddedWallet = _chunkT67KH2PCjs.K; exports.useEmbeddedWalletStateChange = _chunkT67KH2PCjs.L; exports.useHeadlessDelegatedActions = _chunkT67KH2PCjs.y; exports.useIdentityToken = _chunkT67KH2PCjs.M; exports.useLinkEmail = _chunkT67KH2PCjs.p; exports.useLinkSMS = _chunkT67KH2PCjs.s; exports.useLinkWithCrossApp = _chunkT67KH2PCjs.E; exports.useLinkWithFarcaster = _chunkT67KH2PCjs.u; exports.useLinkWithOAuth = F; exports.useLinkWithSiwe = _chunkT67KH2PCjs.j; exports.useLinkWithSiws = _chunkT67KH2PCjs.m; exports.useLoginWithCrossApp = _chunkT67KH2PCjs.D; exports.useLoginWithEmail = _chunkT67KH2PCjs.r; exports.useLoginWithFarcaster = _chunkT67KH2PCjs.w; exports.useLoginWithFarcasterV2 = _chunkT67KH2PCjs.x; exports.useLoginWithOAuth = _chunkOVWIP2ZLjs.b; exports.useLoginWithSMS = _chunkT67KH2PCjs.t; exports.useLoginWithSiwe = _chunkT67KH2PCjs.k; exports.useLoginWithSiws = _chunkT67KH2PCjs.n; exports.useMfa = _chunkT67KH2PCjs.S; exports.useMfaEnrollment = _chunkT67KH2PCjs.T; exports.useMigrateWallets = _chunkT67KH2PCjs._; exports.useOAuthFlow = T; exports.useOAuthTokens = b; exports.useOnNeedsRecovery = _chunkT67KH2PCjs.f; exports.usePrivy = _chunkT67KH2PCjs.X; exports.usePrivyClient = _chunkT67KH2PCjs.l; exports.useRecoverEmbeddedWallet = _chunkT67KH2PCjs.J; exports.useRegisterMfaListener = _chunkT67KH2PCjs.O; exports.useSendTransactionWithCrossApp = _chunkT67KH2PCjs.H; exports.useSessionSigners = _chunkT67KH2PCjs.z; exports.useSetEmbeddedWalletRecovery = _chunkT67KH2PCjs.I; exports.useSignMessageWithCrossApp = _chunkT67KH2PCjs.F; exports.useSignTypedDataWithCrossApp = _chunkT67KH2PCjs.G; exports.useSigners = _chunkT67KH2PCjs.A; exports.useUnlinkEmail = _chunkT67KH2PCjs.q; exports.useUnlinkFarcaster = _chunkT67KH2PCjs.v; exports.useUnlinkOAuth = H; exports.useUnlinkWallet = _chunkT67KH2PCjs.o; exports.useUpdateEmail = _chunkT67KH2PCjs.B; exports.useUpdatePhone = _chunkT67KH2PCjs.C;
package/dist/passkey.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var _chunkW7HLQLVJjs = require('./chunk-W7HLQLVJ.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, _chunkW7HLQLVJjs.$),c=_react.useCallback.call(void 0, o=>{var r;let a=_chunkW7HLQLVJjs.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(!_chunkW7HLQLVJjs.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 _chunkW7HLQLVJjs.P.call(void 0, _chunkW7HLQLVJjs.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, _chunkW7HLQLVJjs.$),c=_react.useCallback.call(void 0, o=>{var r;let a=_chunkW7HLQLVJjs.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(_chunkW7HLQLVJjs.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 _chunkW7HLQLVJjs.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=_chunkW7HLQLVJjs.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, _chunkW7HLQLVJjs.$),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=_chunkW7HLQLVJjs.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(_chunkW7HLQLVJjs.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 _chunkW7HLQLVJjs.P.call(void 0, _chunkW7HLQLVJjs.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;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQSWCX5XIjs = require('./chunk-QSWCX5XI.js');var _chunkT67KH2PCjs = require('./chunk-T67KH2PC.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, _chunkT67KH2PCjs.$),c=_react.useCallback.call(void 0, o=>{var r;let a=_chunkT67KH2PCjs.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(!_chunkT67KH2PCjs.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 _chunkT67KH2PCjs.P.call(void 0, _chunkT67KH2PCjs.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, _chunkT67KH2PCjs.$),c=_react.useCallback.call(void 0, o=>{var r;let a=_chunkT67KH2PCjs.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(_chunkT67KH2PCjs.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 _chunkT67KH2PCjs.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=_chunkT67KH2PCjs.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, _chunkT67KH2PCjs.$),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=_chunkT67KH2PCjs.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(_chunkT67KH2PCjs.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 _chunkT67KH2PCjs.P.call(void 0, _chunkT67KH2PCjs.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;
@@ -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 _chunkW7HLQLVJjs = require('./chunk-W7HLQLVJ.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=_chunkW7HLQLVJjs.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, _chunkW7HLQLVJjs.$),n=_chunkW7HLQLVJjs.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, _chunkW7HLQLVJjs.$),a=_chunkW7HLQLVJjs.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, _chunkW7HLQLVJjs.$),{config:a}=v();return _react.useCallback.call(void 0, n=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[n],function*({chainId:r}){let o=_chunkW7HLQLVJjs.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;
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 _chunkT67KH2PCjs = require('./chunk-T67KH2PC.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=_chunkT67KH2PCjs.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, _chunkT67KH2PCjs.$),n=_chunkT67KH2PCjs.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, _chunkT67KH2PCjs.$),a=_chunkT67KH2PCjs.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, _chunkT67KH2PCjs.$),{config:a}=v();return _react.useCallback.call(void 0, n=>_chunkQTVIWU3Njs.d.call(void 0, void 0,[n],function*({chainId:r}){let o=_chunkT67KH2PCjs.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;