@blocklet/did-space-js 0.5.58

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 (160) hide show
  1. package/README.md +77 -0
  2. package/dist/client/index.d.ts +40 -0
  3. package/dist/client/index.js +110 -0
  4. package/dist/commands/backup/backup-blocklet.d.ts +14 -0
  5. package/dist/commands/backup/backup-blocklet.js +83 -0
  6. package/dist/commands/backup/index.d.ts +3 -0
  7. package/dist/commands/backup/index.js +19 -0
  8. package/dist/commands/backup/post-app-backup.d.ts +9 -0
  9. package/dist/commands/backup/post-app-backup.js +49 -0
  10. package/dist/commands/backup/put-app-backup.d.ts +9 -0
  11. package/dist/commands/backup/put-app-backup.js +49 -0
  12. package/dist/commands/base.d.ts +21 -0
  13. package/dist/commands/base.js +47 -0
  14. package/dist/commands/incremental-backup/backup-blocklet.d.ts +14 -0
  15. package/dist/commands/incremental-backup/backup-blocklet.js +90 -0
  16. package/dist/commands/incremental-backup/index.d.ts +1 -0
  17. package/dist/commands/incremental-backup/index.js +17 -0
  18. package/dist/commands/incremental-sync/index.d.ts +2 -0
  19. package/dist/commands/incremental-sync/index.js +18 -0
  20. package/dist/commands/incremental-sync/sync-base.d.ts +76 -0
  21. package/dist/commands/incremental-sync/sync-base.js +236 -0
  22. package/dist/commands/incremental-sync/sync-push.d.ts +30 -0
  23. package/dist/commands/incremental-sync/sync-push.js +202 -0
  24. package/dist/commands/index.d.ts +9 -0
  25. package/dist/commands/index.js +25 -0
  26. package/dist/commands/nft/index.d.ts +1 -0
  27. package/dist/commands/nft/index.js +17 -0
  28. package/dist/commands/nft/put-nft-object.d.ts +20 -0
  29. package/dist/commands/nft/put-nft-object.js +143 -0
  30. package/dist/commands/object/delete-object.d.ts +7 -0
  31. package/dist/commands/object/delete-object.js +38 -0
  32. package/dist/commands/object/get-object.d.ts +7 -0
  33. package/dist/commands/object/get-object.js +43 -0
  34. package/dist/commands/object/index.d.ts +5 -0
  35. package/dist/commands/object/index.js +21 -0
  36. package/dist/commands/object/list-object.d.ts +7 -0
  37. package/dist/commands/object/list-object.js +31 -0
  38. package/dist/commands/object/list-objects.d.ts +7 -0
  39. package/dist/commands/object/list-objects.js +44 -0
  40. package/dist/commands/object/put-object.d.ts +7 -0
  41. package/dist/commands/object/put-object.js +61 -0
  42. package/dist/commands/restore/index.d.ts +3 -0
  43. package/dist/commands/restore/index.js +19 -0
  44. package/dist/commands/restore/post-app-restore.d.ts +7 -0
  45. package/dist/commands/restore/post-app-restore.js +45 -0
  46. package/dist/commands/restore/put-app-restore.d.ts +9 -0
  47. package/dist/commands/restore/put-app-restore.js +49 -0
  48. package/dist/commands/restore/restore-blocklet.d.ts +14 -0
  49. package/dist/commands/restore/restore-blocklet.js +80 -0
  50. package/dist/commands/space/head.d.ts +8 -0
  51. package/dist/commands/space/head.js +52 -0
  52. package/dist/commands/space/index.d.ts +1 -0
  53. package/dist/commands/space/index.js +17 -0
  54. package/dist/commands/sync/index.d.ts +3 -0
  55. package/dist/commands/sync/index.js +19 -0
  56. package/dist/commands/sync/sync-folder-base.d.ts +105 -0
  57. package/dist/commands/sync/sync-folder-base.js +319 -0
  58. package/dist/commands/sync/sync-folder-pull.d.ts +13 -0
  59. package/dist/commands/sync/sync-folder-pull.js +151 -0
  60. package/dist/commands/sync/sync-folder-push.d.ts +20 -0
  61. package/dist/commands/sync/sync-folder-push.js +166 -0
  62. package/dist/did-document/did-document.d.ts +29 -0
  63. package/dist/did-document/did-document.js +2 -0
  64. package/dist/did-document/index.d.ts +3 -0
  65. package/dist/did-document/index.js +19 -0
  66. package/dist/did-document/sign-document.d.ts +3 -0
  67. package/dist/did-document/sign-document.js +13 -0
  68. package/dist/did-document/verify-document.d.ts +10 -0
  69. package/dist/did-document/verify-document.js +35 -0
  70. package/dist/index.d.ts +7 -0
  71. package/dist/index.js +23 -0
  72. package/dist/libs/api.d.ts +3 -0
  73. package/dist/libs/api.js +65 -0
  74. package/dist/libs/did.d.ts +9 -0
  75. package/dist/libs/did.js +34 -0
  76. package/dist/libs/encoding.d.ts +7 -0
  77. package/dist/libs/encoding.js +17 -0
  78. package/dist/libs/error.d.ts +4 -0
  79. package/dist/libs/error.js +27 -0
  80. package/dist/libs/hash.d.ts +1 -0
  81. package/dist/libs/hash.js +5 -0
  82. package/dist/libs/index.d.ts +11 -0
  83. package/dist/libs/index.js +27 -0
  84. package/dist/libs/logger.d.ts +2 -0
  85. package/dist/libs/logger.js +12 -0
  86. package/dist/libs/object-integrality.d.ts +1 -0
  87. package/dist/libs/object-integrality.js +13 -0
  88. package/dist/libs/performance.d.ts +7 -0
  89. package/dist/libs/performance.js +13 -0
  90. package/dist/libs/sleep.d.ts +1 -0
  91. package/dist/libs/sleep.js +9 -0
  92. package/dist/libs/space.d.ts +16 -0
  93. package/dist/libs/space.js +56 -0
  94. package/dist/libs/stream.d.ts +3 -0
  95. package/dist/libs/stream.js +10 -0
  96. package/dist/meta/backup/backup-blocklet-command.d.ts +50 -0
  97. package/dist/meta/backup/backup-blocklet-command.js +2 -0
  98. package/dist/meta/backup/index.d.ts +3 -0
  99. package/dist/meta/backup/index.js +19 -0
  100. package/dist/meta/backup/post-app-backup-command.d.ts +8 -0
  101. package/dist/meta/backup/post-app-backup-command.js +16 -0
  102. package/dist/meta/backup/put-app-backup-command.d.ts +7 -0
  103. package/dist/meta/backup/put-app-backup-command.js +18 -0
  104. package/dist/meta/incremental-backup/backup-blocklet-command.d.ts +50 -0
  105. package/dist/meta/incremental-backup/backup-blocklet-command.js +2 -0
  106. package/dist/meta/incremental-backup/index.d.ts +1 -0
  107. package/dist/meta/incremental-backup/index.js +17 -0
  108. package/dist/meta/index.d.ts +7 -0
  109. package/dist/meta/index.js +23 -0
  110. package/dist/meta/nft/index.d.ts +1 -0
  111. package/dist/meta/nft/index.js +17 -0
  112. package/dist/meta/nft/put-nft-object-command.d.ts +51 -0
  113. package/dist/meta/nft/put-nft-object-command.js +2 -0
  114. package/dist/meta/object/delete-object-command.d.ts +6 -0
  115. package/dist/meta/object/delete-object-command.js +2 -0
  116. package/dist/meta/object/get-object-command.d.ts +10 -0
  117. package/dist/meta/object/get-object-command.js +2 -0
  118. package/dist/meta/object/head-object-command.d.ts +13 -0
  119. package/dist/meta/object/head-object-command.js +2 -0
  120. package/dist/meta/object/index.d.ts +5 -0
  121. package/dist/meta/object/index.js +21 -0
  122. package/dist/meta/object/list-object-command.d.ts +6 -0
  123. package/dist/meta/object/list-object-command.js +2 -0
  124. package/dist/meta/object/list-objects-command.d.ts +8 -0
  125. package/dist/meta/object/list-objects-command.js +2 -0
  126. package/dist/meta/object/put-object-command.d.ts +29 -0
  127. package/dist/meta/object/put-object-command.js +2 -0
  128. package/dist/meta/restore/index.d.ts +3 -0
  129. package/dist/meta/restore/index.js +19 -0
  130. package/dist/meta/restore/post-app-restore-command.d.ts +8 -0
  131. package/dist/meta/restore/post-app-restore-command.js +13 -0
  132. package/dist/meta/restore/put-app-restore-command.d.ts +7 -0
  133. package/dist/meta/restore/put-app-restore-command.js +18 -0
  134. package/dist/meta/restore/restore-blocklet-command.d.ts +28 -0
  135. package/dist/meta/restore/restore-blocklet-command.js +2 -0
  136. package/dist/meta/spaces-client-options.d.ts +5 -0
  137. package/dist/meta/spaces-client-options.js +2 -0
  138. package/dist/meta/sync/incremental-sync-base-command.d.ts +7 -0
  139. package/dist/meta/sync/incremental-sync-base-command.js +2 -0
  140. package/dist/meta/sync/incremental-sync-push-command.d.ts +8 -0
  141. package/dist/meta/sync/incremental-sync-push-command.js +2 -0
  142. package/dist/meta/sync/index.d.ts +6 -0
  143. package/dist/meta/sync/index.js +22 -0
  144. package/dist/meta/sync/sync-base-command.d.ts +121 -0
  145. package/dist/meta/sync/sync-base-command.js +2 -0
  146. package/dist/meta/sync/sync-folder-base-command.d.ts +12 -0
  147. package/dist/meta/sync/sync-folder-base-command.js +2 -0
  148. package/dist/meta/sync/sync-folder-pull-command.d.ts +5 -0
  149. package/dist/meta/sync/sync-folder-pull-command.js +2 -0
  150. package/dist/meta/sync/sync-folder-push-command.d.ts +7 -0
  151. package/dist/meta/sync/sync-folder-push-command.js +2 -0
  152. package/dist/protocol/command.protocol.d.ts +68 -0
  153. package/dist/protocol/command.protocol.js +2 -0
  154. package/dist/protocol/index.d.ts +1 -0
  155. package/dist/protocol/index.js +17 -0
  156. package/dist/security/index.d.ts +1 -0
  157. package/dist/security/index.js +17 -0
  158. package/dist/security/request-signature.d.ts +32 -0
  159. package/dist/security/request-signature.js +140 -0
  160. package/package.json +78 -0
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getErrorStatusCode = exports.getErrorMessage = void 0;
4
+ const axios_1 = require("axios");
5
+ const got_1 = require("got");
6
+ // @FIXME: @jianchao 使用 got.js 替换掉 axios.js,axios 太不稳定了
7
+ function getErrorMessage(error) {
8
+ if (error instanceof got_1.RequestError) {
9
+ if (typeof error?.response?.body === 'string') {
10
+ return error?.response?.body;
11
+ }
12
+ }
13
+ if (error instanceof axios_1.AxiosError) {
14
+ if (typeof error?.response?.data === 'string') {
15
+ return error?.response?.data;
16
+ }
17
+ }
18
+ return error.message;
19
+ }
20
+ exports.getErrorMessage = getErrorMessage;
21
+ function getErrorStatusCode(error) {
22
+ if (error instanceof axios_1.AxiosError) {
23
+ return error?.response?.status;
24
+ }
25
+ return error?.response?.statusCode;
26
+ }
27
+ exports.getErrorStatusCode = getErrorStatusCode;
@@ -0,0 +1 @@
1
+ export { getHash } from '@did-space/core';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHash = void 0;
4
+ var core_1 = require("@did-space/core");
5
+ Object.defineProperty(exports, "getHash", { enumerable: true, get: function () { return core_1.getHash; } });
@@ -0,0 +1,11 @@
1
+ export * from './api';
2
+ export * from './did';
3
+ export * from './encoding';
4
+ export * from './error';
5
+ export * from './hash';
6
+ export * from './logger';
7
+ export * from './object-integrality';
8
+ export * from './performance';
9
+ export * from './space';
10
+ export * from './stream';
11
+ export * from './sleep';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api"), exports);
18
+ __exportStar(require("./did"), exports);
19
+ __exportStar(require("./encoding"), exports);
20
+ __exportStar(require("./error"), exports);
21
+ __exportStar(require("./hash"), exports);
22
+ __exportStar(require("./logger"), exports);
23
+ __exportStar(require("./object-integrality"), exports);
24
+ __exportStar(require("./performance"), exports);
25
+ __exportStar(require("./space"), exports);
26
+ __exportStar(require("./stream"), exports);
27
+ __exportStar(require("./sleep"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const logger: Console;
2
+ export declare const now: () => string;
@@ -0,0 +1,12 @@
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.now = exports.logger = void 0;
7
+ // @see: https://www.npmjs.com/package/@blocklet/logger
8
+ const dayjs_1 = __importDefault(require("dayjs"));
9
+ // 先为接入 @blocklet/logger 做准备,目前会报错: Error: valid BLOCKLET_LOG_DIR env is required by logger
10
+ exports.logger = console;
11
+ const now = () => (0, dayjs_1.default)().format('YYYY-MM-DD HH:mm:ss');
12
+ exports.now = now;
@@ -0,0 +1 @@
1
+ export declare function verifyObjectHash(key: string, hash: string): Promise<void>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyObjectHash = void 0;
4
+ const core_1 = require("@did-space/core");
5
+ const fs_extra_1 = require("fs-extra");
6
+ async function verifyObjectHash(key, hash) {
7
+ const realHash = await (0, core_1.getHash)((0, fs_extra_1.createReadStream)(key));
8
+ if (realHash !== hash) {
9
+ (0, fs_extra_1.removeSync)(key);
10
+ throw new Error(`Object(${key}) hash(${realHash}) does not match ${hash}`);
11
+ }
12
+ }
13
+ exports.verifyObjectHash = verifyObjectHash;
@@ -0,0 +1,7 @@
1
+ export declare function formatMemoryUsage(): {
2
+ rss: string;
3
+ heapTotal: string;
4
+ heapUsed: string;
5
+ external: string;
6
+ arrayBuffers: string;
7
+ };
@@ -0,0 +1,13 @@
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.formatMemoryUsage = void 0;
7
+ const mapValues_1 = __importDefault(require("lodash/mapValues"));
8
+ const xbytes_1 = __importDefault(require("xbytes"));
9
+ function formatMemoryUsage() {
10
+ const memoryUsage = process.memoryUsage();
11
+ return (0, mapValues_1.default)(memoryUsage, (x) => (0, xbytes_1.default)(x));
12
+ }
13
+ exports.formatMemoryUsage = formatMemoryUsage;
@@ -0,0 +1 @@
1
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = void 0;
4
+ function sleep(ms) {
5
+ return new Promise((resolve) => {
6
+ setTimeout(resolve, ms);
7
+ });
8
+ }
9
+ exports.sleep = sleep;
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ *
4
+ * @private
5
+ * @param {string} endpoint => https://73aa3e87-znkjt5vbgnezh4p6v4dsaye61e7pxxn3vk4j.did.abtnet.io/app/api/space/z3T6WZD3dBtaVUgwb3rtBey8BartrJDTLrmQr/app/zNKsSUmUVJntiVdAPpg8vYtEgnFvSppYLf4F/object/
6
+ * @return {*} {string} https://73aa3e87-znkjt5vbgnezh4p6v4dsaye61e7pxxn3vk4j.did.abtnet.io/app/api/space/z3T6WZD3dBtaVUgwb3rtBey8BartrJDTLrmQr/app/zNKsSUmUVJntiVdAPpg8vYtEgnFvSppYLf4F/
7
+ */
8
+ export declare function normalizeEndpoint(endpoint: string): string;
9
+ /**
10
+ * @description
11
+ * @export
12
+ * @param {string} normalizedEndpoint https://73aa3e87-znkjt5vbgnezh4p6v4dsaye61e7pxxn3vk4j.did.abtnet.io/app/api/space/z3T6WZD3dBtaVUgwb3rtBey8BartrJDTLrmQr/app/zNKsSUmUVJntiVdAPpg8vYtEgnFvSppYLf4F/
13
+ * @param {string} [defaultValue=normalizedEndpoint]
14
+ * @return {*} {Promise<string>}
15
+ */
16
+ export declare function getSpaceServiceEndpoint(normalizedEndpoint: string, defaultValue?: string): Promise<string>;
@@ -0,0 +1,56 @@
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.getSpaceServiceEndpoint = exports.normalizeEndpoint = void 0;
7
+ const is_url_1 = __importDefault(require("is-url"));
8
+ const ufo_1 = require("ufo");
9
+ const api_1 = require("./api");
10
+ const logger_1 = require("./logger");
11
+ /**
12
+ *
13
+ *
14
+ * @private
15
+ * @param {string} endpoint => https://73aa3e87-znkjt5vbgnezh4p6v4dsaye61e7pxxn3vk4j.did.abtnet.io/app/api/space/z3T6WZD3dBtaVUgwb3rtBey8BartrJDTLrmQr/app/zNKsSUmUVJntiVdAPpg8vYtEgnFvSppYLf4F/object/
16
+ * @return {*} {string} https://73aa3e87-znkjt5vbgnezh4p6v4dsaye61e7pxxn3vk4j.did.abtnet.io/app/api/space/z3T6WZD3dBtaVUgwb3rtBey8BartrJDTLrmQr/app/zNKsSUmUVJntiVdAPpg8vYtEgnFvSppYLf4F/
17
+ */
18
+ function normalizeEndpoint(endpoint) {
19
+ if (!(0, is_url_1.default)(endpoint)) {
20
+ throw new Error(`Endpoint(${endpoint}) is not a valid http url or https url`);
21
+ }
22
+ const endpointURL = new URL(endpoint);
23
+ const $endpoint = endpoint.replace(endpointURL.search, '');
24
+ if ($endpoint.endsWith('object/')) {
25
+ return $endpoint.replace(/object\/$/, '');
26
+ }
27
+ return $endpoint;
28
+ }
29
+ exports.normalizeEndpoint = normalizeEndpoint;
30
+ /**
31
+ * @description
32
+ * @export
33
+ * @param {string} normalizedEndpoint https://73aa3e87-znkjt5vbgnezh4p6v4dsaye61e7pxxn3vk4j.did.abtnet.io/app/api/space/z3T6WZD3dBtaVUgwb3rtBey8BartrJDTLrmQr/app/zNKsSUmUVJntiVdAPpg8vYtEgnFvSppYLf4F/
34
+ * @param {string} [defaultValue=normalizedEndpoint]
35
+ * @return {*} {Promise<string>}
36
+ */
37
+ async function getSpaceServiceEndpoint(normalizedEndpoint, defaultValue = normalizedEndpoint) {
38
+ if (!(0, is_url_1.default)(normalizedEndpoint)) {
39
+ throw new Error(`normalizedEndpoint(${normalizedEndpoint}) is not a valid http url or https url`);
40
+ }
41
+ const getSpaceServiceEndpointUrl = (0, ufo_1.joinURL)(normalizedEndpoint, 'endpoint?useServiceUrl=true');
42
+ const response = await api_1.gotApi
43
+ .get(getSpaceServiceEndpointUrl)
44
+ .then((res) => {
45
+ return {
46
+ ...res,
47
+ body: normalizeEndpoint(res.body),
48
+ };
49
+ })
50
+ .catch((error) => {
51
+ logger_1.logger.warn('getSpaceServiceEndpoint', error);
52
+ return { body: '' };
53
+ });
54
+ return response.body || defaultValue;
55
+ }
56
+ exports.getSpaceServiceEndpoint = getSpaceServiceEndpoint;
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ import { Stream } from 'stream';
3
+ export declare function streamToFile(writeStream: Stream): Promise<void>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.streamToFile = void 0;
4
+ function streamToFile(writeStream) {
5
+ return new Promise((resolve, reject) => {
6
+ writeStream.on('error', reject);
7
+ writeStream.on('finish', resolve);
8
+ });
9
+ }
10
+ exports.streamToFile = streamToFile;
@@ -0,0 +1,50 @@
1
+ import { SyncFolderBaseCommandInput, SyncFolderBaseCommandOutput } from '../sync/sync-folder-base-command';
2
+ export interface BackupBlockletCommandInput extends Omit<SyncFolderBaseCommandInput, 'target'> {
3
+ appDid: string;
4
+ /**
5
+ *
6
+ * @description 备份人员的 userDid
7
+ * @type {string}
8
+ * @memberof BackupBlockletCommandInput
9
+ */
10
+ userDid: string;
11
+ /**
12
+ *
13
+ * @description 用户当时在什么页面备份的呢?
14
+ * @type {string}
15
+ * @memberof BackupBlockletCommandInput
16
+ */
17
+ referrer: string;
18
+ /**
19
+ *
20
+ * @description 指向 server 的 did 地址
21
+ * @default ""
22
+ * @type {string}
23
+ * @memberof BackupBlockletCommandInput
24
+ */
25
+ serverDid: string;
26
+ /**
27
+ *
28
+ * @description 本质上是始终指向最新的 appDid,目前主要是 rotate 的 blocklet 在还原的时候会用到这个参数
29
+ * @default ""
30
+ * @type {string}
31
+ * @memberof AppBackup
32
+ */
33
+ signerDid: string;
34
+ /**
35
+ *
36
+ * @description blocklet 的名称
37
+ * @type {string}
38
+ * @memberof BackupBlockletCommandInput
39
+ */
40
+ appName: string;
41
+ /**
42
+ *
43
+ * @description blocklet 的描述
44
+ * @type {string}
45
+ * @memberof BackupBlockletCommandInput
46
+ */
47
+ appDescription: string;
48
+ }
49
+ export interface BackupBlockletCommandOutput extends SyncFolderBaseCommandOutput {
50
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './backup-blocklet-command';
2
+ export * from './post-app-backup-command';
3
+ export * from './put-app-backup-command';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./backup-blocklet-command"), exports);
18
+ __exportStar(require("./post-app-backup-command"), exports);
19
+ __exportStar(require("./put-app-backup-command"), exports);
@@ -0,0 +1,8 @@
1
+ import { AppBackup } from '@did-space/core';
2
+ import type { ObjectSchema } from 'joi';
3
+ import type { CommandOutput } from '../../protocol';
4
+ export declare const PostAppBackupCommandInputSchema: ObjectSchema<any>;
5
+ export interface PostAppBackupCommandInput extends Pick<AppBackup, 'userDid' | 'referrer' | 'appName' | 'appDescription' | 'serverDid' | 'signerDid'> {
6
+ }
7
+ export interface PostAppBackupCommandOutput extends CommandOutput<Required<AppBackup>> {
8
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostAppBackupCommandInputSchema = void 0;
4
+ const validator_1 = require("@arcblock/validator");
5
+ exports.PostAppBackupCommandInputSchema = validator_1.Joi.object({
6
+ userDid: validator_1.Joi.DID(),
7
+ appName: validator_1.Joi.string().required(),
8
+ appDescription: validator_1.Joi.string().required(),
9
+ referrer: validator_1.Joi.string()
10
+ .uri({
11
+ scheme: ['http', 'https'],
12
+ })
13
+ .required(),
14
+ serverDid: validator_1.Joi.string().optional().allow('').default(''),
15
+ signerDid: validator_1.Joi.DID().optional().allow('').default(''),
16
+ });
@@ -0,0 +1,7 @@
1
+ import { AppBackup } from '@did-space/core';
2
+ import type { ObjectSchema } from 'joi';
3
+ import type { CommandOutput } from '../../protocol';
4
+ export declare const PutAppBackupCommandInputSchema: ObjectSchema<any>;
5
+ export type PutAppBackupCommandInput = Required<Pick<AppBackup, 'id'>> & Partial<AppBackup>;
6
+ export interface PutAppBackupCommandOutput extends CommandOutput<Required<AppBackup>> {
7
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PutAppBackupCommandInputSchema = void 0;
4
+ const validator_1 = require("@arcblock/validator");
5
+ const core_1 = require("@did-space/core");
6
+ exports.PutAppBackupCommandInputSchema = validator_1.Joi.object({
7
+ id: validator_1.Joi.string().required(),
8
+ updateAt: validator_1.Joi.string()
9
+ .optional()
10
+ .default(() => new Date().toISOString()),
11
+ // 默认是 APP_BACKUP_STATUS.DEFAULT 是因为我要兼容以前的旧版本的数据
12
+ status: validator_1.Joi.string()
13
+ .optional()
14
+ .allow('')
15
+ .valid(...Object.values(core_1.APP_BACKUP_STATUS))
16
+ .default(core_1.APP_BACKUP_STATUS.DEFAULT),
17
+ message: validator_1.Joi.string().optional().allow('').default(''),
18
+ });
@@ -0,0 +1,50 @@
1
+ import { IncrementalSyncBaseCommandInput, IncrementalSyncBaseCommandOutput } from '../sync';
2
+ export interface IncrementalBackupBlockletCommandInput extends Omit<IncrementalSyncBaseCommandInput, 'target'> {
3
+ appDid: string;
4
+ /**
5
+ *
6
+ * @description 备份人员的 userDid
7
+ * @type {string}
8
+ * @memberof BackupBlockletCommandInput
9
+ */
10
+ userDid: string;
11
+ /**
12
+ *
13
+ * @description 用户当时在什么页面备份的呢?
14
+ * @type {string}
15
+ * @memberof BackupBlockletCommandInput
16
+ */
17
+ referrer: string;
18
+ /**
19
+ *
20
+ * @description 指向 server 的 did 地址
21
+ * @default ""
22
+ * @type {string}
23
+ * @memberof BackupBlockletCommandInput
24
+ */
25
+ serverDid: string;
26
+ /**
27
+ *
28
+ * @description 本质上是始终指向最新的 appDid,目前主要是 rotate 的 blocklet 在还原的时候会用到这个参数
29
+ * @default ""
30
+ * @type {string}
31
+ * @memberof AppBackup
32
+ */
33
+ signerDid: string;
34
+ /**
35
+ *
36
+ * @description blocklet 的名称
37
+ * @type {string}
38
+ * @memberof BackupBlockletCommandInput
39
+ */
40
+ appName: string;
41
+ /**
42
+ *
43
+ * @description blocklet 的描述
44
+ * @type {string}
45
+ * @memberof BackupBlockletCommandInput
46
+ */
47
+ appDescription: string;
48
+ }
49
+ export interface IncrementalBackupBlockletCommandOutput extends IncrementalSyncBaseCommandOutput {
50
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './backup-blocklet-command';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./backup-blocklet-command"), exports);
@@ -0,0 +1,7 @@
1
+ export * from './backup';
2
+ export * from './incremental-backup';
3
+ export * from './nft';
4
+ export * from './object';
5
+ export * from './restore';
6
+ export * from './sync';
7
+ export * from './spaces-client-options';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./backup"), exports);
18
+ __exportStar(require("./incremental-backup"), exports);
19
+ __exportStar(require("./nft"), exports);
20
+ __exportStar(require("./object"), exports);
21
+ __exportStar(require("./restore"), exports);
22
+ __exportStar(require("./sync"), exports);
23
+ __exportStar(require("./spaces-client-options"), exports);
@@ -0,0 +1 @@
1
+ export * from './put-nft-object-command';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./put-nft-object-command"), exports);
@@ -0,0 +1,51 @@
1
+ /// <reference types="node" />
2
+ import { WalletObject } from '@ocap/wallet';
3
+ import { Readable } from 'stream';
4
+ import type { CommandOutput } from '../../protocol';
5
+ export interface PutNftObjectCommandInput {
6
+ /**
7
+ * @description assetDid
8
+ * @example z8iZnaYxnkMD5AKRjTKiCb8pQr1ut8UantAcf
9
+ * @type {string}
10
+ * @memberof PutNftObjectCommandInput
11
+ */
12
+ did: string;
13
+ /**
14
+ *
15
+ * @description 可以控制这个 did document 的钱包对象
16
+ * @example z8iZnaYxnkMD5AKRjTKiCb8pQr1ut8UantAcf
17
+ * @type {string}
18
+ * @memberof PutNftObjectCommandInput
19
+ */
20
+ controller: WalletObject;
21
+ /**
22
+ *
23
+ * @description
24
+ * @example https://beta.abtnetwork.io/api/
25
+ * @type {string}
26
+ * @memberof PutNftObjectCommandInput
27
+ */
28
+ chainHost: string;
29
+ /**
30
+ * @description display 相关配置
31
+ *
32
+ */
33
+ display: {
34
+ /**
35
+ *
36
+ * @description 文件名,无需携带路径
37
+ * @example abc.png
38
+ * @type {string}
39
+ * @memberof PutNftObjectCommandInput
40
+ */
41
+ key: string;
42
+ /**
43
+ *
44
+ * @description display 的数据
45
+ * @type {Readable}
46
+ * @memberof PutNftObjectCommandInput
47
+ */
48
+ data: Readable;
49
+ };
50
+ }
51
+ export type PutNftObjectCommandOutput = CommandOutput<void>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import type { CommandOutput } from '../../protocol';
2
+ export interface DeleteObjectCommandInput {
3
+ key: string;
4
+ }
5
+ export interface DeleteObjectCommandOutput extends CommandOutput<void> {
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ import type { AxiosResponseHeaders, RawAxiosResponseHeaders } from 'axios';
4
+ import type { CommandOutput } from '../../protocol';
5
+ export interface GetObjectCommandInput {
6
+ key: string;
7
+ }
8
+ export interface GetObjectCommandOutput extends CommandOutput<Readable> {
9
+ headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import type { Response } from 'got';
2
+ import type { CommandOutput } from '../../protocol';
3
+ export interface HeadSpaceCommandInput {
4
+ /**
5
+ * @description 对象的大小
6
+ * @default {0}
7
+ * @memberof HeadObjectCommandInput
8
+ */
9
+ size?: number;
10
+ }
11
+ export type HeadSpaceCommandOutput = CommandOutput<void> & {
12
+ response: Response;
13
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export * from './delete-object-command';
2
+ export * from './get-object-command';
3
+ export * from './list-object-command';
4
+ export * from './list-objects-command';
5
+ export * from './put-object-command';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./delete-object-command"), exports);
18
+ __exportStar(require("./get-object-command"), exports);
19
+ __exportStar(require("./list-object-command"), exports);
20
+ __exportStar(require("./list-objects-command"), exports);
21
+ __exportStar(require("./put-object-command"), exports);