@mocanetwork/airkit-connector 1.9.0-beta.3 → 1.10.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.
@@ -94,7 +94,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
94
94
  var e = new Error(message);
95
95
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
96
96
  };
97
- var version$2 = "1.9.0-beta.3";
97
+ var version$2 = "1.10.0";
98
98
  var airkitPackage = {
99
99
  version: version$2
100
100
  };
@@ -134,10 +134,23 @@ const AirAuthMessageTypes = {
134
134
  LOGOUT_RESPONSE: "air_auth_logout_response",
135
135
  START_RECOVERY_REQUEST: "air_start_recovery_request",
136
136
  START_RECOVERY_RESPONSE: "air_start_recovery_response",
137
+ // Dashboard intent posted by recovery-frontend's RecoveryEntryView when
138
+ // the user picks an action. Distinct from START_RECOVERY_REQUEST so that
139
+ // when auth-frontend forwards the actual START_RECOVERY_REQUEST onto the
140
+ // shared recovery channel, the local echo doesn't loop back into
141
+ // auth-frontend's own recovery-channel subscription.
142
+ START_RECOVERY_DASHBOARD_REQUEST: "air_start_recovery_dashboard_request",
137
143
  RECOVERY_REQUEST: "air_auth_recovery_request",
138
144
  RECOVERY_RESPONSE: "air_auth_recovery_response",
139
- ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_auth_issue_on_behalf_new_user_confirmation_request",
140
- ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_auth_issue_on_behalf_new_user_confirmation_response",
145
+ // Mid-flow signing RPCs for the RECOVER_ACCOUNT flow. The recovery
146
+ // private key never leaves recovery-frontend; auth-frontend asks for
147
+ // a signature each time it needs one (after collecting the new email
148
+ // for the canonical reset payload, and after the backend returns the
149
+ // Privy authorization payload to wallet-PATCH).
150
+ RECOVER_ACCOUNT_RESET_SIGNATURE_REQUEST: "air_auth_recover_account_reset_signature_request",
151
+ RECOVER_ACCOUNT_RESET_SIGNATURE_RESPONSE: "air_auth_recover_account_reset_signature_response",
152
+ RECOVER_ACCOUNT_AUTHORIZATION_SIGNATURE_REQUEST: "air_auth_recover_account_authorization_signature_request",
153
+ RECOVER_ACCOUNT_AUTHORIZATION_SIGNATURE_RESPONSE: "air_auth_recover_account_authorization_signature_response",
141
154
  REMOVE_SIGNER_SIGNATURE_REQUEST: "air_auth_remove_signer_signature_request",
142
155
  REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_auth_remove_signer_signature_response",
143
156
  RESET_WALLET_REQUEST: "air_auth_reset_wallet_request",
@@ -616,11 +629,11 @@ const BUILD_ENV = {
616
629
  const IFRAME_NAME_PREFIX_SET = ["air-wallet", "air-credential", "air-auth", "air-recovery"]; // order defines the z-index from highest to lowest
617
630
 
618
631
  const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
619
- const SANDBOX_TESTNET_URLS = {
620
- authUrl: "https://account.sandbox-testnet.air3.com/auth/",
621
- walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
622
- recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
623
- credentialUrl: "https://account.sandbox-testnet.air3.com/credential/"
632
+ const PRODUCTION_MAINNET_URLS = {
633
+ authUrl: "https://account-mainnet.air3.com/auth/",
634
+ walletUrl: "https://account-mainnet.air3.com/wallet/",
635
+ recoveryUrl: "https://account-mainnet.air3.com/recovery/",
636
+ credentialUrl: "https://account-mainnet.air3.com/credential/"
624
637
  };
625
638
  const AIR_URLS = {
626
639
  [BUILD_ENV.DEVELOPMENT]: {
@@ -642,10 +655,10 @@ const AIR_URLS = {
642
655
  credentialUrl: "https://account.uat.air3.com/credential/"
643
656
  },
644
657
  [BUILD_ENV.SANDBOX]: {
645
- authUrl: "https://account.sandbox.air3.com/auth/",
646
- walletUrl: "https://account.sandbox.air3.com/wallet/",
647
- recoveryUrl: "https://account.sandbox.air3.com/recovery/",
648
- credentialUrl: "https://account.sandbox.air3.com/credential/"
658
+ authUrl: "https://account.sandbox-testnet.air3.com/auth/",
659
+ walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
660
+ recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
661
+ credentialUrl: "https://account.sandbox-testnet.air3.com/credential/"
649
662
  },
650
663
  [BUILD_ENV.PRODUCTION]: {
651
664
  authUrl: "https://account.air3.com/auth/",
@@ -655,8 +668,8 @@ const AIR_URLS = {
655
668
  }
656
669
  };
657
670
  const getAirUrls = (buildEnv, credentialNetwork) => {
658
- if (buildEnv === BUILD_ENV.SANDBOX && credentialNetwork === "testnet") {
659
- return SANDBOX_TESTNET_URLS;
671
+ if (buildEnv === BUILD_ENV.PRODUCTION && credentialNetwork === "mainnet") {
672
+ return PRODUCTION_MAINNET_URLS;
660
673
  }
661
674
  return AIR_URLS[buildEnv];
662
675
  };
@@ -1535,6 +1548,41 @@ var AnonymousSubject = function (_super) {
1535
1548
  };
1536
1549
  return AnonymousSubject;
1537
1550
  }(Subject);
1551
+ var BehaviorSubject = function (_super) {
1552
+ __extends(BehaviorSubject, _super);
1553
+ function BehaviorSubject(_value) {
1554
+ var _this = _super.call(this) || this;
1555
+ _this._value = _value;
1556
+ return _this;
1557
+ }
1558
+ Object.defineProperty(BehaviorSubject.prototype, "value", {
1559
+ get: function () {
1560
+ return this.getValue();
1561
+ },
1562
+ enumerable: false,
1563
+ configurable: true
1564
+ });
1565
+ BehaviorSubject.prototype._subscribe = function (subscriber) {
1566
+ var subscription = _super.prototype._subscribe.call(this, subscriber);
1567
+ !subscription.closed && subscriber.next(this._value);
1568
+ return subscription;
1569
+ };
1570
+ BehaviorSubject.prototype.getValue = function () {
1571
+ var _a = this,
1572
+ hasError = _a.hasError,
1573
+ thrownError = _a.thrownError,
1574
+ _value = _a._value;
1575
+ if (hasError) {
1576
+ throw thrownError;
1577
+ }
1578
+ this._throwIfClosed();
1579
+ return _value;
1580
+ };
1581
+ BehaviorSubject.prototype.next = function (value) {
1582
+ _super.prototype.next.call(this, this._value = value);
1583
+ };
1584
+ return BehaviorSubject;
1585
+ }(Subject);
1538
1586
  var EmptyError = createErrorClass(function (_super) {
1539
1587
  return function EmptyErrorImpl() {
1540
1588
  _super(this);
@@ -1611,6 +1659,8 @@ var PartnerAccessTokenErrorName;
1611
1659
  (function (PartnerAccessTokenErrorName) {
1612
1660
  PartnerAccessTokenErrorName["PARTNER_ACCESS_TOKEN_INVALID"] = "PARTNER_ACCESS_TOKEN_INVALID";
1613
1661
  PartnerAccessTokenErrorName["USER_MISMATCH"] = "USER_MISMATCH";
1662
+ /** dApp-supplied partner JWT is past its `exp` — SDK consumers should mint a fresh one. */
1663
+ PartnerAccessTokenErrorName["PARTNER_TOKEN_EXPIRED"] = "PARTNER_TOKEN_EXPIRED";
1614
1664
  })(PartnerAccessTokenErrorName || (PartnerAccessTokenErrorName = {}));
1615
1665
  /*** Realm ID Errors ***/
1616
1666
  var RealmIDErrorName;
@@ -1681,6 +1731,12 @@ var PrivyErrorName;
1681
1731
  (function (PrivyErrorName) {
1682
1732
  PrivyErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1683
1733
  })(PrivyErrorName || (PrivyErrorName = {}));
1734
+ /*** Recovery Errors ***/
1735
+ var RecoveryErrorName;
1736
+ (function (RecoveryErrorName) {
1737
+ RecoveryErrorName["RECOVERY_NOT_CONFIGURED"] = "RECOVERY_NOT_CONFIGURED";
1738
+ RecoveryErrorName["RECOVERY_LOCK_EXCEEDED"] = "RECOVERY_LOCK_EXCEEDED";
1739
+ })(RecoveryErrorName || (RecoveryErrorName = {}));
1684
1740
  /*** Air ID Errors ***/
1685
1741
  var AirIDErrorName;
1686
1742
  (function (AirIDErrorName) {
@@ -1700,6 +1756,13 @@ var AirIDErrorName;
1700
1756
  AirIDErrorName["AIR_ID_INVALID_MINT_NAME"] = "AIR_ID_INVALID_MINT_NAME";
1701
1757
  AirIDErrorName["AIR_ID_MINT_TRANSACTION_HASH_MISMATCH"] = "AIR_ID_MINT_TRANSACTION_HASH_MISMATCH";
1702
1758
  })(AirIDErrorName || (AirIDErrorName = {}));
1759
+ /*** Agent Errors ***/
1760
+ var AgentErrorName;
1761
+ (function (AgentErrorName) {
1762
+ AgentErrorName["CONFLICT_REQUEST"] = "CONFLICT_REQUEST";
1763
+ AgentErrorName["INVALID_PARAMETER"] = "INVALID_PARAMETER";
1764
+ AgentErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1765
+ })(AgentErrorName || (AgentErrorName = {}));
1703
1766
  /*** Window Errors ***/
1704
1767
  var WindowErrorName;
1705
1768
  (function (WindowErrorName) {
@@ -1718,10 +1781,12 @@ const Codes = {
1718
1781
  ...WalletLinkErrorName,
1719
1782
  ...IntentErrorName,
1720
1783
  ...PrivyErrorName,
1784
+ ...RecoveryErrorName,
1721
1785
  ...AirIDErrorName,
1722
- ...WindowErrorName
1786
+ ...WindowErrorName,
1787
+ ...AgentErrorName
1723
1788
  };
1724
- 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"];
1789
+ 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", "START_PIN_RECOVERY"];
1725
1790
  class AirError extends BaseError$2 {}
1726
1791
  new Set(AirClientUserErrors);
1727
1792
  new Set(Object.values(Codes));
@@ -1734,12 +1799,18 @@ class MessageServiceBase {
1734
1799
  return this._messages$;
1735
1800
  }
1736
1801
  get isOpen() {
1737
- return !!this.closeListener;
1802
+ return this._isOpen$.value;
1803
+ }
1804
+ async waitUntilOpen() {
1805
+ if (this.isOpen) return;
1806
+ await firstValueFrom(this._isOpen$.pipe(filter(Boolean)));
1738
1807
  }
1739
1808
  constructor(name, allowedMessageTypes) {
1740
1809
  this.name = name;
1741
1810
  this.allowedMessageTypes = allowedMessageTypes;
1742
1811
  this.closeListener = null;
1812
+ this._isOpen$ = new BehaviorSubject(false);
1813
+ this.isOpen$ = this._isOpen$.asObservable();
1743
1814
  }
1744
1815
  static _getName(name, targetName) {
1745
1816
  return `${name} Service: ${targetName} Channel`;
@@ -1782,6 +1853,7 @@ class MessageServiceBase {
1782
1853
  window.removeEventListener("message", handleMessage);
1783
1854
  };
1784
1855
  }
1856
+ this._isOpen$.next(true);
1785
1857
  }
1786
1858
  isMessageAllowed(message) {
1787
1859
  return this.allowedMessageTypes.includes(message.type);
@@ -1798,6 +1870,7 @@ class MessageServiceBase {
1798
1870
  if (this.eventSubject && !this.eventSubject.closed) {
1799
1871
  this.eventSubject.complete();
1800
1872
  }
1873
+ if (this._isOpen$.value) this._isOpen$.next(false);
1801
1874
  }
1802
1875
  createErrorResponseMessage(type, error) {
1803
1876
  return {
@@ -2142,7 +2215,7 @@ class AuthMessageService extends MessageServiceBase {
2142
2215
  const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.START_RECOVERY_RESPONSE)));
2143
2216
  await this.sendMessage({
2144
2217
  type: AirAuthMessageTypes.START_RECOVERY_REQUEST,
2145
- payload
2218
+ payload: payload ?? {}
2146
2219
  });
2147
2220
  return response;
2148
2221
  }
@@ -2234,11 +2307,14 @@ class IframeController {
2234
2307
  get iframeElement() {
2235
2308
  return this._iframeElement;
2236
2309
  }
2310
+ get isVisible() {
2311
+ return this.state.isVisible;
2312
+ }
2237
2313
  createIframe() {
2238
2314
  if (this._iframeElement) return this._iframeElement;
2239
2315
  const iframe = document.createElement("iframe");
2240
2316
  iframe.id = this.iframeId;
2241
- iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version", "clipboard-write", "web-share"].join("; ");
2317
+ iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version", "clipboard-read", "clipboard-write", "web-share"].join("; ");
2242
2318
  iframe.src = this.iframeUrl;
2243
2319
  iframe.style.position = "fixed";
2244
2320
  iframe.style.zIndex = `${this.getZIndex()}`;
@@ -2273,6 +2349,15 @@ class IframeController {
2273
2349
  style.bottom = "0px";
2274
2350
  Object.assign(this.iframeElement.style, style);
2275
2351
  }
2352
+ focus() {
2353
+ try {
2354
+ this.iframeElement?.contentWindow?.focus();
2355
+ } catch {
2356
+ // Some browsers reject cross-origin focus() outside a user gesture.
2357
+ // The first interaction inside the iframe will restore the correct
2358
+ // keyboard routing, so swallowing this is safe.
2359
+ }
2360
+ }
2276
2361
  destroy() {
2277
2362
  if (this.iframeElement) {
2278
2363
  this.iframeElement.remove();
@@ -2731,7 +2816,7 @@ class WindowService {
2731
2816
  }
2732
2817
  }
2733
2818
  var WindowService$1 = WindowService.instance;
2734
- var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_sessionId, _AirService_sessionConfig, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airEventListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _AirService_credentialNetwork, _AirService_assertInitialized, _AirService_assertLoggedIn, _AirService_ensureCredential, _AirService_initializeCredentials, _AirService_subscribeToCredentialEvents, _AirService_cleanUpCredential, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_subscribeToWalletEvents, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_createLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet, _AirService_ensureRecovery, _AirService_initializeRecovery, _AirService_subscribeToRecoveryEvents, _AirService_cleanUpRecovery;
2819
+ var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_sessionId, _AirService_sessionConfig, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airEventListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _AirService_credentialNetwork, _AirService_assertInitialized, _AirService_assertLoggedIn, _AirService_ensureCredential, _AirService_initializeCredentials, _AirService_subscribeToCredentialEvents, _AirService_cleanUpCredential, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_subscribeToWalletEvents, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_assignAndTriggerLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet, _AirService_ensureRecovery, _AirService_initializeRecovery, _AirService_subscribeToRecoveryEvents, _AirService_cleanUpRecovery, _AirService_refocusTopmostVisibleIframe;
2735
2820
  const airKitVersion = airkitPackage.version;
2736
2821
  class AirService {
2737
2822
  constructor({
@@ -2809,11 +2894,11 @@ class AirService {
2809
2894
  sessionConfig = undefined,
2810
2895
  preloadWallet = false,
2811
2896
  preloadCredential = false,
2812
- credentialNetwork = "devnet"
2897
+ credentialNetwork
2813
2898
  } = config;
2814
2899
  if (!__classPrivateFieldGet$1(this, _AirService_partnerId, "f")) throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2815
2900
  if (__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) return __classPrivateFieldGet$1(this, _AirService_loginResult, "f") ?? null;
2816
- __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.SANDBOX ? credentialNetwork : undefined);
2901
+ __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.PRODUCTION ? credentialNetwork : undefined);
2817
2902
  configureLogLevel(buildEnv, enableLogging);
2818
2903
  const {
2819
2904
  authUrl,
@@ -2844,6 +2929,7 @@ class AirService {
2844
2929
  const authIframeController = __classPrivateFieldGet$1(this, _AirService_authIframeController, "f");
2845
2930
  authIframeController.setIframeVisibility(msg.payload.visible);
2846
2931
  authIframeController.updateIframeState();
2932
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
2847
2933
  break;
2848
2934
  }
2849
2935
  case AirAuthMessageTypes.SETUP_WALLET_REQUEST:
@@ -2886,6 +2972,20 @@ class AirService {
2886
2972
  await this.logout();
2887
2973
  break;
2888
2974
  }
2975
+ case AirAuthMessageTypes.LOGIN_RESPONSE:
2976
+ {
2977
+ if (msg.payload.success === true) {
2978
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, msg.payload);
2979
+ }
2980
+ break;
2981
+ }
2982
+ case AirAuthMessageTypes.LOGOUT_RESPONSE:
2983
+ {
2984
+ const wasLoggedIn = !!__classPrivateFieldGet$1(this, _AirService_loginResult, "f");
2985
+ __classPrivateFieldSet(this, _AirService_loginResult, undefined, "f");
2986
+ if (wasLoggedIn) __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
2987
+ break;
2988
+ }
2889
2989
  }
2890
2990
  });
2891
2991
  const result = await new Promise((resolve, reject) => {
@@ -2922,9 +3022,7 @@ class AirService {
2922
3022
  if (preloadCredential) void this.preloadCredential();
2923
3023
  // rehydrated auth session
2924
3024
  if (result.rehydrated) {
2925
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
2926
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2927
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3025
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, result);
2928
3026
  }
2929
3027
  } catch (error) {
2930
3028
  log$1.debug("Error initializing auth service", error);
@@ -2942,9 +3040,7 @@ class AirService {
2942
3040
  partnerLoginToken: options?.authToken
2943
3041
  });
2944
3042
  if (payload.success === true) {
2945
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload));
2946
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2947
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3043
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, payload);
2948
3044
  }
2949
3045
  throw new AirServiceError(payload.errorName, payload.errorMessage);
2950
3046
  }
@@ -3113,7 +3209,8 @@ class AirService {
3113
3209
  id: info.payload.user.id,
3114
3210
  abstractAccountAddress: info.payload.user.abstractAccountAddress,
3115
3211
  email: info.payload.user.email,
3116
- isMFASetup: info.payload.user.activeMfaMethods.length > 0
3212
+ wallet: info.payload.user.wallet,
3213
+ isMFASetup: (info.payload.user.activeMfaMethods?.length ?? 0) > 0
3117
3214
  }
3118
3215
  };
3119
3216
  }
@@ -3177,8 +3274,6 @@ class AirService {
3177
3274
  // Clear up credentials first to avoid issues with wallet and auth messaging services
3178
3275
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
3179
3276
  await Promise.all([__classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this), __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this), __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").logout()]);
3180
- __classPrivateFieldSet(this, _AirService_loginResult, undefined);
3181
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
3182
3277
  }
3183
3278
  async cleanUp() {
3184
3279
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
@@ -3204,7 +3299,7 @@ class AirService {
3204
3299
  credentialId,
3205
3300
  credentialSubject,
3206
3301
  curve,
3207
- offchain
3302
+ waitForOnchainCompletion
3208
3303
  }) {
3209
3304
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3210
3305
  const response = await __classPrivateFieldGet$1(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
@@ -3213,7 +3308,7 @@ class AirService {
3213
3308
  credentialId,
3214
3309
  credentialSubject,
3215
3310
  curve,
3216
- offchain
3311
+ waitForOnchainCompletion
3217
3312
  });
3218
3313
  const {
3219
3314
  payload
@@ -3337,6 +3432,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3337
3432
  {
3338
3433
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").setIframeVisibility(message.payload.visible);
3339
3434
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").updateIframeState();
3435
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3340
3436
  break;
3341
3437
  }
3342
3438
  }
@@ -3436,6 +3532,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3436
3532
  const walletIframeController = __classPrivateFieldGet$1(this, _AirService_walletIframeController, "f");
3437
3533
  walletIframeController.setIframeVisibility(msg.payload.visible);
3438
3534
  walletIframeController.updateIframeState();
3535
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3439
3536
  break;
3440
3537
  }
3441
3538
  case AirWalletMessageTypes.WALLET_LOGIN_RESPONSE:
@@ -3503,15 +3600,19 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3503
3600
  event: "wallet_initialized",
3504
3601
  result
3505
3602
  });
3506
- }, _AirService_createLoginResult = function _AirService_createLoginResult(payload) {
3507
- return {
3508
- isLoggedIn: true,
3509
- id: payload.id,
3510
- abstractAccountAddress: payload.abstractAccountAddress,
3511
- abstractAccountAddresses: payload.abstractAccountAddresses,
3512
- token: payload.partnerAccessToken,
3513
- isMFASetup: payload.activeMfaMethods.length > 0
3514
- };
3603
+ }, _AirService_assignAndTriggerLoginResult = function _AirService_assignAndTriggerLoginResult(payload) {
3604
+ if (!__classPrivateFieldGet$1(this, _AirService_loginResult, "f")) {
3605
+ __classPrivateFieldSet(this, _AirService_loginResult, {
3606
+ isLoggedIn: true,
3607
+ id: payload.id,
3608
+ abstractAccountAddress: payload.abstractAccountAddress,
3609
+ abstractAccountAddresses: payload.abstractAccountAddresses,
3610
+ token: payload.partnerAccessToken,
3611
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3612
+ });
3613
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
3614
+ }
3615
+ return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3515
3616
  }, _AirService_createWalletInitializedResult = function _AirService_createWalletInitializedResult(payload) {
3516
3617
  if ("isWalletLoggedIn" in payload && !payload.isWalletLoggedIn) {
3517
3618
  return {
@@ -3521,7 +3622,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3521
3622
  }
3522
3623
  return {
3523
3624
  abstractAccountAddress: payload.addresses.aa,
3524
- isMFASetup: payload.activeMfaMethods.length > 0
3625
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3525
3626
  };
3526
3627
  }, _AirService_cleanUpAuth = async function _AirService_cleanUpAuth() {
3527
3628
  // Logout auth session
@@ -3613,6 +3714,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3613
3714
  const recoveryIframeController = __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f");
3614
3715
  recoveryIframeController.setIframeVisibility(message.payload.visible);
3615
3716
  recoveryIframeController.updateIframeState();
3717
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3616
3718
  break;
3617
3719
  }
3618
3720
  }
@@ -3629,6 +3731,14 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3629
3731
  // Close the message service
3630
3732
  await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").close();
3631
3733
  __classPrivateFieldSet(this, _AirService_recoveryInitialization, undefined);
3734
+ }, _AirService_refocusTopmostVisibleIframe = function _AirService_refocusTopmostVisibleIframe() {
3735
+ const candidates = [__classPrivateFieldGet$1(this, _AirService_walletIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_authIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f")];
3736
+ for (const controller of candidates) {
3737
+ if (controller?.isVisible) {
3738
+ controller.focus();
3739
+ return;
3740
+ }
3741
+ }
3632
3742
  };
3633
3743
 
3634
3744
  function isHex(value, {
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
92
92
  var e = new Error(message);
93
93
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
94
94
  };
95
- var version$2 = "1.9.0-beta.3";
95
+ var version$2 = "1.10.0";
96
96
  var airkitPackage = {
97
97
  version: version$2
98
98
  };
@@ -132,10 +132,23 @@ const AirAuthMessageTypes = {
132
132
  LOGOUT_RESPONSE: "air_auth_logout_response",
133
133
  START_RECOVERY_REQUEST: "air_start_recovery_request",
134
134
  START_RECOVERY_RESPONSE: "air_start_recovery_response",
135
+ // Dashboard intent posted by recovery-frontend's RecoveryEntryView when
136
+ // the user picks an action. Distinct from START_RECOVERY_REQUEST so that
137
+ // when auth-frontend forwards the actual START_RECOVERY_REQUEST onto the
138
+ // shared recovery channel, the local echo doesn't loop back into
139
+ // auth-frontend's own recovery-channel subscription.
140
+ START_RECOVERY_DASHBOARD_REQUEST: "air_start_recovery_dashboard_request",
135
141
  RECOVERY_REQUEST: "air_auth_recovery_request",
136
142
  RECOVERY_RESPONSE: "air_auth_recovery_response",
137
- ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_auth_issue_on_behalf_new_user_confirmation_request",
138
- ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_auth_issue_on_behalf_new_user_confirmation_response",
143
+ // Mid-flow signing RPCs for the RECOVER_ACCOUNT flow. The recovery
144
+ // private key never leaves recovery-frontend; auth-frontend asks for
145
+ // a signature each time it needs one (after collecting the new email
146
+ // for the canonical reset payload, and after the backend returns the
147
+ // Privy authorization payload to wallet-PATCH).
148
+ RECOVER_ACCOUNT_RESET_SIGNATURE_REQUEST: "air_auth_recover_account_reset_signature_request",
149
+ RECOVER_ACCOUNT_RESET_SIGNATURE_RESPONSE: "air_auth_recover_account_reset_signature_response",
150
+ RECOVER_ACCOUNT_AUTHORIZATION_SIGNATURE_REQUEST: "air_auth_recover_account_authorization_signature_request",
151
+ RECOVER_ACCOUNT_AUTHORIZATION_SIGNATURE_RESPONSE: "air_auth_recover_account_authorization_signature_response",
139
152
  REMOVE_SIGNER_SIGNATURE_REQUEST: "air_auth_remove_signer_signature_request",
140
153
  REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_auth_remove_signer_signature_response",
141
154
  RESET_WALLET_REQUEST: "air_auth_reset_wallet_request",
@@ -614,11 +627,11 @@ const BUILD_ENV = {
614
627
  const IFRAME_NAME_PREFIX_SET = ["air-wallet", "air-credential", "air-auth", "air-recovery"]; // order defines the z-index from highest to lowest
615
628
 
616
629
  const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
617
- const SANDBOX_TESTNET_URLS = {
618
- authUrl: "https://account.sandbox-testnet.air3.com/auth/",
619
- walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
620
- recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
621
- credentialUrl: "https://account.sandbox-testnet.air3.com/credential/"
630
+ const PRODUCTION_MAINNET_URLS = {
631
+ authUrl: "https://account-mainnet.air3.com/auth/",
632
+ walletUrl: "https://account-mainnet.air3.com/wallet/",
633
+ recoveryUrl: "https://account-mainnet.air3.com/recovery/",
634
+ credentialUrl: "https://account-mainnet.air3.com/credential/"
622
635
  };
623
636
  const AIR_URLS = {
624
637
  [BUILD_ENV.DEVELOPMENT]: {
@@ -640,10 +653,10 @@ const AIR_URLS = {
640
653
  credentialUrl: "https://account.uat.air3.com/credential/"
641
654
  },
642
655
  [BUILD_ENV.SANDBOX]: {
643
- authUrl: "https://account.sandbox.air3.com/auth/",
644
- walletUrl: "https://account.sandbox.air3.com/wallet/",
645
- recoveryUrl: "https://account.sandbox.air3.com/recovery/",
646
- credentialUrl: "https://account.sandbox.air3.com/credential/"
656
+ authUrl: "https://account.sandbox-testnet.air3.com/auth/",
657
+ walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
658
+ recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
659
+ credentialUrl: "https://account.sandbox-testnet.air3.com/credential/"
647
660
  },
648
661
  [BUILD_ENV.PRODUCTION]: {
649
662
  authUrl: "https://account.air3.com/auth/",
@@ -653,8 +666,8 @@ const AIR_URLS = {
653
666
  }
654
667
  };
655
668
  const getAirUrls = (buildEnv, credentialNetwork) => {
656
- if (buildEnv === BUILD_ENV.SANDBOX && credentialNetwork === "testnet") {
657
- return SANDBOX_TESTNET_URLS;
669
+ if (buildEnv === BUILD_ENV.PRODUCTION && credentialNetwork === "mainnet") {
670
+ return PRODUCTION_MAINNET_URLS;
658
671
  }
659
672
  return AIR_URLS[buildEnv];
660
673
  };
@@ -1533,6 +1546,41 @@ var AnonymousSubject = function (_super) {
1533
1546
  };
1534
1547
  return AnonymousSubject;
1535
1548
  }(Subject);
1549
+ var BehaviorSubject = function (_super) {
1550
+ __extends(BehaviorSubject, _super);
1551
+ function BehaviorSubject(_value) {
1552
+ var _this = _super.call(this) || this;
1553
+ _this._value = _value;
1554
+ return _this;
1555
+ }
1556
+ Object.defineProperty(BehaviorSubject.prototype, "value", {
1557
+ get: function () {
1558
+ return this.getValue();
1559
+ },
1560
+ enumerable: false,
1561
+ configurable: true
1562
+ });
1563
+ BehaviorSubject.prototype._subscribe = function (subscriber) {
1564
+ var subscription = _super.prototype._subscribe.call(this, subscriber);
1565
+ !subscription.closed && subscriber.next(this._value);
1566
+ return subscription;
1567
+ };
1568
+ BehaviorSubject.prototype.getValue = function () {
1569
+ var _a = this,
1570
+ hasError = _a.hasError,
1571
+ thrownError = _a.thrownError,
1572
+ _value = _a._value;
1573
+ if (hasError) {
1574
+ throw thrownError;
1575
+ }
1576
+ this._throwIfClosed();
1577
+ return _value;
1578
+ };
1579
+ BehaviorSubject.prototype.next = function (value) {
1580
+ _super.prototype.next.call(this, this._value = value);
1581
+ };
1582
+ return BehaviorSubject;
1583
+ }(Subject);
1536
1584
  var EmptyError = createErrorClass(function (_super) {
1537
1585
  return function EmptyErrorImpl() {
1538
1586
  _super(this);
@@ -1609,6 +1657,8 @@ var PartnerAccessTokenErrorName;
1609
1657
  (function (PartnerAccessTokenErrorName) {
1610
1658
  PartnerAccessTokenErrorName["PARTNER_ACCESS_TOKEN_INVALID"] = "PARTNER_ACCESS_TOKEN_INVALID";
1611
1659
  PartnerAccessTokenErrorName["USER_MISMATCH"] = "USER_MISMATCH";
1660
+ /** dApp-supplied partner JWT is past its `exp` — SDK consumers should mint a fresh one. */
1661
+ PartnerAccessTokenErrorName["PARTNER_TOKEN_EXPIRED"] = "PARTNER_TOKEN_EXPIRED";
1612
1662
  })(PartnerAccessTokenErrorName || (PartnerAccessTokenErrorName = {}));
1613
1663
  /*** Realm ID Errors ***/
1614
1664
  var RealmIDErrorName;
@@ -1679,6 +1729,12 @@ var PrivyErrorName;
1679
1729
  (function (PrivyErrorName) {
1680
1730
  PrivyErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1681
1731
  })(PrivyErrorName || (PrivyErrorName = {}));
1732
+ /*** Recovery Errors ***/
1733
+ var RecoveryErrorName;
1734
+ (function (RecoveryErrorName) {
1735
+ RecoveryErrorName["RECOVERY_NOT_CONFIGURED"] = "RECOVERY_NOT_CONFIGURED";
1736
+ RecoveryErrorName["RECOVERY_LOCK_EXCEEDED"] = "RECOVERY_LOCK_EXCEEDED";
1737
+ })(RecoveryErrorName || (RecoveryErrorName = {}));
1682
1738
  /*** Air ID Errors ***/
1683
1739
  var AirIDErrorName;
1684
1740
  (function (AirIDErrorName) {
@@ -1698,6 +1754,13 @@ var AirIDErrorName;
1698
1754
  AirIDErrorName["AIR_ID_INVALID_MINT_NAME"] = "AIR_ID_INVALID_MINT_NAME";
1699
1755
  AirIDErrorName["AIR_ID_MINT_TRANSACTION_HASH_MISMATCH"] = "AIR_ID_MINT_TRANSACTION_HASH_MISMATCH";
1700
1756
  })(AirIDErrorName || (AirIDErrorName = {}));
1757
+ /*** Agent Errors ***/
1758
+ var AgentErrorName;
1759
+ (function (AgentErrorName) {
1760
+ AgentErrorName["CONFLICT_REQUEST"] = "CONFLICT_REQUEST";
1761
+ AgentErrorName["INVALID_PARAMETER"] = "INVALID_PARAMETER";
1762
+ AgentErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1763
+ })(AgentErrorName || (AgentErrorName = {}));
1701
1764
  /*** Window Errors ***/
1702
1765
  var WindowErrorName;
1703
1766
  (function (WindowErrorName) {
@@ -1716,10 +1779,12 @@ const Codes = {
1716
1779
  ...WalletLinkErrorName,
1717
1780
  ...IntentErrorName,
1718
1781
  ...PrivyErrorName,
1782
+ ...RecoveryErrorName,
1719
1783
  ...AirIDErrorName,
1720
- ...WindowErrorName
1784
+ ...WindowErrorName,
1785
+ ...AgentErrorName
1721
1786
  };
1722
- 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"];
1787
+ 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", "START_PIN_RECOVERY"];
1723
1788
  class AirError extends BaseError$2 {}
1724
1789
  new Set(AirClientUserErrors);
1725
1790
  new Set(Object.values(Codes));
@@ -1732,12 +1797,18 @@ class MessageServiceBase {
1732
1797
  return this._messages$;
1733
1798
  }
1734
1799
  get isOpen() {
1735
- return !!this.closeListener;
1800
+ return this._isOpen$.value;
1801
+ }
1802
+ async waitUntilOpen() {
1803
+ if (this.isOpen) return;
1804
+ await firstValueFrom(this._isOpen$.pipe(filter(Boolean)));
1736
1805
  }
1737
1806
  constructor(name, allowedMessageTypes) {
1738
1807
  this.name = name;
1739
1808
  this.allowedMessageTypes = allowedMessageTypes;
1740
1809
  this.closeListener = null;
1810
+ this._isOpen$ = new BehaviorSubject(false);
1811
+ this.isOpen$ = this._isOpen$.asObservable();
1741
1812
  }
1742
1813
  static _getName(name, targetName) {
1743
1814
  return `${name} Service: ${targetName} Channel`;
@@ -1780,6 +1851,7 @@ class MessageServiceBase {
1780
1851
  window.removeEventListener("message", handleMessage);
1781
1852
  };
1782
1853
  }
1854
+ this._isOpen$.next(true);
1783
1855
  }
1784
1856
  isMessageAllowed(message) {
1785
1857
  return this.allowedMessageTypes.includes(message.type);
@@ -1796,6 +1868,7 @@ class MessageServiceBase {
1796
1868
  if (this.eventSubject && !this.eventSubject.closed) {
1797
1869
  this.eventSubject.complete();
1798
1870
  }
1871
+ if (this._isOpen$.value) this._isOpen$.next(false);
1799
1872
  }
1800
1873
  createErrorResponseMessage(type, error) {
1801
1874
  return {
@@ -2140,7 +2213,7 @@ class AuthMessageService extends MessageServiceBase {
2140
2213
  const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.START_RECOVERY_RESPONSE)));
2141
2214
  await this.sendMessage({
2142
2215
  type: AirAuthMessageTypes.START_RECOVERY_REQUEST,
2143
- payload
2216
+ payload: payload ?? {}
2144
2217
  });
2145
2218
  return response;
2146
2219
  }
@@ -2232,11 +2305,14 @@ class IframeController {
2232
2305
  get iframeElement() {
2233
2306
  return this._iframeElement;
2234
2307
  }
2308
+ get isVisible() {
2309
+ return this.state.isVisible;
2310
+ }
2235
2311
  createIframe() {
2236
2312
  if (this._iframeElement) return this._iframeElement;
2237
2313
  const iframe = document.createElement("iframe");
2238
2314
  iframe.id = this.iframeId;
2239
- iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version", "clipboard-write", "web-share"].join("; ");
2315
+ iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version", "clipboard-read", "clipboard-write", "web-share"].join("; ");
2240
2316
  iframe.src = this.iframeUrl;
2241
2317
  iframe.style.position = "fixed";
2242
2318
  iframe.style.zIndex = `${this.getZIndex()}`;
@@ -2271,6 +2347,15 @@ class IframeController {
2271
2347
  style.bottom = "0px";
2272
2348
  Object.assign(this.iframeElement.style, style);
2273
2349
  }
2350
+ focus() {
2351
+ try {
2352
+ this.iframeElement?.contentWindow?.focus();
2353
+ } catch {
2354
+ // Some browsers reject cross-origin focus() outside a user gesture.
2355
+ // The first interaction inside the iframe will restore the correct
2356
+ // keyboard routing, so swallowing this is safe.
2357
+ }
2358
+ }
2274
2359
  destroy() {
2275
2360
  if (this.iframeElement) {
2276
2361
  this.iframeElement.remove();
@@ -2729,7 +2814,7 @@ class WindowService {
2729
2814
  }
2730
2815
  }
2731
2816
  var WindowService$1 = WindowService.instance;
2732
- var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_sessionId, _AirService_sessionConfig, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airEventListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _AirService_credentialNetwork, _AirService_assertInitialized, _AirService_assertLoggedIn, _AirService_ensureCredential, _AirService_initializeCredentials, _AirService_subscribeToCredentialEvents, _AirService_cleanUpCredential, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_subscribeToWalletEvents, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_createLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet, _AirService_ensureRecovery, _AirService_initializeRecovery, _AirService_subscribeToRecoveryEvents, _AirService_cleanUpRecovery;
2817
+ var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_sessionId, _AirService_sessionConfig, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airEventListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _AirService_credentialNetwork, _AirService_assertInitialized, _AirService_assertLoggedIn, _AirService_ensureCredential, _AirService_initializeCredentials, _AirService_subscribeToCredentialEvents, _AirService_cleanUpCredential, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_subscribeToWalletEvents, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_assignAndTriggerLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet, _AirService_ensureRecovery, _AirService_initializeRecovery, _AirService_subscribeToRecoveryEvents, _AirService_cleanUpRecovery, _AirService_refocusTopmostVisibleIframe;
2733
2818
  const airKitVersion = airkitPackage.version;
2734
2819
  class AirService {
2735
2820
  constructor({
@@ -2807,11 +2892,11 @@ class AirService {
2807
2892
  sessionConfig = undefined,
2808
2893
  preloadWallet = false,
2809
2894
  preloadCredential = false,
2810
- credentialNetwork = "devnet"
2895
+ credentialNetwork
2811
2896
  } = config;
2812
2897
  if (!__classPrivateFieldGet$1(this, _AirService_partnerId, "f")) throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2813
2898
  if (__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) return __classPrivateFieldGet$1(this, _AirService_loginResult, "f") ?? null;
2814
- __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.SANDBOX ? credentialNetwork : undefined);
2899
+ __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.PRODUCTION ? credentialNetwork : undefined);
2815
2900
  configureLogLevel(buildEnv, enableLogging);
2816
2901
  const {
2817
2902
  authUrl,
@@ -2842,6 +2927,7 @@ class AirService {
2842
2927
  const authIframeController = __classPrivateFieldGet$1(this, _AirService_authIframeController, "f");
2843
2928
  authIframeController.setIframeVisibility(msg.payload.visible);
2844
2929
  authIframeController.updateIframeState();
2930
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
2845
2931
  break;
2846
2932
  }
2847
2933
  case AirAuthMessageTypes.SETUP_WALLET_REQUEST:
@@ -2884,6 +2970,20 @@ class AirService {
2884
2970
  await this.logout();
2885
2971
  break;
2886
2972
  }
2973
+ case AirAuthMessageTypes.LOGIN_RESPONSE:
2974
+ {
2975
+ if (msg.payload.success === true) {
2976
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, msg.payload);
2977
+ }
2978
+ break;
2979
+ }
2980
+ case AirAuthMessageTypes.LOGOUT_RESPONSE:
2981
+ {
2982
+ const wasLoggedIn = !!__classPrivateFieldGet$1(this, _AirService_loginResult, "f");
2983
+ __classPrivateFieldSet(this, _AirService_loginResult, undefined, "f");
2984
+ if (wasLoggedIn) __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
2985
+ break;
2986
+ }
2887
2987
  }
2888
2988
  });
2889
2989
  const result = await new Promise((resolve, reject) => {
@@ -2920,9 +3020,7 @@ class AirService {
2920
3020
  if (preloadCredential) void this.preloadCredential();
2921
3021
  // rehydrated auth session
2922
3022
  if (result.rehydrated) {
2923
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
2924
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2925
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3023
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, result);
2926
3024
  }
2927
3025
  } catch (error) {
2928
3026
  log$1.debug("Error initializing auth service", error);
@@ -2940,9 +3038,7 @@ class AirService {
2940
3038
  partnerLoginToken: options?.authToken
2941
3039
  });
2942
3040
  if (payload.success === true) {
2943
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload));
2944
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2945
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3041
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, payload);
2946
3042
  }
2947
3043
  throw new AirServiceError(payload.errorName, payload.errorMessage);
2948
3044
  }
@@ -3111,7 +3207,8 @@ class AirService {
3111
3207
  id: info.payload.user.id,
3112
3208
  abstractAccountAddress: info.payload.user.abstractAccountAddress,
3113
3209
  email: info.payload.user.email,
3114
- isMFASetup: info.payload.user.activeMfaMethods.length > 0
3210
+ wallet: info.payload.user.wallet,
3211
+ isMFASetup: (info.payload.user.activeMfaMethods?.length ?? 0) > 0
3115
3212
  }
3116
3213
  };
3117
3214
  }
@@ -3175,8 +3272,6 @@ class AirService {
3175
3272
  // Clear up credentials first to avoid issues with wallet and auth messaging services
3176
3273
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
3177
3274
  await Promise.all([__classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this), __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this), __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").logout()]);
3178
- __classPrivateFieldSet(this, _AirService_loginResult, undefined);
3179
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
3180
3275
  }
3181
3276
  async cleanUp() {
3182
3277
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
@@ -3202,7 +3297,7 @@ class AirService {
3202
3297
  credentialId,
3203
3298
  credentialSubject,
3204
3299
  curve,
3205
- offchain
3300
+ waitForOnchainCompletion
3206
3301
  }) {
3207
3302
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3208
3303
  const response = await __classPrivateFieldGet$1(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
@@ -3211,7 +3306,7 @@ class AirService {
3211
3306
  credentialId,
3212
3307
  credentialSubject,
3213
3308
  curve,
3214
- offchain
3309
+ waitForOnchainCompletion
3215
3310
  });
3216
3311
  const {
3217
3312
  payload
@@ -3335,6 +3430,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3335
3430
  {
3336
3431
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").setIframeVisibility(message.payload.visible);
3337
3432
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").updateIframeState();
3433
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3338
3434
  break;
3339
3435
  }
3340
3436
  }
@@ -3434,6 +3530,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3434
3530
  const walletIframeController = __classPrivateFieldGet$1(this, _AirService_walletIframeController, "f");
3435
3531
  walletIframeController.setIframeVisibility(msg.payload.visible);
3436
3532
  walletIframeController.updateIframeState();
3533
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3437
3534
  break;
3438
3535
  }
3439
3536
  case AirWalletMessageTypes.WALLET_LOGIN_RESPONSE:
@@ -3501,15 +3598,19 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3501
3598
  event: "wallet_initialized",
3502
3599
  result
3503
3600
  });
3504
- }, _AirService_createLoginResult = function _AirService_createLoginResult(payload) {
3505
- return {
3506
- isLoggedIn: true,
3507
- id: payload.id,
3508
- abstractAccountAddress: payload.abstractAccountAddress,
3509
- abstractAccountAddresses: payload.abstractAccountAddresses,
3510
- token: payload.partnerAccessToken,
3511
- isMFASetup: payload.activeMfaMethods.length > 0
3512
- };
3601
+ }, _AirService_assignAndTriggerLoginResult = function _AirService_assignAndTriggerLoginResult(payload) {
3602
+ if (!__classPrivateFieldGet$1(this, _AirService_loginResult, "f")) {
3603
+ __classPrivateFieldSet(this, _AirService_loginResult, {
3604
+ isLoggedIn: true,
3605
+ id: payload.id,
3606
+ abstractAccountAddress: payload.abstractAccountAddress,
3607
+ abstractAccountAddresses: payload.abstractAccountAddresses,
3608
+ token: payload.partnerAccessToken,
3609
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3610
+ });
3611
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
3612
+ }
3613
+ return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3513
3614
  }, _AirService_createWalletInitializedResult = function _AirService_createWalletInitializedResult(payload) {
3514
3615
  if ("isWalletLoggedIn" in payload && !payload.isWalletLoggedIn) {
3515
3616
  return {
@@ -3519,7 +3620,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3519
3620
  }
3520
3621
  return {
3521
3622
  abstractAccountAddress: payload.addresses.aa,
3522
- isMFASetup: payload.activeMfaMethods.length > 0
3623
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3523
3624
  };
3524
3625
  }, _AirService_cleanUpAuth = async function _AirService_cleanUpAuth() {
3525
3626
  // Logout auth session
@@ -3611,6 +3712,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3611
3712
  const recoveryIframeController = __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f");
3612
3713
  recoveryIframeController.setIframeVisibility(message.payload.visible);
3613
3714
  recoveryIframeController.updateIframeState();
3715
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3614
3716
  break;
3615
3717
  }
3616
3718
  }
@@ -3627,6 +3729,14 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3627
3729
  // Close the message service
3628
3730
  await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").close();
3629
3731
  __classPrivateFieldSet(this, _AirService_recoveryInitialization, undefined);
3732
+ }, _AirService_refocusTopmostVisibleIframe = function _AirService_refocusTopmostVisibleIframe() {
3733
+ const candidates = [__classPrivateFieldGet$1(this, _AirService_walletIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_authIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f")];
3734
+ for (const controller of candidates) {
3735
+ if (controller?.isVisible) {
3736
+ controller.focus();
3737
+ return;
3738
+ }
3739
+ }
3630
3740
  };
3631
3741
 
3632
3742
  function isHex(value, {
@@ -98,7 +98,7 @@
98
98
  var e = new Error(message);
99
99
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
100
100
  };
101
- var version$2 = "1.9.0-beta.3";
101
+ var version$2 = "1.10.0";
102
102
  var airkitPackage = {
103
103
  version: version$2
104
104
  };
@@ -138,10 +138,23 @@
138
138
  LOGOUT_RESPONSE: "air_auth_logout_response",
139
139
  START_RECOVERY_REQUEST: "air_start_recovery_request",
140
140
  START_RECOVERY_RESPONSE: "air_start_recovery_response",
141
+ // Dashboard intent posted by recovery-frontend's RecoveryEntryView when
142
+ // the user picks an action. Distinct from START_RECOVERY_REQUEST so that
143
+ // when auth-frontend forwards the actual START_RECOVERY_REQUEST onto the
144
+ // shared recovery channel, the local echo doesn't loop back into
145
+ // auth-frontend's own recovery-channel subscription.
146
+ START_RECOVERY_DASHBOARD_REQUEST: "air_start_recovery_dashboard_request",
141
147
  RECOVERY_REQUEST: "air_auth_recovery_request",
142
148
  RECOVERY_RESPONSE: "air_auth_recovery_response",
143
- ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_REQUEST: "air_auth_issue_on_behalf_new_user_confirmation_request",
144
- ISSUE_ON_BEHALF_NEW_USER_CONFIRMATION_RESPONSE: "air_auth_issue_on_behalf_new_user_confirmation_response",
149
+ // Mid-flow signing RPCs for the RECOVER_ACCOUNT flow. The recovery
150
+ // private key never leaves recovery-frontend; auth-frontend asks for
151
+ // a signature each time it needs one (after collecting the new email
152
+ // for the canonical reset payload, and after the backend returns the
153
+ // Privy authorization payload to wallet-PATCH).
154
+ RECOVER_ACCOUNT_RESET_SIGNATURE_REQUEST: "air_auth_recover_account_reset_signature_request",
155
+ RECOVER_ACCOUNT_RESET_SIGNATURE_RESPONSE: "air_auth_recover_account_reset_signature_response",
156
+ RECOVER_ACCOUNT_AUTHORIZATION_SIGNATURE_REQUEST: "air_auth_recover_account_authorization_signature_request",
157
+ RECOVER_ACCOUNT_AUTHORIZATION_SIGNATURE_RESPONSE: "air_auth_recover_account_authorization_signature_response",
145
158
  REMOVE_SIGNER_SIGNATURE_REQUEST: "air_auth_remove_signer_signature_request",
146
159
  REMOVE_SIGNER_SIGNATURE_RESPONSE: "air_auth_remove_signer_signature_response",
147
160
  RESET_WALLET_REQUEST: "air_auth_reset_wallet_request",
@@ -620,11 +633,11 @@
620
633
  const IFRAME_NAME_PREFIX_SET = ["air-wallet", "air-credential", "air-auth", "air-recovery"]; // order defines the z-index from highest to lowest
621
634
 
622
635
  const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
623
- const SANDBOX_TESTNET_URLS = {
624
- authUrl: "https://account.sandbox-testnet.air3.com/auth/",
625
- walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
626
- recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
627
- credentialUrl: "https://account.sandbox-testnet.air3.com/credential/"
636
+ const PRODUCTION_MAINNET_URLS = {
637
+ authUrl: "https://account-mainnet.air3.com/auth/",
638
+ walletUrl: "https://account-mainnet.air3.com/wallet/",
639
+ recoveryUrl: "https://account-mainnet.air3.com/recovery/",
640
+ credentialUrl: "https://account-mainnet.air3.com/credential/"
628
641
  };
629
642
  const AIR_URLS = {
630
643
  [BUILD_ENV.DEVELOPMENT]: {
@@ -646,10 +659,10 @@
646
659
  credentialUrl: "https://account.uat.air3.com/credential/"
647
660
  },
648
661
  [BUILD_ENV.SANDBOX]: {
649
- authUrl: "https://account.sandbox.air3.com/auth/",
650
- walletUrl: "https://account.sandbox.air3.com/wallet/",
651
- recoveryUrl: "https://account.sandbox.air3.com/recovery/",
652
- credentialUrl: "https://account.sandbox.air3.com/credential/"
662
+ authUrl: "https://account.sandbox-testnet.air3.com/auth/",
663
+ walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
664
+ recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
665
+ credentialUrl: "https://account.sandbox-testnet.air3.com/credential/"
653
666
  },
654
667
  [BUILD_ENV.PRODUCTION]: {
655
668
  authUrl: "https://account.air3.com/auth/",
@@ -659,8 +672,8 @@
659
672
  }
660
673
  };
661
674
  const getAirUrls = (buildEnv, credentialNetwork) => {
662
- if (buildEnv === BUILD_ENV.SANDBOX && credentialNetwork === "testnet") {
663
- return SANDBOX_TESTNET_URLS;
675
+ if (buildEnv === BUILD_ENV.PRODUCTION && credentialNetwork === "mainnet") {
676
+ return PRODUCTION_MAINNET_URLS;
664
677
  }
665
678
  return AIR_URLS[buildEnv];
666
679
  };
@@ -1539,6 +1552,41 @@
1539
1552
  };
1540
1553
  return AnonymousSubject;
1541
1554
  }(Subject);
1555
+ var BehaviorSubject = function (_super) {
1556
+ __extends(BehaviorSubject, _super);
1557
+ function BehaviorSubject(_value) {
1558
+ var _this = _super.call(this) || this;
1559
+ _this._value = _value;
1560
+ return _this;
1561
+ }
1562
+ Object.defineProperty(BehaviorSubject.prototype, "value", {
1563
+ get: function () {
1564
+ return this.getValue();
1565
+ },
1566
+ enumerable: false,
1567
+ configurable: true
1568
+ });
1569
+ BehaviorSubject.prototype._subscribe = function (subscriber) {
1570
+ var subscription = _super.prototype._subscribe.call(this, subscriber);
1571
+ !subscription.closed && subscriber.next(this._value);
1572
+ return subscription;
1573
+ };
1574
+ BehaviorSubject.prototype.getValue = function () {
1575
+ var _a = this,
1576
+ hasError = _a.hasError,
1577
+ thrownError = _a.thrownError,
1578
+ _value = _a._value;
1579
+ if (hasError) {
1580
+ throw thrownError;
1581
+ }
1582
+ this._throwIfClosed();
1583
+ return _value;
1584
+ };
1585
+ BehaviorSubject.prototype.next = function (value) {
1586
+ _super.prototype.next.call(this, this._value = value);
1587
+ };
1588
+ return BehaviorSubject;
1589
+ }(Subject);
1542
1590
  var EmptyError = createErrorClass(function (_super) {
1543
1591
  return function EmptyErrorImpl() {
1544
1592
  _super(this);
@@ -1615,6 +1663,8 @@
1615
1663
  (function (PartnerAccessTokenErrorName) {
1616
1664
  PartnerAccessTokenErrorName["PARTNER_ACCESS_TOKEN_INVALID"] = "PARTNER_ACCESS_TOKEN_INVALID";
1617
1665
  PartnerAccessTokenErrorName["USER_MISMATCH"] = "USER_MISMATCH";
1666
+ /** dApp-supplied partner JWT is past its `exp` — SDK consumers should mint a fresh one. */
1667
+ PartnerAccessTokenErrorName["PARTNER_TOKEN_EXPIRED"] = "PARTNER_TOKEN_EXPIRED";
1618
1668
  })(PartnerAccessTokenErrorName || (PartnerAccessTokenErrorName = {}));
1619
1669
  /*** Realm ID Errors ***/
1620
1670
  var RealmIDErrorName;
@@ -1685,6 +1735,12 @@
1685
1735
  (function (PrivyErrorName) {
1686
1736
  PrivyErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1687
1737
  })(PrivyErrorName || (PrivyErrorName = {}));
1738
+ /*** Recovery Errors ***/
1739
+ var RecoveryErrorName;
1740
+ (function (RecoveryErrorName) {
1741
+ RecoveryErrorName["RECOVERY_NOT_CONFIGURED"] = "RECOVERY_NOT_CONFIGURED";
1742
+ RecoveryErrorName["RECOVERY_LOCK_EXCEEDED"] = "RECOVERY_LOCK_EXCEEDED";
1743
+ })(RecoveryErrorName || (RecoveryErrorName = {}));
1688
1744
  /*** Air ID Errors ***/
1689
1745
  var AirIDErrorName;
1690
1746
  (function (AirIDErrorName) {
@@ -1704,6 +1760,13 @@
1704
1760
  AirIDErrorName["AIR_ID_INVALID_MINT_NAME"] = "AIR_ID_INVALID_MINT_NAME";
1705
1761
  AirIDErrorName["AIR_ID_MINT_TRANSACTION_HASH_MISMATCH"] = "AIR_ID_MINT_TRANSACTION_HASH_MISMATCH";
1706
1762
  })(AirIDErrorName || (AirIDErrorName = {}));
1763
+ /*** Agent Errors ***/
1764
+ var AgentErrorName;
1765
+ (function (AgentErrorName) {
1766
+ AgentErrorName["CONFLICT_REQUEST"] = "CONFLICT_REQUEST";
1767
+ AgentErrorName["INVALID_PARAMETER"] = "INVALID_PARAMETER";
1768
+ AgentErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1769
+ })(AgentErrorName || (AgentErrorName = {}));
1707
1770
  /*** Window Errors ***/
1708
1771
  var WindowErrorName;
1709
1772
  (function (WindowErrorName) {
@@ -1722,10 +1785,12 @@
1722
1785
  ...WalletLinkErrorName,
1723
1786
  ...IntentErrorName,
1724
1787
  ...PrivyErrorName,
1788
+ ...RecoveryErrorName,
1725
1789
  ...AirIDErrorName,
1726
- ...WindowErrorName
1790
+ ...WindowErrorName,
1791
+ ...AgentErrorName
1727
1792
  };
1728
- 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"];
1793
+ 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", "START_PIN_RECOVERY"];
1729
1794
  class AirError extends BaseError$2 {}
1730
1795
  new Set(AirClientUserErrors);
1731
1796
  new Set(Object.values(Codes));
@@ -1738,12 +1803,18 @@
1738
1803
  return this._messages$;
1739
1804
  }
1740
1805
  get isOpen() {
1741
- return !!this.closeListener;
1806
+ return this._isOpen$.value;
1807
+ }
1808
+ async waitUntilOpen() {
1809
+ if (this.isOpen) return;
1810
+ await firstValueFrom(this._isOpen$.pipe(filter(Boolean)));
1742
1811
  }
1743
1812
  constructor(name, allowedMessageTypes) {
1744
1813
  this.name = name;
1745
1814
  this.allowedMessageTypes = allowedMessageTypes;
1746
1815
  this.closeListener = null;
1816
+ this._isOpen$ = new BehaviorSubject(false);
1817
+ this.isOpen$ = this._isOpen$.asObservable();
1747
1818
  }
1748
1819
  static _getName(name, targetName) {
1749
1820
  return `${name} Service: ${targetName} Channel`;
@@ -1786,6 +1857,7 @@
1786
1857
  window.removeEventListener("message", handleMessage);
1787
1858
  };
1788
1859
  }
1860
+ this._isOpen$.next(true);
1789
1861
  }
1790
1862
  isMessageAllowed(message) {
1791
1863
  return this.allowedMessageTypes.includes(message.type);
@@ -1802,6 +1874,7 @@
1802
1874
  if (this.eventSubject && !this.eventSubject.closed) {
1803
1875
  this.eventSubject.complete();
1804
1876
  }
1877
+ if (this._isOpen$.value) this._isOpen$.next(false);
1805
1878
  }
1806
1879
  createErrorResponseMessage(type, error) {
1807
1880
  return {
@@ -2146,7 +2219,7 @@
2146
2219
  const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.START_RECOVERY_RESPONSE)));
2147
2220
  await this.sendMessage({
2148
2221
  type: AirAuthMessageTypes.START_RECOVERY_REQUEST,
2149
- payload
2222
+ payload: payload ?? {}
2150
2223
  });
2151
2224
  return response;
2152
2225
  }
@@ -2238,11 +2311,14 @@
2238
2311
  get iframeElement() {
2239
2312
  return this._iframeElement;
2240
2313
  }
2314
+ get isVisible() {
2315
+ return this.state.isVisible;
2316
+ }
2241
2317
  createIframe() {
2242
2318
  if (this._iframeElement) return this._iframeElement;
2243
2319
  const iframe = document.createElement("iframe");
2244
2320
  iframe.id = this.iframeId;
2245
- iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version", "clipboard-write", "web-share"].join("; ");
2321
+ iframe.allow = ["publickey-credentials-get *", "publickey-credentials-create *", "ch-ua-model", "ch-ua-platform-version", "clipboard-read", "clipboard-write", "web-share"].join("; ");
2246
2322
  iframe.src = this.iframeUrl;
2247
2323
  iframe.style.position = "fixed";
2248
2324
  iframe.style.zIndex = `${this.getZIndex()}`;
@@ -2277,6 +2353,15 @@
2277
2353
  style.bottom = "0px";
2278
2354
  Object.assign(this.iframeElement.style, style);
2279
2355
  }
2356
+ focus() {
2357
+ try {
2358
+ this.iframeElement?.contentWindow?.focus();
2359
+ } catch {
2360
+ // Some browsers reject cross-origin focus() outside a user gesture.
2361
+ // The first interaction inside the iframe will restore the correct
2362
+ // keyboard routing, so swallowing this is safe.
2363
+ }
2364
+ }
2280
2365
  destroy() {
2281
2366
  if (this.iframeElement) {
2282
2367
  this.iframeElement.remove();
@@ -2735,7 +2820,7 @@
2735
2820
  }
2736
2821
  }
2737
2822
  var WindowService$1 = WindowService.instance;
2738
- var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_sessionId, _AirService_sessionConfig, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airEventListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _AirService_credentialNetwork, _AirService_assertInitialized, _AirService_assertLoggedIn, _AirService_ensureCredential, _AirService_initializeCredentials, _AirService_subscribeToCredentialEvents, _AirService_cleanUpCredential, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_subscribeToWalletEvents, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_createLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet, _AirService_ensureRecovery, _AirService_initializeRecovery, _AirService_subscribeToRecoveryEvents, _AirService_cleanUpRecovery;
2823
+ var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_sessionId, _AirService_sessionConfig, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airEventListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _AirService_credentialNetwork, _AirService_assertInitialized, _AirService_assertLoggedIn, _AirService_ensureCredential, _AirService_initializeCredentials, _AirService_subscribeToCredentialEvents, _AirService_cleanUpCredential, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_subscribeToWalletEvents, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_assignAndTriggerLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet, _AirService_ensureRecovery, _AirService_initializeRecovery, _AirService_subscribeToRecoveryEvents, _AirService_cleanUpRecovery, _AirService_refocusTopmostVisibleIframe;
2739
2824
  const airKitVersion = airkitPackage.version;
2740
2825
  class AirService {
2741
2826
  constructor({
@@ -2813,11 +2898,11 @@
2813
2898
  sessionConfig = undefined,
2814
2899
  preloadWallet = false,
2815
2900
  preloadCredential = false,
2816
- credentialNetwork = "devnet"
2901
+ credentialNetwork
2817
2902
  } = config;
2818
2903
  if (!__classPrivateFieldGet$1(this, _AirService_partnerId, "f")) throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2819
2904
  if (__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) return __classPrivateFieldGet$1(this, _AirService_loginResult, "f") ?? null;
2820
- __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.SANDBOX ? credentialNetwork : undefined);
2905
+ __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.PRODUCTION ? credentialNetwork : undefined);
2821
2906
  configureLogLevel(buildEnv, enableLogging);
2822
2907
  const {
2823
2908
  authUrl,
@@ -2848,6 +2933,7 @@
2848
2933
  const authIframeController = __classPrivateFieldGet$1(this, _AirService_authIframeController, "f");
2849
2934
  authIframeController.setIframeVisibility(msg.payload.visible);
2850
2935
  authIframeController.updateIframeState();
2936
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
2851
2937
  break;
2852
2938
  }
2853
2939
  case AirAuthMessageTypes.SETUP_WALLET_REQUEST:
@@ -2890,6 +2976,20 @@
2890
2976
  await this.logout();
2891
2977
  break;
2892
2978
  }
2979
+ case AirAuthMessageTypes.LOGIN_RESPONSE:
2980
+ {
2981
+ if (msg.payload.success === true) {
2982
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, msg.payload);
2983
+ }
2984
+ break;
2985
+ }
2986
+ case AirAuthMessageTypes.LOGOUT_RESPONSE:
2987
+ {
2988
+ const wasLoggedIn = !!__classPrivateFieldGet$1(this, _AirService_loginResult, "f");
2989
+ __classPrivateFieldSet(this, _AirService_loginResult, undefined, "f");
2990
+ if (wasLoggedIn) __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
2991
+ break;
2992
+ }
2893
2993
  }
2894
2994
  });
2895
2995
  const result = await new Promise((resolve, reject) => {
@@ -2926,9 +3026,7 @@
2926
3026
  if (preloadCredential) void this.preloadCredential();
2927
3027
  // rehydrated auth session
2928
3028
  if (result.rehydrated) {
2929
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
2930
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2931
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3029
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, result);
2932
3030
  }
2933
3031
  } catch (error) {
2934
3032
  log$1.debug("Error initializing auth service", error);
@@ -2946,9 +3044,7 @@
2946
3044
  partnerLoginToken: options?.authToken
2947
3045
  });
2948
3046
  if (payload.success === true) {
2949
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload));
2950
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2951
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3047
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, payload);
2952
3048
  }
