@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.
@@ -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.2";
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",
@@ -172,6 +185,12 @@ const AirRecoveryMessageTypes = {
172
185
  RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
173
186
  UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
174
187
  UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
188
+ GET_AGENT_KEYS_REQUEST: "air_recovery_get_agent_keys_request",
189
+ GET_AGENT_KEYS_RESPONSE: "air_recovery_get_agent_keys_response",
190
+ REGISTER_AGENT_KEY_REQUEST: "air_recovery_register_agent_key_request",
191
+ REGISTER_AGENT_KEY_RESPONSE: "air_recovery_register_agent_key_response",
192
+ REMOVE_AGENT_KEY_REQUEST: "air_recovery_remove_agent_key_request",
193
+ REMOVE_AGENT_KEY_RESPONSE: "air_recovery_remove_agent_key_response",
175
194
  LOGOUT_REQUEST: "air_recovery_logout_request",
176
195
  LOGOUT_RESPONSE: "air_recovery_logout_response"
177
196
  };
@@ -610,11 +629,11 @@ const BUILD_ENV = {
610
629
  const IFRAME_NAME_PREFIX_SET = ["air-wallet", "air-credential", "air-auth", "air-recovery"]; // order defines the z-index from highest to lowest
611
630
 
612
631
  const FONT_CDNS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
613
- const SANDBOX_TESTNET_URLS = {
614
- authUrl: "https://account.sandbox-testnet.air3.com/auth/",
615
- walletUrl: "https://account.sandbox-testnet.air3.com/wallet/",
616
- recoveryUrl: "https://account.sandbox-testnet.air3.com/recovery/",
617
- 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/"
618
637
  };
619
638
  const AIR_URLS = {
620
639
  [BUILD_ENV.DEVELOPMENT]: {
@@ -636,10 +655,10 @@ const AIR_URLS = {
636
655
  credentialUrl: "https://account.uat.air3.com/credential/"
637
656
  },
638
657
  [BUILD_ENV.SANDBOX]: {
639
- authUrl: "https://account.sandbox.air3.com/auth/",
640
- walletUrl: "https://account.sandbox.air3.com/wallet/",
641
- recoveryUrl: "https://account.sandbox.air3.com/recovery/",
642
- 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/"
643
662
  },
644
663
  [BUILD_ENV.PRODUCTION]: {
645
664
  authUrl: "https://account.air3.com/auth/",
@@ -649,8 +668,8 @@ const AIR_URLS = {
649
668
  }
650
669
  };
651
670
  const getAirUrls = (buildEnv, credentialNetwork) => {
652
- if (buildEnv === BUILD_ENV.SANDBOX && credentialNetwork === "testnet") {
653
- return SANDBOX_TESTNET_URLS;
671
+ if (buildEnv === BUILD_ENV.PRODUCTION && credentialNetwork === "mainnet") {
672
+ return PRODUCTION_MAINNET_URLS;
654
673
  }
655
674
  return AIR_URLS[buildEnv];
656
675
  };
@@ -1529,6 +1548,41 @@ var AnonymousSubject = function (_super) {
1529
1548
  };
1530
1549
  return AnonymousSubject;
1531
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);
1532
1586
  var EmptyError = createErrorClass(function (_super) {
1533
1587
  return function EmptyErrorImpl() {
1534
1588
  _super(this);
@@ -1605,6 +1659,8 @@ var PartnerAccessTokenErrorName;
1605
1659
  (function (PartnerAccessTokenErrorName) {
1606
1660
  PartnerAccessTokenErrorName["PARTNER_ACCESS_TOKEN_INVALID"] = "PARTNER_ACCESS_TOKEN_INVALID";
1607
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";
1608
1664
  })(PartnerAccessTokenErrorName || (PartnerAccessTokenErrorName = {}));
1609
1665
  /*** Realm ID Errors ***/
1610
1666
  var RealmIDErrorName;
@@ -1675,6 +1731,12 @@ var PrivyErrorName;
1675
1731
  (function (PrivyErrorName) {
1676
1732
  PrivyErrorName["WALLET_PROVIDER_ERROR"] = "WALLET_PROVIDER_ERROR";
1677
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 = {}));
1678
1740
  /*** Air ID Errors ***/
1679
1741
  var AirIDErrorName;
1680
1742
  (function (AirIDErrorName) {
@@ -1694,6 +1756,13 @@ var AirIDErrorName;
1694
1756
  AirIDErrorName["AIR_ID_INVALID_MINT_NAME"] = "AIR_ID_INVALID_MINT_NAME";
1695
1757
  AirIDErrorName["AIR_ID_MINT_TRANSACTION_HASH_MISMATCH"] = "AIR_ID_MINT_TRANSACTION_HASH_MISMATCH";
1696
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 = {}));
1697
1766
  /*** Window Errors ***/
1698
1767
  var WindowErrorName;
1699
1768
  (function (WindowErrorName) {
@@ -1712,10 +1781,12 @@ const Codes = {
1712
1781
  ...WalletLinkErrorName,
1713
1782
  ...IntentErrorName,
1714
1783
  ...PrivyErrorName,
1784
+ ...RecoveryErrorName,
1715
1785
  ...AirIDErrorName,
1716
- ...WindowErrorName
1786
+ ...WindowErrorName,
1787
+ ...AgentErrorName
1717
1788
  };
1718
- 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"];
1719
1790
  class AirError extends BaseError$2 {}
1720
1791
  new Set(AirClientUserErrors);
1721
1792
  new Set(Object.values(Codes));
@@ -1728,12 +1799,18 @@ class MessageServiceBase {
1728
1799
  return this._messages$;
1729
1800
  }
1730
1801
  get isOpen() {
1731
- 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)));
1732
1807
  }
1733
1808
  constructor(name, allowedMessageTypes) {
1734
1809
  this.name = name;
1735
1810
  this.allowedMessageTypes = allowedMessageTypes;
1736
1811
  this.closeListener = null;
1812
+ this._isOpen$ = new BehaviorSubject(false);
1813
+ this.isOpen$ = this._isOpen$.asObservable();
1737
1814
  }
1738
1815
  static _getName(name, targetName) {
1739
1816
  return `${name} Service: ${targetName} Channel`;
@@ -1776,6 +1853,7 @@ class MessageServiceBase {
1776
1853
  window.removeEventListener("message", handleMessage);
1777
1854
  };
1778
1855
  }
1856
+ this._isOpen$.next(true);
1779
1857
  }
1780
1858
  isMessageAllowed(message) {
1781
1859
  return this.allowedMessageTypes.includes(message.type);
@@ -1792,6 +1870,7 @@ class MessageServiceBase {
1792
1870
  if (this.eventSubject && !this.eventSubject.closed) {
1793
1871
  this.eventSubject.complete();
1794
1872
  }
1873
+ if (this._isOpen$.value) this._isOpen$.next(false);
1795
1874
  }
1796
1875
  createErrorResponseMessage(type, error) {
1797
1876
  return {
@@ -1866,7 +1945,7 @@ _a$4 = ProviderMessageService;
1866
1945
  _ProviderMessageService_instance = {
1867
1946
  value: void 0
1868
1947
  };
1869
- var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_emit;
1948
+ var _AirWalletProvider_instances, _AirWalletProvider_providerMessageService, _AirWalletProvider_isWalletInitialized, _AirWalletProvider_getLoginResult, _AirWalletProvider_ensureWallet, _AirWalletProvider_eventListeners, _AirWalletProvider_currentChainId, _AirWalletProvider_emit, _AirWalletProvider_getAddressForCurrentChain, _AirWalletProvider_parseChainId;
1870
1949
  class AirWalletProvider {
1871
1950
  constructor({
1872
1951
  ensureWallet,
@@ -1879,9 +1958,16 @@ class AirWalletProvider {
1879
1958
  _AirWalletProvider_getLoginResult.set(this, void 0);
1880
1959
  _AirWalletProvider_ensureWallet.set(this, void 0);
1881
1960
  _AirWalletProvider_eventListeners.set(this, void 0);
1961
+ _AirWalletProvider_currentChainId.set(this, null);
1882
1962
  this.startEventMessageListening = async walletIframe => {
1883
1963
  await __classPrivateFieldGet$1(this, _AirWalletProvider_providerMessageService, "f").open(walletIframe);
1884
1964
  __classPrivateFieldGet$1(this, _AirWalletProvider_providerMessageService, "f").messages$.pipe(filter(msg => msg.type === AirWalletProviderMessageTypes.EVENT)).subscribe(message => {
1965
+ if (message.payload.event === "chainChanged") {
1966
+ const parsedChainId = __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, message.payload.data);
1967
+ if (parsedChainId !== null) {
1968
+ __classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId);
1969
+ }
1970
+ }
1885
1971
  __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_emit).call(this, message.payload.event, ...[message.payload.data]);
1886
1972
  });
1887
1973
  };
@@ -1918,8 +2004,12 @@ class AirWalletProvider {
1918
2004
  if (!loginResult) {
1919
2005
  throw new UnauthorizedProviderError("User is not logged in");
1920
2006
  }
1921
- if ((method === "eth_accounts" || method === "eth_requestAccounts") && !__classPrivateFieldGet$1(this, _AirWalletProvider_isWalletInitialized, "f").call(this) && loginResult?.abstractAccountAddress) {
1922
- return [loginResult.abstractAccountAddress];
2007
+ // Early return optimization: return cached address from login result if wallet not yet initialized
2008
+ if ((method === "eth_accounts" || method === "eth_requestAccounts") && !__classPrivateFieldGet$1(this, _AirWalletProvider_isWalletInitialized, "f").call(this)) {
2009
+ const address = __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_getAddressForCurrentChain).call(this, loginResult);
2010
+ if (address) {
2011
+ return [address];
2012
+ }
1923
2013
  }
1924
2014
  const skipWalletLoginMethods = ["eth_chainId"];
1925
2015
  try {
@@ -1941,6 +2031,12 @@ class AirWalletProvider {
1941
2031
  if (!response.success) {
1942
2032
  throw ensureProviderRpcError(response.payload);
1943
2033
  }
2034
+ if (method === "eth_chainId") {
2035
+ const parsedChainId = __classPrivateFieldGet$1(this, _AirWalletProvider_instances, "m", _AirWalletProvider_parseChainId).call(this, response.payload.response);
2036
+ if (parsedChainId !== null) {
2037
+ __classPrivateFieldSet(this, _AirWalletProvider_currentChainId, parsedChainId);
2038
+ }
2039
+ }
1944
2040
  return response.payload.response;
1945
2041
  }
1946
2042
  on(eventName, listener) {
@@ -1964,7 +2060,7 @@ class AirWalletProvider {
1964
2060
  });
1965
2061
  }
1966
2062
  }
1967
- _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) {
2063
+ _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) {
1968
2064
  (__classPrivateFieldGet$1(this, _AirWalletProvider_eventListeners, "f")[eventName] || []).forEach(listener => {
1969
2065
  try {
1970
2066
  return listener(...args);
@@ -1972,6 +2068,30 @@ _AirWalletProvider_providerMessageService = new WeakMap(), _AirWalletProvider_is
1972
2068
  log$1.warn(error);
1973
2069
  }
1974
2070
  });
2071
+ }, _AirWalletProvider_getAddressForCurrentChain = function _AirWalletProvider_getAddressForCurrentChain(loginResult) {
2072
+ const currentChainId = __classPrivateFieldGet$1(this, _AirWalletProvider_currentChainId, "f");
2073
+ // If we have the new addresses array and current chainId, look up by chain
2074
+ if (loginResult.abstractAccountAddresses && currentChainId !== null) {
2075
+ const chainIdStr = String(currentChainId);
2076
+ const addressEntry = loginResult.abstractAccountAddresses.find(entry => entry.chainIds.includes(chainIdStr));
2077
+ if (addressEntry) {
2078
+ return addressEntry.address;
2079
+ }
2080
+ }
2081
+ // Fallback to legacy single address (backward compatibility)
2082
+ return loginResult.abstractAccountAddress;
2083
+ }, _AirWalletProvider_parseChainId = function _AirWalletProvider_parseChainId(chainId) {
2084
+ if (typeof chainId === "number") {
2085
+ return Number.isFinite(chainId) ? chainId : null;
2086
+ }
2087
+ if (typeof chainId === "bigint") {
2088
+ return Number(chainId);
2089
+ }
2090
+ if (typeof chainId !== "string" || !chainId) {
2091
+ return null;
2092
+ }
2093
+ const parsed = chainId.startsWith("0x") ? parseInt(chainId, 16) : parseInt(chainId, 10);
2094
+ return Number.isNaN(parsed) ? null : parsed;
1975
2095
  };
1976
2096
  var _a$3, _AuthMessageService_instance;
1977
2097
  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];
@@ -2095,7 +2215,7 @@ class AuthMessageService extends MessageServiceBase {
2095
2215
  const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirAuthMessageTypes.START_RECOVERY_RESPONSE)));
2096
2216
  await this.sendMessage({
2097
2217
  type: AirAuthMessageTypes.START_RECOVERY_REQUEST,
2098
- payload
2218
+ payload: payload ?? {}
2099
2219
  });
2100
2220
  return response;
2101
2221
  }
@@ -2187,11 +2307,14 @@ class IframeController {
2187
2307
  get iframeElement() {
2188
2308
  return this._iframeElement;
2189
2309
  }
2310
+ get isVisible() {
2311
+ return this.state.isVisible;
2312
+ }
2190
2313
  createIframe() {
2191
2314
  if (this._iframeElement) return this._iframeElement;
2192
2315
  const iframe = document.createElement("iframe");
2193
2316
  iframe.id = this.iframeId;
2194
- 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("; ");
2195
2318
  iframe.src = this.iframeUrl;
2196
2319
  iframe.style.position = "fixed";
2197
2320
  iframe.style.zIndex = `${this.getZIndex()}`;
@@ -2226,6 +2349,15 @@ class IframeController {
2226
2349
  style.bottom = "0px";
2227
2350
  Object.assign(this.iframeElement.style, style);
2228
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
+ }
2229
2361
  destroy() {
2230
2362
  if (this.iframeElement) {
2231
2363
  this.iframeElement.remove();
@@ -2279,6 +2411,29 @@ class RecoveryMessageService extends MessageServiceBase {
2279
2411
  });
2280
2412
  return response;
2281
2413
  }
2414
+ async sendGetAgentKeysRequest() {
2415
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.GET_AGENT_KEYS_RESPONSE)));
2416
+ await this.sendMessage({
2417
+ type: AirRecoveryMessageTypes.GET_AGENT_KEYS_REQUEST
2418
+ });
2419
+ return response;
2420
+ }
2421
+ async sendRegisterAgentKeyRequest(payload) {
2422
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.REGISTER_AGENT_KEY_RESPONSE)));
2423
+ await this.sendMessage({
2424
+ type: AirRecoveryMessageTypes.REGISTER_AGENT_KEY_REQUEST,
2425
+ payload
2426
+ });
2427
+ return response;
2428
+ }
2429
+ async sendRemoveAgentKeyRequest(payload) {
2430
+ const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirRecoveryMessageTypes.REMOVE_AGENT_KEY_RESPONSE)));
2431
+ await this.sendMessage({
2432
+ type: AirRecoveryMessageTypes.REMOVE_AGENT_KEY_REQUEST,
2433
+ payload
2434
+ });
2435
+ return response;
2436
+ }
2282
2437
  async open(element) {
2283
2438
  await this._open({
2284
2439
  window: element.contentWindow,
@@ -2661,7 +2816,7 @@ class WindowService {
2661
2816
  }
2662
2817
  }
2663
2818
  var WindowService$1 = WindowService.instance;
2664
- 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;
2665
2820
  const airKitVersion = airkitPackage.version;
2666
2821
  class AirService {
2667
2822
  constructor({
@@ -2739,11 +2894,11 @@ class AirService {
2739
2894
  sessionConfig = undefined,
2740
2895
  preloadWallet = false,
2741
2896
  preloadCredential = false,
2742
- credentialNetwork = "devnet"
2897
+ credentialNetwork
2743
2898
  } = config;
2744
2899
  if (!__classPrivateFieldGet$1(this, _AirService_partnerId, "f")) throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
2745
2900
  if (__classPrivateFieldGet$1(this, _AirService_isAuthInitialized, "f")) return __classPrivateFieldGet$1(this, _AirService_loginResult, "f") ?? null;
2746
- __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.SANDBOX ? credentialNetwork : undefined);
2901
+ __classPrivateFieldSet(this, _AirService_credentialNetwork, buildEnv === BUILD_ENV.PRODUCTION ? credentialNetwork : undefined);
2747
2902
  configureLogLevel(buildEnv, enableLogging);
2748
2903
  const {
2749
2904
  authUrl,
@@ -2774,6 +2929,7 @@ class AirService {
2774
2929
  const authIframeController = __classPrivateFieldGet$1(this, _AirService_authIframeController, "f");
2775
2930
  authIframeController.setIframeVisibility(msg.payload.visible);
2776
2931
  authIframeController.updateIframeState();
2932
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
2777
2933
  break;
2778
2934
  }
2779
2935
  case AirAuthMessageTypes.SETUP_WALLET_REQUEST:
@@ -2816,6 +2972,20 @@ class AirService {
2816
2972
  await this.logout();
2817
2973
  break;
2818
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
+ }
2819
2989
  }
2820
2990
  });
2821
2991
  const result = await new Promise((resolve, reject) => {
@@ -2852,9 +3022,7 @@ class AirService {
2852
3022
  if (preloadCredential) void this.preloadCredential();
2853
3023
  // rehydrated auth session
2854
3024
  if (result.rehydrated) {
2855
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
2856
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2857
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3025
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, result);
2858
3026
  }
2859
3027
  } catch (error) {
2860
3028
  log$1.debug("Error initializing auth service", error);
@@ -2872,9 +3040,7 @@ class AirService {
2872
3040
  partnerLoginToken: options?.authToken
2873
3041
  });
2874
3042
  if (payload.success === true) {
2875
- __classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, payload));
2876
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedIn).call(this);
2877
- return __classPrivateFieldGet$1(this, _AirService_loginResult, "f");
3043
+ return __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assignAndTriggerLoginResult).call(this, payload);
2878
3044
  }
