@privy-io/js-sdk-core 0.44.0 → 0.44.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/public-api"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js");function h(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 l=/*#__PURE__*/h(e);let c="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.createAnalyticsEvent("sdk_initialize",{})}}async fetch(e,{body:t,params:s,query:a,headers:n,options:h={onRequest:this._beforeRequest.bind(this)}}){let l=new Request(`${this.baseUrl}${i.getPathWithParams(e.path,s)}${o.toSearchParams(a)}`,{method:e.method,body:JSON.stringify(t),headers:n}),c=await h.onRequest(l),d=await this._fetch(l,c),u=await d.json();if(d.status>299)throw new r.PrivyApiError(u);return u}async _beforeRequestWithoutInitialize(e){let 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");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.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{let e=await this._storage.get(c);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(c,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(c)}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(e=!1){let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return console.debug("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 a=await this.session.getToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.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"});try{this.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}}),r=s.session_update_action;return this.debug(`[privy:refresh] response: ${r}`),t||this.callbacks?.setUser?.(s.user),"set"===r&&(await this.session.updateWithTokensResponse(s),this.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&s.token&&(await this.session.storeToken(s.token),this.debug("[privy:refresh] access token stored"),s.identity_token&&(this.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.debug("[privy:refresh] returning response"),s}catch(e){throw this.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.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{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 console.error(e),!1}}debug(e){"DEBUG"===this._logLevel&&console.debug(e)}constructor(e){this._sdkVersion="js-sdk-core:0.44.0",this._cache=new Map,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._logLevel=e.logLevel,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(fetch,{retries:3,retryDelay:500}),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/public-api"),r=require("../Error.js"),a=require("../Session.js"),n=require("../toAbortSignalTimeout.js"),o=require("../utils/toSearchParams.js");function h(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 l=/*#__PURE__*/h(e);let c="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.createAnalyticsEvent("sdk_initialize",{})}}async fetch(e,{body:t,params:s,query:a,headers:n,options:h={onRequest:this._beforeRequest.bind(this)}}){let l=new Request(`${this.baseUrl}${i.getPathWithParams(e.path,s)}${o.toSearchParams(a)}`,{method:e.method,body:JSON.stringify(t),headers:n}),c=await h.onRequest(l),d=await this._fetch(l,c),u=await d.json();if(d.status>299)throw new r.PrivyApiError(u);return u}async _beforeRequestWithoutInitialize(e){let 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");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.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{let e=await this._storage.get(c);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(c,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(c)}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(e=!1){let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return console.debug("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 a=await this.session.getToken();if(!this.session.hasRefreshCredentials(a,e??null))throw this.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"});try{this.debug(`[privy:refresh] fetching: ${i.RefreshSession.path}`);let s=await this.fetch(i.RefreshSession,{body:{refresh_token:e},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}}),r=s.session_update_action;return this.debug(`[privy:refresh] response: ${r}`),t||this.callbacks?.setUser?.(s.user),"set"===r&&(await this.session.updateWithTokensResponse(s),this.debug("[privy:refresh] tokens stored")),"clear"===r&&(await this.session.destroyLocalState(),this.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===r&&s.token&&(await this.session.storeToken(s.token),this.debug("[privy:refresh] access token stored"),s.identity_token&&(this.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.debug("[privy:refresh] returning response"),s}catch(e){throw this.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.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{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 console.error(e),!1}}debug(e){"DEBUG"===this._logLevel&&console.debug(e)}constructor(e){this._sdkVersion="js-sdk-core:0.44.2",this._cache=new Map,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._logLevel=e.logLevel,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(fetch,{retries:3,retryDelay:500}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}};
@@ -1145,6 +1145,7 @@ declare class EmbeddedWalletApi {
1145
1145
  photo_url?: string | null | undefined;
1146
1146
  } | {
1147
1147
  type: "wallet";
1148
+ id: string | null;
1148
1149
  address: string;
1149
1150
  chain_type: "ethereum";
1150
1151
  wallet_index: number;
@@ -1160,6 +1161,7 @@ declare class EmbeddedWalletApi {
1160
1161
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1161
1162
  } | {
1162
1163
  type: "wallet";
1164
+ id: string | null;
1163
1165
  address: string;
1164
1166
  chain_type: "solana";
1165
1167
  wallet_index: number;
@@ -1176,6 +1178,7 @@ declare class EmbeddedWalletApi {
1176
1178
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1177
1179
  } | {
1178
1180
  type: "wallet";
1181
+ id: string | null;
1179
1182
  address: string;
1180
1183
  chain_type: "bitcoin-segwit";
1181
1184
  wallet_index: number;
@@ -1192,6 +1195,7 @@ declare class EmbeddedWalletApi {
1192
1195
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1193
1196
  } | {
1194
1197
  type: "wallet";
1198
+ id: string | null;
1195
1199
  address: string;
1196
1200
  chain_type: "bitcoin-taproot";
1197
1201
  wallet_index: number;
@@ -1532,6 +1536,7 @@ declare class UserApi {
1532
1536
  photo_url?: string | null | undefined;
1533
1537
  } | {
1534
1538
  type: "wallet";
1539
+ id: string | null;
1535
1540
  address: string;
1536
1541
  chain_type: "ethereum";
1537
1542
  wallet_index: number;
@@ -1547,6 +1552,7 @@ declare class UserApi {
1547
1552
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1548
1553
  } | {
1549
1554
  type: "wallet";
1555
+ id: string | null;
1550
1556
  address: string;
1551
1557
  chain_type: "solana";
1552
1558
  wallet_index: number;
@@ -1563,6 +1569,7 @@ declare class UserApi {
1563
1569
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1564
1570
  } | {
1565
1571
  type: "wallet";
1572
+ id: string | null;
1566
1573
  address: string;
1567
1574
  chain_type: "bitcoin-segwit";
1568
1575
  wallet_index: number;
@@ -1579,6 +1586,7 @@ declare class UserApi {
1579
1586
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1580
1587
  } | {
1581
1588
  type: "wallet";
1589
+ id: string | null;
1582
1590
  address: string;
1583
1591
  chain_type: "bitcoin-taproot";
1584
1592
  wallet_index: number;
@@ -1830,6 +1838,7 @@ declare class EmailApi {
1830
1838
  photo_url?: string | null | undefined;
1831
1839
  } | {
1832
1840
  type: "wallet";
1841
+ id: string | null;
1833
1842
  address: string;
1834
1843
  chain_type: "ethereum";
1835
1844
  wallet_index: number;
@@ -1845,6 +1854,7 @@ declare class EmailApi {
1845
1854
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1846
1855
  } | {
1847
1856
  type: "wallet";
1857
+ id: string | null;
1848
1858
  address: string;
1849
1859
  chain_type: "solana";
1850
1860
  wallet_index: number;
@@ -1861,6 +1871,7 @@ declare class EmailApi {
1861
1871
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1862
1872
  } | {
1863
1873
  type: "wallet";
1874
+ id: string | null;
1864
1875
  address: string;
1865
1876
  chain_type: "bitcoin-segwit";
1866
1877
  wallet_index: number;
@@ -1877,6 +1888,7 @@ declare class EmailApi {
1877
1888
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1878
1889
  } | {
1879
1890
  type: "wallet";
1891
+ id: string | null;
1880
1892
  address: string;
1881
1893
  chain_type: "bitcoin-taproot";
1882
1894
  wallet_index: number;
@@ -2080,6 +2092,7 @@ declare class EmailApi {
2080
2092
  photo_url?: string | null | undefined;
2081
2093
  } | {
2082
2094
  type: "wallet";
2095
+ id: string | null;
2083
2096
  address: string;
2084
2097
  chain_type: "ethereum";
2085
2098
  wallet_index: number;
@@ -2095,6 +2108,7 @@ declare class EmailApi {
2095
2108
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2096
2109
  } | {
2097
2110
  type: "wallet";
2111
+ id: string | null;
2098
2112
  address: string;
2099
2113
  chain_type: "solana";
2100
2114
  wallet_index: number;
@@ -2111,6 +2125,7 @@ declare class EmailApi {
2111
2125
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2112
2126
  } | {
2113
2127
  type: "wallet";
2128
+ id: string | null;
2114
2129
  address: string;
2115
2130
  chain_type: "bitcoin-segwit";
2116
2131
  wallet_index: number;
@@ -2127,6 +2142,7 @@ declare class EmailApi {
2127
2142
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2128
2143
  } | {
2129
2144
  type: "wallet";
2145
+ id: string | null;
2130
2146
  address: string;
2131
2147
  chain_type: "bitcoin-taproot";
2132
2148
  wallet_index: number;
@@ -2365,6 +2381,7 @@ declare class FarcasterApi {
2365
2381
  photo_url?: string | null | undefined;
2366
2382
  } | {
2367
2383
  type: "wallet";
2384
+ id: string | null;
2368
2385
  address: string;
2369
2386
  chain_type: "ethereum";
2370
2387
  wallet_index: number;
@@ -2380,6 +2397,7 @@ declare class FarcasterApi {
2380
2397
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2381
2398
  } | {
2382
2399
  type: "wallet";
2400
+ id: string | null;
2383
2401
  address: string;
2384
2402
  chain_type: "solana";
2385
2403
  wallet_index: number;
@@ -2396,6 +2414,7 @@ declare class FarcasterApi {
2396
2414
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2397
2415
  } | {
2398
2416
  type: "wallet";
2417
+ id: string | null;
2399
2418
  address: string;
2400
2419
  chain_type: "bitcoin-segwit";
2401
2420
  wallet_index: number;
@@ -2412,6 +2431,7 @@ declare class FarcasterApi {
2412
2431
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2413
2432
  } | {
2414
2433
  type: "wallet";
2434
+ id: string | null;
2415
2435
  address: string;
2416
2436
  chain_type: "bitcoin-taproot";
2417
2437
  wallet_index: number;
@@ -2620,6 +2640,7 @@ declare class FarcasterApi {
2620
2640
  photo_url?: string | null | undefined;
2621
2641
  } | {
2622
2642
  type: "wallet";
2643
+ id: string | null;
2623
2644
  address: string;
2624
2645
  chain_type: "ethereum";
2625
2646
  wallet_index: number;
@@ -2635,6 +2656,7 @@ declare class FarcasterApi {
2635
2656
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2636
2657
  } | {
2637
2658
  type: "wallet";
2659
+ id: string | null;
2638
2660
  address: string;
2639
2661
  chain_type: "solana";
2640
2662
  wallet_index: number;
@@ -2651,6 +2673,7 @@ declare class FarcasterApi {
2651
2673
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2652
2674
  } | {
2653
2675
  type: "wallet";
2676
+ id: string | null;
2654
2677
  address: string;
2655
2678
  chain_type: "bitcoin-segwit";
2656
2679
  wallet_index: number;
@@ -2667,6 +2690,7 @@ declare class FarcasterApi {
2667
2690
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2668
2691
  } | {
2669
2692
  type: "wallet";
2693
+ id: string | null;
2670
2694
  address: string;
2671
2695
  chain_type: "bitcoin-taproot";
2672
2696
  wallet_index: number;
@@ -2923,6 +2947,7 @@ declare class OAuthApi {
2923
2947
  photo_url?: string | null | undefined;
2924
2948
  } | {
2925
2949
  type: "wallet";
2950
+ id: string | null;
2926
2951
  address: string;
2927
2952
  chain_type: "ethereum";
2928
2953
  wallet_index: number;
@@ -2938,6 +2963,7 @@ declare class OAuthApi {
2938
2963
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2939
2964
  } | {
2940
2965
  type: "wallet";
2966
+ id: string | null;
2941
2967
  address: string;
2942
2968
  chain_type: "solana";
2943
2969
  wallet_index: number;
@@ -2954,6 +2980,7 @@ declare class OAuthApi {
2954
2980
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2955
2981
  } | {
2956
2982
  type: "wallet";
2983
+ id: string | null;
2957
2984
  address: string;
2958
2985
  chain_type: "bitcoin-segwit";
2959
2986
  wallet_index: number;
@@ -2970,6 +2997,7 @@ declare class OAuthApi {
2970
2997
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2971
2998
  } | {
2972
2999
  type: "wallet";
3000
+ id: string | null;
2973
3001
  address: string;
2974
3002
  chain_type: "bitcoin-taproot";
2975
3003
  wallet_index: number;
@@ -3179,6 +3207,7 @@ declare class OAuthApi {
3179
3207
  photo_url?: string | null | undefined;
3180
3208
  } | {
3181
3209
  type: "wallet";
3210
+ id: string | null;
3182
3211
  address: string;
3183
3212
  chain_type: "ethereum";
3184
3213
  wallet_index: number;
@@ -3194,6 +3223,7 @@ declare class OAuthApi {
3194
3223
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3195
3224
  } | {
3196
3225
  type: "wallet";
3226
+ id: string | null;
3197
3227
  address: string;
3198
3228
  chain_type: "solana";
3199
3229
  wallet_index: number;
@@ -3210,6 +3240,7 @@ declare class OAuthApi {
3210
3240
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3211
3241
  } | {
3212
3242
  type: "wallet";
3243
+ id: string | null;
3213
3244
  address: string;
3214
3245
  chain_type: "bitcoin-segwit";
3215
3246
  wallet_index: number;
@@ -3226,6 +3257,7 @@ declare class OAuthApi {
3226
3257
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3227
3258
  } | {
3228
3259
  type: "wallet";
3260
+ id: string | null;
3229
3261
  address: string;
3230
3262
  chain_type: "bitcoin-taproot";
3231
3263
  wallet_index: number;
@@ -3582,6 +3614,7 @@ declare class PhoneApi {
3582
3614
  photo_url?: string | null | undefined;
3583
3615
  } | {
3584
3616
  type: "wallet";
3617
+ id: string | null;
3585
3618
  address: string;
3586
3619
  chain_type: "ethereum";
3587
3620
  wallet_index: number;
@@ -3597,6 +3630,7 @@ declare class PhoneApi {
3597
3630
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3598
3631
  } | {
3599
3632
  type: "wallet";
3633
+ id: string | null;
3600
3634
  address: string;
3601
3635
  chain_type: "solana";
3602
3636
  wallet_index: number;
@@ -3613,6 +3647,7 @@ declare class PhoneApi {
3613
3647
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3614
3648
  } | {
3615
3649
  type: "wallet";
3650
+ id: string | null;
3616
3651
  address: string;
3617
3652
  chain_type: "bitcoin-segwit";
3618
3653
  wallet_index: number;
@@ -3629,6 +3664,7 @@ declare class PhoneApi {
3629
3664
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3630
3665
  } | {
3631
3666
  type: "wallet";
3667
+ id: string | null;
3632
3668
  address: string;
3633
3669
  chain_type: "bitcoin-taproot";
3634
3670
  wallet_index: number;
@@ -3832,6 +3868,7 @@ declare class PhoneApi {
3832
3868
  photo_url?: string | null | undefined;
3833
3869
  } | {
3834
3870
  type: "wallet";
3871
+ id: string | null;
3835
3872
  address: string;
3836
3873
  chain_type: "ethereum";
3837
3874
  wallet_index: number;
@@ -3847,6 +3884,7 @@ declare class PhoneApi {
3847
3884
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3848
3885
  } | {
3849
3886
  type: "wallet";
3887
+ id: string | null;
3850
3888
  address: string;
3851
3889
  chain_type: "solana";
3852
3890
  wallet_index: number;
@@ -3863,6 +3901,7 @@ declare class PhoneApi {
3863
3901
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3864
3902
  } | {
3865
3903
  type: "wallet";
3904
+ id: string | null;
3866
3905
  address: string;
3867
3906
  chain_type: "bitcoin-segwit";
3868
3907
  wallet_index: number;
@@ -3879,6 +3918,7 @@ declare class PhoneApi {
3879
3918
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3880
3919
  } | {
3881
3920
  type: "wallet";
3921
+ id: string | null;
3882
3922
  address: string;
3883
3923
  chain_type: "bitcoin-taproot";
3884
3924
  wallet_index: number;
@@ -5049,6 +5089,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5049
5089
  photo_url?: string | null | undefined;
5050
5090
  } | {
5051
5091
  type: "wallet";
5092
+ id: string | null;
5052
5093
  address: string;
5053
5094
  chain_type: "ethereum";
5054
5095
  wallet_index: number;
@@ -5064,6 +5105,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5064
5105
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5065
5106
  } | {
5066
5107
  type: "wallet";
5108
+ id: string | null;
5067
5109
  address: string;
5068
5110
  chain_type: "solana";
5069
5111
  wallet_index: number;
@@ -5080,6 +5122,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5080
5122
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5081
5123
  } | {
5082
5124
  type: "wallet";
5125
+ id: string | null;
5083
5126
  address: string;
5084
5127
  chain_type: "bitcoin-segwit";
5085
5128
  wallet_index: number;
@@ -5096,6 +5139,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5096
5139
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5097
5140
  } | {
5098
5141
  type: "wallet";
5142
+ id: string | null;
5099
5143
  address: string;
5100
5144
  chain_type: "bitcoin-taproot";
5101
5145
  wallet_index: number;
@@ -5310,6 +5354,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5310
5354
  photo_url?: string | null | undefined;
5311
5355
  } | {
5312
5356
  type: "wallet";
5357
+ id: string | null;
5313
5358
  address: string;
5314
5359
  chain_type: "ethereum";
5315
5360
  wallet_index: number;
@@ -5325,6 +5370,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5325
5370
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5326
5371
  } | {
5327
5372
  type: "wallet";
5373
+ id: string | null;
5328
5374
  address: string;
5329
5375
  chain_type: "solana";
5330
5376
  wallet_index: number;
@@ -5341,6 +5387,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5341
5387
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5342
5388
  } | {
5343
5389
  type: "wallet";
5390
+ id: string | null;
5344
5391
  address: string;
5345
5392
  chain_type: "bitcoin-segwit";
5346
5393
  wallet_index: number;
@@ -5357,6 +5404,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5357
5404
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5358
5405
  } | {
5359
5406
  type: "wallet";
5407
+ id: string | null;
5360
5408
  address: string;
5361
5409
  chain_type: "bitcoin-taproot";
5362
5410
  wallet_index: number;
@@ -1145,6 +1145,7 @@ declare class EmbeddedWalletApi {
1145
1145
  photo_url?: string | null | undefined;
1146
1146
  } | {
1147
1147
  type: "wallet";
1148
+ id: string | null;
1148
1149
  address: string;
1149
1150
  chain_type: "ethereum";
1150
1151
  wallet_index: number;
@@ -1160,6 +1161,7 @@ declare class EmbeddedWalletApi {
1160
1161
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1161
1162
  } | {
1162
1163
  type: "wallet";
1164
+ id: string | null;
1163
1165
  address: string;
1164
1166
  chain_type: "solana";
1165
1167
  wallet_index: number;
@@ -1176,6 +1178,7 @@ declare class EmbeddedWalletApi {
1176
1178
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1177
1179
  } | {
1178
1180
  type: "wallet";
1181
+ id: string | null;
1179
1182
  address: string;
1180
1183
  chain_type: "bitcoin-segwit";
1181
1184
  wallet_index: number;
@@ -1192,6 +1195,7 @@ declare class EmbeddedWalletApi {
1192
1195
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1193
1196
  } | {
1194
1197
  type: "wallet";
1198
+ id: string | null;
1195
1199
  address: string;
1196
1200
  chain_type: "bitcoin-taproot";
1197
1201
  wallet_index: number;
@@ -1532,6 +1536,7 @@ declare class UserApi {
1532
1536
  photo_url?: string | null | undefined;
1533
1537
  } | {
1534
1538
  type: "wallet";
1539
+ id: string | null;
1535
1540
  address: string;
1536
1541
  chain_type: "ethereum";
1537
1542
  wallet_index: number;
@@ -1547,6 +1552,7 @@ declare class UserApi {
1547
1552
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1548
1553
  } | {
1549
1554
  type: "wallet";
1555
+ id: string | null;
1550
1556
  address: string;
1551
1557
  chain_type: "solana";
1552
1558
  wallet_index: number;
@@ -1563,6 +1569,7 @@ declare class UserApi {
1563
1569
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1564
1570
  } | {
1565
1571
  type: "wallet";
1572
+ id: string | null;
1566
1573
  address: string;
1567
1574
  chain_type: "bitcoin-segwit";
1568
1575
  wallet_index: number;
@@ -1579,6 +1586,7 @@ declare class UserApi {
1579
1586
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1580
1587
  } | {
1581
1588
  type: "wallet";
1589
+ id: string | null;
1582
1590
  address: string;
1583
1591
  chain_type: "bitcoin-taproot";
1584
1592
  wallet_index: number;
@@ -1830,6 +1838,7 @@ declare class EmailApi {
1830
1838
  photo_url?: string | null | undefined;
1831
1839
  } | {
1832
1840
  type: "wallet";
1841
+ id: string | null;
1833
1842
  address: string;
1834
1843
  chain_type: "ethereum";
1835
1844
  wallet_index: number;
@@ -1845,6 +1854,7 @@ declare class EmailApi {
1845
1854
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1846
1855
  } | {
1847
1856
  type: "wallet";
1857
+ id: string | null;
1848
1858
  address: string;
1849
1859
  chain_type: "solana";
1850
1860
  wallet_index: number;
@@ -1861,6 +1871,7 @@ declare class EmailApi {
1861
1871
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1862
1872
  } | {
1863
1873
  type: "wallet";
1874
+ id: string | null;
1864
1875
  address: string;
1865
1876
  chain_type: "bitcoin-segwit";
1866
1877
  wallet_index: number;
@@ -1877,6 +1888,7 @@ declare class EmailApi {
1877
1888
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
1878
1889
  } | {
1879
1890
  type: "wallet";
1891
+ id: string | null;
1880
1892
  address: string;
1881
1893
  chain_type: "bitcoin-taproot";
1882
1894
  wallet_index: number;
@@ -2080,6 +2092,7 @@ declare class EmailApi {
2080
2092
  photo_url?: string | null | undefined;
2081
2093
  } | {
2082
2094
  type: "wallet";
2095
+ id: string | null;
2083
2096
  address: string;
2084
2097
  chain_type: "ethereum";
2085
2098
  wallet_index: number;
@@ -2095,6 +2108,7 @@ declare class EmailApi {
2095
2108
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2096
2109
  } | {
2097
2110
  type: "wallet";
2111
+ id: string | null;
2098
2112
  address: string;
2099
2113
  chain_type: "solana";
2100
2114
  wallet_index: number;
@@ -2111,6 +2125,7 @@ declare class EmailApi {
2111
2125
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2112
2126
  } | {
2113
2127
  type: "wallet";
2128
+ id: string | null;
2114
2129
  address: string;
2115
2130
  chain_type: "bitcoin-segwit";
2116
2131
  wallet_index: number;
@@ -2127,6 +2142,7 @@ declare class EmailApi {
2127
2142
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2128
2143
  } | {
2129
2144
  type: "wallet";
2145
+ id: string | null;
2130
2146
  address: string;
2131
2147
  chain_type: "bitcoin-taproot";
2132
2148
  wallet_index: number;
@@ -2365,6 +2381,7 @@ declare class FarcasterApi {
2365
2381
  photo_url?: string | null | undefined;
2366
2382
  } | {
2367
2383
  type: "wallet";
2384
+ id: string | null;
2368
2385
  address: string;
2369
2386
  chain_type: "ethereum";
2370
2387
  wallet_index: number;
@@ -2380,6 +2397,7 @@ declare class FarcasterApi {
2380
2397
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2381
2398
  } | {
2382
2399
  type: "wallet";
2400
+ id: string | null;
2383
2401
  address: string;
2384
2402
  chain_type: "solana";
2385
2403
  wallet_index: number;
@@ -2396,6 +2414,7 @@ declare class FarcasterApi {
2396
2414
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2397
2415
  } | {
2398
2416
  type: "wallet";
2417
+ id: string | null;
2399
2418
  address: string;
2400
2419
  chain_type: "bitcoin-segwit";
2401
2420
  wallet_index: number;
@@ -2412,6 +2431,7 @@ declare class FarcasterApi {
2412
2431
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2413
2432
  } | {
2414
2433
  type: "wallet";
2434
+ id: string | null;
2415
2435
  address: string;
2416
2436
  chain_type: "bitcoin-taproot";
2417
2437
  wallet_index: number;
@@ -2620,6 +2640,7 @@ declare class FarcasterApi {
2620
2640
  photo_url?: string | null | undefined;
2621
2641
  } | {
2622
2642
  type: "wallet";
2643
+ id: string | null;
2623
2644
  address: string;
2624
2645
  chain_type: "ethereum";
2625
2646
  wallet_index: number;
@@ -2635,6 +2656,7 @@ declare class FarcasterApi {
2635
2656
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2636
2657
  } | {
2637
2658
  type: "wallet";
2659
+ id: string | null;
2638
2660
  address: string;
2639
2661
  chain_type: "solana";
2640
2662
  wallet_index: number;
@@ -2651,6 +2673,7 @@ declare class FarcasterApi {
2651
2673
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2652
2674
  } | {
2653
2675
  type: "wallet";
2676
+ id: string | null;
2654
2677
  address: string;
2655
2678
  chain_type: "bitcoin-segwit";
2656
2679
  wallet_index: number;
@@ -2667,6 +2690,7 @@ declare class FarcasterApi {
2667
2690
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2668
2691
  } | {
2669
2692
  type: "wallet";
2693
+ id: string | null;
2670
2694
  address: string;
2671
2695
  chain_type: "bitcoin-taproot";
2672
2696
  wallet_index: number;
@@ -2923,6 +2947,7 @@ declare class OAuthApi {
2923
2947
  photo_url?: string | null | undefined;
2924
2948
  } | {
2925
2949
  type: "wallet";
2950
+ id: string | null;
2926
2951
  address: string;
2927
2952
  chain_type: "ethereum";
2928
2953
  wallet_index: number;
@@ -2938,6 +2963,7 @@ declare class OAuthApi {
2938
2963
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2939
2964
  } | {
2940
2965
  type: "wallet";
2966
+ id: string | null;
2941
2967
  address: string;
2942
2968
  chain_type: "solana";
2943
2969
  wallet_index: number;
@@ -2954,6 +2980,7 @@ declare class OAuthApi {
2954
2980
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2955
2981
  } | {
2956
2982
  type: "wallet";
2983
+ id: string | null;
2957
2984
  address: string;
2958
2985
  chain_type: "bitcoin-segwit";
2959
2986
  wallet_index: number;
@@ -2970,6 +2997,7 @@ declare class OAuthApi {
2970
2997
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
2971
2998
  } | {
2972
2999
  type: "wallet";
3000
+ id: string | null;
2973
3001
  address: string;
2974
3002
  chain_type: "bitcoin-taproot";
2975
3003
  wallet_index: number;
@@ -3179,6 +3207,7 @@ declare class OAuthApi {
3179
3207
  photo_url?: string | null | undefined;
3180
3208
  } | {
3181
3209
  type: "wallet";
3210
+ id: string | null;
3182
3211
  address: string;
3183
3212
  chain_type: "ethereum";
3184
3213
  wallet_index: number;
@@ -3194,6 +3223,7 @@ declare class OAuthApi {
3194
3223
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3195
3224
  } | {
3196
3225
  type: "wallet";
3226
+ id: string | null;
3197
3227
  address: string;
3198
3228
  chain_type: "solana";
3199
3229
  wallet_index: number;
@@ -3210,6 +3240,7 @@ declare class OAuthApi {
3210
3240
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3211
3241
  } | {
3212
3242
  type: "wallet";
3243
+ id: string | null;
3213
3244
  address: string;
3214
3245
  chain_type: "bitcoin-segwit";
3215
3246
  wallet_index: number;
@@ -3226,6 +3257,7 @@ declare class OAuthApi {
3226
3257
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3227
3258
  } | {
3228
3259
  type: "wallet";
3260
+ id: string | null;
3229
3261
  address: string;
3230
3262
  chain_type: "bitcoin-taproot";
3231
3263
  wallet_index: number;
@@ -3582,6 +3614,7 @@ declare class PhoneApi {
3582
3614
  photo_url?: string | null | undefined;
3583
3615
  } | {
3584
3616
  type: "wallet";
3617
+ id: string | null;
3585
3618
  address: string;
3586
3619
  chain_type: "ethereum";
3587
3620
  wallet_index: number;
@@ -3597,6 +3630,7 @@ declare class PhoneApi {
3597
3630
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3598
3631
  } | {
3599
3632
  type: "wallet";
3633
+ id: string | null;
3600
3634
  address: string;
3601
3635
  chain_type: "solana";
3602
3636
  wallet_index: number;
@@ -3613,6 +3647,7 @@ declare class PhoneApi {
3613
3647
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3614
3648
  } | {
3615
3649
  type: "wallet";
3650
+ id: string | null;
3616
3651
  address: string;
3617
3652
  chain_type: "bitcoin-segwit";
3618
3653
  wallet_index: number;
@@ -3629,6 +3664,7 @@ declare class PhoneApi {
3629
3664
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3630
3665
  } | {
3631
3666
  type: "wallet";
3667
+ id: string | null;
3632
3668
  address: string;
3633
3669
  chain_type: "bitcoin-taproot";
3634
3670
  wallet_index: number;
@@ -3832,6 +3868,7 @@ declare class PhoneApi {
3832
3868
  photo_url?: string | null | undefined;
3833
3869
  } | {
3834
3870
  type: "wallet";
3871
+ id: string | null;
3835
3872
  address: string;
3836
3873
  chain_type: "ethereum";
3837
3874
  wallet_index: number;
@@ -3847,6 +3884,7 @@ declare class PhoneApi {
3847
3884
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3848
3885
  } | {
3849
3886
  type: "wallet";
3887
+ id: string | null;
3850
3888
  address: string;
3851
3889
  chain_type: "solana";
3852
3890
  wallet_index: number;
@@ -3863,6 +3901,7 @@ declare class PhoneApi {
3863
3901
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3864
3902
  } | {
3865
3903
  type: "wallet";
3904
+ id: string | null;
3866
3905
  address: string;
3867
3906
  chain_type: "bitcoin-segwit";
3868
3907
  wallet_index: number;
@@ -3879,6 +3918,7 @@ declare class PhoneApi {
3879
3918
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
3880
3919
  } | {
3881
3920
  type: "wallet";
3921
+ id: string | null;
3882
3922
  address: string;
3883
3923
  chain_type: "bitcoin-taproot";
3884
3924
  wallet_index: number;
@@ -5049,6 +5089,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5049
5089
  photo_url?: string | null | undefined;
5050
5090
  } | {
5051
5091
  type: "wallet";
5092
+ id: string | null;
5052
5093
  address: string;
5053
5094
  chain_type: "ethereum";
5054
5095
  wallet_index: number;
@@ -5064,6 +5105,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5064
5105
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5065
5106
  } | {
5066
5107
  type: "wallet";
5108
+ id: string | null;
5067
5109
  address: string;
5068
5110
  chain_type: "solana";
5069
5111
  wallet_index: number;
@@ -5080,6 +5122,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5080
5122
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5081
5123
  } | {
5082
5124
  type: "wallet";
5125
+ id: string | null;
5083
5126
  address: string;
5084
5127
  chain_type: "bitcoin-segwit";
5085
5128
  wallet_index: number;
@@ -5096,6 +5139,7 @@ declare const delegateWallet: (client: Privy) => ({ address, chainType }: Delega
5096
5139
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5097
5140
  } | {
5098
5141
  type: "wallet";
5142
+ id: string | null;
5099
5143
  address: string;
5100
5144
  chain_type: "bitcoin-taproot";
5101
5145
  wallet_index: number;
@@ -5310,6 +5354,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5310
5354
  photo_url?: string | null | undefined;
5311
5355
  } | {
5312
5356
  type: "wallet";
5357
+ id: string | null;
5313
5358
  address: string;
5314
5359
  chain_type: "ethereum";
5315
5360
  wallet_index: number;
@@ -5325,6 +5370,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5325
5370
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5326
5371
  } | {
5327
5372
  type: "wallet";
5373
+ id: string | null;
5328
5374
  address: string;
5329
5375
  chain_type: "solana";
5330
5376
  wallet_index: number;
@@ -5341,6 +5387,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5341
5387
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5342
5388
  } | {
5343
5389
  type: "wallet";
5390
+ id: string | null;
5344
5391
  address: string;
5345
5392
  chain_type: "bitcoin-segwit";
5346
5393
  wallet_index: number;
@@ -5357,6 +5404,7 @@ declare const revokeWallets: (client: Privy) => () => Promise<{
5357
5404
  recovery_method: "user-passcode" | "google-drive" | "icloud" | "privy" | "recovery-encryption-key";
5358
5405
  } | {
5359
5406
  type: "wallet";
5407
+ id: string | null;
5360
5408
  address: string;
5361
5409
  chain_type: "bitcoin-taproot";
5362
5410
  wallet_index: number;
@@ -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 n}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as d}from"../utils/toSearchParams.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.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 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(e,{body:t,params:s,query:r,headers:a,options:n={onRequest:this._beforeRequest.bind(this)}}){let o=new Request(`${this.baseUrl}${i(e.path,s)}${d(r)}`,{method:e.method,body:JSON.stringify(t),headers:a}),c=await n.onRequest(o),l=await this._fetch(o,c),p=await l.json();if(l.status>299)throw new h(p);return p}async _beforeRequestWithoutInitialize(e){let 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");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.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},options:{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){console.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){console.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(p,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){console.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},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}})}catch(e){}}async refreshSession(e=!1){let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return console.debug("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.getToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.debug(`[privy:refresh] fetching: ${n.path}`);let s=await this.fetch(n,{body:{refresh_token:e},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}}),i=s.session_update_action;return this.debug(`[privy:refresh] response: ${i}`),t||this.callbacks?.setUser?.(s.user),"set"===i&&(await this.session.updateWithTokensResponse(s),this.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&s.token&&(await this.session.storeToken(s.token),this.debug("[privy:refresh] access token stored"),s.identity_token&&(this.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.debug("[privy:refresh] returning response"),s}catch(e){throw this.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.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{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 console.error(e),!1}}debug(e){"DEBUG"===this._logLevel&&console.debug(e)}constructor(t){this._sdkVersion="js-sdk-core:0.44.0",this._cache=new Map,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._logLevel=t.logLevel,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new c({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(fetch,{retries:3,retryDelay:500}),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 n}from"@privy-io/public-api";import{PrivyClientError as o,PrivyApiError as h}from"../Error.mjs";import{Session as c}from"../Session.mjs";import l from"../toAbortSignalTimeout.mjs";import{toSearchParams as d}from"../utils/toSearchParams.mjs";import"eventemitter3";import"jose";import"js-cookie";import"../Token.mjs";import"../utils/allSettled.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 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(e,{body:t,params:s,query:r,headers:a,options:n={onRequest:this._beforeRequest.bind(this)}}){let o=new Request(`${this.baseUrl}${i(e.path,s)}${d(r)}`,{method:e.method,body:JSON.stringify(t),headers:a}),c=await n.onRequest(o),l=await this._fetch(o,c),p=await l.json();if(l.status>299)throw new h(p);return p}async _beforeRequestWithoutInitialize(e){let 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");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.getAccessToken(),this.beforeRequestWithoutRefresh(e)}async getAppConfig(){return await this.fetch(r,{params:{app_id:this.appId},options:{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){console.error("Unable to load clientId",e)}try{this._analyticsId=t()}catch(e){console.error("Unable to generate uuidv4",e)}if(!this._analyticsId)return null;try{await this._storage.put(p,this._analyticsId)}catch(e){console.error(`Unable to store clientId: ${this._analyticsId}`,e)}return this._analyticsId}async destroyClientAnalyticsId(){try{return await this._storage.del(p)}catch(e){console.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},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}})}catch(e){}}async refreshSession(e=!1){let t=await this.session.getRefreshToken()??void 0,s=t??"key",i=this._cache.get(s);if(i)return console.debug("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.getToken();if(!this.session.hasRefreshCredentials(i,e??null))throw this.debug("[privy:refresh] missing tokens, skipping request"),await this._initialize(),new h({code:s.MISSING_OR_INVALID_TOKEN,error:"No tokens found in storage"});try{this.debug(`[privy:refresh] fetching: ${n.path}`);let s=await this.fetch(n,{body:{refresh_token:e},options:{onRequest:this.beforeRequestWithoutRefresh.bind(this)}}),i=s.session_update_action;return this.debug(`[privy:refresh] response: ${i}`),t||this.callbacks?.setUser?.(s.user),"set"===i&&(await this.session.updateWithTokensResponse(s),this.debug("[privy:refresh] tokens stored")),"clear"===i&&(await this.session.destroyLocalState(),this.debug("[privy:refresh] tokens cleared"),t||this.callbacks?.setUser?.(null)),"ignore"===i&&s.token&&(await this.session.storeToken(s.token),this.debug("[privy:refresh] access token stored"),s.identity_token&&(this.debug("[privy:refresh] identity token stored"),await this.session.storeIdentityToken(s.identity_token))),this.debug("[privy:refresh] returning response"),s}catch(e){throw this.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.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{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 console.error(e),!1}}debug(e){"DEBUG"===this._logLevel&&console.debug(e)}constructor(t){this._sdkVersion="js-sdk-core:0.44.2",this._cache=new Map,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._logLevel=t.logLevel,this.callbacks=t.callbacks,this.nativeAppIdentifier=t.nativeAppIdentifier,this.session=new c({storage:this._storage,isUsingServerCookies:!1,appId:t.appId}),this._fetch=e(fetch,{retries:3,retryDelay:500}),this.session.on("error_storing_tokens",(e=>{this.createAnalyticsEvent("error_updating_tokens_in_storage",{reason:e})}))}}export{u as PrivyInternal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/js-sdk-core",
3
- "version": "0.44.0",
3
+ "version": "0.44.2",
4
4
  "description": "Vanilla JS client for the Privy Auth API",
5
5
  "keywords": [
6
6
  "authentication",
@@ -69,7 +69,7 @@
69
69
  "@ethersproject/transactions": "^5.7.0",
70
70
  "@ethersproject/units": "^5.7.0",
71
71
  "@privy-io/api-base": "^1.4.3",
72
- "@privy-io/public-api": "2.18.7",
72
+ "@privy-io/public-api": "2.18.9",
73
73
  "eventemitter3": "^5.0.1",
74
74
  "fetch-retry": "^5.0.6",
75
75
  "jose": "^4.15.5",