@blocklet/meta 1.8.1 → 1.8.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/lib/channel.js +39 -0
- package/package.json +13 -13
package/lib/channel.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const { isValid: isValidDid } = require('@arcblock/did');
|
|
2
|
+
|
|
3
|
+
const getAppPublicChannelRegex = () => /app:(\w+):public/;
|
|
4
|
+
|
|
5
|
+
const getAppPublicChannel = (appDid) => `app:${appDid}:public`;
|
|
6
|
+
|
|
7
|
+
const CHANNEL_TYPE = {
|
|
8
|
+
DID: 'DID',
|
|
9
|
+
APP: 'APP',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const parseChannel = (channel) => {
|
|
13
|
+
if (!channel) {
|
|
14
|
+
throw new Error('Channel should not be empty');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const matchAppPublicChannel = getAppPublicChannelRegex().exec(channel);
|
|
18
|
+
if (matchAppPublicChannel) {
|
|
19
|
+
return {
|
|
20
|
+
type: CHANNEL_TYPE.APP,
|
|
21
|
+
appDid: matchAppPublicChannel[1],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (isValidDid(channel)) {
|
|
26
|
+
return {
|
|
27
|
+
type: CHANNEL_TYPE.DID,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new Error(`Invalid channel format: ${channel}`);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
CHANNEL_TYPE,
|
|
36
|
+
getAppPublicChannel,
|
|
37
|
+
getAppPublicChannelRegex,
|
|
38
|
+
parseChannel,
|
|
39
|
+
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.2",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/util": "1.8.
|
|
23
|
-
"@arcblock/did": "1.17.
|
|
24
|
-
"@arcblock/did-ext": "1.17.
|
|
25
|
-
"@arcblock/did-util": "1.17.
|
|
26
|
-
"@arcblock/jwt": "1.17.
|
|
27
|
-
"@arcblock/nft": "1.17.
|
|
28
|
-
"@ocap/asset": "1.17.
|
|
29
|
-
"@ocap/mcrypto": "1.17.
|
|
30
|
-
"@ocap/util": "1.17.
|
|
31
|
-
"@ocap/wallet": "1.17.
|
|
21
|
+
"@abtnode/constant": "1.8.2",
|
|
22
|
+
"@abtnode/util": "1.8.2",
|
|
23
|
+
"@arcblock/did": "1.17.2",
|
|
24
|
+
"@arcblock/did-ext": "1.17.2",
|
|
25
|
+
"@arcblock/did-util": "1.17.2",
|
|
26
|
+
"@arcblock/jwt": "1.17.2",
|
|
27
|
+
"@arcblock/nft": "1.17.2",
|
|
28
|
+
"@ocap/asset": "1.17.2",
|
|
29
|
+
"@ocap/mcrypto": "1.17.2",
|
|
30
|
+
"@ocap/util": "1.17.2",
|
|
31
|
+
"@ocap/wallet": "1.17.2",
|
|
32
32
|
"ajv": "^8.11.0",
|
|
33
33
|
"cjk-length": "^1.0.0",
|
|
34
34
|
"debug": "^4.3.3",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"jest": "^27.4.5"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "fcbe3c97f3825c507ee16714f49bbf8f58c5b59f"
|
|
51
51
|
}
|