@mocanetwork/airkit 1.6.0 → 1.7.0

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.6.0";
100
+ var version = "1.7.0";
101
101
  var airkitPackage = {
102
102
  version: version};
103
103
 
@@ -107,6 +107,8 @@ const AirAuthMessageTypes = {
107
107
  INITIALIZATION_RESPONSE: "air_auth_initialization_response",
108
108
  LOGIN_REQUEST: "air_auth_login_request",
109
109
  LOGIN_RESPONSE: "air_auth_login_response",
110
+ LOGIN_SERVICE_STATUS_REQUEST: "air_auth_login_service_status_request",
111
+ LOGIN_SERVICE_STATUS_RESPONSE: "air_auth_login_service_status_response",
110
112
  LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
111
113
  UPDATE_SESSION_CONFIG_REQUEST: "air_auth_update_session_config_request",
112
114
  UPDATE_SESSION_CONFIG_RESPONSE: "air_auth_update_session_config_response",
@@ -591,6 +593,61 @@ const configureLogLevel = (environment, enableLogging) => {
591
593
  log.info(`[${window?.location?.href}] LogLevel: ${getLevelName(log.getLevel())}`);
592
594
  };
593
595
 
596
+ const mocaDevnet = {
597
+ id: 5151,
598
+ name: "Moca Devnet",
599
+ nativeCurrency: {
600
+ decimals: 18,
601
+ name: "Moca Network",
602
+ symbol: "MOCA"
603
+ },
604
+ rpcUrls: {
605
+ default: {
606
+ http: ["https://devnet-rpc.mocachain.org"],
607
+ webSocket: ["wss://devnet-rpc.mocachain.org"]
608
+ }
609
+ },
610
+ blockExplorers: {
611
+ default: {
612
+ name: "Moca Devnet",
613
+ url: "https://devnet-scan.mocachain.org"
614
+ }
615
+ },
616
+ contracts: {
617
+ multicall3: {
618
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
619
+ blockCreated: 3837540
620
+ }
621
+ }
622
+ };
623
+ const mocaTestnet = {
624
+ id: 222888,
625
+ name: "Moca Testnet",
626
+ nativeCurrency: {
627
+ decimals: 18,
628
+ name: "Moca Network",
629
+ symbol: "MOCA"
630
+ },
631
+ rpcUrls: {
632
+ default: {
633
+ http: ["https://testnet-rpc.mocachain.org"],
634
+ webSocket: ["wss://testnet-rpc.mocachain.org"]
635
+ }
636
+ },
637
+ blockExplorers: {
638
+ default: {
639
+ name: "Moca Testnet",
640
+ url: "https://testnet-scan.mocachain.org"
641
+ }
642
+ },
643
+ contracts: {
644
+ multicall3: {
645
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
646
+ blockCreated: 1330259
647
+ }
648
+ }
649
+ };
650
+
594
651
  const BUILD_ENV = {
595
652
  PRODUCTION: "production",
596
653
  UAT: "uat",
@@ -605,12 +662,13 @@ const IFRAME_NAME_PREFIX_SET = [
605
662
  "air-recovery",
606
663
  ]; // order defines the z-index from highest to lowest
607
664
 
665
+ const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
608
666
  const AIR_URLS = {
609
667
  [BUILD_ENV.DEVELOPMENT]: {
610
- authUrl: "http://localhost:8200/auth/",
611
- walletUrl: "http://localhost:8200/wallet/",
612
- recoveryUrl: "http://localhost:8200/recovery/",
613
- credentialUrl: "http://localhost:8200/credential/",
668
+ authUrl: "https://localhost:8200/auth/",
669
+ walletUrl: "https://localhost:8200/wallet/",
670
+ recoveryUrl: "https://localhost:8200/recovery/",
671
+ credentialUrl: "https://localhost:8200/credential/",
614
672
  },
615
673
  [BUILD_ENV.STAGING]: {
616
674
  authUrl: "https://account.staging.air3.com/auth/",
@@ -637,6 +695,47 @@ const AIR_URLS = {
637
695
  credentialUrl: "https://account.air3.com/credential/",
638
696
  },
639
697
  };
698
+ /**
699
+ * Injects dns-prefetch, preconnect, and prefetch link tags
700
+ * for a given resource or page URL.
701
+ *
702
+ * @param url - Full resource URL (e.g. "https://cdn.example.com/app.js")
703
+ * @param options - Optional configuration
704
+ * prefetch?: boolean — disable if you only want connection warm-up
705
+ * as?: string — specify resource type for prefetch ("document", "script", "style", "font", etc.)
706
+ */
707
+ const addResourceHints = (url, options) => {
708
+ try {
709
+ const parsed = new URL(url, window.location.href);
710
+ const isCrossOrigin = parsed.origin !== window.location.origin;
711
+ const head = document.head;
712
+ const addLink = (rel, href, as, crossOrigin) => {
713
+ // Skip if a matching link already exists
714
+ if (head.querySelector(`link[rel="${rel}"][href="${href}"]`))
715
+ return;
716
+ const link = document.createElement("link");
717
+ link.rel = rel;
718
+ link.href = href;
719
+ if (as)
720
+ link.as = as;
721
+ if (crossOrigin)
722
+ link.crossOrigin = "anonymous";
723
+ head.appendChild(link);
724
+ };
725
+ const hostname = parsed.hostname;
726
+ // DNS Prefetch (scheme-less, safe for any protocol)
727
+ addLink("dns-prefetch", `//${hostname}`);
728
+ // Preconnect (TCP + TLS warm-up)
729
+ addLink("preconnect", parsed.origin, undefined, isCrossOrigin);
730
+ // Prefetch (optional — caches the resource or HTML document)
731
+ if (options?.prefetch !== false) {
732
+ addLink("prefetch", parsed.href, options?.as ?? "document", isCrossOrigin);
733
+ }
734
+ }
735
+ catch (err) {
736
+ log.warn("[addResourceHints] Invalid URL:", url, err);
737
+ }
738
+ };
640
739
  const isElement = (element) => element instanceof Element || element instanceof Document;
641
740
  const randomId = () => Math.random().toString(36).slice(2);
642
741
  const extractErrorHash = (message) => {
@@ -2147,6 +2246,17 @@ class IframeController {
2147
2246
  iframe.style.padding = "0";
2148
2247
  iframe.style.display = "none";
2149
2248
  iframe.style.colorScheme = "auto";
2249
+ iframe.setAttribute("sandbox", [
2250
+ "allow-scripts",
2251
+ "allow-same-origin",
2252
+ "allow-storage-access-by-user-activation",
2253
+ "allow-modals",
2254
+ "allow-popups",
2255
+ "allow-popups-to-escape-sandbox", // for google login
2256
+ "allow-forms", // for google login
2257
+ "allow-downloads", // for recovery export
2258
+ "allow-top-navigation-by-user-activation",
2259
+ ].join(" "));
2150
2260
  document.body.appendChild(iframe);
2151
2261
  this._iframeElement = iframe;
2152
2262
  return iframe;
@@ -2340,10 +2450,11 @@ class WalletMessageService extends MessageServiceBase {
2340
2450
  await this.sendMessage({ type: AirWalletMessageTypes.CLAIM_ID_REQUEST, payload });
2341
2451
  return response;
2342
2452
  }
2343
- async sendShowSwapUIRequest() {
2453
+ async sendShowSwapUIRequest(payload) {
2344
2454
  const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE)));
2345
2455
  await this.sendMessage({
2346
2456
  type: AirWalletMessageTypes.SHOW_SWAP_UI_REQUEST,
2457
+ payload
2347
2458
  });
2348
2459
  return response;
2349
2460
  }
@@ -2591,7 +2702,7 @@ class AirService {
2591
2702
  ensureWallet: __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).bind(this),
2592
2703
  getLoginResult: () => __classPrivateFieldGet(this, _AirService_loginResult, "f"),
2593
2704
  }), "f");
