@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.
- package/dist/lib/cache.js +2 -2
- package/dist/lib/client/SecrecyAppClient.js +2 -2
- package/dist/lib/client/SecrecyCloudClient.js +91 -91
- package/dist/lib/client/SecrecyMailClient.js +36 -29
- package/dist/lib/client/convert/data.js +29 -0
- package/dist/lib/client/convert/mail.js +4 -4
- package/dist/lib/client/convert/node.js +7 -7
- package/dist/lib/client/index.js +3 -3
- package/dist/types/cache.d.ts +3 -3
- package/dist/types/client/SecrecyCloudClient.d.ts +15 -15
- package/dist/types/client/convert/data.d.ts +4 -0
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/types/data.d.ts +6 -0
- package/dist/types/client/types/index.d.ts +1 -1
- package/dist/types/client/types/mail.d.ts +5 -5
- package/dist/types/client/types/node.d.ts +4 -4
- package/dist/types/client.d.ts +392 -390
- package/dist/types/index.d.ts +2 -2
- package/dist/types/worker/sodium.d.ts +1 -1
- package/package.json +2 -2
- package/dist/lib/client/convert/file.js +0 -29
- package/dist/types/client/convert/file.d.ts +0 -4
- package/dist/types/client/types/file.d.ts +0 -6
- /package/dist/lib/client/types/{file.js → data.js} +0 -0
- /package/dist/lib/crypto/{file.js → data.js} +0 -0
- /package/dist/types/crypto/{file.d.ts → data.d.ts} +0 -0
package/dist/lib/client/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseClient } from '../base-client.js';
|
|
2
|
-
import { encryptSecretStream } from '../crypto/
|
|
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,
|
|
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
|
-
|
|
56
|
+
dataCache.clear();
|
|
57
57
|
publicKeysCache.clear();
|
|
58
58
|
await super.logout(sessionId);
|
|
59
59
|
}
|
package/dist/types/cache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { InternalNode,
|
|
1
|
+
import type { InternalNode, InternalData, InternalNodeFull } from './client/types/index.js';
|
|
2
2
|
import { LRUCache } from 'lru-cache';
|
|
3
|
-
export declare const
|
|
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
|
|
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 {
|
|
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
|
-
|
|
9
|
-
|
|
8
|
+
addDataToHistory({ dataId, nodeId, }: {
|
|
9
|
+
dataId: string;
|
|
10
10
|
nodeId: string;
|
|
11
11
|
}): Promise<NodeFull>;
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
49
|
+
dataMetadata({ id }: {
|
|
50
50
|
id: string;
|
|
51
|
-
}): Promise<
|
|
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
|
-
|
|
64
|
-
|
|
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
|
-
|
|
70
|
-
|
|
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({
|
|
83
|
-
|
|
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/
|
|
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']>;
|
|
@@ -15,7 +15,7 @@ export interface BaseMail {
|
|
|
15
15
|
isAltered: boolean;
|
|
16
16
|
recipients: Array<Omit<PublicUser, 'publicKey'>>;
|
|
17
17
|
temporaryRecipients: TemporaryMailUser[];
|
|
18
|
-
|
|
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
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
|
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,
|
|
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']>;
|