@mocanetwork/airkit 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.
@@ -97,7 +97,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
97
97
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
98
98
  };
99
99
 
100
- var version = "1.8.1-beta.0";
100
+ var version = "1.9.0-beta.1";
101
101
  var airkitPackage = {
102
102
  version: version};
103
103
 
@@ -125,6 +125,8 @@ const AirAuthMessageTypes = {
125
125
  SETUP_WALLET_RESPONSE: "air_auth_setup_wallet_response",
126
126
  SETUP_RECOVERY_REQUEST: "air_auth_setup_recovery_request",
127
127
  SETUP_RECOVERY_RESPONSE: "air_auth_setup_recovery_response",
128
+ SETUP_CREDENTIAL_REQUEST: "air_auth_setup_credential_request",
129
+ SETUP_CREDENTIAL_RESPONSE: "air_auth_setup_credential_response",
128
130
  SIGN_SIWE_MESSAGE_REQUEST: "air_auth_sign_siwe_message_request",
129
131
  SIGN_SIWE_MESSAGE_RESPONSE: "air_auth_sign_siwe_message_response",
130
132
  CROSS_PARTNER_TOKEN_REQUEST: "air_auth_cross_partner_token_request",
@@ -137,6 +139,8 @@ const AirAuthMessageTypes = {
137
139
  START_RECOVERY_RESPONSE: "air_start_recovery_response",
138
140
  RECOVERY_REQUEST: "air_auth_recovery_request",
139
141
  RECOVERY_RESPONSE: "air_auth_recovery_response",
142
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_auth_issue_on_behalf_new_user_confirmation_request",
143
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_auth_issue_on_behalf_new_user_confirmation_response",
140
144
  EXPIRED_LOGOUT_REQUEST: "air_auth_expired_logout_request"
141
145
  };
142
146
 
@@ -149,12 +153,16 @@ const AirCredentialMessageTypes = {
149
153
  UPDATE_SESSION_CONFIG_RESPONSE: "air_credential_update_session_config_response",
150
154
  LOGOUT_REQUEST: "air_credential_logout_request",
151
155
  LOGOUT_RESPONSE: "air_credential_logout_response",
156
+ CLOSE_MODAL_REQUEST: "air_credential_close_modal_request",
157
+ CLOSE_MODAL_RESPONSE: "air_credential_close_modal_response",
152
158
  // New credential operation message types
153
159
  ISSUE_CREDENTIAL_REQUEST: "air_credential_issue_request",
154
160
  VERIFY_CREDENTIAL_REQUEST: "air_credential_verify_request",
155
161
  // Event messages for communication with parent
156
162
  ISSUE_CREDENTIAL_RESPONSE: "air_credential_issue_response",
157
- VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response"
163
+ VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response",
164
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_credential_issue_on_behalf_new_user_confirmation_request",
165
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_credential_issue_on_behalf_new_user_confirmation_response"
158
166
  };
159
167
 
160
168
  const AirRecoveryMessageTypes = {
@@ -173,8 +181,8 @@ const AirWalletMessageTypes = {
173
181
  SERVICE_STARTED: "air_service_started",
174
182
  INITIALIZATION_REQUEST: "air_initialization_request",
175
183
  INITIALIZATION_RESPONSE: "air_initialization_response",
176
- CLOSE_MODAL_REQUEST: "air_close_modal_request",
177
- CLOSE_MODAL_RESPONSE: "air_close_modal_response",
184
+ CLOSE_MODAL_REQUEST: "air_wallet_close_modal_request",
185
+ CLOSE_MODAL_RESPONSE: "air_wallet_close_modal_response",
178
186
  WALLET_INITIALIZED: "air_wallet_initialized",
179
187
  UPDATE_SESSION_CONFIG_REQUEST: "air_wallet_update_session_config_request",
180
188
  UPDATE_SESSION_CONFIG_RESPONSE: "air_wallet_update_session_config_response",
@@ -188,6 +196,10 @@ const AirWalletMessageTypes = {
188
196
  SHOW_SWAP_UI_RESPONSE: "air_show_swap_ui_response",
189
197
  SHOW_ON_RAMP_UI_REQUEST: "air_show_on_ramp_ui_request",
190
198
  SHOW_ON_RAMP_UI_RESPONSE: "air_show_on_ramp_ui_response",
199
+ SHOW_TRANSFER_UI_REQUEST: "air_show_transfer_ui_request",
200
+ SHOW_TRANSFER_UI_RESPONSE: "air_show_transfer_ui_response",
201
+ SHOW_RECEIVE_UI_REQUEST: "air_show_receive_ui_request",
202
+ SHOW_RECEIVE_UI_RESPONSE: "air_show_receive_ui_response",
191
203
  DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
192
204
  DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
193
205
  WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
@@ -196,7 +208,11 @@ const AirWalletMessageTypes = {
196
208
  LOGOUT_REQUEST: "air_logout_request",
197
209
  LOGOUT_RESPONSE: "air_logout_response",
198
210
  INTERNAL_PROVIDER_REQUEST: "air_internal_provider_request",
199
- INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response"
211
+ INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response",
212
+ ADDITIONAL_SIGNER_SIGNATURE_REQUEST: "air_additional_signer_signature_request",
213
+ ADDITIONAL_SIGNER_SIGNATURE_RESPONSE: "air_additional_signer_signature_response",
214
+ REMOVE_SIGNER_SIGNATURE_REQUEST: "air_remove_signer_signature_request",
215
+ REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_remove_signer_signature_response"
200
216
  };
201
217
 
202
218
  const AirWindowMessageTypes = {
@@ -649,6 +665,34 @@ const mocaTestnet = {
649
665
  },
650
666
  testnet: true
651
667
  };
668
+ const mocaMainnet = {
669
+ id: 2288,
670
+ name: "Moca Mainnet",
671
+ nativeCurrency: {
672
+ decimals: 18,
673
+ name: "Moca Network",
674
+ symbol: "MOCA"
675
+ },
676
+ rpcUrls: {
677
+ default: {
678
+ http: ["https://rpc.mocachain.org"],
679
+ webSocket: ["wss://rpc.mocachain.org/ws"]
680
+ }
681
+ },
682
+ blockExplorers: {
683
+ default: {
684
+ name: "Moca Mainnet",
685
+ url: "https://scan.mocachain.org"
686
+ } // TODO: need to confirm mainnet explorer
687
+ },
688
+ contracts: {
689
+ multicall3: {
690
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
691
+ blockCreated: 3668598
692
+ }
693
+ },
694
+ testnet: false
695
+ };
652
696
 
653
697
  const BUILD_ENV = {
654
698
  PRODUCTION: "production",
@@ -1810,7 +1854,7 @@ const Codes = {
1810
1854
  ...WindowErrorName
1811
1855
  };
1812
1856
 
1813
- const AirClientUserErrors = ["USER_CANCELLED", "CONFIG_ERROR", "CLIENT_ERROR", "UNKNOWN_ERROR", "PERMISSION_NOT_ENABLED", "SMART_ACCOUNT_NOT_DEPLOYED", "ACCOUNT_DELETION_PENDING"];
1857
+ 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"];
1814
1858
 
1815
1859
  class AirError extends BaseError {}
1816
1860
  new Set(AirClientUserErrors);
@@ -2078,6 +2122,7 @@ const ALLOWED_AUTH_MESSAGES = [
2078
2122
  AirAuthMessageTypes.LOGIN_RESPONSE,
2079
2123
  AirAuthMessageTypes.SETUP_WALLET_REQUEST,
2080
2124
  AirAuthMessageTypes.SETUP_RECOVERY_REQUEST,
2125
+ AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST,
2081
2126
  AirAuthMessageTypes.LOGOUT_RESPONSE,
2082
2127
  AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
2083
2128
  AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
@@ -2157,6 +2202,15 @@ class AuthMessageService extends MessageServiceBase {
2157
2202
  },
2158
2203
  });
2159
2204
  }
2205
+ async sendSetupCredentialSuccessResponse() {
2206
+ await this.sendMessage({
2207
+ type: AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE,
2208
+ payload: { success: true },
2209
+ });
2210
+ }
2211
+ async sendSetupCredentialErrorResponse(error) {
2212
+ await this.sendMessage(this.createErrorResponseMessage(AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE, error));
2213
+ }
2160
2214
  async sendCrossPartnerTokenRequest(targetPartnerUrl) {
2161
2215
  const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE)));
2162
2216
  await this.sendMessage({
@@ -2280,6 +2334,8 @@ class IframeController {
2280
2334
  "publickey-credentials-create *",
2281
2335
  "ch-ua-model",
2282
2336
  "ch-ua-platform-version",
2337
+ "clipboard-write",
2338
+ "web-share"
2283
2339
  ].join("; ");
2284
2340
  iframe.src = this.iframeUrl;
2285
2341
  iframe.style.position = "fixed";
@@ -2390,6 +2446,8 @@ const ALLOWED_WALLET_MESSAGES = [
2390
2446
  AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE,
2391
2447
  AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE,
2392
2448
  AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE,
2449
+ AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE,
2450
+ AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE,
2393
2451
  AirWalletMessageTypes.CLAIM_ID_RESPONSE,
2394
2452
  AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE,
2395
2453
  AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE,
@@ -2514,6 +2572,26 @@ class WalletMessageService extends MessageServiceBase {
2514
2572
  });
2515
2573
  return response;
2516
2574
  }
2575
+ async sendShowTransferUIRequest(payload) {
2576
+ const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE)));
2577
+ await this.sendMessage({
2578
+ type: AirWalletMessageTypes.SHOW_TRANSFER_UI_REQUEST,
2579
+ payload: {
2580
+ tokenSymbol: payload?.tokenSymbol,
2581
+ chainId: payload?.chainId,
2582
+ recipientAddress: payload?.recipientAddress,
2583
+ amount: payload?.amount,
2584
+ },
2585
+ });
2586
+ return response;
2587
+ }
2588
+ async sendShowReceiveUIRequest() {
2589
+ const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE)));
2590
+ await this.sendMessage({
2591
+ type: AirWalletMessageTypes.SHOW_RECEIVE_UI_REQUEST,
2592
+ });
2593
+ return response;
2594
+ }
2517
2595
  }