2594
- // this.#modalZIndex = modalZIndex ?? 99999;
2705
+ FONT_CDNS.forEach((cdn) => addResourceHints(cdn, { prefetch: false }));
2595
2706
  }
2596
2707
  get buildEnv() {
2597
2708
  return __classPrivateFieldGet(this, _AirService_buildEnv, "f");
@@ -2619,16 +2730,23 @@ class AirService {
2619
2730
  shouldEnableAutomation() {
2620
2731
  return localStorage.getItem("automation") === "true" && __classPrivateFieldGet(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
2621
2732
  }
2622
- async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, }) {
2733
+ async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, preloadWallet = false, preloadCredential = false, }) {
2623
2734
  if (!__classPrivateFieldGet(this, _AirService_partnerId, "f"))
2624
2735
  throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2625
2736
  if (__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
2626
2737
  return __classPrivateFieldGet(this, _AirService_loginResult, "f") ?? null;
2738
+ configureLogLevel(buildEnv, enableLogging);
2739
+ const { authUrl, walletUrl, credentialUrl } = AIR_URLS[buildEnv];
2740
+ addResourceHints(authUrl);
2741
+ if (preloadWallet) {
2742
+ addResourceHints(walletUrl);
2743
+ }
2744
+ if (preloadCredential) {
2745
+ addResourceHints(credentialUrl);
2746
+ }
2627
2747
  __classPrivateFieldSet(this, _AirService_buildEnv, buildEnv, "f");
2628
2748
  __classPrivateFieldSet(this, _AirService_enableLogging, enableLogging, "f");
2629
2749
  __classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
2630
- const { authUrl } = AIR_URLS[buildEnv];
2631
- configureLogLevel(buildEnv, enableLogging);
2632
2750
  __classPrivateFieldSet(this, _AirService_sessionId, randomId(), "f");
2633
2751
  const authIframeOrigin = new URL(authUrl).origin;
2634
2752
  __classPrivateFieldSet(this, _AirService_authIframeController, new IframeController("air-auth", authUrl), "f");
@@ -2700,8 +2818,10 @@ class AirService {
2700
2818
  });
2701
2819
  __classPrivateFieldSet(this, _AirService_isAuthInitialized, true, "f");
2702
2820
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthInitialized).call(this, { rehydrated: result.rehydrated });
2703
- if (result.preloadWallet)
2821
+ if (result.preloadWallet || preloadWallet)
2704
2822
  void this.preloadWallet();
2823
+ if (preloadCredential)
2824
+ void this.preloadCredential();
2705
2825
  // rehydrated auth session
