@blocklet/meta 1.15.17 → 1.16.0-beta-8ee536d7

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 (62) hide show
  1. package/lib/channel.d.ts +32 -0
  2. package/lib/channel.js +54 -0
  3. package/lib/constants.d.ts +2 -0
  4. package/lib/constants.js +5 -152
  5. package/lib/did.d.ts +3 -0
  6. package/lib/did.js +9 -9
  7. package/lib/engine.d.ts +7 -0
  8. package/lib/engine.js +21 -25
  9. package/lib/entry.d.ts +3 -0
  10. package/lib/entry.js +51 -64
  11. package/lib/extension.d.ts +14 -0
  12. package/lib/extension.js +82 -77
  13. package/lib/file.d.ts +23 -0
  14. package/lib/file.js +51 -36
  15. package/lib/fix.d.ts +36 -0
  16. package/lib/fix.js +231 -228
  17. package/lib/get-component-process-id.d.ts +5 -0
  18. package/lib/get-component-process-id.js +16 -0
  19. package/lib/has-reserved-key.d.ts +3 -0
  20. package/lib/has-reserved-key.js +15 -0
  21. package/lib/index.d.ts +86 -0
  22. package/lib/index.js +55 -34
  23. package/lib/info.d.ts +15 -0
  24. package/lib/info.js +70 -38
  25. package/lib/name.d.ts +15 -0
  26. package/lib/name.js +41 -8
  27. package/lib/nft-templates.d.ts +86 -0
  28. package/lib/nft-templates.js +52 -0
  29. package/lib/parse-navigation-from-blocklet.d.ts +92 -0
  30. package/lib/parse-navigation-from-blocklet.js +539 -0
  31. package/lib/parse-navigation.d.ts +3 -0
  32. package/lib/parse-navigation.js +197 -0
  33. package/lib/parse.d.ts +22 -0
  34. package/lib/parse.js +100 -89
  35. package/lib/payment/index.d.ts +254 -0
  36. package/lib/payment/index.js +14 -0
  37. package/lib/payment/v1.d.ts +185 -0
  38. package/lib/payment/v1.js +84 -0
  39. package/lib/payment/v2.d.ts +242 -0
  40. package/lib/payment/v2.js +576 -0
  41. package/lib/schema.d.ts +63 -0
  42. package/lib/schema.js +669 -283
  43. package/lib/service.d.ts +27 -0
  44. package/lib/service.js +71 -0
  45. package/lib/types/index.d.ts +1 -0
  46. package/lib/types/index.js +18 -0
  47. package/lib/types/schema.d.ts +284 -0
  48. package/lib/types/schema.js +3 -0
  49. package/lib/url-friendly.d.ts +6 -0
  50. package/lib/url-friendly.js +20 -0
  51. package/lib/util-meta.d.ts +42 -0
  52. package/lib/util-meta.js +146 -0
  53. package/lib/util.d.ts +201 -0
  54. package/lib/util.js +501 -82
  55. package/lib/validate.d.ts +13 -0
  56. package/lib/validate.js +37 -61
  57. package/lib/verify-multi-sig.d.ts +3 -0
  58. package/lib/verify-multi-sig.js +86 -59
  59. package/lib/wallet.d.ts +9 -0
  60. package/lib/wallet.js +19 -30
  61. package/package.json +59 -20
  62. package/lib/payment.js +0 -114
