@blocklet/meta 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 (58) hide show
  1. package/lib/channel.d.ts +27 -0
  2. package/lib/channel.js +32 -32
  3. package/lib/constants.d.ts +2 -0
  4. package/lib/constants.js +6 -3
  5. package/lib/did.d.ts +10 -0
  6. package/lib/did.js +18 -24
  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 +10 -0
  12. package/lib/extension.js +78 -77
  13. package/lib/file.d.ts +21 -0
  14. package/lib/file.js +44 -39
  15. package/lib/fix.d.ts +33 -0
  16. package/lib/fix.js +218 -208
  17. package/lib/get-component-process-id.d.ts +5 -0
  18. package/lib/get-component-process-id.js +13 -14
  19. package/lib/has-reserved-key.d.ts +3 -0
  20. package/lib/has-reserved-key.js +10 -9
  21. package/lib/index.d.ts +82 -0
  22. package/lib/index.js +51 -34
  23. package/lib/info.d.ts +13 -0
  24. package/lib/info.js +58 -60
  25. package/lib/name.d.ts +5 -0
  26. package/lib/name.js +14 -7
  27. package/lib/nft-templates.d.ts +86 -0
  28. package/lib/nft-templates.js +47 -42
  29. package/lib/parse-navigation.d.ts +3 -0
  30. package/lib/parse-navigation.js +167 -228
  31. package/lib/parse.d.ts +22 -0
  32. package/lib/parse.js +71 -82
  33. package/lib/payment/index.d.ts +254 -0
  34. package/lib/payment/index.js +13 -6
  35. package/lib/payment/v1.d.ts +185 -0
  36. package/lib/payment/v1.js +80 -81
  37. package/lib/payment/v2.d.ts +242 -0
  38. package/lib/payment/v2.js +453 -531
  39. package/lib/schema.d.ts +50 -0
  40. package/lib/schema.js +405 -402
  41. package/lib/service-configs/auth.json +61 -61
  42. package/lib/service.d.ts +26 -0
  43. package/lib/service.js +69 -85
  44. package/lib/types/index.d.ts +1 -0
  45. package/lib/types/index.js +18 -0
  46. package/lib/types/schema.d.ts +241 -0
  47. package/lib/types/schema.js +3 -0
  48. package/lib/util-meta.d.ts +42 -0
  49. package/lib/util-meta.js +138 -158
  50. package/lib/util.d.ts +185 -0
  51. package/lib/util.js +359 -414
  52. package/lib/validate.d.ts +10 -0
  53. package/lib/validate.js +28 -34
  54. package/lib/verify-multi-sig.d.ts +3 -0
  55. package/lib/verify-multi-sig.js +94 -101
  56. package/lib/wallet.d.ts +9 -0
  57. package/lib/wallet.js +17 -27
  58. package/package.json +40 -18
package/lib/index.js CHANGED
@@ -1,35 +1,52 @@
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.fixService = exports.fixInterfaces = exports.fixPerson = exports.parsePerson = exports.formatPerson = exports.fixAndValidateService = exports.validateMeta = exports.parse = 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
+ const file_1 = require("./file");
29
+ Object.defineProperty(exports, "list", { enumerable: true, get: function () { return file_1.list; } });
30
+ Object.defineProperty(exports, "select", { enumerable: true, get: function () { return file_1.select; } });
31
+ Object.defineProperty(exports, "update", { enumerable: true, get: function () { return file_1.update; } });
32
+ const verify_multi_sig_1 = __importDefault(require("./verify-multi-sig"));
33
+ exports.verifyMultiSig = verify_multi_sig_1.default;
34
+ exports.default = {
35
+ constants: constants_1.default,
36
+ list: file_1.list,
37
+ select: file_1.select,
38
+ update: file_1.update,
39
+ parse: parse_1.default,
40
+ validateMeta: validate_1.validateMeta,
41
+ fixAndValidateService: validate_1.fixAndValidateService,
42
+ formatPerson: fix_1.formatPerson,
43
+ parsePerson: fix_1.parsePerson,
44
+ fixPerson: fix_1.fixPerson,
45
+ fixInterfaces: fix_1.fixInterfaces,
46
+ fixService: fix_1.fixService,
47
+ toBlockletDid: did_1.default,
48
+ getBlockletWallet: wallet_1.default,
49
+ getBlockletInfo: info_1.default,
50
+ getBlockletEngine: engine_1.default,
51
+ verifyMultiSig: verify_multi_sig_1.default,
35
52
  };