2706
2826
  if (result.rehydrated) {
2707
2827
  __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
@@ -2784,9 +2904,9 @@ class AirService {
2784
2904
  /**
2785
2905
  * @experimental This feature has not been officially released and might change in the future.
2786
2906
  */
2787
- async showSwapUI() {
2907
+ async showSwapUI(options) {
2788
2908
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
2789
- const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest();
2909
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest(options);
2790
2910
  if (result.payload.success === false) {
2791
2911
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2792
2912
  }
@@ -2996,7 +3116,8 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
2996
3116
  await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").open(__classPrivateFieldGet(this, _AirService_credentialIframeController, "f").iframeElement);
2997
3117
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_subscribeToCredentialEvents).call(this);
2998
3118
  await credentialInitRequestPromise;
2999
- await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3119
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
3120
+ void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this); // this call triggers wallet login for later usage
3000
3121
  log.info("Credential service initialized successfully");
3001
3122
  }
3002
3123
  catch (error) {
@@ -3317,3 +3438,5 @@ exports.UnauthorizedProviderError = UnauthorizedProviderError;
3317
3438
  exports.UnsupportedProviderMethodError = UnsupportedProviderMethodError;
3318
3439
  exports.UserRejectedRequestError = UserRejectedRequestError;
3319
3440
  exports.ensureProviderRpcError = ensureProviderRpcError;
3441
+ exports.mocaDevnet = mocaDevnet;
3442
+ 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.6.0";
98
+ var version = "1.7.0";
99
99
  var airkitPackage = {
100
100
  version: version};
101
101
 
@@ -105,6 +105,8 @@ const AirAuthMessageTypes = {
105
105
  INITIALIZATION_RESPONSE: "air_auth_initialization_response",
106
106
  LOGIN_REQUEST: "air_auth_login_request",
107
107
  LOGIN_RESPONSE: "air_auth_login_response",
108
+ LOGIN_SERVICE_STATUS_REQUEST: "air_auth_login_service_status_request",
109
+ LOGIN_SERVICE_STATUS_RESPONSE: "air_auth_login_service_status_response",
108
110
  LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
109
111
  UPDATE_SESSION_CONFIG_REQUEST: "air_auth_update_session_config_request",
110
112
  UPDATE_SESSION_CONFIG_RESPONSE: "air_auth_update_session_config_response",
@@ -589,6 +591,61 @@ const configureLogLevel = (environment, enableLogging) => {
589
591
  log.info(`[${window?.location?.href}] LogLevel: ${getLevelName(log.getLevel())}`);
590
592
  };
591
593
 
594
+ const mocaDevnet = {
595
+ id: 5151,
596
+ name: "Moca Devnet",
597
+ nativeCurrency: {
598
+ decimals: 18,
599
+ name: "Moca Network",
600
+ symbol: "MOCA"
601
+ },
602
+ rpcUrls: {
603
+ default: {
604
+ http: ["https://devnet-rpc.mocachain.org"],
605
+ webSocket: ["wss://devnet-rpc.mocachain.org"]
606
+ }
607
+ },
608
+ blockExplorers: {
609
+ default: {
610
+ name: "Moca Devnet",
611
+ url: "https://devnet-scan.mocachain.org"
612
+ }
613
+ },
614
+ contracts: {
615
+ multicall3: {
616
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
617
+ blockCreated: 3837540
618
+ }
619
+ }
620
+ };
621
+ const mocaTestnet = {
622
+ id: 222888,
623
+ name: "Moca Testnet",
624
+ nativeCurrency: {
625
+ decimals: 18,
626
+ name: "Moca Network",
627
+ symbol: "MOCA"
628
+ },
629
+ rpcUrls: {
630
+ default: {
631
+ http: ["https://testnet-rpc.mocachain.org"],
632
+ webSocket: ["wss://testnet-rpc.mocachain.org"]
633
+ }
634
+ },
635
+ blockExplorers: {
636
+ default: {
637
+ name: "Moca Testnet",
638
+ url: "https://testnet-scan.mocachain.org"
639
+ }
640
+ },
641
+ contracts: {
642
+ multicall3: {
643
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
644
+ blockCreated: 1330259
645
+ }
646
+ }
647
+ };
648
+
592
649
  const BUILD_ENV = {
593
650
  PRODUCTION: "production",
594
651
  UAT: "uat",
@@ -603,12 +660,13 @@ const IFRAME_NAME_PREFIX_SET = [
603
660
  "air-recovery",
604
661
  ]; // order defines the z-index from highest to lowest
605
662
 
663
+ const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
606
664
  const AIR_URLS = {
607
665
  [BUILD_ENV.DEVELOPMENT]: {
608
- authUrl: "http://localhost:8200/auth/",
609
- walletUrl: "http://localhost:8200/wallet/",
610
- recoveryUrl: "http://localhost:8200/recovery/",
611
- credentialUrl: "http://localhost:8200/credential/",
666
+ authUrl: "https://localhost:8200/auth/",
667
+ walletUrl: "https://localhost:8200/wallet/",
668
+ recoveryUrl: "https://localhost:8200/recovery/",
669
+ credentialUrl: "https://localhost:8200/credential/",
612
670
  },
613
671
  [BUILD_ENV.STAGING]: {
614
672
  authUrl: "https://account.staging.air3.com/auth/",
@@ -635,6 +693,47 @@ const AIR_URLS = {
635
693
  credentialUrl: "https://account.air3.com/credential/",
636
694
  },
637
695
  };
696
+ /**
697
+ * Injects dns-prefetch, preconnect, and prefetch link tags
698
+ * for a given resource or page URL.
699
+ *
700
+ * @param url - Full resource URL (e.g. "https://cdn.example.com/app.js")
701
+ * @param options - Optional configuration
702
+ * prefetch?: boolean — disable if you only want connection warm-up
703
+ * as?: string — specify resource type for prefetch ("document", "script", "style", "font", etc.)
704
+ */
705
+ const addResourceHints = (url, options) => {
706
+ try {
707
+ const parsed = new URL(url, window.location.href);
708
+ const isCrossOrigin = parsed.origin !== window.location.origin;
709
+ const head = document.head;
710
+ const addLink = (rel, href, as, crossOrigin) => {
711
+ // Skip if a matching link already exists
712
+ if (head.querySelector(`link[rel="${rel}"][href="${href}"]`))
713
+ return;
714
+ const link = document.createElement("link");
715
+ link.rel = rel;
716
+ link.href = href;
717
+ if (as)
718
+ link.as = as;
719
+ if (crossOrigin)
720
+ link.crossOrigin = "anonymous";
721
+ head.appendChild(link);
722
+ };
723
+ const hostname = parsed.hostname;
724
+ // DNS Prefetch (scheme-less, safe for any protocol)
725
+ addLink("dns-prefetch", `//${hostname}`);
726
+ // Preconnect (TCP + TLS warm-up)
727
+ addLink("preconnect", parsed.origin, undefined, isCrossOrigin);
728
+ // Prefetch (optional — caches the resource or HTML document)
729
+ if (options?.prefetch !== false) {
730
+ addLink("prefetch", parsed.href, options?.as ?? "document", isCrossOrigin);
731
+ }
732
+ }
733
+ catch (err) {
734
+ log.warn("[addResourceHints] Invalid URL:", url, err);
735
+ }
736
+ };
638
737
  const isElement = (element) => element instanceof Element || element instanceof Document;
639
738
  const randomId = () => Math.random().toString(36).slice(2);
640
739
  const extractErrorHash = (message) => {
@@ -2145,6 +2244,17 @@ class IframeController {
2145
2244
  iframe.style.padding = "0";
2146
2245
  iframe.style.display = "none";
2147
2246
  iframe.style.colorScheme = "auto";
2247
+ iframe.setAttribute("sandbox", [
2248
+ "allow-scripts",
2249
+ "allow-same-origin",
2250
+ "allow-storage-access-by-user-activation",
2251
+ "allow-modals",
2252
+ "allow-popups",
2253
+ "allow-popups-to-escape-sandbox", // for google login
2254
+ "allow-forms", // for google login
2255
+ "allow-downloads", // for recovery export
2256
+ "allow-top-navigation-by-user-activation",
2257
+ ].join(" "));
2148
2258
  document.body.appendChild(iframe);
2149
2259
  this._iframeElement = iframe;
2150
2260
  return iframe;
@@ -2338,10 +2448,11 @@ class WalletMessageService extends MessageServiceBase {
2338
2448
  await this.sendMessage({ type: AirWalletMessageTypes.CLAIM_ID_REQUEST, payload });
2339
2449
  return response;
2340
2450
  }
2341
- async sendShowSwapUIRequest() {
2451
+ async sendShowSwapUIRequest(payload) {
2342
2452
  const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE)));
2343
2453
  await this.sendMessage({
2344
2454
  type: AirWalletMessageTypes.SHOW_SWAP_UI_REQUEST,
2455
+ payload
2345
2456
  });
2346
2457
  return response;
2347
2458
  }
@@ -2589,7 +2700,7 @@ class AirService {
2589
2700
  ensureWallet: __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).bind(this),
2590
2701
  getLoginResult: () => __classPrivateFieldGet(this, _AirService_loginResult, "f"),
2591
2702
  }), "f");
2592
- // this.#modalZIndex = modalZIndex ?? 99999;
2703
+ FONT_CDNS.forEach((cdn) => addResourceHints(cdn, { prefetch: false }));
2593
2704
  }
2594
2705
  get buildEnv() {
2595
2706
  return __classPrivateFieldGet(this, _AirService_buildEnv, "f");
@@ -2617,16 +2728,23 @@ class AirService {
2617
2728
  shouldEnableAutomation() {
2618
2729
  return localStorage.getItem("automation") === "true" && __classPrivateFieldGet(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
2619
2730
  }
2620
- async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, }) {
2731
+ async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, preloadWallet = false, preloadCredential = false, }) {
2621
2732
  if (!__classPrivateFieldGet(this, _AirService_partnerId, "f"))
2622
2733
  throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2623
2734
  if (__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
2624
2735
  return __classPrivateFieldGet(this, _AirService_loginResult, "f") ?? null;
2736
+ configureLogLevel(buildEnv, enableLogging);
2737
+ const { authUrl, walletUrl, credentialUrl } = AIR_URLS[buildEnv];
2738
+ addResourceHints(authUrl);
2739
+ if (preloadWallet) {
2740
+ addResourceHints(walletUrl);
2741
+ }
2742
+ if (preloadCredential) {
2743
+ addResourceHints(credentialUrl);
2744
+ }
2625
2745
  __classPrivateFieldSet(this, _AirService_buildEnv, buildEnv, "f");
2626
2746
  __classPrivateFieldSet(this, _AirService_enableLogging, enableLogging, "f");
2627
2747
  __classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
2628
- const { authUrl } = AIR_URLS[buildEnv];
2629
- configureLogLevel(buildEnv, enableLogging);
2630
2748
  __classPrivateFieldSet(this, _AirService_sessionId, randomId(), "f");
2631
2749
  const authIframeOrigin = new URL(authUrl).origin;
2632
2750
  __classPrivateFieldSet(this, _AirService_authIframeController, new IframeController("air-auth", authUrl), "f");
@@ -2698,8 +2816,10 @@ class AirService {
2698
2816
  });
2699
2817
  __classPrivateFieldSet(this, _AirService_isAuthInitialized, true, "f");
2700
2818
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthInitialized).call(this, { rehydrated: result.rehydrated });
2701
- if (result.preloadWallet)
2819
+ if (result.preloadWallet || preloadWallet)
2702
2820
  void this.preloadWallet();
2821
+ if (preloadCredential)
2822
+ void this.preloadCredential();
2703
2823
  // rehydrated auth session
2704
2824
  if (result.rehydrated) {
2705
2825
  __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
@@ -2782,9 +2902,9 @@ class AirService {
2782
2902
  /**
2783
2903
  * @experimental This feature has not been officially released and might change in the future.
2784
2904
  */
2785
- async showSwapUI() {
2905
+ async showSwapUI(options) {
2786
2906
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
2787
- const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest();
2907
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest(options);
2788
2908
  if (result.payload.success === false) {
2789
2909
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2790
2910
  }
@@ -2994,7 +3114,8 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
2994
3114
  await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").open(__classPrivateFieldGet(this, _AirService_credentialIframeController, "f").iframeElement);
2995
3115
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_subscribeToCredentialEvents).call(this);
2996
3116
  await credentialInitRequestPromise;
2997
- await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3117
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
3118
+ void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this); // this call triggers wallet login for later usage
2998
3119
  log.info("Credential service initialized successfully");
2999
3120
  }
3000
3121
  catch (error) {
@@ -3298,4 +3419,4 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3298
3419
  __classPrivateFieldSet(this, _AirService_recoveryInitialization, undefined, "f");
3299
3420
  };
3300
3421
 
3301
- export { AirService, AirServiceError, BUILD_ENV, ChainDisconnectedError, IFRAME_NAME_PREFIX_SET, InternalRpcError, InvalidParamsRpcError, InvalidRequestRpcError, MethodNotFoundRpcError, ProviderDisconnectedError, ProviderRpcError, SwitchChainError, TransactionRejectedRpcError, UnauthorizedProviderError, UnsupportedProviderMethodError, UserRejectedRequestError, ensureProviderRpcError };
3422
+ export { AirService, AirServiceError, BUILD_ENV, ChainDisconnectedError, IFRAME_NAME_PREFIX_SET, InternalRpcError, InvalidParamsRpcError, InvalidRequestRpcError, MethodNotFoundRpcError, ProviderDisconnectedError, ProviderRpcError, SwitchChainError, TransactionRejectedRpcError, UnauthorizedProviderError, UnsupportedProviderMethodError, UserRejectedRequestError, ensureProviderRpcError, mocaDevnet, mocaTestnet };
@@ -101,7 +101,7 @@
101
101
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
102
102
  };
103
103
 
104
- var version = "1.6.0";
104
+ var version = "1.7.0";
105
105
  var airkitPackage = {
106
106
  version: version};
107
107
 
@@ -111,6 +111,8 @@
111
111
  INITIALIZATION_RESPONSE: "air_auth_initialization_response",
112
112
  LOGIN_REQUEST: "air_auth_login_request",
113
113
  LOGIN_RESPONSE: "air_auth_login_response",
114
+ LOGIN_SERVICE_STATUS_REQUEST: "air_auth_login_service_status_request",
115
+ LOGIN_SERVICE_STATUS_RESPONSE: "air_auth_login_service_status_response",
114
116
  LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
115
117
  UPDATE_SESSION_CONFIG_REQUEST: "air_auth_update_session_config_request",
116
118
  UPDATE_SESSION_CONFIG_RESPONSE: "air_auth_update_session_config_response",
@@ -595,6 +597,61 @@
595
597
  log.info(`[${window?.location?.href}] LogLevel: ${getLevelName(log.getLevel())}`);
596
598
  };
