@mocanetwork/airkit 1.8.1-beta.0 → 1.9.0-beta.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.
@@ -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.2";
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,12 @@ 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",
144
+ REMOVE_SIGNER_SIGNATURE_REQUEST: "air_auth_remove_signer_signature_request",
145
+ REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_auth_remove_signer_signature_response",
146
+ RESET_WALLET_REQUEST: "air_auth_reset_wallet_request",
147
+ RESET_WALLET_RESPONSE: "air_auth_reset_wallet_response",
140
148
  EXPIRED_LOGOUT_REQUEST: "air_auth_expired_logout_request"
141
149
  };
142
150
 
@@ -149,12 +157,16 @@ const AirCredentialMessageTypes = {
149
157
  UPDATE_SESSION_CONFIG_RESPONSE: "air_credential_update_session_config_response",
150
158
  LOGOUT_REQUEST: "air_credential_logout_request",
151
159
  LOGOUT_RESPONSE: "air_credential_logout_response",
160
+ CLOSE_MODAL_REQUEST: "air_credential_close_modal_request",
161
+ CLOSE_MODAL_RESPONSE: "air_credential_close_modal_response",
152
162
  // New credential operation message types
153
163
  ISSUE_CREDENTIAL_REQUEST: "air_credential_issue_request",
154
164
  VERIFY_CREDENTIAL_REQUEST: "air_credential_verify_request",
155
165
  // Event messages for communication with parent
156
166
  ISSUE_CREDENTIAL_RESPONSE: "air_credential_issue_response",
157
- VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response"
167
+ VERIFY_CREDENTIAL_RESPONSE: "air_credential_verify_response",
168
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_credential_issue_on_behalf_new_user_confirmation_request",
169
+ ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_credential_issue_on_behalf_new_user_confirmation_response"
158
170
  };
159
171
 
