@mocanetwork/airkit-connector 1.8.1-beta.0 → 1.9.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,7 +94,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
94
94
  var e = new Error(message);
95
95
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
96
96
  };
97
- var version$2 = "1.8.1-beta.0";
97
+ var version$2 = "1.9.0-beta.1";
98
98
  var airkitPackage = {
99
99
  version: version$2
100
100
  };
@@ -122,6 +122,8 @@ const AirAuthMessageTypes = {
122
122
  SETUP_WALLET_RESPONSE: "air_auth_setup_wallet_response",
123
123
  SETUP_RECOVERY_REQUEST: "air_auth_setup_recovery_request",
124
124
  SETUP_RECOVERY_RESPONSE: "air_auth_setup_recovery_response",
125
+ SETUP_CREDENTIAL_REQUEST: "air_auth_setup_credential_request",
126
+ SETUP_CREDENTIAL_RESPONSE: "air_auth_setup_credential_response",
125
127
  SIGN_SIWE_MESSAGE_REQUEST: "air_auth_sign_siwe_message_request",
126
128
  SIGN_SIWE_MESSAGE_RESPONSE: "air_auth_sign_siwe_message_response",
127
129
  CROSS_PARTNER_TOKEN_REQUEST: "air_auth_cross_partner_token_request",
@@ -134,6 +136,8 @@ const AirAuthMessageTypes = {
134
136
  START_RECOVERY_RESPONSE: "air_start_recovery_response",
135
137
  RECOVERY_REQUEST: "air_auth_recovery_request",
136
138
  RECOVERY_RESPONSE: "air_auth_recovery_response",
139
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_auth_issue_on_behalf_new_user_confirmation_request",
140
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_auth_issue_on_behalf_new_user_confirmation_response",
137
141
  EXPIRED_LOGOUT_REQUEST: "air_auth_expired_logout_request"
138
142
  };
139
143
  const AirCredentialMessageTypes = {
@@ -145,12 +149,16 @@ const AirCredentialMessageTypes = {
145
149
  UPDATE_SESSION_CONFIG_RESPONSE: "air_credential_update_session_config_response",
146
150
  LOGOUT_REQUEST: "air_credential_logout_request",
147
151
  LOGOUT_RESPONSE: "air_credential_logout_response",
152
+ CLOSE_MODAL_REQUEST: "air_credential_close_modal_request",
153
+ CLOSE_MODAL_RESPONSE: "air_credential_close_modal_response",
148
154
  // New credential operation message types
149
155
  ISSUE_CREDENTIAL_REQUEST: "air_credential_issue_request",
150
156
  VERIFY_CREDENTIAL_REQUEST: "air_credential_verify_request",
151
157
  // Event messages for communication with parent
152
158
  ISSUE_CREDENTIAL_RESPONSE: "air_credential_issue_response",
153
- VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response"
159
+ VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response",
160
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_credential_issue_on_behalf_new_user_confirmation_request",
161
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_credential_issue_on_behalf_new_user_confirmation_response"
154
162
  };
155
163
  const AirRecoveryMessageTypes = {
156
164
  SERVICE_STARTED: "air_recovery_service_started",
@@ -167,8 +175,8 @@ const AirWalletMessageTypes = {
167
175
  SERVICE_STARTED: "air_service_started",
168
176
  INITIALIZATION_REQUEST: "air_initialization_request",
169
177
  INITIALIZATION_RESPONSE: "air_initialization_response",
170
- CLOSE_MODAL_REQUEST: "air_close_modal_request",
171
- CLOSE_MODAL_RESPONSE: "air_close_modal_response",
178
+ CLOSE_MODAL_REQUEST: "air_wallet_close_modal_request",
179
+ CLOSE_MODAL_RESPONSE: "air_wallet_close_modal_response",
172
180
  WALLET_INITIALIZED: "air_wallet_initialized",
173
181
  UPDATE_SESSION_CONFIG_REQUEST: "air_wallet_update_session_config_request",
174
182
  UPDATE_SESSION_CONFIG_RESPONSE: "air_wallet_update_session_config_response",
@@ -182,6 +190,10 @@ const AirWalletMessageTypes = {
182
190
  SHOW_SWAP_UI_RESPONSE: "air_show_swap_ui_response",
183
191
  SHOW_ON_RAMP_UI_REQUEST: "air_show_on_ramp_ui_request",
184
192
  SHOW_ON_RAMP_UI_RESPONSE: "air_show_on_ramp_ui_response",
193
+ SHOW_TRANSFER_UI_REQUEST: "air_show_transfer_ui_request",
194
+ SHOW_TRANSFER_UI_RESPONSE: "air_show_transfer_ui_response",
195
+ SHOW_RECEIVE_UI_REQUEST: "air_show_receive_ui_request",
196
+ SHOW_RECEIVE_UI_RESPONSE: "air_show_receive_ui_response",
185
197
  DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
186
198
  DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
187
199
  WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
@@ -190,7 +202,11 @@ const AirWalletMessageTypes = {
190
202
  LOGOUT_REQUEST: "air_logout_request",
191
203
  LOGOUT_RESPONSE: "air_logout_response",
192
204
  INTERNAL_PROVIDER_REQUEST: "air_internal_provider_request",
193
- INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response"
205
+ INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response",
206
+ ADDITIONAL_SIGNER_SIGNATURE_REQUEST: "air_additional_signer_signature_request",
207
+ ADDITIONAL_SIGNER_SIGNATURE_RESPONSE: "air_additional_signer_signature_response",
208
+ REMOVE_SIGNER_SIGNATURE_REQUEST: "air_remove_signer_signature_request",
209
+ REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_remove_signer_signature_response"
194
210
  };
195
211
  const AirWindowMessageTypes = {
196
212
  OPEN_WINDOW_REQUEST: "air_open_window_request",
@@ -1695,7 +1711,7 @@ const Codes = {
1695
1711
  ...AirIDErrorName,
1696
1712
  ...WindowErrorName
1697
1713
  };
1698
- const AirClientUserErrors = ["USER_CANCELLED", "CONFIG_ERROR", "CLIENT_ERROR", "UNKNOWN_ERROR", "PERMISSION_NOT_ENABLED", "SMART_ACCOUNT_NOT_DEPLOYED", "ACCOUNT_DELETION_PENDING"];
1714
+ const AirClientUserErrors = ["USER_CANCELLED", "CONFIG_ERROR", "CLIENT_ERROR", "UNKNOWN_ERROR", "PERMISSION_NOT_ENABLED", "SMART_ACCOUNT_NOT_DEPLOYED", "ACCOUNT_DELETION_PENDING", "SWAP_TO_ONRAMP", "USER_REJECTED"];
1699
1715
  class AirError extends BaseError$2 {}
1700
1716
  new Set(AirClientUserErrors);
1701
1717
  new Set(Object.values(Codes));
@@ -1954,7 +1970,7 @@ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_is
1954
1970
  });
1955
1971
  };
1956
1972
  var _a$3, _AuthMessageService_instance;
1957
- const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.START_RECOVERY_RESPONSE, AirAuthMessageTypes.EXPIRED_LOGOUT_REQUEST];
1973
+ const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.START_RECOVERY_RESPONSE, AirAuthMessageTypes.EXPIRED_LOGOUT_REQUEST];
1958
1974
  class AuthMessageService extends MessageServiceBase {
1959
1975
  static create() {
1960
1976
  if (!__classPrivateFieldGet$1(this, _a$3, "f", _AuthMessageService_instance)) {
@@ -2043,6 +2059,17 @@ class AuthMessageService extends MessageServiceBase {
2043
2059
  }
2044
2060
  });
2045
2061
  }
2062
+ async sendSetupCredentialSuccessResponse() {
2063
+ await this.sendMessage({
2064
+ type: AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE,
2065
+ payload: {
2066
+ success: true
2067
+ }
2068
+ });
2069
+ }
2070
+ async sendSetupCredentialErrorResponse(error) {
2071
+ await this.sendMessage(this.createErrorResponseMessage(AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE, error));
2072
+ }
2046
2073
  async sendCrossPartnerTokenRequest(targetPartnerUrl) {
2047
2074
  const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE)));