597
599
 
600
+ const mocaDevnet = {
601
+ id: 5151,
602
+ name: "Moca Devnet",
603
+ nativeCurrency: {
604
+ decimals: 18,
605
+ name: "Moca Network",
606
+ symbol: "MOCA"
607
+ },
608
+ rpcUrls: {
609
+ default: {
610
+ http: ["https://devnet-rpc.mocachain.org"],
611
+ webSocket: ["wss://devnet-rpc.mocachain.org"]
612
+ }
613
+ },
614
+ blockExplorers: {
615
+ default: {
616
+ name: "Moca Devnet",
617
+ url: "https://devnet-scan.mocachain.org"
618
+ }
619
+ },
620
+ contracts: {
621
+ multicall3: {
622
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
623
+ blockCreated: 3837540
624
+ }
625
+ }
626
+ };
627
+ const mocaTestnet = {
628
+ id: 222888,
629
+ name: "Moca Testnet",
630
+ nativeCurrency: {
631
+ decimals: 18,
632
+ name: "Moca Network",
633
+ symbol: "MOCA"
634
+ },
635
+ rpcUrls: {
636
+ default: {
637
+ http: ["https://testnet-rpc.mocachain.org"],
638
+ webSocket: ["wss://testnet-rpc.mocachain.org"]
639
+ }
640
+ },
641
+ blockExplorers: {
642
+ default: {
643
+ name: "Moca Testnet",
644
+ url: "https://testnet-scan.mocachain.org"
645
+ }
646
+ },
647
+ contracts: {
648
+ multicall3: {
649
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
650
+ blockCreated: 1330259
651
+ }
652
+ }
653
+ };
654
+
598
655
  const BUILD_ENV = {
599
656
  PRODUCTION: "production",
600
657
  UAT: "uat",
@@ -609,12 +666,13 @@
609
666
  "air-recovery",
610
667
  ]; // order defines the z-index from highest to lowest
611
668
 