2879
3045
  throw new AirServiceError(payload.errorName, payload.errorMessage);
2880
3046
  }
@@ -2992,6 +3158,43 @@ class AirService {
2992
3158
  throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
2993
3159
  }
2994
3160
  }
3161
+ async getAgentKeys() {
3162
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
3163
+ const {
3164
+ payload
3165
+ } = await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").sendGetAgentKeysRequest();
3166
+ if (payload.success === false) {
3167
+ throw new AirServiceError(payload.errorName, payload.errorMessage);
3168
+ }
3169
+ return payload.agentKeys;
3170
+ }
3171
+ async registerAgentKey(publicKey) {
3172
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
3173
+ const {
3174
+ payload
3175
+ } = await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").sendRegisterAgentKeyRequest({
3176
+ publicKey
3177
+ });
3178
+ if (payload.success === false) {
3179
+ throw new AirServiceError(payload.errorName, payload.errorMessage);
3180
+ }
3181
+ return {
3182
+ id: payload.id,
3183
+ publicKey: payload.publicKey,
3184
+ createdAt: payload.createdAt
3185
+ };
3186
+ }
3187
+ async removeAgentKey(id) {
3188
+ await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureRecovery).call(this);
3189
+ const {
3190
+ payload
3191
+ } = await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").sendRemoveAgentKeyRequest({
3192
+ id
3193
+ });
3194
+ if (payload.success === false) {
3195
+ throw new AirServiceError(payload.errorName, payload.errorMessage);
3196
+ }
3197
+ }
2995
3198
  async getUserInfo() {
2996
3199
  __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
2997
3200
  const info = await __classPrivateFieldGet$1(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
@@ -3006,7 +3209,8 @@ class AirService {
3006
3209
  id: info.payload.user.id,
3007
3210
  abstractAccountAddress: info.payload.user.abstractAccountAddress,
3008
3211
  email: info.payload.user.email,
3009
- isMFASetup: info.payload.user.activeMfaMethods.length > 0
3212
+ wallet: info.payload.user.wallet,
3213
+ isMFASetup: (info.payload.user.activeMfaMethods?.length ?? 0) > 0
3010
3214
  }
3011
3215
  };
3012
3216
  }
