@blocklet/meta 1.6.7 → 1.6.11

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/constants.js CHANGED
@@ -150,5 +150,6 @@ module.exports = Object.freeze({
150
150
  BLOCKLET_APP_DESCRIPTION: 'BLOCKLET_APP_DESCRIPTION',
151
151
  BLOCKLET_APP_SK: 'BLOCKLET_APP_SK',
152
152
  BLOCKLET_WALLET_TYPE: 'BLOCKLET_WALLET_TYPE',
153
+ BLOCKLET_DELETABLE: 'BLOCKLET_DELETABLE',
153
154
  },
154
155
  });
package/lib/util.js CHANGED
@@ -91,9 +91,52 @@ const isFreeBlocklet = (meta) => {
91
91
  return priceList.every((x) => x === 0);
92
92
  };
93
93
 
94
+ const wipeSensitiveData = (blocklet) => {
95
+ if (!blocklet) {
96
+ return blocklet;
97
+ }
98
+
99
+ forEachBlocklet(
100
+ blocklet,
101
+ (d) => {
102
+ (d.configs || []).forEach((x) => {
103
+ if (x.secure) {
104
+ x.value = x.value ? '__encrypted__' : '';
105
+ }
106
+ });
107
+ (d.environments || []).forEach((x) => {
108
+ if (['BLOCKLET_APP_SK'].includes(x.key)) {
109
+ x.value = '__encrypted__';
110
+ }
111
+ });
112
+
113
+ delete blocklet.configObj;
114
+ delete blocklet.environmentObj;
115
+ },
116
+ { sync: true }
117
+ );
118
+
119
+ return blocklet;
120
+ };
121
+
122
+ const isDeletableBlocklet = (blocklet) => {
123
+ if (!blocklet) {
124
+ return false;
125
+ }
126
+
127
+ const config = blocklet.environments.find((x) => x.key === 'BLOCKLET_DELETABLE');
128
+ if (!config) {
129
+ return true;
130
+ }
131
+
132
+ return config.value === 'yes';
133
+ };
134
+
94
135
  module.exports = {
95
136
  isFreeBlocklet,
137
+ isDeletableBlocklet,
96
138
  forEachBlocklet,
97
139
  isAuthServiceEnabled,
98
140
  getRequiredMissingConfigs,
141
+ wipeSensitiveData,
99
142
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.7",
6
+ "version": "1.6.11",
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.4.5"
44
44
  },
45
- "gitHead": "d681c03a398e3c7d4dbc878db93b2ab778dded81"
45
+ "gitHead": "3e98db6be1337968182396e6aac1b3de53b03807"
46
46
  }