@mocanetwork/airkit 1.6.0-beta.0 → 1.6.0-beta.2
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 +40 -142
- package/dist/airkit.esm.js +40 -142
- package/dist/airkit.umd.js +40 -142
- package/dist/types/airService.d.ts +2 -3
- package/dist/types/authMessageService.d.ts +1 -6
- package/dist/types/common/air/messaging/auth.d.ts +1 -13
- package/dist/types/common/air/messaging/credential.d.ts +13 -12
- package/dist/types/common/air/messaging/messageServiceBase.d.ts +2 -1
- package/dist/types/common/air/messaging/recovery.d.ts +2 -5
- package/dist/types/common/air/messaging/wallet.d.ts +2 -10
- package/dist/types/common/const.d.ts +4 -4
- package/dist/types/credentialMessageService.d.ts +1 -2
- package/dist/types/recoveryMessageService.d.ts +0 -1
- package/dist/types/walletMessageService.d.ts +0 -3
- 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-beta.
|
|
100
|
+
var version = "1.6.0-beta.2";
|
|
101
101
|
var airkitPackage = {
|
|
102
102
|
version: version};
|
|
103
103
|
|
|
@@ -116,7 +116,6 @@ const AirAuthMessageTypes = {
|
|
|
116
116
|
REFRESH_TOKEN_RESPONSE: "air_auth_refresh_token_response",
|
|
117
117
|
WALLET_TOKEN_REQUEST: "air_auth_wallet_token_request",
|
|
118
118
|
WALLET_TOKEN_RESPONSE: "air_auth_wallet_token_response",
|
|
119
|
-
INIT_WALLET_COMMUNICATION: "air_auth_init_wallet_communication",
|
|
120
119
|
IFRAME_VISIBILITY_REQUEST: "air_auth_iframe_visibility_request",
|
|
121
120
|
SETUP_WALLET_REQUEST: "air_auth_setup_wallet_request",
|
|
122
121
|
SETUP_WALLET_RESPONSE: "air_auth_setup_wallet_response",
|
|
@@ -130,15 +129,10 @@ const AirAuthMessageTypes = {
|
|
|
130
129
|
PARTNER_ACCESS_TOKEN_RESPONSE: "air_auth_partner_access_token_response",
|
|
131
130
|
LOGOUT_REQUEST: "air_auth_logout_request",
|
|
132
131
|
LOGOUT_RESPONSE: "air_auth_logout_response",
|
|
133
|
-
RESET_WALLET_COMMUNICATION: "air_auth_reset_wallet_communication",
|
|
134
|
-
INIT_RECOVERY_COMMUNICATION: "air_auth_init_recovery_communication",
|
|
135
|
-
RESET_RECOVERY_COMMUNICATION: "air_auth_reset_recovery_communication",
|
|
136
132
|
START_RECOVERY_REQUEST: "air_start_recovery_request",
|
|
137
133
|
START_RECOVERY_RESPONSE: "air_start_recovery_response",
|
|
138
134
|
RECOVERY_REQUEST: "air_auth_recovery_request",
|
|
139
135
|
RECOVERY_RESPONSE: "air_auth_recovery_response",
|
|
140
|
-
INIT_CREDENTIAL_COMMUNICATION: "air_auth_init_credential_communication",
|
|
141
|
-
RESET_CREDENTIAL_COMMUNICATION: "air_auth_reset_credential_communication",
|
|
142
136
|
EXPIRED_LOGOUT_REQUEST: "air_auth_expired_logout_request"
|
|
143
137
|
};
|
|
144
138
|
|
|
@@ -146,10 +140,6 @@ const AirCredentialMessageTypes = {
|
|
|
146
140
|
SERVICE_STARTED: "air_credential_service_started",
|
|
147
141
|
INITIALIZATION_REQUEST: "air_credential_initialization_request",
|
|
148
142
|
INITIALIZATION_RESPONSE: "air_credential_initialization_response",
|
|
149
|
-
INIT_AUTH_COMMUNICATION: "air_credential_init_auth_communication",
|
|
150
|
-
CREDENTIAL_AUTH_INITIALIZED: "air_credential_auth_initialized",
|
|
151
|
-
INIT_WALLET_COMMUNICATION: "air_credential_init_wallet_communication",
|
|
152
|
-
CREDENTIAL_WALLET_INITIALIZED: "air_credential_wallet_initialized",
|
|
153
143
|
CREDENTIAL_IFRAME_VISIBILITY_REQUEST: "air_credential_iframe_visibility_request",
|
|
154
144
|
LOGOUT_REQUEST: "air_credential_logout_request",
|
|
155
145
|
LOGOUT_RESPONSE: "air_credential_logout_response",
|
|
@@ -165,7 +155,6 @@ const AirRecoveryMessageTypes = {
|
|
|
165
155
|
SERVICE_STARTED: "air_recovery_service_started",
|
|
166
156
|
INITIALIZATION_REQUEST: "air_recovery_initialization_request",
|
|
167
157
|
INITIALIZATION_RESPONSE: "air_recovery_initialization_response",
|
|
168
|
-
INIT_AUTH_COMMUNICATION: "air_recovery_init_auth_communication",
|
|
169
158
|
RECOVERY_INITIALIZED: "air_recovery_initialized",
|
|
170
159
|
RECOVERY_IFRAME_VISIBILITY_REQUEST: "air_recovery_iframe_visibility_request",
|
|
171
160
|
LOGOUT_REQUEST: "air_recovery_logout_request",
|
|
@@ -178,7 +167,6 @@ const AirWalletMessageTypes = {
|
|
|
178
167
|
INITIALIZATION_RESPONSE: "air_initialization_response",
|
|
179
168
|
CLOSE_MODAL_REQUEST: "air_close_modal_request",
|
|
180
169
|
CLOSE_MODAL_RESPONSE: "air_close_modal_response",
|
|
181
|
-
INIT_AUTH_COMMUNICATION: "air_init_auth_communication",
|
|
182
170
|
WALLET_INITIALIZED: "air_wallet_initialized",
|
|
183
171
|
WALLET_LOGIN_REQUEST: "air_wallet_login_request",
|
|
184
172
|
WALLET_LOGIN_RESPONSE: "air_wallet_login_response",
|
|
@@ -197,8 +185,6 @@ const AirWalletMessageTypes = {
|
|
|
197
185
|
IS_SMART_ACCOUNT_DEPLOYED_RESPONSE: "air_is_smart_account_deployed_response",
|
|
198
186
|
LOGOUT_REQUEST: "air_logout_request",
|
|
199
187
|
LOGOUT_RESPONSE: "air_logout_response",
|
|
200
|
-
INIT_CREDENTIAL_COMMUNICATION: "air_init_credential_communication",
|
|
201
|
-
RESET_CREDENTIAL_COMMUNICATION: "air_reset_credential_communication",
|
|
202
188
|
INTERNAL_PROVIDER_REQUEST: "air_internal_provider_request",
|
|
203
189
|
INTERNAL_PROVIDER_RESPONSE: "air_internal_provider_response"
|
|
204
190
|
};
|
|
@@ -1685,6 +1671,7 @@ class AirError extends BaseError {}
|
|
|
1685
1671
|
new Set(AirClientUserErrors);
|
|
1686
1672
|
new Set(Object.values(Codes));
|
|
1687
1673
|
|
|
1674
|
+
class OutgoingMessageEvent extends MessageEvent {}
|
|
1688
1675
|
class MessageServiceBase {
|
|
1689
1676
|
get events$() {
|
|
1690
1677
|
return this._events$;
|
|
@@ -1700,13 +1687,16 @@ class MessageServiceBase {
|
|
|
1700
1687
|
this.allowedMessageTypes = allowedMessageTypes;
|
|
1701
1688
|
this.closeListener = null;
|
|
1702
1689
|
}
|
|
1690
|
+
static _getName(name, targetName) {
|
|
1691
|
+
return `${name} Service: ${targetName} Channel`;
|
|
1692
|
+
}
|
|
1703
1693
|
async _open(target) {
|
|
1704
1694
|
await this.close();
|
|
1705
1695
|
this.eventSubject = new Subject();
|
|
1706
1696
|
this._events$ = this.eventSubject.asObservable();
|
|
1707
1697
|
this._messages$ = this.eventSubject.pipe(map(ev => ev.data));
|
|
1708
1698
|
this._events$.subscribe(event => {
|
|
1709
|
-
const sentOrReceived = event
|
|
1699
|
+
const sentOrReceived = event instanceof OutgoingMessageEvent ? "sent" : "received";
|
|
1710
1700
|
log.debug(`[${this.name}] Message ${sentOrReceived}:`, JSON.stringify(event.data, bigIntReplacer));
|
|
1711
1701
|
});
|
|
1712
1702
|
const handleMessage = async ev => {
|
|
@@ -1778,7 +1768,7 @@ class MessageServiceBase {
|
|
|
1778
1768
|
log.debug(`[${this.name}] Not opened yet`);
|
|
1779
1769
|
return;
|
|
1780
1770
|
}
|
|
1781
|
-
this.eventSubject.next(new
|
|
1771
|
+
this.eventSubject.next(new OutgoingMessageEvent("message", {
|
|
1782
1772
|
data: clonedMessage,
|
|
1783
1773
|
origin: window.origin
|
|
1784
1774
|
}));
|
|
@@ -1943,8 +1933,6 @@ const ALLOWED_AUTH_MESSAGES = [
|
|
|
1943
1933
|
AirAuthMessageTypes.LOGIN_RESPONSE,
|
|
1944
1934
|
AirAuthMessageTypes.SETUP_WALLET_REQUEST,
|
|
1945
1935
|
AirAuthMessageTypes.SETUP_RECOVERY_REQUEST,
|
|
1946
|
-
AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION,
|
|
1947
|
-
AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION,
|
|
1948
1936
|
AirAuthMessageTypes.LOGOUT_RESPONSE,
|
|
1949
1937
|
AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE,
|
|
1950
1938
|
AirAuthMessageTypes.CROSS_PARTNER_TOKEN_RESPONSE,
|
|
@@ -1965,11 +1953,6 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
1965
1953
|
const window = authIframe.contentWindow;
|
|
1966
1954
|
await super._open({ window, origin });
|
|
1967
1955
|
}
|
|
1968
|
-
async initWalletCommunication() {
|
|
1969
|
-
await this.sendMessage({
|
|
1970
|
-
type: AirAuthMessageTypes.INIT_WALLET_COMMUNICATION,
|
|
1971
|
-
});
|
|
1972
|
-
}
|
|
1973
1956
|
async sendPartnerUserInfoRequest() {
|
|
1974
1957
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE)));
|
|
1975
1958
|
await this.sendMessage({
|
|
@@ -1983,14 +1966,14 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
1983
1966
|
await this.sendMessage({ type: AirAuthMessageTypes.LOGIN_REQUEST, payload });
|
|
1984
1967
|
return response;
|
|
1985
1968
|
}
|
|
1969
|
+
onLoggedIn() {
|
|
1970
|
+
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.LOGIN_RESPONSE && msg.payload?.success === true)));
|
|
1971
|
+
}
|
|
1986
1972
|
async logout() {
|
|
1987
1973
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.LOGOUT_RESPONSE)));
|
|
1988
1974
|
await this.sendMessage({ type: AirAuthMessageTypes.LOGOUT_REQUEST });
|
|
1989
1975
|
return response;
|
|
1990
1976
|
}
|
|
1991
|
-
async resetWalletCommunication() {
|
|
1992
|
-
await this.sendMessage({ type: AirAuthMessageTypes.RESET_WALLET_COMMUNICATION });
|
|
1993
|
-
}
|
|
1994
1977
|
async sendInitializationRequest(payload) {
|
|
1995
1978
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirAuthMessageTypes.INITIALIZATION_RESPONSE)));
|
|
1996
1979
|
await this.sendMessage({ type: AirAuthMessageTypes.INITIALIZATION_REQUEST, payload });
|
|
@@ -2007,16 +1990,6 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
2007
1990
|
async sendSetupWalletErrorResponse(error) {
|
|
2008
1991
|
await this.sendMessage(this.createErrorResponseMessage(AirAuthMessageTypes.SETUP_WALLET_RESPONSE, error));
|
|
2009
1992
|
}
|
|
2010
|
-
async initRecoveryCommunication() {
|
|
2011
|
-
await this.sendMessage({
|
|
2012
|
-
type: AirAuthMessageTypes.INIT_RECOVERY_COMMUNICATION,
|
|
2013
|
-
});
|
|
2014
|
-
}
|
|
2015
|
-
async resetRecoveryCommunication() {
|
|
2016
|
-
await this.sendMessage({
|
|
2017
|
-
type: AirAuthMessageTypes.RESET_RECOVERY_COMMUNICATION,
|
|
2018
|
-
});
|
|
2019
|
-
}
|
|
2020
1993
|
async sendSetupRecoverySuccessResponse() {
|
|
2021
1994
|
await this.sendMessage({
|
|
2022
1995
|
type: AirAuthMessageTypes.SETUP_RECOVERY_RESPONSE,
|
|
@@ -2053,19 +2026,6 @@ class AuthMessageService extends MessageServiceBase {
|
|
|
2053
2026
|
await this.sendMessage({ type: AirAuthMessageTypes.START_RECOVERY_REQUEST, payload });
|
|
2054
2027
|
return response;
|
|
2055
2028
|
}
|
|
2056
|
-
/*
|
|
2057
|
-
* Initialize credential communication
|
|
2058
|
-
*/
|
|
2059
|
-
async initCredentialCommunication() {
|
|
2060
|
-
await this.sendMessage({
|
|
2061
|
-
type: AirAuthMessageTypes.INIT_CREDENTIAL_COMMUNICATION,
|
|
2062
|
-
});
|
|
2063
|
-
}
|
|
2064
|
-
async resetCredentialCommunication() {
|
|
2065
|
-
await this.sendMessage({
|
|
2066
|
-
type: AirAuthMessageTypes.RESET_CREDENTIAL_COMMUNICATION,
|
|
2067
|
-
});
|
|
2068
|
-
}
|
|
2069
2029
|
}
|
|
2070
2030
|
_a$3 = AuthMessageService;
|
|
2071
2031
|
_AuthMessageService_instance = { value: void 0 };
|
|
@@ -2074,8 +2034,6 @@ var _a$2, _CredentialMessageService_instance;
|
|
|
2074
2034
|
const ALLOWED_CREDENTIAL_MESSAGES = [
|
|
2075
2035
|
AirCredentialMessageTypes.INITIALIZATION_RESPONSE,
|
|
2076
2036
|
AirCredentialMessageTypes.CREDENTIAL_IFRAME_VISIBILITY_REQUEST,
|
|
2077
|
-
AirCredentialMessageTypes.CREDENTIAL_AUTH_INITIALIZED,
|
|
2078
|
-
AirCredentialMessageTypes.CREDENTIAL_WALLET_INITIALIZED,
|
|
2079
2037
|
AirCredentialMessageTypes.LOGOUT_RESPONSE,
|
|
2080
2038
|
AirCredentialMessageTypes.ISSUE_CREDENTIAL_RESPONSE,
|
|
2081
2039
|
AirCredentialMessageTypes.VERIFY_CREDENTIAL_RESPONSE,
|
|
@@ -2101,20 +2059,6 @@ class CredentialMessageService extends MessageServiceBase {
|
|
|
2101
2059
|
});
|
|
2102
2060
|
return response;
|
|
2103
2061
|
}
|
|
2104
|
-
async initAuthCommunication() {
|
|
2105
|
-
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.CREDENTIAL_AUTH_INITIALIZED)));
|
|
2106
|
-
await this.sendMessage({
|
|
2107
|
-
type: AirCredentialMessageTypes.INIT_AUTH_COMMUNICATION,
|
|
2108
|
-
});
|
|
2109
|
-
return response;
|
|
2110
|
-
}
|
|
2111
|
-
async initWalletCommunication() {
|
|
2112
|
-
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.CREDENTIAL_WALLET_INITIALIZED)));
|
|
2113
|
-
await this.sendMessage({
|
|
2114
|
-
type: AirCredentialMessageTypes.INIT_WALLET_COMMUNICATION,
|
|
2115
|
-
});
|
|
2116
|
-
return response;
|
|
2117
|
-
}
|
|
2118
2062
|
async logout() {
|
|
2119
2063
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirCredentialMessageTypes.LOGOUT_RESPONSE)));
|
|
2120
2064
|
await this.sendMessage({
|
|
@@ -2235,11 +2179,6 @@ class RecoveryMessageService extends MessageServiceBase {
|
|
|
2235
2179
|
});
|
|
2236
2180
|
return response;
|
|
2237
2181
|
}
|
|
2238
|
-
async initAuthCommunication() {
|
|
2239
|
-
await this.sendMessage({
|
|
2240
|
-
type: AirRecoveryMessageTypes.INIT_AUTH_COMMUNICATION,
|
|
2241
|
-
});
|
|
2242
|
-
}
|
|
2243
2182
|
async onInitialized() {
|
|
2244
2183
|
return firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirRecoveryMessageTypes.RECOVERY_INITIALIZED)));
|
|
2245
2184
|
}
|
|
@@ -2286,14 +2225,6 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2286
2225
|
const window = walletIframe.contentWindow;
|
|
2287
2226
|
await super._open({ window, origin });
|
|
2288
2227
|
}
|
|
2289
|
-
async initAuthCommunication(skipWalletLogin) {
|
|
2290
|
-
await this.sendMessage({
|
|
2291
|
-
type: AirWalletMessageTypes.INIT_AUTH_COMMUNICATION,
|
|
2292
|
-
payload: {
|
|
2293
|
-
skipWalletLogin,
|
|
2294
|
-
},
|
|
2295
|
-
});
|
|
2296
|
-
}
|
|
2297
2228
|
async sendDeploySmartAccountRequest() {
|
|
2298
2229
|
const response = firstValueFrom(this.messages$.pipe(filter((msg) => msg.type === AirWalletMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE)));
|
|
2299
2230
|
await this.sendMessage({
|
|
@@ -2387,16 +2318,6 @@ class WalletMessageService extends MessageServiceBase {
|
|
|
2387
2318
|
});
|
|
2388
2319
|
return response;
|
|
2389
2320
|
}
|
|
2390
|
-
async initCredentialCommunication() {
|
|
2391
|
-
await this.sendMessage({
|
|
2392
|
-
type: AirWalletMessageTypes.INIT_CREDENTIAL_COMMUNICATION,
|
|
2393
|
-
});
|
|
2394
|
-
}
|
|
2395
|
-
async resetCredentialCommunication() {
|
|
2396
|
-
await this.sendMessage({
|
|
2397
|
-
type: AirWalletMessageTypes.RESET_CREDENTIAL_COMMUNICATION,
|
|
2398
|
-
});
|
|
2399
|
-
}
|
|
2400
2321
|
}
|
|
2401
2322
|
_a = WalletMessageService;
|
|
2402
2323
|
_WalletMessageService_instance = { value: void 0 };
|
|
@@ -2595,7 +2516,7 @@ class WindowService {
|
|
|
2595
2516
|
}
|
|
2596
2517
|
var WindowService$1 = WindowService.instance;
|
|
2597
2518
|
|
|
2598
|
-
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airAuthListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController,
|
|
2519
|
+
var _AirService_instances, _AirService_loginResult, _AirService_buildEnv, _AirService_enableLogging, _AirService_partnerId, _AirService_authMessagingService, _AirService_authIframeController, _AirService_isAuthInitialized, _AirService_airAuthListener, _AirService_walletMessagingService, _AirService_walletIframeController, _AirService_walletInitialization, _AirService_walletLoggedInResult, _AirService_airWalletProvider, _AirService_recoveryInitialization, _AirService_recoveryMessagingService, _AirService_recoveryIframeController, _AirService_credentialsInitialization, _AirService_credentialMessagingService, _AirService_credentialIframeController, _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;
|
|
2599
2520
|
const airKitVersion = airkitPackage.version;
|
|
2600
2521
|
class AirService {
|
|
2601
2522
|
constructor({ partnerId }) {
|
|
@@ -2736,7 +2657,7 @@ class AirService {
|
|
|
2736
2657
|
__classPrivateFieldSet(this, _AirService_isAuthInitialized, true, "f");
|
|
2737
2658
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_triggerAirAuthInitialized).call(this, { rehydrated: result.rehydrated });
|
|
2738
2659
|
if (result.preloadWallet)
|
|
2739
|
-
this.preloadWallet();
|
|
2660
|
+
void this.preloadWallet();
|
|
2740
2661
|
// rehydrated auth session
|
|
2741
2662
|
if (result.rehydrated) {
|
|
2742
2663
|
__classPrivateFieldSet(this, _AirService_loginResult, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_createLoginResult).call(this, result), "f");
|
|
@@ -2939,8 +2860,6 @@ class AirService {
|
|
|
2939
2860
|
* - "logged_in": User successfully logged in
|
|
2940
2861
|
* - "logged_out": User logged out
|
|
2941
2862
|
* - "wallet_initialized": Wallet initialization completed
|
|
2942
|
-
* - "credential_issuance_finished": Credential issuance finished (success or failure)
|
|
2943
|
-
* - "credential_verification_finished": Credential verification finished (success or failure)
|
|
2944
2863
|
*
|
|
2945
2864
|
* @param listener The event listener function
|
|
2946
2865
|
*/
|
|
@@ -2955,23 +2874,26 @@ class AirService {
|
|
|
2955
2874
|
clearEventListeners() {
|
|
2956
2875
|
__classPrivateFieldSet(this, _AirService_airAuthListener, [], "f");
|
|
2957
2876
|
}
|
|
2877
|
+
async preloadCredential() {
|
|
2878
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
|
|
2879
|
+
}
|
|
2958
2880
|
async issueCredential({ authToken, issuerDid, credentialId, credentialSubject, }) {
|
|
2959
|
-
await __classPrivateFieldGet(this, _AirService_instances, "m",
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2881
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
|
|
2882
|
+
const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendIssueCredentialRequest({
|
|
2883
|
+
partnerToken: authToken,
|
|
2884
|
+
issuerDid,
|
|
2885
|
+
credentialId,
|
|
2886
|
+
credentialSubject,
|
|
2887
|
+
});
|
|
2888
|
+
if (payload.closeDApp) {
|
|
2889
|
+
window.close();
|
|
2968
2890
|
}
|
|
2969
|
-
|
|
2970
|
-
throw AirServiceError.
|
|
2891
|
+
if (payload.success === false) {
|
|
2892
|
+
throw new AirServiceError(payload.errorName, payload.errorMessage);
|
|
2971
2893
|
}
|
|
2972
2894
|
}
|
|
2973
2895
|
async verifyCredential({ authToken, programId, redirectUrl, }) {
|
|
2974
|
-
await __classPrivateFieldGet(this, _AirService_instances, "m",
|
|
2896
|
+
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureCredential).call(this);
|
|
2975
2897
|
const { payload } = await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").sendVerifyCredentialRequest({
|
|
2976
2898
|
partnerToken: authToken,
|
|
2977
2899
|
programId,
|
|
@@ -2983,11 +2905,9 @@ class AirService {
|
|
|
2983
2905
|
return payload.verificationResult;
|
|
2984
2906
|
}
|
|
2985
2907
|
}
|
|
2986
|
-
_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(), _AirService_airAuthListener = 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(),
|
|
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(), _AirService_airAuthListener = 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_ensureCredential = async function _AirService_ensureCredential() {
|
|
2987
2909
|
if (!this.isInitialized)
|
|
2988
2910
|
throw new Error("Service not initialized");
|
|
2989
|
-
if (!this.isLoggedIn)
|
|
2990
|
-
throw new Error("User not logged in");
|
|
2991
2911
|
void __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
2992
2912
|
try {
|
|
2993
2913
|
if (!__classPrivateFieldGet(this, _AirService_credentialsInitialization, "f"))
|
|
@@ -3004,11 +2924,12 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3004
2924
|
throw new Error("Already initializing credentials");
|
|
3005
2925
|
}
|
|
3006
2926
|
const { credentialUrl } = AIR_URLS[__classPrivateFieldGet(this, _AirService_buildEnv, "f")];
|
|
3007
|
-
const
|
|
2927
|
+
const credentialIframeOrigin = new URL(credentialUrl).origin;
|
|
2928
|
+
let closeDApp = false;
|
|
3008
2929
|
try {
|
|
3009
2930
|
const credentialInitRequestPromise = new Promise((resolve, reject) => {
|
|
3010
2931
|
const handleCredentialMessage = async (ev) => {
|
|
3011
|
-
if (ev.origin !==
|
|
2932
|
+
if (ev.origin !== credentialIframeOrigin)
|
|
3012
2933
|
return;
|
|
3013
2934
|
if (ev.data === AirCredentialMessageTypes.SERVICE_STARTED) {
|
|
3014
2935
|
window.removeEventListener("message", handleCredentialMessage);
|
|
@@ -3016,12 +2937,14 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3016
2937
|
partnerId: __classPrivateFieldGet(this, _AirService_partnerId, "f"),
|
|
3017
2938
|
enableLogging: __classPrivateFieldGet(this, _AirService_enableLogging, "f"),
|
|
3018
2939
|
sdkVersion: airKitVersion,
|
|
2940
|
+
partnerDAppUrl: window.location.href,
|
|
3019
2941
|
enableAutomation: this.shouldEnableAutomation(),
|
|
3020
2942
|
});
|
|
3021
2943
|
if (payload.success === true) {
|
|
3022
2944
|
resolve();
|
|
3023
2945
|
}
|
|
3024
2946
|
else {
|
|
2947
|
+
closeDApp = !!payload.closeDApp;
|
|
3025
2948
|
reject(new AirServiceError(payload.errorName, payload.errorMessage));
|
|
3026
2949
|
}
|
|
3027
2950
|
}
|
|
@@ -3034,18 +2957,15 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3034
2957
|
await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").open(__classPrivateFieldGet(this, _AirService_credentialIframeController, "f").iframeElement);
|
|
3035
2958
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_subscribeToCredentialEvents).call(this);
|
|
3036
2959
|
await credentialInitRequestPromise;
|
|
3037
|
-
await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").initCredentialCommunication();
|
|
3038
|
-
await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").initAuthCommunication();
|
|
3039
|
-
log.info("[Embed] Credential auth channel initialized");
|
|
3040
2960
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_ensureWallet).call(this);
|
|
3041
|
-
await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").initCredentialCommunication();
|
|
3042
|
-
await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").initWalletCommunication();
|
|
3043
|
-
log.info("[Embed] Credential wallet channel initialized");
|
|
3044
2961
|
log.info("Credential service initialized successfully");
|
|
3045
2962
|
}
|
|
3046
2963
|
catch (error) {
|
|
3047
2964
|
log.error("Error initializing credentials", error);
|
|
3048
2965
|
await __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_cleanUpCredential).call(this);
|
|
2966
|
+
if (closeDApp) {
|
|
2967
|
+
window.close();
|
|
2968
|
+
}
|
|
3049
2969
|
throw error;
|
|
3050
2970
|
}
|
|
3051
2971
|
}, _AirService_subscribeToCredentialEvents = function _AirService_subscribeToCredentialEvents() {
|
|
@@ -3068,21 +2988,11 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3068
2988
|
__classPrivateFieldGet(this, _AirService_credentialIframeController, "f").destroy();
|
|
3069
2989
|
__classPrivateFieldSet(this, _AirService_credentialIframeController, undefined, "f");
|
|
3070
2990
|
}
|
|
3071
|
-
const walletIframeElement = __classPrivateFieldGet(this, _AirService_walletIframeController, "f")?.iframeElement;
|
|
3072
|
-
if (isElement(walletIframeElement) && window.document.body.contains(walletIframeElement)) {
|
|
3073
|
-
await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").resetCredentialCommunication();
|
|
3074
|
-
}
|
|
3075
|
-
const authIframeElement = __classPrivateFieldGet(this, _AirService_authIframeController, "f")?.iframeElement;
|
|
3076
|
-
if (isElement(authIframeElement) && window.document.body.contains(authIframeElement)) {
|
|
3077
|
-
await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").resetCredentialCommunication();
|
|
3078
|
-
}
|
|
3079
2991
|
await __classPrivateFieldGet(this, _AirService_credentialMessagingService, "f").close();
|
|
3080
2992
|
__classPrivateFieldSet(this, _AirService_credentialsInitialization, undefined, "f");
|
|
3081
2993
|
}, _AirService_ensureWallet = async function _AirService_ensureWallet(option) {
|
|
3082
2994
|
if (!this.isInitialized)
|
|
3083
2995
|
throw new Error("Service not initialized");
|
|
3084
|
-
if (!this.isLoggedIn && !option?.skipWalletLogin)
|
|
3085
|
-
throw new Error("User not logged in");
|
|
3086
2996
|
if (!__classPrivateFieldGet(this, _AirService_walletInitialization, "f"))
|
|
3087
2997
|
__classPrivateFieldSet(this, _AirService_walletInitialization, __classPrivateFieldGet(this, _AirService_instances, "m", _AirService_initializeWallet).call(this, option), "f");
|
|
3088
2998
|
if (__classPrivateFieldGet(this, _AirService_walletLoggedInResult, "f"))
|
|
@@ -3141,8 +3051,9 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3141
3051
|
await __classPrivateFieldGet(this, _AirService_airWalletProvider, "f").startEventMessageListening(__classPrivateFieldGet(this, _AirService_walletIframeController, "f").iframeElement);
|
|
3142
3052
|
const walletInitPromise = __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").onInitialized();
|
|
3143
3053
|
await walletInitRequestPromise;
|
|
3144
|
-
|
|
3145
|
-
|
|
3054
|
+
if (!this.isLoggedIn && !option?.skipWalletLogin) {
|
|
3055
|
+
await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").onLoggedIn();
|
|
3056
|
+
}
|
|
3146
3057
|
const walletInitResult = await walletInitPromise;
|
|
3147
3058
|
if (walletInitResult.payload.success !== true) {
|
|
3148
3059
|
throw new AirServiceError(walletInitResult.payload.errorName, walletInitResult.payload.errorMessage);
|
|
@@ -3261,10 +3172,6 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3261
3172
|
__classPrivateFieldGet(this, _AirService_walletIframeController, "f").destroy();
|
|
3262
3173
|
__classPrivateFieldSet(this, _AirService_walletIframeController, undefined, "f");
|
|
3263
3174
|
}
|
|
3264
|
-
const authIframeElement = __classPrivateFieldGet(this, _AirService_authIframeController, "f")?.iframeElement;
|
|
3265
|
-
if (isElement(authIframeElement) && window.document.body.contains(authIframeElement)) {
|
|
3266
|
-
await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").resetWalletCommunication();
|
|
3267
|
-
}
|
|
3268
3175
|
// Close the message service
|
|
3269
3176
|
await __classPrivateFieldGet(this, _AirService_walletMessagingService, "f").close();
|
|
3270
3177
|
__classPrivateFieldSet(this, _AirService_walletLoggedInResult, undefined, "f");
|
|
@@ -3318,12 +3225,7 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3318
3225
|
__classPrivateFieldGet(this, _AirService_instances, "m", _AirService_subscribeToRecoveryEvents).call(this);
|
|
3319
3226
|
const recoveryInitPromise = __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").onInitialized();
|
|
3320
3227
|
await recoveryInitRequestPromise;
|
|
3321
|
-
await
|
|
3322
|
-
await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").initAuthCommunication();
|
|
3323
|
-
const recoveryInitResult = await recoveryInitPromise;
|
|
3324
|
-
if (recoveryInitResult.payload.success !== true) {
|
|
3325
|
-
throw new AirServiceError(recoveryInitResult.payload.errorName, recoveryInitResult.payload.errorMessage);
|
|
3326
|
-
}
|
|
3228
|
+
await recoveryInitPromise;
|
|
3327
3229
|
}
|
|
3328
3230
|
catch (error) {
|
|
3329
3231
|
log.error("Error initializing recovery", error);
|
|
@@ -3351,10 +3253,6 @@ _AirService_loginResult = new WeakMap(), _AirService_buildEnv = new WeakMap(), _
|
|
|
3351
3253
|
__classPrivateFieldGet(this, _AirService_recoveryIframeController, "f").destroy();
|
|
3352
3254
|
__classPrivateFieldSet(this, _AirService_recoveryIframeController, undefined, "f");
|
|
3353
3255
|
}
|
|
3354
|
-
const authIframeElement = __classPrivateFieldGet(this, _AirService_authIframeController, "f")?.iframeElement;
|
|
3355
|
-
if (isElement(authIframeElement) && window.document.body.contains(authIframeElement)) {
|
|
3356
|
-
await __classPrivateFieldGet(this, _AirService_authMessagingService, "f").resetRecoveryCommunication();
|
|
3357
|
-
}
|
|
3358
3256
|
// Close the message service
|
|
3359
3257
|
await __classPrivateFieldGet(this, _AirService_recoveryMessagingService, "f").close();
|
|
3360
3258
|
__classPrivateFieldSet(this, _AirService_recoveryInitialization, undefined, "f");
|