web-dc-api 0.1.11 → 0.1.13

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
@@ -3858,7 +3858,7 @@ interface IAuthOperations {
3858
3858
  * @param seccode 安全码
3859
3859
  * @param mnemonic 助记词 (可选,如果是主账号登录则需要)
3860
3860
  */
3861
- nftAccountPasswordModify(account: string, password: string, seccode: string, mnemonic?: string): Promise<Error | null>;
3861
+ nftAccountPasswordModify(account: string, password: string, seccode: string, mnemonic?: string): Promise<[boolean | null, Error | null]>;
3862
3862
  /**
3863
3863
  * 创建APP访问账号,返回APP专用私钥
3864
3864
  * @param appId 应用ID
@@ -4164,6 +4164,10 @@ declare class SeekableFileStream {
4164
4164
  start?: number;
4165
4165
  end?: number;
4166
4166
  }): ReadableStream<Uint8Array>;
4167
+ /**
4168
+ * 获取文件CID
4169
+ */
4170
+ getCid(): CID;
4167
4171
  }
4168
4172
 
4169
4173
  /**
@@ -4178,6 +4182,14 @@ interface IFileOperations {
4178
4182
  * @returns 可寻址文件流实例
4179
4183
  */
4180
4184
  getSeekableFileStream(ipfsPath: string, decryptKey: string): Promise<SeekableFileStream>;
4185
+ /**
4186
+ * 获取指定文件夹CID中指定路径的文件流
4187
+ * @param rootCid 根文件夹CID
4188
+ * @param filePath 文件相对路径
4189
+ * @param decryptKey 解密密钥
4190
+ * @returns 可寻址文件流实例
4191
+ */
4192
+ getSeekableFileStreamFromDir(rootCid: string, filePath: string, decryptKey: string): Promise<SeekableFileStream>;
4181
4193
  /**
4182
4194
  * 清理文件缓存
4183
4195
  * @param pathname 可选的特定路径,不提供则清除所有缓存
@@ -4198,6 +4210,21 @@ interface IFileOperations {
4198
4210
  * @returns 文件的字节数组,失败则返回undefined
4199
4211
  */
4200
4212
  getFile(cid: string, decryptKey: string): Promise<[Uint8Array | null, Error | null]>;
4213
+ /**
4214
+ * 获取指定文件夹CID中指定路径的文件内容或目录列表
4215
+ * @param rootCid 根文件夹CID
4216
+ * @param filePath 文件相对路径
4217
+ * @param decryptKey 解密密钥
4218
+ * @returns 文件的字节数组或目录列表,失败则返回undefined
4219
+ */
4220
+ getFileFromDir(rootCid: string, filePath: string, decryptKey: string): Promise<[Uint8Array | Array<{
4221
+ Name: string;
4222
+ Type: number;
4223
+ Size: number;
4224
+ Hash: string;
4225
+ Path: string;
4226
+ Content?: Uint8Array;
4227
+ }> | null, Error | null]>;
4201
4228
  /**
4202
4229
  * 创建文件可读流
4203
4230
  * @param cid 文件的内容标识符
@@ -4258,6 +4285,12 @@ interface IFileOperations {
4258
4285
  * @returns 自定义文件列表对象
4259
4286
  */
4260
4287
  createCustomFileList(filesMap: Map<string, string | Uint8Array | ArrayBuffer> | Record<string, string | Uint8Array | ArrayBuffer>, rootFolderName: string): [FileList | null, Error | null];
4288
+ /**
4289
+ * 判断CID是文件还是目录
4290
+ * @param cid
4291
+ * @returns 'file' | 'directory' | 'unknown'
4292
+ */
4293
+ isFileOrDir(cid: string): Promise<'file' | 'directory' | 'unknown'>;
4261
4294
  }
4262
4295
 
4263
4296
  /** Namespace dcnet. */
