@blocklet/meta 1.6.0 → 1.6.1

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.
Files changed (2) hide show
  1. package/lib/info.js +20 -6
  2. package/package.json +2 -2
package/lib/info.js CHANGED
@@ -1,16 +1,30 @@
1
1
  const get = require('lodash/get');
2
2
  const getBlockletWallet = require('./wallet');
3
3
 
4
- module.exports = (state, nodeSk) => {
4
+ module.exports = (state, nodeSk, { returnWallet = true } = {}) => {
5
5
  if (!state || typeof state !== 'object' || !Array.isArray(state.environments) || !get(state, 'meta.did')) {
6
6
  throw new Error('Blocklet state must be an object');
7
7
  }
8
+
9
+ const customName = state.environments.find((x) => x.key === 'BLOCKLET_APP_NAME');
10
+ const customDescription = state.environments.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
11
+
12
+ const { did } = state.meta;
13
+ const name = get(customName, 'value', state.meta.title || state.meta.name);
14
+ const description = get(customDescription, 'value', state.meta.description);
15
+
16
+ if (!returnWallet) {
17
+ return {
18
+ did,
19
+ name,
20
+ description,
21
+ };
22
+ }
23
+
8
24
  if (!nodeSk || typeof nodeSk !== 'string') {
9
25
  throw new Error('Node secret key must be a string');
10
26
  }
11
27
 
12
- const customName = state.environments.find((x) => x.key === 'BLOCKLET_APP_NAME');
13
- const customDescription = state.environments.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
14
28
  const customSk = state.environments.find((x) => x.key === 'BLOCKLET_APP_SK');
15
29
  const customType = state.environments.find((x) => x.key === 'BLOCKLET_WALLET_TYPE');
16
30
 
@@ -31,9 +45,9 @@ module.exports = (state, nodeSk) => {
31
45
  }
32
46
 
33
47
  return {
34
- did: state.meta.did,
35
- name: get(customName, 'value', state.meta.title || state.meta.name),
36
- description: get(customDescription, 'value', state.meta.description),
48
+ did,
49
+ name,
50
+ description,
37
51
  wallet,
38
52
  };
39
53
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.0",
6
+ "version": "1.6.1",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -42,5 +42,5 @@
42
42
  "devDependencies": {
43
43
  "jest": "^27.3.1"
44
44
  },
45
- "gitHead": "5927d4780b21ce46406857575c44e1a8667eddaa"
45
+ "gitHead": "5be6776ba9bbfdbff4000fdab7dcb77686b3a9e8"
46
46
  }