@privy-io/js-sdk-core 0.60.1 → 0.60.2

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";var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/routes"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js"),h=require("./logger.js");function c(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"),require("../utils/noop.js");var l=/*#__PURE__*/c(e);let g="privy:caid";exports.PrivyInternal=class{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!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 r.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._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i.getPathWithParams(e.path,t)}${o.toSearchParams(s)}`}async fetch(e,{body:t,params:s,query:i,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:a}),h=await n(o),c=await this._fetch(o,h),l=await c.json();if(c.status>299)throw new r.PrivyApiError({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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");let 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.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i.AppConfig,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(g);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(g,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(g)}catch(e){this.logger.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},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,t){let a=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new r.PrivyApiError({code:s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),r=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${r}`),"set"===r&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof r.PrivyApiError&&e.code===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t.v4()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.60.1",this._cache=new Map,this.logger=h.toConsoleLogger({level:e.logLevel??"ERROR"}),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,this.nativeAppIdentifier=e.nativeAppIdentifier,this.session=new a.Session({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=l.default(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}};
1
+ "use strict";var e=require("fetch-retry"),t=require("uuid"),s=require("@privy-io/api-base"),i=require("@privy-io/routes"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js"),h=require("./logger.js");function c(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"),require("../utils/noop.js");var l=/*#__PURE__*/c(e);let g="privy:caid";exports.PrivyInternal=class{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!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 r.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._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i.getPathWithParams(e.path,t)}${o.toSearchParams(s)}`}async fetch(e,{body:t,params:s,query:i,headers:a,onRequest:n=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:a}),h=await n(o),c=await this._fetch(o,h),l=await c.json();if(c.status>299)throw new r.PrivyApiError({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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");let 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.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(i.AppConfig,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(g);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t.v4()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(g,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(g)}catch(e){this.logger.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},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new r.PrivyClientError({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let a=this._refreshSession(t,e);this._cache.set(s,a);try{return await a}finally{this._cache.delete(s)}}async _refreshSession(e,t){let a=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new r.PrivyApiError({code:s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),r=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${r}`),"set"===r&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof r.PrivyApiError&&e.code===s.PrivyErrorCode.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t.v4()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(e){this._sdkVersion="js-sdk-core:0.60.2",this._cache=new Map,this.logger=h.toConsoleLogger({level:e.logLevel??"ERROR"}),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,this.nativeAppIdentifier=e.nativeAppIdentifier,this.session=new a.Session({storage:this._storage,isUsingServerCookies:!1,appId:e.appId}),this._fetch=l.default(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}};
@@ -1 +1 @@
1
- "use strict";var e=require("@privy-io/chains");let a=new Set([e.mainnet.id,e.base.id,e.optimism.id,e.polygon.id,e.arbitrum.id,e.avalanche.id]),s=new Set([e.mainnet.id,e.base.id,e.polygon.id,e.optimism.id,e.arbitrum.id,e.avalanche.id]),t={buy:"CARD",send:"CRYPTO_ACCOUNT"},r={USDC:"2b92315d-eab7-5bef-84fa-089a131333f5",ETH:"d85dce9b-5b73-5c3c-8978-522ce1d1c1b4",BTC:"5b71fc48-3dd3-540c-809b-f8c94d0e68b5",SOL:"4f039497-3af8-5bb3-951c-6df9afa9be1c",POL:"026bcc1e-9163-591c-a709-34dd18b2e7a1"},n={[e.mainnet.id]:"ethereum",[e.base.id]:"base",[e.optimism.id]:"optimism",[e.polygon.id]:"polygon",[e.arbitrum.id]:"arbitrum",[e.avalanche.id]:"avacchain"};exports.getCoinbaseOnRampUrl=function({appId:e,input:a,amount:s,blockchain:n,asset:i,experience:o}){let c=new URL("https://pay.coinbase.com/buy/select-asset");return c.searchParams.set("appId",a.app_id),c.searchParams.set("sessionToken",a.session_token),c.searchParams.set("endPartnerName",`privy:${e}`),c.searchParams.set("defaultExperience",o),c.searchParams.set("presetCryptoAmount",s.startsWith(".")?`0${s}`:s),c.searchParams.set("defaultNetwork",n),c.searchParams.set("defaultPaymentMethod",t[o]),c.searchParams.set("defaultAsset",r[i]),c.searchParams.set("partnerUserId",a.partner_user_id),{url:c}},exports.isSupportedChainIdForCoinbaseOnramp=(e,t)=>{switch(t){case"native-currency":return a.has(e);case"USDC":return s.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}},exports.toCoinbaseAssetId=function(a,s){return"USDC"===s?"USDC":a===e.polygon.id?"POL":"ETH"},exports.toCoinbaseBlockchainFromChainId=function(e){return n[e]};
1
+ "use strict";var e=require("@privy-io/chains");let a=new Set([e.mainnet.id,e.base.id,e.optimism.id,e.polygon.id,e.arbitrum.id,e.avalanche.id,e.monadMainnet.id]),s=new Set([e.mainnet.id,e.base.id,e.polygon.id,e.optimism.id,e.arbitrum.id,e.avalanche.id,e.monadMainnet.id]),n={buy:"CARD",send:"CRYPTO_ACCOUNT"},t={USDC:"2b92315d-eab7-5bef-84fa-089a131333f5",ETH:"d85dce9b-5b73-5c3c-8978-522ce1d1c1b4",BTC:"5b71fc48-3dd3-540c-809b-f8c94d0e68b5",SOL:"4f039497-3af8-5bb3-951c-6df9afa9be1c",POL:"026bcc1e-9163-591c-a709-34dd18b2e7a1",MON:"92aa538f-b005-45cc-a237-71d6466f54d9"},i={[e.mainnet.id]:"ethereum",[e.base.id]:"base",[e.optimism.id]:"optimism",[e.polygon.id]:"polygon",[e.arbitrum.id]:"arbitrum",[e.avalanche.id]:"avacchain",[e.monadMainnet.id]:"monad"};exports.getCoinbaseOnRampUrl=function({appId:e,input:a,amount:s,blockchain:i,asset:r,experience:d}){let o=new URL("https://pay.coinbase.com/buy/select-asset");return o.searchParams.set("appId",a.app_id),o.searchParams.set("sessionToken",a.session_token),o.searchParams.set("endPartnerName",`privy:${e}`),o.searchParams.set("defaultExperience",d),o.searchParams.set("presetCryptoAmount",s.startsWith(".")?`0${s}`:s),o.searchParams.set("defaultNetwork",i),o.searchParams.set("defaultPaymentMethod",n[d]),o.searchParams.set("defaultAsset",t[r]),o.searchParams.set("partnerUserId",a.partner_user_id),{url:o}},exports.isSupportedChainIdForCoinbaseOnramp=(e,n)=>{switch(n){case"native-currency":return a.has(e);case"USDC":return s.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}},exports.toCoinbaseAssetId=function(a,s){return"USDC"===s?"USDC":a===e.polygon.id?"POL":a===e.monadMainnet.id?"MON":"ETH"},exports.toCoinbaseBlockchainFromChainId=function(e){return i[e]};
@@ -1 +1 @@
1
- "use strict";var e=require("@privy-io/chains");let n=new Set([e.mainnet.id,e.arbitrum.id,e.base.id,e.polygon.id,e.avalanche.id,e.celo.id]),r=new Set([e.mainnet.id,e.arbitrum.id,e.optimism.id,e.base.id,e.polygon.id,e.avalanche.id]);exports.MoonpayEnvironments={prod:{url:"https://api.moonpay.com/v1",key:"pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL"},sandbox:{url:"https://api.moonpay.com/v1",key:"pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI"}},exports.chainToMoonpayCurrency=function(n,r){switch(n){case e.arbitrum.id:return"native-currency"===r?"ETH_ARBITRUM":"USDC_ARBITRUM";case e.avalanche.id:return"native-currency"===r?"AVAX_CCHAIN":"USDC_CCHAIN";case e.base.id:return"native-currency"===r?"ETH_BASE":"USDC_BASE";case e.celo.id:return"CELO_CELO";case e.polygon.id:return"native-currency"===r?"MATIC_POLYGON":"USDC_POLYGON";case e.mainnet.id:return"native-currency"===r?"ETH_ETHEREUM":"USDC_ETHEREUM";default:return console.warn(`Chain ${n} not supported by Moonpay, defaulting to Ethereum mainnet`),"ETH_ETHEREUM"}},exports.fundingMethodToMoonpayPaymentMethod=function(e){switch(e){case"card":case"payment-request":return"credit_debit_card";default:throw Error(`Unsupported Moonpay funding method ${e}`)}},exports.isSupportedChainIdForMoonpay=function(e,t){switch(t){case"native-currency":return n.has(e);case"USDC":return r.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}};
1
+ "use strict";var e=require("@privy-io/chains");let n=new Set([e.mainnet.id,e.arbitrum.id,e.base.id,e.polygon.id,e.avalanche.id,e.celo.id,e.monadMainnet.id]),r=new Set([e.mainnet.id,e.arbitrum.id,e.optimism.id,e.base.id,e.polygon.id,e.avalanche.id]);exports.MoonpayEnvironments={prod:{url:"https://api.moonpay.com/v1",key:"pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL"},sandbox:{url:"https://api.moonpay.com/v1",key:"pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI"}},exports.chainToMoonpayCurrency=function(n,r){switch(n){case e.arbitrum.id:return"native-currency"===r?"ETH_ARBITRUM":"USDC_ARBITRUM";case e.avalanche.id:return"native-currency"===r?"AVAX_CCHAIN":"USDC_CCHAIN";case e.base.id:return"native-currency"===r?"ETH_BASE":"USDC_BASE";case e.celo.id:return"CELO_CELO";case e.polygon.id:return"native-currency"===r?"MATIC_POLYGON":"USDC_POLYGON";case e.monadMainnet.id:return"MON_MON";case e.mainnet.id:return"native-currency"===r?"ETH_ETHEREUM":"USDC_ETHEREUM";default:return console.warn(`Chain ${n} not supported by Moonpay, defaulting to Ethereum mainnet`),"ETH_ETHEREUM"}},exports.fundingMethodToMoonpayPaymentMethod=function(e){switch(e){case"card":case"payment-request":return"credit_debit_card";default:throw Error(`Unsupported Moonpay funding method ${e}`)}},exports.isSupportedChainIdForMoonpay=function(e,t){switch(t){case"native-currency":return n.has(e);case"USDC":return r.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}};
@@ -1704,7 +1704,7 @@ type MoonpayTransactionStatus = MoonpayTransactionStatusWithoutFailures | 'faile
1704
1704
  * Cryptocurrency codes for the MoonPay fiat on-ramp. These codes