2518
2596
  _a = WalletMessageService;
2519
2597
  _WalletMessageService_instance = { value: void 0 };
@@ -2835,6 +2913,18 @@ class AirService {
2835
2913
  }
2836
2914
  break;
2837
2915
  }
2916
+ case AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST: {
2917
+ try {
2918
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
2919
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
2920
+ await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendSetupCredentialSuccessResponse();
2921
+ }
2922
+ catch (err) {
2923
+ const error = ensureError(err);
2924
+ await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendSetupCredentialErrorResponse(error);
2925
+ }
2926
+ break;
2927
+ }
2838
2928
  case AirAuthMessageTypes.EXPIRED_LOGOUT_REQUEST: {
2839
2929
  await this.logout();
2840
2930
  break;
@@ -2896,6 +2986,10 @@ class AirService {
2896
2986
  });
2897
2987
  if (payload.success === true) {
2898
2988
  __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload), "f");
2989
+ if (payload.needsWalletRestart === true) {
2990
+ await Promise.all([__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this), __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this)]);
2991
+ void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
2992
+ }
2899
2993
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2900
2994
  return __classPrivateFieldGet(this, _AirService_loginResult, "f");
2901
2995
  }
@@ -2973,6 +3067,37 @@ class AirService {
2973
3067
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2974
3068
  }
