@mocanetwork/airkit-connector 1.9.0-beta.2 → 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.
@@ -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.2";
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",
@@ -170,6 +183,12 @@ const AirRecoveryMessageTypes = {
170
183
  RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
171
184
  UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
172
185
  UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
186
+ GET_AGENT_KEYS_REQUEST: "air_recovery_get_agent_keys_request",
187
+ GET_AGENT_KEYS_RESPONSE: "air_recovery_get_agent_keys_response",
188
+ REGISTER_AGENT_KEY_REQUEST: "air_recovery_register_agent_key_request",
189
+ REGISTER_AGENT_KEY_RESPONSE: "air_recovery_register_agent_key_response",
190
+ REMOVE_AGENT_KEY_REQUEST: "air_recovery_remove_agent_key_request",
191
+ REMOVE_AGENT_KEY_RESPONSE: "air_recovery_remove_agent_key_response",
173
192
  LOGOUT_REQUEST: "air_recovery_logout_request",
174
193
  LOGOUT_RESPONSE: "air_recovery_logout_response"
175
194
  };
@@ -608,11 +627,11 @@ const BUILD_ENV = {
608
627
  const IFRAME_NAME_PREFIX_SET = ["air-wallet", "air-credential", "air-auth", "air-recovery"]; // order defines the z-index from highest to lowest
609
628
 
610
629
  const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
611
- const SANDBOX_TESTNET_URLS = {
612
- authUrl: "https://account.sandbox-testnet.air3.com/auth/",
613
- walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
614
- recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
615
- 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/"
616
635
  };
617
636
  const AIR_URLS = {
618
637
  [BUILD_ENV.DEVELOPMENT]: {
@@ -634,10 +653,10 @@ const AIR_URLS = {
634
653
  credentialUrl: "https://account.uat.air3.com/credential/"
635
654
  },
636
655
  [BUILD_ENV.SANDBOX]: {
637
- authUrl: "https://account.sandbox.air3.com/auth/",
638
- walletUrl: "https://account.sandbox.air3.com/wallet/",
639
- recoveryUrl: "https://account.sandbox.air3.com/recovery/",
640
- 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/"
641
660
  },
642
661
  [BUILD_ENV.PRODUCTION]: {
643
662
  authUrl: "https://account.air3.com/auth/",
@@ -647,8 +666,8 @@ const AIR_URLS = {
647
666
  }
648
667
  };
649
668
  const getAirUrls = (buildEnv, credentialNetwork) => {
650
- if (buildEnv === BUILD_ENV.SANDBOX && credentialNetwork === "testnet") {
651
- return SANDBOX_TESTNET_URLS;
669
+ if (buildEnv === BUILD_ENV.PRODUCTION && credentialNetwork === "mainnet") {
670
+ return PRODUCTION_MAINNET_URLS;
652
671
  }
653
672
  return AIR_URLS[buildEnv];
654
673
  };
@@ -1527,6 +1546,41 @@ var AnonymousSubject = function (_super) {
1527
1546
  };
1528
1547
  return AnonymousSubject;
1529
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);
1530
1584
  var EmptyError = createErrorClass(function (_super) {
1531
1585
  return function EmptyErrorImpl() {
1532
1586
  _super(this);
@@ -1603,6 +1657,8 @@ var PartnerAccessTokenErrorName;
1603
1657
  (function (PartnerAccessTokenErrorName) {
1604
1658
  PartnerAccessTokenErrorName["PARTNER_ACCESS_TOKEN_INVALID"] = "PARTNER_ACCESS_TOKEN_INVALID";
1605
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";
1606
1662
  })(PartnerAccessTokenErrorName || (PartnerAccessTokenErrorName = {}));
1607
1663
  /*** Realm ID Errors ***/
1608
1664
  var RealmIDErrorName;
@@ -1673,6 +1729,12 @@ var PrivyErrorName;
1673
1729
  (function (PrivyErrorName) {
1674
1730
  PrivyErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1675
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 = {}));
1676
1738
  /*** Air ID Errors ***/
1677
1739
  var AirIDErrorName;
1678
1740
  (function (AirIDErrorName) {
@@ -1692,6 +1754,13 @@ var AirIDErrorName;
1692
1754
  AirIDErrorName["AIR_ID_INVALID_MINT_NAME"] = "AIR_ID_INVALID_MINT_NAME";
1693
1755
  AirIDErrorName["AIR_ID_MINT_TRANSACTION_HASH_MISMATCH"] = "AIR_ID_MINT_TRANSACTION_HASH_MISMATCH";
1694
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 = {}));
1695
1764
  /*** Window Errors ***/
1696
1765
  var WindowErrorName;
1697
1766
  (function (WindowErrorName) {
@@ -1710,10 +1779,12 @@ const Codes = {
1710
1779
  ...WalletLinkErrorName,
1711
1780
  ...IntentErrorName,
1712
1781
  ...PrivyErrorName,
1782
+ ...RecoveryErrorName,
1713
1783
  ...AirIDErrorName,
1714
- ...WindowErrorName
1784
+ ...WindowErrorName,
1785
+ ...AgentErrorName
1715
1786
  };
1716
- 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"];
1717
1788
  class AirError extends BaseError$2 {}
1718
1789
  new Set(AirClientUserErrors);
1719
1790
  new Set(Object.values(Codes));
@@ -1726,12 +1797,18 @@ class MessageServiceBase {
1726
1797
  return this._messages$;
1727
1798
  }
1728
1799
  get isOpen() {
1729
- 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)));
1730
1805
  }
1731
1806
  constructor(name, allowedMessageTypes) {
1732
1807
  this.name = name;
1733
1808
  this.allowedMessageTypes = allowedMessageTypes;
1734
1809
  this.closeListener = null;
1810
+ this._isOpen$ = new BehaviorSubject(false);
1811
+ this.isOpen$ = this._isOpen$.asObservable();
1735
1812
  }
1736
1813
  static _getName(name, targetName) {
1737
1814
  return `${name} Service: ${targetName} Channel`;
@@ -1774,6 +1851,7 @@ class MessageServiceBase {
1774
1851
  window.removeEventListener("message", handleMessage);
1775
1852
  };
1776
1853
  }
1854
+ this._isOpen$.next(true);
1777
1855
  }
1778
1856
  isMessageAllowed(message) {
1779
1857
  return this.allowedMessageTypes.includes(message.type);
@@ -1790,6 +1868,7 @@ class MessageServiceBase {
1790
1868
  if (this.eventSubject && !this.eventSubject.closed) {
1791
1869
  this.eventSubject.complete();
1792
1870
  }
1871
+ if (this._isOpen$.value) this._isOpen$.next(false);
1793
1872
  }
1794
1873
  createErrorResponseMessage(type, error) {
1795
1874
  return {
@@ -1864,7 +1943,7 @@ _a$4 = ProviderMessageService;
1864
1943
  _ProviderMessageService_instance = {
1865
1944
  value: void 0
1866
1945
  };
1867
- var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_emit;
1946
+ var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_currentChainId, _AirWalletProvider_emit, _AirWalletProvider_getAddressForCurrentChain, _AirWalletProvider_parseChainId;
1868
1947
  class AirWalletProvider {
1869
1948
  constructor({
1870
1949
  ensureWallet,
@@ -1877,9 +1956,16 @@ class AirWalletProvider {
1877
1956
  _AirWalletProvider_getLoginResult.set(this, void 0);
1878
1957
  _AirWalletProvider_ensureWallet.set(this, void 0);
1879
1958
  _AirWalletProvider_eventListeners.set(this, void 0);
1959
+ _AirWalletProvider_currentChainId.set(this, null);
1880
1960
  this.startEventMessageListening = async walletIframe => {
1881
1961
  await __classPrivateFieldGet$1(this, _AirWalletProvider_providerMessageService, "f").open(walletIframe);
1882
1962
  __classPrivateFieldGet$1(this, _AirWalletProvider_providerMessageService, "f").messages$.pipe(filter(msg => msg.type === AirWalletProviderMessageTypes.EVENT)).subscribe(message => {
1963
+ if (message.payload.event === "chainChanged") {
1964
+ const parsedChainId = __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, message.payload.data);
1965
+ if (parsedChainId !== null) {
1966
+ __classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId);
1967
+ }
1968
+ }
1883
1969
  __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_emit).call(this, message.payload.event, ...[message.payload.data]);
1884
1970
  });
1885
1971
  };
@@ -1916,8 +2002,12 @@ class AirWalletProvider {
1916
2002
  if (!loginResult) {
1917
2003
  throw new UnauthorizedProviderError("User is not logged in");
1918
2004
  }
1919
- if ((method === "eth_accounts" || method === "eth_requestAccounts") && !__classPrivateFieldGet$1(this, _AirWalletProvider_isWalletInitialized, "f").call(this) && loginResult?.abstractAccountAddress) {
1920
- return [loginResult.abstractAccountAddress];
2005
+ // Early return optimization: return cached address from login result if wallet not yet initialized
2006
+ if ((method === "eth_accounts" || method === "eth_requestAccounts") && !__classPrivateFieldGet$1(this, _AirWalletProvider_isWalletInitialized, "f").call(this)) {
2007
+ const address = __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_getAddressForCurrentChain).call(this, loginResult);
2008
+ if (address) {
2009
+ return [address];
2010
+ }
1921
2011
  }
1922
2012
  const skipWalletLoginMethods = ["eth_chainId"];
1923
2013
  try {
@@ -1939,6 +2029,12 @@ class AirWalletProvider {
1939
2029
  if (!response.success) {
1940
2030
  throw ensureProviderRpcError(response.payload);
1941
2031
  }
2032
+ if (method === "eth_chainId") {
2033
+ const parsedChainId = __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, response.payload.response);
2034
+ if (parsedChainId !== null) {
2035
+ __classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId);
2036
+ }
2037
+ }
1942
2038
  return response.payload.response;
1943
2039
  }
1944
2040
  on(eventName, listener) {
@@ -1962,7 +2058,7 @@ class AirWalletProvider {
1962
2058
  });
1963
2059
  }
1964
2060
  }
1965
- _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
2061
+ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_isWalletInitialized = new WeakMap(), _AirWalletProvider_getLoginResult = new WeakMap(), _AirWalletProvider_ensureWallet = new WeakMap(), _AirWalletProvider_eventListeners = new WeakMap(), _AirWalletProvider_currentChainId = new WeakMap(), _AirWalletProvider_instances = new WeakSet(), _AirWalletProvider_emit = function _AirWalletProvider_emit(eventName, ...args) {
1966
2062
  (__classPrivateFieldGet$1(this, _AirWalletProvider_eventListeners, "f")[eventName] || []).forEach(listener => {
1967
2063
  try {
1968
2064
  return listener(...args);
@@ -1970,6 +2066,30 @@ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_is
1970
2066
  log$1.warn(error);
1971
2067
  }
1972
2068
  });
2069
+ }, _AirWalletProvider_getAddressForCurrentChain = function _AirWalletProvider_getAddressForCurrentChain(loginResult) {
2070
+ const currentChainId = __classPrivateFieldGet$1(this, _AirWalletProvider_currentChainId, "f");
2071
+ // If we have the new addresses array and current chainId, look up by chain
2072
+ if (loginResult.abstractAccountAddresses && currentChainId !== null) {
2073
+ const chainIdStr = String(currentChainId);
2074
+ const addressEntry = loginResult.abstractAccountAddresses.find(entry => entry.chainIds.includes(chainIdStr));
2075
+ if (addressEntry) {
2076
+ return addressEntry.address;
2077
+ }
2078
+ }
2079
+ // Fallback to legacy single address (backward compatibility)
2080
+ return loginResult.abstractAccountAddress;
2081
+ }, _AirWalletProvider_parseChainId = function _AirWalletProvider_parseChainId(chainId) {
2082
+ if (typeof chainId === "number") {
2083
+ return Number.isFinite(chainId) ? chainId : null;
2084
+ }
2085
+ if (typeof chainId === "bigint") {
2086
+ return Number(chainId);
2087
+ }
2088
+ if (typeof chainId !== "string" || !chainId) {
2089
+ return null;
2090
+ }
2091
+ const parsed = chainId.startsWith("0x") ? parseInt(chainId, 16) : parseInt(chainId, 10);
2092
+ return Number.isNaN(parsed) ? null : parsed;
1973
2093
  };
1974
2094
  var _a$3, _AuthMessageService_instance;
1975
2095
  const ALLOWED_AUTH_MESSAGES = [AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.SETUP_WALLET_REQUEST, AirAuthMessageTypes.SETUP_RECOVERY_REQUEST, AirAuthMessageTypes.SETUP_CREDENTIAL_REQUEST, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE, AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.START_RECOVERY_RESPONSE, AirAuthMessageTypes.EXPIRED_LOGOUT_REQUEST];
@@ -2093,7 +2213,7 @@ class AuthMessageService extends MessageServiceBase {
2093
2213
  const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.START_RECOVERY_RESPONSE)));
2094
2214
  await this.sendMessage({
2095
2215
  type: AirAuthMessageTypes.START_RECOVERY_REQUEST,
2096
- payload
2216
+ payload: payload ?? {}
2097
2217
  });
2098
2218
  return response;
2099
2219
  }
@@ -2185,11 +2305,14 @@ class IframeController {
2185
2305
  get iframeElement() {
2186
2306
  return this._iframeElement;
2187
2307
  }
2308
+ get isVisible() {
2309
+ return this.state.isVisible;
2310
+ }
2188
2311
  createIframe() {
2189
2312
  if (this._iframeElement) return this._iframeElement;
2190
2313
  const iframe = document.createElement("iframe");
2191
2314
  iframe.id = this.iframeId;
2192
- 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("; ");
2193
2316
  iframe.src = this.iframeUrl;
2194
2317
  iframe.style.position = "fixed";
2195
2318
  iframe.style.zIndex = `${this.getZIndex()}`;
@@ -2224,6 +2347,15 @@ class IframeController {
2224
2347
  style.bottom = "0px";
2225
2348
  Object.assign(this.iframeElement.style, style);
2226
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
+ }
2227
2359
  destroy() {
2228
2360
  if (this.iframeElement) {
2229
2361
  this.iframeElement.remove();
@@ -2277,6 +2409,29 @@ class RecoveryMessageService extends MessageServiceBase {
2277
2409
  });
2278
2410
  return response;
2279
2411
  }
2412
+ async sendGetAgentKeysRequest() {
2413
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.GET_AGENT_KEYS_RESPONSE)));
2414
+ await this.sendMessage({
2415
+ type: AirRecoveryMessageTypes.GET_AGENT_KEYS_REQUEST
2416
+ });
2417
+ return response;
2418
+ }
2419
+ async sendRegisterAgentKeyRequest(payload) {
2420
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.REGISTER_AGENT_KEY_RESPONSE)));
2421
+ await this.sendMessage({
2422
+ type: AirRecoveryMessageTypes.REGISTER_AGENT_KEY_REQUEST,
2423
+ payload
2424
+ });
2425
+ return response;
2426
+ }
2427
+ async sendRemoveAgentKeyRequest(payload) {
2428
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.REMOVE_AGENT_KEY_RESPONSE)));
2429
+ await this.sendMessage({
2430
+ type: AirRecoveryMessageTypes.REMOVE_AGENT_KEY_REQUEST,
2431
+ payload
2432
+ });
2433
+ return response;
2434
+ }
2280
2435
  async open(element) {
2281
2436
  await this._open({
2282
2437
  window: element.contentWindow,
@@ -2659,7 +2814,7 @@ class WindowService {
2659
2814
  }
2660
2815
  }
2661
2816
  var WindowService$1 = WindowService.instance;
2662
- 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;
2663
2818
  const airKitVersion = airkitPackage.version;
2664
2819
  class AirService {
2665
2820
  constructor({
@@ -2737,11 +2892,11 @@ class AirService {
2737
2892
  sessionConfig = undefined,
2738
2893
  preloadWallet = false,
2739
2894
  preloadCredential = false,
2740
- credentialNetwork = "devnet"
2895
+ credentialNetwork
2741
2896
  } = config;
2742
2897
  if (!__classPrivateFieldGet$1(this, _AirService_partnerId, "f")) throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2743
2898
  if (__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) return __classPrivateFieldGet$1(this, _AirService_loginResult, "f") ?? null;
2744
- __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.SANDBOX ? credentialNetwork : undefined);
2899
+ __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.PRODUCTION ? credentialNetwork : undefined);
2745
2900
  configureLogLevel(buildEnv, enableLogging);
2746
2901
  const {
2747
2902
  authUrl,
@@ -2772,6 +2927,7 @@ class AirService {
2772
2927
  const authIframeController = __classPrivateFieldGet$1(this, _AirService_authIframeController, "f");
2773
2928
  authIframeController.setIframeVisibility(msg.payload.visible);
2774
2929
  authIframeController.updateIframeState();
2930
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
2775
2931
  break;
2776
2932
  }
2777
2933
  case AirAuthMessageTypes.SETUP_WALLET_REQUEST:
@@ -2814,6 +2970,20 @@ class AirService {
2814
2970
  await this.logout();
2815
2971
  break;
2816
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
+ }
2817
2987
  }
2818
2988
  });
2819
2989
  const result = await new Promise((resolve, reject) => {
@@ -2850,9 +3020,7 @@ class AirService {
2850
3020
  if (preloadCredential) void this.preloadCredential();
2851
3021
  // rehydrated auth session
2852
3022
  if (result.rehydrated) {
2853
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
2854
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2855
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3023
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, result);
2856
3024
  }
2857
3025
  } catch (error) {
2858
3026
  log$1.debug("Error initializing auth service", error);
@@ -2870,9 +3038,7 @@ class AirService {
2870
3038
  partnerLoginToken: options?.authToken
2871
3039
  });
2872
3040
  if (payload.success === true) {
2873
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload));
2874
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2875
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3041
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, payload);
2876
3042
  }
