@secrecy/lib 1.74.5 → 1.74.7

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.
@@ -619,6 +619,7 @@ export class SecrecyCloudClient {
619
619
  const decompressed = decompress(src);
620
620
  dataContentCache.set(dataContent.id, {
621
621
  id: dataContent.id,
622
+ md5: dataContent.md5,
622
623
  size: dataContent.size,
623
624
  sizeEncrypted: dataContent.sizeEncrypted,
624
625
  storageType: dataContent.storageType,
@@ -628,6 +629,7 @@ export class SecrecyCloudClient {
628
629
  });
629
630
  return {
630
631
  id: dataContent.id,
632
+ md5: dataContent.md5,
631
633
  size: dataContent.size,
632
634
  sizeEncrypted: dataContent.sizeEncrypted,
633
635
  storageType: dataContent.storageType,
@@ -32,10 +32,7 @@ export const downloadDataLinkSchema = z.union([
32
32
  export async function downloadDataFromLink(opts) {
33
33
  let dataUrl = opts.dataUrl ?? 'https://data.secrecy.tech/';
34
34
  dataUrl = dataUrl.endsWith('/') ? dataUrl : `${dataUrl}/`;
35
- const rawDataLink = await fetch(`${dataUrl}${opts.dataLinkSlug}/json`, {
36
- mode: 'no-cors',
37
- credentials: 'include',
38
- })
35
+ const rawDataLink = await fetch(`${dataUrl}${opts.dataLinkSlug}/json`)
39
36
  .then((res) => res.json())
40
37
  .catch((err) => {
41
38
  throw new Error(`Unable to fetch "${`${dataUrl}${opts.dataLinkSlug}/json"`}`, { cause: err });
@@ -119,6 +119,7 @@ export async function uploadData({ storageType, data, password, forcePassword =
119
119
  const localData = {
120
120
  id: uploadData.id,
121
121
  storageType: 'lite',
122
+ md5: uploadDataArgs.md5,
122
123
  size: uploadDataArgs.size,
123
124
  sizeEncrypted: uploadDataArgs.sizeEncrypted ?? null,
124
125
  data: dataBuffer,
@@ -170,6 +171,7 @@ export async function uploadData({ storageType, data, password, forcePassword =
170
171
  const localData = {
171
172
  id: uploadData.id,
172
173
  storageType: storageType,
174
+ md5: uploadDataArgs.md5,
173
175
  size: uploadDataArgs.size,
174
176
  sizeEncrypted: uploadDataArgs.sizeEncrypted ?? null,
175
177
  data: dataBuffer,
@@ -230,6 +232,7 @@ export async function uploadData({ storageType, data, password, forcePassword =
230
232
  const localData = {
231
233
  id: uploadData.id,
232
234
  storageType: storageType,
235
+ md5: uploadDataArgs.md5,
233
236
  size: uploadDataArgs.size,
234
237
  sizeEncrypted: uploadDataArgs.sizeEncrypted ?? null,
235
238
  data: dataBuffer,
@@ -0,0 +1,47 @@
1
+ import { getTrpcGuestClient } from './client';
2
+ import { downloadDataFromLink } from './client/data-link';
3
+ import { createPublicDataLink, uploadData } from './client/upload';
4
+ import { setup } from './sodium';
5
+ await setup();
6
+ // const keyPair = {
7
+ // publicKey: '71469f1d931849dab91e8a62bee6c1f442a3f5f64323d14ee0d6ce5200a0640a',
8
+ // privateKey:
9
+ // '427b28fe3835956af5bb457db59884251f19f1228101f336934aff99375dfedc',
10
+ // }
11
+ // const client = createTRPCClient({
12
+ // apiUrl: 'http://localhost:3000/api',
13
+ // session: 'e34db69c7057d2143dab8b0b5054806796818c7da976d8e8275dd017920c3377',
14
+ // })
15
+ const keyPair = undefined;
16
+ const client = getTrpcGuestClient({ url: 'http://localhost:3000/api' });
17
+ const buffer = Buffer.from('10000randomflkhsdjkfhsdfjh');
18
+ console.log({ buffer, strbuff: buffer.toString() });
19
+ const uploaded = await uploadData({
20
+ data: buffer,
21
+ storageType: 's3',
22
+ encrypted: true,
23
+ apiClient: client,
24
+ keyPair,
25
+ password: 'mot-de-passe',
26
+ // forcePassword: true,
27
+ });
28
+ console.dir({ uploaded });
29
+ const link = await createPublicDataLink({
30
+ dataId: uploaded.id,
31
+ expireAt: new Date(Date.now() + 1000 * 60 * 60 * 1),
32
+ name: 'Public test',
33
+ apiClient: client,
34
+ });
35
+ console.dir({ link });
36
+ // - downloadDataFromLink ajouter client auth
37
+ const data = await downloadDataFromLink({
38
+ dataUrl: 'http://localhost:3000/data',
39
+ dataLinkSlug: link.slug,
40
+ crypto: uploaded.sharing
41
+ ? {
42
+ key: uploaded.sharing.encryptedDataKey,
43
+ password: uploaded.sharing.password,
44
+ }
45
+ : undefined,
46
+ });
47
+ console.dir({ data, txt: Buffer.from(data).toString() });
@@ -7,6 +7,7 @@ export type LocalData = {
7
7
  storageType: DataStorageType;
8
8
  size: bigint;
9
9
  sizeEncrypted: bigint | null;
10
+ md5: string;
10
11
  data: Uint8Array<ArrayBuffer>;
11
12
  mime?: string;
12
13
  ext?: string;
@@ -0,0 +1 @@
1
+ export {};
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.74.5",
5
+ "version": "1.74.7",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"