@@ -27853,6 +27886,10 @@ declare class FileModule implements DCModule, IFileOperations {
27853
27886
  * 获取可寻址文件流
27854
27887
  */
27855
27888
  getSeekableFileStream(ipfsPath: string, decryptKey: string): Promise<SeekableFileStream>;
27889
+ /**
27890
+ * 获取指定文件夹CID中指定路径的文件流
27891
+ */
27892
+ getSeekableFileStreamFromDir(rootCid: string, filePath: string, decryptKey: string): Promise<SeekableFileStream>;
27856
27893
  /**
27857
27894
  * 清理文件缓存
27858
27895
  */
@@ -27917,10 +27954,25 @@ declare class FileModule implements DCModule, IFileOperations {
27917
27954
  * @returns A FileList-like object that can be used with addFolder
27918
27955
  */
27919
27956
  createCustomFileList(filesMap: Map<string, string | Uint8Array | ArrayBuffer> | Record<string, string | Uint8Array | ArrayBuffer>, rootFolderName?: string): [FileList | null, Error | null];
27957
+ /**
27958
+ * 判断CID是文件还是目录
27959
+ */
27960
+ isFileOrDir(cid: string): Promise<'file' | 'directory' | 'unknown'>;
27920
27961
  /**
27921
27962
  * 断言模块已初始化
27922
27963
  */
27923
27964
  private assertInitialized;
27965
+ /**
27966
+ * 获取指定文件夹CID中指定路径的文件内容或目录列表
27967
+ */
27968
+ getFileFromDir(rootCid: string, filePath: string, decryptKey: string): Promise<[Uint8Array | Array<{
27969
+ Name: string;
27970
+ Type: number;
27971
+ Size: number;
27972
+ Hash: string;
27973
+ Path: string;
27974
+ Content?: Uint8Array;
27975
+ }> | null, Error | null]>;
27924
27976
  }
27925
27977
 
27926
27978
  /**
@@ -27952,10 +28004,7 @@ declare class AuthModule implements DCModule, IAuthOperations {
27952
28004
  * 账户登录(钱包登录)不抛出异常
27953
28005
  * @returns [账户信息, 错误信息]
27954
28006
  */
27955
- accountLoginWithWallet(accountInfo?: AccountInfo): Promise<[
27956
- Account | null,
27957
- Error | null
27958
- ]>;
28007
+ accountLoginWithWallet(accountInfo?: AccountInfo): Promise<[Account | null, Error | null]>;
27959
28008
  exitLogin(): void;
27960
28009
  /**
27961
28010
  * 账户登录(钱包登录)不抛出异常
@@ -27972,7 +28021,7 @@ declare class AuthModule implements DCModule, IAuthOperations {
27972
28021
  * @param seccode 安全码
27973
28022
  * @param mnemonic 助记词 (可选,如果是主账号登录则需要)
27974
28023
  */
27975
- nftAccountPasswordModify(account: string, password: string, seccode: string, mnemonic?: string): Promise<Error | null>;
28024
+ nftAccountPasswordModify(account: string, password: string, seccode: string, mnemonic?: string): Promise<[boolean | null, Error | null]>;
27976
28025
  signWithWallet(payload: Uint8Array): Promise<Uint8Array>;
27977
28026
  sign(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
27978
28027
  decryptWithWallet(payload: Uint8Array): Promise<[Uint8Array | null, Error | null]>;
@@ -28021,10 +28070,7 @@ declare class AuthModule implements DCModule, IAuthOperations {
28021
28070
  /**
28022
28071
  * 开启定时验证 token 线程,不抛出异常
28023
28072
  */
28024
- startDcPeerTokenKeepValidTask(): Promise<[
28025
- boolean,
28026
- Error | null
28027
- ]>;
28073
+ startDcPeerTokenKeepValidTask(): Promise<[boolean, Error | null]>;
28028
28074
  /**
28029
28075
  * 停止token验证任务,不抛出异常
28030
28076
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-dc-api",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "web相关的dcapi",
5
5
  "type": "module",
6
6
  "browser": "dist/dc.min.js",