package/lib/index.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ /// <reference types="node" />
2
+ import constants from './constants';
3
+ import parse from './parse';
4
+ import toBlockletDid from './did';
5
+ import getBlockletWallet from './wallet';
6
+ import getBlockletInfo from './info';
7
+ import getBlockletEngine from './engine';
8
+ import { validateMeta, fixAndValidateService } from './validate';
9
+ import { formatPerson, parsePerson, fixPerson, fixInterfaces, fixService, fixName } from './fix';
10
+ import { list, select, update, read } from './file';
11
+ import verifyMultiSig from './verify-multi-sig';
12
+ export { constants };
13
+ export { list };
14
+ export { select };
15
+ export { update };
16
+ export { read };
17
+ export { parse };
18
+ export { validateMeta };
19
+ export { fixAndValidateService };
20
+ export { formatPerson };
21
+ export { parsePerson };
22
+ export { fixPerson };
23
+ export { fixInterfaces };
24
+ export { fixService };
25
+ export { fixName };
26
+ export { toBlockletDid };
27
+ export { getBlockletWallet };
28
+ export { getBlockletInfo };
29
+ export { getBlockletEngine };
30
+ export { verifyMultiSig };
31
+ declare const _default: {
32
+ constants: any;
33
+ list: any[];
34
+ select: (dir: string, { throwOnError }?: {
35
+ throwOnError?: boolean;
36
+ }) => string;
37
+ update: (file: string, meta: import("./types").TBlockletMeta, { fix }?: {
38
+ fix?: boolean;
39
+ }) => void;
40
+ read: (file: string) => unknown;
41
+ parse: (dir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, extraRawAttrs, schemaOptions, defaultStoreUrl, fix, }?: {
42
+ ensureMain?: boolean;
43
+ ensureFiles?: boolean;
44
+ ensureDist?: boolean;
45
+ ensureComponentStore?: boolean;
46
+ extraRawAttrs?: any;
47
+ schemaOptions?: any;
48
+ enableDefaults?: boolean;
49
+ extraAttrSpec?: any;
50
+ defaultStoreUrl?: string | ((component: import("./types").TComponent) => string);
51
+ fix?: boolean;
52
+ }) => import("./types").TBlockletMeta;
53
+ validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, schemaOptions, }?: {
54
+ ensureMain?: boolean;
55
+ ensureFiles?: boolean;
56
+ ensureDist?: boolean;
57
+ ensureComponentStore?: boolean;
58
+ ensureName?: boolean;
59
+ skipValidateDidName?: boolean;
60
+ schemaOptions?: any;
61
+ }) => import("./types").TBlockletMeta;
62
+ fixAndValidateService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
63
+ formatPerson: (person: string | Record<string, any>) => string;
64
+ parsePerson: (person: string) => any;
65
+ fixPerson: (data: any) => any;
66
+ fixInterfaces: (meta: any, removeMerged?: boolean) => any;
67
+ fixName: (meta: any) => any;
68
+ fixService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
69
+ toBlockletDid: (name: string | Buffer) => string;
70
+ getBlockletWallet: (blockletDid: string, nodeSk?: string, type?: string | import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
71
+ getBlockletInfo: (state: import("@abtnode/client").BlockletState, nodeSk?: string, { returnWallet }?: {
72
+ returnWallet?: boolean;
73
+ }) => {
74
+ did: string;
75
+ name: string;
76
+ version: string;
77
+ description: string;
78
+ passportColor: string;
79
+ appUrl: string;
80
+ wallet: import("@ocap/wallet").WalletObject<string>;
81
+ permanentWallet: import("@ocap/wallet").WalletObject<string>;
82
+ };
83
+ getBlockletEngine: (meta: import("./types").TBlockletMeta) => import("./types").TEngine;
84
+ verifyMultiSig: (blockletMeta: import("./types").TBlockletMeta) => boolean;
85
+ };
86
+ export default _default;
package/lib/index.js CHANGED
@@ -1,35 +1,56 @@
1
- const constants = require('./constants');
2
- const parse = require('./parse');
3
- const toBlockletDid = require('./did');
4
- const getBlockletWallet = require('./wallet');
5
- const getBlockletInfo = require('./info');
6
- const getBlockletEngine = require('./engine');
7
- const { validateMeta, fixAndValidateService } = require('./validate');
8
- const { formatPerson, parsePerson, fixPerson, fixInterfaces, fixService } = require('./fix');
9
- const { list, select, update } = require('./file');
10
- const verifyMultiSig = require('./verify-multi-sig');
11
-
12
- module.exports = {
13
- constants,
14
-
15
- list,
16
- select,
17
- update,
18
-
19
- parse,
20
- validateMeta,
21
- fixAndValidateService,
22
-
23
- formatPerson,
24
- parsePerson,
25
- fixPerson,
26
- fixInterfaces,
27
- fixService,
28
-
29
- toBlockletDid,
30
- getBlockletWallet,
31
- getBlockletInfo,
32
- getBlockletEngine,
33
-
34
- verifyMultiSig,
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.verifyMultiSig = exports.getBlockletEngine = exports.getBlockletInfo = exports.getBlockletWallet = exports.toBlockletDid = exports.fixName = exports.fixService = exports.fixInterfaces = exports.fixPerson = exports.parsePerson = exports.formatPerson = exports.fixAndValidateService = exports.validateMeta = exports.parse = exports.read = exports.update = exports.select = exports.list = exports.constants = void 0;
7
+ const constants_1 = __importDefault(require("./constants"));
8
+ exports.constants = constants_1.default;
9
+ const parse_1 = __importDefault(require("./parse"));
10
+ exports.parse = parse_1.default;
11
+ const did_1 = __importDefault(require("./did"));
12
+ exports.toBlockletDid = did_1.default;
13
+ const wallet_1 = __importDefault(require("./wallet"));
14
+ exports.getBlockletWallet = wallet_1.default;
15
+ const info_1 = __importDefault(require("./info"));
16
+ exports.getBlockletInfo = info_1.default;
17
+ const engine_1 = __importDefault(require("./engine"));
18
+ exports.getBlockletEngine = engine_1.default;
19
+ const validate_1 = require("./validate");
20
+ Object.defineProperty(exports, "validateMeta", { enumerable: true, get: function () { return validate_1.validateMeta; } });
21
+ Object.defineProperty(exports, "fixAndValidateService", { enumerable: true, get: function () { return validate_1.fixAndValidateService; } });
22
+ const fix_1 = require("./fix");
23
+ Object.defineProperty(exports, "formatPerson", { enumerable: true, get: function () { return fix_1.formatPerson; } });
24
+ Object.defineProperty(exports, "parsePerson", { enumerable: true, get: function () { return fix_1.parsePerson; } });
25
+ Object.defineProperty(exports, "fixPerson", { enumerable: true, get: function () { return fix_1.fixPerson; } });
26
+ Object.defineProperty(exports, "fixInterfaces", { enumerable: true, get: function () { return fix_1.fixInterfaces; } });
27
+ Object.defineProperty(exports, "fixService", { enumerable: true, get: function () { return fix_1.fixService; } });
28
+ Object.defineProperty(exports, "fixName", { enumerable: true, get: function () { return fix_1.fixName; } });
29
+ const file_1 = require("./file");
30
+ Object.defineProperty(exports, "list", { enumerable: true, get: function () { return file_1.list; } });
31
+ Object.defineProperty(exports, "select", { enumerable: true, get: function () { return file_1.select; } });
32
+ Object.defineProperty(exports, "update", { enumerable: true, get: function () { return file_1.update; } });
33
+ Object.defineProperty(exports, "read", { enumerable: true, get: function () { return file_1.read; } });
34
+ const verify_multi_sig_1 = __importDefault(require("./verify-multi-sig"));
35
+ exports.verifyMultiSig = verify_multi_sig_1.default;
36
+ exports.default = {
37
+ constants: constants_1.default,
38
+ list: file_1.list,
39
+ select: file_1.select,
40
+ update: file_1.update,
41
+ read: file_1.read,
42
+ parse: parse_1.default,
43
+ validateMeta: validate_1.validateMeta,
44
+ fixAndValidateService: validate_1.fixAndValidateService,
45
+ formatPerson: fix_1.formatPerson,
46
+ parsePerson: fix_1.parsePerson,
47
+ fixPerson: fix_1.fixPerson,
48
+ fixInterfaces: fix_1.fixInterfaces,
49
+ fixName: fix_1.fixName,
50
+ fixService: fix_1.fixService,
51
+ toBlockletDid: did_1.default,
52
+ getBlockletWallet: wallet_1.default,
53
+ getBlockletInfo: info_1.default,
54
+ getBlockletEngine: engine_1.default,
55
+ verifyMultiSig: verify_multi_sig_1.default,
35
56
  };
package/lib/info.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { WalletObject } from '@ocap/wallet';
2
+ import { BlockletState } from '@abtnode/client';
3
+ declare const getBlockletInfo: (state: BlockletState, nodeSk?: string, { returnWallet }?: {
4
+ returnWallet?: boolean;
5
+ }) => {
6
+ did: string;
7
+ name: string;
8
+ version: string;
9
+ description: string;
10
+ passportColor: string;
11
+ appUrl: string;
12
+ wallet: WalletObject;
13
+ permanentWallet: WalletObject;
14
+ };
15
+ export = getBlockletInfo;
package/lib/info.js CHANGED
@@ -1,39 +1,71 @@
1
- const get = require('lodash/get');
2
- const getBlockletWallet = require('./wallet');
3
-
4
- module.exports = (state, nodeSk) => {
5
- if (!state || typeof state !== 'object' || !Array.isArray(state.environments) || !get(state, 'meta.did')) {
6
- throw new Error('Blocklet state must be an object');
7
- }
8
- if (!nodeSk || typeof nodeSk !== 'string') {
9
- throw new Error('Node secret key must be a string');
10
- }
11
-
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
- const customSk = state.environments.find((x) => x.key === 'BLOCKLET_APP_SK');
15
- const customType = state.environments.find((x) => x.key === 'BLOCKLET_WALLET_TYPE');
16
-
17
- let type;
18
- if (customType && customType.value === 'eth') {
19
- type = customType.value;
20
- }
21
-
22
- let wallet = null;
23
- if (customSk && customSk.value && customType) {
24
- wallet = getBlockletWallet(customSk.value, null, type);
25
- } else if (customSk && customSk.value) {
26
- wallet = getBlockletWallet(customSk.value);
27
- } else if (customType) {
28
- wallet = getBlockletWallet(state.meta.did, nodeSk, type);
29
- } else {
30
- wallet = getBlockletWallet(state.meta.did, nodeSk);
31
- }
32
-
33
- 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),
37
- wallet,
38
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
4
  };