2048
2075
  await this.sendMessage({
@@ -2160,7 +2187,7 @@ class IframeController {
2160
2187
  if (this._iframeElement) return this._iframeElement;
2161
2188
  const iframe = document.createElement("iframe");
2162
2189
  iframe.id = this.iframeId;
2163
- iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version"].join("; ");
2190
+ iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version", "clipboard-write", "web-share"].join("; ");
2164
2191
  iframe.src = this.iframeUrl;
2165
2192
  iframe.style.position = "fixed";
2166
2193
  iframe.style.zIndex = `${this.getZIndex()}`;
@@ -2263,7 +2290,7 @@ _RecoveryMessageService_instance = {
2263
2290
  value: void 0
2264
2291
  };
2265
2292
  var _a, _WalletMessageService_instance;
2266
- const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
2293
+ const ALLOWED_WALLET_MESSAGES = [AirWalletMessageTypes.INITIALIZATION_RESPONSE, AirWalletMessageTypes.WALLET_INITIALIZED, AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE, AirWalletMessageTypes.WALLET_LOGIN_RESPONSE, AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE, AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE, AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE, AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE, AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE, AirWalletMessageTypes.CLAIM_ID_RESPONSE, AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE, AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirWalletMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST, AirWalletMessageTypes.LOGOUT_RESPONSE, AirWindowMessageTypes.OPEN_WINDOW_REQUEST, AirWindowMessageTypes.OPEN_WINDOW_RETRY_RESPONSE];
2267
2294
  class WalletMessageService extends MessageServiceBase {
2268
2295
  static create() {
2269
2296
  if (!__classPrivateFieldGet$1(this, _a, "f", _WalletMessageService_instance)) {
@@ -2399,6 +2426,26 @@ class WalletMessageService extends MessageServiceBase {
2399
2426
  });
2400
2427
  return response;
2401
2428
  }
2429
+ async sendShowTransferUIRequest(payload) {
2430
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE)));
2431
+ await this.sendMessage({
2432
+ type: AirWalletMessageTypes.SHOW_TRANSFER_UI_REQUEST,
2433
+ payload: {
2434
+ tokenSymbol: payload?.tokenSymbol,
2435
+ chainId: payload?.chainId,
2436
+ recipientAddress: payload?.recipientAddress,
2437
+ amount: payload?.amount
2438
+ }
2439
+ });
2440
+ return response;
2441
+ }
2442
+ async sendShowReceiveUIRequest() {
2443
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE)));
2444
+ await this.sendMessage({
2445
+ type: AirWalletMessageTypes.SHOW_RECEIVE_UI_REQUEST
2446
+ });
2447
+ return response;
2448
+ }
2402
2449
  }
