@secrecy/lib 1.74.0-feat-groups-identity.4 → 1.74.0-feat-transfer-adaptations.1

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.
Files changed (54) hide show
  1. package/dist/lib/base-client.js +4 -27
  2. package/dist/lib/client/SecrecyAppClient.js +17 -13
  3. package/dist/lib/client/SecrecyCloudClient.js +156 -368
  4. package/dist/lib/client/SecrecyDbClient.js +7 -3
  5. package/dist/lib/client/SecrecyMailClient.js +48 -38
  6. package/dist/lib/client/SecrecyOrganizationClient.js +12 -10
  7. package/dist/lib/client/SecrecyPayClient.js +5 -1
  8. package/dist/lib/client/SecrecyPseudonymClient.js +8 -4
  9. package/dist/lib/client/SecrecyUserClient.js +11 -11
  10. package/dist/lib/client/SecrecyWalletClient.js +2 -0
  11. package/dist/lib/client/convert/data.js +4 -4
  12. package/dist/lib/client/convert/mail.js +6 -5
  13. package/dist/lib/client/convert/node.js +34 -46
  14. package/dist/lib/client/data-link.js +77 -0
  15. package/dist/lib/client/download.js +84 -0
  16. package/dist/lib/client/helpers.js +11 -18
  17. package/dist/lib/client/index.js +12 -48
  18. package/dist/lib/client/storage.js +2 -3
  19. package/dist/lib/client/types/index.js +7 -3
  20. package/dist/lib/client/upload.js +252 -0
  21. package/dist/lib/client.js +7 -0
  22. package/dist/lib/crypto/data.js +3 -0
  23. package/dist/lib/crypto/domain.js +123 -12
  24. package/dist/lib/crypto/helpers.js +23 -0
  25. package/dist/lib/index.js +0 -1
  26. package/dist/types/base-client.d.ts +1 -2
  27. package/dist/types/client/SecrecyAppClient.d.ts +3 -2
  28. package/dist/types/client/SecrecyCloudClient.d.ts +28 -20
  29. package/dist/types/client/SecrecyDbClient.d.ts +3 -1
  30. package/dist/types/client/SecrecyMailClient.d.ts +3 -2
  31. package/dist/types/client/SecrecyOrganizationClient.d.ts +3 -2
  32. package/dist/types/client/SecrecyPayClient.d.ts +3 -1
  33. package/dist/types/client/SecrecyPseudonymClient.d.ts +3 -2
  34. package/dist/types/client/SecrecyUserClient.d.ts +3 -2
  35. package/dist/types/client/convert/data.d.ts +3 -3
  36. package/dist/types/client/convert/mail.d.ts +5 -3
  37. package/dist/types/client/convert/node.d.ts +5 -5
  38. package/dist/types/client/data-link.d.ts +37 -0
  39. package/dist/types/client/download.d.ts +2 -0
  40. package/dist/types/client/index.d.ts +3 -11
  41. package/dist/types/client/storage.d.ts +2 -3
  42. package/dist/types/client/types/index.d.ts +9 -13
  43. package/dist/types/client/types/mail.d.ts +1 -2
  44. package/dist/types/client/types/node.d.ts +9 -12
  45. package/dist/types/client/types/user.d.ts +0 -15
  46. package/dist/types/client/upload.d.ts +38 -0
  47. package/dist/types/client.d.ts +6174 -681
  48. package/dist/types/crypto/domain.d.ts +36 -8
  49. package/dist/types/crypto/helpers.d.ts +12 -0
  50. package/dist/types/crypto/index.d.ts +3 -3
  51. package/dist/types/index.d.ts +1 -2
  52. package/package.json +4 -2
  53. package/dist/lib/client/types/identity.js +0 -18
  54. package/dist/types/client/types/identity.d.ts +0 -29