package/lib/info.d.ts ADDED
@@ -0,0 +1,13 @@
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
+ description: string;
9
+ passportColor?: string;
10
+ appUrl: string;
11
+ wallet?: WalletObject;
12
+ };
13
+ export = getBlockletInfo;
package/lib/info.js CHANGED
@@ -1,63 +1,61 @@
1
- const get = require('lodash/get');
2
- const getBlockletWallet = require('./wallet');
3
- const { getDisplayName } = require('./util');
4
-
5
- module.exports = (state, nodeSk, { returnWallet = true } = {}) => {
6
- if (!state || typeof state !== 'object' || !Array.isArray(state.environments) || !get(state, 'meta.did')) {
7
- throw new Error('Blocklet state must be an object');
8
- }
9
-
10
- const { environments, configs = [] } = state;
11
- const envs = [...configs, ...environments];
12
-
13
- const customDescription = envs.find((x) => x.key === 'BLOCKLET_APP_DESCRIPTION');
14
- const customPassportColor = envs.find((x) => x.key === 'BLOCKLET_PASSPORT_COLOR');
15
- const customAppUrl = envs.find((x) => x.key === 'BLOCKLET_APP_URL');
16
-
17
- const { did } = state.meta;
18
- const name = getDisplayName(state);
19
- const description = get(customDescription, 'value', state.meta.description);
20
- const passportColor = get(customPassportColor, 'value', 'auto');
21
- const appUrl = get(customAppUrl, 'value', '');
22
-
23
- if (!returnWallet) {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
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 } = 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
+ name,
26
+ description,
27
+ appUrl,
28
+ };
29
+ }
30
+ if (!nodeSk || typeof nodeSk !== 'string') {
31
+ throw new Error('Node secret key must be a string');
32
+ }
33
+ const customSk = envs.find((x) => x.key === 'BLOCKLET_APP_SK');
34
+ const customType = envs.find((x) => x.key === 'BLOCKLET_WALLET_TYPE');
35
+ let type;
36
+ if (customType && customType.value === 'eth') {
37
+ type = customType.value;
38
+ }
39
+ let wallet = null;
40
+ if (customSk && customSk.value && customType) {
41
+ wallet = (0, wallet_1.default)(customSk.value, null, type);
42
+ }
43
+ else if (customSk && customSk.value) {
44
+ wallet = (0, wallet_1.default)(customSk.value);
45
+ }
46
+ else if (customType) {
47
+ wallet = (0, wallet_1.default)(state.meta.did, nodeSk, type);
48
+ }
49
+ else {
50
+ wallet = (0, wallet_1.default)(state.meta.did, nodeSk);
51
+ }
24
52
  return {
25
- did,
26
- name,
27
- description,
28
- appUrl,
53
+ did,
54
+ name,
55
+ description,
56
+ passportColor,
57
+ appUrl,
58
+ wallet,
29
59
  };
