@secrecy/lib 1.74.6 → 1.75.0-feat-groups-identity.2

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 +26 -2
  2. package/dist/lib/client/SecrecyAppClient.js +14 -18
  3. package/dist/lib/client/SecrecyCloudClient.js +130 -135
  4. package/dist/lib/client/SecrecyDbClient.js +1 -8
  5. package/dist/lib/client/SecrecyMailClient.js +38 -48
  6. package/dist/lib/client/SecrecyOrganizationClient.js +10 -12
  7. package/dist/lib/client/SecrecyPayClient.js +1 -5
  8. package/dist/lib/client/SecrecyPseudonymClient.js +4 -8
  9. package/dist/lib/client/SecrecyUserClient.js +11 -11
  10. package/dist/lib/client/SecrecyWalletClient.js +0 -2
  11. package/dist/lib/client/convert/data.js +8 -4
  12. package/dist/lib/client/convert/mail.js +8 -6
  13. package/dist/lib/client/convert/node.js +59 -34
  14. package/dist/lib/client/data-link.js +4 -1
  15. package/dist/lib/client/helpers.js +17 -7
  16. package/dist/lib/client/index.js +48 -12
  17. package/dist/lib/client/storage.js +3 -2
  18. package/dist/lib/client/types/identity.js +19 -0
  19. package/dist/lib/client/types/index.js +3 -7
  20. package/dist/lib/client/upload.js +20 -17
  21. package/dist/lib/crypto/data.js +4 -4
  22. package/dist/lib/crypto/domain.js +10 -10
  23. package/dist/lib/index.js +1 -0
  24. package/dist/lib/minify/lz4.js +1 -0
  25. package/dist/lib/utils/links.js +5 -5
  26. package/dist/lib/utils.js +1 -1
  27. package/dist/lib/worker/sodium.js +2 -2
  28. package/dist/types/base-client.d.ts +3 -1
  29. package/dist/types/client/SecrecyAppClient.d.ts +2 -3
  30. package/dist/types/client/SecrecyCloudClient.d.ts +19 -19
  31. package/dist/types/client/SecrecyDbClient.d.ts +1 -4
  32. package/dist/types/client/SecrecyMailClient.d.ts +2 -3
  33. package/dist/types/client/SecrecyOrganizationClient.d.ts +2 -3
  34. package/dist/types/client/SecrecyPayClient.d.ts +1 -3
  35. package/dist/types/client/SecrecyPseudonymClient.d.ts +2 -3
  36. package/dist/types/client/SecrecyUserClient.d.ts +2 -3
  37. package/dist/types/client/convert/data.d.ts +3 -3
  38. package/dist/types/client/convert/mail.d.ts +3 -5
  39. package/dist/types/client/convert/node.d.ts +5 -5
  40. package/dist/types/client/data-link.d.ts +2 -2
  41. package/dist/types/client/index.d.ts +11 -3
  42. package/dist/types/client/storage.d.ts +3 -2
  43. package/dist/types/client/types/identity.d.ts +37 -0
  44. package/dist/types/client/types/index.d.ts +17 -9
  45. package/dist/types/client/types/mail.d.ts +2 -1
  46. package/dist/types/client/types/node.d.ts +12 -9
  47. package/dist/types/client/types/user.d.ts +15 -0
  48. package/dist/types/client/upload.d.ts +8 -7
  49. package/dist/types/client.d.ts +1438 -1050
  50. package/dist/types/crypto/data.d.ts +2 -2
  51. package/dist/types/crypto/domain.d.ts +6 -4
  52. package/dist/types/crypto/index.d.ts +3 -3
  53. package/dist/types/index.d.ts +2 -1
  54. package/package.json +21 -21
@@ -1,6 +1,6 @@
1
1
  import z from 'zod';