@@ -3070,8 +3274,6 @@ class AirService {
3070
3274
  // Clear up credentials first to avoid issues with wallet and auth messaging services
3071
3275
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
3072
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()]);
3073
- __classPrivateFieldSet(this, _AirService_loginResult, undefined);
3074
- __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
3075
3277
  }
3076
3278
  async cleanUp() {
3077
3279
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
@@ -3097,7 +3299,7 @@ class AirService {
3097
3299
  credentialId,
3098
3300
  credentialSubject,
3099
3301
  curve,
3100
- offchain
3302
+ waitForOnchainCompletion
3101
3303
  }) {
3102
3304
  await __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
3103
3305
  const response = await __classPrivateFieldGet$1(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
@@ -3106,7 +3308,7 @@ class AirService {
3106
3308
  credentialId,
3107
3309
  credentialSubject,
3108
3310
  curve,
3109
- offchain
3311
+ waitForOnchainCompletion
3110
3312
  });
3111
3313
  const {
3112
3314
  payload
@@ -3230,6 +3432,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3230
3432
  {
3231
3433
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").setIframeVisibility(message.payload.visible);
3232
3434
  __classPrivateFieldGet$1(this, _AirService_credentialIframeController, "f").updateIframeState();
3435
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3233
3436
  break;
3234
3437
  }
3235
3438
  }
@@ -3329,6 +3532,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3329
3532
  const walletIframeController = __classPrivateFieldGet$1(this, _AirService_walletIframeController, "f");
3330
3533
  walletIframeController.setIframeVisibility(msg.payload.visible);
3331
3534
  walletIframeController.updateIframeState();
3535
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3332
3536
  break;
3333
3537
  }
