@abtnode/auth 1.16.25-next-b726d470 → 1.16.25
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/lib/launcher.js +17 -3
- package/package.json +9 -9
package/lib/launcher.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const Joi = require('joi');
|
|
2
2
|
const axios = require('@abtnode/util/lib/axios');
|
|
3
|
-
const
|
|
3
|
+
const { joinURL } = require('ufo');
|
|
4
4
|
const pRetry = require('p-retry');
|
|
5
5
|
const { stableStringify } = require('@arcblock/vc');
|
|
6
6
|
const { toBase58 } = require('@ocap/util');
|
|
@@ -9,6 +9,8 @@ const formatError = require('@abtnode/util/lib/format-error');
|
|
|
9
9
|
|
|
10
10
|
const logger = require('@abtnode/logger')('@abtnode/auth:launcher');
|
|
11
11
|
|
|
12
|
+
const LAUNCHER_BLOCKLET_DID = 'z8iZkFBbrVQxZHvcWWB3Sa2TrfGmSeFz9MSU7';
|
|
13
|
+
|
|
12
14
|
const schema = Joi.object({
|
|
13
15
|
launcherSessionId: Joi.string().required(),
|
|
14
16
|
launcherUrl: Joi.string().uri().required(),
|
|
@@ -23,9 +25,20 @@ const doRequest = async (serverSk, { launcherUrl, pathname, payload, method = 'p
|
|
|
23
25
|
const wallet = getNodeWallet(serverSk);
|
|
24
26
|
|
|
25
27
|
const fn = async () => {
|
|
28
|
+
const baseURL = new URL(launcherUrl).origin;
|
|
29
|
+
const { data: launcherMeta } = await axios.get(joinURL(baseURL, '__blocklet__.js?type=json'));
|
|
30
|
+
const mountPoint = launcherMeta.componentMountPoints?.find((x) => x.did === LAUNCHER_BLOCKLET_DID);
|
|
31
|
+
if (!mountPoint) {
|
|
32
|
+
throw new Error('launcher blocklet mount point not found');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const url = joinURL(baseURL, mountPoint.mountPoint, pathname);
|
|
36
|
+
|
|
37
|
+
logger.info('do launcher request', { url, method, payload });
|
|
38
|
+
|
|
26
39
|
const { data } = await axios({
|
|
27
40
|
method,
|
|
28
|
-
url
|
|
41
|
+
url,
|
|
29
42
|
data: method !== 'get' ? payload : {},
|
|
30
43
|
params: method === 'get' ? payload : {},
|
|
31
44
|
headers: {
|
|
@@ -42,7 +55,7 @@ const doRequest = async (serverSk, { launcherUrl, pathname, payload, method = 'p
|
|
|
42
55
|
minTimeout: delay,
|
|
43
56
|
maxTimeout: delay,
|
|
44
57
|
onFailedAttempt: (error) => {
|
|
45
|
-
logger.error('failed to call launcher', { error, launcherUrl, pathname, payload });
|
|
58
|
+
logger.error('failed to call launcher', { error, method, launcherUrl, pathname, payload });
|
|
46
59
|
// Exclude retrying for 4XX response codes
|
|
47
60
|
if (error.response && error.response.status >= 400 && error.response.status < 500) {
|
|
48
61
|
throw error;
|
|
@@ -87,4 +100,5 @@ module.exports = {
|
|
|
87
100
|
doRequest,
|
|
88
101
|
getLauncherSession,
|
|
89
102
|
getLauncherUser,
|
|
103
|
+
LAUNCHER_BLOCKLET_DID,
|
|
90
104
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.25
|
|
6
|
+
"version": "1.16.25",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@abtnode/constant": "1.16.25
|
|
24
|
-
"@abtnode/logger": "1.16.25
|
|
25
|
-
"@abtnode/util": "1.16.25
|
|
23
|
+
"@abtnode/constant": "1.16.25",
|
|
24
|
+
"@abtnode/logger": "1.16.25",
|
|
25
|
+
"@abtnode/util": "1.16.25",
|
|
26
26
|
"@arcblock/did": "1.18.113",
|
|
27
27
|
"@arcblock/jwt": "^1.18.113",
|
|
28
|
-
"@arcblock/nft-display": "^2.9.
|
|
28
|
+
"@arcblock/nft-display": "^2.9.63",
|
|
29
29
|
"@arcblock/validator": "^1.18.113",
|
|
30
30
|
"@arcblock/vc": "1.18.113",
|
|
31
|
-
"@blocklet/constant": "1.16.25
|
|
32
|
-
"@blocklet/meta": "1.16.25
|
|
33
|
-
"@blocklet/sdk": "1.16.25
|
|
31
|
+
"@blocklet/constant": "1.16.25",
|
|
32
|
+
"@blocklet/meta": "1.16.25",
|
|
33
|
+
"@blocklet/sdk": "1.16.25",
|
|
34
34
|
"@ocap/client": "^1.18.113",
|
|
35
35
|
"@ocap/mcrypto": "1.18.113",
|
|
36
36
|
"@ocap/util": "1.18.113",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"jest": "^29.7.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "8752b9a0caa8745e16e1de8db4ef696b713ffb4d"
|
|
55
55
|
}
|