@abtnode/auth 1.17.4-beta-20251205-104405-28838df1 → 1.17.4-beta-20251206-081442-6f622450
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 +23 -12
- package/package.json +8 -8
package/lib/launcher.js
CHANGED
|
@@ -27,21 +27,33 @@ const getLauncherInfo = async (launcherUrl) => {
|
|
|
27
27
|
return { ...pick(meta, ['appId', 'appPk', 'appPid', 'appUrl']), mountPoint: component?.mountPoint || '/' };
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
const buildLauncherUrl = async (launcherUrl, pathname) => {
|
|
31
|
+
const launcherInfo = await getLauncherInfo(launcherUrl);
|
|
32
|
+
if (!launcherInfo.mountPoint) {
|
|
33
|
+
throw new Error('launcher blocklet mount point not found');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const url = joinURL(launcherInfo.appUrl, launcherInfo.mountPoint, pathname);
|
|
37
|
+
|
|
38
|
+
return url;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const buildRequestHeaders = async (serverSk, payload) => {
|
|
42
|
+
const wallet = getNodeWallet(serverSk);
|
|
43
|
+
return {
|
|
44
|
+
'x-server-sig': toBase58(await wallet.sign(stableStringify(payload))),
|
|
45
|
+
'User-Agent': `ABTNode/${version}`,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
30
49
|
// eslint-disable-next-line require-await
|
|
31
50
|
const doRequest = async (serverSk, { launcherUrl, pathname, payload, method = 'post', locale = 'en' }) => {
|
|
32
51
|
if (!serverSk) {
|
|
33
52
|
throw new Error('serverSk is required to request launcher');
|
|
34
53
|
}
|
|
35
54
|
|
|
36
|
-
const wallet = getNodeWallet(serverSk);
|
|
37
|
-
|
|
38
55
|
const fn = async () => {
|
|
39
|
-
const
|
|
40
|
-
if (!launcherInfo.mountPoint) {
|
|
41
|
-
throw new Error('launcher blocklet mount point not found');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const url = joinURL(launcherInfo.appUrl, launcherInfo.mountPoint, pathname);
|
|
56
|
+
const url = await buildLauncherUrl(launcherUrl, pathname);
|
|
45
57
|
|
|
46
58
|
let params = method === 'get' ? payload : {};
|
|
47
59
|
params = { ...(params || {}), locale };
|
|
@@ -52,10 +64,7 @@ const doRequest = async (serverSk, { launcherUrl, pathname, payload, method = 'p
|
|
|
52
64
|
method,
|
|
53
65
|
url,
|
|
54
66
|
params,
|
|
55
|
-
headers:
|
|
56
|
-
'x-server-sig': toBase58(await wallet.sign(stableStringify(payload))),
|
|
57
|
-
'User-Agent': `ABTNode/${version}`,
|
|
58
|
-
},
|
|
67
|
+
headers: await buildRequestHeaders(serverSk, payload),
|
|
59
68
|
};
|
|
60
69
|
if (method === 'post') {
|
|
61
70
|
options.data = payload;
|
|
@@ -139,6 +148,8 @@ module.exports = {
|
|
|
139
148
|
getLauncherSession,
|
|
140
149
|
getLauncherUser,
|
|
141
150
|
getLauncherInfo,
|
|
151
|
+
buildLauncherUrl,
|
|
152
|
+
buildRequestHeaders,
|
|
142
153
|
sendEmailWithLauncher,
|
|
143
154
|
LAUNCHER_BLOCKLET_DID,
|
|
144
155
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.17.4-beta-
|
|
6
|
+
"version": "1.17.4-beta-20251206-081442-6f622450",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.17.4-beta-
|
|
22
|
-
"@abtnode/logger": "1.17.4-beta-
|
|
23
|
-
"@abtnode/util": "1.17.4-beta-
|
|
21
|
+
"@abtnode/constant": "1.17.4-beta-20251206-081442-6f622450",
|
|
22
|
+
"@abtnode/logger": "1.17.4-beta-20251206-081442-6f622450",
|
|
23
|
+
"@abtnode/util": "1.17.4-beta-20251206-081442-6f622450",
|
|
24
24
|
"@arcblock/did": "^1.27.12",
|
|
25
25
|
"@arcblock/did-connect-js": "^1.27.12",
|
|
26
26
|
"@arcblock/did-ext": "^1.27.12",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@arcblock/nft-display": "^3.2.11",
|
|
30
30
|
"@arcblock/validator": "^1.27.12",
|
|
31
31
|
"@arcblock/vc": "^1.27.12",
|
|
32
|
-
"@blocklet/constant": "1.17.4-beta-
|
|
32
|
+
"@blocklet/constant": "1.17.4-beta-20251206-081442-6f622450",
|
|
33
33
|
"@blocklet/error": "^0.3.3",
|
|
34
|
-
"@blocklet/meta": "1.17.4-beta-
|
|
35
|
-
"@blocklet/sdk": "1.17.4-beta-
|
|
34
|
+
"@blocklet/meta": "1.17.4-beta-20251206-081442-6f622450",
|
|
35
|
+
"@blocklet/sdk": "1.17.4-beta-20251206-081442-6f622450",
|
|
36
36
|
"@ocap/client": "^1.27.12",
|
|
37
37
|
"@ocap/mcrypto": "^1.27.12",
|
|
38
38
|
"@ocap/util": "^1.27.12",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"axios-mock-adapter": "^2.1.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "37b0b1147d40a5cf787cba5d111a63a2b6259790"
|
|
59
59
|
}
|