2
- import { ProgressCallback } from '.';
3
- import { Progress } from 'ky';
2
+ import { type ProgressCallback } from '.';
3
+ import { type Progress } from 'ky';
4
4
  export declare const downloadDataLinkSchema: z.ZodUnion<readonly [z.ZodObject<{
5
5
  name: z.ZodString;
6
6
  md5: z.ZodString;
@@ -6,16 +6,17 @@ import { SecrecyAppClient } from './SecrecyAppClient.js';
6
6
  import { SecrecyDbClient } from './SecrecyDbClient.js';
7
7
  import { SecrecyWalletClient } from './SecrecyWalletClient.js';
8
8
  import { SecrecyPayClient } from './SecrecyPayClient.js';
9
- import { ApiClient, type RouterInputs } from '../client.js';
10
- import { type KeyPair } from './types/index.js';
9
+ import { type ApiClient, type RouterInputs, type RouterOutputs } from '../client.js';
11
10
  import { SecrecyUserClient } from './SecrecyUserClient.js';
12
11
  import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
13
12
  import { SecrecyOrganizationClient } from './SecrecyOrganizationClient.js';
13
+ import type { AccessIdentity, GroupIdentity, UserAppIdentity } from './types/identity.js';
14
14
  export type NewMail = Pick<RouterInputs['mail']['createDraft'], 'body' | 'subject' | 'senderFiles' | 'recipients' | 'replyToId'>;
15
15
  export type ProgressCallback = (progress: SecretStreamProgress) => Promise<void>;
16
16
  export interface SecrecyClientOptions {
17
17
  uaSession: string;
18
- uaKeys: KeyPair;
18
+ identities: AccessIdentity[];
19
+ keyPairs: Record<string, string>;
19
20
  uaJwt: string;
20
21
  apiClient?: ApiClient;
21
22
  secrecyUrls?: Partial<SecrecyUrls>;
@@ -33,6 +34,13 @@ export declare class SecrecyClient extends BaseClient {
33
34
  pseudonym: SecrecyPseudonymClient;
34
35
  constructor(opts: SecrecyClientOptions);
35
36
  get publicKey(): string;
37
+ get apiClient(): Readonly<ApiClient>;
38
+ get keyPairs(): Readonly<Record<string, string>>;
39
+ getPrivateKey(pubKey: string): string;
40
+ get uaPrivateKey(): string;
41
+ get groupIdentities(): ReadonlyArray<Readonly<GroupIdentity>>;
42
+ get uaIdentity(): Readonly<UserAppIdentity>;
36
43
  decryptAnonymous(data: Uint8Array): Uint8Array;
37
44
  logout(sessionId?: string | null | undefined): Promise<void>;
45
+ getIdentities(input: RouterInputs['identity']['getMany']): Promise<RouterOutputs['identity']['getMany']>;
38
46
  }
@@ -1,7 +1,8 @@
1
1
  import type { StoreBuddy } from '../utils/store-buddy.js';
2
- import { type KeyPair } from './types/index.js';
2
+ import type { AccessIdentity } from './types/identity.js';
3
3
  export declare function getStorage(session?: boolean | undefined): {
4
- userAppKeys: StoreBuddy<KeyPair | null>;
4
+ identities: StoreBuddy<AccessIdentity[] | null>;
5
+ keyPairs: StoreBuddy<Record<string, string> | null>;
5
6
  userAppSession: StoreBuddy<string | null>;
6
7
  jwt: StoreBuddy<string | null>;
7
8
  };
@@ -0,0 +1,37 @@
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
+ groupRole: z.ZodEnum<{
13
+ ADMIN: "ADMIN";
14
+ MEMBER: "MEMBER";
15
+ }>;
16
+ sharedByPubKey: z.ZodString;
17
+ groupOwnerPubKey: z.ZodString;
18
+ }, z.core.$strip>;
19
+ export declare const accessIdentitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
20
+ kind: z.ZodLiteral<"USER_APP">;
21
+ identityPubKey: z.ZodString;
22
+ userId: z.ZodString;
23
+ appId: z.ZodString;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ kind: z.ZodLiteral<"GROUP">;
26
+ identityPubKey: z.ZodString;
27
+ groupId: z.ZodString;
28
+ groupRole: z.ZodEnum<{
29
+ ADMIN: "ADMIN";
30
+ MEMBER: "MEMBER";
31
+ }>;
32
+ sharedByPubKey: z.ZodString;
33
+ groupOwnerPubKey: z.ZodString;
34
+ }, z.core.$strip>], "kind">;
35
+ export type AccessIdentity = z.infer<typeof accessIdentitySchema>;
36
+ export type UserAppIdentity = z.infer<typeof userAppSchema>;
37
+ export type GroupIdentity = z.infer<typeof groupSchema>;
@@ -4,16 +4,24 @@ export type * from './data.js';
4
4
  export type * from './node.js';
