@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.
- package/README.md +77 -0
- package/dist/client/index.d.ts +40 -0
- package/dist/client/index.js +110 -0
- package/dist/commands/backup/backup-blocklet.d.ts +14 -0
- package/dist/commands/backup/backup-blocklet.js +83 -0
- package/dist/commands/backup/index.d.ts +3 -0
- package/dist/commands/backup/index.js +19 -0
- package/dist/commands/backup/post-app-backup.d.ts +9 -0
- package/dist/commands/backup/post-app-backup.js +49 -0
- package/dist/commands/backup/put-app-backup.d.ts +9 -0
- package/dist/commands/backup/put-app-backup.js +49 -0
- package/dist/commands/base.d.ts +21 -0
- package/dist/commands/base.js +47 -0
- package/dist/commands/incremental-backup/backup-blocklet.d.ts +14 -0
- package/dist/commands/incremental-backup/backup-blocklet.js +90 -0
- package/dist/commands/incremental-backup/index.d.ts +1 -0
- package/dist/commands/incremental-backup/index.js +17 -0
- package/dist/commands/incremental-sync/index.d.ts +2 -0
- package/dist/commands/incremental-sync/index.js +18 -0
- package/dist/commands/incremental-sync/sync-base.d.ts +76 -0
- package/dist/commands/incremental-sync/sync-base.js +236 -0
- package/dist/commands/incremental-sync/sync-push.d.ts +30 -0
- package/dist/commands/incremental-sync/sync-push.js +202 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.js +25 -0
- package/dist/commands/nft/index.d.ts +1 -0
- package/dist/commands/nft/index.js +17 -0
- package/dist/commands/nft/put-nft-object.d.ts +20 -0
- package/dist/commands/nft/put-nft-object.js +143 -0
- package/dist/commands/object/delete-object.d.ts +7 -0
- package/dist/commands/object/delete-object.js +38 -0
- package/dist/commands/object/get-object.d.ts +7 -0
- package/dist/commands/object/get-object.js +43 -0
- package/dist/commands/object/index.d.ts +5 -0
- package/dist/commands/object/index.js +21 -0
- package/dist/commands/object/list-object.d.ts +7 -0
- package/dist/commands/object/list-object.js +31 -0
- package/dist/commands/object/list-objects.d.ts +7 -0
- package/dist/commands/object/list-objects.js +44 -0
- package/dist/commands/object/put-object.d.ts +7 -0
- package/dist/commands/object/put-object.js +61 -0
- package/dist/commands/restore/index.d.ts +3 -0
- package/dist/commands/restore/index.js +19 -0
- package/dist/commands/restore/post-app-restore.d.ts +7 -0
- package/dist/commands/restore/post-app-restore.js +45 -0
- package/dist/commands/restore/put-app-restore.d.ts +9 -0
- package/dist/commands/restore/put-app-restore.js +49 -0
- package/dist/commands/restore/restore-blocklet.d.ts +14 -0
- package/dist/commands/restore/restore-blocklet.js +80 -0
- package/dist/commands/space/head.d.ts +8 -0
- package/dist/commands/space/head.js +52 -0
- package/dist/commands/space/index.d.ts +1 -0
- package/dist/commands/space/index.js +17 -0
- package/dist/commands/sync/index.d.ts +3 -0
- package/dist/commands/sync/index.js +19 -0
- package/dist/commands/sync/sync-folder-base.d.ts +105 -0
- package/dist/commands/sync/sync-folder-base.js +319 -0
- package/dist/commands/sync/sync-folder-pull.d.ts +13 -0
- package/dist/commands/sync/sync-folder-pull.js +151 -0
- package/dist/commands/sync/sync-folder-push.d.ts +20 -0
- package/dist/commands/sync/sync-folder-push.js +166 -0
- package/dist/did-document/did-document.d.ts +29 -0
- package/dist/did-document/did-document.js +2 -0
- package/dist/did-document/index.d.ts +3 -0
- package/dist/did-document/index.js +19 -0
- package/dist/did-document/sign-document.d.ts +3 -0
- package/dist/did-document/sign-document.js +13 -0
- package/dist/did-document/verify-document.d.ts +10 -0
- package/dist/did-document/verify-document.js +35 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +23 -0
- package/dist/libs/api.d.ts +3 -0
- package/dist/libs/api.js +65 -0
- package/dist/libs/did.d.ts +9 -0
- package/dist/libs/did.js +34 -0
- package/dist/libs/encoding.d.ts +7 -0
- package/dist/libs/encoding.js +17 -0
- package/dist/libs/error.d.ts +4 -0
- package/dist/libs/error.js +27 -0
- package/dist/libs/hash.d.ts +1 -0
- package/dist/libs/hash.js +5 -0
- package/dist/libs/index.d.ts +11 -0
- package/dist/libs/index.js +27 -0
- package/dist/libs/logger.d.ts +2 -0
- package/dist/libs/logger.js +12 -0
- package/dist/libs/object-integrality.d.ts +1 -0
- package/dist/libs/object-integrality.js +13 -0
- package/dist/libs/performance.d.ts +7 -0
- package/dist/libs/performance.js +13 -0
- package/dist/libs/sleep.d.ts +1 -0
- package/dist/libs/sleep.js +9 -0
- package/dist/libs/space.d.ts +16 -0
- package/dist/libs/space.js +56 -0
- package/dist/libs/stream.d.ts +3 -0
- package/dist/libs/stream.js +10 -0
- package/dist/meta/backup/backup-blocklet-command.d.ts +50 -0
- package/dist/meta/backup/backup-blocklet-command.js +2 -0
- package/dist/meta/backup/index.d.ts +3 -0
- package/dist/meta/backup/index.js +19 -0
- package/dist/meta/backup/post-app-backup-command.d.ts +8 -0
- package/dist/meta/backup/post-app-backup-command.js +16 -0
- package/dist/meta/backup/put-app-backup-command.d.ts +7 -0
- package/dist/meta/backup/put-app-backup-command.js +18 -0
- package/dist/meta/incremental-backup/backup-blocklet-command.d.ts +50 -0
- package/dist/meta/incremental-backup/backup-blocklet-command.js +2 -0
- package/dist/meta/incremental-backup/index.d.ts +1 -0
- package/dist/meta/incremental-backup/index.js +17 -0
- package/dist/meta/index.d.ts +7 -0
- package/dist/meta/index.js +23 -0
- package/dist/meta/nft/index.d.ts +1 -0
- package/dist/meta/nft/index.js +17 -0
- package/dist/meta/nft/put-nft-object-command.d.ts +51 -0
- package/dist/meta/nft/put-nft-object-command.js +2 -0
- package/dist/meta/object/delete-object-command.d.ts +6 -0
- package/dist/meta/object/delete-object-command.js +2 -0
- package/dist/meta/object/get-object-command.d.ts +10 -0
- package/dist/meta/object/get-object-command.js +2 -0
- package/dist/meta/object/head-object-command.d.ts +13 -0
- package/dist/meta/object/head-object-command.js +2 -0
- package/dist/meta/object/index.d.ts +5 -0
- package/dist/meta/object/index.js +21 -0
- package/dist/meta/object/list-object-command.d.ts +6 -0
- package/dist/meta/object/list-object-command.js +2 -0
- package/dist/meta/object/list-objects-command.d.ts +8 -0
- package/dist/meta/object/list-objects-command.js +2 -0
- package/dist/meta/object/put-object-command.d.ts +29 -0
- package/dist/meta/object/put-object-command.js +2 -0
- package/dist/meta/restore/index.d.ts +3 -0
- package/dist/meta/restore/index.js +19 -0
- package/dist/meta/restore/post-app-restore-command.d.ts +8 -0
- package/dist/meta/restore/post-app-restore-command.js +13 -0
- package/dist/meta/restore/put-app-restore-command.d.ts +7 -0
- package/dist/meta/restore/put-app-restore-command.js +18 -0
- package/dist/meta/restore/restore-blocklet-command.d.ts +28 -0
- package/dist/meta/restore/restore-blocklet-command.js +2 -0
- package/dist/meta/spaces-client-options.d.ts +5 -0
- package/dist/meta/spaces-client-options.js +2 -0
- package/dist/meta/sync/incremental-sync-base-command.d.ts +7 -0
- package/dist/meta/sync/incremental-sync-base-command.js +2 -0
- package/dist/meta/sync/incremental-sync-push-command.d.ts +8 -0
- package/dist/meta/sync/incremental-sync-push-command.js +2 -0
- package/dist/meta/sync/index.d.ts +6 -0
- package/dist/meta/sync/index.js +22 -0
- package/dist/meta/sync/sync-base-command.d.ts +121 -0
- package/dist/meta/sync/sync-base-command.js +2 -0
- package/dist/meta/sync/sync-folder-base-command.d.ts +12 -0
- package/dist/meta/sync/sync-folder-base-command.js +2 -0
- package/dist/meta/sync/sync-folder-pull-command.d.ts +5 -0
- package/dist/meta/sync/sync-folder-pull-command.js +2 -0
- package/dist/meta/sync/sync-folder-push-command.d.ts +7 -0
- package/dist/meta/sync/sync-folder-push-command.js +2 -0
- package/dist/protocol/command.protocol.d.ts +68 -0
- package/dist/protocol/command.protocol.js +2 -0
- package/dist/protocol/index.d.ts +1 -0
- package/dist/protocol/index.js +17 -0
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.js +17 -0
- package/dist/security/request-signature.d.ts +32 -0
- package/dist/security/request-signature.js +140 -0
- 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,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,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,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,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,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,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 @@
|
|
|
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,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,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,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,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);
|