@mocanetwork/airkit 1.1.0-beta.0 → 1.2.0-beta.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 +111 -58
- package/dist/airkit.esm.js +111 -58
- package/dist/airkit.umd.js +111 -58
- package/dist/types/airService.d.ts +8 -3
- package/dist/types/airWalletProvider.d.ts +1 -1
- package/dist/types/common/realm/messaging/auth.d.ts +8 -1
- package/dist/types/common/realm/messaging/types.d.ts +45 -50
- package/dist/types/common/realm/partner/config.d.ts +1 -0
- package/dist/types/messageService.d.ts +4 -0
- package/package.json +1 -1
package/dist/airkit.cjs.js
CHANGED
|
@@ -120,6 +120,8 @@ const AirAuthMessageTypes = {
|
|
|
120
120
|
SIGN_SIWE_MESSAGE_RESPONSE: "air_auth_sign_siwe_message_response",
|
|
121
121
|
CROSS_PARTNER_TOKEN_REQUEST: "air_auth_cross_partner_token_request",
|
|
122
122
|
CROSS_PARTNER_TOKEN_RESPONSE: "air_auth_cross_partner_token_response",
|
|
123
|
+
GET_PARTNER_ACCESS_TOKEN_REQUEST: "air_auth_get_partner_access_token_request",
|
|
124
|
+
GET_PARTNER_ACCESS_TOKEN_RESPONSE: "air_auth_get_partner_access_token_response",
|
|
123
125
|
LOGOUT_REQUEST: "air_auth_logout_request",
|
|
124
126
|
LOGOUT_RESPONSE: "air_auth_logout_response",
|
|
125
127
|
RESET_WALLET_COMMUNICATION: "air_auth_reset_wallet_communication"
|
|
@@ -131,6 +133,10 @@ const AirMessageTypes = {
|
|
|
131
133
|
INITIALIZATION_RESPONSE: "air_initialization_response",
|
|
132
134
|
INIT_AUTH_COMMUNICATION: "air_init_auth_communication",
|
|
133
135
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
136
|
+
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
137
|
+
WALLET_LOGIN_RESPONSE: "air_wallet_login_response",
|
|
138
|
+
SETUP_MFA_REQUEST: "air_setup_mfa_request",
|
|
139
|
+
SETUP_MFA_RESPONSE: "air_setup_mfa_response",
|
|
134
140
|
CLAIM_ID_REQUEST: "air_claim_id_request",
|
|
135
141
|
CLAIM_ID_RESPONSE: "air_claim_id_response",
|
|
136
142
|
DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
|
|
@@ -141,12 +147,13 @@ const AirMessageTypes = {
|
|
|
141
147
|
EXECUTE_ACTION_RESPONSE: "air_execute_action_response",
|
|
142
148
|
REVOKE_PERMISSIONS_REQUEST: "air_revoke_permissions_request",
|
|
143
149
|
REVOKE_PERMISSIONS_RESPONSE: "air_revoke_permissions_response",
|
|
150
|
+
LIST_ALL_SESSION_KEY_SCOPES_REQUEST: "air_list_all_session_key_scopes_request",
|
|
151
|
+
LIST_ALL_SESSION_KEY_SCOPES_RESPONSE: "air_list_all_session_key_scopes_response",
|
|
144
152
|
WALLET_IFRAME_VISIBILITY_REQUEST: "air_wallet_iframe_visibility_request",
|
|
145
153
|
IS_SMART_ACCOUNT_DEPLOYED_REQUEST: "air_is_smart_account_deployed_request",
|
|
146
154
|
IS_SMART_ACCOUNT_DEPLOYED_RESPONSE: "air_is_smart_account_deployed_response",
|
|
147
155
|
LOGOUT_REQUEST: "air_logout_request",
|
|
148
|
-
LOGOUT_RESPONSE: "air_logout_response"
|
|
149
|
-
SETUP_MFA_REQUEST: "air_setup_mfa_request"
|
|
156
|
+
LOGOUT_RESPONSE: "air_logout_response"
|
|
150
157
|
};
|
|
151
158
|
|
|
152
159
|
class BaseError extends Error {
|
|
@@ -1365,12 +1372,15 @@ var AirWalletProviderMessageTypes;
|
|
|
1365
1372
|
const ACCOUNT_MESSAGES = [
|
|
1366
1373
|
AirMessageTypes.INITIALIZATION_RESPONSE,
|
|
1367
1374
|
AirMessageTypes.WALLET_INITIALIZED,
|
|
1375
|
+
AirMessageTypes.WALLET_LOGIN_RESPONSE,
|
|
1376
|
+
AirMessageTypes.SETUP_MFA_RESPONSE,
|
|
1368
1377
|
AirMessageTypes.CLAIM_ID_RESPONSE,
|
|
1369
1378
|
AirMessageTypes.IS_SMART_ACCOUNT_DEPLOYED_RESPONSE,
|
|
1370
1379
|
AirMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE,
|
|
1371
1380
|
AirMessageTypes.EXECUTE_ACTION_RESPONSE,
|
|
1372
1381
|
AirMessageTypes.REVOKE_PERMISSIONS_RESPONSE,
|
|
1373
1382
|
AirMessageTypes.GRANT_PERMISSIONS_RESPONSE,
|
|
1383
|
+
AirMessageTypes.LIST_ALL_SESSION_KEY_SCOPES_RESPONSE,
|
|
1374
1384
|
AirMessageTypes.WALLET_INITIALIZED,
|
|
1375
1385
|
AirMessageTypes.WALLET_IFRAME_VISIBILITY_REQUEST,
|
|
1376
1386
|
AirMessageTypes.LOGOUT_RESPONSE,
|
|
@@ -1383,6 +1393,7 @@ const AUTH_MESSAGES = [
|
|
|
1383
1393
|
AirAuthMessageTypes.LOGOUT_RESPONSE,
|
|
1384
1394
|
AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
|
|
1385
1395
|
AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE,
|
|
1396
|
+
AirAuthMessageTypes.GET_PARTNER_ACCESS_TOKEN_RESPONSE,
|
|
1386
1397
|
AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST,
|
|
1387
1398
|
];
|
|
1388
1399
|
class AirMessageService {
|
|
@@ -1596,9 +1607,27 @@ class AirMessageService {
|
|
|
1596
1607
|
walletIframe.contentWindow.postMessage({ type: AirMessageTypes.GRANT_PERMISSIONS_REQUEST, payload }, origin);
|
|
1597
1608
|
return response;
|
|
1598
1609
|
}
|
|
1610
|
+
async sendListAllSessionKeyScopesRequest(walletIframe) {
|
|
1611
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirMessageTypes.LIST_ALL_SESSION_KEY_SCOPES_RESPONSE)));
|
|
1612
|
+
const { origin } = new URL(walletIframe.src);
|
|
1613
|
+
walletIframe.contentWindow.postMessage({ type: AirMessageTypes.LIST_ALL_SESSION_KEY_SCOPES_REQUEST }, origin);
|
|
1614
|
+
return response;
|
|
1615
|
+
}
|
|
1599
1616
|
onWalletInitialized() {
|
|
1600
1617
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirMessageTypes.WALLET_INITIALIZED)));
|
|
1601
1618
|
}
|
|
1619
|
+
sendWalletLoginRequest(walletIframe) {
|
|
1620
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirMessageTypes.WALLET_LOGIN_RESPONSE)));
|
|
1621
|
+
const { origin } = new URL(walletIframe.src);
|
|
1622
|
+
walletIframe.contentWindow.postMessage({ type: AirMessageTypes.WALLET_LOGIN_REQUEST }, origin);
|
|
1623
|
+
return response;
|
|
1624
|
+
}
|
|
1625
|
+
async sendSetupMfaRequest(walletIframe) {
|
|
1626
|
+
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirMessageTypes.SETUP_MFA_RESPONSE)));
|
|
1627
|
+
const { origin } = new URL(walletIframe.src);
|
|
1628
|
+
walletIframe.contentWindow.postMessage({ type: AirMessageTypes.SETUP_MFA_REQUEST }, origin);
|
|
1629
|
+
return response;
|
|
1630
|
+
}
|
|
1602
1631
|
async sendClaimIdRequest(walletIframe, payload) {
|
|
1603
1632
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirMessageTypes.CLAIM_ID_RESPONSE)));
|
|
1604
1633
|
const { origin } = new URL(walletIframe.src);
|
|
@@ -1645,6 +1674,12 @@ class AirMessageService {
|
|
|
1645
1674
|
this._providerMessage$ = new Subject();
|
|
1646
1675
|
this._providerEvent$ = new Subject();
|
|
1647
1676
|
}
|
|
1677
|
+
async sendGetPartnerAccessTokenRequest(authIframe) {
|
|
1678
|
+
const response = firstValueFrom(this.authMessage$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.GET_PARTNER_ACCESS_TOKEN_RESPONSE)));
|
|
1679
|
+
const { origin } = new URL(authIframe.src);
|
|
1680
|
+
authIframe.contentWindow.postMessage({ type: AirAuthMessageTypes.GET_PARTNER_ACCESS_TOKEN_REQUEST }, origin);
|
|
1681
|
+
return response;
|
|
1682
|
+
}
|
|
1648
1683
|
}
|
|
1649
1684
|
var AirMessageService$1 = AirMessageService.instance;
|
|
1650
1685
|
|
|
@@ -1682,7 +1717,7 @@ class AirWalletProvider {
|
|
|
1682
1717
|
_AirWalletProvider_ensureWallet.set(this, undefined);
|
|
1683
1718
|
_AirWalletProvider_getWalletIframeController.set(this, undefined);
|
|
1684
1719
|
_AirWalletProvider_eventListeners.set(this, undefined);
|
|
1685
|
-
this.
|
|
1720
|
+
this.startEventMessageListening = () => {
|
|
1686
1721
|
AirMessageService$1.providerEvent$.subscribe((message) => {
|
|
1687
1722
|
__classPrivateFieldGet(this, _AirWalletProvider_instances, "m", _AirWalletProvider_emit).call(this, message.payload.event, ...[message.payload.data]);
|
|
1688
1723
|
});
|
|
@@ -1829,7 +1864,7 @@ IframeController.defaultState = {
|
|
|
1829
1864
|
isVisible: false,
|
|
1830
1865
|
};
|
|
1831
1866
|
|
|
1832
|
-
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airAuthListener, _AirService_walletIframeController, _AirService_walletInitialization,
|
|
1867
|
+
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airAuthListener, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_ensureWallet, _AirService_initializeWallet, _AirService_triggerEventListeners, _AirService_triggerAirAuthInitialized, _AirService_triggerAirAuthLoggedIn, _AirService_triggerAirAuthLoggedOut, _AirService_triggerWalletInitialized, _AirService_createLoginResult, _AirService_createWalletInitializedResult, _AirService_cleanUpAuth, _AirService_cleanUpWallet;
|
|
1833
1868
|
class AirService {
|
|
1834
1869
|
constructor({ partnerId }) {
|
|
1835
1870
|
_AirService_instances.add(this);
|
|
@@ -1843,7 +1878,6 @@ class AirService {
|
|
|
1843
1878
|
_AirService_airAuthListener.set(this, []);
|
|
1844
1879
|
_AirService_walletIframeController.set(this, undefined);
|
|
1845
1880
|
_AirService_walletInitialization.set(this, undefined);
|
|
1846
|
-
_AirService_isWalletInitialized.set(this, false);
|
|
1847
1881
|
_AirService_walletLoggedInResult.set(this, undefined);
|
|
1848
1882
|
_AirService_airWalletProvider.set(this, undefined);
|
|
1849
1883
|
__classPrivateFieldSet(this, _AirService_partnerId, partnerId, "f");
|
|
@@ -2017,6 +2051,24 @@ class AirService {
|
|
|
2017
2051
|
throw AirServiceError.from(error);
|
|
2018
2052
|
}
|
|
2019
2053
|
}
|
|
2054
|
+
/**
|
|
2055
|
+
* @experimental This method is experimental and will change in the future.
|
|
2056
|
+
*/
|
|
2057
|
+
async listAllSessionKeyScopes() {
|
|
2058
|
+
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2059
|
+
throw new Error("Service is not initialized");
|
|
2060
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2061
|
+
try {
|
|
2062
|
+
const { payload } = await AirMessageService$1.sendListAllSessionKeyScopesRequest(__classPrivateFieldGet(this, _AirService_walletIframeController, "f").iframeElement);
|
|
2063
|
+
if (payload.success === false) {
|
|
2064
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2065
|
+
}
|
|
2066
|
+
return payload.sessionKeyScopes;
|
|
2067
|
+
}
|
|
2068
|
+
catch (error) {
|
|
2069
|
+
throw AirServiceError.from(error);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2020
2072
|
/**
|
|
2021
2073
|
* @experimental This method is experimental and will change in the future.
|
|
2022
2074
|
*/
|
|
@@ -2071,9 +2123,14 @@ class AirService {
|
|
|
2071
2123
|
return this.provider;
|
|
2072
2124
|
}
|
|
2073
2125
|
async preloadWallet() {
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2126
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
|
|
2127
|
+
}
|
|
2128
|
+
async setupOrUpdateMfa() {
|
|
2129
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this, { skipWalletLogin: true });
|
|
2130
|
+
const result = await AirMessageService$1.sendSetupMfaRequest(__classPrivateFieldGet(this, _AirService_walletIframeController, "f").iframeElement);
|
|
2131
|
+
if (result.payload.success === false) {
|
|
2132
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2133
|
+
}
|
|
2077
2134
|
}
|
|
2078
2135
|
async claimAirId(options) {
|
|
2079
2136
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
@@ -2142,50 +2199,51 @@ class AirService {
|
|
|
2142
2199
|
clearEventListeners() {
|
|
2143
2200
|
__classPrivateFieldSet(this, _AirService_airAuthListener, [], "f");
|
|
2144
2201
|
}
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2202
|
+
async getPartnerAccessToken() {
|
|
2203
|
+
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2204
|
+
throw new Error("Service is not initialized");
|
|
2205
|
+
if (!this.isLoggedIn)
|
|
2206
|
+
throw new Error("No active session to get partner access token");
|
|
2207
|
+
const result = await AirMessageService$1.sendGetPartnerAccessTokenRequest(__classPrivateFieldGet(this, _AirService_authIframeController, "f").iframeElement);
|
|
2208
|
+
if (result.payload.success === false) {
|
|
2209
|
+
throw new AirServiceError(result.payload.errorName, result.payload.errorMessage);
|
|
2210
|
+
}
|
|
2211
|
+
if (!result.payload.partnerAccessToken) {
|
|
2212
|
+
throw new Error("Partner access token not found in response");
|
|
2213
|
+
}
|
|
2214
|
+
return result.payload.partnerAccessToken;
|
|
2152
2215
|
}
|
|
2153
2216
|
}
|
|
2154
|
-
_AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _AirService_enableLogging = new WeakMap(), _AirService_partnerId = new WeakMap(), _AirService_authIframeController = new WeakMap(), _AirService_isAuthInitialized = new WeakMap(), _AirService_airAuthListener = new WeakMap(), _AirService_walletIframeController = new WeakMap(), _AirService_walletInitialization = new WeakMap(),
|
|
2155
|
-
// Result of this.#walletInitialization:
|
|
2156
|
-
// - If skipWalletLogin is true, it returns the result of empty abstractAccountAddress
|
|
2157
|
-
// - If skipWalletLogin is false, it returns the result of abstractAccountAddress from wallet initialization
|
|
2158
|
-
// - If #ensureWallet is called again, it returns the result of abstractAccountAddress from the second
|
|
2159
|
-
// wallet initialization if this first wallet initialization doesn't have abstractAccountAddress
|
|
2160
|
-
async function _AirService_ensureWallet(option) {
|
|
2217
|
+
_AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _AirService_enableLogging = new WeakMap(), _AirService_partnerId = new WeakMap(), _AirService_authIframeController = new WeakMap(), _AirService_isAuthInitialized = new WeakMap(), _AirService_airAuthListener = new WeakMap(), _AirService_walletIframeController = new WeakMap(), _AirService_walletInitialization = new WeakMap(), _AirService_walletLoggedInResult = new WeakMap(), _AirService_airWalletProvider = new WeakMap(), _AirService_instances = new WeakSet(), _AirService_ensureWallet = async function _AirService_ensureWallet(option) {
|
|
2161
2218
|
if (!this.isInitialized)
|
|
2162
2219
|
throw new Error("Service not initialized");
|
|
2163
2220
|
if (!this.isLoggedIn && !option?.skipWalletLogin)
|
|
2164
2221
|
throw new Error("User not logged in");
|
|
2165
2222
|
if (!__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
2166
2223
|
__classPrivateFieldSet(this, _AirService_walletInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeWallet).call(this, option), "f");
|
|
2224
|
+
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
2225
|
+
return __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f");
|
|
2167
2226
|
try {
|
|
2168
2227
|
const result = await __classPrivateFieldGet(this, _AirService_walletInitialization, "f");
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
result?.abstractAccountAddress ||
|
|
2172
|
-
__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f")?.abstractAccountAddress) {
|
|
2173
|
-
return result || __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f");
|
|
2174
|
-
}
|
|
2175
|
-
const walletInitResult = await AirMessageService$1.onWalletInitialized();
|
|
2176
|
-
if (walletInitResult.payload.success !== true) {
|
|
2177
|
-
throw new AirServiceError(walletInitResult.payload.errorName, walletInitResult.payload.errorMessage);
|
|
2228
|
+
if (option?.skipWalletLogin || result.isWalletLoggedIn) {
|
|
2229
|
+
return __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, result);
|
|
2178
2230
|
}
|
|
2179
|
-
return __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, walletInitResult.payload);
|
|
2180
2231
|
}
|
|
2181
2232
|
catch (error) {
|
|
2182
2233
|
__classPrivateFieldSet(this, _AirService_walletInitialization, null, "f");
|
|
2183
2234
|
log.error("Error initializing wallet", error);
|
|
2184
2235
|
throw error;
|
|
2185
2236
|
}
|
|
2237
|
+
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
2238
|
+
return __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f");
|
|
2239
|
+
const walletLoginResult = await AirMessageService$1.sendWalletLoginRequest(__classPrivateFieldGet(this, _AirService_walletIframeController, "f").iframeElement);
|
|
2240
|
+
if (walletLoginResult.payload.success !== true) {
|
|
2241
|
+
throw new AirServiceError(walletLoginResult.payload.errorName, walletLoginResult.payload.errorMessage);
|
|
2242
|
+
}
|
|
2243
|
+
return __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, walletLoginResult.payload);
|
|
2186
2244
|
}, _AirService_initializeWallet = async function _AirService_initializeWallet(option) {
|
|
2187
|
-
if (__classPrivateFieldGet(this,
|
|
2188
|
-
throw new
|
|
2245
|
+
if (__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
2246
|
+
throw new Error("Already initializing");
|
|
2189
2247
|
const { walletUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
2190
2248
|
log.info(walletUrl, "url loaded");
|
|
2191
2249
|
const walletIframeOrigin = new URL(walletUrl).origin;
|
|
@@ -2201,21 +2259,11 @@ async function _AirService_ensureWallet(option) {
|
|
|
2201
2259
|
walletIframeController.updateIframeState();
|
|
2202
2260
|
break;
|
|
2203
2261
|
}
|
|
2204
|
-
case AirMessageTypes.
|
|
2205
|
-
if (msg.payload.success === true &&
|
|
2262
|
+
case AirMessageTypes.WALLET_LOGIN_RESPONSE: {
|
|
2263
|
+
if (msg.payload.success === true && !__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f")) {
|
|
2206
2264
|
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, msg.payload), "f");
|
|
2207
2265
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerWalletInitialized).call(this, __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"));
|
|
2208
2266
|
}
|
|
2209
|
-
if (msg.payload.success === false) {
|
|
2210
|
-
if (!__classPrivateFieldGet(this, _AirService_isWalletInitialized, "f")) {
|
|
2211
|
-
// MFA fail case, also reset wallet port
|
|
2212
|
-
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpAuthWalletCommunication).call(this);
|
|
2213
|
-
}
|
|
2214
|
-
else {
|
|
2215
|
-
// Logout wallet and destroy the wallet iframe
|
|
2216
|
-
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpWallet).call(this);
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
2267
|
break;
|
|
2220
2268
|
}
|
|
2221
2269
|
}
|
|
@@ -2240,15 +2288,18 @@ async function _AirService_ensureWallet(option) {
|
|
|
2240
2288
|
};
|
|
2241
2289
|
window.addEventListener("message", handleAuthMessage);
|
|
2242
2290
|
});
|
|
2243
|
-
__classPrivateFieldGet(this, _AirService_airWalletProvider, "f").
|
|
2291
|
+
__classPrivateFieldGet(this, _AirService_airWalletProvider, "f").startEventMessageListening();
|
|
2244
2292
|
const walletInitPromise = AirMessageService$1.onWalletInitialized();
|
|
2245
2293
|
AirMessageService$1.setupIframeCommunication(__classPrivateFieldGet(this, _AirService_authIframeController, "f").iframeElement, __classPrivateFieldGet(this, _AirService_walletIframeController, "f").iframeElement, option?.skipWalletLogin ?? false);
|
|
2246
2294
|
const walletInitResult = await walletInitPromise;
|
|
2247
2295
|
if (walletInitResult.payload.success !== true) {
|
|
2248
2296
|
throw new AirServiceError(walletInitResult.payload.errorName, walletInitResult.payload.errorMessage);
|
|
2249
2297
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2298
|
+
if (!__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f") && walletInitResult.payload.isWalletLoggedIn) {
|
|
2299
|
+
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createWalletInitializedResult).call(this, walletInitResult.payload), "f");
|
|
2300
|
+
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerWalletInitialized).call(this, __classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"));
|
|
2301
|
+
}
|
|
2302
|
+
return walletInitResult.payload;
|
|
2252
2303
|
}
|
|
2253
2304
|
catch (error) {
|
|
2254
2305
|
log.error("Error initializing wallet", error);
|
|
@@ -2282,8 +2333,14 @@ async function _AirService_ensureWallet(option) {
|
|
|
2282
2333
|
isMFASetup: payload.isMFASetup,
|
|
2283
2334
|
};
|
|
2284
2335
|
}, _AirService_createWalletInitializedResult = function _AirService_createWalletInitializedResult(payload) {
|
|
2336
|
+
if ("isWalletLoggedIn" in payload && !payload.isWalletLoggedIn) {
|
|
2337
|
+
return {
|
|
2338
|
+
abstractAccountAddress: null,
|
|
2339
|
+
isMFASetup: __classPrivateFieldGet(this, _AirService_loginResult, "f")?.isMFASetup ?? false,
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2285
2342
|
return {
|
|
2286
|
-
abstractAccountAddress: payload.addresses
|
|
2343
|
+
abstractAccountAddress: payload.addresses.aa,
|
|
2287
2344
|
isMFASetup: payload.isMFASetup,
|
|
2288
2345
|
};
|
|
2289
2346
|
}, _AirService_cleanUpAuth = async function _AirService_cleanUpAuth() {
|
|
@@ -2308,18 +2365,14 @@ async function _AirService_ensureWallet(option) {
|
|
|
2308
2365
|
__classPrivateFieldGet(this, _AirService_walletIframeController, "f").destroy();
|
|
2309
2366
|
__classPrivateFieldSet(this, _AirService_walletIframeController, undefined, "f");
|
|
2310
2367
|
}
|
|
2311
|
-
// Close the message service
|
|
2312
|
-
AirMessageService$1.closeAirObservables();
|
|
2313
|
-
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, undefined, "f");
|
|
2314
|
-
__classPrivateFieldSet(this, _AirService_walletInitialization, undefined, "f");
|
|
2315
|
-
__classPrivateFieldSet(this, _AirService_isWalletInitialized, false, "f");
|
|
2316
|
-
}, _AirService_cleanUpAuthWalletCommunication = function _AirService_cleanUpAuthWalletCommunication() {
|
|
2317
|
-
if (!__classPrivateFieldGet(this, _AirService_isAuthInitialized, "f"))
|
|
2318
|
-
return;
|
|
2319
2368
|
const authIframeElement = __classPrivateFieldGet(this, _AirService_authIframeController, "f")?.iframeElement;
|
|
2320
2369
|
if (isElement(authIframeElement) && window.document.body.contains(authIframeElement)) {
|
|
2321
2370
|
AirMessageService$1.sendResetAuthServiceWalletCommunication(authIframeElement);
|
|
2322
2371
|
}
|
|
2372
|
+
// Close the message service
|
|
2373
|
+
AirMessageService$1.closeAirObservables();
|
|
2374
|
+
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, undefined, "f");
|
|
2375
|
+
__classPrivateFieldSet(this, _AirService_walletInitialization, undefined, "f");
|
|
2323
2376
|
};
|
|
2324
2377
|
|
|
2325
2378
|
exports.AirService = AirService;
|