@abtnode/util 1.16.15-beta-d8e7b6c0 → 1.16.15-beta-375899b6
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/blocklet.js +23 -0
- package/package.json +5 -5
package/lib/blocklet.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { createHash } = require('crypto');
|
|
2
|
+
|
|
3
|
+
const getComponentApiKey = ({ serverSk, app, component } = {}) => {
|
|
4
|
+
if (!serverSk) {
|
|
5
|
+
throw new Error('serverSk should not be empty');
|
|
6
|
+
}
|
|
7
|
+
if (!app?.meta?.did) {
|
|
8
|
+
throw new Error('app.meta.did should not be empty');
|
|
9
|
+
}
|
|
10
|
+
if (!component?.meta?.did) {
|
|
11
|
+
throw new Error('component.meta.did should not be empty');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const hash = createHash('sha256');
|
|
15
|
+
const token = hash
|
|
16
|
+
.update(`${serverSk}${app?.meta?.did}${component?.meta?.did}${component?.installedAt}`)
|
|
17
|
+
.digest('base64');
|
|
18
|
+
return token;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
getComponentApiKey,
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.15-beta-
|
|
6
|
+
"version": "1.16.15-beta-375899b6",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.15-beta-
|
|
22
|
-
"@abtnode/logger": "1.16.15-beta-
|
|
23
|
-
"@blocklet/constant": "1.16.15-beta-
|
|
21
|
+
"@abtnode/constant": "1.16.15-beta-375899b6",
|
|
22
|
+
"@abtnode/logger": "1.16.15-beta-375899b6",
|
|
23
|
+
"@blocklet/constant": "1.16.15-beta-375899b6",
|
|
24
24
|
"@ocap/client": "1.18.89",
|
|
25
25
|
"@ocap/mcrypto": "1.18.89",
|
|
26
26
|
"@ocap/util": "1.18.89",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"fs-extra": "^10.1.0",
|
|
72
72
|
"jest": "^27.5.1"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "c999a7f47ecdca1494eb53fc177d28899b3effc9"
|
|
75
75
|
}
|