web-dc-api 0.1.19 → 0.1.21

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/index.d.ts CHANGED
@@ -33,14 +33,14 @@ declare class Client {
33
33
 
34
34
  declare class Ed25519PubKey implements Ed25519PublicKey {
35
35
  raw: Uint8Array;
36
- type: 'Ed25519';
36
+ type: "Ed25519";
37
37
  constructor(publicKey: Uint8Array);
38
38
  private static readonly proto;
39
39
  bytes(): Uint8Array<ArrayBufferLike>;
40
40
  /**
41
- * Returns a multihash, the digest of which is the protobuf-encoded public key
42
- * encoded as an identity hash
43
- */
41
+ * Returns a multihash, the digest of which is the protobuf-encoded public key
42
+ * encoded as an identity hash
43
+ */
44
44
  toMultihash(): MultihashDigest<0>;
45
45
  toCID(): CID<unknown, 114, 0, 1>;
46
46
  equals(other: Ed25519PublicKey): boolean;
@@ -54,8 +54,8 @@ declare class Ed25519PubKey implements Ed25519PublicKey {
54
54
  string(): string;
55
55
  static unmarshalString(str: string): Ed25519PubKey;
56
56
  /**
57
- * Returns this key as a multihash with base58btc encoding
58
- */
57
+ * Returns this key as a multihash with base58btc encoding
58
+ */
59
59
  toString(): string;
60
60
  static fromString(str: string): Ed25519PubKey;
61
61
  toBase58(): string;
@@ -63,7 +63,7 @@ declare class Ed25519PubKey implements Ed25519PublicKey {
63
63
  static edPubkeyFromStr(pubkey: string): Ed25519PubKey;
64
64
  }
65
65
  declare class Ed25519PrivKey implements Ed25519PrivateKey {
66
- readonly type: 'Ed25519';
66
+ readonly type: "Ed25519";
67
67
  readonly raw: Uint8Array;
68
68
  readonly publicKey: Ed25519PubKey;
69
69
  constructor(privateKey: Uint8Array);
@@ -123,9 +123,9 @@ interface FileTransmit {
123
123
  interface APPInfo {
124
124
  appId: string;
125
125
  appName: string;
126
- appIcon: string;
127
- appUrl: string;
128
- appVersion: string;
126
+ appIcon?: string;
127
+ appUrl?: string;
128
+ appVersion?: string;
129
129
  }
130
130
  interface ThemeObj {
131
131
  theme: string;
@@ -377,11 +377,11 @@ declare class ChainUtil {
377
377
  getUserInfoWithAccount(account: string): Promise<User>;
378
378
  getUserInfoWithNftHex(nftHexAccount: string): Promise<User>;
379
379
  /**
380
- * 计算两个字节数组之间的XOR距离
381
- * @param key1 第一个字节数组
382
- * @param key2 第二个字节数组
383
- * @returns 两个键之间的XOR距离,以BigInt表示
384
- */
380
+ * 计算两个字节数组之间的XOR距离
381
+ * @param key1 第一个字节数组
382
+ * @param key2 第二个字节数组
383
+ * @returns 两个键之间的XOR距离,以BigInt表示
384
+ */
385
385
  calculateDistance(key1: Uint8Array, key2: Uint8Array): bigint;
386
386
  getUserInfoWithNft(nftAccount: string): Promise<User | null>;
387
387
  getUserWalletAccount(nftAccount: string): Promise<string | null>;
@@ -418,14 +418,14 @@ declare class DcUtil {
418
418
  _getNodeAddr: (peerId: string) => Promise<Multiaddr | undefined>;
419
419
  getDefaultDcNodeAddr: () => Promise<Multiaddr | undefined>;
420
420
  _getConnectDcNodeList: (nodeList: string[]) => Promise<Multiaddr | undefined>;
421
- _getRamdomNodeList: (nodeList: string[], num: number) => string[];
421
+ _getRandomNodeList: (nodeList: string[], num: number) => string[];
422
422
  createTransferStream(libp2p: Libp2p, blockstore: Blocks$1, nodeAddr: Multiaddr, type: number, oid: string): Promise<void>;
423
423
  private chunkGenerator;
424
424
  /**
425
- * 组装 CustomMessage 数据到 Uint8Array
426
- * @param message - CustomMessage 包含消息的基本结构
427
- * @returns Uint8Array - 序列化后的数据
428
- */
425
+ * 组装 CustomMessage 数据到 Uint8Array
426
+ * @param message - CustomMessage 包含消息的基本结构
427
+ * @returns Uint8Array - 序列化后的数据
428
+ */
429
429
  assembleCustomMessage(message: CustomMessage): Uint8Array;
430
430
  parseMessage(data: Uint8Array): {
431
431
  type: number;
@@ -3841,7 +3841,7 @@ interface IAuthOperations {
3841
3841
  * @param payload 要解密的数据
3842
3842
  * @returns 解密结果
3843
3843
  */
3844
- decryptWithWallet(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
3844
+ decrypt(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
3845
3845
  /**
3846
3846
  * 将公钥绑定NFT账号
3847
3847
  * @param account NFT账号
@@ -3891,6 +3891,7 @@ interface IAuthOperations {
3891
3891
  * @returns 用户信息
3892
3892
  */
3893
3893
  getUserInfoWithAccount(pubkeyAccount: string): Promise<[User | null, Error | null]>;
3894
+ getToken(publicKeyBase32: string): Promise<[boolean, Error | null]>;
3894
3895
  /**
3895
3896
  * 开启定时验证token线程
3896
3897
  */
@@ -27553,16 +27554,16 @@ declare class DBManager {
27553
27554
  network: Net, dc: DcUtil, connectedDc: DCConnectInfo, opts: NewOptions | undefined, chainUtil: ChainUtil, storagePrefix: string, context: DCContext);
27554
27555
  loadDbs(): Promise<void>;
27555
27556
  /**
27556
- * Gets the log key for a thread. If it doesn't exist, creates a new one.
27557
- * @param tid Thread ID
27558
- * @returns Promise resolving to the private key
27559
- * @throws Error if key operations fail
27560
- */
27557
+ * Gets the log key for a thread. If it doesn't exist, creates a new one.
27558
+ * @param tid Thread ID
27559
+ * @returns Promise resolving to the private key
27560
+ * @throws Error if key operations fail
27561
+ */
27561
27562
  getLogKey(tid: ThreadID): Promise<Ed25519PrivKey>;
27562
27563
  /**
27563
- * Creates a new log key
27564
- * @private
27565
- */
27564
+ * Creates a new log key
27565
+ * @private
27566
+ */
27566
27567
  private newLogKey;
27567
27568
  /**
27568
27569
  * FromAddr returns ID from a multiaddress if present.
@@ -27652,21 +27653,21 @@ declare class DBManager {
27652
27653
  private deleteThreadNamespace;
27653
27654
  /**********************数据库数据操作相关**********************/
27654
27655
  /**
27655
- * Create creates new instances of objects in a collection
27656
- * @param threadId Thread ID string
27657
- * @param collectionName Collection name
27658
- * @param jsonInstance JSON string representing the instance
27659
- * @returns Promise resolving to the created instance ID
27660
- * @throws Error if creation fails
27661
- */
27656
+ * Create creates new instances of objects in a collection
27657
+ * @param threadId Thread ID string
27658
+ * @param collectionName Collection name
27659
+ * @param jsonInstance JSON string representing the instance
27660
+ * @returns Promise resolving to the created instance ID
27661
+ * @throws Error if creation fails
27662
+ */
27662
27663
  create(threadId: string, collectionName: string, jsonInstance: string): Promise<string>;
27663
27664
  /**
27664
- * Delete deletes an instance by ID
27665
- * @param threadId Thread ID string
27666
- * @param collectionName Collection name
27667
- * @param instanceID Instance ID to delete
27668
- * @throws Error if deletion fails
27669
- */
27665
+ * Delete deletes an instance by ID
27666
+ * @param threadId Thread ID string
27667
+ * @param collectionName Collection name
27668
+ * @param instanceID Instance ID to delete
27669
+ * @throws Error if deletion fails
27670
+ */
27670
27671
  delete(threadId: string, collectionName: string, instanceID: string): Promise<void>;
27671
27672
  /**
27672
27673
  * Save updates an existing instance
@@ -27738,6 +27739,7 @@ interface DCContext {
27738
27739
  dbManager?: DBManager;
27739
27740
  publicKey: Ed25519PubKey | undefined;
27740
27741
  privateKey: Ed25519PrivKey | undefined | null;
27742
+ parentPublicKey: Ed25519PubKey | undefined | null;
27741
27743
  ethAddress: string | undefined;
27742
27744
  grpcServer: DCGrpcServer;
27743
27745
  sign(payload: Uint8Array): Promise<Uint8Array>;
@@ -28000,6 +28002,9 @@ declare class AuthModule implements DCModule, IAuthOperations {
28000
28002
  * @returns 是否登录成功
28001
28003
  */
28002
28004
  accountLoginWithWalletCall(accountInfo?: AccountInfo): Promise<Account>;
28005
+ getToken(publicKeyBase32: string): Promise<[boolean, Error | null]>;
28006
+ private getUserToken;
28007
+ private checkSpaceAfterLogin;
28003
28008
  /**
28004
28009
  * 账户登录(钱包登录)不抛出异常
28005
28010
  * @returns [账户信息, 错误信息]
@@ -28022,9 +28027,10 @@ declare class AuthModule implements DCModule, IAuthOperations {
28022
28027
  * @param mnemonic 助记词 (可选,如果是主账号登录则需要)
28023
28028
  */
28024
28029
  nftAccountPasswordModify(account: string, password: string, seccode: string, mnemonic?: string): Promise<[boolean | null, Error | null]>;
28025
- signWithWallet(payload: Uint8Array): Promise<Uint8Array>;
28030
+ signWith(payload: Uint8Array): Promise<Uint8Array>;
28026
28031
  sign(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
28027
- decryptWithWallet(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
28032
+ decrypt(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
28033
+ decryptWith(payload: Uint8Array): Promise<Uint8Array>;
28028
28034
  signMessageWithWallet(data: SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
28029
28035
  signEIP712MessageWithWallet(data: EIP712SignReqMessage): Promise<[SignResponseMessage | null, Error | null]>;
28030
28036
  /**
@@ -28797,8 +28803,9 @@ declare class DC implements DCContext {
28797
28803
  dcChain: ChainUtil;
28798
28804
  dcNodeClient: HeliaLibp2p<Libp2p$1>;
28799
28805
  dcutil: DcUtil;
28800
- privateKey: Ed25519PrivKey | undefined;
28806
+ privateKey: Ed25519PrivKey | undefined | null;
28801
28807
  publicKey: Ed25519PubKey | undefined;
28808
+ parentPublicKey: Ed25519PubKey | undefined | null;
28802
28809
  dbThreadId: string;
28803
28810
  ethAddress: string;
28804
28811
  connectedDc: DCConnectInfo;
@@ -28807,7 +28814,6 @@ declare class DC implements DCContext {
28807
28814
  Blockheight: number;
28808
28815
  grpcServer: DCGrpcServer;
28809
28816
  appInfo: APPInfo;
28810
- shouldReturnUserInfo: boolean;
28811
28817
  accountInfo: AccountInfo;
28812
28818
  userInfo: Account | null;
28813
28819
  dbManager: any;
@@ -28845,7 +28851,6 @@ declare class DC implements DCContext {
28845
28851
  init: (backStep?: (step: number) => Promise<void>) => Promise<boolean>;
28846
28852
  setAppInfo(appInfo: APPInfo): void;
28847
28853
  setAccountInfo(accountInfo: AccountInfo): void;
28848
- setShouldReturnUserInfo(shouldReturnUserInfo: boolean): void;
28849
28854
  /**
28850
28855
  * 获取当前用户的去中心数据库信息,如果用户数据库不存在,则会自动创建
28851
28856
  * @param collections 集合配置数组,定义数据库中的集合结构
@@ -28881,6 +28886,8 @@ declare class DC implements DCContext {
28881
28886
  * @returns 原始公钥字节数据
28882
28887
  */
28883
28888
  getPubkeyRaw(): Uint8Array;
28889
+ setParentPublicKey(parentPublicKey: Ed25519PubKey): void;
28890
+ setPrivateKey(appPrivateKey: Ed25519PrivKey | null): void;
28884
28891
  /**
28885
28892
  * 创建DC客户端
28886
28893
  * @param nodeAddr 节点地址
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-dc-api",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "web相关的dcapi",
5
5
  "type": "module",
6
6
  "browser": "dist/dc.min.js",
@@ -15,6 +15,11 @@
15
15
  "browser": "./dist/dc.min.js"
16
16
  }
17
17
  },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/dcnetio/web-dc-api.git"
21
+ },
22
+ "homepage": "https://github.com/dcnetio/web-dc-api#readme",
18
23
  "files": [
19
24
  "dist"
20
25
  ],