2953
3049
  throw new AirServiceError(payload.errorName, payload.errorMessage);
2954
3050
  }
@@ -3117,7 +3213,8 @@
3117
3213
  id: info.payload.user.id,
3118
3214
  abstractAccountAddress: info.payload.user.abstractAccountAddress,
3119
3215
  email: info.payload.user.email,
3120
- isMFASetup: info.payload.user.activeMfaMethods.length > 0
3216
+ wallet: info.payload.user.wallet,
3217
+ isMFASetup: (info.payload.user.activeMfaMethods?.length ?? 0) > 0
3121
3218
  }
3122
3219
  };
3123
3220
  }
@@ -3181,8 +3278,6 @@
3181
3278
  // Clear up credentials first to avoid issues with wallet and auth messaging services
3182
3279
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
3183
3280
  await Promise.all([__classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this), __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this), __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").logout()]);
3184
- __classPrivateFieldSet(this, _AirService_loginResult, undefined);
3185
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
3186
3281
  }
3187
3282
  async cleanUp() {
3188
3283
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
@@ -3208,7 +3303,7 @@
3208
3303
  credentialId,
3209
3304
  credentialSubject,
3210
3305
  curve,
3211
- offchain
3306
+ waitForOnchainCompletion
3212
3307
  }) {
3213
3308
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3214
3309
  const response = await __classPrivateFieldGet$1(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
@@ -3217,7 +3312,7 @@
3217
3312
  credentialId,
3218
3313
  credentialSubject,
3219
3314
  curve,
3220
- offchain
3315
+ waitForOnchainCompletion
3221
3316
  });
