@secrecy/lib 1.49.0-feat-report-data.1 → 1.49.0-feat-report-data.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.
@@ -9,7 +9,7 @@ import { sodium } from '../sodium.js';
9
9
  import { enumerate, chunks, concatenate } from '../utils/array.js';
10
10
  import { md5 } from '../worker/md5.js';
11
11
  import { decrypt, encrypt } from '../worker/sodium.js';
12
- import { apiDataToExternal } from './convert/data.js';
12
+ import { apiDataToExternal, apiDataToInternal } from './convert/data.js';
13
13
  import { apiNodeFullToInternalFull, apiNodeToExternal, apiNodeToExternalNodeFull, internalNodeFullToNodeFull, } from './convert/node.js';
14
14
  import { promiseAllLimit } from '../utils/promise.js';
15
15
  import { kiloToBytes } from '../utils.js';
@@ -550,19 +550,15 @@ export class SecrecyCloudClient {
550
550
  };
551
551
  };
552
552
  async reportData({ id, reasons, }) {
553
- const [data, secrecy] = await Promise.all([
553
+ const [rawData, secrecy] = await Promise.all([
554
554
  this.#apiClient.cloud.dataById.query({ id }),
555
555
  this.#apiClient.misc.publicKey.query(),
556
556
  ]);
557
- if (!data.access.key) {
558
- throw new Error('Unable to retreive data key!');
559
- }
560
- const decryptedDataKey = decryptCryptoBox(sodium.from_hex(data.access.key), this.#keys.publicKey, this.#keys.privateKey);
561
- const encryptedDataKey = sodium.to_hex(encryptCryptoBox(decryptedDataKey, secrecy.publicKey, this.#keys.privateKey));
557
+ const data = apiDataToInternal(rawData, this.#keys);
562
558
  return this.#apiClient.cloud.reportData.mutate({
563
- id,
564
- reasons,
565
- encryptedDataKey,
559
+ id: id,
560
+ reasons: reasons,
561
+ encryptedDataKey: data.key,
566
562
  });
567
563
  }
568
564
  }
@@ -3503,12 +3503,12 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
3503
3503
  _input_in: {
3504
3504
  id: string;
3505
3505
  reasons: "data_leak"[];
3506
- encryptedDataKey: string;
3506
+ encryptedDataKey: string | null;
3507
3507
  };
3508
3508
  _input_out: {
3509
3509
  id: string;
3510
3510
  reasons: "data_leak"[];
3511
- encryptedDataKey: string;
3511
+ encryptedDataKey: string | null;
3512
3512
  };
3513
3513
  _output_in: {
3514
3514
  isReported: boolean;
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.49.0-feat-report-data.1",
5
+ "version": "1.49.0-feat-report-data.3",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"
@@ -74,7 +74,7 @@
74
74
  "typescript": "^5.6.2"
75
75
  },
76
76
  "dependencies": {
77
- "@secrecy/trpc-api-types": "1.33.0-feat-report-data-content.5",
77
+ "@secrecy/trpc-api-types": "1.33.0-feat-report-data-content.6",
78
78
  "@trpc/client": "10.45.2",
79
79
  "@trpc/server": "10.45.2",
80
80
  "@types/libsodium-wrappers-sumo": "^0.7.8",