web-dc-api 0.1.4 → 0.1.6
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/dist/cjs/index.js +1 -1
- package/dist/dc.min.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +934 -878
- package/package.json +4 -8
- package/dist/cjs/helia-core-B1Xqha7a.js +0 -1
- package/dist/cjs/helia-core-D8Uv1KjQ.js +0 -1
- package/dist/cjs/polkadot-api-7PhQf3ws.js +0 -1
- package/dist/cjs/polkadot-api-CtrJVWuZ.js +0 -1
- package/dist/esm/chunks/helia-core-BxMqyK2Y.js +0 -1
- package/dist/esm/chunks/helia-core-DMXRpcO-.js +0 -1
- package/dist/esm/chunks/polkadot-api-5Y9Bw8VT.js +0 -1
- package/dist/esm/chunks/polkadot-api-D69Ioun_.js +0 -1
- package/lib/common/blowfish/block.ts +0 -259
- package/lib/common/blowfish/cipher.ts +0 -144
- package/lib/common/blowfish/const.ts +0 -195
- package/lib/common/chain.ts +0 -469
- package/lib/common/commonclient.ts +0 -202
- package/lib/common/constants.ts +0 -55
- package/lib/common/dc-key/ed25519.ts +0 -343
- package/lib/common/dc-key/keyManager.ts +0 -424
- package/lib/common/dcapi.ts +0 -98
- package/lib/common/dcutil.ts +0 -627
- package/lib/common/define.ts +0 -70
- package/lib/common/error.ts +0 -67
- package/lib/common/grpc-dc.ts +0 -104
- package/lib/common/module-system.ts +0 -184
- package/lib/common/service-worker.ts +0 -234
- package/lib/common/types/types.ts +0 -344
- package/lib/dc.ts +0 -701
- package/lib/implements/account/client.ts +0 -185
- package/lib/implements/account/manager.ts +0 -683
- package/lib/implements/aiproxy/client.ts +0 -357
- package/lib/implements/aiproxy/manager.ts +0 -670
- package/lib/implements/cache/client.ts +0 -105
- package/lib/implements/cache/manager.ts +0 -127
- package/lib/implements/comment/client.ts +0 -982
- package/lib/implements/comment/manager.ts +0 -1151
- package/lib/implements/dc/client.ts +0 -51
- package/lib/implements/dc/manager.ts +0 -33
- package/lib/implements/file/client.ts +0 -253
- package/lib/implements/file/file-cache-manager.ts +0 -142
- package/lib/implements/file/manager.ts +0 -1240
- package/lib/implements/file/seekableFileStream.ts +0 -344
- package/lib/implements/file/streamwriter.ts +0 -322
- package/lib/implements/keyvalue/client.ts +0 -376
- package/lib/implements/keyvalue/manager.ts +0 -759
- package/lib/implements/message/client.ts +0 -250
- package/lib/implements/message/manager.ts +0 -215
- package/lib/implements/threaddb/cbor/coding.ts +0 -62
- package/lib/implements/threaddb/cbor/event.ts +0 -336
- package/lib/implements/threaddb/cbor/node.ts +0 -542
- package/lib/implements/threaddb/cbor/record.ts +0 -398
- package/lib/implements/threaddb/common/AsyncMutex.ts +0 -24
- package/lib/implements/threaddb/common/addrinfo.ts +0 -135
- package/lib/implements/threaddb/common/dispatcher.ts +0 -81
- package/lib/implements/threaddb/common/idbstore-adapter.ts +0 -260
- package/lib/implements/threaddb/common/json-patcher.ts +0 -204
- package/lib/implements/threaddb/common/key.ts +0 -290
- package/lib/implements/threaddb/common/level-adapter.ts +0 -235
- package/lib/implements/threaddb/common/lineReader.ts +0 -79
- package/lib/implements/threaddb/common/logstore.ts +0 -215
- package/lib/implements/threaddb/common/transformed-datastore.ts +0 -308
- package/lib/implements/threaddb/core/app.ts +0 -206
- package/lib/implements/threaddb/core/core.ts +0 -230
- package/lib/implements/threaddb/core/db.ts +0 -249
- package/lib/implements/threaddb/core/event.ts +0 -54
- package/lib/implements/threaddb/core/head.ts +0 -89
- package/lib/implements/threaddb/core/identity.ts +0 -171
- package/lib/implements/threaddb/core/logstore.ts +0 -137
- package/lib/implements/threaddb/core/options.ts +0 -14
- package/lib/implements/threaddb/core/record.ts +0 -54
- package/lib/implements/threaddb/db/collection.ts +0 -1910
- package/lib/implements/threaddb/db/db.ts +0 -698
- package/lib/implements/threaddb/db/json2Query.ts +0 -192
- package/lib/implements/threaddb/db/query.ts +0 -524
- package/lib/implements/threaddb/dbclient.ts +0 -543
- package/lib/implements/threaddb/dbmanager.ts +0 -1906
- package/lib/implements/threaddb/lsstoreds/addr_book.ts +0 -549
- package/lib/implements/threaddb/lsstoreds/cache.ts +0 -36
- package/lib/implements/threaddb/lsstoreds/cyclic_batch.ts +0 -87
- package/lib/implements/threaddb/lsstoreds/global.ts +0 -151
- package/lib/implements/threaddb/lsstoreds/headbook.ts +0 -373
- package/lib/implements/threaddb/lsstoreds/keybook.ts +0 -297
- package/lib/implements/threaddb/lsstoreds/logstore.ts +0 -29
- package/lib/implements/threaddb/lsstoreds/metadata.ts +0 -223
- package/lib/implements/threaddb/net/define.ts +0 -149
- package/lib/implements/threaddb/net/grpcClient.ts +0 -589
- package/lib/implements/threaddb/net/grpcserver.ts +0 -146
- package/lib/implements/threaddb/net/net.ts +0 -2047
- package/lib/implements/threaddb/pb/lstore.proto +0 -38
- package/lib/implements/threaddb/pb/lstore.ts +0 -393
- package/lib/implements/threaddb/pb/lstore_pb.d.ts +0 -433
- package/lib/implements/threaddb/pb/lstore_pb.js +0 -1085
- package/lib/implements/threaddb/pb/net.proto +0 -194
- package/lib/implements/threaddb/pb/net_pb.d.ts +0 -2349
- package/lib/implements/threaddb/pb/net_pb.js +0 -5525
- package/lib/implements/threaddb/pb/proto-custom-types.ts +0 -212
- package/lib/implements/util/client.ts +0 -72
- package/lib/implements/util/manager.ts +0 -146
- package/lib/implements/wallet/manager.ts +0 -671
- package/lib/index.ts +0 -57
- package/lib/interfaces/DCContext.ts +0 -51
- package/lib/interfaces/aiproxy-interface.ts +0 -145
- package/lib/interfaces/auth-interface.ts +0 -118
- package/lib/interfaces/cache-interface.ts +0 -22
- package/lib/interfaces/client-interface.ts +0 -11
- package/lib/interfaces/comment-interface.ts +0 -167
- package/lib/interfaces/components/news-component.ts +0 -0
- package/lib/interfaces/database-interface.ts +0 -169
- package/lib/interfaces/file-interface.ts +0 -120
- package/lib/interfaces/index.ts +0 -10
- package/lib/interfaces/keyvalue-interface.ts +0 -156
- package/lib/interfaces/message-interface.ts +0 -22
- package/lib/interfaces/util-interface.ts +0 -31
- package/lib/modules/aiproxy-module.ts +0 -246
- package/lib/modules/auth-module.ts +0 -753
- package/lib/modules/cache-module.ts +0 -99
- package/lib/modules/client-module.ts +0 -71
- package/lib/modules/comment-module.ts +0 -429
- package/lib/modules/components/news-components.ts +0 -390
- package/lib/modules/database-module.ts +0 -598
- package/lib/modules/file-module.ts +0 -291
- package/lib/modules/index.ts +0 -13
- package/lib/modules/keyvalue-module.ts +0 -379
- package/lib/modules/message-module.ts +0 -107
- package/lib/modules/util-module.ts +0 -148
- package/lib/polyfills/process-env-browser.ts +0 -1
- package/lib/proto/datasource.ts +0 -93
- package/lib/proto/dcnet.proto +0 -1601
- package/lib/proto/dcnet_proto.d.ts +0 -22857
- package/lib/proto/dcnet_proto.js +0 -55204
- package/lib/proto/dcnet_proto_sparse.js +0 -55166
- package/lib/proto/oidfetch.proto +0 -25
- package/lib/proto/oidfetch_proto.d.ts +0 -585
- package/lib/proto/oidfetch_proto.js +0 -1247
- package/lib/serverless/babel-browser.ts +0 -39
- package/lib/serverless/base_entity.ts +0 -78
- package/lib/serverless/base_repository.ts +0 -414
- package/lib/serverless/browser_schema_extractor.ts +0 -283
- package/lib/serverless/decorator_factory.ts +0 -322
- package/lib/util/BrowserLineReader.ts +0 -73
- package/lib/util/base64.ts +0 -105
- package/lib/util/bcrypt.ts +0 -206
- package/lib/util/curve25519Encryption.ts +0 -418
- package/lib/util/dccrypt.ts +0 -73
- package/lib/util/logger.ts +0 -104
- package/lib/util/utils.ts +0 -289
package/lib/index.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// index.ts
|
|
2
|
-
// 导出主要类和功能
|
|
3
|
-
// 在您库的入口文件开头添加
|
|
4
|
-
|
|
5
|
-
declare global {
|
|
6
|
-
interface PromiseConstructor {
|
|
7
|
-
withResolvers<T = any>(): {
|
|
8
|
-
promise: Promise<T>;
|
|
9
|
-
resolve: (value: T | PromiseLike<T>) => void;
|
|
10
|
-
reject: (reason?: any) => void;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (typeof Promise !== 'undefined' && !Promise.withResolvers) {
|
|
16
|
-
Promise.withResolvers = function<T = any>() {
|
|
17
|
-
let resolve!: (value: T | PromiseLike<T>) => void;
|
|
18
|
-
let reject!: (reason?: any) => void;
|
|
19
|
-
const promise = new Promise<T>((res, rej) => {
|
|
20
|
-
resolve = res;
|
|
21
|
-
reject = rej;
|
|
22
|
-
});
|
|
23
|
-
return { promise, resolve, reject };
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export { DC } from './dc';
|
|
27
|
-
export {BaseEntity} from './serverless/base_entity';
|
|
28
|
-
export { EntityRepository,type FindIndexOptions, type FindValuesOptions,composeCompositeIndexValue} from './serverless/base_repository';
|
|
29
|
-
export * from './serverless/decorator_factory';
|
|
30
|
-
export * from './serverless/browser_schema_extractor';
|
|
31
|
-
export { registerServiceWorker, isServiceWorkerActive, updateServiceWorker } from './common/service-worker';
|
|
32
|
-
export * from './common/types/types';
|
|
33
|
-
export * from './interfaces';
|
|
34
|
-
export * from './common/define';
|
|
35
|
-
export {ThemePermission} from './common/constants';
|
|
36
|
-
|
|
37
|
-
// 导出模块系统
|
|
38
|
-
export { ModuleSystem, CoreModuleName } from './common/module-system';
|
|
39
|
-
export type { DCModule } from './common/module-system';
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// 导出核心模块
|
|
43
|
-
export * from './modules';
|
|
44
|
-
|
|
45
|
-
// 导出工具类
|
|
46
|
-
export { createLogger, configureLogger, LogLevel } from './util/logger';
|
|
47
|
-
|
|
48
|
-
// 导出keyManager
|
|
49
|
-
export { KeyManager } from './common/dc-key/keyManager';
|
|
50
|
-
|
|
51
|
-
// 导出私钥
|
|
52
|
-
export { Ed25519PrivKey, Ed25519PubKey } from './common/dc-key/ed25519';
|
|
53
|
-
|
|
54
|
-
// 导出错误类型
|
|
55
|
-
export { Errors } from './common/error';
|
|
56
|
-
|
|
57
|
-
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Ed25519PrivKey, Ed25519PubKey } from "../common/dc-key/ed25519";
|
|
3
|
-
import type { DCConnectInfo, APPInfo, AccountInfo, Account } from "../common/types/types";
|
|
4
|
-
import type { HeliaLibp2p } from "helia";
|
|
5
|
-
import { Libp2p } from "@libp2p/interface";
|
|
6
|
-
import { ChainUtil } from "../common/chain";
|
|
7
|
-
import { DcUtil } from "../common/dcutil";
|
|
8
|
-
import { DBManager } from "../implements/threaddb/dbmanager";
|
|
9
|
-
import { DCGrpcServer } from "../implements/threaddb/net/grpcserver";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 核心系统上下文接口
|
|
13
|
-
* 定义所有模块可以访问的核心系统组件
|
|
14
|
-
*/
|
|
15
|
-
export interface DCContext {
|
|
16
|
-
// 核心基础设施
|
|
17
|
-
dcNodeClient: HeliaLibp2p<Libp2p>;
|
|
18
|
-
dcChain: ChainUtil;
|
|
19
|
-
dcutil: DcUtil;
|
|
20
|
-
|
|
21
|
-
swInited: boolean;
|
|
22
|
-
|
|
23
|
-
// 连接信息
|
|
24
|
-
connectedDc: DCConnectInfo;
|
|
25
|
-
// 账号信息备份连接信息
|
|
26
|
-
AccountBackupDc: DCConnectInfo;
|
|
27
|
-
|
|
28
|
-
// 应用信息
|
|
29
|
-
appInfo: APPInfo;
|
|
30
|
-
|
|
31
|
-
// 当前登录的账户信息
|
|
32
|
-
accountInfo: AccountInfo;
|
|
33
|
-
// 当前登录的用户信息
|
|
34
|
-
userInfo: Account | null;
|
|
35
|
-
|
|
36
|
-
// 数据库管理器
|
|
37
|
-
dbManager?: DBManager;
|
|
38
|
-
|
|
39
|
-
// 身份相关
|
|
40
|
-
publicKey: Ed25519PubKey | undefined;
|
|
41
|
-
privateKey: Ed25519PrivKey | undefined | null;
|
|
42
|
-
// 以太坊格式的公钥,16进制字符串
|
|
43
|
-
ethAddress: string | undefined;
|
|
44
|
-
|
|
45
|
-
grpcServer: DCGrpcServer;
|
|
46
|
-
|
|
47
|
-
// 核心功能
|
|
48
|
-
sign(payload: Uint8Array): Promise<Uint8Array> ;
|
|
49
|
-
getPubkeyRaw(): Uint8Array;
|
|
50
|
-
getPublicKey(): Ed25519PubKey;
|
|
51
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { AIProxyConfig, IAICallConfig, OnStreamResponseType, ProxyCallConfig, UserProxyCallConfig } from "../common/types/types";
|
|
2
|
-
import { AIProxyUserPermission } from "../common/constants";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* AI代理操作接口
|
|
6
|
-
* 提供AI代理的配置和调用功能
|
|
7
|
-
*/
|
|
8
|
-
export interface IAIProxyOperations {
|
|
9
|
-
/**
|
|
10
|
-
* 创建AI调用的Proxy配置
|
|
11
|
-
* @param appId 应用ID
|
|
12
|
-
* @param configTheme 配置主题
|
|
13
|
-
* @returns [状态码, 错误信息]
|
|
14
|
-
*/
|
|
15
|
-
createProxyConfig(
|
|
16
|
-
appId: string,
|
|
17
|
-
configTheme: string
|
|
18
|
-
): Promise<[number | null, Error | null]>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 删除AI调用的Proxy配置
|
|
23
|
-
* @param appId 应用ID
|
|
24
|
-
* @param configTheme 配置主题
|
|
25
|
-
* @returns [状态码, 错误信息]
|
|
26
|
-
*/
|
|
27
|
-
deleteProxyConfig(
|
|
28
|
-
appId: string,
|
|
29
|
-
configTheme: string
|
|
30
|
-
): Promise<[number | null, Error | null]>;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 配置AI代理的访问配置
|
|
34
|
-
* 如果serverConfig为空,则表示删除该serviceName的配置
|
|
35
|
-
* @param appId 应用ID
|
|
36
|
-
* @param configAuthor 配置作者的公钥
|
|
37
|
-
* @param configTheme 配置主题
|
|
38
|
-
* @param serviceName 服务名称
|
|
39
|
-
* @param serviceConfig 服务配置(可选)
|
|
40
|
-
* @param vaccount 虚拟账户(可选)
|
|
41
|
-
* @returns [是否配置成功, 错误信息]
|
|
42
|
-
*/
|
|
43
|
-
configAIProxy(
|
|
44
|
-
appId: string,
|
|
45
|
-
configAuthor: string,
|
|
46
|
-
configTheme: string,
|
|
47
|
-
serviceName: string,
|
|
48
|
-
serviceConfig?: AIProxyConfig,
|
|
49
|
-
vaccount?: string
|
|
50
|
-
): Promise<[boolean | null, Error | null]>;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 配置用户的访问权限
|
|
54
|
-
* @param appId 应用ID
|
|
55
|
-
* @param configAuthor 配置作者的公钥
|
|
56
|
-
* @param configTheme 配置主题
|
|
57
|
-
* @param authPubkey 被授权用户的公钥
|
|
58
|
-
* @param permission 权限级别
|
|
59
|
-
* @param authConfig 授权配置
|
|
60
|
-
* @param vaccount 虚拟账户(可选)
|
|
61
|
-
* @returns [状态码, 错误信息]
|
|
62
|
-
*/
|
|
63
|
-
configAuth(
|
|
64
|
-
appId: string,
|
|
65
|
-
configAuthor: string,
|
|
66
|
-
configTheme: string,
|
|
67
|
-
authPubkey: string,
|
|
68
|
-
permission: AIProxyUserPermission,
|
|
69
|
-
authConfig: ProxyCallConfig,
|
|
70
|
-
vaccount?: string
|
|
71
|
-
): Promise<[number | null, Error | null]>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 获取AI代理的所有配置
|
|
75
|
-
* 包括服务与授权列表
|
|
76
|
-
* @param appId 应用ID
|
|
77
|
-
* @param themeAuthor 主题作者的公钥
|
|
78
|
-
* @param configTheme 配置主题
|
|
79
|
-
* @param vaccount 虚拟账户(可选)
|
|
80
|
-
* @returns [用户授权配置列表, AI代理配置列表, 错误信息]
|
|
81
|
-
*/
|
|
82
|
-
GetAIProxyConfig(
|
|
83
|
-
appId: string,
|
|
84
|
-
themeAuthor: string,
|
|
85
|
-
configTheme: string,
|
|
86
|
-
vaccount?: string
|
|
87
|
-
): Promise<[UserProxyCallConfig[] | null, AIProxyConfig[] | null, Error | null]>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 获取当前用户自身的AI代理授权信息
|
|
91
|
-
* @param appId 应用ID
|
|
92
|
-
* @param themeAuthor 主题作者的公钥
|
|
93
|
-
* @param configTheme 配置主题
|
|
94
|
-
* @returns [授权配置, 错误信息]
|
|
95
|
-
*/
|
|
96
|
-
GetUserOwnAIProxyAuth(
|
|
97
|
-
appId: string,
|
|
98
|
-
themeAuthor: string,
|
|
99
|
-
configTheme: string
|
|
100
|
-
): Promise<[ProxyCallConfig | null, Error | null]>;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 执行AI代理调用
|
|
104
|
-
* 包括代理与AI的通信或者与MCPServer的通信
|
|
105
|
-
* @param reqBody 请求体
|
|
106
|
-
* @param forceRefresh 是否强制刷新,强制刷鞋会消耗一定数量的token,一般在更新了用户授权后,才需要强制刷新
|
|
107
|
-
* @param onStreamResponse 流式响应回调函数
|
|
108
|
-
* @param appId 应用ID(可选),为空时使用默认的调用配置中的appId
|
|
109
|
-
* @param themeAuthor(可选) 主题作者的公钥,为空时使用默认的调用配置中的themeAuthor
|
|
110
|
-
* @param configTheme(可选) 配置主题,为空时使用默认的调用配置中的configTheme
|
|
111
|
-
* @param serviceName(可选) 服务器名称,为空时使用默认的调用配置中的serviceName
|
|
112
|
-
* @param headers 请求头(可选),为空时使用默认的调用配置中的headers
|
|
113
|
-
* @param path 请求路径(可选),为空时使用默认的调用配置中的path
|
|
114
|
-
* @param model 模型名称(可选),为空时使用默认的调用配置中的model
|
|
115
|
-
* @returns 调用状态码
|
|
116
|
-
*/
|
|
117
|
-
DoAIProxyCall(
|
|
118
|
-
context: { signal?: AbortSignal },
|
|
119
|
-
reqBody: string,
|
|
120
|
-
forceRefresh: boolean,
|
|
121
|
-
onStreamResponse: OnStreamResponseType,
|
|
122
|
-
appId?: string,
|
|
123
|
-
themeAuthor?: string,
|
|
124
|
-
configTheme?: string,
|
|
125
|
-
serviceName?: string,
|
|
126
|
-
headers?: Record<string, string>,
|
|
127
|
-
path?: string,
|
|
128
|
-
model?: string
|
|
129
|
-
): Promise<[number | null, Error | null]>;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 设置AI调用的配置
|
|
133
|
-
* @param appId 应用ID
|
|
134
|
-
* @param themeAuthor 主题作者的公钥
|
|
135
|
-
* @param configTheme 配置主题
|
|
136
|
-
* @param serviceName 服务名称
|
|
137
|
-
* @param headers 请求头(可选)
|
|
138
|
-
* @param path 请求路径(可选)
|
|
139
|
-
* @param model 模型名称(可选)
|
|
140
|
-
* @returns Promise<void>
|
|
141
|
-
* */
|
|
142
|
-
SetAICallConfig(
|
|
143
|
-
callConfig:IAICallConfig
|
|
144
|
-
): Promise<Error | null>;
|
|
145
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { DCConnectInfo, NFTBindStatus, User, Account, AccountInfo } from "../common/types/types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 认证操作接口
|
|
7
|
-
* 处理用户身份验证、账户管理和访问控制
|
|
8
|
-
*/
|
|
9
|
-
export interface IAuthOperations {
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 账户登录通过钱包
|
|
13
|
-
* @returns 是否登录成功
|
|
14
|
-
*/
|
|
15
|
-
accountLoginWithWallet(accountInfo?: AccountInfo): Promise<[Account | null, Error | null]>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 账户登录
|
|
19
|
-
* @param nftAccount NFT账户
|
|
20
|
-
* @param password 密码
|
|
21
|
-
* @param safecode 安全码,默认000000
|
|
22
|
-
* @returns 是否登录成功
|
|
23
|
-
*/
|
|
24
|
-
accountLogin(nftAccount: string, password: string, safecode: string): Promise<[string, Error | null]>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 签名数据
|
|
28
|
-
* @param payload 要签名的数据
|
|
29
|
-
* @returns 签名结果
|
|
30
|
-
*/
|
|
31
|
-
sign(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 解密数据
|
|
36
|
-
* @param payload 要解密的数据
|
|
37
|
-
* @returns 解密结果
|
|
38
|
-
*/
|
|
39
|
-
decryptWithWallet(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 将公钥绑定NFT账号
|
|
43
|
-
* @param account NFT账号
|
|
44
|
-
* @param password 密码
|
|
45
|
-
* @param seccode 安全码
|
|
46
|
-
* @param mnemonic 助记词,将安全存储在DC云端
|
|
47
|
-
* @returns [状态码, 错误信息]
|
|
48
|
-
*/
|
|
49
|
-
bindNFTAccount(account: string, password: string, seccode: string, mnemonic: string): Promise<[NFTBindStatus | null, Error | null]>;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 创建APP访问账号,返回APP专用私钥
|
|
53
|
-
* @param appId 应用ID
|
|
54
|
-
* @param mnemonic 助记词
|
|
55
|
-
* @returns [私钥字符串, 错误]
|
|
56
|
-
*/
|
|
57
|
-
generateAppAccount(appId: string, mnemonic: string): Promise<[string | null, Error | null]>;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 检查NFT账号是否成功绑定到当前用户的公钥
|
|
61
|
-
* @param nftAccount NFT账号
|
|
62
|
-
* @param pubKeyStr 公钥字符串
|
|
63
|
-
* @returns 是否成功绑定
|
|
64
|
-
*/
|
|
65
|
-
isNftAccountBindSuccess(nftAccount: string, pubKeyStr: string): Promise<[boolean | null, Error | null]>;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 检查NFT账号是否已经被公钥绑定
|
|
69
|
-
* @param nftAccount NFT账号
|
|
70
|
-
* @returns 是否被其他账号绑定
|
|
71
|
-
*/
|
|
72
|
-
isNftAccountBinded(nftAccount: string): Promise<[boolean | null, Error | null]>;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* 获取用户信息
|
|
76
|
-
* @param nftAccount NFT账户
|
|
77
|
-
* @returns 用户信息
|
|
78
|
-
*/
|
|
79
|
-
getUserInfoWithNft(nftAccount: string): Promise<[User | null, Error | null]>;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 获取用户钱包信息
|
|
84
|
-
* @param pubkeyAccount 账户名
|
|
85
|
-
* @returns 用户信息
|
|
86
|
-
*/
|
|
87
|
-
getUserInfoWithAccount(pubkeyAccount: string): Promise<[User | null, Error | null]>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 开启定时验证token线程
|
|
91
|
-
*/
|
|
92
|
-
startDcPeerTokenKeepValidTask(): Promise<[boolean, Error | null]>;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 检查用户空间是否足够
|
|
98
|
-
* @param needSize 需要的空间大小
|
|
99
|
-
* @returns 空间信息
|
|
100
|
-
*/
|
|
101
|
-
ifEnoughUserSpace(needSize?: number): Promise<[boolean | null, Error | null]>;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* 刷新用户信息
|
|
105
|
-
* @returns 用户信息
|
|
106
|
-
*/
|
|
107
|
-
refreshUserInfo(): Promise<[User | null, Error | null]>;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 获取用户默认数据库
|
|
111
|
-
* @param threadId 数据库ID
|
|
112
|
-
* @param rk 读取密钥,主要用来加解密真正的数据,注意对数据记录进行加密和解密
|
|
113
|
-
* @param sk 服务密钥,主要用来处理传输过程加解密,主要对数据链表头进行加密和解密
|
|
114
|
-
* @param remark 备注信息
|
|
115
|
-
* @returns 用户默认数据库信息
|
|
116
|
-
*/
|
|
117
|
-
setUserDefaultDB(threadId: string, rk: string,sk: string,remark: string,vaccount?: string): Promise< Error | null>;
|
|
118
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 临时缓存操作接口
|
|
3
|
-
* 提供从分布式网络获取和设置缓存值的功能,调用前请确保DC网络已连接,且用户已登录
|
|
4
|
-
*/
|
|
5
|
-
export interface ICacheOperations {
|
|
6
|
-
/**
|
|
7
|
-
* 从DC网络获取缓存值
|
|
8
|
-
* @param key 缓存键
|
|
9
|
-
* @returns 缓存值,如果键不存在则返回null
|
|
10
|
-
* @throws 当操作失败时抛出错误
|
|
11
|
-
*/
|
|
12
|
-
getCacheValue(key: string): Promise<[string | null, Error | null]>;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 设置缓存值
|
|
16
|
-
* @param value 缓存值
|
|
17
|
-
* @param expire 可选,过期时间(秒),默认为一天
|
|
18
|
-
* @returns 设置操作的结果
|
|
19
|
-
* @throws 当操作失败时抛出错误
|
|
20
|
-
*/
|
|
21
|
-
setCacheKey(value: string, expire?: number): Promise<[string | null, Error | null]>;
|
|
22
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { OpenFlag, ThemePermission } from "../common/constants";
|
|
2
|
-
import { ThemeAuthInfo, ThemeComment, ThemeObj } from "../common/types/types";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 评论操作接口
|
|
6
|
-
* 提供评论系统的所有功能操作
|
|
7
|
-
*/
|
|
8
|
-
export interface ICommentOperations {
|
|
9
|
-
/**
|
|
10
|
-
* 为指定主题开通评论功能
|
|
11
|
-
* @param theme 主题/对象标识符
|
|
12
|
-
* @param openFlag 开放标志 0-公开 1-私密 2-鉴权
|
|
13
|
-
* @param commentSpace 可选,评论空间上限大小(字节),默认50MB
|
|
14
|
-
* @returns 操作结果 0:成功 1:评论空间没有配置 2:评论空间不足 3:评论数据同步中
|
|
15
|
-
*/
|
|
16
|
-
addThemeObj(theme: string, openFlag: OpenFlag, commentSpace?: number): Promise<[number | null, Error | null]>;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 添加用户链下评论空间,DC为了提升性能,用户发布评论等操作,无需上链,有DC节点在TEE环境维护用户的评论空间使用情况,新用户在发布评论前需要先添加评论空间,每次调用会分配50MB的链下空间,用于发布评论等链下操作
|
|
20
|
-
* @returns 添加结果 true:成功 false:失败
|
|
21
|
-
*/
|
|
22
|
-
addUserOffChainSpace(): Promise<[boolean | null, Error | null]>
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 为用户添加链下操作次数,DC为了提升性能,用户发布评论等操作,无需上链,用于发布评论等链下操作次数,
|
|
26
|
-
* @param times 操作次数
|
|
27
|
-
* @param vaccount 可选,用户的虚拟账号
|
|
28
|
-
* @returns 操作结果 0:成功 1:评论空间没有配置 2:评论空间不足 3:评论数据同步中
|
|
29
|
-
*/
|
|
30
|
-
addUserOffChainOpTimes(
|
|
31
|
-
times: number,
|
|
32
|
-
vaccount?: string
|
|
33
|
-
): Promise<[boolean | null, Error | null]>
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 为已开通评论的主题增加评论空间,为了防止每个主题评论空间浪费,每个主题在创建时会分配50MB的评论空间,如果后续不够,可以通过这个接口增加
|
|
37
|
-
* 本方法可以为指定主题的keyvaluedb增加空间
|
|
38
|
-
* @param theme 主题/对象标识符
|
|
39
|
-
* @param addSpace 要增加的空间大小(字节)
|
|
40
|
-
* @returns 操作结果
|
|
41
|
-
*/
|
|
42
|
-
addThemeSpace(theme: string, addSpace: number): Promise<[number | null, Error | null]>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 向指定主题发布评论
|
|
46
|
-
* @param theme 主题/对象标识符
|
|
47
|
-
* @param themeAuthor 主题作者的公钥
|
|
48
|
-
* @param commentType 评论类型
|
|
49
|
-
* @param comment 评论内容
|
|
50
|
-
* @param refercommentkey 可选,引用的评论键
|
|
51
|
-
* @param openFlag 可选,评论可见性标志
|
|
52
|
-
* @returns 评论发布结果
|
|
53
|
-
*/
|
|
54
|
-
publishCommentToTheme(
|
|
55
|
-
theme: string,
|
|
56
|
-
themeAuthor: string,
|
|
57
|
-
commentType: number,
|
|
58
|
-
comment: string,
|
|
59
|
-
openFlag?: number,
|
|
60
|
-
refercommentkey?: string
|
|
61
|
-
): Promise<[string | null, Error | null]>;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 删除自己发布的评论,只是删除了在自己列表中的评论,不能删除已经发布到主题下的评论
|
|
65
|
-
* @param theme 主题/对象标识符
|
|
66
|
-
* @param themeAuthor 主题作者的公钥
|
|
67
|
-
* @param commentKey 评论的唯一键
|
|
68
|
-
* @returns 删除操作结果
|
|
69
|
-
*/
|
|
70
|
-
deleteSelfComment(theme: string, themeAuthor: string, commentKey: string): Promise<[number | null, Error | null]>;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 获取指定作者的主题对象列表,无法查询作者设置为私密的主题
|
|
74
|
-
* @param themeAuthor 主题作者的公钥
|
|
75
|
-
* @param startHeight 可选,查询起始高度
|
|
76
|
-
* @param direction 可选,查询方向 (0:从新到旧, 1:从旧到新)
|
|
77
|
-
* @param offset 可选,结果集偏移量
|
|
78
|
-
* @param limit 可选,最大返回数量,默认100
|
|
79
|
-
* @param seekKey 可选,查询的起始键,格式为返回记录的 blockheight/key
|
|
80
|
-
* @returns 主题对象列表
|
|
81
|
-
*/
|
|
82
|
-
getThemeObj(
|
|
83
|
-
themeAuthor: string,
|
|
84
|
-
startHeight?: number,
|
|
85
|
-
direction?: number,
|
|
86
|
-
offset?: number,
|
|
87
|
-
limit?: number,
|
|
88
|
-
seekKey?: string
|
|
89
|
-
): Promise<[ThemeObj[] | null, Error | null]>;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* 获取指定主题的评论列表,无法查询作者设置为私密的评论
|
|
93
|
-
* @param theme 主题/对象标识符
|
|
94
|
-
* @param themeAuthor 主题作者的公钥
|
|
95
|
-
* @param startHeight 可选,查询起始高度
|
|
96
|
-
* @param direction 可选,查询方向 (0:从新到旧, 1:从旧到新)
|
|
97
|
-
* @param offset 可选,结果集偏移量
|
|
98
|
-
* @param limit 可选,最大返回数量,默认100
|
|
99
|
-
* @param seekKey 可选,查询的起始键,格式为返回记录的 blockheight/key
|
|
100
|
-
* @returns 主题的评论列表
|
|
101
|
-
*/
|
|
102
|
-
getThemeComments(
|
|
103
|
-
theme: string,
|
|
104
|
-
themeAuthor: string,
|
|
105
|
-
startHeight?: number,
|
|
106
|
-
direction?: number,
|
|
107
|
-
offset?: number,
|
|
108
|
-
limit?: number,
|
|
109
|
-
seekKey?: string
|
|
110
|
-
): Promise<[ThemeComment[] | null, Error | null]>;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 配置主题的授权信息
|
|
115
|
-
* @param appId 应用ID
|
|
116
|
-
* @param themeAuthor 主题作者的公钥
|
|
117
|
-
* @param theme 主题名称
|
|
118
|
-
* @param authPubkey 被授权者的公钥
|
|
119
|
-
* @param permission 权限级别
|
|
120
|
-
* @param remark 备注信息
|
|
121
|
-
* @param vaccount 可选的虚拟账户
|
|
122
|
-
* @returns [授权状态码, 错误信息]
|
|
123
|
-
*/
|
|
124
|
-
configAuth(
|
|
125
|
-
themeAuthor: string,
|
|
126
|
-
theme: string,
|
|
127
|
-
authPubkey: string,
|
|
128
|
-
permission: ThemePermission,
|
|
129
|
-
remark: string,
|
|
130
|
-
vaccount?: string
|
|
131
|
-
): Promise<[number | null, Error | null]>;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* 获取指定主题的授权列表,
|
|
136
|
-
* @param appId 应用ID
|
|
137
|
-
* @param themeAuthor 主题作者的公钥
|
|
138
|
-
* @param theme 主题/对象标识符
|
|
139
|
-
* @param vaccount 可选,虚拟账户
|
|
140
|
-
* @returns [授权列表, 评论列表, 错误信息]
|
|
141
|
-
*/
|
|
142
|
-
getAuthList(
|
|
143
|
-
themeAuthor: string,
|
|
144
|
-
theme: string,
|
|
145
|
-
vaccount?: string
|
|
146
|
-
): Promise<[ThemeAuthInfo[]|null,ThemeComment[] | null, Error | null]>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 获取指定用户发布的评论列表,无法查询用户设置为私密的评论
|
|
151
|
-
* @param userPubkey 用户公钥
|
|
152
|
-
* @param startHeight 可选,查询起始高度
|
|
153
|
-
* @param direction 可选,查询方向 (0:从新到旧, 1:从旧到新)
|
|
154
|
-
* @param offset 可选,结果集偏移量
|
|
155
|
-
* @param limit 可选,最大返回数量,默认100
|
|
156
|
-
* @param seekKey 可选,查询的起始键,格式为返回记录的 blockheight/key
|
|
157
|
-
* @returns 用户的评论列表
|
|
158
|
-
*/
|
|
159
|
-
getUserComments(
|
|
160
|
-
userPubkey: string,
|
|
161
|
-
startHeight?: number,
|
|
162
|
-
direction?: number,
|
|
163
|
-
offset?: number,
|
|
164
|
-
limit?: number,
|
|
165
|
-
seekKey?: string
|
|
166
|
-
): Promise<[ThemeComment[] | null, Error | null]>;
|
|
167
|
-
}
|
|
File without changes
|