@secrecy/lib 1.29.0-feat-manage-user-data.2 → 1.29.0-feat-rename-file.3

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.
@@ -1,10 +1,10 @@
1
1
  import { BaseClient } from '../base-client.js';
2
- import { encryptSecretStream } from '../crypto/file.js';
2
+ import { encryptSecretStream } from '../crypto/data.js';
3
3
  import { sodium } from '../sodium.js';
4
4
  import { SecrecyCloudClient } from './SecrecyCloudClient.js';
5
5
  import { SecrecyMailClient } from './SecrecyMailClient.js';
6
6
  import { SecrecyAppClient } from './SecrecyAppClient.js';
7
- import { nodesCache, filesCache, publicKeysCache } from '../cache.js';
7
+ import { nodesCache, dataCache, publicKeysCache } from '../cache.js';
8
8
  import { SecrecyDbClient } from './SecrecyDbClient.js';
9
9
  import { SecrecyWalletClient } from './SecrecyWalletClient.js';
10
10
  import { SecrecyPayClient } from './SecrecyPayClient.js';
@@ -53,7 +53,7 @@ export class SecrecyClient extends BaseClient {
53
53
  }
54
54
  async logout(sessionId) {
55
55
  nodesCache.clear();
56
- filesCache.clear();
56
+ dataCache.clear();
57
57
  publicKeysCache.clear();
58
58
  await super.logout(sessionId);
59
59
  }
@@ -1,6 +1,6 @@
1
- import type { InternalNode, InternalFile, InternalNodeFull } from './client/types/index.js';
1
+ import type { InternalNode, InternalData, InternalNodeFull } from './client/types/index.js';
2
2
  import { LRUCache } from 'lru-cache';
3
- export declare const filesCache: Map<string, InternalFile>;
3
+ export declare const dataCache: Map<string, InternalData>;
4
4
  export declare const nodesCache: Map<string, InternalNode | InternalNodeFull>;