3222
3317
  const {
3223
3318
  payload
@@ -3341,6 +3436,7 @@
3341
3436
  {
3342
3437
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").setIframeVisibility(message.payload.visible);
3343
3438
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").updateIframeState();
3439
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3344
3440
  break;
3345
3441
  }
3346
3442
  }
@@ -3440,6 +3536,7 @@
3440
3536
  const walletIframeController = __classPrivateFieldGet$1(this, _AirService_walletIframeController, "f");
3441
3537
  walletIframeController.setIframeVisibility(msg.payload.visible);
3442
3538
  walletIframeController.updateIframeState();
3539
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3443
3540
  break;
3444
3541
  }
3445
3542
  case AirWalletMessageTypes.WALLET_LOGIN_RESPONSE:
@@ -3507,15 +3604,19 @@
3507
3604
  event: "wallet_initialized",
3508
3605
  result
3509
3606
  });
3510
- }, _AirService_createLoginResult = function _AirService_createLoginResult(payload) {
3511
- return {
3512
- isLoggedIn: true,
3513
- id: payload.id,
3514
- abstractAccountAddress: payload.abstractAccountAddress,
3515
- abstractAccountAddresses: payload.abstractAccountAddresses,
3516
- token: payload.partnerAccessToken,
3517
- isMFASetup: payload.activeMfaMethods.length > 0
3518
- };
3607
+ }, _AirService_assignAndTriggerLoginResult = function _AirService_assignAndTriggerLoginResult(payload) {
3608
+ if (!__classPrivateFieldGet$1(this, _AirService_loginResult, "f")) {
3609
+ __classPrivateFieldSet(this, _AirService_loginResult, {
3610
+ isLoggedIn: true,
3611
+ id: payload.id,
3612
+ abstractAccountAddress: payload.abstractAccountAddress,
3613
+ abstractAccountAddresses: payload.abstractAccountAddresses,
3614
+ token: payload.partnerAccessToken,
3615
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3616
+ });
3617
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
3618
+ }
3619
+ return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3519
3620
  }, _AirService_createWalletInitializedResult = function _AirService_createWalletInitializedResult(payload) {
3520
3621
  if ("isWalletLoggedIn" in payload && !payload.isWalletLoggedIn) {
3521
3622
  return {
@@ -3525,7 +3626,7 @@
3525
3626
  }
3526
3627
  return {
3527
3628
  abstractAccountAddress: payload.addresses.aa,
3528
- isMFASetup: payload.activeMfaMethods.length > 0
3629
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3529
3630
  };
3530
3631
  }, _AirService_cleanUpAuth = async function _AirService_cleanUpAuth() {
3531
3632
  // Logout auth session
@@ -3617,6 +3718,7 @@
3617
3718
  const recoveryIframeController = __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f");
3618
3719
  recoveryIframeController.setIframeVisibility(message.payload.visible);
3619
3720
  recoveryIframeController.updateIframeState();
3721
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3620
3722
  break;
3621
3723
  }
3622
3724
  }