1705
1705
  * follow the format {TOKEN_NAME}_{NETWORK_NAME}.
1706
1706
  */
1707
- type MoonpayCurrencyCode = 'AVAX_CCHAIN' | 'CELO_CELO' | 'CUSD_CELO' | 'DAI_ETHEREUM' | 'ETH_ETHEREUM' | 'ETH_ARBITRUM' | 'ETH_POLYGON' | 'ETH_BASE' | 'FIL_FVM' | 'MATIC_ETHEREUM' | 'MATIC_POLYGON' | 'POL_POLYGON' | 'POL_ETHEREUM' | 'USDC_ETHEREUM' | 'USDC_ARBITRUM' | 'USDC_OPTIMISM' | 'USDC_POLYGON' | 'USDC_BASE' | 'USDC_CCHAIN' | 'USDC_SOL' | 'USDT_ETHEREUM' | 'USDT_POLYGON' | 'WETH_POLYGON' | 'WBTC_ETHEREUM' | 'BNB_BNB' | 'BNB_BSC' | 'SOL';
1707
+ type MoonpayCurrencyCode = 'AVAX_CCHAIN' | 'CELO_CELO' | 'CUSD_CELO' | 'DAI_ETHEREUM' | 'ETH_ETHEREUM' | 'ETH_ARBITRUM' | 'ETH_POLYGON' | 'ETH_BASE' | 'FIL_FVM' | 'MATIC_ETHEREUM' | 'MATIC_POLYGON' | 'POL_POLYGON' | 'POL_ETHEREUM' | 'USDC_ETHEREUM' | 'USDC_ARBITRUM' | 'USDC_OPTIMISM' | 'USDC_POLYGON' | 'USDC_BASE' | 'USDC_CCHAIN' | 'USDC_SOL' | 'USDT_ETHEREUM' | 'USDT_POLYGON' | 'WETH_POLYGON' | 'WBTC_ETHEREUM' | 'BNB_BNB' | 'BNB_BSC' | 'MON_MON' | 'SOL';
1708
1708
  type MoonpayTransactionStatusResponse = {
1709
1709
  status?: MoonpayTransactionStatus;
1710
1710
  paymentMethod?: string;
@@ -2274,6 +2274,7 @@ declare const ASSET_ID_MAP: {
2274
2274
  readonly BTC: "5b71fc48-3dd3-540c-809b-f8c94d0e68b5";
2275
2275
  readonly SOL: "4f039497-3af8-5bb3-951c-6df9afa9be1c";
2276
2276
  readonly POL: "026bcc1e-9163-591c-a709-34dd18b2e7a1";
2277
+ readonly MON: "92aa538f-b005-45cc-a237-71d6466f54d9";
2277
2278
  };
2278
2279
  type CoinbaseAssetId = keyof typeof ASSET_ID_MAP;
2279
2280
  type SupportedBlockchains = CoinbaseOnRampInitInput['addresses'][0]['blockchains'][0];
@@ -1704,7 +1704,7 @@ type MoonpayTransactionStatus = MoonpayTransactionStatusWithoutFailures | 'faile
1704
1704
  * Cryptocurrency codes for the MoonPay fiat on-ramp. These codes
1705
1705
  * follow the format {TOKEN_NAME}_{NETWORK_NAME}.
1706
1706
  */
1707
- type MoonpayCurrencyCode = 'AVAX_CCHAIN' | 'CELO_CELO' | 'CUSD_CELO' | 'DAI_ETHEREUM' | 'ETH_ETHEREUM' | 'ETH_ARBITRUM' | 'ETH_POLYGON' | 'ETH_BASE' | 'FIL_FVM' | 'MATIC_ETHEREUM' | 'MATIC_POLYGON' | 'POL_POLYGON' | 'POL_ETHEREUM' | 'USDC_ETHEREUM' | 'USDC_ARBITRUM' | 'USDC_OPTIMISM' | 'USDC_POLYGON' | 'USDC_BASE' | 'USDC_CCHAIN' | 'USDC_SOL' | 'USDT_ETHEREUM' | 'USDT_POLYGON' | 'WETH_POLYGON' | 'WBTC_ETHEREUM' | 'BNB_BNB' | 'BNB_BSC' | 'SOL';
1707
+ type MoonpayCurrencyCode = 'AVAX_CCHAIN' | 'CELO_CELO' | 'CUSD_CELO' | 'DAI_ETHEREUM' | 'ETH_ETHEREUM' | 'ETH_ARBITRUM' | 'ETH_POLYGON' | 'ETH_BASE' | 'FIL_FVM' | 'MATIC_ETHEREUM' | 'MATIC_POLYGON' | 'POL_POLYGON' | 'POL_ETHEREUM' | 'USDC_ETHEREUM' | 'USDC_ARBITRUM' | 'USDC_OPTIMISM' | 'USDC_POLYGON' | 'USDC_BASE' | 'USDC_CCHAIN' | 'USDC_SOL' | 'USDT_ETHEREUM' | 'USDT_POLYGON' | 'WETH_POLYGON' | 'WBTC_ETHEREUM' | 'BNB_BNB' | 'BNB_BSC' | 'MON_MON' | 'SOL';
1708
1708
  type MoonpayTransactionStatusResponse = {
1709
1709
  status?: MoonpayTransactionStatus;
1710
1710
  paymentMethod?: string;
@@ -2274,6 +2274,7 @@ declare const ASSET_ID_MAP: {
2274
2274
  readonly BTC: "5b71fc48-3dd3-540c-809b-f8c94d0e68b5";
2275
2275
  readonly SOL: "4f039497-3af8-5bb3-951c-6df9afa9be1c";
2276
2276
  readonly POL: "026bcc1e-9163-591c-a709-34dd18b2e7a1";
2277
+ readonly MON: "92aa538f-b005-45cc-a237-71d6466f54d9";
2277
2278
  };
2278
2279
  type CoinbaseAssetId = keyof typeof ASSET_ID_MAP;
2279
2280
  type SupportedBlockchains = CoinbaseOnRampInitInput['addresses'][0]['blockchains'][0];
@@ -1 +1 @@
1
- import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as o}from"@privy-io/routes";import{PrivyClientError as n,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as g}from"../utils/toSearchParams.mjs";import{toConsoleLogger as d}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!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 n({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._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i(e.path,t)}${g(s)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),n=await a(o),c=await this._fetch(o,n),l=await c.json();if(c.status>299)throw new h({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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");let 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(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(p);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(p,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(a,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new n({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(s,r);try{return await r}finally{this._cache.delete(s)}}async _refreshSession(e,t){let i=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${o.path}`);let s=await this.fetch(o,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof h&&e.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.60.1",this._cache=new Map,this.logger=d({level:t.logLevel??"ERROR"}),this._storage=t.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=t.baseUrl??"https://auth.privy.io",this.appId=t.appId,this.appClientId=t.appClientId,this._sdkVersion=t.sdkVersion??this._sdkVersion,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new c({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}}export{u as PrivyInternal};
1
+ import e from"fetch-retry";import{v4 as t}from"uuid";import{PrivyErrorCode as s}from"@privy-io/api-base";import{getPathWithParams as i,AppConfig as r,AnalyticsEvent as a,RefreshSession as o}from"@privy-io/routes";import{PrivyClientError as n,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as g}from"../utils/toSearchParams.mjs";import{toConsoleLogger as d}from"./logger.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.mjs";import"../utils/noop.mjs";let p="privy:caid";class u{setCallbacks(e){this.callbacks={...this.callbacks,...e}}get isReady(){return!!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 n({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._sdkVersion.startsWith("react-auth:")||this.createAnalyticsEvent("sdk_initialize",{})}}getPath(e,{params:t,query:s}){return`${this.baseUrl}${i(e.path,t)}${g(s)}`}async fetch(e,{body:t,params:s,query:i,headers:r,onRequest:a=this._beforeRequest.bind(this)}){let o=new Request(this.getPath(e,{params:s,query:i}),{method:e.method,body:JSON.stringify(t),headers:r}),n=await a(o),c=await this._fetch(o,n),l=await c.json();if(c.status>299)throw new h({...l,status:c.status});return l}async _beforeRequestWithoutInitialize(e){let t=await this.session.getPrivyAccessToken()??await this.session.getCustomerAccessToken(),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");let 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(e){return await this._initialize(),this._beforeRequestWithoutInitialize(e)}async _beforeRequest(e){return await this._initialize(),await this.getAccessTokenInternal(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},onRequest:this._beforeRequestWithoutInitialize.bind(this)})}async _getOrGenerateClientAnalyticsId(){if(this._analyticsId)return this._analyticsId;try{let e=await this._storage.get(p);if("string"==typeof e&&e.length>0)return this._analyticsId=e,e}catch(e){this.logger.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){this.logger.error("Unable to generate uuidv4",e)}if(this._analyticsId){try{await this._storage.put(p,this._analyticsId)}catch(e){this.logger.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){this.logger.error("Unable to delete clientId",e)}}async createAnalyticsEvent(e,t){try{await this.fetch(a,{body:{event_name:e,client_id:await this._getOrGenerateClientAnalyticsId(),payload:t},onRequest:this.beforeRequestWithoutRefresh.bind(this)})}catch(e){}}async refreshSession(e=!1){if(!await this.isStorageAccessible())throw new n({code:"storage_error",error:"Unable to access storage"});let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return this.logger.debug("[privy:refresh] found in-flight session refresh request, deduping"),await i;let r=this._refreshSession(t,e);this._cache.set(s,r);try{return await r}finally{this._cache.delete(s)}}async _refreshSession(e,t){let i=await this.session.getCustomerAccessToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.logger.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage",status:401});try{this.logger.debug(`[privy:refresh] fetching: ${o.path}`);let s=await this.fetch(o,{body:{refresh_token:e},onRequest:this.beforeRequestWithoutRefresh.bind(this)}),i=s.session_update_action;return this.logger.debug(`[privy:refresh] response: ${i}`),"set"===i&&(await this.session.updateWithTokensResponse(s),this.logger.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.logger.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&(s.token&&(await this.session.storeCustomerAccessToken(s.token),this.logger.debug("[privy:refresh] token stored (CAT)")),s.privy_access_token&&(await this.session.storePrivyAccessToken(s.privy_access_token),this.logger.debug("[privy:refresh] token stored (PAT)")),s.identity_token&&(this.logger.debug("[privy:refresh] token stored (IDT)"),await this.session.storeIdentityToken(s.identity_token))),this.logger.debug("[privy:refresh] returning response"),t||this.callbacks?.setUser?.(s.user),s}catch(e){throw this.logger.debug(`[privy:refresh] error: ${e.message??"unknown error"}`),e instanceof h&&e.code===s.MISSING_OR_INVALID_TOKEN&&(await this.session.destroyLocalState(),t||this.callbacks?.setUser?.(null)),e}}async getAccessToken(){let[e,t]=await Promise.all([this.session.getCustomerAccessToken(),this.session.getRefreshToken()]);if(!this.session.tokenIsActive(e)&&this.session.hasRefreshCredentials(e,t)){let t=await this.refreshSession(),s=await this.session.getCustomerAccessToken();return t.token||this.logger.debug("[privy:getAccessToken] expected token received null"),t.token===e&&this.logger.debug("[privy:getAccessToken] expected new token in response received existing"),s===e&&this.logger.debug("[privy:getAccessToken] expected new token in storage received existing"),t.token??s}return e}async getAccessTokenInternal(){let e=await this.getAccessToken();return await this.session.getPrivyAccessToken()??e}async getIdentityToken(){return await this.session.getIdentityToken()}async isStorageAccessible(){try{let e=`privy:__storage__test-${t()}`,s="blobby";await this._storage.put(e,s);let i=await this._storage.get(e);return await this._storage.del(e),i===s}catch(e){return this.logger.error(e),!1}}constructor(t){this._sdkVersion="js-sdk-core:0.60.2",this._cache=new Map,this.logger=d({level:t.logLevel??"ERROR"}),this._storage=t.storage,this._analyticsId=null,this._getOrGenerateClientAnalyticsId(),this.baseUrl=t.baseUrl??"https://auth.privy.io",this.appId=t.appId,this.appClientId=t.appClientId,this._sdkVersion=t.sdkVersion??this._sdkVersion,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new c({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(globalThis.fetch,{retries:3,retryDelay:e=>3**e*500,retryOn:[408,409,425,500,502,503,504]}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}}export{u as PrivyInternal};
@@ -1 +1 @@
1
- import{mainnet as e,base as a,optimism as s,polygon as t,arbitrum as r,avalanche as n}from"@privy-io/chains";let i=new Set([e.id,a.id,s.id,t.id,r.id,n.id]),d=new Set([e.id,a.id,t.id,s.id,r.id,n.id]),c={buy:"CARD",send:"CRYPTO_ACCOUNT"},o={USDC:"2b92315d-eab7-5bef-84fa-089a131333f5",ETH:"d85dce9b-5b73-5c3c-8978-522ce1d1c1b4",BTC:"5b71fc48-3dd3-540c-809b-f8c94d0e68b5",SOL:"4f039497-3af8-5bb3-951c-6df9afa9be1c",POL:"026bcc1e-9163-591c-a709-34dd18b2e7a1"},u={[e.id]:"ethereum",[a.id]:"base",[s.id]:"optimism",[t.id]:"polygon",[r.id]:"arbitrum",[n.id]:"avacchain"};function p({appId:e,input:a,amount:s,blockchain:t,asset:r,experience:n}){let i=new URL("https://pay.coinbase.com/buy/select-asset");return i.searchParams.set("appId",a.app_id),i.searchParams.set("sessionToken",a.session_token),i.searchParams.set("endPartnerName",`privy:${e}`),i.searchParams.set("defaultExperience",n),i.searchParams.set("presetCryptoAmount",s.startsWith(".")?`0${s}`:s),i.searchParams.set("defaultNetwork",t),i.searchParams.set("defaultPaymentMethod",c[n]),i.searchParams.set("defaultAsset",o[r]),i.searchParams.set("partnerUserId",a.partner_user_id),{url:i}}const b=(e,a)=>{switch(a){case"native-currency":return i.has(e);case"USDC":return d.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}};function m(e){return u[e]}function h(e,a){return"USDC"===a?"USDC":e===t.id?"POL":"ETH"}export{p as getCoinbaseOnRampUrl,b as isSupportedChainIdForCoinbaseOnramp,h as toCoinbaseAssetId,m as toCoinbaseBlockchainFromChainId};
1
+ import{mainnet as e,base as a,optimism as s,polygon as t,arbitrum as r,avalanche as d,monadMainnet as i}from"@privy-io/chains";let n=new Set([e.id,a.id,s.id,t.id,r.id,d.id,i.id]),c=new Set([e.id,a.id,t.id,s.id,r.id,d.id,i.id]),o={buy:"CARD",send:"CRYPTO_ACCOUNT"},u={USDC:"2b92315d-eab7-5bef-84fa-089a131333f5",ETH:"d85dce9b-5b73-5c3c-8978-522ce1d1c1b4",BTC:"5b71fc48-3dd3-540c-809b-f8c94d0e68b5",SOL:"4f039497-3af8-5bb3-951c-6df9afa9be1c",POL:"026bcc1e-9163-591c-a709-34dd18b2e7a1",MON:"92aa538f-b005-45cc-a237-71d6466f54d9"},p={[e.id]:"ethereum",[a.id]:"base",[s.id]:"optimism",[t.id]:"polygon",[r.id]:"arbitrum",[d.id]:"avacchain",[i.id]:"monad"};function b({appId:e,input:a,amount:s,blockchain:t,asset:r,experience:d}){let i=new URL("https://pay.coinbase.com/buy/select-asset");return i.searchParams.set("appId",a.app_id),i.searchParams.set("sessionToken",a.session_token),i.searchParams.set("endPartnerName",`privy:${e}`),i.searchParams.set("defaultExperience",d),i.searchParams.set("presetCryptoAmount",s.startsWith(".")?`0${s}`:s),i.searchParams.set("defaultNetwork",t),i.searchParams.set("defaultPaymentMethod",o[d]),i.searchParams.set("defaultAsset",u[r]),i.searchParams.set("partnerUserId",a.partner_user_id),{url:i}}const m=(e,a)=>{switch(a){case"native-currency":return n.has(e);case"USDC":return c.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}};function f(e){return p[e]}function h(e,a){return"USDC"===a?"USDC":e===t.id?"POL":e===i.id?"MON":"ETH"}export{b as getCoinbaseOnRampUrl,m as isSupportedChainIdForCoinbaseOnramp,h as toCoinbaseAssetId,f as toCoinbaseBlockchainFromChainId};
@@ -1 +1 @@
1
- import{mainnet as e,arbitrum as r,base as n,polygon as t,avalanche as i,celo as a,optimism as c}from"@privy-io/chains";const o={prod:{url:"https://api.moonpay.com/v1",key:"pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL"},sandbox:{url:"https://api.moonpay.com/v1",key:"pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI"}};let d=new Set([e.id,r.id,n.id,t.id,i.id,a.id]),u=new Set([e.id,r.id,c.id,n.id,t.id,i.id]);function s(e,r){switch(r){case"native-currency":return d.has(e);case"USDC":return u.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}}function p(c,o){switch(c){case r.id:return"native-currency"===o?"ETH_ARBITRUM":"USDC_ARBITRUM";case i.id:return"native-currency"===o?"AVAX_CCHAIN":"USDC_CCHAIN";case n.id:return"native-currency"===o?"ETH_BASE":"USDC_BASE";case a.id:return"CELO_CELO";case t.id:return"native-currency"===o?"MATIC_POLYGON":"USDC_POLYGON";case e.id:return"native-currency"===o?"ETH_ETHEREUM":"USDC_ETHEREUM";default:return console.warn(`Chain ${c} not supported by Moonpay, defaulting to Ethereum mainnet`),"ETH_ETHEREUM"}}function E(e){switch(e){case"card":case"payment-request":return"credit_debit_card";default:throw Error(`Unsupported Moonpay funding method ${e}`)}}export{o as MoonpayEnvironments,p as chainToMoonpayCurrency,E as fundingMethodToMoonpayPaymentMethod,s as isSupportedChainIdForMoonpay};
1
+ import{mainnet as e,arbitrum as r,base as n,polygon as t,avalanche as i,celo as a,monadMainnet as c,optimism as o}from"@privy-io/chains";const d={prod:{url:"https://api.moonpay.com/v1",key:"pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL"},sandbox:{url:"https://api.moonpay.com/v1",key:"pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI"}};let u=new Set([e.id,r.id,n.id,t.id,i.id,a.id,c.id]),s=new Set([e.id,r.id,o.id,n.id,t.id,i.id]);function p(e,r){switch(r){case"native-currency":return u.has(e);case"USDC":return s.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}}function E(o,d){switch(o){case r.id:return"native-currency"===d?"ETH_ARBITRUM":"USDC_ARBITRUM";case i.id:return"native-currency"===d?"AVAX_CCHAIN":"USDC_CCHAIN";case n.id:return"native-currency"===d?"ETH_BASE":"USDC_BASE";case a.id:return"CELO_CELO";case t.id:return"native-currency"===d?"MATIC_POLYGON":"USDC_POLYGON";case c.id:return"MON_MON";case e.id:return"native-currency"===d?"ETH_ETHEREUM":"USDC_ETHEREUM";default:return console.warn(`Chain ${o} not supported by Moonpay, defaulting to Ethereum mainnet`),"ETH_ETHEREUM"}}function _(e){switch(e){case"card":case"payment-request":return"credit_debit_card";default:throw Error(`Unsupported Moonpay funding method ${e}`)}}export{d as MoonpayEnvironments,E as chainToMoonpayCurrency,_ as fundingMethodToMoonpayPaymentMethod,p as isSupportedChainIdForMoonpay};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/js-sdk-core",
3
- "version": "0.60.1",
3
+ "version": "0.60.2",
4
4
  "description": "Vanilla JS client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",
@@ -62,7 +62,7 @@
62
62
  "@privy-io/api-base": "1.8.2",
63
63
  "@privy-io/ethereum": "0.0.8",
64
64
  "@privy-io/routes": "0.0.7",
65
- "@privy-io/chains": "0.1.0"
65
+ "@privy-io/chains": "0.1.1"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@metamask/eth-sig-util": "^8.2.0",