30
- }
31
-
32
- if (!nodeSk || typeof nodeSk !== 'string') {
33
- throw new Error('Node secret key must be a string');
34
- }
35
-
36
- const customSk = envs.find((x) => x.key === 'BLOCKLET_APP_SK');
37
- const customType = envs.find((x) => x.key === 'BLOCKLET_WALLET_TYPE');
38
-
39
- let type;
40
- if (customType && customType.value === 'eth') {
41
- type = customType.value;
42
- }
43
-
44
- let wallet = null;
45
- if (customSk && customSk.value && customType) {
46
- wallet = getBlockletWallet(customSk.value, null, type);
47
- } else if (customSk && customSk.value) {
48
- wallet = getBlockletWallet(customSk.value);
49
- } else if (customType) {
50
- wallet = getBlockletWallet(state.meta.did, nodeSk, type);
51
- } else {
52
- wallet = getBlockletWallet(state.meta.did, nodeSk);
53
- }
54
-
55
- return {
56
- did,
57
- name,
58
- description,
59
- passportColor,
60
- appUrl,
61
- wallet,
62
- };
63
60
  };
61
+ module.exports = getBlockletInfo;
package/lib/name.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare const validateName: (name: string) => void;
2
+ declare const _default: {
3
+ validateName: (name: string) => void;
4
+ };
5
+ export default _default;
package/lib/name.js CHANGED
@@ -1,10 +1,17 @@
1
- const validate = require('validate-npm-package-name');
2
-
3
- module.exports = {
4
- validateName: (name) => {
5
- const { validForNewPackages, errors = [], warnings = [] } = validate(name);
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 = void 0;
7
+ const validate_npm_package_name_1 = __importDefault(require("validate-npm-package-name"));
8
+ const validateName = (name) => {
9
+ const { validForNewPackages, errors = [], warnings = [] } = (0, validate_npm_package_name_1.default)(name);
6
10
  if (!validForNewPackages) {
7
- throw new Error(errors[0] || warnings[0]);
11
+ throw new Error(errors[0] || warnings[0]);
8
12
  }
9
- },
13
+ };
14
+ exports.validateName = validateName;
15
+ exports.default = {
16
+ validateName: exports.validateName,
10
17
  };
@@ -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;
@@ -1,47 +1,52 @@
1
- const joinUrl = require('url-join');
2
-
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"));
3
8
  const getBlockletPurchaseTemplate = (serviceUrl = 'https://registry.arcblock.io') => ({
4
- type: 'vc',
5
- value: {
6
- '@context': 'https://schema.arcblock.io/v0.1/context.jsonld',
7
- id: '{{input.id}}',
8
- tag: ['{{data.did}}'],
9
- type: ['VerifiableCredential', 'PurchaseCredential', 'NFTCertificate', 'BlockletPurchaseCredential'],
10
- issuer: {
11
- id: '{{ctx.issuer.id}}',
12
- pk: '{{ctx.issuer.pk}}',
13
- name: '{{ctx.issuer.name}}',
14
- },
15
- issuanceDate: '{{input.issuanceDate}}', // does not expire
16
- credentialSubject: {
17
- id: '{{ctx.owner}}',
18
- sn: '{{ctx.id}}',
19
- purchased: {
20
- blocklet: {
21
- id: '{{data.did}}',
22
- url: '{{{data.url}}}',
23
- name: '{{data.name}}',
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}}',
24
46
  },
25
- },
26
- display: {
27
- type: 'url',
28
- content: joinUrl(serviceUrl, '/api/nft/display'), // accept asset-did in query param
29
- },
30
- },
31
- credentialStatus: {
32
- id: joinUrl(serviceUrl, '/api/nft/status'),
33
- type: 'NFTStatusList2021',
34
- scope: 'public',
35
- },
36
- proof: {
37
- type: '{{input.proofType}}',
38
- created: '{{input.issuanceDate}}',
39
- proofPurpose: 'assertionMethod',
40
- jws: '{{input.signature}}',
41
47
  },
42
- },
43
48
  });
44
-
45
- module.exports = {
46
- getBlockletPurchaseTemplate,
49
+ exports.getBlockletPurchaseTemplate = getBlockletPurchaseTemplate;
50
+ exports.default = {
51
+ getBlockletPurchaseTemplate,
47
52
  };
@@ -0,0 +1,3 @@
1
+ import { TNavigationItem } from './types';
2
+ declare const parseNavigation: (...args: any[]) => TNavigationItem[];
3
+ export = parseNavigation;