@mocanetwork/airkit 0.5.0-beta.2 → 0.5.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 +119 -7
- package/dist/airkit.esm.js +119 -7
- package/dist/airkit.umd.min.js +1 -1
- package/dist/lib.cjs/common/src/realm/messaging/types.js +7 -1
- package/dist/lib.cjs/ws-embed/src/airService.js +37 -3
- package/dist/lib.cjs/ws-embed/src/embed.js +15 -0
- package/dist/lib.cjs/ws-embed/src/messageService.js +58 -1
- package/dist/lib.cjs/ws-embed/src/utils.js +2 -2
- package/dist/lib.esm/common/src/realm/messaging/types.js +7 -1
- package/dist/lib.esm/ws-embed/src/airService.js +37 -3
- package/dist/lib.esm/ws-embed/src/embed.js +15 -0
- package/dist/lib.esm/ws-embed/src/messageService.js +58 -1
- package/dist/lib.esm/ws-embed/src/utils.js +2 -2
- package/dist/types/airService.d.ts +25 -0
- package/dist/types/common/realm/messaging/types.d.ts +50 -2
- package/dist/types/common/realm/partner/config.d.ts +28 -26
- package/dist/types/common/realm/smart-session/hex.d.ts +1 -0
- package/dist/types/common/realm/smart-session/rule.d.ts +49 -0
- package/dist/types/common/realm/smart-session/types.d.ts +56 -0
- package/dist/types/common/realm/user/types.d.ts +1 -1
- package/dist/types/embed.d.ts +13 -0
- package/dist/types/interfaces.d.ts +4 -3
- package/dist/types/messageService.d.ts +13 -0
- package/package.json +1 -1
package/dist/airkit.cjs.js
CHANGED
|
@@ -110,7 +110,13 @@ const AirMessageTypes = {
|
|
|
110
110
|
CLOSE_MODAL: "air_close_modal",
|
|
111
111
|
INIT_AUTH_COMMUNICATION: "air_init_auth_communication",
|
|
112
112
|
DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
|
|
113
|
-
DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response"
|
|
113
|
+
DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
|
|
114
|
+
GRANT_PERMISSIONS_REQUEST: "air_grant_permissions_request",
|
|
115
|
+
GRANT_PERMISSIONS_RESPONSE: "air_grant_permissions_response",
|
|
116
|
+
EXECUTE_ACTION_REQUEST: "air_execute_action_request",
|
|
117
|
+
EXECUTE_ACTION_RESPONSE: "air_execute_action_response",
|
|
118
|
+
REVOKE_PERMISSIONS_REQUEST: "air_revoke_permissions_request",
|
|
119
|
+
REVOKE_PERMISSIONS_RESPONSE: "air_revoke_permissions_response"
|
|
114
120
|
};
|
|
115
121
|
const AirLoginClaimStates = {
|
|
116
122
|
CONNECTED: "connected",
|
|
@@ -201,12 +207,12 @@ const AIR_URLS = {
|
|
|
201
207
|
logLevel: "debug"
|
|
202
208
|
},
|
|
203
209
|
[EMBED_BUILD_ENV.STAGING]: {
|
|
204
|
-
authUrl: "https://
|
|
210
|
+
authUrl: "https://auth.staging.air3.com",
|
|
205
211
|
walletUrl: "https://account.staging.realmnetwork.io",
|
|
206
212
|
logLevel: "info"
|
|
207
213
|
},
|
|
208
214
|
[EMBED_BUILD_ENV.PRODUCTION]: {
|
|
209
|
-
authUrl: "https://
|
|
215
|
+
authUrl: "https://auth.air3.com",
|
|
210
216
|
walletUrl: "https://account.realmnetwork.io",
|
|
211
217
|
logLevel: "error"
|
|
212
218
|
}
|
|
@@ -1220,7 +1226,7 @@ var _AirMessageService;
|
|
|
1220
1226
|
|
|
1221
1227
|
|
|
1222
1228
|
|
|
1223
|
-
const REALM_EMBED_MESSAGES = [AirMessageTypes.LOGIN_CLAIM_STATE, AirMessageTypes.CLOSE_MODAL, AirMessageTypes.SERVICE_INITIALIZED, AirMessageTypes.SERVICE_INITIALIZED_ERROR, AirMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE];
|
|
1229
|
+
const REALM_EMBED_MESSAGES = [AirMessageTypes.LOGIN_CLAIM_STATE, AirMessageTypes.CLOSE_MODAL, AirMessageTypes.SERVICE_INITIALIZED, AirMessageTypes.SERVICE_INITIALIZED_ERROR, AirMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirMessageTypes.EXECUTE_ACTION_RESPONSE, AirMessageTypes.REVOKE_PERMISSIONS_RESPONSE, AirMessageTypes.GRANT_PERMISSIONS_RESPONSE];
|
|
1224
1230
|
const AUTH_EMBED_MESSAGES = [AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.USER_INFO_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.REFRESH_TOKEN_RESPONSE, AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.SETUP_WALLET_REQUEST];
|
|
1225
1231
|
class AirMessageService {
|
|
1226
1232
|
constructor() {
|
|
@@ -1339,6 +1345,63 @@ class AirMessageService {
|
|
|
1339
1345
|
}, origin);
|
|
1340
1346
|
return response;
|
|
1341
1347
|
}
|
|
1348
|
+
async sendGrantPermissionRequest(walletIframe, policies) {
|
|
1349
|
+
const response = (0,external_rxjs_namespaceObject.firstValueFrom)(this.messages$.pipe((0,external_rxjs_namespaceObject.filter)(msg => msg.type === AirMessageTypes.GRANT_PERMISSIONS_RESPONSE)));
|
|
1350
|
+
const {
|
|
1351
|
+
origin
|
|
1352
|
+
} = new URL(walletIframe.src);
|
|
1353
|
+
walletIframe.contentWindow.postMessage({
|
|
1354
|
+
type: AirMessageTypes.GRANT_PERMISSIONS_REQUEST,
|
|
1355
|
+
payload: {
|
|
1356
|
+
policies
|
|
1357
|
+
}
|
|
1358
|
+
}, origin);
|
|
1359
|
+
const result = await response;
|
|
1360
|
+
if (result.payload.success === false) {
|
|
1361
|
+
throw new RealmEmbedError(result.payload.errorName, result.payload.errorMessage);
|
|
1362
|
+
}
|
|
1363
|
+
return result.payload.sessionData;
|
|
1364
|
+
}
|
|
1365
|
+
async sendExecuteActionRequest(walletIframe, params) {
|
|
1366
|
+
const response = (0,external_rxjs_namespaceObject.firstValueFrom)(this.messages$.pipe((0,external_rxjs_namespaceObject.filter)(msg => msg.type === AirMessageTypes.EXECUTE_ACTION_RESPONSE)));
|
|
1367
|
+
const {
|
|
1368
|
+
origin
|
|
1369
|
+
} = new URL(walletIframe.src);
|
|
1370
|
+
walletIframe.contentWindow.postMessage({
|
|
1371
|
+
type: AirMessageTypes.EXECUTE_ACTION_REQUEST,
|
|
1372
|
+
payload: {
|
|
1373
|
+
sessionData: params.sessionData,
|
|
1374
|
+
call: {
|
|
1375
|
+
to: params.call.to,
|
|
1376
|
+
value: params.call.value,
|
|
1377
|
+
data: params.call.data
|
|
1378
|
+
},
|
|
1379
|
+
sessionOwnerPrivateKey: params.sessionOwnerPrivateKey
|
|
1380
|
+
}
|
|
1381
|
+
}, origin);
|
|
1382
|
+
const result = await response;
|
|
1383
|
+
if (result.payload.success === false) {
|
|
1384
|
+
throw new RealmEmbedError(result.payload.errorName, result.payload.errorMessage);
|
|
1385
|
+
}
|
|
1386
|
+
return result.payload.txHash;
|
|
1387
|
+
}
|
|
1388
|
+
async sendRevokePermissionsRequest(walletIframe, permissionId) {
|
|
1389
|
+
const response = (0,external_rxjs_namespaceObject.firstValueFrom)(this.messages$.pipe((0,external_rxjs_namespaceObject.filter)(msg => msg.type === AirMessageTypes.REVOKE_PERMISSIONS_RESPONSE)));
|
|
1390
|
+
const {
|
|
1391
|
+
origin
|
|
1392
|
+
} = new URL(walletIframe.src);
|
|
1393
|
+
walletIframe.contentWindow.postMessage({
|
|
1394
|
+
type: AirMessageTypes.REVOKE_PERMISSIONS_REQUEST,
|
|
1395
|
+
payload: {
|
|
1396
|
+
permissionId
|
|
1397
|
+
}
|
|
1398
|
+
}, origin);
|
|
1399
|
+
const result = await response;
|
|
1400
|
+
if (result.payload.success === false) {
|
|
1401
|
+
throw new RealmEmbedError(result.payload.errorName, result.payload.errorMessage);
|
|
1402
|
+
}
|
|
1403
|
+
return result.payload.txHash;
|
|
1404
|
+
}
|
|
1342
1405
|
sendDeploySmartAccountRequest(walletIframe) {
|
|
1343
1406
|
const response = (0,external_rxjs_namespaceObject.firstValueFrom)(this.messages$.pipe((0,external_rxjs_namespaceObject.filter)(msg => msg.type === AirMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE)));
|
|
1344
1407
|
const {
|
|
@@ -1830,6 +1893,21 @@ class RealmEmbed {
|
|
|
1830
1893
|
throw RealmEmbedError.from(error);
|
|
1831
1894
|
}
|
|
1832
1895
|
}
|
|
1896
|
+
async _grantPermission(policies) {
|
|
1897
|
+
if (!this.isConnected) throw new RealmEmbedError("NOT_LOGGED_IN", "User needs to be connected first");
|
|
1898
|
+
try {
|
|
1899
|
+
return await messageService.sendGrantPermissionRequest(_classPrivateFieldGet(_walletIframe, this), policies);
|
|
1900
|
+
} catch (error) {
|
|
1901
|
+
throw RealmEmbedError.from(error);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
async _executeAction(params) {
|
|
1905
|
+
return messageService.sendExecuteActionRequest(_classPrivateFieldGet(_walletIframe, this), params);
|
|
1906
|
+
}
|
|
1907
|
+
async _revokePermission(permissionId) {
|
|
1908
|
+
return messageService.sendRevokePermissionsRequest(_classPrivateFieldGet(_walletIframe, this), permissionId);
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1833
1911
|
// async loginV2<T extends boolean>(options?: {
|
|
1834
1912
|
// skipClaiming: T;
|
|
1835
1913
|
// token?: string;
|
|
@@ -2417,7 +2495,9 @@ class AirService {
|
|
|
2417
2495
|
const authServiceInitialization = messageService.waitForAuthInitialization();
|
|
2418
2496
|
const result = await Promise.all([initializationPromise, authServiceInitialization]);
|
|
2419
2497
|
airService_classPrivateFieldSet(airService_isInitialized, this, true);
|
|
2420
|
-
airService_assertClassBrand(_AirService_brand, this, _triggerAirAuthInitialized).call(this
|
|
2498
|
+
airService_assertClassBrand(_AirService_brand, this, _triggerAirAuthInitialized).call(this, {
|
|
2499
|
+
rehydrated: result[1].rehydrated
|
|
2500
|
+
});
|
|
2421
2501
|
airService_assertClassBrand(_AirService_brand, this, _prepareRealmEmbedListeners).call(this);
|
|
2422
2502
|
|
|
2423
2503
|
// rehydrated auth session
|
|
@@ -2469,11 +2549,42 @@ class AirService {
|
|
|
2469
2549
|
}
|
|
2470
2550
|
throw new AirServiceError("UNKNOWN_ERROR", "Unknown error occurred");
|
|
2471
2551
|
}
|
|
2552
|
+
|
|
2553
|
+
/**
|
|
2554
|
+
* @experimental This method is experimental and will change in the future.
|
|
2555
|
+
*/
|
|
2472
2556
|
async deploySmartAccount() {
|
|
2473
2557
|
if (!airService_classPrivateFieldGet(airService_isInitialized, this)) throw new Error("Service is not initialized");
|
|
2474
2558
|
await airService_assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2475
2559
|
return airService_classPrivateFieldGet(_realmEmbed, this)._deploySmartAccount();
|
|
2476
2560
|
}
|
|
2561
|
+
|
|
2562
|
+
/**
|
|
2563
|
+
* @experimental This method is experimental and will change in the future.
|
|
2564
|
+
*/
|
|
2565
|
+
async grantPermission(policies) {
|
|
2566
|
+
if (!airService_classPrivateFieldGet(airService_isInitialized, this)) throw new Error("AirAuth is not initialized");
|
|
2567
|
+
await airService_assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2568
|
+
return airService_classPrivateFieldGet(_realmEmbed, this)._grantPermission(policies);
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
/**
|
|
2572
|
+
* @experimental This method is experimental and will change in the future.
|
|
2573
|
+
*/
|
|
2574
|
+
async executeAction(params) {
|
|
2575
|
+
if (!airService_classPrivateFieldGet(airService_isInitialized, this)) throw new Error("AirAuth is not initialized");
|
|
2576
|
+
await airService_assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2577
|
+
return airService_classPrivateFieldGet(_realmEmbed, this)._executeAction(params);
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/**
|
|
2581
|
+
* @experimental This method is experimental and will change in the future.
|
|
2582
|
+
*/
|
|
2583
|
+
async revokePermission(permissionId) {
|
|
2584
|
+
if (!airService_classPrivateFieldGet(airService_isInitialized, this)) throw new Error("AirAuth is not initialized");
|
|
2585
|
+
await airService_assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2586
|
+
return airService_classPrivateFieldGet(_realmEmbed, this)._revokePermission(permissionId);
|
|
2587
|
+
}
|
|
2477
2588
|
async logout() {
|
|
2478
2589
|
if (!airService_classPrivateFieldGet(airService_isInitialized, this)) throw new Error("Service is not initialized");
|
|
2479
2590
|
if (!this.isLoggedIn) throw new Error("No active session to logout");
|
|
@@ -2601,9 +2712,10 @@ async function _triggerEventListeners(data) {
|
|
|
2601
2712
|
listener(data);
|
|
2602
2713
|
});
|
|
2603
2714
|
}
|
|
2604
|
-
async function _triggerAirAuthInitialized() {
|
|
2715
|
+
async function _triggerAirAuthInitialized(result) {
|
|
2605
2716
|
await airService_assertClassBrand(_AirService_brand, this, _triggerEventListeners).call(this, {
|
|
2606
|
-
event: "initialized"
|
|
2717
|
+
event: "initialized",
|
|
2718
|
+
result
|
|
2607
2719
|
});
|
|
2608
2720
|
}
|
|
2609
2721
|
async function _triggerAirAuthLoggedIn() {
|
package/dist/airkit.esm.js
CHANGED
|
@@ -45,7 +45,13 @@ const AirMessageTypes = {
|
|
|
45
45
|
CLOSE_MODAL: "air_close_modal",
|
|
46
46
|
INIT_AUTH_COMMUNICATION: "air_init_auth_communication",
|
|
47
47
|
DEPLOY_SMART_ACCOUNT_REQUEST: "air_deploy_smart_account_request",
|
|
48
|
-
DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response"
|
|
48
|
+
DEPLOY_SMART_ACCOUNT_RESPONSE: "air_deploy_smart_account_response",
|
|
49
|
+
GRANT_PERMISSIONS_REQUEST: "air_grant_permissions_request",
|
|
50
|
+
GRANT_PERMISSIONS_RESPONSE: "air_grant_permissions_response",
|
|
51
|
+
EXECUTE_ACTION_REQUEST: "air_execute_action_request",
|
|
52
|
+
EXECUTE_ACTION_RESPONSE: "air_execute_action_response",
|
|
53
|
+
REVOKE_PERMISSIONS_REQUEST: "air_revoke_permissions_request",
|
|
54
|
+
REVOKE_PERMISSIONS_RESPONSE: "air_revoke_permissions_response"
|
|
49
55
|
};
|
|
50
56
|
|
|
51
57
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -113,12 +119,12 @@ const AIR_URLS = {
|
|
|
113
119
|
logLevel: "debug"
|
|
114
120
|
},
|
|
115
121
|
[EMBED_BUILD_ENV.STAGING]: {
|
|
116
|
-
authUrl: "https://
|
|
122
|
+
authUrl: "https://auth.staging.air3.com",
|
|
117
123
|
walletUrl: "https://account.staging.realmnetwork.io",
|
|
118
124
|
logLevel: "info"
|
|
119
125
|
},
|
|
120
126
|
[EMBED_BUILD_ENV.PRODUCTION]: {
|
|
121
|
-
authUrl: "https://
|
|
127
|
+
authUrl: "https://auth.air3.com",
|
|
122
128
|
walletUrl: "https://account.realmnetwork.io",
|
|
123
129
|
logLevel: "error"
|
|
124
130
|
}
|
|
@@ -1067,7 +1073,7 @@ _defineProperty(AirInPageProvider, "defaultState", {
|
|
|
1067
1073
|
});
|
|
1068
1074
|
class TorusInPageProvider extends AirInPageProvider {}
|
|
1069
1075
|
|
|
1070
|
-
const REALM_EMBED_MESSAGES = [AirMessageTypes.LOGIN_CLAIM_STATE, AirMessageTypes.CLOSE_MODAL, AirMessageTypes.SERVICE_INITIALIZED, AirMessageTypes.SERVICE_INITIALIZED_ERROR, AirMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE];
|
|
1076
|
+
const REALM_EMBED_MESSAGES = [AirMessageTypes.LOGIN_CLAIM_STATE, AirMessageTypes.CLOSE_MODAL, AirMessageTypes.SERVICE_INITIALIZED, AirMessageTypes.SERVICE_INITIALIZED_ERROR, AirMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE, AirMessageTypes.EXECUTE_ACTION_RESPONSE, AirMessageTypes.REVOKE_PERMISSIONS_RESPONSE, AirMessageTypes.GRANT_PERMISSIONS_RESPONSE];
|
|
1071
1077
|
const AUTH_EMBED_MESSAGES = [AirAuthMessageTypes.LOGIN_RESPONSE, AirAuthMessageTypes.USER_INFO_RESPONSE, AirAuthMessageTypes.PARTNER_USER_INFO_RESPONSE, AirAuthMessageTypes.REFRESH_TOKEN_RESPONSE, AirAuthMessageTypes.INITIALIZATION_RESPONSE, AirAuthMessageTypes.LOGOUT_RESPONSE, AirAuthMessageTypes.IFRAME_VISIBILITY_REQUEST, AirAuthMessageTypes.SETUP_WALLET_REQUEST];
|
|
1072
1078
|
class AirMessageService {
|
|
1073
1079
|
constructor() {
|
|
@@ -1184,6 +1190,63 @@ class AirMessageService {
|
|
|
1184
1190
|
}, origin);
|
|
1185
1191
|
return response;
|
|
1186
1192
|
}
|
|
1193
|
+
async sendGrantPermissionRequest(walletIframe, policies) {
|
|
1194
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirMessageTypes.GRANT_PERMISSIONS_RESPONSE)));
|
|
1195
|
+
const {
|
|
1196
|
+
origin
|
|
1197
|
+
} = new URL(walletIframe.src);
|
|
1198
|
+
walletIframe.contentWindow.postMessage({
|
|
1199
|
+
type: AirMessageTypes.GRANT_PERMISSIONS_REQUEST,
|
|
1200
|
+
payload: {
|
|
1201
|
+
policies
|
|
1202
|
+
}
|
|
1203
|
+
}, origin);
|
|
1204
|
+
const result = await response;
|
|
1205
|
+
if (result.payload.success === false) {
|
|
1206
|
+
throw new RealmEmbedError(result.payload.errorName, result.payload.errorMessage);
|
|
1207
|
+
}
|
|
1208
|
+
return result.payload.sessionData;
|
|
1209
|
+
}
|
|
1210
|
+
async sendExecuteActionRequest(walletIframe, params) {
|
|
1211
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirMessageTypes.EXECUTE_ACTION_RESPONSE)));
|
|
1212
|
+
const {
|
|
1213
|
+
origin
|
|
1214
|
+
} = new URL(walletIframe.src);
|
|
1215
|
+
walletIframe.contentWindow.postMessage({
|
|
1216
|
+
type: AirMessageTypes.EXECUTE_ACTION_REQUEST,
|
|
1217
|
+
payload: {
|
|
1218
|
+
sessionData: params.sessionData,
|
|
1219
|
+
call: {
|
|
1220
|
+
to: params.call.to,
|
|
1221
|
+
value: params.call.value,
|
|
1222
|
+
data: params.call.data
|
|
1223
|
+
},
|
|
1224
|
+
sessionOwnerPrivateKey: params.sessionOwnerPrivateKey
|
|
1225
|
+
}
|
|
1226
|
+
}, origin);
|
|
1227
|
+
const result = await response;
|
|
1228
|
+
if (result.payload.success === false) {
|
|
1229
|
+
throw new RealmEmbedError(result.payload.errorName, result.payload.errorMessage);
|
|
1230
|
+
}
|
|
1231
|
+
return result.payload.txHash;
|
|
1232
|
+
}
|
|
1233
|
+
async sendRevokePermissionsRequest(walletIframe, permissionId) {
|
|
1234
|
+
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirMessageTypes.REVOKE_PERMISSIONS_RESPONSE)));
|
|
1235
|
+
const {
|
|
1236
|
+
origin
|
|
1237
|
+
} = new URL(walletIframe.src);
|
|
1238
|
+
walletIframe.contentWindow.postMessage({
|
|
1239
|
+
type: AirMessageTypes.REVOKE_PERMISSIONS_REQUEST,
|
|
1240
|
+
payload: {
|
|
1241
|
+
permissionId
|
|
1242
|
+
}
|
|
1243
|
+
}, origin);
|
|
1244
|
+
const result = await response;
|
|
1245
|
+
if (result.payload.success === false) {
|
|
1246
|
+
throw new RealmEmbedError(result.payload.errorName, result.payload.errorMessage);
|
|
1247
|
+
}
|
|
1248
|
+
return result.payload.txHash;
|
|
1249
|
+
}
|
|
1187
1250
|
sendDeploySmartAccountRequest(walletIframe) {
|
|
1188
1251
|
const response = firstValueFrom(this.messages$.pipe(filter(msg => msg.type === AirMessageTypes.DEPLOY_SMART_ACCOUNT_RESPONSE)));
|
|
1189
1252
|
const {
|
|
@@ -1658,6 +1721,21 @@ class RealmEmbed {
|
|
|
1658
1721
|
throw RealmEmbedError.from(error);
|
|
1659
1722
|
}
|
|
1660
1723
|
}
|
|
1724
|
+
async _grantPermission(policies) {
|
|
1725
|
+
if (!this.isConnected) throw new RealmEmbedError("NOT_LOGGED_IN", "User needs to be connected first");
|
|
1726
|
+
try {
|
|
1727
|
+
return await AirMessageService$1.sendGrantPermissionRequest(_classPrivateFieldGet$1(_walletIframe, this), policies);
|
|
1728
|
+
} catch (error) {
|
|
1729
|
+
throw RealmEmbedError.from(error);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
async _executeAction(params) {
|
|
1733
|
+
return AirMessageService$1.sendExecuteActionRequest(_classPrivateFieldGet$1(_walletIframe, this), params);
|
|
1734
|
+
}
|
|
1735
|
+
async _revokePermission(permissionId) {
|
|
1736
|
+
return AirMessageService$1.sendRevokePermissionsRequest(_classPrivateFieldGet$1(_walletIframe, this), permissionId);
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1661
1739
|
// async loginV2<T extends boolean>(options?: {
|
|
1662
1740
|
// skipClaiming: T;
|
|
1663
1741
|
// token?: string;
|
|
@@ -2230,7 +2308,9 @@ class AirService {
|
|
|
2230
2308
|
const authServiceInitialization = AirMessageService$1.waitForAuthInitialization();
|
|
2231
2309
|
const result = await Promise.all([initializationPromise, authServiceInitialization]);
|
|
2232
2310
|
_classPrivateFieldSet(_isInitialized, this, true);
|
|
2233
|
-
_assertClassBrand(_AirService_brand, this, _triggerAirAuthInitialized).call(this
|
|
2311
|
+
_assertClassBrand(_AirService_brand, this, _triggerAirAuthInitialized).call(this, {
|
|
2312
|
+
rehydrated: result[1].rehydrated
|
|
2313
|
+
});
|
|
2234
2314
|
_assertClassBrand(_AirService_brand, this, _prepareRealmEmbedListeners).call(this);
|
|
2235
2315
|
|
|
2236
2316
|
// rehydrated auth session
|
|
@@ -2282,11 +2362,42 @@ class AirService {
|
|
|
2282
2362
|
}
|
|
2283
2363
|
throw new AirServiceError("UNKNOWN_ERROR", "Unknown error occurred");
|
|
2284
2364
|
}
|
|
2365
|
+
|
|
2366
|
+
/**
|
|
2367
|
+
* @experimental This method is experimental and will change in the future.
|
|
2368
|
+
*/
|
|
2285
2369
|
async deploySmartAccount() {
|
|
2286
2370
|
if (!_classPrivateFieldGet(_isInitialized, this)) throw new Error("Service is not initialized");
|
|
2287
2371
|
await _assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2288
2372
|
return _classPrivateFieldGet(_realmEmbed, this)._deploySmartAccount();
|
|
2289
2373
|
}
|
|
2374
|
+
|
|
2375
|
+
/**
|
|
2376
|
+
* @experimental This method is experimental and will change in the future.
|
|
2377
|
+
*/
|
|
2378
|
+
async grantPermission(policies) {
|
|
2379
|
+
if (!_classPrivateFieldGet(_isInitialized, this)) throw new Error("AirAuth is not initialized");
|
|
2380
|
+
await _assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2381
|
+
return _classPrivateFieldGet(_realmEmbed, this)._grantPermission(policies);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
/**
|
|
2385
|
+
* @experimental This method is experimental and will change in the future.
|
|
2386
|
+
*/
|
|
2387
|
+
async executeAction(params) {
|
|
2388
|
+
if (!_classPrivateFieldGet(_isInitialized, this)) throw new Error("AirAuth is not initialized");
|
|
2389
|
+
await _assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2390
|
+
return _classPrivateFieldGet(_realmEmbed, this)._executeAction(params);
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
/**
|
|
2394
|
+
* @experimental This method is experimental and will change in the future.
|
|
2395
|
+
*/
|
|
2396
|
+
async revokePermission(permissionId) {
|
|
2397
|
+
if (!_classPrivateFieldGet(_isInitialized, this)) throw new Error("AirAuth is not initialized");
|
|
2398
|
+
await _assertClassBrand(_AirService_brand, this, _ensureWallet).call(this);
|
|
2399
|
+
return _classPrivateFieldGet(_realmEmbed, this)._revokePermission(permissionId);
|
|
2400
|
+
}
|
|
2290
2401
|
async logout() {
|
|
2291
2402
|
if (!_classPrivateFieldGet(_isInitialized, this)) throw new Error("Service is not initialized");
|
|
2292
2403
|
if (!this.isLoggedIn) throw new Error("No active session to logout");
|
|
@@ -2414,9 +2525,10 @@ async function _triggerEventListeners(data) {
|
|
|
2414
2525
|
listener(data);
|
|
2415
2526
|
});
|
|
2416
2527
|
}
|
|
2417
|
-
async function _triggerAirAuthInitialized() {
|
|
2528
|
+
async function _triggerAirAuthInitialized(result) {
|
|
2418
2529
|
await _assertClassBrand(_AirService_brand, this, _triggerEventListeners).call(this, {
|
|
2419
|
-
event: "initialized"
|
|
2530
|
+
event: "initialized",
|
|
2531
|
+
result
|
|
2420
2532
|
});
|
|
2421
2533
|
}
|
|
2422
2534
|
async function _triggerAirAuthLoggedIn() {
|