@mocanetwork/airkit 1.6.0-beta.4 → 1.6.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.
- package/dist/airkit.cjs.js +138 -96
- package/dist/airkit.esm.js +138 -96
- package/dist/airkit.umd.js +138 -96
- package/dist/types/airService.d.ts +4 -15
- package/dist/types/authMessageService.d.ts +2 -1
- package/dist/types/common/air/messaging/auth.d.ts +12 -5
- package/dist/types/common/air/messaging/const.d.ts +2 -1
- package/dist/types/common/air/messaging/credential.d.ts +13 -3
- package/dist/types/common/air/messaging/recovery.d.ts +8 -2
- package/dist/types/common/air/messaging/types.d.ts +3 -0
- package/dist/types/common/air/messaging/wallet.d.ts +8 -2
- package/dist/types/common/const.d.ts +29 -2
- package/dist/types/credentialMessageService.d.ts +3 -8
- package/dist/types/error.d.ts +1 -1
- package/dist/types/interfaces.d.ts +3 -0
- package/dist/types/recoveryMessageService.d.ts +3 -7
- package/dist/types/walletMessageService.d.ts +2 -1
- package/dist/types/windowService.d.ts +2 -1
- package/package.json +1 -1
package/dist/airkit.cjs.js
CHANGED
|
@@ -97,7 +97,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
97
97
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
var version = "1.6.0
|
|
100
|
+
var version = "1.6.0";
|
|
101
101
|
var airkitPackage = {
|
|
102
102
|
version: version};
|
|
103
103
|
|
|
@@ -108,6 +108,8 @@ const AirAuthMessageTypes = {
|
|
|
108
108
|
LOGIN_REQUEST: "air_auth_login_request",
|
|
109
109
|
LOGIN_RESPONSE: "air_auth_login_response",
|
|
110
110
|
LOGIN_SERVICE_RESPONSE: "air_auth_login_service_response",
|
|
111
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_auth_update_session_config_request",
|
|
112
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_auth_update_session_config_response",
|
|
111
113
|
USER_INFO_REQUEST: "air_auth_user_info_request",
|
|
112
114
|
USER_INFO_RESPONSE: "air_auth_user_info_response",
|
|
113
115
|
PARTNER_USER_INFO_REQUEST: "air_auth_partner_user_info_request",
|
|
@@ -141,6 +143,8 @@ const AirCredentialMessageTypes = {
|
|
|
141
143
|
INITIALIZATION_REQUEST: "air_credential_initialization_request",
|
|
142
144
|
INITIALIZATION_RESPONSE: "air_credential_initialization_response",
|
|
143
145
|
CREDENTIAL_IFRAME_VISIBILITY_REQUEST: "air_credential_iframe_visibility_request",
|
|
146
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_credential_update_session_config_request",
|
|
147
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_credential_update_session_config_response",
|
|
144
148
|
LOGOUT_REQUEST: "air_credential_logout_request",
|
|
145
149
|
LOGOUT_RESPONSE: "air_credential_logout_response",
|
|
146
150
|
// New credential operation message types
|
|
@@ -157,6 +161,8 @@ const AirRecoveryMessageTypes = {
|
|
|
157
161
|
INITIALIZATION_RESPONSE: "air_recovery_initialization_response",
|
|
158
162
|
RECOVERY_INITIALIZED: "air_recovery_initialized",
|
|
159
163
|
RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
|
|
164
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_recovery_update_session_config_request",
|
|
165
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_recovery_update_session_config_response",
|
|
160
166
|
LOGOUT_REQUEST: "air_recovery_logout_request",
|
|
161
167
|
LOGOUT_RESPONSE: "air_recovery_logout_response"
|
|
162
168
|
};
|
|
@@ -168,6 +174,8 @@ const AirWalletMessageTypes = {
|
|
|
168
174
|
CLOSE_MODAL_REQUEST: "air_close_modal_request",
|
|
169
175
|
CLOSE_MODAL_RESPONSE: "air_close_modal_response",
|
|
170
176
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
177
|
+
UPDATE_SESSION_CONFIG_REQUEST: "air_wallet_update_session_config_request",
|
|
178
|
+
UPDATE_SESSION_CONFIG_RESPONSE: "air_wallet_update_session_config_response",
|
|
171
179
|
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
172
180
|
WALLET_LOGIN_RESPONSE: "air_wallet_login_response",
|
|
173
181
|
SETUP_OR_UPDATE_MFA_REQUEST: "air_setup_mfa_request",
|
|
@@ -714,7 +722,7 @@ class SwitchChainError extends ProviderRpcError {
|
|
|
714
722
|
class TransactionRejectedRpcError extends ProviderRpcError {
|
|
715
723
|
constructor(message) {
|
|
716
724
|
// Remove the "Version: viem@x.x.x" suffix if present
|
|
717
|
-
const cleanMessage = message.replace(/\nVersion:.*$/,
|
|
725
|
+
const cleanMessage = message.replace(/\nVersion:.*$/, "");
|
|
718
726
|
super(cleanMessage);
|
|
719
727
|
this.code = -32003;
|
|
720
728
|
this.name = "TransactionRejectedRpcError";
|
|
@@ -1868,7 +1876,7 @@ class AirWalletProvider {
|
|
|
1868
1876
|
if (!loginResult) {
|
|
1869
1877
|
throw new UnauthorizedProviderError("User is not logged in");
|
|
1870
1878
|
}
|
|
1871
|
-
if (method === "eth_accounts" &&
|
|
1879
|
+
if ((method === "eth_accounts" || method === "eth_requestAccounts") &&
|
|
1872
1880
|
!__classPrivateFieldGet(this, _AirWalletProvider_isWalletInitialized, "f").call(this) &&
|
|
1873
1881
|
loginResult?.abstractAccountAddress) {
|
|
1874
1882
|
return [loginResult.abstractAccountAddress];
|
|
@@ -1934,6 +1942,7 @@ const ALLOWED_AUTH_MESSAGES = [
|
|
|
1934
1942
|
AirAuthMessageTypes.SETUP_WALLET_REQUEST,
|
|
1935
1943
|
AirAuthMessageTypes.SETUP_RECOVERY_REQUEST,
|
|
1936
1944
|
AirAuthMessageTypes.LOGOUT_RESPONSE,
|
|
1945
|
+
AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
1937
1946
|
AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
|
|
1938
1947
|
AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE,
|
|
1939
1948
|
AirAuthMessageTypes.PARTNER_ACCESS_TOKEN_RESPONSE,
|
|
@@ -1961,6 +1970,11 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
1961
1970
|
});
|
|
1962
1971
|
return response;
|
|
1963
1972
|
}
|
|
1973
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
1974
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
1975
|
+
await this.sendMessage({ type: AirAuthMessageTypes.UPDATE_SESSION_CONFIG_REQUEST, payload });
|
|
1976
|
+
return response;
|
|
1977
|
+
}
|
|
1964
1978
|
async sendLoginRequest(payload) {
|
|
1965
1979
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.LOGIN_RESPONSE)));
|
|
1966
1980
|
await this.sendMessage({ type: AirAuthMessageTypes.LOGIN_REQUEST, payload });
|
|
@@ -2034,6 +2048,7 @@ var _a$2, _CredentialMessageService_instance;
|
|
|
2034
2048
|
const ALLOWED_CREDENTIAL_MESSAGES = [
|
|
2035
2049
|
AirCredentialMessageTypes.INITIALIZATION_RESPONSE,
|
|
2036
2050
|
AirCredentialMessageTypes.CREDENTIAL_IFRAME_VISIBILITY_REQUEST,
|
|
2051
|
+
AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
2037
2052
|
AirCredentialMessageTypes.LOGOUT_RESPONSE,
|
|
2038
2053
|
AirCredentialMessageTypes.ISSUE_CREDENTIAL_RESPONSE,
|
|
2039
2054
|
AirCredentialMessageTypes.VERIFY_CREDENTIAL_RESPONSE,
|
|
@@ -2059,6 +2074,14 @@ class CredentialMessageService extends MessageServiceBase {
|
|
|
2059
2074
|
});
|
|
2060
2075
|
return response;
|
|
2061
2076
|
}
|
|
2077
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2078
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2079
|
+
await this.sendMessage({
|
|
2080
|
+
type: AirCredentialMessageTypes.UPDATE_SESSION_CONFIG_REQUEST,
|
|
2081
|
+
payload,
|
|
2082
|
+
});
|
|
2083
|
+
return response;
|
|
2084
|
+
}
|
|
2062
2085
|
async logout() {
|
|
2063
2086
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.LOGOUT_RESPONSE)));
|
|
2064
2087
|
await this.sendMessage({
|
|
@@ -2182,6 +2205,14 @@ class RecoveryMessageService extends MessageServiceBase {
|
|
|
2182
2205
|
async onInitialized() {
|
|
2183
2206
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.RECOVERY_INITIALIZED)));
|
|
2184
2207
|
}
|
|
2208
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2209
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2210
|
+
await this.sendMessage({
|
|
2211
|
+
type: AirRecoveryMessageTypes.UPDATE_SESSION_CONFIG_REQUEST,
|
|
2212
|
+
payload,
|
|
2213
|
+
});
|
|
2214
|
+
return response;
|
|
2215
|
+
}
|
|
2185
2216
|
async logout() {
|
|
2186
2217
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.LOGOUT_RESPONSE)));
|
|
2187
2218
|
await this.sendMessage({ type: AirRecoveryMessageTypes.LOGOUT_REQUEST });
|
|
@@ -2201,6 +2232,7 @@ var _a, _WalletMessageService_instance;
|
|
|
2201
2232
|
const ALLOWED_WALLET_MESSAGES = [
|
|
2202
2233
|
AirWalletMessageTypes.INITIALIZATION_RESPONSE,
|
|
2203
2234
|
AirWalletMessageTypes.WALLET_INITIALIZED,
|
|
2235
|
+
AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE,
|
|
2204
2236
|
AirWalletMessageTypes.WALLET_LOGIN_RESPONSE,
|
|
2205
2237
|
AirWalletMessageTypes.SETUP_OR_UPDATE_MFA_RESPONSE,
|
|
2206
2238
|
AirWalletMessageTypes.SHOW_SWAP_UI_RESPONSE,
|
|
@@ -2252,6 +2284,11 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2252
2284
|
onInitialized() {
|
|
2253
2285
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.WALLET_INITIALIZED)));
|
|
2254
2286
|
}
|
|
2287
|
+
async sendUpdateSessionConfigRequest(payload) {
|
|
2288
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.UPDATE_SESSION_CONFIG_RESPONSE)));
|
|
2289
|
+
await this.sendMessage({ type: AirWalletMessageTypes.UPDATE_SESSION_CONFIG_REQUEST, payload });
|
|
2290
|
+
return response;
|
|
2291
|
+
}
|
|
2255
2292
|
async sendLoginRequest() {
|
|
2256
2293
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.WALLET_LOGIN_RESPONSE)));
|
|
2257
2294
|
await this.sendMessage({
|
|
@@ -2459,7 +2496,7 @@ class WindowService {
|
|
|
2459
2496
|
]);
|
|
2460
2497
|
return (await response).data;
|
|
2461
2498
|
}
|
|
2462
|
-
async openAndInitializeWalletServiceWindow({ url, windowId, partnerId, enableLogging, onRetry, sdkVersion, enableAutomation, }) {
|
|
2499
|
+
async openAndInitializeWalletServiceWindow({ url, windowId, sessionId, partnerId, enableLogging, onRetry, sdkVersion, enableAutomation, }) {
|
|
2463
2500
|
if (this.windowControllers.has(windowId)) {
|
|
2464
2501
|
throw new Error("Window controller already exists");
|
|
2465
2502
|
}
|
|
@@ -2477,6 +2514,7 @@ class WindowService {
|
|
|
2477
2514
|
try {
|
|
2478
2515
|
channel = new MessageChannel();
|
|
2479
2516
|
const { payload } = await this.sendWindowInitializationRequest(windowId, {
|
|
2517
|
+
sessionId,
|
|
2480
2518
|
partnerId,
|
|
2481
2519
|
enableLogging,
|
|
2482
2520
|
sdkVersion,
|
|
@@ -2516,7 +2554,7 @@ class WindowService {
|
|
|
2516
2554
|
}
|
|
2517
2555
|
var WindowService$1 = WindowService.instance;
|
|
2518
2556
|
|
|
2519
|
-
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized,
|
|
2557
|
+
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_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;
|
|
2520
2558
|
const airKitVersion = airkitPackage.version;
|
|
2521
2559
|
class AirService {
|
|
2522
2560
|
constructor({ partnerId }) {
|
|
@@ -2525,11 +2563,13 @@ class AirService {
|
|
|
2525
2563
|
_AirService_buildEnv.set(this, void 0);
|
|
2526
2564
|
_AirService_enableLogging.set(this, false);
|
|
2527
2565
|
_AirService_partnerId.set(this, void 0);
|
|
2566
|
+
_AirService_sessionId.set(this, void 0);
|
|
2567
|
+
_AirService_sessionConfig.set(this, void 0);
|
|
2528
2568
|
//#modalZIndex: number; TODO implement z index overwrite
|
|
2529
2569
|
_AirService_authMessagingService.set(this, void 0);
|
|
2530
2570
|
_AirService_authIframeController.set(this, void 0);
|
|
2531
2571
|
_AirService_isAuthInitialized.set(this, false);
|
|
2532
|
-
|
|
2572
|
+
_AirService_airEventListener.set(this, []);
|
|
2533
2573
|
_AirService_walletMessagingService.set(this, void 0);
|
|
2534
2574
|
_AirService_walletIframeController.set(this, void 0);
|
|
2535
2575
|
_AirService_walletInitialization.set(this, void 0);
|
|
@@ -2579,15 +2619,17 @@ class AirService {
|
|
|
2579
2619
|
shouldEnableAutomation() {
|
|
2580
2620
|
return localStorage.getItem("automation") === "true" && __classPrivateFieldGet(this, _AirService_buildEnv, "f") !== BUILD_ENV.PRODUCTION;
|
|
2581
2621
|
}
|
|
2582
|
-
async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, }) {
|
|
2622
|
+
async init({ buildEnv = BUILD_ENV.PRODUCTION, enableLogging = false, skipRehydration = false, sessionConfig = undefined, }) {
|
|
2583
2623
|
if (!__classPrivateFieldGet(this, _AirService_partnerId, "f"))
|
|
2584
|
-
throw new
|
|
2624
|
+
throw new AirServiceError("CLIENT_ERROR", "Partner ID is required to initialize the service");
|
|
2585
2625
|
if (__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2586
|
-
return;
|
|
2626
|
+
return __classPrivateFieldGet(this, _AirService_loginResult, "f") ?? null;
|
|
2587
2627
|
__classPrivateFieldSet(this, _AirService_buildEnv, buildEnv, "f");
|
|
2588
2628
|
__classPrivateFieldSet(this, _AirService_enableLogging, enableLogging, "f");
|
|
2629
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
2589
2630
|
const { authUrl } = AIR_URLS[buildEnv];
|
|
2590
2631
|
configureLogLevel(buildEnv, enableLogging);
|
|
2632
|
+
__classPrivateFieldSet(this, _AirService_sessionId, randomId(), "f");
|
|
2591
2633
|
const authIframeOrigin = new URL(authUrl).origin;
|
|
2592
2634
|
__classPrivateFieldSet(this, _AirService_authIframeController, new IframeController("air-auth", authUrl), "f");
|
|
2593
2635
|
try {
|
|
@@ -2637,12 +2679,14 @@ class AirService {
|
|
|
2637
2679
|
if (ev.data === AirAuthMessageTypes.AUTH_SETUP_COMPLETED) {
|
|
2638
2680
|
window.removeEventListener("message", handleAuthMessage);
|
|
2639
2681
|
const { payload } = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendInitializationRequest({
|
|
2682
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
2640
2683
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
2641
2684
|
skipRehydration,
|
|
2642
2685
|
partnerDAppUrl: window.location.href,
|
|
2643
2686
|
sdkVersion: airKitVersion,
|
|
2644
2687
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
2645
2688
|
enableAutomation: this.shouldEnableAutomation(),
|
|
2689
|
+
sessionConfig,
|
|
2646
2690
|
});
|
|
2647
2691
|
if (payload.success === true) {
|
|
2648
2692
|
resolve(payload);
|
|
@@ -2668,13 +2712,12 @@ class AirService {
|
|
|
2668
2712
|
catch (error) {
|
|
2669
2713
|
log.debug("Error initializing auth service", error);
|
|
2670
2714
|
await this.cleanUp();
|
|
2671
|
-
throw error;
|
|
2715
|
+
throw AirServiceError.from(error);
|
|
2672
2716
|
}
|
|
2673
2717
|
return null;
|
|
2674
2718
|
}
|
|
2675
2719
|
async login(options) {
|
|
2676
|
-
|
|
2677
|
-
throw new Error("Service is not initialized");
|
|
2720
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2678
2721
|
if (__classPrivateFieldGet(this, _AirService_loginResult, "f"))
|
|
2679
2722
|
return __classPrivateFieldGet(this, _AirService_loginResult, "f");
|
|
2680
2723
|
const { payload } = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendLoginRequest({
|
|
@@ -2691,38 +2734,24 @@ class AirService {
|
|
|
2691
2734
|
* @experimental This method is experimental and will change in the future.
|
|
2692
2735
|
*/
|
|
2693
2736
|
async deploySmartAccount() {
|
|
2694
|
-
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2695
|
-
throw new Error("Service is not initialized");
|
|
2696
2737
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2702
|
-
}
|
|
2703
|
-
return { txHash: payload.txHash };
|
|
2704
|
-
}
|
|
2705
|
-
catch (error) {
|
|
2706
|
-
throw AirServiceError.from(error);
|
|
2738
|
+
log.info("deploySmartAccount");
|
|
2739
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendDeploySmartAccountRequest();
|
|
2740
|
+
if (payload.success === false) {
|
|
2741
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2707
2742
|
}
|
|
2743
|
+
return { txHash: payload.txHash };
|
|
2708
2744
|
}
|
|
2709
2745
|
/**
|
|
2710
2746
|
* @experimental This method is experimental and will change in the future.
|
|
2711
2747
|
*/
|
|
2712
2748
|
async isSmartAccountDeployed() {
|
|
2713
|
-
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2714
|
-
throw new Error("Service is not initialized");
|
|
2715
2749
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2720
|
-
}
|
|
2721
|
-
return payload.isDeployed;
|
|
2722
|
-
}
|
|
2723
|
-
catch (error) {
|
|
2724
|
-
throw AirServiceError.from(error);
|
|
2750
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendIsSmartAccountDeployedRequest();
|
|
2751
|
+
if (payload.success === false) {
|
|
2752
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2725
2753
|
}
|
|
2754
|
+
return payload.isDeployed;
|
|
2726
2755
|
}
|
|
2727
2756
|
getProvider() {
|
|
2728
2757
|
return this.provider;
|
|
@@ -2774,8 +2803,7 @@ class AirService {
|
|
|
2774
2803
|
}
|
|
2775
2804
|
}
|
|
2776
2805
|
async getUserInfo() {
|
|
2777
|
-
|
|
2778
|
-
throw new Error("User not logged in");
|
|
2806
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2779
2807
|
const info = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerUserInfoRequest();
|
|
2780
2808
|
if (info.payload.success === false) {
|
|
2781
2809
|
throw new AirServiceError(info.payload.errorName, info.payload.errorMessage);
|
|
@@ -2792,11 +2820,37 @@ class AirService {
|
|
|
2792
2820
|
},
|
|
2793
2821
|
};
|
|
2794
2822
|
}
|
|
2823
|
+
async updateSessionConfig(config) {
|
|
2824
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2825
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, config, "f");
|
|
2826
|
+
const resultsPromise = [__classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendUpdateSessionConfigRequest(config)];
|
|
2827
|
+
if (__classPrivateFieldGet(this, _AirService_walletInitialization, "f")) {
|
|
2828
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_walletInitialization, "f")
|
|
2829
|
+
.then(() => __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2830
|
+
.catch(() => null));
|
|
2831
|
+
}
|
|
2832
|
+
if (__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")) {
|
|
2833
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")
|
|
2834
|
+
.then(() => __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2835
|
+
.catch(() => null));
|
|
2836
|
+
}
|
|
2837
|
+
if (__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")) {
|
|
2838
|
+
resultsPromise.push(__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")
|
|
2839
|
+
.then(() => __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendUpdateSessionConfigRequest(config))
|
|
2840
|
+
.catch(() => null));
|
|
2841
|
+
}
|
|
2842
|
+
const results = await Promise.all(resultsPromise);
|
|
2843
|
+
for (const result of results) {
|
|
2844
|
+
if (result && result.payload.success === false) {
|
|
2845
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
const sessionConfig = { locale: results[0].payload.locale };
|
|
2849
|
+
__classPrivateFieldSet(this, _AirService_sessionConfig, sessionConfig, "f");
|
|
2850
|
+
return sessionConfig;
|
|
2851
|
+
}
|
|
2795
2852
|
async goToPartner(partnerUrl) {
|
|
2796
|
-
|
|
2797
|
-
throw new Error("Service is not initialized");
|
|
2798
|
-
if (!this.isLoggedIn)
|
|
2799
|
-
throw new Error("No active session to generate token");
|
|
2853
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2800
2854
|
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendCrossPartnerTokenRequest(partnerUrl);
|
|
2801
2855
|
if (result.payload.success === false) {
|
|
2802
2856
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
@@ -2806,35 +2860,24 @@ class AirService {
|
|
|
2806
2860
|
};
|
|
2807
2861
|
}
|
|
2808
2862
|
async startRecovery(payload) {
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
catch (error) {
|
|
2816
|
-
throw AirServiceError.from(error);
|
|
2863
|
+
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendAccountRecoveryRequest(payload);
|
|
2864
|
+
if (result.payload.success === false) {
|
|
2865
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2817
2866
|
}
|
|
2818
2867
|
}
|
|
2819
2868
|
async getAccessToken() {
|
|
2820
|
-
|
|
2821
|
-
throw new Error("Service is not initialized");
|
|
2822
|
-
if (!this.isLoggedIn)
|
|
2823
|
-
throw new Error("No active session to get partner access token");
|
|
2869
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2824
2870
|
const result = await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").sendPartnerAccessTokenRequest();
|
|
2825
2871
|
if (result.payload.success !== true) {
|
|
2826
2872
|
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2827
2873
|
}
|
|
2828
2874
|
if (!result.payload.partnerAccessToken) {
|
|
2829
|
-
throw new
|
|
2875
|
+
throw new AirServiceError("UNAUTHORIZED", "Partner access token not found in response");
|
|
2830
2876
|
}
|
|
2831
2877
|
return { token: result.payload.partnerAccessToken };
|
|
2832
2878
|
}
|
|
2833
2879
|
async logout() {
|
|
2834
|
-
|
|
2835
|
-
throw new Error("Service is not initialized");
|
|
2836
|
-
if (!this.isLoggedIn)
|
|
2837
|
-
throw new Error("No active session to logout");
|
|
2880
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertLoggedIn).call(this);
|
|
2838
2881
|
// Clear up credentials first to avoid issues with wallet and auth messaging services
|
|
2839
2882
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
|
|
2840
2883
|
await Promise.all([
|
|
@@ -2846,33 +2889,21 @@ class AirService {
|
|
|
2846
2889
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthLoggedOut).call(this);
|
|
2847
2890
|
}
|
|
2848
2891
|
async cleanUp() {
|
|
2892
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
|
|
2893
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this);
|
|
2849
2894
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this);
|
|
2850
2895
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpAuth).call(this);
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
this
|
|
2896
|
+
__classPrivateFieldSet(this, _AirService_airEventListener, [], "f");
|
|
2897
|
+
__classPrivateFieldSet(this, _AirService_sessionId, undefined, "f");
|
|
2898
|
+
__classPrivateFieldSet(this, _AirService_buildEnv, undefined, "f");
|
|
2854
2899
|
}
|
|
2855
|
-
/**
|
|
2856
|
-
* Register an event listener for Air service events.
|
|
2857
|
-
*
|
|
2858
|
-
* Available events:
|
|
2859
|
-
* - "initialized": Service initialization completed
|
|
2860
|
-
* - "logged_in": User successfully logged in
|
|
2861
|
-
* - "logged_out": User logged out
|
|
2862
|
-
* - "wallet_initialized": Wallet initialization completed
|
|
2863
|
-
*
|
|
2864
|
-
* @param listener The event listener function
|
|
2865
|
-
*/
|
|
2866
2900
|
on(listener) {
|
|
2867
|
-
if (__classPrivateFieldGet(this,
|
|
2868
|
-
__classPrivateFieldGet(this,
|
|
2901
|
+
if (__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener) < 0)
|
|
2902
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").push(listener);
|
|
2869
2903
|
}
|
|
2870
2904
|
off(listener) {
|
|
2871
|
-
if (__classPrivateFieldGet(this,
|
|
2872
|
-
__classPrivateFieldGet(this,
|
|
2873
|
-
}
|
|
2874
|
-
clearEventListeners() {
|
|
2875
|
-
__classPrivateFieldSet(this, _AirService_airAuthListener, [], "f");
|
|
2905
|
+
if (__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener) >= 0)
|
|
2906
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").splice(__classPrivateFieldGet(this, _AirService_airEventListener, "f").indexOf(listener), 1);
|
|
2876
2907
|
}
|
|
2877
2908
|
async preloadCredential() {
|
|
2878
2909
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
|
|
@@ -2905,9 +2936,15 @@ class AirService {
|
|
|
2905
2936
|
return payload.verificationResult;
|
|
2906
2937
|
}
|
|
2907
2938
|
}
|
|
2908
|
-
_AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _AirService_enableLogging = new WeakMap(), _AirService_partnerId = new WeakMap(), _AirService_authMessagingService = new WeakMap(), _AirService_authIframeController = new WeakMap(), _AirService_isAuthInitialized = new WeakMap(),
|
|
2909
|
-
if (!this
|
|
2910
|
-
throw new
|
|
2939
|
+
_AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _AirService_enableLogging = new WeakMap(), _AirService_partnerId = new WeakMap(), _AirService_sessionId = new WeakMap(), _AirService_sessionConfig = new WeakMap(), _AirService_authMessagingService = new WeakMap(), _AirService_authIframeController = new WeakMap(), _AirService_isAuthInitialized = new WeakMap(), _AirService_airEventListener = new WeakMap(), _AirService_walletMessagingService = new WeakMap(), _AirService_walletIframeController = new WeakMap(), _AirService_walletInitialization = new WeakMap(), _AirService_walletLoggedInResult = new WeakMap(), _AirService_airWalletProvider = new WeakMap(), _AirService_recoveryInitialization = new WeakMap(), _AirService_recoveryMessagingService = new WeakMap(), _AirService_recoveryIframeController = new WeakMap(), _AirService_credentialsInitialization = new WeakMap(), _AirService_credentialMessagingService = new WeakMap(), _AirService_credentialIframeController = new WeakMap(), _AirService_instances = new WeakSet(), _AirService_assertInitialized = function _AirService_assertInitialized() {
|
|
2940
|
+
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2941
|
+
throw new AirServiceError("NOT_INITIALIZED", "Service is not initialized");
|
|
2942
|
+
}, _AirService_assertLoggedIn = function _AirService_assertLoggedIn() {
|
|
2943
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2944
|
+
if (!this.isLoggedIn)
|
|
2945
|
+
throw new AirServiceError("NOT_LOGGED_IN", "User not logged in");
|
|
2946
|
+
}, _AirService_ensureCredential = async function _AirService_ensureCredential() {
|
|
2947
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2911
2948
|
void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2912
2949
|
try {
|
|
2913
2950
|
if (!__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f"))
|
|
@@ -2917,11 +2954,11 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2917
2954
|
catch (error) {
|
|
2918
2955
|
__classPrivateFieldSet(this, _AirService_credentialsInitialization, null, "f");
|
|
2919
2956
|
log.error("Error ensuring credentials", error);
|
|
2920
|
-
throw error;
|
|
2957
|
+
throw AirServiceError.from(error);
|
|
2921
2958
|
}
|
|
2922
2959
|
}, _AirService_initializeCredentials = async function _AirService_initializeCredentials() {
|
|
2923
2960
|
if (__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f")) {
|
|
2924
|
-
throw new
|
|
2961
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing credentials");
|
|
2925
2962
|
}
|
|
2926
2963
|
const { credentialUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
2927
2964
|
const credentialIframeOrigin = new URL(credentialUrl).origin;
|
|
@@ -2934,11 +2971,13 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2934
2971
|
if (ev.data === AirCredentialMessageTypes.SERVICE_STARTED) {
|
|
2935
2972
|
window.removeEventListener("message", handleCredentialMessage);
|
|
2936
2973
|
const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendInitializationRequest({
|
|
2974
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
2937
2975
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
2938
2976
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
2939
2977
|
sdkVersion: airKitVersion,
|
|
2940
2978
|
partnerDAppUrl: window.location.href,
|
|
2941
2979
|
enableAutomation: this.shouldEnableAutomation(),
|
|
2980
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
2942
2981
|
});
|
|
2943
2982
|
if (payload.success === true) {
|
|
2944
2983
|
resolve();
|
|
@@ -2966,7 +3005,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2966
3005
|
if (closeDApp) {
|
|
2967
3006
|
window.close();
|
|
2968
3007
|
}
|
|
2969
|
-
throw error;
|
|
3008
|
+
throw AirServiceError.from(error);
|
|
2970
3009
|
}
|
|
2971
3010
|
}, _AirService_subscribeToCredentialEvents = function _AirService_subscribeToCredentialEvents() {
|
|
2972
3011
|
__classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").messages$.subscribe(async (message) => {
|
|
@@ -2991,8 +3030,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
2991
3030
|
await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").close();
|
|
2992
3031
|
__classPrivateFieldSet(this, _AirService_credentialsInitialization, undefined, "f");
|
|
2993
3032
|
}, _AirService_ensureWallet = async function _AirService_ensureWallet(option) {
|
|
2994
|
-
|
|
2995
|
-
throw new Error("Service not initialized");
|
|
3033
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
2996
3034
|
if (!__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
2997
3035
|
__classPrivateFieldSet(this, _AirService_walletInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeWallet).call(this, option), "f");
|
|
2998
3036
|
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
@@ -3006,7 +3044,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3006
3044
|
catch (error) {
|
|
3007
3045
|
__classPrivateFieldSet(this, _AirService_walletInitialization, null, "f");
|
|
3008
3046
|
log.error("Error initializing wallet", error);
|
|
3009
|
-
throw error;
|
|
3047
|
+
throw AirServiceError.from(error);
|
|
3010
3048
|
}
|
|
3011
3049
|
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
3012
3050
|
return __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f");
|
|
@@ -3017,7 +3055,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3017
3055
|
return __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, walletLoginResult.payload);
|
|
3018
3056
|
}, _AirService_initializeWallet = async function _AirService_initializeWallet(option) {
|
|
3019
3057
|
if (__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
3020
|
-
throw new
|
|
3058
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing");
|
|
3021
3059
|
const { walletUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
3022
3060
|
const walletIframeOrigin = new URL(walletUrl).origin;
|
|
3023
3061
|
try {
|
|
@@ -3028,10 +3066,12 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3028
3066
|
if (ev.data === AirWalletMessageTypes.SERVICE_STARTED) {
|
|
3029
3067
|
window.removeEventListener("message", handleWalletMessage);
|
|
3030
3068
|
const { payload } = await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").sendInitializationRequest({
|
|
3069
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3031
3070
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3032
3071
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3033
3072
|
sdkVersion: airKitVersion,
|
|
3034
3073
|
enableAutomation: this.shouldEnableAutomation(),
|
|
3074
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
3035
3075
|
});
|
|
3036
3076
|
if (payload.success === true) {
|
|
3037
3077
|
resolve();
|
|
@@ -3067,7 +3107,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3067
3107
|
catch (error) {
|
|
3068
3108
|
log.error("Error initializing wallet", error);
|
|
3069
3109
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this);
|
|
3070
|
-
throw error;
|
|
3110
|
+
throw AirServiceError.from(error);
|
|
3071
3111
|
}
|
|
3072
3112
|
}, _AirService_subscribeToWalletEvents = function _AirService_subscribeToWalletEvents() {
|
|
3073
3113
|
__classPrivateFieldGet(this, _AirService_walletMessagingService, "f").messages$.subscribe(async (msg) => {
|
|
@@ -3096,6 +3136,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3096
3136
|
const { windowController, port } = await WindowService$1.openAndInitializeWalletServiceWindow({
|
|
3097
3137
|
url: msg.payload.url,
|
|
3098
3138
|
windowId: msg.payload.windowId,
|
|
3139
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3099
3140
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3100
3141
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3101
3142
|
sdkVersion: airKitVersion,
|
|
@@ -3114,7 +3155,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3114
3155
|
}
|
|
3115
3156
|
});
|
|
3116
3157
|
}, _AirService_triggerEventListeners = function _AirService_triggerEventListeners(data) {
|
|
3117
|
-
__classPrivateFieldGet(this,
|
|
3158
|
+
__classPrivateFieldGet(this, _AirService_airEventListener, "f").forEach((listener) => {
|
|
3118
3159
|
listener(data);
|
|
3119
3160
|
});
|
|
3120
3161
|
}, _AirService_triggerAirAuthInitialized = function _AirService_triggerAirAuthInitialized(result) {
|
|
@@ -3177,8 +3218,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3177
3218
|
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, undefined, "f");
|
|
3178
3219
|
__classPrivateFieldSet(this, _AirService_walletInitialization, undefined, "f");
|
|
3179
3220
|
}, _AirService_ensureRecovery = async function _AirService_ensureRecovery() {
|
|
3180
|
-
|
|
3181
|
-
throw new Error("Service not initialized");
|
|
3221
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_assertInitialized).call(this);
|
|
3182
3222
|
if (!__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f")) {
|
|
3183
3223
|
__classPrivateFieldSet(this, _AirService_recoveryInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeRecovery).call(this), "f");
|
|
3184
3224
|
}
|
|
@@ -3188,11 +3228,11 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3188
3228
|
catch (error) {
|
|
3189
3229
|
__classPrivateFieldSet(this, _AirService_recoveryInitialization, null, "f");
|
|
3190
3230
|
log.error("Error initializing recovery", error);
|
|
3191
|
-
throw error;
|
|
3231
|
+
throw AirServiceError.from(error);
|
|
3192
3232
|
}
|
|
3193
3233
|
}, _AirService_initializeRecovery = async function _AirService_initializeRecovery() {
|
|
3194
3234
|
if (__classPrivateFieldGet(this, _AirService_recoveryInitialization, "f"))
|
|
3195
|
-
throw new
|
|
3235
|
+
throw new AirServiceError("ALREADY_INITIALIZING", "Already initializing");
|
|
3196
3236
|
const { recoveryUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
3197
3237
|
const recoveryIframeOrigin = new URL(recoveryUrl).origin;
|
|
3198
3238
|
try {
|
|
@@ -3203,10 +3243,12 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3203
3243
|
if (ev.data === AirRecoveryMessageTypes.SERVICE_STARTED) {
|
|
3204
3244
|
window.removeEventListener("message", handleRecoveryMessage);
|
|
3205
3245
|
const { payload } = await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").sendInitializationRequest({
|
|
3246
|
+
sessionId: __classPrivateFieldGet(this, _AirService_sessionId, "f"),
|
|
3206
3247
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3207
3248
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3208
3249
|
sdkVersion: airKitVersion,
|
|
3209
3250
|
enableAutomation: this.shouldEnableAutomation(),
|
|
3251
|
+
sessionConfig: __classPrivateFieldGet(this, _AirService_sessionConfig, "f"),
|
|
3210
3252
|
});
|
|
3211
3253
|
if (payload.success === true) {
|
|
3212
3254
|
resolve();
|
|
@@ -3230,7 +3272,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3230
3272
|
catch (error) {
|
|
3231
3273
|
log.error("Error initializing recovery", error);
|
|
3232
3274
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpRecovery).call(this);
|
|
3233
|
-
throw error;
|
|
3275
|
+
throw AirServiceError.from(error);
|
|
3234
3276
|
}
|
|
3235
3277
|
}, _AirService_subscribeToRecoveryEvents = function _AirService_subscribeToRecoveryEvents() {
|
|
3236
3278
|
__classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").messages$.subscribe(async (message) => {
|