669
+ const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
612
670
  const AIR_URLS = {
613
671
  [BUILD_ENV.DEVELOPMENT]: {
614
- authUrl: "http://localhost:8200/auth/",
615
- walletUrl: "http://localhost:8200/wallet/",
616
- recoveryUrl: "http://localhost:8200/recovery/",
617
- credentialUrl: "http://localhost:8200/credential/",
672
+ authUrl: "https://localhost:8200/auth/",
673
+ walletUrl: "https://localhost:8200/wallet/",
674
+ recoveryUrl: "https://localhost:8200/recovery/",
675
+ credentialUrl: "https://localhost:8200/credential/",
618
676
  },
619
677
  [BUILD_ENV.STAGING]: {
620
678
  authUrl: "https://account.staging.air3.com/auth/",
@@ -641,6 +699,47 @@
641
699
  credentialUrl: "https://account.air3.com/credential/",
642
700
  },
643
701
  };
702
+ /**
703
+ * Injects dns-prefetch, preconnect, and prefetch link tags
704
+ * for a given resource or page URL.
705
+ *
706
+ * @param url - Full resource URL (e.g. "https://cdn.example.com/app.js")
707
+ * @param options - Optional configuration
708
+ * prefetch?: boolean — disable if you only want connection warm-up
709
+ * as?: string — specify resource type for prefetch ("document", "script", "style", "font", etc.)
710
+ */
711
+ const addResourceHints = (url, options) => {
712
+ try {
713
+ const parsed = new URL(url, window.location.href);
714
+ const isCrossOrigin = parsed.origin !== window.location.origin;
715
+ const head = document.head;
716
+ const addLink = (rel, href, as, crossOrigin) => {
717
+ // Skip if a matching link already exists
718
+ if (head.querySelector(`link[rel="${rel}"][href="${href}"]`))
719
+ return;
720
+ const link = document.createElement("link");
721
+ link.rel = rel;
722
+ link.href = href;
723
+ if (as)
724
+ link.as = as;
725
+ if (crossOrigin)
726
+ link.crossOrigin = "anonymous";
727
+ head.appendChild(link);
728
+ };
729
+ const hostname = parsed.hostname;
730
+ // DNS Prefetch (scheme-less, safe for any protocol)
731
+ addLink("dns-prefetch", `//${hostname}`);
732
+ // Preconnect (TCP + TLS warm-up)
733
+ addLink("preconnect", parsed.origin, undefined, isCrossOrigin);
734
+ // Prefetch (optional — caches the resource or HTML document)
735
+ if (options?.prefetch !== false) {
736
+ addLink("prefetch", parsed.href, options?.as ?? "document", isCrossOrigin);
737
+ }
738
+ }
739
+ catch (err) {
740
+ log.warn("[addResourceHints] Invalid URL:", url, err);
741
+ }
742
+ };
644
743
  const isElement = (element) => element instanceof Element || element instanceof Document;
645
744
  const randomId = () => Math.random().toString(36).slice(2);
646
745
  const extractErrorHash = (message) => {
@@ -2151,6 +2250,17 @@
2151
2250
  iframe.style.padding = "0";
2152
2251
  iframe.style.display = "none";
2153
2252
  iframe.style.colorScheme = "auto";
2253
+ iframe.setAttribute("sandbox", [
2254
+ "allow-scripts",
2255
+ "allow-same-origin",
2256
+ "allow-storage-access-by-user-activation",
2257
+ "allow-modals",
2258
+ "allow-popups",
2259
+ "allow-popups-to-escape-sandbox", // for google login
2260
+ "allow-forms", // for google login
2261
+ "allow-downloads", // for recovery export
2262
+ "allow-top-navigation-by-user-activation",
2263
+ ].join(" "));
2154
2264
  document.body.appendChild(iframe);
2155
2265
  this._iframeElement = iframe;
2156
2266
  return iframe;
@@ -2344,10 +2454,11 @@
2344
2454
  await this.sendMessage({ type: AirWalletMessageTypes.CLAIM_ID_REQUEST, payload });
2345
2455
  return response;
2346
2456
  }
2347
- async sendShowSwapUIRequest() {
2457
+ async sendShowSwapUIRequest(payload) {
2348
2458
  const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE)));
2349
2459
  await this.sendMessage({
2350
2460
  type: AirWalletMessageTypes.SHOW_SWAP_UI_REQUEST,
2461
+ payload
2351
2462
  });
2352
2463
  return response;
2353
2464
  }
@@ -2595,7 +2706,7 @@
2595
2706
  ensureWallet: __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).bind(this),
2596
2707
  getLoginResult: () => __classPrivateFieldGet(this, _AirService_loginResult, "f"),
2597
2708
  }), "f");
2598
- // this.#modalZIndex = modalZIndex ?? 99999;
2709
+ FONT_CDNS.forEach((cdn) => addResourceHints(cdn, { prefetch: false }));
2599
2710
  }
2600
2711
  get buildEnv() {
2601
2712
  return __classPrivateFieldGet(this, _AirService_buildEnv, "f");
@@ -2623,16 +2734,23 @@
2623
2734
  shouldEnableAutomation() {
2624
2735
  return localStorage.getItem("automation") === "true" && __classPrivateFieldGet(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
2625
2736
  }
2626
- async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, }) {
2737
+ async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, preloadWallet = false, preloadCredential = false, }) {
2627
2738
  if (!__classPrivateFieldGet(this, _AirService_partnerId, "f"))
2628
2739
  throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2629
2740
  if (__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
2630
2741
  return __classPrivateFieldGet(this, _AirService_loginResult, "f") ?? null;
2742
+ configureLogLevel(buildEnv, enableLogging);
2743
+ const { authUrl, walletUrl, credentialUrl } = AIR_URLS[buildEnv];
2744
+ addResourceHints(authUrl);
2745
+ if (preloadWallet) {
2746
+ addResourceHints(walletUrl);
2747
+ }
2748
+ if (preloadCredential) {
2749
+ addResourceHints(credentialUrl);
2750
+ }
2631
2751
  __classPrivateFieldSet(this, _AirService_buildEnv, buildEnv, "f");
2632
2752
  __classPrivateFieldSet(this, _AirService_enableLogging, enableLogging, "f");
2633
2753
  __classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
2634
- const { authUrl } = AIR_URLS[buildEnv];
2635
- configureLogLevel(buildEnv, enableLogging);
2636
2754
  __classPrivateFieldSet(this, _AirService_sessionId, randomId(), "f");
2637
2755
  const authIframeOrigin = new URL(authUrl).origin;
2638
2756
  __classPrivateFieldSet(this, _AirService_authIframeController, new IframeController("air-auth", authUrl), "f");
@@ -2704,8 +2822,10 @@
2704
2822
  });
2705
2823
  __classPrivateFieldSet(this, _AirService_isAuthInitialized, true, "f");
2706
2824
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthInitialized).call(this, { rehydrated: result.rehydrated });
2707
- if (result.preloadWallet)
2825
+ if (result.preloadWallet || preloadWallet)
2708
2826
  void this.preloadWallet();
