@secrecy/lib 1.10.0 → 1.11.0
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/base-client.js +1 -1
- package/dist/lib/cache.js +9 -0
- package/dist/lib/client/SecrecyCloudClient.js +19 -14
- package/dist/lib/client/SecrecyMailClient.js +3 -4
- package/dist/lib/client/convert/node.js +4 -5
- package/dist/lib/client/index.js +2 -2
- package/dist/lib/crypto/file.js +12 -12
- package/dist/lib/index.js +0 -3
- package/dist/lib/utils.js +2 -0
- package/dist/types/base-client.d.ts +1 -1
- package/dist/types/cache.d.ts +2 -0
- package/dist/types/client.d.ts +88 -0
- package/dist/types/crypto/file.d.ts +3 -3
- package/dist/types/index.d.ts +0 -2
- package/dist/types/utils.d.ts +2 -0
- package/package.json +3 -2
package/dist/lib/base-client.js
CHANGED
|
@@ -58,7 +58,7 @@ export class BaseClient {
|
|
|
58
58
|
}
|
|
59
59
|
async updateProfile(data) {
|
|
60
60
|
const updateProfile = await this.client.user.updateProfile.mutate(data);
|
|
61
|
-
return updateProfile;
|
|
61
|
+
return updateProfile;
|
|
62
62
|
}
|
|
63
63
|
static async isCryptoTransactionDone({ idOrHash, network = 'mainnet', }) {
|
|
64
64
|
const { isDone } = await this.getBaseClient().crypto.isTransactionDone.query({
|
package/dist/lib/cache.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import { LRUCache } from 'lru-cache';
|
|
2
|
+
import { gigaToBytes } from './utils.js';
|
|
1
3
|
export const filesCache = new Map();
|
|
2
4
|
export const nodesCache = new Map();
|
|
3
5
|
export const usersCache = new Map();
|
|
4
6
|
export const publicKeysCache = new Map();
|
|
7
|
+
export const dataCache = new LRUCache({
|
|
8
|
+
max: 500,
|
|
9
|
+
maxSize: gigaToBytes(0.5),
|
|
10
|
+
sizeCalculation: (value) => {
|
|
11
|
+
return value.byteLength;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import ky from 'ky';
|
|
3
3
|
import { encryptName } from '../index.js';
|
|
4
|
-
import { nodesCache, filesCache } from '../cache.js';
|
|
5
|
-
import {
|
|
4
|
+
import { nodesCache, filesCache, dataCache } from '../cache.js';
|
|
5
|
+
import { secretStreamKeygen } from '../crypto/file.js';
|
|
6
6
|
import { decryptCryptoBox, encryptCryptoBox } from '../crypto/index.js';
|
|
7
7
|
import { compress, decompress } from '../minify/index.js';
|
|
8
8
|
import { sodium } from '../sodium.js';
|
|
@@ -35,16 +35,19 @@ export class SecrecyCloudClient {
|
|
|
35
35
|
await this.#apiClient.cloud.shareFileInHistory.mutate({
|
|
36
36
|
fileId: file.id,
|
|
37
37
|
nodeId,
|
|
38
|
-
users: users.map(([u]) =>
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
users: await Promise.all(users.map(async ([u]) => {
|
|
39
|
+
const userPubKey = await this.#client.app.userPublicKey(u.id);
|
|
40
|
+
return {
|
|
41
|
+
id: u.id,
|
|
42
|
+
key: sodium.to_hex(encryptCryptoBox(sodium.from_hex(file.key), userPubKey, this.#keys.privateKey)),
|
|
43
|
+
};
|
|
41
44
|
})),
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
return internalNodeFullToNodeFull(node);
|
|
45
48
|
}
|
|
46
49
|
async uploadFile({ file, encryptProgress, uploadProgress, signal, }) {
|
|
47
|
-
const fileKey =
|
|
50
|
+
const fileKey = secretStreamKeygen();
|
|
48
51
|
const fileBuffer = file instanceof File ? new Uint8Array(await file.arrayBuffer()) : file;
|
|
49
52
|
const compressed = compress(fileBuffer);
|
|
50
53
|
const { data: encryptedFile, md5: md5File, md5Encrypted, } = await encrypt(fileKey, compressed, encryptProgress, signal);
|
|
@@ -118,16 +121,12 @@ export class SecrecyCloudClient {
|
|
|
118
121
|
signal,
|
|
119
122
|
});
|
|
120
123
|
await uploadPartEnded(chunk.md5, chunk.order);
|
|
121
|
-
// if ((e as any).response.status === 0) {
|
|
122
|
-
// // TODO https://github.com/sindresorhus/ky/issues/305
|
|
123
|
-
// } else {
|
|
124
|
-
// throw e;
|
|
125
|
-
// }
|
|
126
124
|
};
|
|
127
125
|
await promiseAllLimit(3, uploadFile.parts.map((p) => async () => {
|
|
128
126
|
await byPart(p);
|
|
129
127
|
}));
|
|
130
128
|
await uploadEnded();
|
|
129
|
+
dataCache.set(uploadFile.fileId, fileBuffer);
|
|
131
130
|
return uploadFile.fileId;
|
|
132
131
|
}
|
|
133
132
|
async uploadFileInCloud({ file, name, nodeId, encryptProgress, uploadProgress, signal, }) {
|
|
@@ -194,7 +193,7 @@ export class SecrecyCloudClient {
|
|
|
194
193
|
return isDeleted;
|
|
195
194
|
}
|
|
196
195
|
async createFolder({ name, parentFolderId, }) {
|
|
197
|
-
const key =
|
|
196
|
+
const key = secretStreamKeygen();
|
|
198
197
|
const encryptedName = await encryptName(name, sodium.to_hex(key));
|
|
199
198
|
const encryptedKey = encryptCryptoBox(key, this.#keys.publicKey, this.#keys.privateKey);
|
|
200
199
|
const createFolder = await this.#apiClient.cloud.createFolder.mutate({
|
|
@@ -272,6 +271,10 @@ export class SecrecyCloudClient {
|
|
|
272
271
|
return await apiNodeToExternalNodeFull(updateNode, this.#keys);
|
|
273
272
|
}
|
|
274
273
|
async fileContent({ fileId, onDownloadProgress, progressDecrypt, signal, }) {
|
|
274
|
+
const cached = dataCache.get(fileId);
|
|
275
|
+
if (cached !== undefined) {
|
|
276
|
+
return cached;
|
|
277
|
+
}
|
|
275
278
|
const fileContent = await this.#apiClient.cloud.fileContentById.query({
|
|
276
279
|
id: fileId,
|
|
277
280
|
});
|
|
@@ -344,7 +347,9 @@ export class SecrecyCloudClient {
|
|
|
344
347
|
if (encryptedContent === null) {
|
|
345
348
|
throw `Can't find content for file ${fileId}`;
|
|
346
349
|
}
|
|
347
|
-
|
|
350
|
+
const data = await finalize(encryptedContent);
|
|
351
|
+
dataCache.set(fileId, data);
|
|
352
|
+
return data;
|
|
348
353
|
}
|
|
349
354
|
async deleteFile({ fileId, nodeId, }) {
|
|
350
355
|
const { isDeleted } = await this.#apiClient.cloud.deleteFile.mutate({
|
|
@@ -425,7 +430,7 @@ export class SecrecyCloudClient {
|
|
|
425
430
|
key = file.key;
|
|
426
431
|
}
|
|
427
432
|
key = sodium.to_hex(encryptCryptoBox(sodium.from_hex(key), this.#keys.publicKey, this.#keys.privateKey));
|
|
428
|
-
const nameKey =
|
|
433
|
+
const nameKey = secretStreamKeygen();
|
|
429
434
|
const encryptedName = await encryptName(name, sodium.to_hex(nameKey));
|
|
430
435
|
const encryptedNameKey = sodium.to_hex(encryptCryptoBox(nameKey, this.#keys.publicKey, this.#keys.privateKey));
|
|
431
436
|
const saveInCloud = await this.#apiClient.cloud.saveInCloud.mutate({
|
|
@@ -123,7 +123,7 @@ export class SecrecyMailClient {
|
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
125
|
const temporaryRecipients = new Array();
|
|
126
|
-
const recipients = new Array();
|
|
126
|
+
const recipients = new Array();
|
|
127
127
|
for (const { email } of draft.temporaryRecipients) {
|
|
128
128
|
if (email === undefined) {
|
|
129
129
|
continue;
|
|
@@ -154,7 +154,7 @@ export class SecrecyMailClient {
|
|
|
154
154
|
return isSent;
|
|
155
155
|
}
|
|
156
156
|
async sendWaitingEmails() {
|
|
157
|
-
// TODO
|
|
157
|
+
// TODO optimize this
|
|
158
158
|
const mails = await this.sentMails();
|
|
159
159
|
const filtered = mails.filter((m) => m.temporaryRecipients.length > 0);
|
|
160
160
|
for (const mail of filtered) {
|
|
@@ -196,8 +196,7 @@ export class SecrecyMailClient {
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
const createDraftMail = await this.#apiClient.mail.createDraft.mutate({
|
|
199
|
-
|
|
200
|
-
recipients, // TODO
|
|
199
|
+
recipients,
|
|
201
200
|
replyToId,
|
|
202
201
|
body: sodium.to_hex(encryptCryptoBox(sodium.from_string(body), this.#keys.publicKey, this.#keys.privateKey)),
|
|
203
202
|
subject: sodium.to_hex(encryptCryptoBox(sodium.from_string(subject), this.#keys.publicKey, this.#keys.privateKey)),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sodium } from '../../sodium.js';
|
|
2
2
|
import { decryptCryptoBox } from '../../crypto/index.js';
|
|
3
3
|
import { nodesCache } from '../../cache.js';
|
|
4
|
-
import {
|
|
4
|
+
import { decryptSecretStream } from '../../crypto/file.js';
|
|
5
5
|
import { apiFileToInternal, internalFileToFile } from './file.js';
|
|
6
6
|
export async function apiNodeToInternal(apiNode, keyPair) {
|
|
7
7
|
const internal = {
|
|
@@ -23,13 +23,12 @@ export async function apiNodeToInternal(apiNode, keyPair) {
|
|
|
23
23
|
deletedAt: apiNode.deletedAt,
|
|
24
24
|
users: apiNode.users,
|
|
25
25
|
parentId: apiNode.parentId ?? null,
|
|
26
|
-
currentFileId: null,
|
|
27
|
-
// currentFileId: apiNode.currentFiledId ?? null,
|
|
26
|
+
currentFileId: apiNode.currentFileId ?? null,
|
|
28
27
|
};
|
|
29
28
|
internal.access = { ...apiNode.access };
|
|
30
29
|
if (apiNode.access.nameKey !== null) {
|
|
31
30
|
const key = decryptCryptoBox(sodium.from_hex(apiNode.access.nameKey), apiNode.access.sharedByPubKey, keyPair.privateKey);
|
|
32
|
-
internal.name = sodium.to_string(await
|
|
31
|
+
internal.name = sodium.to_string(await decryptSecretStream(key, sodium.from_hex(internal.name)));
|
|
33
32
|
internal.access.nameKey = sodium.to_hex(key);
|
|
34
33
|
}
|
|
35
34
|
for (const b of internal.breadcrumb) {
|
|
@@ -38,7 +37,7 @@ export async function apiNodeToInternal(apiNode, keyPair) {
|
|
|
38
37
|
}
|
|
39
38
|
const key = decryptCryptoBox(sodium.from_hex(b.nameKey), b.pubKey, keyPair.privateKey);
|
|
40
39
|
b.nameKey = sodium.to_hex(key);
|
|
41
|
-
b.name = sodium.to_string(await
|
|
40
|
+
b.name = sodium.to_string(await decryptSecretStream(key, sodium.from_hex(b.name)));
|
|
42
41
|
}
|
|
43
42
|
nodesCache.set(internal.id, internal);
|
|
44
43
|
return internal;
|
package/dist/lib/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient } from '../base-client.js';
|
|
2
|
-
import {
|
|
2
|
+
import { encryptSecretStream } from '../crypto/file.js';
|
|
3
3
|
import { sodium } from '../sodium.js';
|
|
4
4
|
import { SecrecyCloudClient } from './SecrecyCloudClient.js';
|
|
5
5
|
import { SecrecyMailClient } from './SecrecyMailClient.js';
|
|
@@ -11,7 +11,7 @@ import { SecrecyPayClient } from './SecrecyPayClient.js';
|
|
|
11
11
|
import { SecrecyUserClient } from './SecrecyUserClient.js';
|
|
12
12
|
import { SecrecyCareClient } from './SecrecryCareClient.js';
|
|
13
13
|
export const encryptName = async (name, nameKey) => {
|
|
14
|
-
const { data } = await
|
|
14
|
+
const { data } = await encryptSecretStream(sodium.from_hex(nameKey), sodium.from_string(name));
|
|
15
15
|
const nameEncrypted = sodium.to_hex(data);
|
|
16
16
|
return nameEncrypted;
|
|
17
17
|
};
|
package/dist/lib/crypto/file.js
CHANGED
|
@@ -6,7 +6,7 @@ function assert(c, message) {
|
|
|
6
6
|
throw new Error(message);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
export function
|
|
9
|
+
export function secretStreamKeygen() {
|
|
10
10
|
return sodium.crypto_secretstream_xchacha20poly1305_keygen();
|
|
11
11
|
}
|
|
12
12
|
function encrypt(key) {
|
|
@@ -46,7 +46,7 @@ function decrypt(header, key) {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
export const CHUNK_SIZE = 8192;
|
|
49
|
-
export async function
|
|
49
|
+
export async function encryptSecretStream(key, data, progress, abort) {
|
|
50
50
|
await setup();
|
|
51
51
|
const { encrypt: crypt, destroy, header } = encrypt(key);
|
|
52
52
|
const encryptedChunk = CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;
|
|
@@ -102,11 +102,11 @@ export async function encryptSecretstream(key, data, progress, abort) {
|
|
|
102
102
|
md5: spark.end(),
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
export async function
|
|
105
|
+
export async function decryptSecretStream(key, data, progress, abort) {
|
|
106
106
|
await setup();
|
|
107
107
|
const header = data.slice(0, sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES);
|
|
108
108
|
data = data.slice(sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES);
|
|
109
|
-
const { decrypt:
|
|
109
|
+
const { decrypt: decryptFn, destroy } = decrypt(header, key);
|
|
110
110
|
const chunkSize = CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;
|
|
111
111
|
const max = Math.ceil(data.byteLength / chunkSize) * CHUNK_SIZE;
|
|
112
112
|
void progress?.({
|
|
@@ -121,9 +121,9 @@ export async function decryptSecretstream(key, data, progress, abort) {
|
|
|
121
121
|
if (abort?.signal.aborted === true) {
|
|
122
122
|
throw new Error(`Decrypt aborted`);
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
final.set(
|
|
126
|
-
total +=
|
|
124
|
+
const messageTag = decryptFn(chunk);
|
|
125
|
+
final.set(messageTag.message, total);
|
|
126
|
+
total += messageTag.message.byteLength;
|
|
127
127
|
const percent = total / max;
|
|
128
128
|
if (percent > lastPercent + 0.01) {
|
|
129
129
|
void progress?.({
|
|
@@ -142,13 +142,13 @@ export async function decryptSecretstream(key, data, progress, abort) {
|
|
|
142
142
|
});
|
|
143
143
|
return final.slice(0, total);
|
|
144
144
|
}
|
|
145
|
-
// async function
|
|
145
|
+
// async function mainSecretStream(random: Uint8Array): Promise<vo id> {
|
|
146
146
|
// const key = secretstreamKeygen();
|
|
147
147
|
// console.time("secretstream_encrypt");
|
|
148
|
-
// const crypted = en
|
|
148
|
+
// const crypted = en cryptSecretStream(key, random);
|
|
149
149
|
// consol e.timeEnd("secretstream_encrypt");
|
|
150
150
|
// console.time("secretstream_decrypt");
|
|
151
|
-
// const decrypted =
|
|
151
|
+
// const decrypted = decryptSecretStream(key, crypted);
|
|
152
152
|
// con sole.timeEnd("secretstream_decrypt");
|
|
153
153
|
// const first = t o_hex(random).slice(0, 32);
|
|
154
154
|
// const final = to_hex(decrypted).slice(0, 32);
|
|
@@ -158,7 +158,7 @@ export async function decryptSecretstream(key, data, progress, abort) {
|
|
|
158
158
|
// equals: firs t === final
|
|
159
159
|
// }) ;
|
|
160
160
|
// }
|
|
161
|
-
// async function
|
|
161
|
+
// async function mainSecretBox(random: Uint8Array): Promise< void> {
|
|
162
162
|
// const key = generateSecretBox();
|
|
163
163
|
// console.time("secretbox _encrypt");
|
|
164
164
|
// const crypted = encryptFile(random, key);
|
|
@@ -179,6 +179,6 @@ export async function decryptSecretstream(key, data, progress, abort) {
|
|
|
179
179
|
// console.time("randombytes_buf");
|
|
180
180
|
// const random = randombytes_buf(1_000_000 * 1024);
|
|
181
181
|
// consol e.timeEnd("randombytes_buf");
|
|
182
|
-
// await Promise.all([
|
|
182
|
+
// await Promise.all([mainSecretStream(random), mainSecretBox(random)]);
|
|
183
183
|
// }
|
|
184
184
|
// main();
|
package/dist/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export declare class BaseClient {
|
|
|
12
12
|
static getUser(userId: string, sessionId?: string | null | undefined): Promise<PublicUser>;
|
|
13
13
|
getUser(userId: string): Promise<PublicUser>;
|
|
14
14
|
searchUsers(search: string): Promise<PublicUser[]>;
|
|
15
|
-
updateProfile(data: RouterInputs['user']['updateProfile']): Promise<SelfUser
|
|
15
|
+
updateProfile(data: RouterInputs['user']['updateProfile']): Promise<Omit<SelfUser, 'account'>>;
|
|
16
16
|
static isCryptoTransactionDone({ idOrHash, network, }: {
|
|
17
17
|
idOrHash: string;
|
|
18
18
|
network?: InfuraNetwork;
|
package/dist/types/cache.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InternalNode, InternalFile, InternalNodeFull } from './client/types/index.js';
|
|
2
|
+
import { LRUCache } from 'lru-cache';
|
|
2
3
|
export declare const filesCache: Map<string, InternalFile>;
|
|
3
4
|
export declare const nodesCache: Map<string, InternalNode | InternalNodeFull>;
|
|
4
5
|
export declare const usersCache: Map<string, {
|
|
@@ -9,3 +10,4 @@ export declare const usersCache: Map<string, {
|
|
|
9
10
|
isSearchable: boolean;
|
|
10
11
|
}>;
|
|
11
12
|
export declare const publicKeysCache: Map<string, string>;
|
|
13
|
+
export declare const dataCache: LRUCache<string, Uint8Array, unknown>;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1783,6 +1783,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
1783
1783
|
type: "FILE" | "FOLDER";
|
|
1784
1784
|
parentId: string | null;
|
|
1785
1785
|
isFavorite: boolean;
|
|
1786
|
+
currentFileId: string | null;
|
|
1786
1787
|
} & {
|
|
1787
1788
|
users: [{
|
|
1788
1789
|
id: string;
|
|
@@ -1847,6 +1848,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
1847
1848
|
type: "FILE" | "FOLDER";
|
|
1848
1849
|
parentId: string | null;
|
|
1849
1850
|
isFavorite: boolean;
|
|
1851
|
+
currentFileId: string | null;
|
|
1850
1852
|
} & {
|
|
1851
1853
|
users: [{
|
|
1852
1854
|
id: string;
|
|
@@ -1878,6 +1880,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
1878
1880
|
type: "FILE" | "FOLDER";
|
|
1879
1881
|
parentId: string | null;
|
|
1880
1882
|
isFavorite: boolean;
|
|
1883
|
+
currentFileId: string | null;
|
|
1881
1884
|
} & {
|
|
1882
1885
|
users: [{
|
|
1883
1886
|
id: string;
|
|
@@ -1899,6 +1902,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
1899
1902
|
isRoot: boolean;
|
|
1900
1903
|
sharedByPubKey: string;
|
|
1901
1904
|
};
|
|
1905
|
+
} & {
|
|
1906
|
+
sizes: {
|
|
1907
|
+
size: bigint;
|
|
1908
|
+
sizeBefore: bigint;
|
|
1909
|
+
};
|
|
1902
1910
|
})[];
|
|
1903
1911
|
breadcrumb: {
|
|
1904
1912
|
id: string;
|
|
@@ -1916,6 +1924,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
1916
1924
|
type: "FILE" | "FOLDER";
|
|
1917
1925
|
parentId: string | null;
|
|
1918
1926
|
isFavorite: boolean;
|
|
1927
|
+
currentFileId: string | null;
|
|
1919
1928
|
} & {
|
|
1920
1929
|
users: [{
|
|
1921
1930
|
id: string;
|
|
@@ -1980,6 +1989,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
1980
1989
|
type: "FILE" | "FOLDER";
|
|
1981
1990
|
parentId: string | null;
|
|
1982
1991
|
isFavorite: boolean;
|
|
1992
|
+
currentFileId: string | null;
|
|
1983
1993
|
} & {
|
|
1984
1994
|
users: [{
|
|
1985
1995
|
id: string;
|
|
@@ -2011,6 +2021,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2011
2021
|
type: "FILE" | "FOLDER";
|
|
2012
2022
|
parentId: string | null;
|
|
2013
2023
|
isFavorite: boolean;
|
|
2024
|
+
currentFileId: string | null;
|
|
2014
2025
|
} & {
|
|
2015
2026
|
users: [{
|
|
2016
2027
|
id: string;
|
|
@@ -2032,6 +2043,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2032
2043
|
isRoot: boolean;
|
|
2033
2044
|
sharedByPubKey: string;
|
|
2034
2045
|
};
|
|
2046
|
+
} & {
|
|
2047
|
+
sizes: {
|
|
2048
|
+
size: bigint;
|
|
2049
|
+
sizeBefore: bigint;
|
|
2050
|
+
};
|
|
2035
2051
|
})[];
|
|
2036
2052
|
breadcrumb: {
|
|
2037
2053
|
id: string;
|
|
@@ -2487,6 +2503,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2487
2503
|
type: "FILE" | "FOLDER";
|
|
2488
2504
|
parentId: string | null;
|
|
2489
2505
|
isFavorite: boolean;
|
|
2506
|
+
currentFileId: string | null;
|
|
2490
2507
|
} & {
|
|
2491
2508
|
users: [{
|
|
2492
2509
|
id: string;
|
|
@@ -2551,6 +2568,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2551
2568
|
type: "FILE" | "FOLDER";
|
|
2552
2569
|
parentId: string | null;
|
|
2553
2570
|
isFavorite: boolean;
|
|
2571
|
+
currentFileId: string | null;
|
|
2554
2572
|
} & {
|
|
2555
2573
|
users: [{
|
|
2556
2574
|
id: string;
|
|
@@ -2582,6 +2600,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2582
2600
|
type: "FILE" | "FOLDER";
|
|
2583
2601
|
parentId: string | null;
|
|
2584
2602
|
isFavorite: boolean;
|
|
2603
|
+
currentFileId: string | null;
|
|
2585
2604
|
} & {
|
|
2586
2605
|
users: [{
|
|
2587
2606
|
id: string;
|
|
@@ -2603,6 +2622,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2603
2622
|
isRoot: boolean;
|
|
2604
2623
|
sharedByPubKey: string;
|
|
2605
2624
|
};
|
|
2625
|
+
} & {
|
|
2626
|
+
sizes: {
|
|
2627
|
+
size: bigint;
|
|
2628
|
+
sizeBefore: bigint;
|
|
2629
|
+
};
|
|
2606
2630
|
})[];
|
|
2607
2631
|
breadcrumb: {
|
|
2608
2632
|
id: string;
|
|
@@ -2620,6 +2644,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2620
2644
|
type: "FILE" | "FOLDER";
|
|
2621
2645
|
parentId: string | null;
|
|
2622
2646
|
isFavorite: boolean;
|
|
2647
|
+
currentFileId: string | null;
|
|
2623
2648
|
} & {
|
|
2624
2649
|
users: [{
|
|
2625
2650
|
id: string;
|
|
@@ -2684,6 +2709,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2684
2709
|
type: "FILE" | "FOLDER";
|
|
2685
2710
|
parentId: string | null;
|
|
2686
2711
|
isFavorite: boolean;
|
|
2712
|
+
currentFileId: string | null;
|
|
2687
2713
|
} & {
|
|
2688
2714
|
users: [{
|
|
2689
2715
|
id: string;
|
|
@@ -2715,6 +2741,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2715
2741
|
type: "FILE" | "FOLDER";
|
|
2716
2742
|
parentId: string | null;
|
|
2717
2743
|
isFavorite: boolean;
|
|
2744
|
+
currentFileId: string | null;
|
|
2718
2745
|
} & {
|
|
2719
2746
|
users: [{
|
|
2720
2747
|
id: string;
|
|
@@ -2736,6 +2763,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
2736
2763
|
isRoot: boolean;
|
|
2737
2764
|
sharedByPubKey: string;
|
|
2738
2765
|
};
|
|
2766
|
+
} & {
|
|
2767
|
+
sizes: {
|
|
2768
|
+
size: bigint;
|
|
2769
|
+
sizeBefore: bigint;
|
|
2770
|
+
};
|
|
2739
2771
|
})[];
|
|
2740
2772
|
breadcrumb: {
|
|
2741
2773
|
id: string;
|
|
@@ -3023,6 +3055,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3023
3055
|
type: "FILE" | "FOLDER";
|
|
3024
3056
|
parentId: string | null;
|
|
3025
3057
|
isFavorite: boolean;
|
|
3058
|
+
currentFileId: string | null;
|
|
3026
3059
|
} & {
|
|
3027
3060
|
users: [{
|
|
3028
3061
|
id: string;
|
|
@@ -3087,6 +3120,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3087
3120
|
type: "FILE" | "FOLDER";
|
|
3088
3121
|
parentId: string | null;
|
|
3089
3122
|
isFavorite: boolean;
|
|
3123
|
+
currentFileId: string | null;
|
|
3090
3124
|
} & {
|
|
3091
3125
|
users: [{
|
|
3092
3126
|
id: string;
|
|
@@ -3118,6 +3152,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3118
3152
|
type: "FILE" | "FOLDER";
|
|
3119
3153
|
parentId: string | null;
|
|
3120
3154
|
isFavorite: boolean;
|
|
3155
|
+
currentFileId: string | null;
|
|
3121
3156
|
} & {
|
|
3122
3157
|
users: [{
|
|
3123
3158
|
id: string;
|
|
@@ -3139,6 +3174,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3139
3174
|
isRoot: boolean;
|
|
3140
3175
|
sharedByPubKey: string;
|
|
3141
3176
|
};
|
|
3177
|
+
} & {
|
|
3178
|
+
sizes: {
|
|
3179
|
+
size: bigint;
|
|
3180
|
+
sizeBefore: bigint;
|
|
3181
|
+
};
|
|
3142
3182
|
})[];
|
|
3143
3183
|
breadcrumb: {
|
|
3144
3184
|
id: string;
|
|
@@ -3156,6 +3196,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3156
3196
|
type: "FILE" | "FOLDER";
|
|
3157
3197
|
parentId: string | null;
|
|
3158
3198
|
isFavorite: boolean;
|
|
3199
|
+
currentFileId: string | null;
|
|
3159
3200
|
} & {
|
|
3160
3201
|
users: [{
|
|
3161
3202
|
id: string;
|
|
@@ -3220,6 +3261,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3220
3261
|
type: "FILE" | "FOLDER";
|
|
3221
3262
|
parentId: string | null;
|
|
3222
3263
|
isFavorite: boolean;
|
|
3264
|
+
currentFileId: string | null;
|
|
3223
3265
|
} & {
|
|
3224
3266
|
users: [{
|
|
3225
3267
|
id: string;
|
|
@@ -3251,6 +3293,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3251
3293
|
type: "FILE" | "FOLDER";
|
|
3252
3294
|
parentId: string | null;
|
|
3253
3295
|
isFavorite: boolean;
|
|
3296
|
+
currentFileId: string | null;
|
|
3254
3297
|
} & {
|
|
3255
3298
|
users: [{
|
|
3256
3299
|
id: string;
|
|
@@ -3272,6 +3315,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3272
3315
|
isRoot: boolean;
|
|
3273
3316
|
sharedByPubKey: string;
|
|
3274
3317
|
};
|
|
3318
|
+
} & {
|
|
3319
|
+
sizes: {
|
|
3320
|
+
size: bigint;
|
|
3321
|
+
sizeBefore: bigint;
|
|
3322
|
+
};
|
|
3275
3323
|
})[];
|
|
3276
3324
|
breadcrumb: {
|
|
3277
3325
|
id: string;
|
|
@@ -3651,6 +3699,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3651
3699
|
type: "FILE" | "FOLDER";
|
|
3652
3700
|
parentId: string | null;
|
|
3653
3701
|
isFavorite: boolean;
|
|
3702
|
+
currentFileId: string | null;
|
|
3654
3703
|
} & {
|
|
3655
3704
|
users: [{
|
|
3656
3705
|
id: string;
|
|
@@ -3687,6 +3736,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3687
3736
|
type: "FILE" | "FOLDER";
|
|
3688
3737
|
parentId: string | null;
|
|
3689
3738
|
isFavorite: boolean;
|
|
3739
|
+
currentFileId: string | null;
|
|
3690
3740
|
} & {
|
|
3691
3741
|
users: [{
|
|
3692
3742
|
id: string;
|
|
@@ -3757,6 +3807,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3757
3807
|
type: "FILE" | "FOLDER";
|
|
3758
3808
|
parentId: string | null;
|
|
3759
3809
|
isFavorite: boolean;
|
|
3810
|
+
currentFileId: string | null;
|
|
3760
3811
|
} & {
|
|
3761
3812
|
users: [{
|
|
3762
3813
|
id: string;
|
|
@@ -3821,6 +3872,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3821
3872
|
type: "FILE" | "FOLDER";
|
|
3822
3873
|
parentId: string | null;
|
|
3823
3874
|
isFavorite: boolean;
|
|
3875
|
+
currentFileId: string | null;
|
|
3824
3876
|
} & {
|
|
3825
3877
|
users: [{
|
|
3826
3878
|
id: string;
|
|
@@ -3852,6 +3904,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3852
3904
|
type: "FILE" | "FOLDER";
|
|
3853
3905
|
parentId: string | null;
|
|
3854
3906
|
isFavorite: boolean;
|
|
3907
|
+
currentFileId: string | null;
|
|
3855
3908
|
} & {
|
|
3856
3909
|
users: [{
|
|
3857
3910
|
id: string;
|
|
@@ -3873,6 +3926,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3873
3926
|
isRoot: boolean;
|
|
3874
3927
|
sharedByPubKey: string;
|
|
3875
3928
|
};
|
|
3929
|
+
} & {
|
|
3930
|
+
sizes: {
|
|
3931
|
+
size: bigint;
|
|
3932
|
+
sizeBefore: bigint;
|
|
3933
|
+
};
|
|
3876
3934
|
})[];
|
|
3877
3935
|
breadcrumb: {
|
|
3878
3936
|
id: string;
|
|
@@ -3890,6 +3948,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3890
3948
|
type: "FILE" | "FOLDER";
|
|
3891
3949
|
parentId: string | null;
|
|
3892
3950
|
isFavorite: boolean;
|
|
3951
|
+
currentFileId: string | null;
|
|
3893
3952
|
} & {
|
|
3894
3953
|
users: [{
|
|
3895
3954
|
id: string;
|
|
@@ -3954,6 +4013,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3954
4013
|
type: "FILE" | "FOLDER";
|
|
3955
4014
|
parentId: string | null;
|
|
3956
4015
|
isFavorite: boolean;
|
|
4016
|
+
currentFileId: string | null;
|
|
3957
4017
|
} & {
|
|
3958
4018
|
users: [{
|
|
3959
4019
|
id: string;
|
|
@@ -3985,6 +4045,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3985
4045
|
type: "FILE" | "FOLDER";
|
|
3986
4046
|
parentId: string | null;
|
|
3987
4047
|
isFavorite: boolean;
|
|
4048
|
+
currentFileId: string | null;
|
|
3988
4049
|
} & {
|
|
3989
4050
|
users: [{
|
|
3990
4051
|
id: string;
|
|
@@ -4006,6 +4067,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4006
4067
|
isRoot: boolean;
|
|
4007
4068
|
sharedByPubKey: string;
|
|
4008
4069
|
};
|
|
4070
|
+
} & {
|
|
4071
|
+
sizes: {
|
|
4072
|
+
size: bigint;
|
|
4073
|
+
sizeBefore: bigint;
|
|
4074
|
+
};
|
|
4009
4075
|
})[];
|
|
4010
4076
|
breadcrumb: {
|
|
4011
4077
|
id: string;
|
|
@@ -4091,6 +4157,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4091
4157
|
type: "FILE" | "FOLDER";
|
|
4092
4158
|
parentId: string | null;
|
|
4093
4159
|
isFavorite: boolean;
|
|
4160
|
+
currentFileId: string | null;
|
|
4094
4161
|
} & {
|
|
4095
4162
|
users: [{
|
|
4096
4163
|
id: string;
|
|
@@ -4122,6 +4189,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4122
4189
|
type: "FILE" | "FOLDER";
|
|
4123
4190
|
parentId: string | null;
|
|
4124
4191
|
isFavorite: boolean;
|
|
4192
|
+
currentFileId: string | null;
|
|
4125
4193
|
} & {
|
|
4126
4194
|
users: [{
|
|
4127
4195
|
id: string;
|
|
@@ -4185,6 +4253,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4185
4253
|
type: "FILE" | "FOLDER";
|
|
4186
4254
|
parentId: string | null;
|
|
4187
4255
|
isFavorite: boolean;
|
|
4256
|
+
currentFileId: string | null;
|
|
4188
4257
|
} & {
|
|
4189
4258
|
users: [{
|
|
4190
4259
|
id: string;
|
|
@@ -4216,6 +4285,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4216
4285
|
type: "FILE" | "FOLDER";
|
|
4217
4286
|
parentId: string | null;
|
|
4218
4287
|
isFavorite: boolean;
|
|
4288
|
+
currentFileId: string | null;
|
|
4219
4289
|
} & {
|
|
4220
4290
|
users: [{
|
|
4221
4291
|
id: string;
|
|
@@ -4275,6 +4345,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4275
4345
|
type: "FILE" | "FOLDER";
|
|
4276
4346
|
parentId: string | null;
|
|
4277
4347
|
isFavorite: boolean;
|
|
4348
|
+
currentFileId: string | null;
|
|
4278
4349
|
} & {
|
|
4279
4350
|
users: [{
|
|
4280
4351
|
id: string;
|
|
@@ -4306,6 +4377,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4306
4377
|
type: "FILE" | "FOLDER";
|
|
4307
4378
|
parentId: string | null;
|
|
4308
4379
|
isFavorite: boolean;
|
|
4380
|
+
currentFileId: string | null;
|
|
4309
4381
|
} & {
|
|
4310
4382
|
users: [{
|
|
4311
4383
|
id: string;
|
|
@@ -4509,6 +4581,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4509
4581
|
type: "FILE" | "FOLDER";
|
|
4510
4582
|
parentId: string | null;
|
|
4511
4583
|
isFavorite: boolean;
|
|
4584
|
+
currentFileId: string | null;
|
|
4512
4585
|
} & {
|
|
4513
4586
|
users: [{
|
|
4514
4587
|
id: string;
|
|
@@ -4573,6 +4646,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4573
4646
|
type: "FILE" | "FOLDER";
|
|
4574
4647
|
parentId: string | null;
|
|
4575
4648
|
isFavorite: boolean;
|
|
4649
|
+
currentFileId: string | null;
|
|
4576
4650
|
} & {
|
|
4577
4651
|
users: [{
|
|
4578
4652
|
id: string;
|
|
@@ -4604,6 +4678,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4604
4678
|
type: "FILE" | "FOLDER";
|
|
4605
4679
|
parentId: string | null;
|
|
4606
4680
|
isFavorite: boolean;
|
|
4681
|
+
currentFileId: string | null;
|
|
4607
4682
|
} & {
|
|
4608
4683
|
users: [{
|
|
4609
4684
|
id: string;
|
|
@@ -4625,6 +4700,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4625
4700
|
isRoot: boolean;
|
|
4626
4701
|
sharedByPubKey: string;
|
|
4627
4702
|
};
|
|
4703
|
+
} & {
|
|
4704
|
+
sizes: {
|
|
4705
|
+
size: bigint;
|
|
4706
|
+
sizeBefore: bigint;
|
|
4707
|
+
};
|
|
4628
4708
|
})[];
|
|
4629
4709
|
breadcrumb: {
|
|
4630
4710
|
id: string;
|
|
@@ -4642,6 +4722,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4642
4722
|
type: "FILE" | "FOLDER";
|
|
4643
4723
|
parentId: string | null;
|
|
4644
4724
|
isFavorite: boolean;
|
|
4725
|
+
currentFileId: string | null;
|
|
4645
4726
|
} & {
|
|
4646
4727
|
users: [{
|
|
4647
4728
|
id: string;
|
|
@@ -4706,6 +4787,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4706
4787
|
type: "FILE" | "FOLDER";
|
|
4707
4788
|
parentId: string | null;
|
|
4708
4789
|
isFavorite: boolean;
|
|
4790
|
+
currentFileId: string | null;
|
|
4709
4791
|
} & {
|
|
4710
4792
|
users: [{
|
|
4711
4793
|
id: string;
|
|
@@ -4737,6 +4819,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4737
4819
|
type: "FILE" | "FOLDER";
|
|
4738
4820
|
parentId: string | null;
|
|
4739
4821
|
isFavorite: boolean;
|
|
4822
|
+
currentFileId: string | null;
|
|
4740
4823
|
} & {
|
|
4741
4824
|
users: [{
|
|
4742
4825
|
id: string;
|
|
@@ -4758,6 +4841,11 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4758
4841
|
isRoot: boolean;
|
|
4759
4842
|
sharedByPubKey: string;
|
|
4760
4843
|
};
|
|
4844
|
+
} & {
|
|
4845
|
+
sizes: {
|
|
4846
|
+
size: bigint;
|
|
4847
|
+
sizeBefore: bigint;
|
|
4848
|
+
};
|
|
4761
4849
|
})[];
|
|
4762
4850
|
breadcrumb: {
|
|
4763
4851
|
id: string;
|
|
@@ -3,12 +3,12 @@ export interface EncryptedFile {
|
|
|
3
3
|
md5: string;
|
|
4
4
|
md5Encrypted: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function secretStreamKeygen(): Uint8Array;
|
|
7
7
|
export declare const CHUNK_SIZE = 8192;
|
|
8
8
|
export interface Progress {
|
|
9
9
|
percent: number;
|
|
10
10
|
total: number;
|
|
11
11
|
current: number;
|
|
12
12
|
}
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
13
|
+
export declare function encryptSecretStream(key: Uint8Array, data: Uint8Array, progress?: (progress: Progress) => Promise<void>, abort?: AbortController): Promise<EncryptedFile>;
|
|
14
|
+
export declare function decryptSecretStream(key: Uint8Array, data: Uint8Array, progress?: (progress: Progress) => Promise<void>, abort?: AbortController): Promise<Uint8Array>;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@secrecy/lib",
|
|
3
3
|
"author": "Anonymize <anonymize@gmail.com>",
|
|
4
4
|
"description": "Anonymize Secrecy Library",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.11.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/anonymize-org/lib.git"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@secrecy/lib-utils": "^1.0.18",
|
|
77
|
-
"@secrecy/trpc-api-types": "1.18.0-dev.
|
|
77
|
+
"@secrecy/trpc-api-types": "1.18.0-dev.8",
|
|
78
78
|
"@trpc/client": "10.45.2",
|
|
79
79
|
"@trpc/server": "10.45.2",
|
|
80
80
|
"@types/libsodium-wrappers-sumo": "^0.7.8",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"jsonwebtoken": "^9.0.2",
|
|
85
85
|
"ky": "^1.2.3",
|
|
86
86
|
"libsodium-wrappers-sumo": "^0.7.13",
|
|
87
|
+
"lru-cache": "^10.2.0",
|
|
87
88
|
"spark-md5": "^3.0.2",
|
|
88
89
|
"superjson": "2.2.1",
|
|
89
90
|
"zod": "3.22.4"
|