2403
2450
  _a = WalletMessageService;
2404
2451
  _WalletMessageService_instance = {
@@ -2749,6 +2796,20 @@ class AirService {
2749
2796
  }
2750
2797
  break;
2751
2798
  }
2799
+ case AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST:
2800
+ {
2801
+ try {
2802
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, {
2803
+ skipWalletLogin: true
2804
+ });
2805
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
2806
+ await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendSetupCredentialSuccessResponse();
2807
+ } catch (err) {
2808
+ const error = ensureError(err);
2809
+ await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendSetupCredentialErrorResponse(error);
2810
+ }
2811
+ break;
2812
+ }
2752
2813
  case AirAuthMessageTypes.EXPIRED_LOGOUT_REQUEST:
2753
2814
  {
2754
2815
  await this.logout();
@@ -2811,6 +2872,10 @@ class AirService {
2811
2872
  });
2812
2873
  if (payload.success === true) {
2813
2874
  __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload));
2875
+ if (payload.needsWalletRestart === true) {
2876
+ await Promise.all([__classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this), __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this)]);
2877
+ void __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
2878
+ }
2814
2879
  __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2815
2880
  return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
2816
2881
  }
@@ -2900,6 +2965,36 @@ class AirService {
2900
2965
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2901
2966
  }
2902
2967
  }