2827
+ if (preloadCredential)
2828
+ void this.preloadCredential();
2709
2829
  // rehydrated auth session
2710
2830
  if (result.rehydrated) {
2711
2831
  __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
@@ -2788,9 +2908,9 @@
2788
2908
  /**
2789
2909
  * @experimental This feature has not been officially released and might change in the future.
2790
2910
  */
2791
- async showSwapUI() {
2911
+ async showSwapUI(options) {
2792
2912
  await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
2793
- const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest();
2913
+ const result = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendShowSwapUIRequest(options);
2794
2914
  if (result.payload.success === false) {
2795
2915
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2796
2916
  }
@@ -3000,7 +3120,8 @@
3000
3120
  await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").open(__classPrivateFieldGet(this, _AirService_credentialIframeController, "f").iframeElement);
3001
3121
  __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_subscribeToCredentialEvents).call(this);
3002
3122
  await credentialInitRequestPromise;
3003
- await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
3123
+ await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
3124
+ void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this); // this call triggers wallet login for later usage
3004
3125
  log.info("Credential service initialized successfully");
3005
3126
  }
3006
3127
  catch (error) {
@@ -3321,5 +3442,7 @@
3321
3442
  exports.UnsupportedProviderMethodError = UnsupportedProviderMethodError;
3322
3443
  exports.UserRejectedRequestError = UserRejectedRequestError;
3323
3444
  exports.ensureProviderRpcError = ensureProviderRpcError;
3445
+ exports.mocaDevnet = mocaDevnet;
3446
+ exports.mocaTestnet = mocaTestnet;
3324
3447
 
3325
3448
  }));