5
+ const get_1 = __importDefault(require("lodash/get"));
6
+ const wallet_1 = __importDefault(require("./wallet"));
7
+ const util_1 = require("./util");
8
+ const getBlockletInfo = (state, nodeSk, { returnWallet = true } = {}) => {
9
+ if (!state || typeof state !== 'object' || !Array.isArray(state.environments) || !(0, get_1.default)(state, 'meta.did')) {
10
+ throw new Error('Blocklet state must be an object');
11
+ }
12
+ const { environments, configs = [] } = state;
13
+ const envs = [...configs, ...environments];
14
+ const customDescription = envs.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
15
+ const customPassportColor = envs.find((x) => x.key === 'BLOCKLET_PASSPORT_COLOR');
16
+ const customAppUrl = envs.find((x) => x.key === 'BLOCKLET_APP_URL');
17
+ const { did, version } = state.meta;
18
+ const name = (0, util_1.getDisplayName)(state);
19
+ const description = (0, get_1.default)(customDescription, 'value', state.meta.description);
20
+ const passportColor = (0, get_1.default)(customPassportColor, 'value', 'auto');
21
+ const appUrl = (0, get_1.default)(customAppUrl, 'value', '');
22
+ if (!returnWallet) {
23
+ return {
24
+ did,
25
+ version,
26
+ name,
27
+ description,
28
+ passportColor,
29
+ appUrl,
30
+ wallet: null,
31
+ permanentWallet: null,
32
+ };
33
+ }
34
+ const customSk = envs.find((x) => x.key === 'BLOCKLET_APP_SK');
35
+ const customType = envs.find((x) => x.key === 'BLOCKLET_WALLET_TYPE');
36
+ const permanentSk = envs.find((x) => x.key === 'BLOCKLET_APP_PSK');
37
+ let type;
38
+ if (customType && customType.value === 'eth') {
39
+ type = customType.value;
40
+ }
41
+ let wallet = null;
42
+ let permanentWallet = null;
43
+ if (customSk && customSk.value) {
44
+ wallet = (0, wallet_1.default)(customSk.value, undefined, type);
45
+ if (permanentSk && permanentSk.value && permanentSk.value !== customSk.value) {
46
+ permanentWallet = (0, wallet_1.default)(permanentSk.value, undefined, type);
47
+ }
48
+ }
49
+ else {
50
+ if (!nodeSk || typeof nodeSk !== 'string') {
51
+ throw new Error('Node secret key must be a string');
52
+ }
53
+ if (customType) {
54
+ wallet = (0, wallet_1.default)(state.meta.did, nodeSk, type);
55
+ }
56
+ else {
57
+ wallet = (0, wallet_1.default)(state.meta.did, nodeSk);
58
+ }
59
+ }
60
+ return {
61
+ did,
62
+ version,
63
+ name,
64
+ description,
65
+ passportColor,
66
+ appUrl,
67
+ wallet,
68
+ permanentWallet: permanentWallet || wallet,
69
+ };
70
+ };
71
+ module.exports = getBlockletInfo;
package/lib/name.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 检查一个 did 是否为新版 blocklet-did(这里只需要判断是否为 ROLE_BLOCKLET 即可)
3
+ * @param did 需要检查是否为新版 did 的值
4
+ */
5
+ export declare const validateNewDid: (did: string) => void;
6
+ export declare const validateName: (name: string, { checkDid }?: {
7
+ checkDid?: boolean;
8
+ }) => void;
9
+ declare const _default: {
10
+ validateName: (name: string, { checkDid }?: {
11
+ checkDid?: boolean;
12
+ }) => void;
13
+ validateNewDid: (did: string) => void;
14
+ };
15
+ export default _default;
package/lib/name.js CHANGED
@@ -1,10 +1,43 @@
1
- const validate = require('validate-npm-package-name');
2
-
3
- module.exports = {
4
- validateName: (name) => {
5
- const { validForNewPackages, errors = [], warnings = [] } = validate(name);
6
- if (!validForNewPackages) {
7
- throw new Error(errors[0] || warnings[0]);
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateName = exports.validateNewDid = void 0;
7
+ const did_1 = require("@arcblock/did");
8
+ const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
9
+ const MAX_NAME_LENGTH = 32;
10
+ /**
11
+ * 检查一个 did 是否为新版 blocklet-did(这里只需要判断是否为 ROLE_BLOCKLET 即可)
12
+ * @param did 需要检查是否为新版 did 的值
13
+ */
14
+ const validateNewDid = (did) => {
15
+ const typeInfo = (0, did_1.toTypeInfo)(did);
16
+ if (typeInfo.role !== did_1.types.RoleType.ROLE_BLOCKLET) {
17
+ throw new Error("Blocklet DID's type must be ROLE_BLOCKLET");
18
+ }
19
+ };
20
+ exports.validateNewDid = validateNewDid;
21
+ const validateName = (name, { checkDid = true } = {}) => {
22
+ if ((0, did_1.isValid)(name)) {
23
+ // new did mode
24
+ if (checkDid) {
25
+ (0, exports.validateNewDid)(name);
26
+ }
8
27
  }
9
- },
28
+ else {
29
+ // old did mode
30
+ const { validForNewPackages, errors = [], warnings = [] } = (0, validate_npm_package_name_1.default)(name);
31
+ if (!validForNewPackages) {
32
+ throw new Error(errors[0] || warnings[0]);
33
+ }
34
+ if (name.length > MAX_NAME_LENGTH) {
35
+ throw new Error('Blocklet name is too long');
36
+ }
37
+ }
38
+ };
39
+ exports.validateName = validateName;
40
+ exports.default = {
41
+ validateName: exports.validateName,
42
+ validateNewDid: exports.validateNewDid,
10
43
  };
@@ -0,0 +1,86 @@
1
+ declare const getBlockletPurchaseTemplate: (serviceUrl?: string) => {
2
+ type: string;
3
+ value: {
4
+ '@context': string;
5
+ id: string;
6
+ tag: string[];
7
+ type: string[];
8
+ issuer: {
9
+ id: string;
10
+ pk: string;
11
+ name: string;
12
+ };
13
+ issuanceDate: string;
14
+ credentialSubject: {
15
+ id: string;
16
+ sn: string;
17
+ purchased: {
18
+ blocklet: {
19
+ id: string;
20
+ url: string;
21
+ name: string;
22
+ };
23
+ };
24
+ display: {
25
+ type: string;
26
+ content: string;
27
+ };
28
+ };
29
+ credentialStatus: {
30
+ id: string;
31
+ type: string;
32
+ scope: string;
33
+ };
34
+ proof: {
35
+ type: string;
36
+ created: string;
37
+ proofPurpose: string;
38
+ jws: string;
39
+ };
40
+ };
41
+ };
42
+ export { getBlockletPurchaseTemplate };
43
+ declare const _default: {
44
+ getBlockletPurchaseTemplate: (serviceUrl?: string) => {
45
+ type: string;
46
+ value: {
47
+ '@context': string;
48
+ id: string;
49
+ tag: string[];
50
+ type: string[];
51
+ issuer: {
52
+ id: string;
53
+ pk: string;
54
+ name: string;
55
+ };
56
+ issuanceDate: string;
57
+ credentialSubject: {
58
+ id: string;
59
+ sn: string;
60
+ purchased: {
61
+ blocklet: {
62
+ id: string;
63
+ url: string;
64
+ name: string;
65
+ };
66
+ };
67
+ display: {
68
+ type: string;
69
+ content: string;
70
+ };
71
+ };
72
+ credentialStatus: {
73
+ id: string;
74
+ type: string;
75
+ scope: string;
76
+ };
77
+ proof: {
78
+ type: string;
79
+ created: string;
80
+ proofPurpose: string;
81
+ jws: string;
82
+ };
83
+ };
84
+ };
85
+ };
86
+ export default _default;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getBlockletPurchaseTemplate = void 0;
7
+ const url_join_1 = __importDefault(require("url-join"));
8
+ const getBlockletPurchaseTemplate = (serviceUrl = 'https://registry.arcblock.io') => ({
9
+ type: 'vc',
10
+ value: {
11
+ '@context': 'https://schema.arcblock.io/v0.1/context.jsonld',
12
+ id: '{{input.id}}',
13
+ tag: ['{{data.did}}'],
14
+ type: ['VerifiableCredential', 'PurchaseCredential', 'NFTCertificate', 'BlockletPurchaseCredential'],
15
+ issuer: {
16
+ id: '{{ctx.issuer.id}}',
17
+ pk: '{{ctx.issuer.pk}}',
18
+ name: '{{ctx.issuer.name}}',
19
+ },
20
+ issuanceDate: '{{input.issuanceDate}}',
21
+ credentialSubject: {
22
+ id: '{{ctx.owner}}',
23
+ sn: '{{ctx.id}}',
24
+ purchased: {
25
+ blocklet: {
26
+ id: '{{data.did}}',
27
+ url: '{{{data.url}}}',
28
+ name: '{{data.name}}',
29
+ },
30
+ },
31
+ display: {
32
+ type: 'url',
33
+ content: (0, url_join_1.default)(serviceUrl, '/api/nft/display'), // accept asset-did in query param
34
+ },
35
+ },
36
+ credentialStatus: {
37
+ id: (0, url_join_1.default)(serviceUrl, '/api/nft/status'),
38
+ type: 'NFTStatusList2021',
39
+ scope: 'public',
40
+ },
41
+ proof: {
42
+ type: '{{input.proofType}}',
43
+ created: '{{input.issuanceDate}}',
44
+ proofPurpose: 'assertionMethod',
45
+ jws: '{{input.signature}}',
46
+ },
47
+ },
48
+ });
49
+ exports.getBlockletPurchaseTemplate = getBlockletPurchaseTemplate;
50
+ exports.default = {
51
+ getBlockletPurchaseTemplate,
52
+ };
@@ -0,0 +1,92 @@
1
+ declare const checkLink: (value: string) => boolean;
2
+ interface DeepWalkCallback {
3
+ (current: any, parent: any, options: DeepWalkCallbackOptions): void;
4
+ }
5
+ interface DeepWalkCallbackOptions {
6
+ index: number;
7
+ level: number;
8
+ }
9
+ /**
10
+ *
11
+ * @param {object} tree 需要深度遍历的数状结构
12
+ * @param {function} cb 每一个节点的回调函数,回调的参数:当前节点数据,父亲节点数据,{index:当前节点所属的数组中的序号,level: 当前节点所处的深度}
13
+ * @param {object} param 深度遍历的参数
14
+ * @param {string} param.key 孩子数组的 key 值
15
+ * @param {number} param.index 当前节点所属的数组中的序号
16
+ * @param {object} param.parent 当前节点的父节点
17
+ * @param {number} param.level 当前节点的深度
18
+ */
19
+ type TreeNode<K extends string> = Record<string, any> & {
20
+ [key in K]?: TreeNode<K>[];
21
+ };
22
+ declare function deepWalk<K extends string>(tree: TreeNode<K>, cb: DeepWalkCallback, { key, order }: {
23
+ key: K;
24
+ order?: 'first' | 'last';
25
+ }): void;
26
+ declare function deepWalk(tree: TreeNode<'children'>, cb: DeepWalkCallback, { key, order }?: {
27
+ key?: 'children';
28
+ order?: 'first' | 'last';
29
+ }): void;
30
+ /**
31
+ * 判断一个传入值是否属于一个 section
32
+ * @param {string | array} sections 需要判断的对象
33
+ * @param {string} section 目标 section
34
+ */
35
+ declare function isMatchSection(sections: string[] | string, section: string): boolean;
36
+ interface NavigationItem {
37
+ id: string;
38
+ role?: string;
39
+ section?: string;
40
+ title?: string;
41
+ link?: string;
42
+ items?: NavigationItem[];
43
+ component?: string;
44
+ child?: string;
45
+ [key: string]: any;
46
+ }
47
+ interface ComponentItem {
48
+ name: string;
49
+ link: string;
50
+ }
51
+ declare function joinLink(navigation: NavigationItem, components: ComponentItem[]): NavigationItem;
52
+ interface FlatternNavigationOption {
53
+ transform?: (current: any, parent?: any) => any;
54
+ depth?: number;
55
+ }
56
+ /**
57
+ * 将树状结构的导航列表进行扁平化处理
58
+ * @param {array} navigationList 树状结构的导航列表
59
+ * @param {object} params 配置参数
60
+ * @param {number} params.depth 扁平化的层级,默认为 1(全拍平)
61
+ * @param {function} params.transform 当发生拍平处理时
62
+ * @returns 扁平化后的导航列表
63
+ */
64
+ declare function flatternNavigation(list?: NavigationItem[], { depth, transform }?: FlatternNavigationOption): any[];
65
+ /**
66
+ * 根据导航中每一个子菜单所属的 section,将原由的导航数据分离为多个导航数据(此时每一个导航 item 只会包含一个 section)
67
+ * @param {array} navigation 导航列表数据(树状结构,目前只适用于两层的树状结构)
68
+ * @returns
69
+ */
70
+ declare function splitNavigationBySection(navigation: NavigationItem[]): any[];
71
+ /**
72
+ * 将导航数据进行层叠处理
73
+ * @param {array} list 扁平化的导航数据
74
+ * @returns 处理后的导航
75
+ */
76
+ declare function nestNavigationList(list?: any[]): any[];
77
+ declare function filterNavigation(navigationList: NavigationItem[], components?: ComponentItem[]): any[];
78
+ declare function cleanOrphanNavigation(list: NavigationItem[]): NavigationItem[];
79
+ interface Blocklet {
80
+ settings?: {
81
+ navigations?: NavigationItem[];
82
+ };
83
+ }
84
+ interface ParseNavigationOption {
85
+ beforeProcess?: (data: any) => any;
86
+ }
87
+ declare function parseNavigation(blocklet?: Blocklet, options?: ParseNavigationOption): {
88
+ navigationList: any[];
89
+ components: any[];
90
+ builtinList: any[];
91
+ };
92
+ export { parseNavigation, deepWalk, isMatchSection, nestNavigationList, filterNavigation, cleanOrphanNavigation, joinLink, checkLink, flatternNavigation, splitNavigationBySection, };