5
5
  export type * from './mail.js';
6
6
  export type * from './user.js';
7
- declare const keyPair: z.ZodObject<{
8
- publicKey: z.ZodString;
9
- privateKey: z.ZodString;
10
- }, z.core.$strict>;
11
- export type KeyPair = z.infer<typeof keyPair>;
12
7
  export declare const secrecyUserApp: z.ZodReadonly<z.ZodObject<{
13
- keys: z.ZodObject<{
14
- publicKey: z.ZodString;
15
- privateKey: z.ZodString;
16
- }, z.core.$strict>;
8
+ identities: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
9
+ kind: z.ZodLiteral<"USER_APP">;
10
+ identityPubKey: z.ZodString;
11
+ userId: z.ZodString;
12
+ appId: z.ZodString;
13
+ }, z.core.$strip>, z.ZodObject<{
14
+ kind: z.ZodLiteral<"GROUP">;
15
+ identityPubKey: z.ZodString;
16
+ groupId: z.ZodString;
17
+ groupRole: z.ZodEnum<{
18
+ ADMIN: "ADMIN";
19
+ MEMBER: "MEMBER";
20
+ }>;
21
+ sharedByPubKey: z.ZodString;
22
+ groupOwnerPubKey: z.ZodString;
23
+ }, z.core.$strip>], "kind">>;
24
+ keyPairs: z.ZodRecord<z.ZodString, z.ZodString>;
17
25
  jwt: z.ZodString;
18
26
  uaSession: z.ZodString;
19
27
  }, z.core.$strict>>;