@@ -4,7 +4,6 @@ declare class AirService {
4
4
  #private;
5
5
  constructor({ partnerId }: {
6
6
  partnerId: string;
7
- modalZIndex?: number;
8
7
  });
9
8
  get buildEnv(): BUILD_ENV_TYPE;
10
9
  get isInitialized(): boolean;
@@ -13,10 +12,12 @@ declare class AirService {
13
12
  get isWalletInitialized(): boolean;
14
13
  get provider(): EIP1193Provider;
15
14
  private shouldEnableAutomation;
16
- init({ buildEnv, enableLogging, skipRehydration, sessionConfig, }: {
15
+ init({ buildEnv, enableLogging, skipRehydration, sessionConfig, preloadWallet, preloadCredential, }: {
17
16
  buildEnv: BUILD_ENV_TYPE;
18
17
  enableLogging: boolean;
19
18
  skipRehydration: boolean;
19
+ preloadWallet?: boolean;
20
+ preloadCredential?: boolean;
20
21
  sessionConfig?: Partial<AirSessionConfig>;
21
22
  }): Promise<AirLoginResult | null>;
22
23
  login(options?: {
@@ -42,7 +43,11 @@ declare class AirService {
42
43
  /**
43
44
  * @experimental This feature has not been officially released and might change in the future.
44
45
  */
45
- showSwapUI(): Promise<{
46
+ showSwapUI(options?: {
47
+ initialFromToken?: string;
48
+ fallbackFromToken?: string;
49
+ initialToToken?: string;
50
+ }): Promise<{
46
51
  txHash: `0x${string}`;
47
52
  }>;
48
53
  /**
@@ -7,6 +7,8 @@ export declare const AirAuthMessageTypes: {
7
7
  readonly INITIALIZATION_RESPONSE: "air_auth_initialization_response";
8
8
  readonly LOGIN_REQUEST: "air_auth_login_request";
9
9
  readonly LOGIN_RESPONSE: "air_auth_login_response";
10
+ readonly LOGIN_SERVICE_STATUS_REQUEST: "air_auth_login_service_status_request";
11
+ readonly LOGIN_SERVICE_STATUS_RESPONSE: "air_auth_login_service_status_response";
10
12
  readonly LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response";
11
13
  readonly UPDATE_SESSION_CONFIG_REQUEST: "air_auth_update_session_config_request";
12
14
  readonly UPDATE_SESSION_CONFIG_RESPONSE: "air_auth_update_session_config_response";
@@ -53,8 +55,8 @@ export type AirAuthUserInfoResponsePayload = (AirMessageSuccessPayload & GlobalI
53
55
  airIds: AirIdDetails[];
54
56
  }) | AirMessageErrorPayload;
55
57
  export type AirAuthPartnerUserDetailsSuccess = AirMessageSuccessPayload & {
56
- partnerId: string;
57
- partnerUserId: string;
58
+ partnerId?: string;
59
+ partnerUserId?: string;
58
60
  airId?: AirIdDetails;
59
61
  user: GlobalId & {
60
62
  email?: string;
@@ -62,7 +64,12 @@ export type AirAuthPartnerUserDetailsSuccess = AirMessageSuccessPayload & {
62
64
  };
63
65
  export type AirAuthSuccessWithAirIdAndTokens = AirAuthPartnerUserDetailsSuccess & AirMessageSuccessPayloadTokens;
64
66
  type AirAuthLoginResponseToEmbedPayload = AirAuthLoginSuccess | AirMessageErrorPayload;
65
- type AirAuthLoginResponseToWalletPayload = AirAuthSuccessWithAirIdAndTokens | AirMessageErrorPayload;
67
+ type AirAuthLoginResponseToAirServicePayload = AirAuthSuccessWithAirIdAndTokens | AirMessageErrorPayload;
68
+ export type AirAuthLoginServiceStatusResponsePayload = ({
69
+ isUserLoggedIn: false;
70
+ } & AirMessageSuccessPayload) | ({
71
+ isUserLoggedIn: true;
72
+ } & AirAuthSuccessWithAirIdAndTokens);
66
73
  type AirAuthRefreshTokenResponsePayload = AirMessageSuccessPayloadTokens | AirMessageErrorPayload;
67
74
  type AirAuthPartnerUserInfoResponsePayload = AirAuthPartnerUserDetailsSuccess | AirMessageErrorPayload;
68
75
  type AirAuthWalletTokenRequestPayload = {
@@ -71,6 +78,7 @@ type AirAuthWalletTokenRequestPayload = {
71
78
  };
72
79
  type AirAuthWalletTokenResponsePayload = (AirAuthPartnerUserDetailsSuccess & {
73
80
  accessToken: string;
81
+ partnerAccessToken: string;
74
82
  walletToken: string;
75
83
  }) | AirMessageErrorPayload;
76
84
  export type AirAuthInitializationSuccess = (AirAuthLoginSuccess & {
@@ -115,7 +123,9 @@ export type AirAuthInitializationRequestMessage = AirAuthMessageBase<"air_auth_i
115
123
  export type AirAuthInitializationResponseMessage = AirAuthMessageBase<"air_auth_initialization_response", AirAuthInitializationResponsePayload>;
116
124
  export type AirAuthLoginRequestMessage = AirAuthMessageBase<"air_auth_login_request", AirAuthLoginRequestPayload>;
117
125
  export type AirAuthLoginResponseToEmbedMessage = AirAuthMessageBase<"air_auth_login_response", AirAuthLoginResponseToEmbedPayload>;
118
- export type AirAuthLoginResponseToWalletServiceMessage = AirAuthMessageBase<"air_auth_login_service_response", AirAuthLoginResponseToWalletPayload>;
126
+ export type AirAuthLoginResponseToAirServiceMessage = AirAuthMessageBase<"air_auth_login_service_response", AirAuthLoginResponseToAirServicePayload>;
127
+ export type AirAuthLoginStatusRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_login_service_status_request">;
128
+ export type AirAuthLoginStatusResponseMessage = AirAuthMessageBase<"air_auth_login_service_status_response", AirAuthLoginServiceStatusResponsePayload>;
119
129
  export type AirAuthUpdateSessionConfigRequestMessage = AirAuthMessageBase<"air_auth_update_session_config_request", Partial<SessionConfig>>;
120
130
  export type AirAuthUpdateSessionConfigResponseMessage = AirAuthMessageBase<"air_auth_update_session_config_response", (AirMessageSuccessPayload & SessionConfig) | AirMessageErrorPayload>;
121
131
  export type AirAuthUserInfoRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_user_info_request">;
@@ -189,5 +199,5 @@ export type AirAuthRecoverySuccessPayload = AirMessageSuccessPayload & {
189
199
  };
190
200
  export type AirAuthRecoveryResponseMessage = AirAuthMessageBase<"air_auth_recovery_response", AirAuthRecoverySuccessPayload | AirMessageErrorPayload>;
191
201
  export type AirAuthExpiredLogoutRequestMessage = AirAuthMessageBaseWithoutPayload<"air_auth_expired_logout_request">;
192
- export type AirAuthMessage = AirAuthSetupCompletedMessage | AirAuthInitializationRequestMessage | AirAuthInitializationResponseMessage | AirAuthLoginRequestMessage | AirAuthLoginResponseToEmbedMessage | AirAuthLoginResponseToWalletServiceMessage | AirAuthUpdateSessionConfigRequestMessage | AirAuthUpdateSessionConfigResponseMessage | AirAuthUserInfoRequestMessage | AirAuthUserInfoResponseMessage | AirAuthPartnerUserInfoRequestMessage | AirAuthPartnerUserInfoResponseMessage | AirAuthRefreshTokenRequestMessage | AirAuthRefreshTokenResponseMessage | AirAuthWalletTokenRequestMessage | AirAuthWalletTokenResponseMessage | AirAuthSetupWalletRequestMessage | AirAuthSetupWalletResponseMessage | AirAuthSignSiweMessageRequestMessage | AirAuthSignSiweMessageResponseMessage | AirAuthCrossPartnerTokenRequestMessage | AirAuthCrossPartnerTokenResponseMessage | AirAuthLogoutRequestMessage | AirAuthLogoutResponseMessage | AirAuthIframeVisibilityRequestMessage | AirAuthPartnerAccessTokenRequestMessage | AirAuthPartnerAccessTokenResponseMessage | AirAuthSetupRecoveryRequestMessage | AirAuthSetupRecoveryResponseMessage | AirStartRecoveryRequestMessage | AirStartRecoveryResponseMessage | AirAuthRecoveryRequestMessage | AirAuthRecoveryResponseMessage | AirAuthExpiredLogoutRequestMessage;
202
+ export type AirAuthMessage = AirAuthSetupCompletedMessage | AirAuthInitializationRequestMessage | AirAuthInitializationResponseMessage | AirAuthLoginRequestMessage | AirAuthLoginResponseToEmbedMessage | AirAuthLoginResponseToAirServiceMessage | AirAuthLoginStatusRequestMessage | AirAuthLoginStatusResponseMessage | AirAuthUpdateSessionConfigRequestMessage | AirAuthUpdateSessionConfigResponseMessage | AirAuthUserInfoRequestMessage | AirAuthUserInfoResponseMessage | AirAuthPartnerUserInfoRequestMessage | AirAuthPartnerUserInfoResponseMessage | AirAuthRefreshTokenRequestMessage | AirAuthRefreshTokenResponseMessage | AirAuthWalletTokenRequestMessage | AirAuthWalletTokenResponseMessage | AirAuthSetupWalletRequestMessage | AirAuthSetupWalletResponseMessage | AirAuthSignSiweMessageRequestMessage | AirAuthSignSiweMessageResponseMessage | AirAuthCrossPartnerTokenRequestMessage | AirAuthCrossPartnerTokenResponseMessage | AirAuthLogoutRequestMessage | AirAuthLogoutResponseMessage | AirAuthIframeVisibilityRequestMessage | AirAuthPartnerAccessTokenRequestMessage | AirAuthPartnerAccessTokenResponseMessage | AirAuthSetupRecoveryRequestMessage | AirAuthSetupRecoveryResponseMessage | AirStartRecoveryRequestMessage | AirStartRecoveryResponseMessage | AirAuthRecoveryRequestMessage | AirAuthRecoveryResponseMessage | AirAuthExpiredLogoutRequestMessage;
193
203
  export {};
@@ -75,7 +75,11 @@ export type AirClaimIdSuccess = AirMessageSuccessPayload & {
75
75
  };
76
76
  export type AirClaimIdResponsePayload = AirClaimIdSuccess | AirMessageErrorPayload;
77
77
  export type AirClaimIdResponseMessage = AirWalletMessageBase<"air_claim_id_response", AirClaimIdResponsePayload>;
78
- export type AirShowSwapUIRequestMessage = AirWalletMessageBaseWithoutPayload<"air_show_swap_ui_request">;
78
+ export type AirShowSwapUIRequestMessage = AirWalletMessageBase<"air_show_swap_ui_request", {
79
+ initialFromToken?: string;
80
+ fallbackFromToken?: string;
81
+ initialToToken?: string;
82
+ }>;
79
83
  export type AirShowSwapUISuccess = AirMessageSuccessPayload & {
80
84
  txHash: `0x${string}`;
81
85
  };
@@ -48,7 +48,7 @@ export declare const mocaTestnet: {
48
48
  readonly contracts: {
49
49
  readonly multicall3: {
50
50
  readonly address: "0xcA11bde05977b3631167028862bE2a173976CA11";
51
- readonly blockCreated: 0;
51
+ readonly blockCreated: 1330259;
52
52
  };
53
53
  };
54
54
  };
@@ -5,7 +5,7 @@ export type ProviderConnectInfo = {
5
5
  chainId: string;
6
6
  };
7
7
  export interface ExecuteActionParams {
8
- compressedSessionData: string;
8
+ sessionDetailsTypedDataSign: string;
9
9
  sessionOwnerPrivateKey: Hex;
10
10
  call: {
11
11
  data?: Hex | undefined;
@@ -46,4 +46,16 @@ export type Rule = {
46
46
  /** The usage object containing limit and used values (required if isLimited is true) */
47
47
  usage: LimitUsage;
48
48
  };
49
+ export type ParamRule = {
50
+ /** The condition to apply to the parameter */
51
+ condition: ParamCondition;
52
+ /** The offset index in the calldata where the value to be checked is located */
53
+ offset: bigint;
54
+ /** Indicates if the rule has a usage limit */
55
+ isLimited: boolean;
56
+ /** The reference value to compare against */
57
+ ref: Hex;
58
+ /** The usage object containing limit and used values (required if isLimited is true) */
59
+ usage: LimitUsage;
60
+ };
49
61
  export {};
@@ -1,4 +1,4 @@
1
- import type { Abi } from "abitype";
1
+ import type { Abi, AbiFunction } from "abitype";
2
2
  import { Hex } from "../../types";
3
3
  import { Rule } from "./rule";
4
4
  export type Address = Hex;
@@ -41,7 +41,7 @@ export type ActionPolicyInfo = {
41
41
  sudo?: boolean;
42
42
  } & OneOf<{
43
43
  /** The specific function selector from the contract to be included in the policy */
44
- functionSelector: string;
44
+ functionSelector: string | AbiFunction;
45
45
  /** Array of rules for the policy */
46
46
  rules?: Rule[];
47
47
  } | {
@@ -53,4 +53,4 @@ export type Call = {
53
53
  data?: Hex | undefined;
54
54
  value?: bigint | undefined;
55
55
  };
56
- export {};
56
+ export { };
@@ -53,8 +53,8 @@ export type UserResponse = {
53
53
  } & MFASetup;
54
54
  };
55
55
  export type PartnerUserResponse = {
56
- partnerId: string;
57
- partnerUserId: string;
56
+ partnerId?: string;
57
+ partnerUserId?: string;
58
58
  airId?: Omit<AirIdDetails, "id">;
59
59
  } & {
60
60
  user: UserResponse["user"] & CredentialConfigResponse;
@@ -11,3 +11,4 @@ export type Optional<T, K extends keyof T> = Omit<T, K> & {
11
11
  export type IntersectionToUnion<T> = {
12
12
  [K in keyof T]: (x: T[K]) => void;
13
13
  }[keyof T] extends (x: infer U) => void ? U : never;
14
+ export type FixedArray<T, N extends number, Acc extends T[] = []> = Acc["length"] extends N ? Acc : FixedArray<T, N, [...Acc, T]>;
@@ -6,7 +6,6 @@ export type PromiseHandle<T> = {
6
6
  export declare function promiseCreator<T>(): PromiseHandle<T>;
7
7
  export declare const sleep: (ms: number) => Promise<unknown>;
8
8
  export declare const formatPublicKey: (publicKey: string) => string;
9
- export declare const setPartnerTheme: (theme: string, partnerId: string, configApiUrl: string) => void;
10
9
  /**
11
10
  * Returns a random number. Don't use for cryptographic purposes.
12
11
  * @returns a random number
@@ -19,3 +18,5 @@ export declare const bigIntReplacer: (_key: string, value: unknown) => unknown;
19
18
  * Slightly reduces the size to avoid browser auto-resizing.
20
19
  */
21
20
  export declare const getWindowFeatures: (maxWidth: number, maxHeight: number) => string;
21
+ export declare const isPWA: () => boolean;
22
+ export declare const isIOS: () => boolean;
@@ -1,4 +1,5 @@
1
1
  import { AirVerifyCredentialSuccessResponsePayload } from "@mocanetwork/common/src/air/messaging/credential";
2
+ import { mocaDevnet, mocaTestnet } from "@mocanetwork/common/src/const";
2
3
  import { EIP1193Provider as EIP1193ProviderInterface } from "./common/provider/types";
3
4
  import { AirIdDetails } from "./common/realm/user/types";
4
5
  export declare const BUILD_ENV: {
@@ -21,8 +22,8 @@ export type AirInitializationResult = {
21
22
  rehydrated: boolean;
22
23
  };
23
24
  export type AirUserDetails = {
24
- partnerId: string;
25
- partnerUserId: string;
25
+ partnerId?: string;
26
+ partnerUserId?: string;
26
27
  airId?: AirIdDetails;
27
28
  user: {
28
29
  id: string;
@@ -76,3 +77,4 @@ export type ClaimAirIdOptions = {
76
77
  offchain?: boolean;
77
78
  };
78
79
  export type EIP1193Provider = EIP1193ProviderInterface;
80
+ export { mocaDevnet, mocaTestnet };
@@ -1,5 +1,19 @@
1
1
  import { AirUrlConfig, BUILD_ENV_TYPE } from "./interfaces";
2
+ export declare const FONT_CDNS: string[];
2
3
  export declare const AIR_URLS: Record<BUILD_ENV_TYPE, AirUrlConfig>;
4
+ /**
5
+ * Injects dns-prefetch, preconnect, and prefetch link tags
6
+ * for a given resource or page URL.
7
+ *
8
+ * @param url - Full resource URL (e.g. "https://cdn.example.com/app.js")
9
+ * @param options - Optional configuration
10
+ * prefetch?: boolean — disable if you only want connection warm-up
11
+ * as?: string — specify resource type for prefetch ("document", "script", "style", "font", etc.)
12
+ */
13
+ export declare const addResourceHints: (url: string, options?: {
14
+ prefetch?: boolean;
15
+ as?: string;
16
+ }) => void;
3
17
  export declare const handleEvent: (handle: EventTarget, eventName: string, handler: (...args: unknown[]) => void, ...handlerArgs: unknown[]) => void;
4
18
  export declare const htmlToElement: <T extends Element>(html: string) => T;
5
19
  export declare const isElement: (element: unknown) => element is Element | Document;
@@ -18,7 +18,11 @@ export declare class WalletMessageService extends MessageServiceBase<AirWalletMe
18
18
  sendOpenWindowRetryRequest(windowId: string): Promise<import("@mocanetwork/common/src/air/messaging/window").AirOpenWindowRetryResponseMessage>;
19
19
  sendWindowClosed(windowId: string): Promise<void>;
20
20
  sendClaimIdRequest(payload: AirClaimIdRequestMessage["payload"]): Promise<import("./common/air/messaging/wallet").AirClaimIdResponseMessage>;
21
- sendShowSwapUIRequest(): Promise<import("./common/air/messaging/wallet").AirShowSwapUIResponseMessage>;
21
+ sendShowSwapUIRequest(payload?: {
22
+ initialFromToken?: string;
23
+ fallbackFromToken?: string;
24
+ initialToToken?: string;
25
+ }): Promise<import("./common/air/messaging/wallet").AirShowSwapUIResponseMessage>;
22
26
  sendShowOnRampUIRequest(payload: {
23
27
  displayCurrencyCode: string;
24
28
  targetCurrencyCode?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mocanetwork/airkit",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Air kit to interact with the Moca Network",
5
5
  "main": "dist/airkit.cjs.js",
6
6
  "module": "dist/airkit.esm.js",