2877
3043
  throw new AirServiceError(payload.errorName, payload.errorMessage);
2878
3044
  }
@@ -2990,6 +3156,43 @@ class AirService {
2990
3156
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2991
3157
  }
2992
3158
  }
3159
+ async getAgentKeys() {
3160
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
3161
+ const {
3162
+ payload
3163
+ } = await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").sendGetAgentKeysRequest();
3164
+ if (payload.success === false) {
3165
+ throw new AirServiceError(payload.errorName, payload.errorMessage);
3166
+ }
3167
+ return payload.agentKeys;
3168
+ }
3169
+ async registerAgentKey(publicKey) {
3170
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
3171
+ const {
3172
+ payload
3173
+ } = await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").sendRegisterAgentKeyRequest({
3174
+ publicKey
3175
+ });
3176
+ if (payload.success === false) {
3177
+ throw new AirServiceError(payload.errorName, payload.errorMessage);
3178
+ }
3179
+ return {
3180
+ id: payload.id,
3181
+ publicKey: payload.publicKey,
3182
+ createdAt: payload.createdAt
3183
+ };
3184
+ }
3185
+ async removeAgentKey(id) {
3186
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
3187
+ const {
3188
+ payload
3189
+ } = await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").sendRemoveAgentKeyRequest({
3190
+ id
3191
+ });
3192
+ if (payload.success === false) {
3193
+ throw new AirServiceError(payload.errorName, payload.errorMessage);
3194
+ }
3195
+ }
2993
3196
  async getUserInfo() {
2994
3197
  __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
2995
3198
  const info = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
@@ -3004,7 +3207,8 @@ class AirService {
3004
3207
  id: info.payload.user.id,
3005
3208
  abstractAccountAddress: info.payload.user.abstractAccountAddress,
3006
3209
  email: info.payload.user.email,
3007
- isMFASetup: info.payload.user.activeMfaMethods.length > 0
3210
+ wallet: info.payload.user.wallet,
3211
+ isMFASetup: (info.payload.user.activeMfaMethods?.length ?? 0) > 0
3008
3212
  }
3009
3213
  };
