@privy-io/js-sdk-core 0.34.2 → 0.34.3-beta-20241119044014
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/cjs/AuthApi.js +1 -1
- package/dist/cjs/FarcasterV2Api.js +1 -0
- package/dist/cjs/Privy.js +1 -1
- package/dist/cjs/PrivyInternal.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/dts/AuthApi.d.mts +6 -0
- package/dist/dts/AuthApi.d.ts +6 -0
- package/dist/dts/FarcasterV2Api.d.mts +15 -0
- package/dist/dts/FarcasterV2Api.d.ts +15 -0
- package/dist/esm/AuthApi.mjs +1 -1
- package/dist/esm/FarcasterV2Api.mjs +1 -0
- package/dist/esm/Privy.mjs +1 -1
- package/dist/esm/PrivyInternal.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/package.json +2 -2
package/dist/cjs/AuthApi.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@privy-io/public-api"),r=require("./CustomProviderApi.js"),t=require("./EmailApi.js"),i=require("./FarcasterApi.js"),s=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@privy-io/public-api"),r=require("./CustomProviderApi.js"),t=require("./EmailApi.js"),i=require("./FarcasterApi.js"),s=require("./FarcasterV2Api.js"),a=require("./GuestApi.js"),n=require("./OAuthApi.js"),l=require("./PasskeyApi.js"),o=require("./PhoneApi.js"),u=require("./SiweApi.js"),p=require("./SmartWalletApi.js");require("./Error.js"),require("./pkce.js"),require("jose");exports.default=class{_privyInternal;customProvider;phone;email;oauth;siwe;smartWallet;passkey;farcaster;farcasterV2;guest;constructor(e,h,y){this._privyInternal=e,this.customProvider=new r.default(this._privyInternal),this.phone=new o.default(this._privyInternal),this.email=new t.default(this._privyInternal),this.oauth=new n.default(this._privyInternal,h,y),this.guest=new a.default(this._privyInternal),this.siwe=new u.default(this._privyInternal),this.smartWallet=new p.default(this._privyInternal),this.passkey=new l.default(this._privyInternal),this.farcaster=new i.default(this._privyInternal),this.farcasterV2=new s.default(this._privyInternal)}async logout(){try{const r=await this._privyInternal.session.getRefreshToken()??void 0;await this._privyInternal.fetch(e.Logout,{body:{refresh_token:r}})}catch(e){console.warn("Error destroying session")}await Promise.all([this._privyInternal.session.destroyLocalState({reason:"logout"}),this._privyInternal.destroyClientAnalyticsId()]),this._privyInternal.callbacks?.setUser?.(null)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@privy-io/public-api");exports.default=class{_privyInternal;constructor(e){this._privyInternal=e}async initializeAuth(){return await this._privyInternal.fetch(e.FarcasterV2Init,{body:{}})}async authenticate({message:t,signature:r,fid:a}){const i=await this._privyInternal.fetch(e.FarcasterV2Authenticate,{body:{message:t,signature:r,fid:a}});return await this._privyInternal.session.updateWithTokensResponse(i),this._privyInternal.callbacks?.setUser?.(i.user),i}};
|
package/dist/cjs/Privy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./AppApi.js"),r=require("./AuthApi.js"),i=require("./EmbeddedWalletApi.js"),s=require("./MfaApi.js"),t=require("./MfaPromises.js"),a=require("./PrivyInternal.js"),u=require("./RecoveryApi.js"),n=require("./UserApi.js");require("@privy-io/public-api"),require("./CustomProviderApi.js"),require("./EmailApi.js"),require("./FarcasterApi.js"),require("./GuestApi.js"),require("./OAuthApi.js"),require("./Error.js"),require("./pkce.js"),require("jose"),require("./PasskeyApi.js"),require("./PhoneApi.js"),require("./SiweApi.js"),require("./SmartWalletApi.js"),require("./chains/index.js"),require("./chains/arbitrum.js"),require("./chains/arbitrumGoerli.js"),require("./chains/arbitrumSepolia.js"),require("./chains/avalanche.js"),require("./chains/avalancheFuji.js"),require("./chains/base.js"),require("./chains/baseGoerli.js"),require("./chains/baseSepolia.js"),require("./chains/berachainArtio.js"),require("./chains/celo.js"),require("./chains/celoAlfajores.js"),require("./chains/filecoin.js"),require("./chains/filecoinCalibration.js"),require("./chains/garnetHolesky.js"),require("./chains/goerli.js"),require("./chains/holesky.js"),require("./chains/linea.js"),require("./chains/lineaTestnet.js"),require("./chains/mainnet.js"),require("./chains/optimism.js"),require("./chains/optimismGoerli.js"),require("./chains/optimismSepolia.js"),require("./chains/polygon.js"),require("./chains/polygonMumbai.js"),require("./chains/redstone.js"),require("./chains/redstoneHolesky.js"),require("./chains/sepolia.js"),require("./chains/zora.js"),require("./chains/zoraSepolia.js"),require("./chains/zoraTestnet.js"),require("./embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("./embedded/errors.js"),require("./embedded/types.js"),require("./embedded/methods.js"),require("./embedded/utils/index.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("./embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("./embedded/utils/ethers.js"),require("./embedded/gas/bsc.js"),require("./embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("./embedded/gas/polygon.js"),require("@ethersproject/units"),require("fetch-retry"),require("./chains/polygonAmoy.js"),require("./embedded/utils/gas.js"),require("./embedded/EmbeddedSolanaWalletProvider.js"),require("./embedded/EmbeddedWalletProxy.js"),require("./embedded/EventCallbackQueue.js"),require("./embedded/withMfa.js"),require("./embedded/EmbeddedBitcoinWalletProvider.js"),require("./MfaPasskeyApi.js"),require("./MfaSmsApi.js"),require("uuid"),require("@privy-io/api-base"),require("./Session.js"),require("js-cookie"),require("./Token.js"),require("./utils/allSettled.js"),require("./toAbortSignalTimeout.js"),require("./RecoveryICloudApi.js"),require("./RecoveryOAuthApi.js");exports.default=class{auth;user;embeddedWallet;recovery;mfa;app;mfaPromises;_privyInternal;constructor({clientId:d,...o}){this._privyInternal=new a.PrivyInternal({...o,appClientId:d}),this.user=new n.default(this._privyInternal),this.app=new e.default(this._privyInternal),this.auth=new r.default(this._privyInternal,o.storage,o.crypto),this.mfa=new s.default(this._privyInternal),this.mfaPromises=new t.default,this.embeddedWallet=new i.default(this._privyInternal,o.embeddedWalletMessagePoster,o.supportedChains,this.mfa,this.mfaPromises),this.recovery=new u.default(this._privyInternal,o.storage,o.crypto)}async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./AppApi.js"),r=require("./AuthApi.js"),i=require("./EmbeddedWalletApi.js"),s=require("./MfaApi.js"),t=require("./MfaPromises.js"),a=require("./PrivyInternal.js"),u=require("./RecoveryApi.js"),n=require("./UserApi.js");require("@privy-io/public-api"),require("./CustomProviderApi.js"),require("./EmailApi.js"),require("./FarcasterApi.js"),require("./FarcasterV2Api.js"),require("./GuestApi.js"),require("./OAuthApi.js"),require("./Error.js"),require("./pkce.js"),require("jose"),require("./PasskeyApi.js"),require("./PhoneApi.js"),require("./SiweApi.js"),require("./SmartWalletApi.js"),require("./chains/index.js"),require("./chains/arbitrum.js"),require("./chains/arbitrumGoerli.js"),require("./chains/arbitrumSepolia.js"),require("./chains/avalanche.js"),require("./chains/avalancheFuji.js"),require("./chains/base.js"),require("./chains/baseGoerli.js"),require("./chains/baseSepolia.js"),require("./chains/berachainArtio.js"),require("./chains/celo.js"),require("./chains/celoAlfajores.js"),require("./chains/filecoin.js"),require("./chains/filecoinCalibration.js"),require("./chains/garnetHolesky.js"),require("./chains/goerli.js"),require("./chains/holesky.js"),require("./chains/linea.js"),require("./chains/lineaTestnet.js"),require("./chains/mainnet.js"),require("./chains/optimism.js"),require("./chains/optimismGoerli.js"),require("./chains/optimismSepolia.js"),require("./chains/polygon.js"),require("./chains/polygonMumbai.js"),require("./chains/redstone.js"),require("./chains/redstoneHolesky.js"),require("./chains/sepolia.js"),require("./chains/zora.js"),require("./chains/zoraSepolia.js"),require("./chains/zoraTestnet.js"),require("./embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("./embedded/errors.js"),require("./embedded/types.js"),require("./embedded/methods.js"),require("./embedded/utils/index.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("./embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("./embedded/utils/ethers.js"),require("./embedded/gas/bsc.js"),require("./embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("./embedded/gas/polygon.js"),require("@ethersproject/units"),require("fetch-retry"),require("./chains/polygonAmoy.js"),require("./embedded/utils/gas.js"),require("./embedded/EmbeddedSolanaWalletProvider.js"),require("./embedded/EmbeddedWalletProxy.js"),require("./embedded/EventCallbackQueue.js"),require("./embedded/withMfa.js"),require("./embedded/EmbeddedBitcoinWalletProvider.js"),require("./MfaPasskeyApi.js"),require("./MfaSmsApi.js"),require("uuid"),require("@privy-io/api-base"),require("./Session.js"),require("js-cookie"),require("./Token.js"),require("./utils/allSettled.js"),require("./toAbortSignalTimeout.js"),require("./RecoveryICloudApi.js"),require("./RecoveryOAuthApi.js");exports.default=class{auth;user;embeddedWallet;recovery;mfa;app;mfaPromises;_privyInternal;constructor({clientId:d,...o}){this._privyInternal=new a.PrivyInternal({...o,appClientId:d}),this.user=new n.default(this._privyInternal),this.app=new e.default(this._privyInternal),this.auth=new r.default(this._privyInternal,o.storage,o.crypto),this.mfa=new s.default(this._privyInternal),this.mfaPromises=new t.default,this.embeddedWallet=new i.default(this._privyInternal,o.embeddedWalletMessagePoster,o.supportedChains,this.mfa,this.mfaPromises),this.recovery=new u.default(this._privyInternal,o.storage,o.crypto)}async initialize(){await this._privyInternal._initialize()}setMessagePoster(e){this.embeddedWallet.setMessagePoster(e)}addOAuthTokensListener(e){return this._privyInternal.session.on("oauth_tokens_granted",e),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",e)}}}setCallbacks(e){this._privyInternal.setCallbacks(e)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/public-api"),a=require("./Error.js"),r=require("./Session.js"),n=require("./toAbortSignalTimeout.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("eventemitter3"),require("jose"),require("js-cookie"),require("./Token.js"),require("./utils/allSettled.js");var c=o(e);const h="privy:caid";exports.PrivyInternal=class{baseUrl;_config;appId;appClientId;_storage;_analyticsId;_sdkVersion="js-sdk-core:0.34.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/public-api"),a=require("./Error.js"),r=require("./Session.js"),n=require("./toAbortSignalTimeout.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("eventemitter3"),require("jose"),require("js-cookie"),require("./Token.js"),require("./utils/allSettled.js");var c=o(e);const h="privy:caid";exports.PrivyInternal=class{baseUrl;_config;appId;appClientId;_storage;_analyticsId;_sdkVersion="js-sdk-core:0.34.3-beta-20241119044014";_fetch;nativeAppIdentifier;callbacks;_cache=new Map;session;constructor(e){this._storage=e.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=e.baseUrl??"https://auth.privy.io",this.appId=e.appId,this.appClientId=e.appClientId,this._sdkVersion=e.sdkVersion??this._sdkVersion,this.callbacks=e.callbacks,"undefined"==typeof document&&(this.nativeAppIdentifier=e.nativeAppIdentifier),this.session=new r.Session({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=c.default(fetch,{retries:3,retryDelay:500}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return Boolean(this._config)}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new a.PrivyClientError({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this.createAnalyticsEvent("sdk_initialize",{})}}async fetch(e,{body:t,params:s,headers:r,options:n={onRequest:this._beforeRequest.bind(this)}}){const o=`${this.baseUrl}${i.getPathWithParams(e.path,s)}`,c=new Request(o,{method:e.method,body:JSON.stringify(t),headers:r}),h=await n.onRequest(c),l=await this._fetch(c,h),d=await l.json();if(l.status>299)throw new a.PrivyApiError(d);return d}async _beforeRequestWithoutInitialize(e){const t=await this.session.getToken(),s=new Headers(e.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-client",this._sdkVersion),t&&s.set("Authorization",`Bearer ${t}`),s.set("Content-Type","application/json"),s.set("Accept","application/json");const i=await this._getOrGenerateClientAnalyticsId();return i&&s.set("privy-ca-id",i),this.nativeAppIdentifier&&s.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:n.default(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i.AppConfig,{params:{app_id:this.appId},options:{onRequest:this._beforeRequestWithoutInitialize.bind(this)}})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{const e=await this._storage.get(h);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){console.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){console.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(h,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(h)}catch(e){console.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(i.AnalyticsEvent,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}})}catch(e){}}async refreshSession(){const e=await this.session.getRefreshToken()??void 0,t=e??"key",s=this._cache.get(t);if(s)return await s;const i=this._refreshSession(e);this._cache.set(t,i);try{return await i}catch(e){throw e}finally{this._cache.delete(t)}}async _refreshSession(e){const t=await this.session.getToken();if(!this.session.hasRefreshCredentials(t,e??null))throw await this._initialize(),new a.PrivyApiError({code:s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{const t=await this.fetch(i.RefreshSession,{body:{refresh_token:e},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}}),s=t.session_update_action;return this.callbacks?.setUser?.(t.user),"set"===s&&await this.session.updateWithTokensResponse(t),"clear"===s&&(await this.session.destroyLocalState(),this.callbacks?.setUser?.(null)),"ignore"===s&&t.token&&(await this.session.storeToken(t.token),t.identity_token&&await this.session.storeIdentityToken(t.identity_token)),t}catch(e){throw e instanceof a.PrivyApiError&&e.code===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),this.callbacks?.setUser?.(null)),e}}async getAccessToken(){const[e,t]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);return!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)?(await this.refreshSession(),await this.session.getToken()):e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{const e="privy:__storage__test",t="blobby";await this._storage.put(e,t);const s=await this._storage.get(e);return await this._storage.del(e),s===t}catch(e){return console.error(e),!1}}};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./Privy.js"),r=require("@privy-io/public-api"),i=require("./storage/LocalStorage.js"),t=require("./storage/InMemoryStorage.js"),s=require("./Error.js"),o=require("./embedded/errors.js"),a=require("./utils/getUserEmbeddedEthereumWallet.js"),d=require("./utils/getAllUserEmbeddedEthereumWallets.js"),u=require("./utils/getAllUserEmbeddedSolanaWallets.js"),n=require("./utils/getAllUserEmbeddedBitcoinWallets.js"),l=require("./utils/getUserSmartWallet.js"),c=require("./embedded/utils/index.js"),p=require("./utils/phoneNumberUtils.js"),m=require("./utils/getUserEmbeddedSolanaWallet.js"),j=require("./utils/toObjectKeys.js"),q=require("./embedded/utils/gas.js"),b=require("./embedded/utils/ethers.js"),E=require("./types.js"),h=require("./chains/index.js");require("./AppApi.js"),require("./AuthApi.js"),require("./CustomProviderApi.js"),require("./EmailApi.js"),require("./FarcasterApi.js"),require("./GuestApi.js"),require("./OAuthApi.js"),require("./pkce.js"),require("jose"),require("./PasskeyApi.js"),require("./PhoneApi.js"),require("./SiweApi.js"),require("./SmartWalletApi.js"),require("./EmbeddedWalletApi.js"),require("./embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("./embedded/methods.js"),require("./embedded/EmbeddedSolanaWalletProvider.js"),require("./embedded/EmbeddedWalletProxy.js"),require("./embedded/EventCallbackQueue.js"),require("./embedded/withMfa.js"),require("./embedded/EmbeddedBitcoinWalletProvider.js"),require("./MfaApi.js"),require("./MfaPasskeyApi.js"),require("./MfaSmsApi.js"),require("./MfaPromises.js"),require("./PrivyInternal.js"),require("fetch-retry"),require("uuid"),require("@privy-io/api-base"),require("./Session.js"),require("js-cookie"),require("./Token.js"),require("./utils/allSettled.js"),require("./toAbortSignalTimeout.js"),require("./RecoveryApi.js"),require("./RecoveryICloudApi.js"),require("./RecoveryOAuthApi.js"),require("./UserApi.js"),require("./embedded/types.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("./embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("./chains/arbitrum.js"),require("./chains/arbitrumGoerli.js"),require("./chains/arbitrumSepolia.js"),require("./embedded/gas/bsc.js"),require("./embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("./chains/base.js"),require("./chains/baseGoerli.js"),require("./chains/baseSepolia.js"),require("./chains/optimism.js"),require("./chains/optimismGoerli.js"),require("./chains/optimismSepolia.js"),require("./chains/zora.js"),require("./chains/zoraSepolia.js"),require("./chains/zoraTestnet.js"),require("./embedded/gas/polygon.js"),require("@ethersproject/units"),require("./chains/polygon.js"),require("./chains/polygonAmoy.js"),require("./chains/polygonMumbai.js"),require("./chains/avalanche.js"),require("./chains/avalancheFuji.js"),require("./chains/berachainArtio.js"),require("./chains/celo.js"),require("./chains/celoAlfajores.js"),require("./chains/filecoin.js"),require("./chains/filecoinCalibration.js"),require("./chains/garnetHolesky.js"),require("./chains/goerli.js"),require("./chains/holesky.js"),require("./chains/linea.js"),require("./chains/lineaTestnet.js"),require("./chains/mainnet.js"),require("./chains/redstone.js"),require("./chains/redstoneHolesky.js"),require("./chains/sepolia.js"),exports.default=e.default,Object.defineProperty(exports,"BICONOMY",{enumerable:!0,get:function(){return r.BICONOMY}}),Object.defineProperty(exports,"COINBASE_SMART_WALLET",{enumerable:!0,get:function(){return r.COINBASE_SMART_WALLET}}),Object.defineProperty(exports,"KERNEL",{enumerable:!0,get:function(){return r.KERNEL}}),Object.defineProperty(exports,"LIGHT_ACCOUNT",{enumerable:!0,get:function(){return r.LIGHT_ACCOUNT}}),Object.defineProperty(exports,"SAFE",{enumerable:!0,get:function(){return r.SAFE}}),exports.LocalStorage=i.LocalStorage,exports.InMemoryCache=t.InMemoryCache,exports.PrivyApiError=s.PrivyApiError,exports.PrivyClientError=s.PrivyClientError,exports.createErrorFormatter=s.createErrorFormatter,exports.errorIndicatesMfaCanceled=s.errorIndicatesMfaCanceled,exports.EmbeddedProviderError=o.EmbeddedProviderError,exports.PrivyConnectorError=o.PrivyConnectorError,Object.defineProperty(exports,"PrivyEmbeddedWalletErrorCode",{enumerable:!0,get:function(){return o.PrivyEmbeddedWalletErrorCode}}),exports.PrivyProviderRpcError=o.PrivyProviderRpcError,exports.ProviderErrors=o.ProviderErrors,exports.errorIndicatesMaxMfaRetries=o.errorIndicatesMaxMfaRetries,exports.errorIndicatesMfaRateLimit=o.errorIndicatesMfaRateLimit,exports.errorIndicatesMfaTimeout=o.errorIndicatesMfaTimeout,exports.errorIndicatesMfaVerificationFailed=o.errorIndicatesMfaVerificationFailed,exports.errorIndicatesRecoveryIsNeeded=o.errorIndicatesRecoveryIsNeeded,exports.getUserEmbeddedEthereumWallet=a.getUserEmbeddedEthereumWallet,exports.getUserEmbeddedWallet=a.getUserEmbeddedWallet,exports.getAllUserEmbeddedEthereumWallets=d.getAllUserEmbeddedEthereumWallets,exports.getAllUserEmbeddedSolanaWallets=u.getAllUserEmbeddedSolanaWallets,exports.getAllUserEmbeddedBitcoinWallets=n.getAllUserEmbeddedBitcoinWallets,exports.getUserSmartWallet=l.getUserSmartWallet,exports.getJsonRpcEndpointFromChain=c.getJsonRpcEndpointFromChain,exports.populateTransactionRequest=c.populateTransactionRequest,exports.throwIfInvalidRecoveryUpgradePath=c.throwIfInvalidRecoveryUpgradePath,exports.countryCodesAndNumbers=p.countryCodesAndNumbers,exports.formatPhoneNumber=p.formatPhoneNumber,exports.getCountryCallingCode=p.getCountryCallingCode,exports.getPhoneCountryCodeAndNumber=p.getPhoneCountryCodeAndNumber,exports.getPlaceholderPhoneNumber=p.getPlaceholderPhoneNumber,exports.lastFourDigits=p.lastFourDigits,exports.phoneNumberTypingFormatter=p.phoneNumberTypingFormatter,exports.validatePhoneNumber=p.validatePhoneNumber,exports.getUserEmbeddedSolanaWallet=m.getUserEmbeddedSolanaWallet,exports.toObjectKeys=j.toObjectKeys,exports.calculateTotalGasEstimate=q.calculateTotalGasEstimate,exports.QuantityToBigNumber=b.QuantityToBigNumber,exports.convertBigNumberish=b.convertBigNumberish,exports.toEthersUnsignedTransaction=b.toEthersUnsignedTransaction,exports.ALL_WALLET_CLIENT_TYPES=E.ALL_WALLET_CLIENT_TYPES,exports.SUPPORTED_CONNECTOR_TYPES=E.SUPPORTED_CONNECTOR_TYPES,exports.DEFAULT_SUPPORTED_CHAINS=h.DEFAULT_SUPPORTED_CHAINS,exports.DEFAULT_SUPPORTED_CHAIN_IDS=h.DEFAULT_SUPPORTED_CHAIN_IDS,exports.chainDefs=h.chainDefs;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./Privy.js"),r=require("@privy-io/public-api"),i=require("./storage/LocalStorage.js"),t=require("./storage/InMemoryStorage.js"),s=require("./Error.js"),o=require("./embedded/errors.js"),a=require("./utils/getUserEmbeddedEthereumWallet.js"),d=require("./utils/getAllUserEmbeddedEthereumWallets.js"),u=require("./utils/getAllUserEmbeddedSolanaWallets.js"),n=require("./utils/getAllUserEmbeddedBitcoinWallets.js"),l=require("./utils/getUserSmartWallet.js"),c=require("./embedded/utils/index.js"),p=require("./utils/phoneNumberUtils.js"),m=require("./utils/getUserEmbeddedSolanaWallet.js"),j=require("./utils/toObjectKeys.js"),q=require("./embedded/utils/gas.js"),b=require("./embedded/utils/ethers.js"),E=require("./types.js"),h=require("./chains/index.js");require("./AppApi.js"),require("./AuthApi.js"),require("./CustomProviderApi.js"),require("./EmailApi.js"),require("./FarcasterApi.js"),require("./FarcasterV2Api.js"),require("./GuestApi.js"),require("./OAuthApi.js"),require("./pkce.js"),require("jose"),require("./PasskeyApi.js"),require("./PhoneApi.js"),require("./SiweApi.js"),require("./SmartWalletApi.js"),require("./EmbeddedWalletApi.js"),require("./embedded/EmbeddedWalletProvider.js"),require("eventemitter3"),require("./embedded/methods.js"),require("./embedded/EmbeddedSolanaWalletProvider.js"),require("./embedded/EmbeddedWalletProxy.js"),require("./embedded/EventCallbackQueue.js"),require("./embedded/withMfa.js"),require("./embedded/EmbeddedBitcoinWalletProvider.js"),require("./MfaApi.js"),require("./MfaPasskeyApi.js"),require("./MfaSmsApi.js"),require("./MfaPromises.js"),require("./PrivyInternal.js"),require("fetch-retry"),require("uuid"),require("@privy-io/api-base"),require("./Session.js"),require("js-cookie"),require("./Token.js"),require("./utils/allSettled.js"),require("./toAbortSignalTimeout.js"),require("./RecoveryApi.js"),require("./RecoveryICloudApi.js"),require("./RecoveryOAuthApi.js"),require("./UserApi.js"),require("./embedded/types.js"),require("@ethersproject/abstract-signer"),require("@ethersproject/providers"),require("./embedded/gas/arbitrum.js"),require("@ethersproject/bignumber"),require("./chains/arbitrum.js"),require("./chains/arbitrumGoerli.js"),require("./chains/arbitrumSepolia.js"),require("./embedded/gas/bsc.js"),require("./embedded/gas/op-stack.js"),require("@ethersproject/contracts"),require("@ethersproject/transactions"),require("./chains/base.js"),require("./chains/baseGoerli.js"),require("./chains/baseSepolia.js"),require("./chains/optimism.js"),require("./chains/optimismGoerli.js"),require("./chains/optimismSepolia.js"),require("./chains/zora.js"),require("./chains/zoraSepolia.js"),require("./chains/zoraTestnet.js"),require("./embedded/gas/polygon.js"),require("@ethersproject/units"),require("./chains/polygon.js"),require("./chains/polygonAmoy.js"),require("./chains/polygonMumbai.js"),require("./chains/avalanche.js"),require("./chains/avalancheFuji.js"),require("./chains/berachainArtio.js"),require("./chains/celo.js"),require("./chains/celoAlfajores.js"),require("./chains/filecoin.js"),require("./chains/filecoinCalibration.js"),require("./chains/garnetHolesky.js"),require("./chains/goerli.js"),require("./chains/holesky.js"),require("./chains/linea.js"),require("./chains/lineaTestnet.js"),require("./chains/mainnet.js"),require("./chains/redstone.js"),require("./chains/redstoneHolesky.js"),require("./chains/sepolia.js"),exports.default=e.default,Object.defineProperty(exports,"BICONOMY",{enumerable:!0,get:function(){return r.BICONOMY}}),Object.defineProperty(exports,"COINBASE_SMART_WALLET",{enumerable:!0,get:function(){return r.COINBASE_SMART_WALLET}}),Object.defineProperty(exports,"KERNEL",{enumerable:!0,get:function(){return r.KERNEL}}),Object.defineProperty(exports,"LIGHT_ACCOUNT",{enumerable:!0,get:function(){return r.LIGHT_ACCOUNT}}),Object.defineProperty(exports,"SAFE",{enumerable:!0,get:function(){return r.SAFE}}),exports.LocalStorage=i.LocalStorage,exports.InMemoryCache=t.InMemoryCache,exports.PrivyApiError=s.PrivyApiError,exports.PrivyClientError=s.PrivyClientError,exports.createErrorFormatter=s.createErrorFormatter,exports.errorIndicatesMfaCanceled=s.errorIndicatesMfaCanceled,exports.EmbeddedProviderError=o.EmbeddedProviderError,exports.PrivyConnectorError=o.PrivyConnectorError,Object.defineProperty(exports,"PrivyEmbeddedWalletErrorCode",{enumerable:!0,get:function(){return o.PrivyEmbeddedWalletErrorCode}}),exports.PrivyProviderRpcError=o.PrivyProviderRpcError,exports.ProviderErrors=o.ProviderErrors,exports.errorIndicatesMaxMfaRetries=o.errorIndicatesMaxMfaRetries,exports.errorIndicatesMfaRateLimit=o.errorIndicatesMfaRateLimit,exports.errorIndicatesMfaTimeout=o.errorIndicatesMfaTimeout,exports.errorIndicatesMfaVerificationFailed=o.errorIndicatesMfaVerificationFailed,exports.errorIndicatesRecoveryIsNeeded=o.errorIndicatesRecoveryIsNeeded,exports.getUserEmbeddedEthereumWallet=a.getUserEmbeddedEthereumWallet,exports.getUserEmbeddedWallet=a.getUserEmbeddedWallet,exports.getAllUserEmbeddedEthereumWallets=d.getAllUserEmbeddedEthereumWallets,exports.getAllUserEmbeddedSolanaWallets=u.getAllUserEmbeddedSolanaWallets,exports.getAllUserEmbeddedBitcoinWallets=n.getAllUserEmbeddedBitcoinWallets,exports.getUserSmartWallet=l.getUserSmartWallet,exports.getJsonRpcEndpointFromChain=c.getJsonRpcEndpointFromChain,exports.populateTransactionRequest=c.populateTransactionRequest,exports.throwIfInvalidRecoveryUpgradePath=c.throwIfInvalidRecoveryUpgradePath,exports.countryCodesAndNumbers=p.countryCodesAndNumbers,exports.formatPhoneNumber=p.formatPhoneNumber,exports.getCountryCallingCode=p.getCountryCallingCode,exports.getPhoneCountryCodeAndNumber=p.getPhoneCountryCodeAndNumber,exports.getPlaceholderPhoneNumber=p.getPlaceholderPhoneNumber,exports.lastFourDigits=p.lastFourDigits,exports.phoneNumberTypingFormatter=p.phoneNumberTypingFormatter,exports.validatePhoneNumber=p.validatePhoneNumber,exports.getUserEmbeddedSolanaWallet=m.getUserEmbeddedSolanaWallet,exports.toObjectKeys=j.toObjectKeys,exports.calculateTotalGasEstimate=q.calculateTotalGasEstimate,exports.QuantityToBigNumber=b.QuantityToBigNumber,exports.convertBigNumberish=b.convertBigNumberish,exports.toEthersUnsignedTransaction=b.toEthersUnsignedTransaction,exports.ALL_WALLET_CLIENT_TYPES=E.ALL_WALLET_CLIENT_TYPES,exports.SUPPORTED_CONNECTOR_TYPES=E.SUPPORTED_CONNECTOR_TYPES,exports.DEFAULT_SUPPORTED_CHAINS=h.DEFAULT_SUPPORTED_CHAINS,exports.DEFAULT_SUPPORTED_CHAIN_IDS=h.DEFAULT_SUPPORTED_CHAIN_IDS,exports.chainDefs=h.chainDefs;
|
package/dist/dts/AuthApi.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import CustomProviderApi from './CustomProviderApi';
|
|
2
2
|
import EmailApi from './EmailApi';
|
|
3
3
|
import FarcasterApi from './FarcasterApi';
|
|
4
|
+
import FarcasterV2Api from './FarcasterV2Api';
|
|
4
5
|
import GuestApi from './GuestApi';
|
|
5
6
|
import OAuthApi from './OAuthApi';
|
|
6
7
|
import PasskeyApi from './PasskeyApi';
|
|
@@ -40,6 +41,11 @@ export default class AuthApi {
|
|
|
40
41
|
* APIs for login with Farcaster
|
|
41
42
|
*/
|
|
42
43
|
readonly farcaster: FarcasterApi;
|
|
44
|
+
/**
|
|
45
|
+
* @experimental
|
|
46
|
+
* APIs for bare metal login with Farcaster
|
|
47
|
+
*/
|
|
48
|
+
readonly farcasterV2: FarcasterV2Api;
|
|
43
49
|
/**
|
|
44
50
|
* APIs for guest login
|
|
45
51
|
*/
|
package/dist/dts/AuthApi.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import CustomProviderApi from './CustomProviderApi';
|
|
2
2
|
import EmailApi from './EmailApi';
|
|
3
3
|
import FarcasterApi from './FarcasterApi';
|
|
4
|
+
import FarcasterV2Api from './FarcasterV2Api';
|
|
4
5
|
import GuestApi from './GuestApi';
|
|
5
6
|
import OAuthApi from './OAuthApi';
|
|
6
7
|
import PasskeyApi from './PasskeyApi';
|
|
@@ -40,6 +41,11 @@ export default class AuthApi {
|
|
|
40
41
|
* APIs for login with Farcaster
|
|
41
42
|
*/
|
|
42
43
|
readonly farcaster: FarcasterApi;
|
|
44
|
+
/**
|
|
45
|
+
* @experimental
|
|
46
|
+
* APIs for bare metal login with Farcaster
|
|
47
|
+
*/
|
|
48
|
+
readonly farcasterV2: FarcasterV2Api;
|
|
43
49
|
/**
|
|
44
50
|
* APIs for guest login
|
|
45
51
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class FarcasterV2Api {
|
|
2
|
+
/**
|
|
3
|
+
* Begin a login / link flow with a farcaster.
|
|
4
|
+
*/
|
|
5
|
+
initializeAuth(): Promise<import("@privy-io/public-api").PrivyFarcasterV2InitResponse>;
|
|
6
|
+
/**
|
|
7
|
+
* Authenticate with Privy via the Sign-In With Farcaster spec [FIP-11: Sign in with Farcaster](https://github.com/farcasterxyz/protocol/discussions/110).
|
|
8
|
+
*/
|
|
9
|
+
authenticate({ message, signature, fid, }: {
|
|
10
|
+
message: string;
|
|
11
|
+
signature: string;
|
|
12
|
+
fid: number;
|
|
13
|
+
mode?: 'login-or-sign-up' | 'no-signup';
|
|
14
|
+
}): Promise<import("@privy-io/public-api").PrivyAuthenticatedUser>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default class FarcasterV2Api {
|
|
2
|
+
/**
|
|
3
|
+
* Begin a login / link flow with a farcaster.
|
|
4
|
+
*/
|
|
5
|
+
initializeAuth(): Promise<import("@privy-io/public-api").PrivyFarcasterV2InitResponse>;
|
|
6
|
+
/**
|
|
7
|
+
* Authenticate with Privy via the Sign-In With Farcaster spec [FIP-11: Sign in with Farcaster](https://github.com/farcasterxyz/protocol/discussions/110).
|
|
8
|
+
*/
|
|
9
|
+
authenticate({ message, signature, fid, }: {
|
|
10
|
+
message: string;
|
|
11
|
+
signature: string;
|
|
12
|
+
fid: number;
|
|
13
|
+
mode?: 'login-or-sign-up' | 'no-signup';
|
|
14
|
+
}): Promise<import("@privy-io/public-api").PrivyAuthenticatedUser>;
|
|
15
|
+
}
|
package/dist/esm/AuthApi.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logout as
|
|
1
|
+
import{Logout as r}from"@privy-io/public-api";import t from"./CustomProviderApi.mjs";import i from"./EmailApi.mjs";import s from"./FarcasterApi.mjs";import e from"./FarcasterV2Api.mjs";import a from"./GuestApi.mjs";import o from"./OAuthApi.mjs";import n from"./PasskeyApi.mjs";import p from"./PhoneApi.mjs";import m from"./SiweApi.mjs";import l from"./SmartWalletApi.mjs";import"./Error.mjs";import"./pkce.mjs";import"jose";class h{_privyInternal;customProvider;phone;email;oauth;siwe;smartWallet;passkey;farcaster;farcasterV2;guest;constructor(r,h,y){this._privyInternal=r,this.customProvider=new t(this._privyInternal),this.phone=new p(this._privyInternal),this.email=new i(this._privyInternal),this.oauth=new o(this._privyInternal,h,y),this.guest=new a(this._privyInternal),this.siwe=new m(this._privyInternal),this.smartWallet=new l(this._privyInternal),this.passkey=new n(this._privyInternal),this.farcaster=new s(this._privyInternal),this.farcasterV2=new e(this._privyInternal)}async logout(){try{const t=await this._privyInternal.session.getRefreshToken()??void 0;await this._privyInternal.fetch(r,{body:{refresh_token:t}})}catch(r){console.warn("Error destroying session")}await Promise.all([this._privyInternal.session.destroyLocalState({reason:"logout"}),this._privyInternal.destroyClientAnalyticsId()]),this._privyInternal.callbacks?.setUser?.(null)}}export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{FarcasterV2Init as t,FarcasterV2Authenticate as i}from"@privy-io/public-api";class e{_privyInternal;constructor(t){this._privyInternal=t}async initializeAuth(){return await this._privyInternal.fetch(t,{body:{}})}async authenticate({message:t,signature:e,fid:a}){const s=await this._privyInternal.fetch(i,{body:{message:t,signature:e,fid:a}});return await this._privyInternal.session.updateWithTokensResponse(s),this._privyInternal.callbacks?.setUser?.(s.user),s}}export{e as default};
|
package/dist/esm/Privy.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import i from"./AppApi.mjs";import e from"./AuthApi.mjs";import t from"./EmbeddedWalletApi.mjs";import s from"./MfaApi.mjs";import r from"./MfaPromises.mjs";import{PrivyInternal as m}from"./PrivyInternal.mjs";import o from"./RecoveryApi.mjs";import p from"./UserApi.mjs";import"@privy-io/public-api";import"./CustomProviderApi.mjs";import"./EmailApi.mjs";import"./FarcasterApi.mjs";import"./GuestApi.mjs";import"./OAuthApi.mjs";import"./Error.mjs";import"./pkce.mjs";import"jose";import"./PasskeyApi.mjs";import"./PhoneApi.mjs";import"./SiweApi.mjs";import"./SmartWalletApi.mjs";import"./chains/index.mjs";import"./chains/arbitrum.mjs";import"./chains/arbitrumGoerli.mjs";import"./chains/arbitrumSepolia.mjs";import"./chains/avalanche.mjs";import"./chains/avalancheFuji.mjs";import"./chains/base.mjs";import"./chains/baseGoerli.mjs";import"./chains/baseSepolia.mjs";import"./chains/berachainArtio.mjs";import"./chains/celo.mjs";import"./chains/celoAlfajores.mjs";import"./chains/filecoin.mjs";import"./chains/filecoinCalibration.mjs";import"./chains/garnetHolesky.mjs";import"./chains/goerli.mjs";import"./chains/holesky.mjs";import"./chains/linea.mjs";import"./chains/lineaTestnet.mjs";import"./chains/mainnet.mjs";import"./chains/optimism.mjs";import"./chains/optimismGoerli.mjs";import"./chains/optimismSepolia.mjs";import"./chains/polygon.mjs";import"./chains/polygonMumbai.mjs";import"./chains/redstone.mjs";import"./chains/redstoneHolesky.mjs";import"./chains/sepolia.mjs";import"./chains/zora.mjs";import"./chains/zoraSepolia.mjs";import"./chains/zoraTestnet.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"./embedded/errors.mjs";import"./embedded/types.mjs";import"./embedded/methods.mjs";import"./embedded/utils/index.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"./embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"./embedded/utils/ethers.mjs";import"./embedded/gas/bsc.mjs";import"./embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./embedded/gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"./chains/polygonAmoy.mjs";import"./embedded/utils/gas.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./MfaPasskeyApi.mjs";import"./MfaSmsApi.mjs";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./Token.mjs";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./RecoveryICloudApi.mjs";import"./RecoveryOAuthApi.mjs";class a{auth;user;embeddedWallet;recovery;mfa;app;mfaPromises;_privyInternal;constructor({clientId:a,...n}){this._privyInternal=new m({...n,appClientId:a}),this.user=new p(this._privyInternal),this.app=new i(this._privyInternal),this.auth=new e(this._privyInternal,n.storage,n.crypto),this.mfa=new s(this._privyInternal),this.mfaPromises=new r,this.embeddedWallet=new t(this._privyInternal,n.embeddedWalletMessagePoster,n.supportedChains,this.mfa,this.mfaPromises),this.recovery=new o(this._privyInternal,n.storage,n.crypto)}async initialize(){await this._privyInternal._initialize()}setMessagePoster(i){this.embeddedWallet.setMessagePoster(i)}addOAuthTokensListener(i){return this._privyInternal.session.on("oauth_tokens_granted",i),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",i)}}}setCallbacks(i){this._privyInternal.setCallbacks(i)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}}export{a as default};
|
|
1
|
+
import i from"./AppApi.mjs";import e from"./AuthApi.mjs";import t from"./EmbeddedWalletApi.mjs";import s from"./MfaApi.mjs";import r from"./MfaPromises.mjs";import{PrivyInternal as m}from"./PrivyInternal.mjs";import o from"./RecoveryApi.mjs";import p from"./UserApi.mjs";import"@privy-io/public-api";import"./CustomProviderApi.mjs";import"./EmailApi.mjs";import"./FarcasterApi.mjs";import"./FarcasterV2Api.mjs";import"./GuestApi.mjs";import"./OAuthApi.mjs";import"./Error.mjs";import"./pkce.mjs";import"jose";import"./PasskeyApi.mjs";import"./PhoneApi.mjs";import"./SiweApi.mjs";import"./SmartWalletApi.mjs";import"./chains/index.mjs";import"./chains/arbitrum.mjs";import"./chains/arbitrumGoerli.mjs";import"./chains/arbitrumSepolia.mjs";import"./chains/avalanche.mjs";import"./chains/avalancheFuji.mjs";import"./chains/base.mjs";import"./chains/baseGoerli.mjs";import"./chains/baseSepolia.mjs";import"./chains/berachainArtio.mjs";import"./chains/celo.mjs";import"./chains/celoAlfajores.mjs";import"./chains/filecoin.mjs";import"./chains/filecoinCalibration.mjs";import"./chains/garnetHolesky.mjs";import"./chains/goerli.mjs";import"./chains/holesky.mjs";import"./chains/linea.mjs";import"./chains/lineaTestnet.mjs";import"./chains/mainnet.mjs";import"./chains/optimism.mjs";import"./chains/optimismGoerli.mjs";import"./chains/optimismSepolia.mjs";import"./chains/polygon.mjs";import"./chains/polygonMumbai.mjs";import"./chains/redstone.mjs";import"./chains/redstoneHolesky.mjs";import"./chains/sepolia.mjs";import"./chains/zora.mjs";import"./chains/zoraSepolia.mjs";import"./chains/zoraTestnet.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"./embedded/errors.mjs";import"./embedded/types.mjs";import"./embedded/methods.mjs";import"./embedded/utils/index.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"./embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"./embedded/utils/ethers.mjs";import"./embedded/gas/bsc.mjs";import"./embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./embedded/gas/polygon.mjs";import"@ethersproject/units";import"fetch-retry";import"./chains/polygonAmoy.mjs";import"./embedded/utils/gas.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./MfaPasskeyApi.mjs";import"./MfaSmsApi.mjs";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./Token.mjs";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./RecoveryICloudApi.mjs";import"./RecoveryOAuthApi.mjs";class a{auth;user;embeddedWallet;recovery;mfa;app;mfaPromises;_privyInternal;constructor({clientId:a,...n}){this._privyInternal=new m({...n,appClientId:a}),this.user=new p(this._privyInternal),this.app=new i(this._privyInternal),this.auth=new e(this._privyInternal,n.storage,n.crypto),this.mfa=new s(this._privyInternal),this.mfaPromises=new r,this.embeddedWallet=new t(this._privyInternal,n.embeddedWalletMessagePoster,n.supportedChains,this.mfa,this.mfaPromises),this.recovery=new o(this._privyInternal,n.storage,n.crypto)}async initialize(){await this._privyInternal._initialize()}setMessagePoster(i){this.embeddedWallet.setMessagePoster(i)}addOAuthTokensListener(i){return this._privyInternal.session.on("oauth_tokens_granted",i),{unsubscribe:()=>{this._privyInternal.session.removeListener("oauth_tokens_granted",i)}}}setCallbacks(i){this._privyInternal.setCallbacks(i)}getAccessToken(){return this._privyInternal.getAccessToken()}getIdentityToken(){return this._privyInternal.getIdentityToken()}}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"fetch-retry";import{v4 as e}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as a,AnalyticsEvent as n,RefreshSession as r}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as c}from"./Error.mjs";import{Session as h}from"./Session.mjs";import l from"./toAbortSignalTimeout.mjs";import"eventemitter3";import"jose";import"js-cookie";import"./Token.mjs";import"./utils/allSettled.mjs";const d="privy:caid";class p{baseUrl;_config;appId;appClientId;_storage;_analyticsId;_sdkVersion="js-sdk-core:0.34.
|
|
1
|
+
import t from"fetch-retry";import{v4 as e}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as a,AnalyticsEvent as n,RefreshSession as r}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as c}from"./Error.mjs";import{Session as h}from"./Session.mjs";import l from"./toAbortSignalTimeout.mjs";import"eventemitter3";import"jose";import"js-cookie";import"./Token.mjs";import"./utils/allSettled.mjs";const d="privy:caid";class p{baseUrl;_config;appId;appClientId;_storage;_analyticsId;_sdkVersion="js-sdk-core:0.34.3-beta-20241119044014";_fetch;nativeAppIdentifier;callbacks;_cache=new Map;session;constructor(e){this._storage=e.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=e.baseUrl??"https://auth.privy.io",this.appId=e.appId,this.appClientId=e.appClientId,this._sdkVersion=e.sdkVersion??this._sdkVersion,this.callbacks=e.callbacks,"undefined"==typeof document&&(this.nativeAppIdentifier=e.nativeAppIdentifier),this.session=new h({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=t(fetch,{retries:3,retryDelay:500}),this.session.on("error_storing_tokens",(t=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:t})}))}setCallbacks(t){this.callbacks={...this.callbacks,...t}}get isReady(){return Boolean(this._config)}get config(){return this._config}get caid(){return this._analyticsId}async _initialize(){if(this.isReady)this.callbacks?.setIsReady?.(!0);else{if(!await this.isStorageAccessible())throw new o({code:"storage_error",error:"Unable to access storage"});this._config=await this.getAppConfig(),this._config?.custom_api_url&&(this.baseUrl=this._config.custom_api_url,this.session.isUsingServerCookies=!0),this.callbacks?.setIsReady?.(!0),this.createAnalyticsEvent("sdk_initialize",{})}}async fetch(t,{body:e,params:s,headers:a,options:n={onRequest:this._beforeRequest.bind(this)}}){const r=`${this.baseUrl}${i(t.path,s)}`,o=new Request(r,{method:t.method,body:JSON.stringify(e),headers:a}),h=await n.onRequest(o),l=await this._fetch(o,h),d=await l.json();if(l.status>299)throw new c(d);return d}async _beforeRequestWithoutInitialize(t){const e=await this.session.getToken(),s=new Headers(t.headers);s.set("privy-app-id",this.appId),this.appClientId&&s.set("privy-client-id",this.appClientId),s.set("privy-client",this._sdkVersion),e&&s.set("Authorization",`Bearer ${e}`),s.set("Content-Type","application/json"),s.set("Accept","application/json");const i=await this._getOrGenerateClientAnalyticsId();return i&&s.set("privy-ca-id",i),this.nativeAppIdentifier&&s.set("x-native-app-identifier",this.nativeAppIdentifier),{signal:l(2e4),headers:s,credentials:"include"}}async beforeRequestWithoutRefresh(t){return await this._initialize(),this._beforeRequestWithoutInitialize(t)}async _beforeRequest(t){return await this._initialize(),await this.getAccessToken(),this.beforeRequestWithoutRefresh(t)}async getAppConfig(){return await this.fetch(a,{params:{app_id:this.appId},options:{onRequest:this._beforeRequestWithoutInitialize.bind(this)}})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{const t=await this._storage.get(d);if("string"==typeof t&&t.length>0)return this._analyticsId=t,t}catch(t){console.error("Unable to load clientId",t)}try{this._analyticsId=e()}catch(t){console.error("Unable to generate uuidv4",t)}if(!this._analyticsId)return null;try{await this._storage.put(d,this._analyticsId)}catch(t){console.error(`Unable to store clientId: ${this._analyticsId}`,t)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(d)}catch(t){console.error("Unable to delete clientId",t)}}async createAnalyticsEvent(t,e){try{await this.fetch(n,{body:{event_name:t,client_id:await this._getOrGenerateClientAnalyticsId(),payload:e},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}})}catch(t){}}async refreshSession(){const t=await this.session.getRefreshToken()??void 0,e=t??"key",s=this._cache.get(e);if(s)return await s;const i=this._refreshSession(t);this._cache.set(e,i);try{return await i}catch(t){throw t}finally{this._cache.delete(e)}}async _refreshSession(t){const e=await this.session.getToken();if(!this.session.hasRefreshCredentials(e,t??null))throw await this._initialize(),new c({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{const e=await this.fetch(r,{body:{refresh_token:t},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}}),s=e.session_update_action;return this.callbacks?.setUser?.(e.user),"set"===s&&await this.session.updateWithTokensResponse(e),"clear"===s&&(await this.session.destroyLocalState(),this.callbacks?.setUser?.(null)),"ignore"===s&&e.token&&(await this.session.storeToken(e.token),e.identity_token&&await this.session.storeIdentityToken(e.identity_token)),e}catch(t){throw t instanceof c&&t.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),this.callbacks?.setUser?.(null)),t}}async getAccessToken(){const[t,e]=await Promise.all([this.session.getToken(),this.session.getRefreshToken()]);return!this.session.tokenIsActive(t)&&this.session.hasRefreshCredentials(t,e)?(await this.refreshSession(),await this.session.getToken()):t}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{const t="privy:__storage__test",e="blobby";await this._storage.put(t,e);const s=await this._storage.get(t);return await this._storage.del(t),s===e}catch(t){return console.error(t),!1}}}export{p as PrivyInternal};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./Privy.mjs";export{default}from"./Privy.mjs";export{BICONOMY,COINBASE_SMART_WALLET,KERNEL,LIGHT_ACCOUNT,SAFE}from"@privy-io/public-api";export{LocalStorage}from"./storage/LocalStorage.mjs";export{InMemoryCache}from"./storage/InMemoryStorage.mjs";export{PrivyApiError,PrivyClientError,createErrorFormatter,errorIndicatesMfaCanceled}from"./Error.mjs";export{EmbeddedProviderError,PrivyConnectorError,PrivyEmbeddedWalletErrorCode,PrivyProviderRpcError,ProviderErrors,errorIndicatesMaxMfaRetries,errorIndicatesMfaRateLimit,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,errorIndicatesRecoveryIsNeeded}from"./embedded/errors.mjs";export{getUserEmbeddedEthereumWallet,getUserEmbeddedWallet}from"./utils/getUserEmbeddedEthereumWallet.mjs";export{getAllUserEmbeddedEthereumWallets}from"./utils/getAllUserEmbeddedEthereumWallets.mjs";export{getAllUserEmbeddedSolanaWallets}from"./utils/getAllUserEmbeddedSolanaWallets.mjs";export{getAllUserEmbeddedBitcoinWallets}from"./utils/getAllUserEmbeddedBitcoinWallets.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,populateTransactionRequest,throwIfInvalidRecoveryUpgradePath}from"./embedded/utils/index.mjs";export{countryCodesAndNumbers,formatPhoneNumber,getCountryCallingCode,getPhoneCountryCodeAndNumber,getPlaceholderPhoneNumber,lastFourDigits,phoneNumberTypingFormatter,validatePhoneNumber}from"./utils/phoneNumberUtils.mjs";export{getUserEmbeddedSolanaWallet}from"./utils/getUserEmbeddedSolanaWallet.mjs";export{toObjectKeys}from"./utils/toObjectKeys.mjs";export{calculateTotalGasEstimate}from"./embedded/utils/gas.mjs";export{QuantityToBigNumber,convertBigNumberish,toEthersUnsignedTransaction}from"./embedded/utils/ethers.mjs";export{ALL_WALLET_CLIENT_TYPES,SUPPORTED_CONNECTOR_TYPES}from"./types.mjs";export{DEFAULT_SUPPORTED_CHAINS,DEFAULT_SUPPORTED_CHAIN_IDS,chainDefs}from"./chains/index.mjs";import"./AppApi.mjs";import"./AuthApi.mjs";import"./CustomProviderApi.mjs";import"./EmailApi.mjs";import"./FarcasterApi.mjs";import"./GuestApi.mjs";import"./OAuthApi.mjs";import"./pkce.mjs";import"jose";import"./PasskeyApi.mjs";import"./PhoneApi.mjs";import"./SiweApi.mjs";import"./SmartWalletApi.mjs";import"./EmbeddedWalletApi.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"./embedded/methods.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./MfaApi.mjs";import"./MfaPasskeyApi.mjs";import"./MfaSmsApi.mjs";import"./MfaPromises.mjs";import"./PrivyInternal.mjs";import"fetch-retry";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./Token.mjs";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./RecoveryApi.mjs";import"./RecoveryICloudApi.mjs";import"./RecoveryOAuthApi.mjs";import"./UserApi.mjs";import"./embedded/types.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"./embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"./chains/arbitrum.mjs";import"./chains/arbitrumGoerli.mjs";import"./chains/arbitrumSepolia.mjs";import"./embedded/gas/bsc.mjs";import"./embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./chains/base.mjs";import"./chains/baseGoerli.mjs";import"./chains/baseSepolia.mjs";import"./chains/optimism.mjs";import"./chains/optimismGoerli.mjs";import"./chains/optimismSepolia.mjs";import"./chains/zora.mjs";import"./chains/zoraSepolia.mjs";import"./chains/zoraTestnet.mjs";import"./embedded/gas/polygon.mjs";import"@ethersproject/units";import"./chains/polygon.mjs";import"./chains/polygonAmoy.mjs";import"./chains/polygonMumbai.mjs";import"./chains/avalanche.mjs";import"./chains/avalancheFuji.mjs";import"./chains/berachainArtio.mjs";import"./chains/celo.mjs";import"./chains/celoAlfajores.mjs";import"./chains/filecoin.mjs";import"./chains/filecoinCalibration.mjs";import"./chains/garnetHolesky.mjs";import"./chains/goerli.mjs";import"./chains/holesky.mjs";import"./chains/linea.mjs";import"./chains/lineaTestnet.mjs";import"./chains/mainnet.mjs";import"./chains/redstone.mjs";import"./chains/redstoneHolesky.mjs";import"./chains/sepolia.mjs";
|
|
1
|
+
import e from"./Privy.mjs";export{default}from"./Privy.mjs";export{BICONOMY,COINBASE_SMART_WALLET,KERNEL,LIGHT_ACCOUNT,SAFE}from"@privy-io/public-api";export{LocalStorage}from"./storage/LocalStorage.mjs";export{InMemoryCache}from"./storage/InMemoryStorage.mjs";export{PrivyApiError,PrivyClientError,createErrorFormatter,errorIndicatesMfaCanceled}from"./Error.mjs";export{EmbeddedProviderError,PrivyConnectorError,PrivyEmbeddedWalletErrorCode,PrivyProviderRpcError,ProviderErrors,errorIndicatesMaxMfaRetries,errorIndicatesMfaRateLimit,errorIndicatesMfaTimeout,errorIndicatesMfaVerificationFailed,errorIndicatesRecoveryIsNeeded}from"./embedded/errors.mjs";export{getUserEmbeddedEthereumWallet,getUserEmbeddedWallet}from"./utils/getUserEmbeddedEthereumWallet.mjs";export{getAllUserEmbeddedEthereumWallets}from"./utils/getAllUserEmbeddedEthereumWallets.mjs";export{getAllUserEmbeddedSolanaWallets}from"./utils/getAllUserEmbeddedSolanaWallets.mjs";export{getAllUserEmbeddedBitcoinWallets}from"./utils/getAllUserEmbeddedBitcoinWallets.mjs";export{getUserSmartWallet}from"./utils/getUserSmartWallet.mjs";export{getJsonRpcEndpointFromChain,populateTransactionRequest,throwIfInvalidRecoveryUpgradePath}from"./embedded/utils/index.mjs";export{countryCodesAndNumbers,formatPhoneNumber,getCountryCallingCode,getPhoneCountryCodeAndNumber,getPlaceholderPhoneNumber,lastFourDigits,phoneNumberTypingFormatter,validatePhoneNumber}from"./utils/phoneNumberUtils.mjs";export{getUserEmbeddedSolanaWallet}from"./utils/getUserEmbeddedSolanaWallet.mjs";export{toObjectKeys}from"./utils/toObjectKeys.mjs";export{calculateTotalGasEstimate}from"./embedded/utils/gas.mjs";export{QuantityToBigNumber,convertBigNumberish,toEthersUnsignedTransaction}from"./embedded/utils/ethers.mjs";export{ALL_WALLET_CLIENT_TYPES,SUPPORTED_CONNECTOR_TYPES}from"./types.mjs";export{DEFAULT_SUPPORTED_CHAINS,DEFAULT_SUPPORTED_CHAIN_IDS,chainDefs}from"./chains/index.mjs";import"./AppApi.mjs";import"./AuthApi.mjs";import"./CustomProviderApi.mjs";import"./EmailApi.mjs";import"./FarcasterApi.mjs";import"./FarcasterV2Api.mjs";import"./GuestApi.mjs";import"./OAuthApi.mjs";import"./pkce.mjs";import"jose";import"./PasskeyApi.mjs";import"./PhoneApi.mjs";import"./SiweApi.mjs";import"./SmartWalletApi.mjs";import"./EmbeddedWalletApi.mjs";import"./embedded/EmbeddedWalletProvider.mjs";import"eventemitter3";import"./embedded/methods.mjs";import"./embedded/EmbeddedSolanaWalletProvider.mjs";import"./embedded/EmbeddedWalletProxy.mjs";import"./embedded/EventCallbackQueue.mjs";import"./embedded/withMfa.mjs";import"./embedded/EmbeddedBitcoinWalletProvider.mjs";import"./MfaApi.mjs";import"./MfaPasskeyApi.mjs";import"./MfaSmsApi.mjs";import"./MfaPromises.mjs";import"./PrivyInternal.mjs";import"fetch-retry";import"uuid";import"@privy-io/api-base";import"./Session.mjs";import"js-cookie";import"./Token.mjs";import"./utils/allSettled.mjs";import"./toAbortSignalTimeout.mjs";import"./RecoveryApi.mjs";import"./RecoveryICloudApi.mjs";import"./RecoveryOAuthApi.mjs";import"./UserApi.mjs";import"./embedded/types.mjs";import"@ethersproject/abstract-signer";import"@ethersproject/providers";import"./embedded/gas/arbitrum.mjs";import"@ethersproject/bignumber";import"./chains/arbitrum.mjs";import"./chains/arbitrumGoerli.mjs";import"./chains/arbitrumSepolia.mjs";import"./embedded/gas/bsc.mjs";import"./embedded/gas/op-stack.mjs";import"@ethersproject/contracts";import"@ethersproject/transactions";import"./chains/base.mjs";import"./chains/baseGoerli.mjs";import"./chains/baseSepolia.mjs";import"./chains/optimism.mjs";import"./chains/optimismGoerli.mjs";import"./chains/optimismSepolia.mjs";import"./chains/zora.mjs";import"./chains/zoraSepolia.mjs";import"./chains/zoraTestnet.mjs";import"./embedded/gas/polygon.mjs";import"@ethersproject/units";import"./chains/polygon.mjs";import"./chains/polygonAmoy.mjs";import"./chains/polygonMumbai.mjs";import"./chains/avalanche.mjs";import"./chains/avalancheFuji.mjs";import"./chains/berachainArtio.mjs";import"./chains/celo.mjs";import"./chains/celoAlfajores.mjs";import"./chains/filecoin.mjs";import"./chains/filecoinCalibration.mjs";import"./chains/garnetHolesky.mjs";import"./chains/goerli.mjs";import"./chains/holesky.mjs";import"./chains/linea.mjs";import"./chains/lineaTestnet.mjs";import"./chains/mainnet.mjs";import"./chains/redstone.mjs";import"./chains/redstoneHolesky.mjs";import"./chains/sepolia.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privy-io/js-sdk-core",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.3-beta-20241119044014",
|
|
4
4
|
"description": "Vanilla JS client for the Privy Auth API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@ethersproject/transactions": "^5.7.0",
|
|
69
69
|
"@ethersproject/units": "^5.7.0",
|
|
70
70
|
"@privy-io/api-base": "^1.4.0",
|
|
71
|
-
"@privy-io/public-api": "2.15.
|
|
71
|
+
"@privy-io/public-api": "2.15.2-beta-20241119044014",
|
|
72
72
|
"eventemitter3": "^5.0.1",
|
|
73
73
|
"fetch-retry": "^5.0.6",
|
|
74
74
|
"jose": "^4.15.5",
|