160
172
  const AirRecoveryMessageTypes = {
@@ -173,8 +185,8 @@ const AirWalletMessageTypes = {
173
185
  SERVICE_STARTED: "air_service_started",
174
186
  INITIALIZATION_REQUEST: "air_initialization_request",
175
187
  INITIALIZATION_RESPONSE: "air_initialization_response",
176
- CLOSE_MODAL_REQUEST: "air_close_modal_request",
177
- CLOSE_MODAL_RESPONSE: "air_close_modal_response",
188
+ CLOSE_MODAL_REQUEST: "air_wallet_close_modal_request",
189
+ CLOSE_MODAL_RESPONSE: "air_wallet_close_modal_response",
178
190
  WALLET_INITIALIZED: "air_wallet_initialized",
179
191
  UPDATE_SESSION_CONFIG_REQUEST: "air_wallet_update_session_config_request",
180
192
  UPDATE_SESSION_CONFIG_RESPONSE: "air_wallet_update_session_config_response",
@@ -188,6 +200,10 @@ const AirWalletMessageTypes = {
188
200
  SHOW_SWAP_UI_RESPONSE: "air_show_swap_ui_response",
189
201
  SHOW_ON_RAMP_UI_REQUEST: "air_show_on_ramp_ui_request",
190
202
  SHOW_ON_RAMP_UI_RESPONSE: "air_show_on_ramp_ui_response",
203
+ SHOW_TRANSFER_UI_REQUEST: "air_show_transfer_ui_request",
204
+ SHOW_TRANSFER_UI_RESPONSE: "air_show_transfer_ui_response",
205
+ SHOW_RECEIVE_UI_REQUEST: "air_show_receive_ui_request",
206
+ SHOW_RECEIVE_UI_RESPONSE: "air_show_receive_ui_response",
191
207
  DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
192
208
  DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
193
209
  WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
@@ -196,7 +212,11 @@ const AirWalletMessageTypes = {
196
212
  LOGOUT_REQUEST: "air_logout_request",
197
213
  LOGOUT_RESPONSE: "air_logout_response",
198
214
  INTERNAL_PROVIDER_REQUEST: "air_internal_provider_request",
199
- INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response"
215
+ INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response",
216
+ ADDITIONAL_SIGNER_SIGNATURE_REQUEST: "air_additional_signer_signature_request",
217
+ ADDITIONAL_SIGNER_SIGNATURE_RESPONSE: "air_additional_signer_signature_response",
218
+ REMOVE_SIGNER_SIGNATURE_REQUEST: "air_remove_signer_signature_request",
219
+ REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_remove_signer_signature_response"
200
220
  };
201
221
 
202
222
  const AirWindowMessageTypes = {
@@ -632,7 +652,7 @@ const mocaTestnet = {
632
652
  rpcUrls: {
633
653
  default: {
634
654
  http: ["https://rpc.testnet.mocachain.dev"],
635
- webSocket: ["wss://rpc.testnet.mocachain.dev"]
655
+ webSocket: ["wss://ws.testnet.mocachain.dev"]
636
656
  }
637
657
  },
638
658
  blockExplorers: {
@@ -649,6 +669,34 @@ const mocaTestnet = {
649
669
  },
650
670
  testnet: true
651
671
  };
672
+ const mocaMainnet = {
673
+ id: 2288,
674
+ name: "Moca Mainnet",
675
+ nativeCurrency: {
676
+ decimals: 18,
677
+ name: "Moca Network",
678
+ symbol: "MOCA"
679
+ },
680
+ rpcUrls: {
681
+ default: {
682
+ http: ["https://rpc.mocachain.org"],
683
+ webSocket: ["wss://rpc.mocachain.org/ws"]
684
+ }
685
+ },
686
+ blockExplorers: {
687
+ default: {
688
+ name: "Moca Mainnet",
689
+ url: "https://scan.mocachain.org"
690
+ } // TODO: need to confirm mainnet explorer
691
+ },
692
+ contracts: {
693
+ multicall3: {
694
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
695
+ blockCreated: 3668598
696
+ }
697
+ },
698
+ testnet: false
699
+ };
652
700
 
653
701
  const BUILD_ENV = {
654
702
  PRODUCTION: "production",
@@ -1810,7 +1858,7 @@ const Codes = {
1810
1858
  ...WindowErrorName
1811
1859
  };
1812
1860
 
1813
- const AirClientUserErrors = ["USER_CANCELLED", "CONFIG_ERROR", "CLIENT_ERROR", "UNKNOWN_ERROR", "PERMISSION_NOT_ENABLED", "SMART_ACCOUNT_NOT_DEPLOYED", "ACCOUNT_DELETION_PENDING"];
1861
+ 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
1862
 
1815
1863
  class AirError extends BaseError {}
1816
1864
  new Set(AirClientUserErrors);
@@ -1953,7 +2001,7 @@ class ProviderMessageService extends MessageServiceBase {
1953
2001
  await super._open({ window, origin });
1954
2002
  }
1955
2003
  async sendWalletProviderRequest(payload) {
1956
- const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletProviderMessageTypes.RESPONSE), filter((msg) => msg.payload.method === payload.method)));
2004
+ const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletProviderMessageTypes.RESPONSE), filter((msg) => msg.payload.method === payload.method && msg.payload.requestId === payload.requestId)));
1957
2005
  await this.sendMessage({
1958
2006
  type: AirWalletProviderMessageTypes.REQUEST,
1959
2007
  payload,
@@ -2078,6 +2126,7 @@ const ALLOWED_AUTH_MESSAGES = [
2078
2126
  AirAuthMessageTypes.LOGIN_RESPONSE,
2079
2127
  AirAuthMessageTypes.SETUP_WALLET_REQUEST,
2080
2128
  AirAuthMessageTypes.SETUP_RECOVERY_REQUEST,
2129
+ AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST,
2081
2130
  AirAuthMessageTypes.LOGOUT_RESPONSE,
2082
2131
  AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
2083
2132
  AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
@@ -2157,6 +2206,15 @@ class AuthMessageService extends MessageServiceBase {
2157
2206
  },
2158
2207
  });
2159
2208
  }
2209
+ async sendSetupCredentialSuccessResponse() {
2210
+ await this.sendMessage({
2211
+ type: AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE,
2212
+ payload: { success: true },
2213
+ });
2214
+ }
2215
+ async sendSetupCredentialErrorResponse(error) {
2216
+ await this.sendMessage(this.createErrorResponseMessage(AirAuthMessageTypes.SETUP_CREDENTIAL_RESPONSE, error));
2217
+ }
2160
2218
  async sendCrossPartnerTokenRequest(targetPartnerUrl) {
2161
2219
  const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE)));