2975
3069
  }
3070
+ /**
3071
+ * @experimental This feature has not been officially released and might change in the future.
3072
+ */
3073
+ async showTransferUI(options) {
3074
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3075
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowTransferUIRequest(options);
3076
+ if (result.payload.success === false) {
3077
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
3078
+ }
3079
+ return {
3080
+ txHash: result.payload.txHash,
3081
+ symbol: result.payload.symbol,
3082
+ chainId: result.payload.chainId,
3083
+ decimals: result.payload.decimals,
3084
+ address: result.payload.address,
3085
+ recipientAddress: result.payload.recipientAddress,
3086
+ amount: result.payload.amount
3087
+ };
3088
+ }
3089
+ /**
3090
+ * @experimental This feature has not been officially released and might change in the future.
3091
+ */
3092
+ async showReceiveUI() {
3093
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3094
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowReceiveUIRequest();
3095
+ if (result.payload.success === false) {
3096
+ if (result.payload.errorName === "USER_CANCELLED")
3097
+ return;
3098
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
3099
+ }
3100
+ }
2976
3101
  async getUserInfo() {
2977
3102
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
2978
3103
  const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
@@ -3082,7 +3207,7 @@ class AirService {
3082
3207
  async preloadCredential() {
3083
3208
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3084
3209
  }
3085
- async issueCredential({ authToken, issuerDid, credentialId, credentialSubject, curve, }) {
3210
+ async issueCredential({ authToken, issuerDid, credentialId, credentialSubject, curve, offchain, }) {
3086
3211
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3087
3212
  const response = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
3088
3213
  partnerToken: authToken,
@@ -3090,6 +3215,7 @@ class AirService {
3090
3215
  credentialId,
3091
3216
  credentialSubject,
3092
3217
  curve,
3218
+ offchain,
3093
3219
  });
3094
3220
  const { payload } = response;
3095
3221
  if (payload.closeDApp) {
@@ -3102,12 +3228,14 @@ class AirService {
3102
3228
  cakPublicKey: payload.cakPublicKey,
3103
3229
  };
3104
3230
  }
3105
- async verifyCredential({ authToken, programId, redirectUrl, }) {
3231
+ async verifyCredential({ authToken, programId, redirectUrl, requestDisclosure, offchain, }) {
3106
3232
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3107
3233
  const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendVerifyCredentialRequest({
3108
3234
  partnerToken: authToken,
3109
3235
  programId,
3110
3236
  redirectUrl,
3237
+ requestDisclosure,
3238
+ offchain,
3111
3239
  });
3112
3240
  if (payload.success === false) {
3113
3241
  throw new AirServiceError(payload.errorName, payload.errorMessage);
@@ -3249,6 +3377,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3249
3377
  const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendInitializationRequest({
3250
3378
  sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
3251
3379
  partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
3380
+ partnerDAppUrl: window.location.href,
3252
3381
  enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
3253
3382
  sdkVersion: airKitVersion,
3254
3383
  enableAutomation: this.shouldEnableAutomation(),
@@ -3426,6 +3555,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3426
3555
  const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendInitializationRequest({
3427
3556
  sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
3428
3557
  partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
3558
+ partnerDAppUrl: window.location.href,
3429
3559
  enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
3430
3560
  sdkVersion: airKitVersion,
3431
3561
  enableAutomation: this.shouldEnableAutomation(),
@@ -3499,4 +3629,5 @@ exports.UnsupportedProviderMethodError = UnsupportedProviderMethodError;
3499
3629
  exports.UserRejectedRequestError = UserRejectedRequestError;
3500
3630
  exports.ensureProviderRpcError = ensureProviderRpcError;
3501
3631
  exports.mocaDevnet = mocaDevnet;
3632
+ exports.mocaMainnet = mocaMainnet;
3502
3633
  exports.mocaTestnet = mocaTestnet;
@@ -95,7 +95,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
95
95
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
96
96
  };
97
97
 
98
- var version = "1.8.1-beta.0";
98
+ var version = "1.9.0-beta.1";
99
99
  var airkitPackage = {
100
100
  version: version};
101
101
 
@@ -123,6 +123,8 @@ const AirAuthMessageTypes = {
123
123
  SETUP_WALLET_RESPONSE: "air_auth_setup_wallet_response",
124
124
  SETUP_RECOVERY_REQUEST: "air_auth_setup_recovery_request",
125
125
  SETUP_RECOVERY_RESPONSE: "air_auth_setup_recovery_response",
126
+ SETUP_CREDENTIAL_REQUEST: "air_auth_setup_credential_request",
127
+ SETUP_CREDENTIAL_RESPONSE: "air_auth_setup_credential_response",
126
128
  SIGN_SIWE_MESSAGE_REQUEST: "air_auth_sign_siwe_message_request",
127
129
  SIGN_SIWE_MESSAGE_RESPONSE: "air_auth_sign_siwe_message_response",
128
130
  CROSS_PARTNER_TOKEN_REQUEST: "air_auth_cross_partner_token_request",
@@ -135,6 +137,8 @@ const AirAuthMessageTypes = {
135
137
  START_RECOVERY_RESPONSE: "air_start_recovery_response",
136
138
  RECOVERY_REQUEST: "air_auth_recovery_request",
137
139
  RECOVERY_RESPONSE: "air_auth_recovery_response",
140
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_auth_issue_on_behalf_new_user_confirmation_request",
141
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_auth_issue_on_behalf_new_user_confirmation_response",
138
142
  EXPIRED_LOGOUT_REQUEST: "air_auth_expired_logout_request"
139
143
  };
140
144
 
@@ -147,12 +151,16 @@ const AirCredentialMessageTypes = {
147
151
  UPDATE_SESSION_CONFIG_RESPONSE: "air_credential_update_session_config_response",
148
152
  LOGOUT_REQUEST: "air_credential_logout_request",
149
153
  LOGOUT_RESPONSE: "air_credential_logout_response",
154
+ CLOSE_MODAL_REQUEST: "air_credential_close_modal_request",
155
+ CLOSE_MODAL_RESPONSE: "air_credential_close_modal_response",
150
156
  // New credential operation message types
151
157
  ISSUE_CREDENTIAL_REQUEST: "air_credential_issue_request",
152
158
  VERIFY_CREDENTIAL_REQUEST: "air_credential_verify_request",
153
159
  // Event messages for communication with parent
154
160
  ISSUE_CREDENTIAL_RESPONSE: "air_credential_issue_response",
155
- VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response"
161
+ VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response",
162
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_credential_issue_on_behalf_new_user_confirmation_request",
163
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_credential_issue_on_behalf_new_user_confirmation_response"
156
164
  };
157
165
 
158
166
  const AirRecoveryMessageTypes = {
@@ -171,8 +179,8 @@ const AirWalletMessageTypes = {
171
179
  SERVICE_STARTED: "air_service_started",
172
180
  INITIALIZATION_REQUEST: "air_initialization_request",
173
181
  INITIALIZATION_RESPONSE: "air_initialization_response",
174
- CLOSE_MODAL_REQUEST: "air_close_modal_request",
175
- CLOSE_MODAL_RESPONSE: "air_close_modal_response",
182
+ CLOSE_MODAL_REQUEST: "air_wallet_close_modal_request",
183
+ CLOSE_MODAL_RESPONSE: "air_wallet_close_modal_response",
176
184
  WALLET_INITIALIZED: "air_wallet_initialized",
177
185
  UPDATE_SESSION_CONFIG_REQUEST: "air_wallet_update_session_config_request",
178
186
  UPDATE_SESSION_CONFIG_RESPONSE: "air_wallet_update_session_config_response",
@@ -186,6 +194,10 @@ const AirWalletMessageTypes = {
186
194
  SHOW_SWAP_UI_RESPONSE: "air_show_swap_ui_response",
187
195
  SHOW_ON_RAMP_UI_REQUEST: "air_show_on_ramp_ui_request",
188
196
  SHOW_ON_RAMP_UI_RESPONSE: "air_show_on_ramp_ui_response",
197
+ SHOW_TRANSFER_UI_REQUEST: "air_show_transfer_ui_request",
198
+ SHOW_TRANSFER_UI_RESPONSE: "air_show_transfer_ui_response",
199
+ SHOW_RECEIVE_UI_REQUEST: "air_show_receive_ui_request",
200
+ SHOW_RECEIVE_UI_RESPONSE: "air_show_receive_ui_response",
189
201
  DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
190
202
  DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
191
203
  WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
@@ -194,7 +206,11 @@ const AirWalletMessageTypes = {
194
206
  LOGOUT_REQUEST: "air_logout_request",
195
207
  LOGOUT_RESPONSE: "air_logout_response",
196
208
  INTERNAL_PROVIDER_REQUEST: "air_internal_provider_request",
197
- INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response"
209
+ INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response",
210
+ ADDITIONAL_SIGNER_SIGNATURE_REQUEST: "air_additional_signer_signature_request",
211
+ ADDITIONAL_SIGNER_SIGNATURE_RESPONSE: "air_additional_signer_signature_response",
212
+ REMOVE_SIGNER_SIGNATURE_REQUEST: "air_remove_signer_signature_request",
213
+ REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_remove_signer_signature_response"
198
214
  };
199
215
 
200
216
  const AirWindowMessageTypes = {
@@ -647,6 +663,34 @@ const mocaTestnet = {
647
663
  },
648
664
  testnet: true
649
665
  };
666
+ const mocaMainnet = {
667
+ id: 2288,
668
+ name: "Moca Mainnet",
669
+ nativeCurrency: {
670
+ decimals: 18,
671
+ name: "Moca Network",
672
+ symbol: "MOCA"
673
+ },
674
+ rpcUrls: {
675
+ default: {
676
+ http: ["https://rpc.mocachain.org"],
677
+ webSocket: ["wss://rpc.mocachain.org/ws"]
678
+ }
679
+ },
680
+ blockExplorers: {
681
+ default: {
682
+ name: "Moca Mainnet",
683
+ url: "https://scan.mocachain.org"
684
+ } // TODO: need to confirm mainnet explorer
685
+ },
686
+ contracts: {
687
+ multicall3: {
688
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
689
+ blockCreated: 3668598
690
+ }
691
+ },
692
+ testnet: false
693
+ };
650
694
 
651
695
  const BUILD_ENV = {
652
696
  PRODUCTION: "production",
@@ -1808,7 +1852,7 @@ const Codes = {
1808
1852
  ...WindowErrorName
1809
1853
  };
1810
1854
 
1811
- const AirClientUserErrors = ["USER_CANCELLED", "CONFIG_ERROR", "CLIENT_ERROR", "UNKNOWN_ERROR", "PERMISSION_NOT_ENABLED", "SMART_ACCOUNT_NOT_DEPLOYED", "ACCOUNT_DELETION_PENDING"];
1855
+ 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"];
1812
1856
 
1813
1857
  class AirError extends BaseError {}
1814
1858
  new Set(AirClientUserErrors);
@@ -2076,6 +2120,7 @@ const ALLOWED_AUTH_MESSAGES = [
2076
2120
  AirAuthMessageTypes.LOGIN_RESPONSE,
2077
2121
  AirAuthMessageTypes.SETUP_WALLET_REQUEST,
2078
2122
  AirAuthMessageTypes.SETUP_RECOVERY_REQUEST,
2123
+ AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST,
2079
2124
  AirAuthMessageTypes.LOGOUT_RESPONSE,
2080
2125
  AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
2081
2126
  AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
@@ -2155,6 +2200,15 @@ class AuthMessageService extends MessageServiceBase {
2155
2200
  },
2156
2201
  });
2157
2202
  }
2203
+ async sendSetupCredentialSuccessResponse() {
2204
+ await this.sendMessage({
2205
+ type: AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE,
2206
+ payload: { success: true },
2207
+ });
2208
+ }
2209
+ async sendSetupCredentialErrorResponse(error) {
2210
+ await this.sendMessage(this.createErrorResponseMessage(AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE, error));
2211
+ }
2158
2212
  async sendCrossPartnerTokenRequest(targetPartnerUrl) {
2159
2213
  const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE)));
2160
2214
  await this.sendMessage({
@@ -2278,6 +2332,8 @@ class IframeController {
2278
2332
  "publickey-credentials-create *",
2279
2333
  "ch-ua-model",
2280
2334
  "ch-ua-platform-version",
2335
+ "clipboard-write",
2336
+ "web-share"
2281
2337
  ].join("; ");
2282
2338
  iframe.src = this.iframeUrl;
2283
2339
  iframe.style.position = "fixed";
@@ -2388,6 +2444,8 @@ const ALLOWED_WALLET_MESSAGES = [
2388
2444
  AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE,
2389
2445
  AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE,
2390
2446
  AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE,
2447
+ AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE,
2448
+ AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE,
2391
2449
  AirWalletMessageTypes.CLAIM_ID_RESPONSE,
2392
2450
  AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE,
2393
2451
  AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE,
@@ -2512,6 +2570,26 @@ class WalletMessageService extends MessageServiceBase {
2512
2570
  });
2513
2571
  return response;
2514
2572
  }
2573
+ async sendShowTransferUIRequest(payload) {
2574
+ const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE)));
2575
+ await this.sendMessage({
2576
+ type: AirWalletMessageTypes.SHOW_TRANSFER_UI_REQUEST,
2577
+ payload: {
2578
+ tokenSymbol: payload?.tokenSymbol,
2579
+ chainId: payload?.chainId,
2580
+ recipientAddress: payload?.recipientAddress,
2581
+ amount: payload?.amount,
2582
+ },
2583
+ });
2584
+ return response;
2585
+ }
2586
+ async sendShowReceiveUIRequest() {
2587
+ const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE)));
2588
+ await this.sendMessage({
2589
+ type: AirWalletMessageTypes.SHOW_RECEIVE_UI_REQUEST,
2590
+ });
2591
+ return response;
2592
+ }
2515
2593
  }
2516
2594
  _a = WalletMessageService;
2517
2595
  _WalletMessageService_instance = { value: void 0 };
@@ -2833,6 +2911,18 @@ class AirService {
2833
2911
  }
2834
2912
  break;
2835
2913
  }
2914
+ case AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST: {
2915
+ try {
2916
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
2917
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
2918
+ await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendSetupCredentialSuccessResponse();
2919
+ }
2920
+ catch (err) {
2921
+ const error = ensureError(err);
2922
+ await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendSetupCredentialErrorResponse(error);
2923
+ }
2924
+ break;
2925
+ }
2836
2926
  case AirAuthMessageTypes.EXPIRED_LOGOUT_REQUEST: {
2837
2927
  await this.logout();
2838
2928
  break;
@@ -2894,6 +2984,10 @@ class AirService {
2894
2984
  });
2895
2985
  if (payload.success === true) {
2896
2986
  __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload), "f");
2987
+ if (payload.needsWalletRestart === true) {
2988
+ await Promise.all([__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this), __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this)]);
2989
+ void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
2990
+ }
2897
2991
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2898
2992
  return __classPrivateFieldGet(this, _AirService_loginResult, "f");