3334
3538
  case AirWalletMessageTypes.WALLET_LOGIN_RESPONSE:
@@ -3396,14 +3600,19 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3396
3600
  event: "wallet_initialized",
3397
3601
  result
3398
3602
  });
3399
- }, _AirService_createLoginResult = function _AirService_createLoginResult(payload) {
3400
- return {
3401
- isLoggedIn: true,
3402
- id: payload.id,
3403
- abstractAccountAddress: payload.abstractAccountAddress,
3404
- token: payload.partnerAccessToken,
3405
- isMFASetup: payload.activeMfaMethods.length > 0
3406
- };
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");
3407
3616
  }, _AirService_createWalletInitializedResult = function _AirService_createWalletInitializedResult(payload) {
3408
3617
  if ("isWalletLoggedIn" in payload && !payload.isWalletLoggedIn) {
3409
3618
  return {
@@ -3413,7 +3622,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3413
3622
  }
3414
3623
  return {
3415
3624
  abstractAccountAddress: payload.addresses.aa,
3416
- isMFASetup: payload.activeMfaMethods.length > 0
3625
+ isMFASetup: (payload.activeMfaMethods?.length ?? 0) > 0
3417
3626
  };
3418
3627
  }, _AirService_cleanUpAuth = async function _AirService_cleanUpAuth() {
3419
3628
  // Logout auth session
@@ -3505,6 +3714,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3505
3714
  const recoveryIframeController = __classPrivateFieldGet$1(this, _AirService_recoveryIframeController, "f");
3506
3715
  recoveryIframeController.setIframeVisibility(message.payload.visible);
3507
3716
  recoveryIframeController.updateIframeState();
3717
+ __classPrivateFieldGet$1(this, _AirService_instances, "m", _AirService_refocusTopmostVisibleIframe).call(this);
3508
3718
  break;
3509
3719
  }
3510
3720
  }
@@ -3521,6 +3731,14 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
3521
3731
  // Close the message service
3522
3732
  await __classPrivateFieldGet$1(this, _AirService_recoveryMessagingService, "f").close();
3523
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
+ }
3524
3742
  };
3525
3743
 
3526
3744
  function isHex(value, {