2162
2220
  await this.sendMessage({
@@ -2280,6 +2338,8 @@ class IframeController {
2280
2338
  "publickey-credentials-create *",
2281
2339
  "ch-ua-model",
2282
2340
  "ch-ua-platform-version",
2341
+ "clipboard-write",
2342
+ "web-share"
2283
2343
  ].join("; ");
2284
2344
  iframe.src = this.iframeUrl;
2285
2345
  iframe.style.position = "fixed";
@@ -2390,6 +2450,8 @@ const ALLOWED_WALLET_MESSAGES = [
2390
2450
  AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE,
2391
2451
  AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE,
2392
2452
  AirWalletMessageTypes.SHOW_ON_RAMP_UI_RESPONSE,
2453
+ AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE,
2454
+ AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE,
2393
2455
  AirWalletMessageTypes.CLAIM_ID_RESPONSE,
2394
2456
  AirWalletMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE,
2395
2457
  AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE,
@@ -2514,6 +2576,26 @@ class WalletMessageService extends MessageServiceBase {
2514
2576
  });
2515
2577
  return response;
2516
2578
  }
2579
+ async sendShowTransferUIRequest(payload) {
2580
+ const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_TRANSFER_UI_RESPONSE)));
2581
+ await this.sendMessage({
2582
+ type: AirWalletMessageTypes.SHOW_TRANSFER_UI_REQUEST,
2583
+ payload: {
2584
+ tokenSymbol: payload?.tokenSymbol,
2585
+ chainId: payload?.chainId,
2586
+ recipientAddress: payload?.recipientAddress,
2587
+ amount: payload?.amount,
2588
+ },
2589
+ });
2590
+ return response;
2591
+ }
2592
+ async sendShowReceiveUIRequest() {
2593
+ const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_RECEIVE_UI_RESPONSE)));
2594
+ await this.sendMessage({
2595
+ type: AirWalletMessageTypes.SHOW_RECEIVE_UI_REQUEST,
2596
+ });
2597
+ return response;
2598
+ }
2517
2599
  }
2518
2600
  _a = WalletMessageService;
2519
2601
  _WalletMessageService_instance = { value: void 0 };
@@ -2835,6 +2917,17 @@ class AirService {
2835
2917
  }
2836
2918
  break;
2837
2919
  }
2920
+ case AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST: {
2921
+ try {
2922
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
2923
+ await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendSetupCredentialSuccessResponse();
2924
+ }
2925
+ catch (err) {
2926
+ const error = ensureError(err);
2927
+ await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendSetupCredentialErrorResponse(error);
2928
+ }
2929
+ break;
2930
+ }
2838
2931
  case AirAuthMessageTypes.EXPIRED_LOGOUT_REQUEST: {
2839
2932
  await this.logout();
2840
2933
  break;
@@ -2973,6 +3066,37 @@ class AirService {
2973
3066
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2974
3067
  }
2975
3068
  }
3069
+ /**
3070
+ * @experimental This feature has not been officially released and might change in the future.
3071
+ */
3072
+ async showTransferUI(options) {
3073
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3074
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowTransferUIRequest(options);
3075
+ if (result.payload.success === false) {
3076
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
3077
+ }
3078
+ return {
3079
+ txHash: result.payload.txHash,
3080
+ symbol: result.payload.symbol,
3081
+ chainId: result.payload.chainId,
3082
+ decimals: result.payload.decimals,
3083
+ address: result.payload.address,
3084
+ recipientAddress: result.payload.recipientAddress,
3085
+ amount: result.payload.amount,
3086
+ };
3087
+ }
3088
+ /**
3089
+ * @experimental This feature has not been officially released and might change in the future.
3090
+ */
3091
+ async showReceiveUI() {
3092
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3093
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowReceiveUIRequest();
3094
+ if (result.payload.success === false) {
3095
+ if (result.payload.errorName === "USER_CANCELLED")
3096
+ return;
3097
+ throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
3098
+ }
3099
+ }
2976
3100
  async getUserInfo() {
2977
3101
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
2978
3102
  const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
@@ -2987,7 +3111,7 @@ class AirService {
2987
3111
  id: info.payload.user.id,
2988
3112
  abstractAccountAddress: info.payload.user.abstractAccountAddress,
2989
3113
  email: info.payload.user.email,
2990
- isMFASetup: info.payload.user.isMFASetup,
3114
+ isMFASetup: info.payload.user.activeMfaMethods.length > 0,
2991
3115
  },
2992
3116
  };
2993
3117
  }
