@secrecy/lib 1.65.0-feat-next15.4 → 1.65.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/client/SecrecyCloudClient.js +77 -31
- package/dist/lib/client/convert/node.js +5 -1
- package/dist/lib/client.js +9 -4
- package/dist/types/cache.d.ts +2 -2
- package/dist/types/client/SecrecyCloudClient.d.ts +33 -33
- package/dist/types/client/index.d.ts +2 -2
- package/dist/types/client/types/index.d.ts +29 -3
- package/dist/types/client/types/node.d.ts +6 -6
- package/dist/types/client.d.ts +18018 -5231
- package/dist/types/crypto/data.d.ts +3 -3
- package/dist/types/error/client.d.ts +11 -7
- package/dist/types/error/index.d.ts +23 -23
- package/dist/types/error/server.d.ts +13 -35
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +2 -1
- package/dist/types/worker/sodium.d.ts +3 -3
- package/package.json +30 -31
- package/dist/lib/transformer.js +0 -18
- package/dist/types/transformer.d.ts +0 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
1
2
|
import ky from 'ky';
|
|
2
3
|
import { nodesCache, dataCache, dataContentCache, nodesEncryptionCache, } from '../cache.js';
|
|
3
4
|
import { secretStreamKeygen } from '../crypto/data.js';
|
|
@@ -14,7 +15,6 @@ import { kiloToBytes } from '../utils.js';
|
|
|
14
15
|
import { fileTypeFromBuffer } from 'file-type';
|
|
15
16
|
import { encryptName, generateAndEncryptNameAndKey } from '../crypto/domain.js';
|
|
16
17
|
import { chunkByTotalItems } from '../utils/object.js';
|
|
17
|
-
import axios from 'axios';
|
|
18
18
|
export class SecrecyCloudClient {
|
|
19
19
|
#client;
|
|
20
20
|
#keys;
|
|
@@ -25,7 +25,10 @@ export class SecrecyCloudClient {
|
|
|
25
25
|
this.#apiClient = apiClient;
|
|
26
26
|
}
|
|
27
27
|
async addDataToHistory({ dataId, nodeId, }) {
|
|
28
|
-
const addDataToHistory = await this.#apiClient.cloud.addDataToHistory.mutate({
|
|
28
|
+
const addDataToHistory = await this.#apiClient.cloud.addDataToHistory.mutate({
|
|
29
|
+
dataId,
|
|
30
|
+
nodeId,
|
|
31
|
+
});
|
|
29
32
|
const node = await apiNodeFullToInternalFull(addDataToHistory, this.#keys);
|
|
30
33
|
const data = node.history.find((d) => d.id === dataId);
|
|
31
34
|
if (data !== undefined) {
|
|
@@ -71,7 +74,10 @@ export class SecrecyCloudClient {
|
|
|
71
74
|
const dataKey = encrypted ? secretStreamKeygen() : null;
|
|
72
75
|
const { data: encryptedData, md5: md5Data, md5Encrypted, } = dataKey
|
|
73
76
|
? await encrypt(dataKey, compressed, encryptProgress, signal)
|
|
74
|
-
: {
|
|
77
|
+
: {
|
|
78
|
+
data: compressed,
|
|
79
|
+
md5: await md5(compressed),
|
|
80
|
+
};
|
|
75
81
|
const encryptedDataKey = dataKey
|
|
76
82
|
? encryptCryptoBox(dataKey, this.#keys.publicKey, this.#keys.privateKey)
|
|
77
83
|
: null;
|
|
@@ -162,7 +168,11 @@ export class SecrecyCloudClient {
|
|
|
162
168
|
return localData;
|
|
163
169
|
}
|
|
164
170
|
const uploadDataPartEnd = async (md5, order) => {
|
|
165
|
-
return this.#apiClient.cloud.uploadDataPartEnd.mutate({
|
|
171
|
+
return this.#apiClient.cloud.uploadDataPartEnd.mutate({
|
|
172
|
+
dataId: uploadData.id,
|
|
173
|
+
md5,
|
|
174
|
+
order,
|
|
175
|
+
}, { signal });
|
|
166
176
|
};
|
|
167
177
|
const chunkParts = new Array();
|
|
168
178
|
for (const [index, chunk] of enumerate(chunks(encryptedData, Number(uploadData.partSize)))) {
|
|
@@ -175,7 +185,7 @@ export class SecrecyCloudClient {
|
|
|
175
185
|
const progressParts = {};
|
|
176
186
|
const onProgress = (part, progressEvent) => {
|
|
177
187
|
progressParts[part] = progressEvent;
|
|
178
|
-
const current = Object.values(progressParts).reduce((prv, cur) => prv + cur.
|
|
188
|
+
const current = Object.values(progressParts).reduce((prv, cur) => prv + cur.loaded, 0);
|
|
179
189
|
void uploadProgress?.({
|
|
180
190
|
percent: current / encryptedData.byteLength,
|
|
181
191
|
total: encryptedData.byteLength,
|
|
@@ -191,16 +201,12 @@ export class SecrecyCloudClient {
|
|
|
191
201
|
for (const [key, value] of Object.entries(part.fields)) {
|
|
192
202
|
formData.append(key, value);
|
|
193
203
|
}
|
|
194
|
-
formData.append('file', new Blob([chunk.data
|
|
204
|
+
formData.append('file', new Blob([chunk.data], { type: filetype?.mime }), `${uploadData.id}-${chunk.order}`);
|
|
195
205
|
await axios.post(part.url, formData, {
|
|
196
|
-
signal,
|
|
197
206
|
onUploadProgress: (progressEvent) => {
|
|
198
|
-
onProgress(part.order,
|
|
199
|
-
percent: progressEvent.progress ?? 0,
|
|
200
|
-
totalBytes: progressEvent.total ?? 0,
|
|
201
|
-
transferredBytes: progressEvent.loaded ?? 0,
|
|
202
|
-
});
|
|
207
|
+
onProgress(part.order, progressEvent);
|
|
203
208
|
},
|
|
209
|
+
signal,
|
|
204
210
|
});
|
|
205
211
|
return uploadDataPartEnd(chunk.md5, chunk.order);
|
|
206
212
|
};
|
|
@@ -228,7 +234,11 @@ export class SecrecyCloudClient {
|
|
|
228
234
|
uploadProgress,
|
|
229
235
|
signal,
|
|
230
236
|
});
|
|
231
|
-
return await this.saveInCloud({
|
|
237
|
+
return await this.saveInCloud({
|
|
238
|
+
dataId: uploadedData.id,
|
|
239
|
+
name,
|
|
240
|
+
nodeId,
|
|
241
|
+
});
|
|
232
242
|
}
|
|
233
243
|
async deletedNodes() {
|
|
234
244
|
const deletedNodes = await this.#apiClient.cloud.nodesDeleted.query({});
|
|
@@ -239,7 +249,9 @@ export class SecrecyCloudClient {
|
|
|
239
249
|
return await Promise.all(nodesShared.map(async (node) => await apiNodeToExternal(node, this.#keys)));
|
|
240
250
|
}
|
|
241
251
|
async nodesSharedWithMe(type = 'FOLDER') {
|
|
242
|
-
const nodesSharedWithMe = await this.#apiClient.cloud.nodesSharedWithMe.query({
|
|
252
|
+
const nodesSharedWithMe = await this.#apiClient.cloud.nodesSharedWithMe.query({
|
|
253
|
+
type,
|
|
254
|
+
});
|
|
243
255
|
return await Promise.all(nodesSharedWithMe.map(async (node) => await apiNodeToExternal(node, this.#keys)));
|
|
244
256
|
}
|
|
245
257
|
async deleteNodeSharing({ nodeId, userId, }) {
|
|
@@ -273,7 +285,9 @@ export class SecrecyCloudClient {
|
|
|
273
285
|
return isDuplicated;
|
|
274
286
|
}
|
|
275
287
|
async deleteNodeCloudTrash({ ids }) {
|
|
276
|
-
const { isDeleted } = await this.#apiClient.cloud.deleteNodeCloudTrash.mutate({
|
|
288
|
+
const { isDeleted } = await this.#apiClient.cloud.deleteNodeCloudTrash.mutate({
|
|
289
|
+
ids,
|
|
290
|
+
});
|
|
277
291
|
return isDeleted;
|
|
278
292
|
}
|
|
279
293
|
async createFolder({ name, parentFolderId, }) {
|
|
@@ -304,11 +318,16 @@ export class SecrecyCloudClient {
|
|
|
304
318
|
return folder;
|
|
305
319
|
}
|
|
306
320
|
async node({ id, deleted, } = {}) {
|
|
307
|
-
const node = await this.#apiClient.cloud.nodeFullById.query({
|
|
321
|
+
const node = await this.#apiClient.cloud.nodeFullById.query({
|
|
322
|
+
id,
|
|
323
|
+
deleted,
|
|
324
|
+
});
|
|
308
325
|
return await apiNodeToExternalNodeFull(node, this.#keys);
|
|
309
326
|
}
|
|
310
327
|
async dataMetadata({ id }) {
|
|
311
|
-
const data = await this.#apiClient.cloud.dataById.query({
|
|
328
|
+
const data = await this.#apiClient.cloud.dataById.query({
|
|
329
|
+
id,
|
|
330
|
+
});
|
|
312
331
|
return apiDataToExternal(data, this.#keys);
|
|
313
332
|
}
|
|
314
333
|
async shareNode(input, progress) {
|
|
@@ -320,7 +339,11 @@ export class SecrecyCloudClient {
|
|
|
320
339
|
const publicKeysMap = await this.#client.app.userPublicKey(neededUserKey);
|
|
321
340
|
const maxNodesBatchSize = 1000;
|
|
322
341
|
const totalNodesToShare = Object.values(nodesMap).reduce((size, ids) => size + ids.length, 0);
|
|
323
|
-
progress?.({
|
|
342
|
+
progress?.({
|
|
343
|
+
total: totalNodesToShare,
|
|
344
|
+
current: 0,
|
|
345
|
+
percent: 0,
|
|
346
|
+
});
|
|
324
347
|
const chunks = totalNodesToShare > maxNodesBatchSize
|
|
325
348
|
? chunkByTotalItems(nodesMap, maxNodesBatchSize)
|
|
326
349
|
: [nodesMap];
|
|
@@ -389,7 +412,7 @@ export class SecrecyCloudClient {
|
|
|
389
412
|
.map((node) => {
|
|
390
413
|
const share = shares.find((share) => share.nodeId === node.nodeId && share.userId === userId);
|
|
391
414
|
if (!share) {
|
|
392
|
-
throw new Error('Unable to retrieve
|
|
415
|
+
throw new Error('Unable to retrieve permissions!');
|
|
393
416
|
}
|
|
394
417
|
return {
|
|
395
418
|
nodeId: node.nodeId,
|
|
@@ -401,12 +424,22 @@ export class SecrecyCloudClient {
|
|
|
401
424
|
const withKeys = Object.fromEntries(Object.entries(infos).map('rights' in input
|
|
402
425
|
? ([userId, nodes]) => [
|
|
403
426
|
userId,
|
|
404
|
-
{
|
|
427
|
+
{
|
|
428
|
+
userId,
|
|
429
|
+
nodes,
|
|
430
|
+
permissions: {
|
|
431
|
+
rights: input.rights,
|
|
432
|
+
addAccess: input.addAccess,
|
|
433
|
+
delAccess: input.delAccess,
|
|
434
|
+
sharingAddAccess: input.sharingAddAccess,
|
|
435
|
+
sharingDelAccess: input.sharingDelAccess,
|
|
436
|
+
},
|
|
437
|
+
},
|
|
405
438
|
]
|
|
406
439
|
: ([userId, nodes]) => {
|
|
407
440
|
const share = shares.find((share) => share.userId === userId && share.nodeId === nodes[0].id);
|
|
408
441
|
if (!share) {
|
|
409
|
-
throw new Error('Unable to retrieve
|
|
442
|
+
throw new Error('Unable to retrieve permissions!');
|
|
410
443
|
}
|
|
411
444
|
return [
|
|
412
445
|
userId,
|
|
@@ -419,16 +452,25 @@ export class SecrecyCloudClient {
|
|
|
419
452
|
userId,
|
|
420
453
|
nodes: nodes.nodes.map((node) => ({
|
|
421
454
|
id: node.id,
|
|
422
|
-
...nodes.permissions,
|
|
423
455
|
nameKey: node.nameKey,
|
|
424
|
-
data: node.data.map((d) => ({
|
|
456
|
+
data: node.data.map((d) => ({
|
|
457
|
+
id: d.id,
|
|
458
|
+
key: d.key,
|
|
459
|
+
})),
|
|
460
|
+
...nodes.permissions,
|
|
425
461
|
})),
|
|
426
462
|
});
|
|
427
463
|
}
|
|
428
464
|
for (const [userId, nodes] of Object.entries(nodesToUpdateRights)) {
|
|
429
465
|
finishInput.push(...nodes.map((node) => ({
|
|
430
466
|
userId,
|
|
431
|
-
nodes: [
|
|
467
|
+
nodes: [
|
|
468
|
+
{
|
|
469
|
+
id: node.nodeId,
|
|
470
|
+
data: [],
|
|
471
|
+
...node.permissions,
|
|
472
|
+
},
|
|
473
|
+
],
|
|
432
474
|
})));
|
|
433
475
|
}
|
|
434
476
|
const subState = await this.#apiClient.cloud.shareNodeFinish.mutate(finishInput);
|
|
@@ -466,7 +508,10 @@ export class SecrecyCloudClient {
|
|
|
466
508
|
const errorDetailsLength = details.invalidRightsAccesses.length +
|
|
467
509
|
details.missingDataAccesses.length +
|
|
468
510
|
details.missingNodeAccesses.length;
|
|
469
|
-
return {
|
|
511
|
+
return {
|
|
512
|
+
isFinished: errorDetailsLength === 0,
|
|
513
|
+
details: details,
|
|
514
|
+
};
|
|
470
515
|
}
|
|
471
516
|
async updateNode({ nodeId, name, isFavorite, deletedAt, }) {
|
|
472
517
|
let node = nodesCache.get(nodeId);
|
|
@@ -549,7 +594,9 @@ export class SecrecyCloudClient {
|
|
|
549
594
|
}));
|
|
550
595
|
}
|
|
551
596
|
async deleteNodes({ nodeIds, }) {
|
|
552
|
-
return this.#apiClient.cloud.deleteNodes.mutate({
|
|
597
|
+
return this.#apiClient.cloud.deleteNodes.mutate({
|
|
598
|
+
ids: nodeIds,
|
|
599
|
+
});
|
|
553
600
|
}
|
|
554
601
|
async deleteData({ dataId, nodeId, }) {
|
|
555
602
|
const { isDeleted } = await this.#apiClient.cloud.deleteData.mutate({
|
|
@@ -648,13 +695,14 @@ export class SecrecyCloudClient {
|
|
|
648
695
|
});
|
|
649
696
|
const node = await apiNodeToExternalNodeFull(saveInCloud, this.#keys);
|
|
650
697
|
const me = node.parent?.users.find(([u]) => u.id === this.#client.app.userId);
|
|
651
|
-
// TODO:
|
|
652
|
-
if (me !== undefined && ['
|
|
698
|
+
// TODO: ??
|
|
699
|
+
if (me !== undefined && ['delete', 'write'].includes(me[1].rights)) {
|
|
653
700
|
const others = node.parent?.users.filter(([u]) => u.id !== this.#client.app.userId) ??
|
|
654
701
|
[];
|
|
655
702
|
if (others.length > 0) {
|
|
656
703
|
await this.shareNode(others.map(([user, permissions]) => ({
|
|
657
704
|
userId: user.id,
|
|
705
|
+
permissions,
|
|
658
706
|
nodeId: node.id,
|
|
659
707
|
...permissions,
|
|
660
708
|
})));
|
|
@@ -678,9 +726,7 @@ export class SecrecyCloudClient {
|
|
|
678
726
|
}
|
|
679
727
|
// Retrieve and format nodes.
|
|
680
728
|
for (const nodeId of nodeIds) {
|
|
681
|
-
let node;
|
|
682
|
-
node ??= nodesEncryptionCache.get(nodeId);
|
|
683
|
-
node ??= nodesCache.get(nodeId);
|
|
729
|
+
let node = nodesEncryptionCache.get(nodeId) ?? nodesCache.get(nodeId);
|
|
684
730
|
if (node &&
|
|
685
731
|
'history' in node &&
|
|
686
732
|
node.history.length > 0 &&
|
|
@@ -66,8 +66,12 @@ function internalNodeToNode(internal) {
|
|
|
66
66
|
})),
|
|
67
67
|
access: {
|
|
68
68
|
isRoot: internal.access.isRoot,
|
|
69
|
-
rights: internal.access.rights,
|
|
70
69
|
sharedByPubKey: internal.access.sharedByPubKey,
|
|
70
|
+
rights: internal.access.rights,
|
|
71
|
+
addAccess: internal.access.addAccess,
|
|
72
|
+
delAccess: internal.access.delAccess,
|
|
73
|
+
sharingAddAccess: internal.access.sharingAddAccess,
|
|
74
|
+
sharingDelAccess: internal.access.sharingDelAccess,
|
|
71
75
|
},
|
|
72
76
|
};
|
|
73
77
|
return node;
|
package/dist/lib/client.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { httpBatchLink, loggerLink,
|
|
1
|
+
import { httpBatchLink, loggerLink, createTRPCProxyClient, TRPCClientError, } from '@trpc/client';
|
|
2
|
+
import superjson from 'superjson';
|
|
2
3
|
import { SECRECY_LIB_VERSION } from './versioning.js';
|
|
3
|
-
import { transformer } from './transformer.js';
|
|
4
4
|
export function isTRPCClientError(cause) {
|
|
5
5
|
return cause instanceof TRPCClientError;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
superjson.registerCustom({
|
|
8
|
+
isApplicable: (v) => v instanceof Buffer,
|
|
9
|
+
serialize: (v) => [...v],
|
|
10
|
+
deserialize: (v) => Buffer.from(v),
|
|
11
|
+
}, 'buffer');
|
|
12
|
+
export const createTRPCClient = (opts) => createTRPCProxyClient({
|
|
13
|
+
transformer: superjson,
|
|
8
14
|
links: [
|
|
9
15
|
loggerLink({
|
|
10
16
|
enabled: (op) => {
|
|
@@ -18,7 +24,6 @@ export const createTRPCClient = (opts) => innerCreateTRPCClient({
|
|
|
18
24
|
},
|
|
19
25
|
}),
|
|
20
26
|
httpBatchLink({
|
|
21
|
-
transformer,
|
|
22
27
|
url: opts.apiUrl
|
|
23
28
|
? `${opts.apiUrl}/trpc`
|
|
24
29
|
: 'https://api.secrecy.tech/trpc',
|
package/dist/types/cache.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export declare const dataCache: Map<string, InternalData>;
|
|
|
4
4
|
export declare const nodesCache: Map<string, InternalNode | InternalNodeFull>;
|
|
5
5
|
export declare const nodesEncryptionCache: Map<string, InternalMinimalNodeForEncryption>;
|
|
6
6
|
export declare const usersCache: Map<string, {
|
|
7
|
-
firstname: string;
|
|
8
|
-
lastname: string;
|
|
9
7
|
id: string;
|
|
8
|
+
lastname: string;
|
|
9
|
+
firstname: string;
|
|
10
10
|
avatar: string | null;
|
|
11
11
|
isSearchable: boolean;
|
|
12
12
|
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProgressCallback, SecrecyClient } from '../index.js';
|
|
2
2
|
import type { DataMetadata, DataStorageType, KeyPair, LocalData, Node, NodeFull, NodeType } from './types/index.js';
|
|
3
3
|
import { type RouterInputs, type ApiClient, type RouterOutputs } from '../client.js';
|
|
4
|
-
import { type
|
|
4
|
+
import { type DownloadProgress } from '../types.js';
|
|
5
5
|
import { FileTypeResult } from 'file-type';
|
|
6
6
|
export declare class SecrecyCloudClient {
|
|
7
7
|
#private;
|
|
@@ -63,13 +63,13 @@ export declare class SecrecyCloudClient {
|
|
|
63
63
|
}): Promise<NodeFull>;
|
|
64
64
|
dataContent({ dataId, onDownloadProgress, progressDecrypt, signal, }: {
|
|
65
65
|
dataId: string;
|
|
66
|
-
onDownloadProgress?: (progress:
|
|
66
|
+
onDownloadProgress?: (progress: DownloadProgress) => void;
|
|
67
67
|
progressDecrypt?: ProgressCallback;
|
|
68
68
|
signal?: AbortSignal;
|
|
69
69
|
}): Promise<LocalData>;
|
|
70
70
|
dataContents({ dataIds, onDownloadProgress, progressDecrypt, signal, }: {
|
|
71
71
|
dataIds: string[];
|
|
72
|
-
onDownloadProgress?: (progress:
|
|
72
|
+
onDownloadProgress?: (progress: DownloadProgress) => void;
|
|
73
73
|
progressDecrypt?: ProgressCallback;
|
|
74
74
|
signal?: AbortSignal;
|
|
75
75
|
}): Promise<LocalData[]>;
|
|
@@ -104,23 +104,22 @@ export declare class SecrecyCloudClient {
|
|
|
104
104
|
toType: "s3" | "cold" | "lite";
|
|
105
105
|
}>;
|
|
106
106
|
getPublicDataLink(input: RouterInputs['cloud']['dataLink']): Promise<{
|
|
107
|
-
id: string;
|
|
108
107
|
name: string;
|
|
109
|
-
|
|
110
|
-
expireAt: Date | null;
|
|
108
|
+
id: string;
|
|
111
109
|
dataId: string;
|
|
110
|
+
expireAt: Date | null;
|
|
111
|
+
slug: string;
|
|
112
112
|
}>;
|
|
113
113
|
getPublicDataLinks(input: RouterInputs['cloud']['dataLinks']): Promise<{
|
|
114
|
-
id: string;
|
|
115
114
|
name: string;
|
|
116
|
-
|
|
117
|
-
expireAt: Date | null;
|
|
115
|
+
id: string;
|
|
118
116
|
dataId: string;
|
|
117
|
+
expireAt: Date | null;
|
|
118
|
+
slug: string;
|
|
119
119
|
}[]>;
|
|
120
120
|
checkAccesses(input: RouterInputs['cloud']['checkAccesses']): Promise<{
|
|
121
121
|
isMatching: true;
|
|
122
122
|
} | {
|
|
123
|
-
isMatching: false;
|
|
124
123
|
details: {
|
|
125
124
|
missingNodeAccesses: {
|
|
126
125
|
userId: string;
|
|
@@ -128,51 +127,52 @@ export declare class SecrecyCloudClient {
|
|
|
128
127
|
}[];
|
|
129
128
|
missingDataAccesses: {
|
|
130
129
|
userId: string;
|
|
131
|
-
nodeId: string;
|
|
132
130
|
dataId: string;
|
|
131
|
+
nodeId: string;
|
|
133
132
|
}[];
|
|
134
133
|
invalidRightsAccesses: {
|
|
135
134
|
userId: string;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
rights: "delete" | "read" | "write";
|
|
135
|
+
current: {
|
|
136
|
+
rights: "delete" | "write" | "read";
|
|
139
137
|
} & {
|
|
140
|
-
addAccess?: "delete" | "
|
|
141
|
-
sharingAddAccess?: "delete" | "
|
|
142
|
-
delAccess?: "delete" | "
|
|
143
|
-
sharingDelAccess?: "delete" | "
|
|
138
|
+
addAccess?: "delete" | "write" | "read" | null | undefined;
|
|
139
|
+
sharingAddAccess?: "delete" | "write" | "read" | null | undefined;
|
|
140
|
+
delAccess?: "delete" | "write" | "read" | null | undefined;
|
|
141
|
+
sharingDelAccess?: "delete" | "write" | "read" | null | undefined;
|
|
144
142
|
};
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
nodeId: string;
|
|
144
|
+
expect: {
|
|
145
|
+
rights: "delete" | "write" | "read";
|
|
147
146
|
} & {
|
|
148
|
-
addAccess?: "delete" | "
|
|
149
|
-
sharingAddAccess?: "delete" | "
|
|
150
|
-
delAccess?: "delete" | "
|
|
151
|
-
sharingDelAccess?: "delete" | "
|
|
147
|
+
addAccess?: "delete" | "write" | "read" | null | undefined;
|
|
148
|
+
sharingAddAccess?: "delete" | "write" | "read" | null | undefined;
|
|
149
|
+
delAccess?: "delete" | "write" | "read" | null | undefined;
|
|
150
|
+
sharingDelAccess?: "delete" | "write" | "read" | null | undefined;
|
|
152
151
|
};
|
|
153
152
|
}[];
|
|
154
153
|
};
|
|
154
|
+
isMatching: false;
|
|
155
155
|
}>;
|
|
156
156
|
createPublicDataLink(input: RouterInputs['cloud']['createDataLink']): Promise<{
|
|
157
|
-
id: string;
|
|
158
157
|
name: string;
|
|
159
|
-
|
|
160
|
-
expireAt: Date | null;
|
|
158
|
+
id: string;
|
|
161
159
|
dataId: string;
|
|
160
|
+
expireAt: Date | null;
|
|
161
|
+
slug: string;
|
|
162
162
|
}>;
|
|
163
163
|
updatePublicDataLink(input: RouterInputs['cloud']['updateDataLink']): Promise<{
|
|
164
|
-
id: string;
|
|
165
164
|
name: string;
|
|
166
|
-
|
|
167
|
-
expireAt: Date | null;
|
|
165
|
+
id: string;
|
|
168
166
|
dataId: string;
|
|
167
|
+
expireAt: Date | null;
|
|
168
|
+
slug: string;
|
|
169
169
|
}>;
|
|
170
170
|
deletePublicDataLink(input: RouterInputs['cloud']['deleteDataLink']): Promise<{
|
|
171
|
-
id: string;
|
|
172
171
|
name: string;
|
|
173
|
-
|
|
174
|
-
expireAt: Date | null;
|
|
172
|
+
id: string;
|
|
175
173
|
dataId: string;
|
|
174
|
+
expireAt: Date | null;
|
|
175
|
+
slug: string;
|
|
176
176
|
}>;
|
|
177
177
|
private _handleDataContent;
|
|
178
178
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient, type SecrecyUrls } from '../base-client.js';
|
|
2
|
-
import type {
|
|
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';
|
|
@@ -11,7 +11,7 @@ import { type KeyPair } from './types/index.js';
|
|
|
11
11
|
import { SecrecyUserClient } from './SecrecyUserClient.js';
|
|
12
12
|
import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
|
|
13
13
|
export type NewMail = Pick<RouterInputs['mail']['createDraft'], 'body' | 'subject' | 'senderFiles' | 'recipients' | 'replyToId'>;
|
|
14
|
-
export type ProgressCallback = (progress:
|
|
14
|
+
export type ProgressCallback = (progress: Progress) => Promise<void>;
|
|
15
15
|
export interface SecrecyClientOptions {
|
|
16
16
|
uaSession: string;
|
|
17
17
|
uaKeys: KeyPair;
|
|
@@ -7,14 +7,40 @@ export type * from './user.js';
|
|
|
7
7
|
declare const keyPair: z.ZodObject<{
|
|
8
8
|
publicKey: z.ZodString;
|
|
9
9
|
privateKey: z.ZodString;
|
|
10
|
-
}, z.
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
publicKey: string;
|
|
12
|
+
privateKey: string;
|
|
13
|
+
}, {
|
|
14
|
+
publicKey: string;
|
|
15
|
+
privateKey: string;
|
|
16
|
+
}>;
|
|
11
17
|
export type KeyPair = z.infer<typeof keyPair>;
|
|
12
18
|
export declare const secrecyUserApp: z.ZodReadonly<z.ZodObject<{
|
|
13
19
|
keys: z.ZodObject<{
|
|
14
20
|
publicKey: z.ZodString;
|
|
15
21
|
privateKey: z.ZodString;
|
|
16
|
-
}, z.
|
|
22
|
+
}, "strict", z.ZodTypeAny, {
|
|
23
|
+
publicKey: string;
|
|
24
|
+
privateKey: string;
|
|
25
|
+
}, {
|
|
26
|
+
publicKey: string;
|
|
27
|
+
privateKey: string;
|
|
28
|
+
}>;
|
|
17
29
|
jwt: z.ZodString;
|
|
18
30
|
uaSession: z.ZodString;
|
|
19
|
-
}, z.
|
|
31
|
+
}, "strict", z.ZodTypeAny, {
|
|
32
|
+
keys: {
|
|
33
|
+
publicKey: string;
|
|
34
|
+
privateKey: string;
|
|
35
|
+
};
|
|
36
|
+
jwt: string;
|
|
37
|
+
uaSession: string;
|
|
38
|
+
}, {
|
|
39
|
+
keys: {
|
|
40
|
+
publicKey: string;
|
|
41
|
+
privateKey: string;
|
|
42
|
+
};
|
|
43
|
+
jwt: string;
|
|
44
|
+
uaSession: string;
|
|
45
|
+
}>>;
|
|
20
46
|
export type SecrecyUserApp = z.infer<typeof secrecyUserApp>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type RouterOutputs } from '../../client.js';
|
|
2
2
|
import type { DataMetadata, InternalData, PublicUser } from './index.js';
|
|
3
|
-
export type
|
|
4
|
-
export type Rights =
|
|
5
|
-
export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T &
|
|
3
|
+
export type Permissions = ApiNode['users'][number][1];
|
|
4
|
+
export type Rights = Permissions['rights'];
|
|
5
|
+
export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T & Permissions & {
|
|
6
6
|
isRoot: boolean;
|
|
7
7
|
sharedByPubKey: string;
|
|
8
8
|
};
|
|
@@ -33,7 +33,7 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
|
|
|
33
33
|
breadcrumb: T[];
|
|
34
34
|
owner: PublicUser;
|
|
35
35
|
access: NodeAccess<U>;
|
|
36
|
-
users: Array<[PublicUser,
|
|
36
|
+
users: Array<[PublicUser, Permissions]>;
|
|
37
37
|
currentDataId: string | null;
|
|
38
38
|
parentId: string | null;
|
|
39
39
|
}
|
|
@@ -82,9 +82,9 @@ export type ShareNodeDetails = {
|
|
|
82
82
|
}[];
|
|
83
83
|
invalidRightsAccesses: {
|
|
84
84
|
userId: string;
|
|
85
|
-
current:
|
|
85
|
+
current: Permissions;
|
|
86
86
|
nodeId: string;
|
|
87
|
-
expect:
|
|
87
|
+
expect: Permissions;
|
|
88
88
|
}[];
|
|
89
89
|
};
|
|
90
90
|
export {};
|