@abtnode/constant 1.8.34 → 1.8.36

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/index.js +57 -20
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -18,15 +18,31 @@ const SERVER_ROLES = Object.freeze({
18
18
  ...ROLES,
19
19
  CI: 'ci',
20
20
  CERTIFICATE: 'certificate',
21
- BLOCKLET: 'blocklet',
21
+
22
+ // blocklet user or sdk. must start with 'blocklet-
23
+ BLOCKLET_OWNER: 'blocklet-owner',
24
+ BLOCKLET_ADMIN: 'blocklet-admin',
25
+ BLOCKLET_MEMBER: 'blocklet-member',
26
+ BLOCKLET_SDK: 'blocklet-sdk',
27
+
28
+ // external user
22
29
  EXTERNAL_BLOCKLET_CONTROLLER: 'external-blocklet-controller',
23
30
  EXTERNAL_BLOCKLETS_MANAGER: 'external-blocklets-manager',
24
31
  });
25
32
 
33
+ const isBlockletRole = (role) =>
34
+ role &&
35
+ [
36
+ SERVER_ROLES.BLOCKLET_OWNER,
37
+ SERVER_ROLES.BLOCKLET_ADMIN,
38
+ SERVER_ROLES.BLOCKLET_MEMBER,
39
+ SERVER_ROLES.BLOCKLET_SDK,
40
+ ].includes(role);
41
+
26
42
  const AUTH_CERT_TYPE = {
27
43
  USER: 'user',
28
44
  OWNERSHIP_NFT: 'ownership_nft',
29
- BLOCKLET: 'blocklet',
45
+ BLOCKLET_USER: 'blocklet_user',
30
46
  BLOCKLET_CONTROLLER: 'blocklet_controller',
31
47
  };
32
48
 
@@ -73,9 +89,20 @@ const RBAC_CONFIG = {
73
89
  noHuman: true,
74
90
  },
75
91
  {
76
- name: SERVER_ROLES.BLOCKLET,
77
- title: 'Blocklet',
78
- // passport: true, // TODO enable this when we support access key for manage single blocklet
92
+ name: SERVER_ROLES.BLOCKLET_OWNER,
93
+ title: 'Blocklet Owner',
94
+ },
95
+ {
96
+ name: SERVER_ROLES.BLOCKLET_ADMIN,
97
+ title: 'Blocklet Admin',
98
+ },
99
+ {
100
+ name: SERVER_ROLES.BLOCKLET_MEMBER,
101
+ title: 'Blocklet Member',
102
+ },
103
+ {
104
+ name: SERVER_ROLES.BLOCKLET_SDK,
105
+ title: 'Blocklet SDK',
79
106
  },
80
107
  {
81
108
  name: SERVER_ROLES.EXTERNAL_BLOCKLET_CONTROLLER,
@@ -129,15 +156,11 @@ const RBAC_CONFIG = {
129
156
  description: 'Manage team data(members/roles/permissions) for Blocklet Server and blocklets',
130
157
  },
131
158
  {
132
- name: 'manage_blocklet',
133
- description: 'Manage a single blocklet',
134
- },
135
- {
136
- name: 'query_blocklet',
159
+ name: 'query_blocklets',
137
160
  description: 'View store and installed blocklets, including blocklet runtime configuration, domains and urls',
138
161
  },
139
162
  {
140
- name: 'mutate_blocklet',
163
+ name: 'mutate_blocklets',
141
164
  description: 'Perform state changing actions on blocklets, such as install/upgrade/config/start/stop/remove',
142
165
  },
143
166
  {
@@ -172,10 +195,18 @@ const RBAC_CONFIG = {
172
195
  name: 'mutate_webhook',
173
196
  description: 'Manage integrations',
174
197
  },
198
+ {
199
+ name: 'query_blocklet',
200
+ description: 'View a blocklet, including blocklet runtime configuration, domains and urls',
201
+ },
202
+ {
203
+ name: 'mutate_blocklet',
204
+ description: 'Perform state changing actions on a blocklet, such as upgrade/config/start/stop',
205
+ },
175
206
  ]),