@@ -3633,6 +3735,14 @@
3633
3735
  // Close the message service
3634
3736
  await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").close();
3635
3737
  __classPrivateFieldSet(this, _AirService_recoveryInitialization, undefined);
3738
+ }, _AirService_refocusTopmostVisibleIframe = function _AirService_refocusTopmostVisibleIframe() {
3739
+ const candidates = [__classPrivateFieldGet$1(this, _AirService_walletIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_authIframeController, "f"), __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f")];
3740
+ for (const controller of candidates) {
3741
+ if (controller?.isVisible) {
3742
+ controller.focus();
3743
+ return;
3744
+ }
3745
+ }
3636
3746
  };
3637
3747
 
3638
3748
  function isHex(value, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mocanetwork/airkit-connector",
3
- "version": "1.9.0-beta.3",
3
+ "version": "1.10.0",
4
4
  "description": "AirKit wagmi connector to connect with the AirService",
5
5
  "main": "dist/airkitConnector.cjs.js",
6
6
  "unpkg": "dist/airkitConnector.umd.min.js",
@@ -24,7 +24,7 @@
24
24
  "check-circular": "madge -c --ts-config=tsconfig.json --extensions ts ./src"
25
25
  },
26
26
  "dependencies": {
27
- "@mocanetwork/airkit": "^1.9.0-beta.3",
27
+ "@mocanetwork/airkit": "^1.10.0",
28
28
  "@wagmi/core": "^2.x",
29
29
  "loglevel": "^1.8.1",
30
30
  "viem": "^2.x"