2899
2993
  }
@@ -2971,6 +3065,37 @@ class AirService {
2971
3065
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2972
3066
  }
2973
3067
  }
3068
+ /**
3069
+ * @experimental This feature has not been officially released and might change in the future.
3070
+ */
3071
+ async showTransferUI(options) {
3072
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3073
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowTransferUIRequest(options);
3074
+ if (result.payload.success === false) {
3075
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
3076
+ }
3077
+ return {
3078
+ txHash: result.payload.txHash,
3079
+ symbol: result.payload.symbol,
3080
+ chainId: result.payload.chainId,
3081
+ decimals: result.payload.decimals,
3082
+ address: result.payload.address,
3083
+ recipientAddress: result.payload.recipientAddress,
3084
+ amount: result.payload.amount
3085
+ };
3086
+ }
3087
+ /**
3088
+ * @experimental This feature has not been officially released and might change in the future.
3089
+ */
3090
+ async showReceiveUI() {
3091
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3092
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowReceiveUIRequest();
3093
+ if (result.payload.success === false) {
3094
+ if (result.payload.errorName === "USER_CANCELLED")
3095
+ return;
3096
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
3097
+ }
3098
+ }
2974
3099
  async getUserInfo() {
2975
3100
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
2976
3101
  const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
@@ -3080,7 +3205,7 @@ class AirService {
3080
3205
  async preloadCredential() {
3081
3206
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3082
3207
  }
3083
- async issueCredential({ authToken, issuerDid, credentialId, credentialSubject, curve, }) {
3208
+ async issueCredential({ authToken, issuerDid, credentialId, credentialSubject, curve, offchain, }) {
3084
3209
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3085
3210
  const response = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
3086
3211
  partnerToken: authToken,
@@ -3088,6 +3213,7 @@ class AirService {
3088
3213
  credentialId,
3089
3214
  credentialSubject,
3090
3215
  curve,
3216
+ offchain,
3091
3217
  });
3092
3218
  const { payload } = response;
3093
3219
  if (payload.closeDApp) {
@@ -3100,12 +3226,14 @@ class AirService {
3100
3226
  cakPublicKey: payload.cakPublicKey,
3101
3227
  };
3102
3228
  }
3103
- async verifyCredential({ authToken, programId, redirectUrl, }) {
3229
+ async verifyCredential({ authToken, programId, redirectUrl, requestDisclosure, offchain, }) {
3104
3230
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3105
3231
  const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendVerifyCredentialRequest({
3106
3232
  partnerToken: authToken,
3107
3233
  programId,
3108
3234
  redirectUrl,
3235
+ requestDisclosure,
3236
+ offchain,
3109
3237
  });
3110
3238
  if (payload.success === false) {
3111
3239
  throw new AirServiceError(payload.errorName, payload.errorMessage);
@@ -3247,6 +3375,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3247
3375
  const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendInitializationRequest({
3248
3376
  sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
3249
3377
  partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
3378
+ partnerDAppUrl: window.location.href,
3250
3379
  enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
3251
3380
  sdkVersion: airKitVersion,
3252
3381
  enableAutomation: this.shouldEnableAutomation(),
@@ -3424,6 +3553,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3424
3553
  const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendInitializationRequest({
3425
3554
  sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
3426
3555
  partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
3556
+ partnerDAppUrl: window.location.href,
3427
3557
  enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
3428
3558
  sdkVersion: airKitVersion,
3429
3559
  enableAutomation: this.shouldEnableAutomation(),
@@ -3479,4 +3609,4 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3479
3609
  __classPrivateFieldSet(this, _AirService_recoveryInitialization, undefined, "f");
3480
3610
  };
3481
3611
 
3482
- export { AirService, AirServiceError, BUILD_ENV, ChainDisconnectedError, IFRAME_NAME_PREFIX_SET, InternalRpcError, InvalidParamsRpcError, InvalidRequestRpcError, MethodNotFoundRpcError, ProviderDisconnectedError, ProviderRpcError, SwitchChainError, TransactionRejectedRpcError, UnauthorizedProviderError, UnsupportedProviderMethodError, UserRejectedRequestError, ensureProviderRpcError, mocaDevnet, mocaTestnet };
3612
+ export { AirService, AirServiceError, BUILD_ENV, ChainDisconnectedError, IFRAME_NAME_PREFIX_SET, InternalRpcError, InvalidParamsRpcError, InvalidRequestRpcError, MethodNotFoundRpcError, ProviderDisconnectedError, ProviderRpcError, SwitchChainError, TransactionRejectedRpcError, UnauthorizedProviderError, UnsupportedProviderMethodError, UserRejectedRequestError, ensureProviderRpcError, mocaDevnet, mocaMainnet, mocaTestnet };