@@ -1,10 +1,38 @@
1
- export declare function encryptName(name: string, nameKey: string): Promise<string>;
2
- export declare function generateAndEncryptNameAndKey(args: {
3
- name: string;
4
- privateKey: string;
5
- publicKey: string;
1
+ import { type Progress } from '../types.js';
2
+ import { ApiExtendedData, KeyPair } from '../client/types';
3
+ import { ProgressCallback } from '../client/index';
4
+ import z from 'zod';
5
+ import { downloadDataLinkSchema } from '../client/data-link.js';
6
+ /**
7
+ * Encrypt the dataKey and the data as logged or guest user.
8
+ * If a string is provided as keypair, it should be considered as guest with password case.
9
+ * If keypair is not provided, then we generate a key to be used as password for guest too.
10
+ */
11
+ export declare function encryptDataAndKey({ data, keyPair, progress, signal, }: {
12
+ data: Uint8Array<ArrayBuffer>;
13
+ keyPair?: KeyPair;
14
+ progress?: ProgressCallback;
15
+ signal?: AbortSignal;
6
16
  }): Promise<{
7
- nameKey: Uint8Array<ArrayBufferLike>;
8
- encryptedName: string;
9
- encryptedNameKey: string;
17
+ encryptedDataKey?: Uint8Array<ArrayBufferLike>;
18
+ encryptedData: Uint8Array<ArrayBuffer>;
19
+ dataKey: Uint8Array<ArrayBufferLike>;
20
+ md5Data: string;
21
+ md5Encrypted: string;
10
22
  }>;
23
+ export declare function buildBytesFromApiData({ dataContent, totalBytes, progressParts, onDownloadProgress, signal, }: {
24
+ dataContent: ApiExtendedData;
25
+ totalBytes: number;
26
+ progressParts: Record<string, Progress>;
27
+ onDownloadProgress?: (progress: Progress) => void;
28
+ progressDecrypt?: ProgressCallback;
29
+ signal?: AbortSignal;
30
+ }): Promise<{
31
+ encryptedContent: Uint8Array<ArrayBuffer>;
32
+ }>;
33
+ export declare function buildBytesFromDataLink({ dataLink, totalBytes, onDownloadProgress, signal, }: {
34
+ dataLink: z.output<typeof downloadDataLinkSchema>;
35
+ totalBytes: number;
36
+ onDownloadProgress?: (progress: Progress) => void;
37
+ signal?: AbortSignal;
38
+ }): Promise<Uint8Array<ArrayBuffer>>;
@@ -0,0 +1,12 @@
1
+ export declare function generatePassword(): string;
2
+ export declare function derivePassword(password: string, salt: Uint8Array<ArrayBufferLike>): string;
3
+ export declare function encryptName(name: string, nameKey: string): Promise<string>;
4
+ export declare function generateAndEncryptNameAndKey(args: {
5
+ name: string;
6
+ privateKey: string;
7
+ publicKey: string;
8
+ }): Promise<{
9
+ nameKey: Uint8Array<ArrayBufferLike>;
10
+ encryptedName: string;
11
+ encryptedNameKey: string;
12
+ }>;
@@ -1,9 +1,9 @@
1
- import { sodium } from '../sodium.js';
1
+ import { type KeyPair } from '../client/types/index.js';
2
2
  export declare function encryptCryptoBox(data: Uint8Array, publicKeyBob: string, privateKeyAlice: string): Uint8Array;
3
- export declare function generateCryptoBoxKeyPair(): sodium.StringKeyPair;
3
+ export declare function generateCryptoBoxKeyPair(): KeyPair;
4
4
  export declare function decryptCryptoBox(data: Uint8Array, publicKeyAlice: string, privateKeyBob: string): Uint8Array;
5
5
  export declare function generateSecretBoxKey(): string;
6
6
  export declare function encryptSecretBox(data: Uint8Array, key: string): Uint8Array;
7
7
  export declare function decryptSecretBox(data: Uint8Array, key: string): Uint8Array;
8
8
  export declare function encryptAnonymous(data: Uint8Array, receiverPublicKey: string): Uint8Array;
9
- export declare function decryptAnonymous(data: Uint8Array, { privateKey, publicKey }: Omit<sodium.StringKeyPair, 'keyType'>): Uint8Array;
9
+ export declare function decryptAnonymous(data: Uint8Array, { privateKey, publicKey }: KeyPair): Uint8Array;
@@ -2,8 +2,7 @@ export * from './client/index.js';
2
2
  export * from './crypto/index.js';
3
3
  export type { SecretStreamProgress } from './crypto/data.js';
4
4
  export { BaseClient } from './base-client.js';
5
- export type { Node, NodeFull, DataMetadata, SecrecyUserApp, BaseMail, ReceivedMail, SentMail, PublicUser, SelfUser, NodeSize, MailData, MailIntegrity, DraftMail, Mail, WaitingReceivedMail, } from './client/types/index.js';
6
- export * from './client/types/identity.js';
5
+ export type { Node, NodeFull, DataMetadata, SecrecyUserApp, BaseMail, ReceivedMail, SentMail, PublicUser, SelfUser, NodeSize, MailData, MailIntegrity, DraftMail, Mail, WaitingReceivedMail, KeyPair, } from './client/types/index.js';
7
6
  export * from './client/helpers.js';
8
7
  export * from './sodium.js';
9
8
  export * from './utils/store-buddy.js';
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.0-feat-groups-identity.4",
5
+ "version": "1.74.0-feat-transfer-adaptations.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"
@@ -55,6 +55,7 @@
55
55
  "@types/bun": "^1.2.21",
56
56
  "@types/jsonwebtoken": "^9.0.10",
57
57
  "@types/spark-md5": "^3.0.5",
58
+ "@types/streamsaver": "^2.0.5",
58
59
  "@typescript-eslint/eslint-plugin": "^8.44.0",
59
60
  "@typescript-eslint/parser": "^8.44.0",
60
61
  "eslint": "^9.35.0",
@@ -75,7 +76,7 @@
75
76
  },
76
77
  "dependencies": {
77
78
  "@js-temporal/polyfill": "^0.5.1",
78
- "@secrecy/trpc-api-types": "1.33.0-feat-groups-identity.9",
79
+ "@secrecy/trpc-api-types": "1.33.0-feat-side-fixes.1",
79
80
  "@trpc/client": "11.5.1",
80
81
  "@trpc/server": "^11.5.1",
81
82
  "@types/libsodium-wrappers-sumo": "^0.7.8",
@@ -88,6 +89,7 @@
88
89
  "libsodium-wrappers-sumo": "^0.7.15",
89
90
  "lru-cache": "^11.2.1",
90
91
  "spark-md5": "^3.0.2",
92
+ "streamsaver": "^2.0.6",
91
93
  "superjson": "2.2.2",
92
94
  "zod": "4.1.9"
93
95
  }
@@ -1,18 +0,0 @@
1
- import { z } from 'zod/v4';
2
- export const userAppSchema = z.object({
3
- kind: z.literal('USER_APP'),
4
- identityPubKey: z.string(),
5
- userId: z.string(),
6
- appId: z.string(),
7
- });
8
- export const groupSchema = z.object({
9
- kind: z.literal('GROUP'),
10
- identityPubKey: z.string(),
11
- groupId: z.string(),
12
- sharedByPubKey: z.string(),
13
- groupOwnerPubKey: z.string(),
14
- });
15
- export const accessIdentitySchema = z.discriminatedUnion('kind', [
16
- userAppSchema,
17
- groupSchema,
18
- ]);
@@ -1,29 +0,0 @@
1
- import { z } from 'zod/v4';
2
- export declare const userAppSchema: z.ZodObject<{
3
- kind: z.ZodLiteral<"USER_APP">;
4
- identityPubKey: z.ZodString;
5
- userId: z.ZodString;
6
- appId: z.ZodString;
7
- }, z.core.$strip>;
8
- export declare const groupSchema: z.ZodObject<{
9
- kind: z.ZodLiteral<"GROUP">;
10
- identityPubKey: z.ZodString;
11
- groupId: z.ZodString;
12
- sharedByPubKey: z.ZodString;
13
- groupOwnerPubKey: z.ZodString;
14
- }, z.core.$strip>;
15
- export declare const accessIdentitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
16
- kind: z.ZodLiteral<"USER_APP">;
17
- identityPubKey: z.ZodString;
18
- userId: z.ZodString;
19
- appId: z.ZodString;
20
- }, z.core.$strip>, z.ZodObject<{
21
- kind: z.ZodLiteral<"GROUP">;
22
- identityPubKey: z.ZodString;
23
- groupId: z.ZodString;
24
- sharedByPubKey: z.ZodString;
25
- groupOwnerPubKey: z.ZodString;
26
- }, z.core.$strip>], "kind">;
27
- export type AccessIdentity = z.infer<typeof accessIdentitySchema>;
28
- export type UserAppIdentity = z.infer<typeof userAppSchema>;
29
- export type GroupIdentity = z.infer<typeof groupSchema>;