@blocklet/meta 1.8.36 → 1.8.38
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/did.d.ts +4 -2
- package/lib/fix.js +1 -4
- package/lib/index.d.ts +5 -1
- package/lib/info.d.ts +1 -0
- package/lib/info.js +3 -1
- package/lib/parse.js +0 -2
- package/lib/schema.d.ts +5 -1
- package/lib/schema.js +77 -7
- package/lib/service.d.ts +10 -9
- package/lib/service.js +13 -33
- package/lib/types/schema.d.ts +11 -2
- package/lib/util.d.ts +20 -11
- package/lib/util.js +27 -9
- package/package.json +16 -16
- package/lib/service-configs/auth.json +0 -66
package/lib/did.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { TBlockletMeta } from './types';
|
|
3
2
|
declare const toBlockletDid: {
|
|
4
3
|
(name: string | Buffer): string;
|
|
5
4
|
toExternalBlocklet(name: string, userDid: string, { didOnly, nameOnly }?: {
|
|
6
5
|
didOnly?: boolean;
|
|
7
6
|
nameOnly?: boolean;
|
|
8
|
-
}):
|
|
7
|
+
}): string | {
|
|
8
|
+
did: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
9
11
|
};
|
|
10
12
|
export = toBlockletDid;
|
package/lib/fix.js
CHANGED
|
@@ -37,11 +37,8 @@ Object.defineProperty(exports, "fixService", { enumerable: true, get: function (
|
|
|
37
37
|
const constants_1 = __importDefault(require("./constants"));
|
|
38
38
|
const debug = (0, debug_1.default)('@blocklet/meta:fix');
|
|
39
39
|
const { BLOCKLET_DEFAULT_VERSION, BLOCKLET_DEFAULT_PORT_NAME, BLOCKLET_DYNAMIC_PATH_PREFIX, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_INTERFACE_PUBLIC, } = constants_1.default;
|
|
40
|
-
// Assign sensible defaults:
|
|
40
|
+
// Assign sensible defaults: description/main/group/version/public_url
|
|
41
41
|
const fixRequired = (data, dir) => {
|
|
42
|
-
if (!data.name) {
|
|
43
|
-
data.name = path_1.default.basename(dir);
|
|
44
|
-
}
|
|
45
42
|
if (!data.description) {
|
|
46
43
|
data.description = `Blocklet from ${dir}`;
|
|
47
44
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -63,7 +63,10 @@ declare const _default: {
|
|
|
63
63
|
toExternalBlocklet(name: string, userDid: string, { didOnly, nameOnly }?: {
|
|
64
64
|
didOnly?: boolean;
|
|
65
65
|
nameOnly?: boolean;
|
|
66
|
-
}): string |
|
|
66
|
+
}): string | {
|
|
67
|
+
did: string;
|
|
68
|
+
name: string;
|
|
69
|
+
};
|
|
67
70
|
};
|
|
68
71
|
getBlockletWallet: (blockletDid: string, nodeSk?: string, type?: import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
|
|
69
72
|
getBlockletInfo: (state: import("@abtnode/client").BlockletState, nodeSk?: string, { returnWallet }?: {
|
|
@@ -71,6 +74,7 @@ declare const _default: {
|
|
|
71
74
|
}) => {
|
|
72
75
|
did: string;
|
|
73
76
|
name: string;
|
|
77
|
+
version: string;
|
|
74
78
|
description: string;
|
|
75
79
|
passportColor?: string;
|
|
76
80
|
appUrl: string;
|
package/lib/info.d.ts
CHANGED
package/lib/info.js
CHANGED
|
@@ -14,7 +14,7 @@ const getBlockletInfo = (state, nodeSk, { returnWallet = true } = {}) => {
|
|
|
14
14
|
const customDescription = envs.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
|
|
15
15
|
const customPassportColor = envs.find((x) => x.key === 'BLOCKLET_PASSPORT_COLOR');
|
|
16
16
|
const customAppUrl = envs.find((x) => x.key === 'BLOCKLET_APP_URL');
|
|
17
|
-
const { did } = state.meta;
|
|
17
|
+
const { did, version } = state.meta;
|
|
18
18
|
const name = (0, util_1.getDisplayName)(state);
|
|
19
19
|
const description = (0, get_1.default)(customDescription, 'value', state.meta.description);
|
|
20
20
|
const passportColor = (0, get_1.default)(customPassportColor, 'value', 'auto');
|
|
@@ -22,6 +22,7 @@ const getBlockletInfo = (state, nodeSk, { returnWallet = true } = {}) => {
|
|
|
22
22
|
if (!returnWallet) {
|
|
23
23
|
return {
|
|
24
24
|
did,
|
|
25
|
+
version,
|
|
25
26
|
name,
|
|
26
27
|
description,
|
|
27
28
|
appUrl,
|
|
@@ -51,6 +52,7 @@ const getBlockletInfo = (state, nodeSk, { returnWallet = true } = {}) => {
|
|
|
51
52
|
}
|
|
52
53
|
return {
|
|
53
54
|
did,
|
|
55
|
+
version,
|
|
54
56
|
name,
|
|
55
57
|
description,
|
|
56
58
|
passportColor,
|
package/lib/parse.js
CHANGED
|
@@ -8,7 +8,6 @@ const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
|
8
8
|
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
9
9
|
const debug_1 = __importDefault(require("debug"));
|
|
10
10
|
const constants_1 = __importDefault(require("./constants"));
|
|
11
|
-
const did_1 = __importDefault(require("./did"));
|
|
12
11
|
const schema_1 = require("./schema");
|
|
13
12
|
const fix_1 = require("./fix");
|
|
14
13
|
const debug = (0, debug_1.default)('@blocklet/meta:parse');
|
|
@@ -67,7 +66,6 @@ const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = fals
|
|
|
67
66
|
debug('fix', result);
|
|
68
67
|
// We will overwrite did anyway
|
|
69
68
|
result.path = `/${result.group}/${result.name}`;
|
|
70
|
-
result.did = (0, did_1.default)(Buffer.from(result.name, 'utf8'));
|
|
71
69
|
// Ensure camelCase
|
|
72
70
|
result = Object.keys(result).reduce((acc, k) => {
|
|
73
71
|
acc[(0, camelCase_1.default)(k)] = result[k];
|
package/lib/schema.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare const descriptionSchema: JOI.StringSchema<string>;
|
|
|
4
4
|
declare const logoSchema: JOI.StringSchema<string>;
|
|
5
5
|
declare const mountPointSchema: JOI.StringSchema<string>;
|
|
6
6
|
declare const blockletNameSchema: JOI.StringSchema<string>;
|
|
7
|
+
declare const environmentNameSchema: JOI.StringSchema<string>;
|
|
7
8
|
declare const environmentSchema: JOI.ObjectSchema<any>;
|
|
8
9
|
declare const scriptsSchema: JOI.ObjectSchema<any>;
|
|
9
10
|
declare const serviceSchema: JOI.ObjectSchema<any>;
|
|
@@ -18,13 +19,14 @@ declare const signatureSchema: JOI.ObjectSchema<any>;
|
|
|
18
19
|
declare const navigationItemSchema: JOI.ObjectSchema<any>;
|
|
19
20
|
declare const navigationSchema: JOI.ArraySchema<any[]>;
|
|
20
21
|
declare const themeSchema: JOI.ObjectSchema<any>;
|
|
22
|
+
declare const authConfigSchema: JOI.ObjectSchema<any>;
|
|
21
23
|
declare const blockletMetaSchema: JOI.ObjectSchema<any>;
|
|
22
24
|
declare const createBlockletSchema: (baseDir: string, { ensureMain, ensureFiles, ensureDist, ...schemaOptions }?: {
|
|
23
25
|
ensureMain?: boolean;
|
|
24
26
|
ensureFiles?: boolean;
|
|
25
27
|
ensureDist?: boolean;
|
|
26
28
|
}) => JOI.ObjectSchema;
|
|
27
|
-
export { blockletMetaSchema, blockletNameSchema, componentSchema, createBlockletSchema, descriptionSchema, distSchema, endpointSchema, engineSchema, environmentSchema, interfaceSchema, logoSchema, mountPointSchema, navigationItemSchema, navigationSchema, personSchema, scriptsSchema, serviceSchema, signatureSchema, themeSchema, titleSchema, statsSchema, };
|
|
29
|
+
export { blockletMetaSchema, blockletNameSchema, componentSchema, createBlockletSchema, descriptionSchema, distSchema, endpointSchema, engineSchema, environmentSchema, environmentNameSchema, interfaceSchema, logoSchema, mountPointSchema, navigationItemSchema, navigationSchema, personSchema, scriptsSchema, serviceSchema, signatureSchema, themeSchema, titleSchema, statsSchema, authConfigSchema, };
|
|
28
30
|
declare const _default: {
|
|
29
31
|
blockletNameSchema: JOI.StringSchema<string>;
|
|
30
32
|
componentSchema: JOI.ObjectSchema<any>;
|
|
@@ -37,6 +39,7 @@ declare const _default: {
|
|
|
37
39
|
}) => JOI.ObjectSchema<any>;
|
|
38
40
|
interfaceSchema: JOI.ObjectSchema<any>;
|
|
39
41
|
environmentSchema: JOI.ObjectSchema<any>;
|
|
42
|
+
environmentNameSchema: JOI.StringSchema<string>;
|
|
40
43
|
scriptsSchema: JOI.ObjectSchema<any>;
|
|
41
44
|
personSchema: JOI.ObjectSchema<any>;
|
|
42
45
|
distSchema: JOI.ObjectSchema<any>;
|
|
@@ -46,5 +49,6 @@ declare const _default: {
|
|
|
46
49
|
navigationSchema: JOI.ArraySchema<any[]>;
|
|
47
50
|
themeSchema: JOI.ObjectSchema<any>;
|
|
48
51
|
mountPointSchema: JOI.StringSchema<string>;
|
|
52
|
+
authConfigSchema: JOI.ObjectSchema<any>;
|
|
49
53
|
};
|
|
50
54
|
export default _default;
|
package/lib/schema.js
CHANGED
|
@@ -14,18 +14,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.statsSchema = exports.titleSchema = exports.themeSchema = exports.signatureSchema = exports.serviceSchema = exports.scriptsSchema = exports.personSchema = exports.navigationSchema = exports.navigationItemSchema = exports.mountPointSchema = exports.logoSchema = exports.interfaceSchema = exports.environmentSchema = exports.engineSchema = exports.endpointSchema = exports.distSchema = exports.descriptionSchema = exports.createBlockletSchema = exports.componentSchema = exports.blockletNameSchema = exports.blockletMetaSchema = void 0;
|
|
17
|
+
exports.authConfigSchema = exports.statsSchema = exports.titleSchema = exports.themeSchema = exports.signatureSchema = exports.serviceSchema = exports.scriptsSchema = exports.personSchema = exports.navigationSchema = exports.navigationItemSchema = exports.mountPointSchema = exports.logoSchema = exports.interfaceSchema = exports.environmentNameSchema = exports.environmentSchema = exports.engineSchema = exports.endpointSchema = exports.distSchema = exports.descriptionSchema = exports.createBlockletSchema = exports.componentSchema = exports.blockletNameSchema = exports.blockletMetaSchema = void 0;
|
|
18
18
|
const fs_1 = __importDefault(require("fs"));
|
|
19
19
|
const joi_1 = __importDefault(require("joi"));
|
|
20
20
|
// eslint-disable-next-line import/no-named-default
|
|
21
21
|
const cjk_length_1 = __importDefault(require("cjk-length"));
|
|
22
22
|
const is_glob_1 = __importDefault(require("is-glob"));
|
|
23
23
|
const joi_extension_semver_1 = require("joi-extension-semver");
|
|
24
|
+
const did_1 = __importDefault(require("./did"));
|
|
24
25
|
const extension_1 = require("./extension");
|
|
25
26
|
const name_1 = require("./name");
|
|
26
27
|
const constants_1 = __importDefault(require("./constants"));
|
|
27
28
|
const cjkLength = cjk_length_1.default.default;
|
|
28
|
-
const { BLOCKLET_GROUPS, BLOCKLET_PLATFORMS, BLOCKLET_ARCHITECTURES, BLOCKLET_INTERFACE_TYPES, BLOCKLET_INTERFACE_PROTOCOLS, BLOCKLET_ENTRY_FILE, BLOCKLET_BUNDLE_FILE, BLOCKLET_DEFAULT_PORT_NAME, BLOCKLET_DYNAMIC_PATH_PREFIX, BlockletGroup, BLOCKLET_LATEST_REQUIREMENT_SERVER, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
|
|
29
|
+
const { BLOCKLET_GROUPS, BLOCKLET_PLATFORMS, BLOCKLET_ARCHITECTURES, BLOCKLET_INTERFACE_TYPES, BLOCKLET_INTERFACE_PROTOCOLS, BLOCKLET_ENTRY_FILE, BLOCKLET_BUNDLE_FILE, BLOCKLET_DEFAULT_PORT_NAME, BLOCKLET_DYNAMIC_PATH_PREFIX, BlockletGroup, BLOCKLET_LATEST_REQUIREMENT_SERVER, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_INTERFACE_TYPE_WELLKNOWN, BLOCKLET_APP_SPACE_ENDPOINTS, BLOCKLET_CONFIGURABLE_KEY, } = constants_1.default;
|
|
29
30
|
const WELLKNOWN_PATH_PREFIX = '/.well-known';
|
|
30
31
|
const MAX_TITLE_LENGTH = 24;
|
|
31
32
|
const MAX_NAME_LENGTH = 32;
|
|
@@ -61,8 +62,40 @@ const blockletNameSchema = Joi.string()
|
|
|
61
62
|
.max(MAX_NAME_LENGTH)
|
|
62
63
|
.meta({ className: 'TBlockletName' });
|
|
63
64
|
exports.blockletNameSchema = blockletNameSchema;
|
|
65
|
+
const ENV_NAME_WHITE_LIST = [BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_WALLET_TYPE];
|
|
66
|
+
const environmentNameSchema = Joi.string()
|
|
67
|
+
.trim()
|
|
68
|
+
.min(1)
|
|
69
|
+
.max(50)
|
|
70
|
+
.required()
|
|
71
|
+
.custom((name, helper) => {
|
|
72
|
+
if (name.startsWith('BLOCKLET')) {
|
|
73
|
+
if (!ENV_NAME_WHITE_LIST.includes(name)) {
|
|
74
|
+
// @ts-expect-error
|
|
75
|
+
return helper.message('Env name can not start with BLOCKLET_');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (name.startsWith('COMPONENT')) {
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
return helper.message('Env name can not start with COMPONENT_');
|
|
81
|
+
}
|
|
82
|
+
if (name.startsWith('ABTNODE')) {
|
|
83
|
+
// @ts-expect-error
|
|
84
|
+
return helper.message('Env name can not start with ABTNODE_');
|
|
85
|
+
}
|
|
86
|
+
if (/[^\w]/.test(name)) {
|
|
87
|
+
// @ts-expect-error
|
|
88
|
+
return helper.message('Env name can include only numbers or letters or "_"');
|
|
89
|
+
}
|
|
90
|
+
return name;
|
|
91
|
+
})
|
|
92
|
+
.meta({
|
|
93
|
+
className: 'TEnvironmentName',
|
|
94
|
+
unknownType: 'any',
|
|
95
|
+
});
|
|
96
|
+
exports.environmentNameSchema = environmentNameSchema;
|
|
64
97
|
const environmentSchema = Joi.object({
|
|
65
|
-
name:
|
|
98
|
+
name: environmentNameSchema.required(),
|
|
66
99
|
description: Joi.string().trim().required(),
|
|
67
100
|
default: Joi.string().optional().allow('').default(''),
|
|
68
101
|
required: Joi.boolean().default(false),
|
|
@@ -303,6 +336,20 @@ const themeSchema = Joi.object({
|
|
|
303
336
|
unknownType: 'any',
|
|
304
337
|
});
|
|
305
338
|
exports.themeSchema = themeSchema;
|
|
339
|
+
const authConfigSchema = Joi.object({
|
|
340
|
+
whoCanAccess: Joi.string().valid('owner', 'invited', 'all'),
|
|
341
|
+
profileFields: Joi.array().items(Joi.string().valid('fullName', 'email', 'avatar', 'phone')).unique(),
|
|
342
|
+
ignoreUrls: Joi.array().items(Joi.string().min(1)),
|
|
343
|
+
allowSwitchProfile: Joi.boolean(),
|
|
344
|
+
blockUnauthenticated: Joi.boolean(),
|
|
345
|
+
blockUnauthorized: Joi.boolean(),
|
|
346
|
+
})
|
|
347
|
+
.options({ stripUnknown: true })
|
|
348
|
+
.meta({
|
|
349
|
+
className: 'TAuthConfig',
|
|
350
|
+
unknownType: 'any',
|
|
351
|
+
});
|
|
352
|
+
exports.authConfigSchema = authConfigSchema;
|
|
306
353
|
const blockletMetaProps = {
|
|
307
354
|
did: Joi.DID().trim().required(),
|
|
308
355
|
version: Joi.semver().valid().required(),
|
|
@@ -445,7 +492,20 @@ const blockletMetaProps = {
|
|
|
445
492
|
})
|
|
446
493
|
.default([]),
|
|
447
494
|
// environments
|
|
448
|
-
environments: Joi.array()
|
|
495
|
+
environments: Joi.array()
|
|
496
|
+
.items(environmentSchema)
|
|
497
|
+
.default([])
|
|
498
|
+
.optional()
|
|
499
|
+
.custom((data, helper) => {
|
|
500
|
+
if (data && data.length) {
|
|
501
|
+
const duplicates = data.filter((x, index) => data.findIndex((y) => y.name === x.name) !== index);
|
|
502
|
+
if (duplicates.length) {
|
|
503
|
+
// @ts-expect-error
|
|
504
|
+
return helper.message(`find duplicate environment names ${duplicates.map((x) => x.name).join(', ')}`);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return data;
|
|
508
|
+
}),
|
|
449
509
|
// scripts & hooks
|
|
450
510
|
scripts: scriptsSchema,
|
|
451
511
|
// capabilities
|
|
@@ -453,8 +513,8 @@ const blockletMetaProps = {
|
|
|
453
513
|
clusterMode: Joi.boolean().default(false),
|
|
454
514
|
// added in 1.2.2
|
|
455
515
|
component: Joi.boolean().default(true),
|
|
456
|
-
|
|
457
|
-
.valid(...Object.values(
|
|
516
|
+
didSpace: Joi.string()
|
|
517
|
+
.valid(...Object.values(BLOCKLET_APP_SPACE_ENDPOINTS))
|
|
458
518
|
.optional(),
|
|
459
519
|
}).default({
|
|
460
520
|
clusterMode: false,
|
|
@@ -511,7 +571,15 @@ const createBlockletSchema = (baseDir, _a = {}) => {
|
|
|
511
571
|
: Joi.string().trim())
|
|
512
572
|
.optional(), dist: ensureDist ? distSchema.required() : distSchema.optional() }))
|
|
513
573
|
.options(Object.assign({ stripUnknown: true, noDefaults: false }, schemaOptions))
|
|
514
|
-
.rename('children', 'components')
|
|
574
|
+
.rename('children', 'components')
|
|
575
|
+
.custom((data, helper) => {
|
|
576
|
+
const { did, name } = data;
|
|
577
|
+
if ((0, did_1.default)(name) !== did) {
|
|
578
|
+
// @ts-expect-error
|
|
579
|
+
return helper.message(`name "${name}" does not match with did "${did}"`);
|
|
580
|
+
}
|
|
581
|
+
return data;
|
|
582
|
+
});
|
|
515
583
|
};
|
|
516
584
|
exports.createBlockletSchema = createBlockletSchema;
|
|
517
585
|
exports.default = {
|
|
@@ -522,6 +590,7 @@ exports.default = {
|
|
|
522
590
|
createBlockletSchema,
|
|
523
591
|
interfaceSchema,
|
|
524
592
|
environmentSchema,
|
|
593
|
+
environmentNameSchema,
|
|
525
594
|
scriptsSchema,
|
|
526
595
|
personSchema,
|
|
527
596
|
distSchema,
|
|
@@ -531,4 +600,5 @@ exports.default = {
|
|
|
531
600
|
navigationSchema,
|
|
532
601
|
themeSchema,
|
|
533
602
|
mountPointSchema,
|
|
603
|
+
authConfigSchema,
|
|
534
604
|
};
|
package/lib/service.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
declare const setService: (meta:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const setService: (meta: {
|
|
2
|
+
name: string;
|
|
3
|
+
schema: any;
|
|
4
|
+
default: any;
|
|
5
|
+
}) => void;
|
|
5
6
|
declare const getServiceConfig: (serviceName: string, customConfig: any, { validate }?: {
|
|
6
7
|
validate?: any;
|
|
7
8
|
}) => any;
|
|
8
9
|
declare const getDefaultServiceConfig: (serviceName: string) => any;
|
|
9
10
|
declare const findService: (services: any[], name: string) => any;
|
|
10
|
-
export { getServiceMetas };
|
|
11
11
|
export { getServiceConfig };
|
|
12
12
|
export { getDefaultServiceConfig };
|
|
13
13
|
export { findService };
|
|
14
14
|
export { setService };
|
|
15
15
|
declare const _default: {
|
|
16
|
-
getServiceMetas: ({ stringifySchema }?: {
|
|
17
|
-
stringifySchema?: boolean;
|
|
18
|
-
}) => any[];
|
|
19
16
|
getServiceConfig: (serviceName: string, customConfig: any, { validate }?: {
|
|
20
17
|
validate?: any;
|
|
21
18
|
}) => any;
|
|
22
19
|
getDefaultServiceConfig: (serviceName: string) => any;
|
|
23
20
|
findService: (services: any[], name: string) => any;
|
|
24
|
-
setService: (meta:
|
|
21
|
+
setService: (meta: {
|
|
22
|
+
name: string;
|
|
23
|
+
schema: any;
|
|
24
|
+
default: any;
|
|
25
|
+
}) => void;
|
|
25
26
|
};
|
|
26
27
|
export default _default;
|
package/lib/service.js
CHANGED
|
@@ -3,43 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setService = exports.findService = exports.getDefaultServiceConfig = exports.getServiceConfig =
|
|
6
|
+
exports.setService = exports.findService = exports.getDefaultServiceConfig = exports.getServiceConfig = void 0;
|
|
7
7
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
8
|
-
const ajv_1 = __importDefault(require("ajv"));
|
|
9
8
|
const constant_1 = __importDefault(require("@abtnode/constant"));
|
|
10
|
-
const
|
|
9
|
+
const schema_1 = require("./schema");
|
|
11
10
|
const { NODE_SERVICES } = constant_1.default;
|
|
12
|
-
const ajv = new ajv_1.default({
|
|
13
|
-
useDefaults: true,
|
|
14
|
-
removeAdditional: 'all',
|
|
15
|
-
});
|
|
16
11
|
const SERVICES = {};
|
|
17
12
|
const setService = (meta) => {
|
|
18
|
-
const validate = ajv.compile(meta.schema.JSONSchema);
|
|
19
|
-
// parse empty custom config to get default config
|
|
20
|
-
const defaultConfig = {};
|
|
21
|
-
validate(defaultConfig);
|
|
22
13
|
SERVICES[meta.name] = {
|
|
23
|
-
meta,
|
|
24
|
-
|
|
25
|
-
defaultConfig,
|
|
14
|
+
validate: meta.schema.validate.bind(meta.schema),
|
|
15
|
+
defaultConfig: meta.default,
|
|
26
16
|
};
|
|
27
17
|
};
|
|
28
18
|
exports.setService = setService;
|
|
29
|
-
setService(
|
|
19
|
+
setService({
|
|
20
|
+
name: 'auth',
|
|
21
|
+
schema: schema_1.authConfigSchema,
|
|
22
|
+
default: {},
|
|
23
|
+
});
|
|
30
24
|
// backward compatible
|
|
31
25
|
SERVICES[NODE_SERVICES.AUTH_SERVICE] = Object.assign(Object.assign({}, SERVICES[NODE_SERVICES.AUTH]), { meta: Object.assign(Object.assign({}, SERVICES[NODE_SERVICES.AUTH].meta), { name: NODE_SERVICES.AUTH_SERVICE }) });
|
|
32
|
-
const getServiceMetas = ({ stringifySchema = false } = {}) => {
|
|
33
|
-
const list = Object.values(SERVICES).map(({ meta }) => {
|
|
34
|
-
const data = (0, cloneDeep_1.default)(meta);
|
|
35
|
-
if (stringifySchema) {
|
|
36
|
-
data.schema = JSON.stringify(meta.schema);
|
|
37
|
-
}
|
|
38
|
-
return data;
|
|
39
|
-
});
|
|
40
|
-
return list;
|
|
41
|
-
};
|
|
42
|
-
exports.getServiceMetas = getServiceMetas;
|
|
43
26
|
const getService = (serviceName) => {
|
|
44
27
|
if (!serviceName) {
|
|
45
28
|
throw new Error('service name should not be empty');
|
|
@@ -53,13 +36,11 @@ const getService = (serviceName) => {
|
|
|
53
36
|
const getServiceConfig = (serviceName, customConfig, { validate } = {}) => {
|
|
54
37
|
const service = getService(serviceName);
|
|
55
38
|
const data = (0, cloneDeep_1.default)(customConfig || {});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const message = service.validate.errors.map((x) => `${x.instancePath} ${x.message}`).join(', ');
|
|
60
|
-
throw new Error(`Invalid blocklet service config: ${message}`);
|
|
39
|
+
const { value, error } = service.validate(data);
|
|
40
|
+
if (validate && error) {
|
|
41
|
+
throw new Error(`Invalid blocklet service config: ${error.details.map((x) => x.message).join(', ')}`);
|
|
61
42
|
}
|
|
62
|
-
return
|
|
43
|
+
return value;
|
|
63
44
|
};
|
|
64
45
|
exports.getServiceConfig = getServiceConfig;
|
|
65
46
|
const getDefaultServiceConfig = (serviceName) => {
|
|
@@ -77,7 +58,6 @@ const findService = (services, name) => {
|
|
|
77
58
|
};
|
|
78
59
|
exports.findService = findService;
|
|
79
60
|
exports.default = {
|
|
80
|
-
getServiceMetas,
|
|
81
61
|
getServiceConfig,
|
|
82
62
|
getDefaultServiceConfig,
|
|
83
63
|
findService,
|
package/lib/types/schema.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export interface TAuthConfig {
|
|
2
|
+
allowSwitchProfile?: boolean;
|
|
3
|
+
blockUnauthenticated?: boolean;
|
|
4
|
+
blockUnauthorized?: boolean;
|
|
5
|
+
ignoreUrls?: string[];
|
|
6
|
+
profileFields?: ('fullName' | 'email' | 'avatar' | 'phone')[];
|
|
7
|
+
whoCanAccess?: 'owner' | 'invited' | 'all';
|
|
8
|
+
}
|
|
1
9
|
export interface TBlockletMeta {
|
|
2
10
|
author?: TPerson;
|
|
3
11
|
bundleDid?: string;
|
|
@@ -5,7 +13,7 @@ export interface TBlockletMeta {
|
|
|
5
13
|
capabilities?: {
|
|
6
14
|
clusterMode?: boolean;
|
|
7
15
|
component?: boolean;
|
|
8
|
-
|
|
16
|
+
didSpace?: 'required' | 'optional';
|
|
9
17
|
};
|
|
10
18
|
community?: string;
|
|
11
19
|
components?: TComponent[];
|
|
@@ -139,12 +147,13 @@ export interface TEngine {
|
|
|
139
147
|
export interface TEnvironment {
|
|
140
148
|
default?: string;
|
|
141
149
|
description: string;
|
|
142
|
-
name:
|
|
150
|
+
name: TEnvironmentName;
|
|
143
151
|
required?: boolean;
|
|
144
152
|
secure?: boolean;
|
|
145
153
|
shared?: boolean;
|
|
146
154
|
validation?: string;
|
|
147
155
|
}
|
|
156
|
+
export declare type TEnvironmentName = string;
|
|
148
157
|
export interface TInterface {
|
|
149
158
|
endpoints?: TEndpoint[];
|
|
150
159
|
name: string;
|
package/lib/util.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { BlockletState } from '@abtnode/client';
|
|
1
|
+
import { BlockletState, ComponentState } from '@abtnode/client';
|
|
2
2
|
import { Request } from 'express';
|
|
3
3
|
import { TBlockletMeta, TEnvironment } from './types';
|
|
4
|
+
declare type TConfig = TEnvironment & {
|
|
5
|
+
key: string;
|
|
6
|
+
};
|
|
4
7
|
declare const getComponentId: (component?: {
|
|
5
8
|
meta?: {
|
|
6
9
|
did?: string;
|
|
@@ -36,7 +39,7 @@ declare const getComponentBundleId: (component: {
|
|
|
36
39
|
* @a/b/@c/d/@e/f => @a/b/@c/d
|
|
37
40
|
*/
|
|
38
41
|
declare const getParentComponentName: (name?: string) => string;
|
|
39
|
-
declare const forEachBlocklet: (blocklet: BlockletState, cb: Function, { parallel, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, }?: {
|
|
42
|
+
declare const forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Function, { parallel, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, }?: {
|
|
40
43
|
parallel?: boolean;
|
|
41
44
|
sync?: boolean;
|
|
42
45
|
params?: any;
|
|
@@ -49,14 +52,13 @@ declare const forEachBlocklet: (blocklet: BlockletState, cb: Function, { paralle
|
|
|
49
52
|
declare const forEachBlockletSync: (blocklet: any, cb: Function) => Promise<unknown>;
|
|
50
53
|
declare const forEachChild: (blocklet: any, cb: Function, params?: any) => Promise<any>;
|
|
51
54
|
declare const forEachChildSync: (blocklet: BlockletState, cb: Function) => Promise<any>;
|
|
52
|
-
declare const findComponentById: (blocklet: BlockletState, componentId: string
|
|
55
|
+
declare const findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | Array<string>, { _ancestors, returnAncestors, }?: {
|
|
53
56
|
_ancestors?: any[];
|
|
54
57
|
returnAncestors?: boolean;
|
|
55
58
|
}) => any;
|
|
56
|
-
declare const isEnvShareable: (env?:
|
|
57
|
-
key: string;
|
|
58
|
-
}) => boolean;
|
|
59
|
+
declare const isEnvShareable: (env?: TConfig) => boolean;
|
|
59
60
|
declare const getSharedConfigObj: (component: BlockletState, ancestors?: any[]) => any;
|
|
61
|
+
declare const isPreferenceKey: (x: TConfig) => Boolean;
|
|
60
62
|
declare const getAppMissingConfigs: (blocklet?: any) => any[];
|
|
61
63
|
declare const getComponentMissingConfigs: (component?: any, ancestors?: any[]) => any[];
|
|
62
64
|
declare const isFreeBlocklet: (meta: TBlockletMeta) => boolean;
|
|
@@ -84,6 +86,9 @@ declare const replaceSlotToIp: (url?: string, ip?: string) => string;
|
|
|
84
86
|
declare const urlFriendly: (name: string) => string;
|
|
85
87
|
declare const getChainInfo: (env: Record<string, string>) => Record<string, string>;
|
|
86
88
|
declare const isExternalBlocklet: (blocklet?: BlockletState) => boolean;
|
|
89
|
+
declare const getRolesFromAuthConfig: (config: {
|
|
90
|
+
whoCanAccess: string;
|
|
91
|
+
}) => Array<string>;
|
|
87
92
|
export { isFreeBlocklet };
|
|
88
93
|
export { isFreeComponent };
|
|
89
94
|
export { isComponentBlocklet };
|
|
@@ -113,11 +118,13 @@ export { getParentComponentName };
|
|
|
113
118
|
export { getConnectAppUrl };
|
|
114
119
|
export { getChainInfo };
|
|
115
120
|
export { isExternalBlocklet };
|
|
121
|
+
export { isPreferenceKey };
|
|
122
|
+
export { getRolesFromAuthConfig };
|
|
116
123
|
declare const _default: {
|
|
117
124
|
isFreeBlocklet: (meta: TBlockletMeta) => boolean;
|
|
118
125
|
isFreeComponent: (meta: TBlockletMeta) => boolean;
|
|
119
126
|
isComponentBlocklet: (meta?: TBlockletMeta) => boolean;
|
|
120
|
-
forEachBlocklet: (blocklet: BlockletState, cb: Function, { parallel, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, }?: {
|
|
127
|
+
forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Function, { parallel, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, }?: {
|
|
121
128
|
parallel?: boolean;
|
|
122
129
|
sync?: boolean;
|
|
123
130
|
params?: any;
|
|
@@ -134,9 +141,7 @@ declare const _default: {
|
|
|
134
141
|
getSharedConfigObj: (component: BlockletState, ancestors?: any[]) => any;
|
|
135
142
|
getAppMissingConfigs: (blocklet?: any) => any[];
|
|
136
143
|
getComponentMissingConfigs: (component?: any, ancestors?: any[]) => any[];
|
|
137
|
-
isEnvShareable: (env?:
|
|
138
|
-
key: string;
|
|
139
|
-
}) => boolean;
|
|
144
|
+
isEnvShareable: (env?: TConfig) => boolean;
|
|
140
145
|
wipeSensitiveData: (blocklet?: BlockletState) => BlockletState;
|
|
141
146
|
hasRunnableComponent: (blocklet: BlockletState) => boolean;
|
|
142
147
|
getDisplayName: (blocklet: BlockletState, onlyUseMeta?: boolean) => string;
|
|
@@ -170,7 +175,7 @@ declare const _default: {
|
|
|
170
175
|
version: string;
|
|
171
176
|
};
|
|
172
177
|
}) => string;
|
|
173
|
-
findComponentById: (blocklet: BlockletState, componentId: string, { _ancestors, returnAncestors, }?: {
|
|
178
|
+
findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | string[], { _ancestors, returnAncestors, }?: {
|
|
174
179
|
_ancestors?: any[];
|
|
175
180
|
returnAncestors?: boolean;
|
|
176
181
|
}) => any;
|
|
@@ -181,5 +186,9 @@ declare const _default: {
|
|
|
181
186
|
}) => string;
|
|
182
187
|
getChainInfo: (env: Record<string, string>) => Record<string, string>;
|
|
183
188
|
isExternalBlocklet: (blocklet?: BlockletState) => boolean;
|
|
189
|
+
isPreferenceKey: (x: TConfig) => Boolean;
|
|
190
|
+
getRolesFromAuthConfig: (config: {
|
|
191
|
+
whoCanAccess: string;
|
|
192
|
+
}) => string[];
|
|
184
193
|
};
|
|
185
194
|
export default _default;
|
package/lib/util.js
CHANGED
|
@@ -12,15 +12,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.isExternalBlocklet = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.findComponentById = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.urlFriendly = exports.replaceSlotToIp = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterface = exports.fixBlockletStatus = exports.getDisplayName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
15
|
+
exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.findComponentById = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.urlFriendly = exports.replaceSlotToIp = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterface = exports.fixBlockletStatus = exports.getDisplayName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
16
16
|
/* eslint-disable no-await-in-loop */
|
|
17
17
|
const get_1 = __importDefault(require("lodash/get"));
|
|
18
18
|
const slugify_1 = __importDefault(require("slugify"));
|
|
19
19
|
const url_join_1 = __importDefault(require("url-join"));
|
|
20
20
|
const constant_1 = __importDefault(require("@abtnode/constant"));
|
|
21
21
|
const constants_1 = __importDefault(require("./constants"));
|
|
22
|
-
const { NODE_SERVICES, SLOT_FOR_IP_DNS_SITE, WHO_CAN_ACCESS } = constant_1.default;
|
|
23
|
-
const { BlockletGroup, fromBlockletStatus, fromBlockletSource, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_CONFIGURABLE_KEY, CHAIN_INFO_CONFIG, } = constants_1.default;
|
|
22
|
+
const { NODE_SERVICES, SLOT_FOR_IP_DNS_SITE, WHO_CAN_ACCESS, WHO_CAN_ACCESS_PREFIX_ROLES } = constant_1.default;
|
|
23
|
+
const { BlockletGroup, fromBlockletStatus, fromBlockletSource, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_CONFIGURABLE_KEY, CHAIN_INFO_CONFIG, BLOCKLET_PREFERENCE_PREFIX, } = constants_1.default;
|
|
24
24
|
const getComponentId = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.did : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.did : ''}`;
|
|
25
25
|
exports.getComponentId = getComponentId;
|
|
26
26
|
const getComponentName = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.name : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.name : ''}`;
|
|
@@ -151,6 +151,10 @@ exports.forEachChild = forEachChild;
|
|
|
151
151
|
const forEachChildSync = (blocklet, cb) => forEachChild(blocklet, cb, { sync: true });
|
|
152
152
|
exports.forEachChildSync = forEachChildSync;
|
|
153
153
|
const findComponentById = (blocklet, componentId, { _ancestors = [], returnAncestors = false, } = {}) => {
|
|
154
|
+
if (Array.isArray(componentId)) {
|
|
155
|
+
// eslint-disable-next-line no-param-reassign
|
|
156
|
+
componentId = componentId.join('/');
|
|
157
|
+
}
|
|
154
158
|
const id = getComponentId(blocklet, _ancestors);
|
|
155
159
|
if (componentId === id) {
|
|
156
160
|
if (returnAncestors) {
|
|
@@ -205,6 +209,8 @@ const getSharedConfigObj = (component, ancestors) => {
|
|
|
205
209
|
return res;
|
|
206
210
|
};
|
|
207
211
|
exports.getSharedConfigObj = getSharedConfigObj;
|
|
212
|
+
const isPreferenceKey = (x) => x.key.startsWith(BLOCKLET_PREFERENCE_PREFIX) === true;
|
|
213
|
+
exports.isPreferenceKey = isPreferenceKey;
|
|
208
214
|
const getAppMissingConfigs = (blocklet = {}) => {
|
|
209
215
|
const missingConfigs = [];
|
|
210
216
|
forEachBlockletSync(blocklet, (b, { ancestors }) => {
|
|
@@ -216,7 +222,7 @@ const getAppMissingConfigs = (blocklet = {}) => {
|
|
|
216
222
|
}
|
|
217
223
|
});
|
|
218
224
|
});
|
|
219
|
-
return missingConfigs;
|
|
225
|
+
return missingConfigs.filter((x) => !isPreferenceKey(x));
|
|
220
226
|
};
|
|
221
227
|
exports.getAppMissingConfigs = getAppMissingConfigs;
|
|
222
228
|
const getComponentMissingConfigs = (component = {}, ancestors = []) => {
|
|
@@ -258,11 +264,14 @@ const wipeSensitiveData = (blocklet) => {
|
|
|
258
264
|
return blocklet;
|
|
259
265
|
}
|
|
260
266
|
forEachBlocklet(blocklet, (d) => {
|
|
261
|
-
(d.configs
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
267
|
+
if (d.configs) {
|
|
268
|
+
d.configs = d.configs.filter((x) => !isPreferenceKey(x));
|
|
269
|
+
d.configs.forEach((x) => {
|
|
270
|
+
if (x.secure) {
|
|
271
|
+
x.value = x.value ? '__encrypted__' : '';
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
266
275
|
(d.environments || []).forEach((x) => {
|
|
267
276
|
if (['BLOCKLET_APP_SK'].includes(x.key)) {
|
|
268
277
|
x.value = '__encrypted__';
|
|
@@ -408,6 +417,13 @@ const getChainInfo = (env) => Object.entries(CHAIN_INFO_CONFIG).reduce((info, x)
|
|
|
408
417
|
exports.getChainInfo = getChainInfo;
|
|
409
418
|
const isExternalBlocklet = (blocklet) => !!(blocklet === null || blocklet === void 0 ? void 0 : blocklet.controller);
|
|
410
419
|
exports.isExternalBlocklet = isExternalBlocklet;
|
|
420
|
+
const getRolesFromAuthConfig = (config) => {
|
|
421
|
+
if (!config.whoCanAccess.startsWith(WHO_CAN_ACCESS_PREFIX_ROLES)) {
|
|
422
|
+
return [];
|
|
423
|
+
}
|
|
424
|
+
return config.whoCanAccess.substring(WHO_CAN_ACCESS_PREFIX_ROLES.length).split(',');
|
|
425
|
+
};
|
|
426
|
+
exports.getRolesFromAuthConfig = getRolesFromAuthConfig;
|
|
411
427
|
exports.default = {
|
|
412
428
|
isFreeBlocklet,
|
|
413
429
|
isFreeComponent,
|
|
@@ -438,4 +454,6 @@ exports.default = {
|
|
|
438
454
|
getConnectAppUrl,
|
|
439
455
|
getChainInfo,
|
|
440
456
|
isExternalBlocklet,
|
|
457
|
+
isPreferenceKey,
|
|
458
|
+
getRolesFromAuthConfig,
|
|
441
459
|
};
|
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.38",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@abtnode/client": "1.8.
|
|
28
|
-
"@abtnode/constant": "1.8.
|
|
29
|
-
"@abtnode/util": "1.8.
|
|
30
|
-
"@arcblock/did": "1.18.
|
|
31
|
-
"@arcblock/did-ext": "1.18.
|
|
32
|
-
"@arcblock/did-util": "1.18.
|
|
33
|
-
"@arcblock/jwt": "1.18.
|
|
34
|
-
"@blocklet/constant": "1.8.
|
|
35
|
-
"@ocap/asset": "1.18.
|
|
36
|
-
"@ocap/mcrypto": "1.18.
|
|
37
|
-
"@ocap/types": "1.18.
|
|
38
|
-
"@ocap/util": "1.18.
|
|
39
|
-
"@ocap/wallet": "1.18.
|
|
27
|
+
"@abtnode/client": "1.8.38",
|
|
28
|
+
"@abtnode/constant": "1.8.38",
|
|
29
|
+
"@abtnode/util": "1.8.38",
|
|
30
|
+
"@arcblock/did": "1.18.18",
|
|
31
|
+
"@arcblock/did-ext": "1.18.18",
|
|
32
|
+
"@arcblock/did-util": "1.18.18",
|
|
33
|
+
"@arcblock/jwt": "1.18.18",
|
|
34
|
+
"@blocklet/constant": "1.8.38",
|
|
35
|
+
"@ocap/asset": "1.18.18",
|
|
36
|
+
"@ocap/mcrypto": "1.18.18",
|
|
37
|
+
"@ocap/types": "1.18.18",
|
|
38
|
+
"@ocap/util": "1.18.18",
|
|
39
|
+
"@ocap/wallet": "1.18.18",
|
|
40
40
|
"ajv": "^8.11.0",
|
|
41
41
|
"axios": "^0.27.2",
|
|
42
42
|
"cjk-length": "^1.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"validate-npm-package-name": "^3.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@abtnode/client": "^1.8.
|
|
59
|
+
"@abtnode/client": "^1.8.37",
|
|
60
60
|
"@arcblock/eslint-config-ts": "^0.2.3",
|
|
61
61
|
"@types/express": "^4.17.14",
|
|
62
62
|
"@types/jest": "^29.2.2",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"ts-node": "^10.9.1",
|
|
78
78
|
"typescript": "^4.8.4"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "cbb88f107eb6b403c8cd47a765920575860c7bc7"
|
|
81
81
|
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "auth",
|
|
3
|
-
"description": "Neat and easy to use user authentication and authorization service for blocklets",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"schema": {
|
|
6
|
-
"JSONSchema": {
|
|
7
|
-
"title": "Config Auth Service",
|
|
8
|
-
"description": "Customize how Auth Service works",
|
|
9
|
-
"type": "object",
|
|
10
|
-
"required": ["profileFields", "webWalletUrl"],
|
|
11
|
-
"properties": {
|
|
12
|
-
"whoCanAccess": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"title": "Who can access the blocklet?",
|
|
15
|
-
"enum": ["owner", "invited", "all"],
|
|
16
|
-
"default": "all"
|
|
17
|
-
},
|
|
18
|
-
"profileFields": {
|
|
19
|
-
"type": "array",
|
|
20
|
-
"title": "What info do you want user to provide when login?",
|
|
21
|
-
"items": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"enum": ["fullName", "email", "avatar", "phone"]
|
|
24
|
-
},
|
|
25
|
-
"default": ["fullName", "email", "avatar"],
|
|
26
|
-
"uniqueItems": true
|
|
27
|
-
},
|
|
28
|
-
"allowSwitchProfile": {
|
|
29
|
-
"type": "boolean",
|
|
30
|
-
"title": "Does you app allow user to switch profile?",
|
|
31
|
-
"default": true
|
|
32
|
-
},
|
|
33
|
-
"webWalletUrl": {
|
|
34
|
-
"type": "string",
|
|
35
|
-
"title": "The URL of your preferred web wallet instance",
|
|
36
|
-
"pattern": "^https?://",
|
|
37
|
-
"default": "https://web.abtwallet.io"
|
|
38
|
-
},
|
|
39
|
-
"ignoreUrls": {
|
|
40
|
-
"type": "array",
|
|
41
|
-
"title": "Which URLs do not need to be protected. e.g: /public/**",
|
|
42
|
-
"items": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"minLength": 1
|
|
45
|
-
},
|
|
46
|
-
"default": []
|
|
47
|
-
},
|
|
48
|
-
"blockUnauthenticated": {
|
|
49
|
-
"type": "boolean",
|
|
50
|
-
"title": "Do you want Auth Service block unauthenticated requests for you?",
|
|
51
|
-
"default": false
|
|
52
|
-
},
|
|
53
|
-
"blockUnauthorized": {
|
|
54
|
-
"type": "boolean",
|
|
55
|
-
"title": "Do you want Auth Service block unauthorized requests for you?",
|
|
56
|
-
"default": false
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"UISchema": {
|
|
61
|
-
"profileFields": {
|
|
62
|
-
"ui:widget": "checkboxes"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|