3010
3214
  }
@@ -3068,8 +3272,6 @@ class AirService {
3068
3272
  // Clear up credentials first to avoid issues with wallet and auth messaging services
3069
3273
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
3070
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()]);
3071
- __classPrivateFieldSet(this, _AirService_loginResult, undefined);
3072
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
3073
3275
  }
3074
3276
  async cleanUp() {
3075
3277
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
@@ -3095,7 +3297,7 @@ class AirService {
3095
3297
  credentialId,
3096
3298
  credentialSubject,
3097
3299
  curve,
3098
- offchain
3300
+ waitForOnchainCompletion
3099
3301
  }) {
3100
3302
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3101
3303
  const response = await __classPrivateFieldGet$1(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
@@ -3104,7 +3306,7 @@ class AirService {
3104
3306
  credentialId,
3105
3307
  credentialSubject,
3106
3308
  curve,
3107
- offchain
3309
+ waitForOnchainCompletion
3108
3310
  });
3109
3311
  const {
3110
3312
  payload
@@ -3228,6 +3430,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3228
3430
  {
3229
3431
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").setIframeVisibility(message.payload.visible);
3230
3432
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").updateIframeState();
3433
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3231
3434
  break;
3232
3435
  }
3233
3436
  }
@@ -3327,6 +3530,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3327
3530
  const walletIframeController = __classPrivateFieldGet$1(this, _AirService_walletIframeController, "f");
3328
3531
  walletIframeController.setIframeVisibility(msg.payload.visible);
3329
3532
  walletIframeController.updateIframeState();
3533
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3330
3534
  break;
3331
3535
  }