@@ -3082,7 +3206,7 @@ class AirService {
3082
3206
  async preloadCredential() {
3083
3207
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3084
3208
  }
3085
- async issueCredential({ authToken, issuerDid, credentialId, credentialSubject, curve, }) {
3209
+ async issueCredential({ authToken, issuerDid, credentialId, credentialSubject, curve, offchain, }) {
3086
3210
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3087
3211
  const response = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
3088
3212
  partnerToken: authToken,
@@ -3090,6 +3214,7 @@ class AirService {
3090
3214
  credentialId,
3091
3215
  credentialSubject,
3092
3216
  curve,
3217
+ offchain,
3093
3218
  });
3094
3219
  const { payload } = response;
3095
3220
  if (payload.closeDApp) {
@@ -3102,12 +3227,17 @@ class AirService {
3102
3227
  cakPublicKey: payload.cakPublicKey,
3103
3228
  };
3104
3229
  }
3105
- async verifyCredential({ authToken, programId, redirectUrl, }) {
3230
+ async verifyCredential({ authToken, programId, redirectUrl, fieldsToDisclose, offchain, }) {
3231
+ if (Array.isArray(fieldsToDisclose) && fieldsToDisclose.length === 0) {
3232
+ throw new AirServiceError("CLIENT_ERROR", "fieldsToDisclose array must contain at least one field");
3233
+ }
3106
3234
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3107
3235
  const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendVerifyCredentialRequest({
3108
3236
  partnerToken: authToken,
3109
3237
  programId,
3110
3238
  redirectUrl,
3239
+ fieldsToDisclose,
3240
+ offchain,
3111
3241
  });
3112
3242
  if (payload.success === false) {
3113
3243
  throw new AirServiceError(payload.errorName, payload.errorMessage);
@@ -3124,7 +3254,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3124
3254
  throw new AirServiceError("NOT_LOGGED_IN", "User not logged in");
3125
3255
  }, _AirService_ensureCredential = async function _AirService_ensureCredential() {
3126
3256
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
3127
- void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3257
+ void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
3128
3258
  try {
3129
3259
  if (!__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f"))
3130
3260
  __classPrivateFieldSet(this, _AirService_credentialsInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeCredentials).call(this), "f");
@@ -3249,6 +3379,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3249
3379
  const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendInitializationRequest({
3250
3380
  sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
3251
3381
  partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
3382
+ partnerDAppUrl: window.location.href,
3252
3383
  enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
3253
3384
  sdkVersion: airKitVersion,
3254
3385
  enableAutomation: this.shouldEnableAutomation(),
@@ -3359,7 +3490,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3359
3490
  id: payload.id,
3360
3491
  abstractAccountAddress: payload.abstractAccountAddress,
3361
3492
  token: payload.partnerAccessToken,
3362
- isMFASetup: payload.isMFASetup,
3493
+ isMFASetup: payload.activeMfaMethods.length > 0,
3363
3494
  };
3364
3495
  }, _AirService_createWalletInitializedResult = function _AirService_createWalletInitializedResult(payload) {
3365
3496
  if ("isWalletLoggedIn" in payload && !payload.isWalletLoggedIn) {
@@ -3370,7 +3501,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3370
3501
  }
3371
3502
  return {
3372
3503
  abstractAccountAddress: payload.addresses.aa,
3373
- isMFASetup: payload.isMFASetup,
3504
+ isMFASetup: payload.activeMfaMethods.length > 0,
3374
3505
  };
3375
3506
  }, _AirService_cleanUpAuth = async function _AirService_cleanUpAuth() {
3376
3507
  // Logout auth session
@@ -3426,6 +3557,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3426
3557
  const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendInitializationRequest({
3427
3558
  sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
3428
3559
  partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
3560
+ partnerDAppUrl: window.location.href,
3429
3561
  enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
3430
3562
  sdkVersion: airKitVersion,
3431
3563
  enableAutomation: this.shouldEnableAutomation(),
@@ -3499,4 +3631,5 @@ exports.UnsupportedProviderMethodError = UnsupportedProviderMethodError;
3499
3631
  exports.UserRejectedRequestError = UserRejectedRequestError;
3500
3632
  exports.ensureProviderRpcError = ensureProviderRpcError;
3501
3633
  exports.mocaDevnet = mocaDevnet;
3634
+ exports.mocaMainnet = mocaMainnet;
3502
3635
  exports.mocaTestnet = mocaTestnet;