2968
+ /**
2969
+ * @experimental This feature has not been officially released and might change in the future.
2970
+ */
2971
+ async showTransferUI(options) {
2972
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
2973
+ const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowTransferUIRequest(options);
2974
+ if (result.payload.success === false) {
2975
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2976
+ }
2977
+ return {
2978
+ txHash: result.payload.txHash,
2979
+ symbol: result.payload.symbol,
2980
+ chainId: result.payload.chainId,
2981
+ decimals: result.payload.decimals,
2982
+ address: result.payload.address,
2983
+ recipientAddress: result.payload.recipientAddress,
2984
+ amount: result.payload.amount
2985
+ };
2986
+ }
2987
+ /**
2988
+ * @experimental This feature has not been officially released and might change in the future.
2989
+ */
2990
+ async showReceiveUI() {
2991
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
2992
+ const result = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendShowReceiveUIRequest();
2993
+ if (result.payload.success === false) {
2994
+ if (result.payload.errorName === "USER_CANCELLED") return;
2995
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2996
+ }
2997
+ }
2903
2998
  async getUserInfo() {
2904
2999
  __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
2905
3000
  const info = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
@@ -3004,7 +3099,8 @@ class AirService {
3004
3099
  issuerDid,
3005
3100
  credentialId,
3006
3101
  credentialSubject,
3007
- curve
3102
+ curve,
3103
+ offchain
3008
3104
  }) {
3009
3105
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3010
3106
  const response = await __classPrivateFieldGet$1(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
@@ -3012,7 +3108,8 @@ class AirService {
3012
3108
  issuerDid,
3013
3109
  credentialId,
3014
3110
  credentialSubject,
3015
- curve
3111
+ curve,
3112
+ offchain
3016
3113
  });
3017
3114
  const {
3018
3115
  payload
@@ -3030,7 +3127,9 @@ class AirService {
3030
3127
  async verifyCredential({
3031
3128
  authToken,
3032
3129
  programId,
3033
- redirectUrl
3130
+ redirectUrl,
3131
+ requestDisclosure,
3132
+ offchain
3034
3133
  }) {
3035
3134
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3036
3135
  const {
@@ -3038,7 +3137,9 @@ class AirService {
3038
3137
  } = await __classPrivateFieldGet$1(this, _AirService_credentialMessagingService, "f").sendVerifyCredentialRequest({
3039
3138
  partnerToken: authToken,
3040
3139
  programId,
3041
- redirectUrl
3140
+ redirectUrl,
3141
+ requestDisclosure,
3142
+ offchain
3042
3143
  });
3043
3144
  if (payload.success === false) {
3044
3145
  throw new AirServiceError(payload.errorName, payload.errorMessage);
@@ -3178,6 +3279,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3178
3279
  } = await __classPrivateFieldGet$1(this, _AirService_walletMessagingService, "f").sendInitializationRequest({
3179
3280
  sessionId: __classPrivateFieldGet$1(this, _AirService_sessionId, "f"),
3180
3281
  partnerId: __classPrivateFieldGet$1(this, _AirService_partnerId, "f"),
3282
+ partnerDAppUrl: window.location.href,
3181
3283
  enableLogging: __classPrivateFieldGet$1(this, _AirService_enableLogging, "f"),
3182
3284
  sdkVersion: airKitVersion,
3183
3285
  enableAutomation: this.shouldEnableAutomation(),
@@ -3365,6 +3467,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3365
3467
  } = await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").sendInitializationRequest({
3366
3468
  sessionId: __classPrivateFieldGet$1(this, _AirService_sessionId, "f"),
3367
3469
  partnerId: __classPrivateFieldGet$1(this, _AirService_partnerId, "f"),
3470
+ partnerDAppUrl: window.location.href,
3368
3471
  enableLogging: __classPrivateFieldGet$1(this, _AirService_enableLogging, "f"),
3369
3472
  sdkVersion: airKitVersion,
3370
3473
  enableAutomation: this.shouldEnableAutomation(),
@@ -3418,7 +3521,28 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3418
3521
  __classPrivateFieldSet(this, _AirService_recoveryInitialization, undefined);
3419
3522
  };
3420
3523
 
3421
- const version$1 = '2.34.0';
3524
+ function isHex(value, {
3525
+ strict = true
3526
+ } = {}) {
3527
+ if (!value) return false;
3528
+ if (typeof value !== 'string') return false;
3529
+ return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith('0x');
3530
+ }
3531
+
3532
+ /**
3533
+ * @description Retrieves the size of the value (in bytes).
3534
+ *
3535
+ * @param value The value (hex or byte array) to retrieve the size of.
3536
+ * @returns The size of the value (in bytes).
3537
+ */
3538
+ function size(value) {
3539
+ if (isHex(value, {
3540
+ strict: false
3541
+ })) return Math.ceil((value.length - 2) / 2);
3542
+ return value.length;
3543
+ }
3544
+
3545
+ const version$1 = '2.46.3';
3422
3546
 
3423
3547
  let errorConfig = {
3424
3548
  getDocsUrl: ({
@@ -3500,26 +3624,13 @@ function walk(err, fn) {
3500
3624
  return fn ? null : err;
3501
3625
  }
3502
3626
 
3503
- class IntegerOutOfRangeError extends BaseError$1 {
3504
- constructor({
3505
- max,
3506
- min,
3507
- signed,
3508
- size,
3509
- value
3510
- }) {
3511
- super(`Number "${value}" is not in safe ${size ? `${size * 8}-bit ${signed ? 'signed' : 'unsigned'} ` : ''}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, {
3512
- name: 'IntegerOutOfRangeError'
3513
- });
3514
- }
3515
- }
3516
- class SizeOverflowError extends BaseError$1 {
3627
+ class InvalidAddressError extends BaseError$1 {
3517
3628
  constructor({
3518
- givenSize,
3519
- maxSize
3629
+ address
3520
3630
  }) {
3521
- super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, {
3522
- name: 'SizeOverflowError'
3631
+ super(`Address "${address}" is invalid.`, {
3632
+ metaMessages: ['- Address must be a hex value of 20 bytes (40 hex characters).', '- Address must match its checksum counterpart.'],
3633
+ name: 'InvalidAddressError'
3523
3634
  });
3524
3635
  }
3525
3636
  }
@@ -3580,25 +3691,86 @@ function padBytes(bytes, {
3580
3691
  return paddedBytes;
3581
3692
  }
3582
3693
 
3583
- function isHex(value, {
3584
- strict = true
3585
- } = {}) {
3586
- if (!value) return false;
3587
- if (typeof value !== 'string') return false;
3588
- return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith('0x');
3694
+ class IntegerOutOfRangeError extends BaseError$1 {
3695
+ constructor({
3696
+ max,
3697
+ min,
3698
+ signed,
3699
+ size,
3700
+ value
3701
+ }) {
3702
+ super(`Number "${value}" is not in safe ${size ? `${size * 8}-bit ${signed ? 'signed' : 'unsigned'} ` : ''}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, {
3703
+ name: 'IntegerOutOfRangeError'
3704
+ });
3705
+ }
3706
+ }
3707
+ class SizeOverflowError extends BaseError$1 {
3708
+ constructor({
3709
+ givenSize,
3710
+ maxSize
3711
+ }) {
3712
+ super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, {
3713
+ name: 'SizeOverflowError'
3714
+ });
3715
+ }
3716
+ }
3717
+
3718
+ function assertSize(hexOrBytes, {
3719
+ size: size$1
3720
+ }) {
3721
+ if (size(hexOrBytes) > size$1) throw new SizeOverflowError({
3722
+ givenSize: size(hexOrBytes),
3723
+ maxSize: size$1
3724
+ });
3589
3725
  }
3590
3726
 
3591
3727
  /**
3592
- * @description Retrieves the size of the value (in bytes).
3728
+ * Encodes a number or bigint into a hex string
3593
3729
  *
3594
- * @param value The value (hex or byte array) to retrieve the size of.
3595
- * @returns The size of the value (in bytes).
3730
+ * - Docs: https://viem.sh/docs/utilities/toHex#numbertohex
3731
+ *
3732
+ * @param value Value to encode.
3733
+ * @param opts Options.
3734
+ * @returns Hex value.
3735
+ *
3736
+ * @example
3737
+ * import { numberToHex } from 'viem'
3738
+ * const data = numberToHex(420)
3739
+ * // '0x1a4'
3740
+ *
3741
+ * @example
3742
+ * import { numberToHex } from 'viem'
3743
+ * const data = numberToHex(420, { size: 32 })
3744
+ * // '0x00000000000000000000000000000000000000000000000000000000000001a4'
3596
3745
  */
3597
- function size(value) {
3598
- if (isHex(value, {
3599
- strict: false
3600
- })) return Math.ceil((value.length - 2) / 2);
3601
- return value.length;
3746
+ function numberToHex(value_, opts = {}) {
3747
+ const {
3748
+ signed,
3749
+ size
3750
+ } = opts;
3751
+ const value = BigInt(value_);
3752
+ let maxValue;
3753
+ if (size) {
3754
+ if (signed) maxValue = (1n << BigInt(size) * 8n - 1n) - 1n;else maxValue = 2n ** (BigInt(size) * 8n) - 1n;
3755
+ } else if (typeof value_ === 'number') {
3756
+ maxValue = BigInt(Number.MAX_SAFE_INTEGER);
3757
+ }
3758
+ const minValue = typeof maxValue === 'bigint' && signed ? -maxValue - 1n : 0;
3759
+ if (maxValue && value > maxValue || value < minValue) {
3760
+ const suffix = typeof value_ === 'bigint' ? 'n' : '';
3761
+ throw new IntegerOutOfRangeError({
3762
+ max: maxValue ? `${maxValue}${suffix}` : undefined,
3763
+ min: `${minValue}${suffix}`,
3764
+ signed,
3765
+ size,
3766
+ value: `${value_}${suffix}`
3767
+ });
3768
+ }
3769
+ const hex = `0x${(signed && value < 0 ? (1n << BigInt(size * 8)) + BigInt(value) : value).toString(16)}`;
3770
+ if (size) return pad(hex, {
3771
+ size
3772
+ });
3773
+ return hex;
3602
3774
  }
3603
3775
 
3604
3776
  const encoder = /*#__PURE__*/new TextEncoder();
@@ -3780,109 +3952,6 @@ function stringToBytes(value, opts = {}) {
3780
3952
  return bytes;
3781
3953
  }
3782
3954
 
3783
- function assertSize(hexOrBytes, {
3784
- size: size$1
3785
- }) {
3786
- if (size(hexOrBytes) > size$1) throw new SizeOverflowError({
3787
- givenSize: size(hexOrBytes),
3788
- maxSize: size$1
3789
- });
3790
- }
3791
-
3792
- /**
3793
- * Encodes a number or bigint into a hex string
3794
- *
3795
- * - Docs: https://viem.sh/docs/utilities/toHex#numbertohex
3796
- *
3797
- * @param value Value to encode.
3798
- * @param opts Options.
3799
- * @returns Hex value.
3800
- *
3801
- * @example
3802
- * import { numberToHex } from 'viem'
3803
- * const data = numberToHex(420)
3804
- * // '0x1a4'
3805
- *
3806
- * @example
3807
- * import { numberToHex } from 'viem'
3808
- * const data = numberToHex(420, { size: 32 })
3809
- * // '0x00000000000000000000000000000000000000000000000000000000000001a4'
3810
- */
3811
- function numberToHex(value_, opts = {}) {
3812
- const {
3813
- signed,
3814
- size
3815
- } = opts;
3816
- const value = BigInt(value_);
3817
- let maxValue;
3818
- if (size) {
3819
- if (signed) maxValue = (1n << BigInt(size) * 8n - 1n) - 1n;else maxValue = 2n ** (BigInt(size) * 8n) - 1n;
3820
- } else if (typeof value_ === 'number') {
3821
- maxValue = BigInt(Number.MAX_SAFE_INTEGER);
3822
- }
3823
- const minValue = typeof maxValue === 'bigint' && signed ? -maxValue - 1n : 0;
3824
- if (maxValue && value > maxValue || value < minValue) {
3825
- const suffix = typeof value_ === 'bigint' ? 'n' : '';
3826
- throw new IntegerOutOfRangeError({
3827
- max: maxValue ? `${maxValue}${suffix}` : undefined,
3828
- min: `${minValue}${suffix}`,
3829
- signed,
3830
- size,
3831
- value: `${value_}${suffix}`
3832
- });
3833
- }
3834
- const hex = `0x${(signed && value < 0 ? (1n << BigInt(size * 8)) + BigInt(value) : value).toString(16)}`;
3835
- if (size) return pad(hex, {
3836
- size
3837
- });
3838
- return hex;
3839
- }
3840
-
3841
- class InvalidAddressError extends BaseError$1 {
3842
- constructor({
3843
- address
3844
- }) {
3845
- super(`Address "${address}" is invalid.`, {
3846
- metaMessages: ['- Address must be a hex value of 20 bytes (40 hex characters).', '- Address must match its checksum counterpart.'],
3847
- name: 'InvalidAddressError'
3848
- });
3849
- }
3850
- }
3851
-
3852
- /**
3853
- * Map with a LRU (Least recently used) policy.
3854
- *
3855
- * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
3856
- */
3857
- class LruMap extends Map {
3858
- constructor(size) {
3859
- super();
3860
- Object.defineProperty(this, "maxSize", {
3861
- enumerable: true,
3862
- configurable: true,
3863
- writable: true,
3864
- value: void 0
3865
- });
3866
- this.maxSize = size;
3867
- }
3868
- get(key) {
3869
- const value = super.get(key);
3870
- if (super.has(key) && value !== undefined) {
3871
- this.delete(key);
3872
- super.set(key, value);
3873
- }
3874
- return value;
3875
- }
3876
- set(key, value) {
3877
- super.set(key, value);
3878
- if (this.maxSize && this.size > this.maxSize) {
3879
- const firstKey = this.keys().next().value;
3880
- if (firstKey) this.delete(firstKey);
3881
- }
3882
- return this;
3883
- }
3884
- }
3885
-
3886
3955
  /**
3887
3956
  * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
3888
3957
  * @todo re-check https://issues.chromium.org/issues/42212588
@@ -4234,6 +4303,59 @@ function keccak256(value, to_) {
4234
4303
  return bytes;
4235
4304
  }
4236
4305
 
4306
+ /**
4307
+ * Map with a LRU (Least recently used) policy.
4308
+ *
4309
+ * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
4310
+ */
4311
+ class LruMap extends Map {
4312
+ constructor(size) {
4313
+ super();
4314
+ Object.defineProperty(this, "maxSize", {
4315
+ enumerable: true,
4316
+ configurable: true,
4317
+ writable: true,
4318
+ value: void 0
4319
+ });
4320
+ this.maxSize = size;
4321
+ }
4322
+ get(key) {
4323
+ const value = super.get(key);
4324
+ if (super.has(key) && value !== undefined) {
4325
+ this.delete(key);
4326
+ super.set(key, value);
4327
+ }
4328
+ return value;
4329
+ }
4330
+ set(key, value) {
4331
+ super.set(key, value);
4332
+ if (this.maxSize && this.size > this.maxSize) {
4333
+ const firstKey = this.keys().next().value;
4334
+ if (firstKey) this.delete(firstKey);
4335
+ }
4336
+ return this;
4337
+ }
4338
+ }
4339
+
4340
+ const addressRegex = /^0x[a-fA-F0-9]{40}$/;
4341
+ /** @internal */
4342
+ const isAddressCache = /*#__PURE__*/new LruMap(8192);
4343
+ function isAddress(address, options) {
4344
+ const {
4345
+ strict = true
4346
+ } = options ?? {};
4347
+ const cacheKey = `${address}.${strict}`;
4348
+ if (isAddressCache.has(cacheKey)) return isAddressCache.get(cacheKey);
4349
+ const result = (() => {
4350
+ if (!addressRegex.test(address)) return false;
4351
+ if (address.toLowerCase() === address) return true;
4352
+ if (strict) return checksumAddress(address) === address;
4353
+ return true;
4354
+ })();
4355
+ isAddressCache.set(cacheKey, result);
4356
+ return result;
4357
+ }
4358
+
4237
4359
  const checksumAddressCache = /*#__PURE__*/new LruMap(8192);
4238
4360
  function checksumAddress(address_,
4239
4361
  /**
@@ -4283,25 +4405,6 @@ chainId) {
4283
4405
  return checksumAddress(address, chainId);
4284
4406
  }
4285
4407
 
4286
- const addressRegex = /^0x[a-fA-F0-9]{40}$/;
4287
- /** @internal */
4288
- const isAddressCache = /*#__PURE__*/new LruMap(8192);
4289
- function isAddress(address, options) {
4290
- const {
4291
- strict = true
4292
- } = options ?? {};
4293
- const cacheKey = `${address}.${strict}`;
4294
- if (isAddressCache.has(cacheKey)) return isAddressCache.get(cacheKey);
4295
- const result = (() => {
4296
- if (!addressRegex.test(address)) return false;
4297
- if (address.toLowerCase() === address) return true;
4298
- if (strict) return checksumAddress(address) === address;
4299
- return true;
4300
- })();
4301
- isAddressCache.set(cacheKey, result);
4302
- return result;
4303
- }
4304
-
4305
4408
  const stringify = (value, replacer, space) => JSON.stringify(value, (key, value_) => {
4306
4409
  const value = typeof value_ === 'bigint' ? value_.toString() : value_;
4307
4410
  return value;
@@ -4333,8 +4436,15 @@ class RpcRequestError extends BaseError$1 {
4333
4436
  writable: true,
4334
4437
  value: void 0
4335
4438
  });
4439
+ Object.defineProperty(this, "url", {
4440
+ enumerable: true,
4441
+ configurable: true,
4442
+ writable: true,
4443
+ value: void 0
4444
+ });
4336
4445
  this.code = error.code;
4337
4446
  this.data = error.data;
4447
+ this.url = url;
4338
4448
  }
4339
4449
  }
4340
4450
 
@@ -4406,7 +4516,7 @@ Object.defineProperty(SwitchChainError, "code", {
4406
4516
  value: 4902
4407
4517
  });
4408
4518
 
4409
- const version = '2.19.0';
4519
+ const version = '2.21.2';
4410
4520
 
4411
4521
  const getVersion = () => `@wagmi/core@${version}`;
4412
4522
 
@@ -4840,10 +4950,11 @@ function airConnector(parameters) {
4840
4950
  isRainbowKitConnector: true,
4841
4951
  airService: service,
4842
4952
  getLoginResult: () => loginResult,
4843
- async connect({ chainId, authToken } = {}) {
4953
+ async connect(connectParams) {
4954
+ const { chainId, authToken } = connectParams ?? {};
4844
4955
  try {
4845
4956
  config.emitter.emit("message", { type: "connecting" });
4846
- const provider = await this.getProvider();
4957
+ const provider = (await this.getProvider());
4847
4958
  provider.on("accountsChanged", (payload) => this.onAccountsChanged(payload));
4848
4959
  provider.on("chainChanged", this.onChainChanged);
4849
4960
  provider.on("disconnect", this.onDisconnect.bind(this));
@@ -4869,14 +4980,14 @@ function airConnector(parameters) {
4869
4980
  }
4870
4981
  },
4871
4982
  async getAccounts() {
4872
- const provider = await this.getProvider();
4983
+ const provider = (await this.getProvider());
4873
4984
  return (await provider.request({
4874
4985
  method: "eth_accounts",
4875
4986
  params: [],
4876
4987
  })).map((x) => getAddress(x));
4877
4988
  },
4878
4989
  async getChainId() {
4879
- const provider = await this.getProvider();
4990
+ const provider = (await this.getProvider());
4880
4991
  const chainId = await provider.request({
4881
4992
  method: "eth_chainId",
4882
4993
  params: [],
@@ -4907,7 +5018,7 @@ function airConnector(parameters) {
4907
5018
  const chain = config.chains.find((x) => x.id === chainId);
4908
5019
  if (!chain)
4909
5020
  throw new SwitchChainError(new ChainNotConfiguredError());
4910
- const provider = await this.getProvider();
5021
+ const provider = (await this.getProvider());
4911
5022
  const hexChainId = numberToHex(chain.id);
4912
5023
  try {
4913
5024
  await provider.request({
@@ -4963,7 +5074,7 @@ function airConnector(parameters) {
4963
5074
  await service.logout();
4964
5075
  return;
4965
5076
  }
4966
- const provider = await this.getProvider();
5077
+ const provider = (await this.getProvider());
4967
5078
  if (provider) {
4968
5079
  provider.removeListener("accountsChanged", (payload) => this.onAccountsChanged(payload));
4969
5080
  provider.removeListener("chainChanged", this.onChainChanged);