176
207
  grants: Object.freeze({
177
208
  [SERVER_ROLES.GUEST]: [
178
- 'query_blocklet',
209
+ 'query_blocklets',
179
210
  'query_router',
180
211
  'query_webhook',
181
212
  'query_notification',
@@ -186,7 +217,7 @@ const RBAC_CONFIG = {
186
217
  ],
187
218
  [SERVER_ROLES.MEMBER]: [
188
219
  SERVER_ROLES.GUEST,
189
- 'mutate_blocklet',
220
+ 'mutate_blocklets',
190
221
  'mutate_router',
191
222
  'mutate_notification',
192
223
  'mutate_session',
@@ -200,14 +231,18 @@ const RBAC_CONFIG = {
200
231
  'mutate_certificate',
201
232
  ],
202
233
  [SERVER_ROLES.OWNER]: [ROLES.ADMIN],
203
- [SERVER_ROLES.CI]: ['query_blocklet', 'mutate_blocklet'],
234
+ [SERVER_ROLES.CI]: ['query_blocklets', 'mutate_blocklets'],
204
235
  [SERVER_ROLES.CERTIFICATE]: ['query_certificate', 'mutate_certificate'],
205
- [SERVER_ROLES.BLOCKLET]: ['query_team', 'mutate_team', 'manage_blocklet'],
206
- [SERVER_ROLES.EXTERNAL_BLOCKLET_CONTROLLER]: ['query_blocklet', 'mutate_blocklet'],
207
- [SERVER_ROLES.EXTERNAL_BLOCKLETS_MANAGER]: ['query_blocklet', 'mutate_blocklet'],
208
236
 
209
- // for backwards compatibility
210
- [NODE_SERVICES.AUTH_SERVICE]: ['query_team', 'mutate_team'],
237
+ // blocklet app or blocklet user
238
+ [SERVER_ROLES.BLOCKLET_SDK]: ['query_team', 'mutate_team'],
239
+ [SERVER_ROLES.BLOCKLET_OWNER]: [SERVER_ROLES.BLOCKLET_ADMIN],
240
+ [SERVER_ROLES.BLOCKLET_ADMIN]: [SERVER_ROLES.BLOCKLET_MEMBER, 'mutate_team', 'mutate_blocklet'],
241
+ [SERVER_ROLES.BLOCKLET_MEMBER]: ['query_team', 'query_blocklet'],
242
+
243
+ // external user
244
+ [SERVER_ROLES.EXTERNAL_BLOCKLET_CONTROLLER]: ['query_blocklets', 'mutate_blocklets'],
245
+ [SERVER_ROLES.EXTERNAL_BLOCKLETS_MANAGER]: ['query_blocklets', 'mutate_blocklets'],
211
246
  }),
212
247
  };
213
248
 
@@ -260,8 +295,8 @@ module.exports = Object.freeze({
260
295
  VC_TYPE_NODE_PASSPORT: 'ABTNodePassport',
261
296
  VC_TYPE_GENERAL_PASSPORT: 'NFTPassport',
262
297
 
263
- VC_TYPE_SERVER_SHARE: 'BlockletServerShareCertificate',
264
298
  NFT_TYPE_SERVER_OWNERSHIP: 'BlockletServerOwnershipNFT',
299
+ NFT_TYPE_SERVER_USAGE_CREDENTIAL: 'BlockletServerUsageCredential',
265
300
 
266
301
  NODE_PACKAGE_NAME: '@abtnode/cli', // deprecated in 1.6.0
267
302
  NODE_COMMAND_NAME: 'abtnode', // deprecated in 1.6.0
@@ -332,6 +367,7 @@ module.exports = Object.freeze({
332
367
  DEFAULT_HTTPS_PORT: 443,
333
368
  MAX_UPLOAD_FILE_SIZE: 500, // unit: MB
334
369
  DEFAULT_DAEMON_PORT: 8089,
370
+ MAX_NGINX_WORKER_CONNECTIONS: 10240,
335
371
 
336
372
  BLOCKLET_PROXY_PATH_PREFIX: '/.blocklet/proxy',
337
373
  BLOCKLET_SITE_GROUP_SUFFIX: '.blocklet-domain-group',
@@ -355,6 +391,7 @@ module.exports = Object.freeze({
355
391
  // Team
356
392
  ROLES,
357
393
  SERVER_ROLES,
394
+ isBlockletRole,
358
395
  AUTH_CERT_TYPE,
359
396
  RBAC_CONFIG,
360
397
  genPermissionName: (resource, action = 'access') => `${action}_${resource.replace('_', '-')}`, // resource cannot include '_'
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.34",
6
+ "version": "1.8.36",
7
7
  "description": "ABT Node constants",
8
8
  "main": "index.js",
9
9
  "files": [
@@ -20,5 +20,5 @@
20
20
  "devDependencies": {
21
21
  "jest": "^27.5.1"
22
22
  },
23
- "gitHead": "c5fbb8e57493db62f212217cfde1980c82f00297"
23
+ "gitHead": "507e974ce88bad1aa002c593130b32982207f803"
24
24
  }