@@ -13,7 +13,7 @@ export interface BaseMail {
13
13
  deletedAt: Date | null;
14
14
  openedAt: Date | null;
15
15
  isAltered: boolean;
16
- recipients: Array<Omit<PublicUser, 'publicKey'>>;
16
+ recipients: Array<PublicUser>;
17
17
  temporaryRecipients: TemporaryMailUser[];
18
18
  attachments: Array<{
19
19
  id: string;
@@ -24,6 +24,7 @@ export interface BaseMail {
24
24
  export interface ReceivedMail extends BaseMail {
25
25
  type: 'received';
26
26
  sender: PublicUser;
27
+ senderPublicKey: string;
27
28
  }
28
29
  export interface InternalSentMail {
29
30
  user: {
@@ -1,17 +1,19 @@
1
1
  import { type RouterOutputs } from '../../client.js';
2
- import type { DataMetadata, InternalData, PublicUser } from './index.js';
3
- export type Permissions = ApiNode['users'][number][1];
2
+ import type { DataMetadata, InternalData, UserAppOrg } from './index.js';
3
+ export type Permissions = ApiNode['identities'][number];
4
4
  export type Rights = Permissions['rights'];
5
5
  export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T & Permissions & {
6
6
  isRoot: boolean;
7
7
  sharedByPubKey: string;
8
+ identityPubKey: string;
8
9
  };
9
10
  export interface NodeBreadcrumbItem {
10
11
  id: string;
11
12
  name: string;
12
13
  }
13
14
  export interface NodeBreadcrumbItemWithPubKey extends NodeBreadcrumbItem {
14
- pubKey: string;
15
+ sharedByPubKey: string;
16
+ identityPubKey: string;
15
17
  }
16
18
  export interface NodeSize {
17
19
  size: bigint;
@@ -31,9 +33,10 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
31
33
  sizes: NodeSize;
32
34
  name: string;
33
35
  breadcrumb: T[];
34
- owner: PublicUser;
35
- access: NodeAccess<U>;
36
- users: Array<[PublicUser, Permissions]>;
36
+ owner: UserAppOrg;
37
+ accesses: NodeAccess<U>[];
38
+ permissions: Permissions;
39
+ identities: Record<string, Permissions>;
37
40
  currentDataId: string | null;
38
41
  parentId: string | null;
39
42
  }
@@ -72,16 +75,16 @@ export type EncryptedNodeInfos = {
72
75
  };
73
76
  export type ShareNodeDetails = {
74
77
  missingNodeAccesses: {
75
- userId: string;
78
+ pubKey: string;
76
79
  nodeId: string;
77
80
  }[];
78
81
  missingDataAccesses: {
79
- userId: string;
82
+ pubKey: string;
80
83
  dataId: string;
81
84
  nodeId: string;
82
85
  }[];
83
86
  invalidRightsAccesses: {
84
- userId: string;
87
+ pubKey: string;
85
88
  current: Permissions;
86
89
  nodeId: string;
87
90
  expect: Permissions;
@@ -1,3 +1,18 @@
1
1
  import { type RouterOutputs } from '../../client.js';
2
2
  export type SelfUser = RouterOutputs['user']['self'];
3
3
  export type PublicUser = RouterOutputs['user']['byId'];
4
+ export type UserAppOrg = RouterOutputs['cloud']['nodeById']['owner'];
5
+ export type AccessIdentity = RouterOutputs['identity']['list']['identities'][number];
6
+ export type PublicAccessIdentity = RouterOutputs['identity']['get']['identity'];
7
+ export type PublicUserAppIdentity = Extract<PublicAccessIdentity, {
8
+ kind: 'USER_APP';
9
+ }>;
10
+ export type PublicGroupIdentity = Extract<PublicAccessIdentity, {
11
+ kind: 'GROUP';
12
+ }>;
13
+ export type UserAppIdentity = Extract<AccessIdentity, {
14
+ kind: 'USER_APP';
15
+ }>;
16
+ export type GroupIdentity = Extract<AccessIdentity, {
17
+ kind: 'GROUP';
18
+ }>;
@@ -1,8 +1,8 @@
1
- import { DataStorageType, LocalData } from './types/data.js';
2
- import { ProgressCallback } from './index.js';
3
- import { FileTypeResult } from 'file-type';
4
- import { KeyPair } from './types/index.js';
5
- import { ApiClient, RouterInputs } from '../client.js';
1
+ import type { DataStorageType, LocalData } from './types/data.js';
2
+ import type { ProgressCallback } from './index.js';
3
+ import { type FileTypeResult } from 'file-type';
4
+ import { type ApiClient, type RouterInputs } from '../client.js';
5
+ import type { UserAppIdentity } from './types/identity.js';
6
6
  export type UploadDataOptions = {
7
7
  storageType: DataStorageType;
8
8
  data: globalThis.File | Uint8Array<ArrayBuffer>;
@@ -14,8 +14,9 @@ export type UploadDataOptions = {
14
14
  meta?: FileTypeResult | true;
15
15
  forcePassword?: boolean;
16
16
  };
17
- export declare function uploadData({ storageType, data, password, forcePassword, encrypted, encryptProgress, uploadProgress, signal, meta, keyPair, apiClient, }: UploadDataOptions & {
18
- keyPair?: KeyPair;
17
+ export declare function uploadData({ storageType, data, password, forcePassword, encrypted, encryptProgress, uploadProgress, signal, meta, uaIdentity, keyPairs, apiClient, }: UploadDataOptions & {
18
+ uaIdentity?: UserAppIdentity;
19
+ keyPairs?: Record<string, string>;
19
20
  apiClient?: ApiClient;
20
21
  }): Promise<LocalData & {
21
22
  sharing: {