5
5
  export declare const usersCache: Map<string, {
6
6
  id: string;
@@ -10,4 +10,4 @@ export declare const usersCache: Map<string, {
10
10
  isSearchable: boolean;
11
11
  }>;
12
12
  export declare const publicKeysCache: Map<string, string>;
13
- export declare const dataCache: LRUCache<string, Uint8Array, unknown>;
13
+ export declare const lruCache: LRUCache<string, Uint8Array, unknown>;
@@ -1,22 +1,22 @@
1
1
  import type { ProgressCallback, SecrecyClient } from '../index.js';
2
- import type { FileMetadata, KeyPair, Node, NodeFull, NodeType, Rights } from './types/index.js';
2
+ import type { DataMetadata, KeyPair, Node, NodeFull, NodeType, Rights } from './types/index.js';
3
3
  import { type ApiClient } from '../client.js';
4
4
  import { type DownloadProgress } from '../types.js';
5
5
  export declare class SecrecyCloudClient {
6
6
  #private;
7
7
  constructor(client: SecrecyClient, keys: KeyPair, apiClient: ApiClient);
8
- addFileToHistory({ fileId, nodeId, }: {
9
- fileId: string;
8
+ addDataToHistory({ dataId, nodeId, }: {
9
+ dataId: string;
10
10
  nodeId: string;
11
11
  }): Promise<NodeFull>;
12
- uploadFile({ file, encryptProgress, uploadProgress, signal, }: {
13
- file: globalThis.File | Uint8Array;
12
+ uploadData({ data, encryptProgress, uploadProgress, signal, }: {
13
+ data: globalThis.File | Uint8Array;
14
14
  encryptProgress?: ProgressCallback;
15
15
  uploadProgress?: ProgressCallback;
16
16
  signal?: AbortSignal;
17
17
  }): Promise<string>;
18
- uploadFileInCloud({ file, name, nodeId, encryptProgress, uploadProgress, signal, }: {
19
- file: globalThis.File | Uint8Array;
18
+ uploadDataInCloud({ data, name, nodeId, encryptProgress, uploadProgress, signal, }: {
19
+ data: globalThis.File | Uint8Array;
20
20
  name: string;
21
21
  nodeId?: string;
22
22
  encryptProgress?: ProgressCallback;
@@ -46,9 +46,9 @@ export declare class SecrecyCloudClient {
46
46
  id?: string | null | undefined;
47
47
  deleted?: boolean | null | undefined;
48
48
  }): Promise<NodeFull>;
49
- fileMetadata({ id }: {
49
+ dataMetadata({ id }: {
50
50
  id: string;
51
- }): Promise<FileMetadata>;
51
+ }): Promise<DataMetadata>;
52
52
  shareNode({ nodeId, userId, rights, }: {
53
53
  nodeId: string;
54
54
  userId: string;
@@ -60,14 +60,14 @@ export declare class SecrecyCloudClient {
60
60
  isFavorite?: boolean | null | undefined;
61
61
  deletedAt?: Date | null | undefined;
62
62
  }): Promise<NodeFull>;
63
- fileContent({ fileId, onDownloadProgress, progressDecrypt, signal, }: {
64
- fileId: string;
63
+ dataContent({ dataId, onDownloadProgress, progressDecrypt, signal, }: {
64
+ dataId: string;
65
65
  onDownloadProgress?: (progress: DownloadProgress) => void;
66
66
  progressDecrypt?: ProgressCallback;
67
67
  signal?: AbortSignal;
68
68
  }): Promise<Uint8Array>;
69
- deleteFile({ fileId, nodeId, }: {
70
- fileId: string;
69
+ deleteData({ dataId, nodeId, }: {
70
+ dataId: string;
71
71
  nodeId: string;
72
72
  }): Promise<boolean>;
73
73
  deleteNode({ nodeId }: {
@@ -79,8 +79,8 @@ export declare class SecrecyCloudClient {
79
79
  nodeIds: string[];
80
80
  parentNodeId?: string | null | undefined;
81
81
  }): Promise<boolean>;
82
- saveInCloud({ fileId, name, nodeId, }: {
83
- fileId: string;
82
+ saveInCloud({ dataId, name, nodeId, }: {
83
+ dataId: string;
84
84
  name: string;
85
85
  nodeId?: string;
86
86
  }): Promise<NodeFull>;
@@ -0,0 +1,4 @@
1
+ import type { ApiData, InternalData, DataMetadata, KeyPair } from '../types/index.js';
2
+ export declare function apiDataToInternal(apiData: ApiData, keyPair: KeyPair): InternalData;
3
+ export declare function internalDataToExternalData(internal: InternalData): DataMetadata;
4
+ export declare function apiDataToExternal(apiData: ApiData, keyPair: KeyPair): DataMetadata;
@@ -1,5 +1,5 @@
1
1
  import { BaseClient } from '../base-client.js';
2
- import type { Progress } from '../crypto/file.js';
2
+ import type { Progress } from '../crypto/data.js';
3
3
  import { SecrecyCloudClient } from './SecrecyCloudClient.js';
4
4
  import { SecrecyMailClient } from './SecrecyMailClient.js';
5
5
  import { SecrecyAppClient } from './SecrecyAppClient.js';
@@ -0,0 +1,6 @@
1
+ import { type RouterOutputs } from '../../client.js';
2
+ export type DataMetadata = Pick<ApiData, 'id' | 'size' | 'sizeBefore' | 'md5' | 'md5Encrypted' | 'createdAt'>;
3
+ export type InternalData = DataMetadata & {
4
+ key: string;
5
+ };
6
+ export type ApiData = NonNullable<RouterOutputs['cloud']['dataById']>;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export type * from './app.js';
3
- export type * from './file.js';
3
+ export type * from './data.js';
4
4
  export type * from './node.js';
5
5
  export type * from './mail.js';
6
6
  export type * from './user.js';
@@ -15,7 +15,7 @@ export interface BaseMail {
15
15
  isAltered: boolean;
16
16
  recipients: Array<Omit<PublicUser, 'publicKey'>>;
17
17
  temporaryRecipients: TemporaryMailUser[];
18
- files: Array<{
18
+ data: Array<{
19
19
  id: string;
20
20
  name: string;
21
21
  key: string;
@@ -74,10 +74,10 @@ export interface WaitingReceivedMail {
74
74
  recipients: PublicUser[];
75
75
  temporaryRecipients: TemporaryMailUser[];
76
76
  }
77
- export interface MailFile {
78
- fileKey: string;
79
- filename: string;
80
- file: {
77
+ export interface MailData {
78
+ dataKey: string;
79
+ dataName: string;
80
+ data: {
81
81
  id: string;
82
82
  };
83
83
  }
@@ -1,5 +1,5 @@
1
1
  import { type RouterOutputs } from '../../client.js';
2
- import type { FileMetadata, InternalFile, PublicUser } from './index.js';
2
+ import type { DataMetadata, InternalData, PublicUser } from './index.js';
3
3
  export type Rights = ApiNode['users'][number][1];
4
4
  export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T & {
5
5
  rights: Rights;
@@ -34,17 +34,17 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
34
34
  createdBy: PublicUser;
35
35
  access: NodeAccess<U>;
36
36
  users: Array<[PublicUser, Rights]>;
37
- currentFileId: string | null;
37
+ currentDataId: string | null;
38
38
  parentId: string | null;
39
39
  }
40
- export type NodeFull<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U extends Record<string, unknown> = Record<string, unknown>, V extends FileMetadata = FileMetadata> = Node<T, U> & {
40
+ export type NodeFull<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U extends Record<string, unknown> = Record<string, unknown>, V extends DataMetadata = DataMetadata> = Node<T, U> & {
41
41
  parent: Node<T, U> | null;
42
42
  children: Array<Node<T, U>>;
43
43
  current?: V;
44
44
  history: V[];
45
45
  };
46
46
  export type InternalNode = Node<InternalNodeBreadcrumbItem, NameKey>;
47
- export type InternalNodeFull = NodeFull<InternalNodeBreadcrumbItem, NameKey, InternalFile>;
47
+ export type InternalNodeFull = NodeFull<InternalNodeBreadcrumbItem, NameKey, InternalData>;
48
48
  export type ApiNode = RouterOutputs['cloud']['nodeById'];
49
49
  export type ApiNodeFull = RouterOutputs['cloud']['nodeFullById'];
50
50
  export type ApiNodeParent = NonNullable<RouterOutputs['cloud']['nodeFullById']['parent']>;