3332
3536
  case AirWalletMessageTypes.WALLET_LOGIN_RESPONSE:
@@ -3394,14 +3598,19 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3394
3598
  event: "wallet_initialized",
3395
3599
  result
3396
3600
  });
3397
- }, _AirService_createLoginResult = function _AirService_createLoginResult(payload) {
3398
- return {
3399
- isLoggedIn: true,
3400
- id: payload.id,
3401
- abstractAccountAddress: payload.abstractAccountAddress,
3402
- token: payload.partnerAccessToken,
3403
- isMFASetup: payload.activeMfaMethods.length > 0
3404
- };
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");
3405
3614
  }, _AirService_createWalletInitializedResult = function _AirService_createWalletInitializedResult(payload) {
3406
3615
  if ("isWalletLoggedIn" in payload && !payload.isWalletLoggedIn) {
3407
3616
  return {
@@ -3411,7 +3620,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3411
3620
  }
3412
3621
  return {
3413
3622
  abstractAccountAddress: payload.addresses.aa,
3414
- isMFASetup: payload.activeMfaMethods.length > 0
3623
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3415
3624
  };
3416
3625
  }, _AirService_cleanUpAuth = async function _AirService_cleanUpAuth() {
3417
3626
  // Logout auth session
@@ -3503,6 +3712,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3503
3712
  const recoveryIframeController = __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f");
3504
3713
  recoveryIframeController.setIframeVisibility(message.payload.visible);
3505
3714
  recoveryIframeController.updateIframeState();
3715
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3506
3716
  break;
3507
3717
  }
3508
3718
  }
@@ -3519,6 +3729,14 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3519
3729
  // Close the message service
3520
3730
  await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").close();
3521
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
+ }
3522
3740
  };
3523
3741
 
3524
3742
  function isHex(value, {