@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
@@ -0,0 +1,23 @@
1
+ import { encryptCryptoBox } from '.';
2
+ import { sodium } from '../sodium';
3
+ import { encryptSecretStream, secretStreamKeygen } from './data';
4
+ export function generatePassword() {
5
+ return sodium.randombytes_buf(16, 'hex');
6
+ }
7
+ export function derivePassword(password, salt) {
8
+ return sodium.crypto_pwhash(sodium.crypto_secretbox_KEYBYTES, password, salt, sodium.crypto_pwhash_OPSLIMIT_INTERACTIVE, sodium.crypto_pwhash_MEMLIMIT_INTERACTIVE, sodium.crypto_pwhash_ALG_ARGON2ID13, 'hex');
9
+ }
10
+ export async function encryptName(name, nameKey) {
11
+ const { data } = await encryptSecretStream(sodium.from_hex(nameKey), sodium.from_string(name));
12
+ return sodium.to_hex(data);
13
+ }
14
+ export async function generateAndEncryptNameAndKey(args) {
15
+ const nameKey = secretStreamKeygen();
16
+ const encryptedName = await encryptName(args.name, sodium.to_hex(nameKey));
17
+ const encryptedNameKey = sodium.to_hex(encryptCryptoBox(nameKey, args.publicKey, args.privateKey));
18
+ return {
19
+ nameKey,
20
+ encryptedName,
21
+ encryptedNameKey,
22
+ };
23
+ }
package/dist/lib/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './client/index.js';
2
2
  export * from './crypto/index.js';
3
3
  export { BaseClient } from './base-client.js';
4
- export * from './client/types/identity.js';
5
4
  export * from './client/helpers.js';
6
5
  export * from './sodium.js';
7
6
  export * from './utils/store-buddy.js';
@@ -5,6 +5,7 @@ export type SecrecyUrls = {
5
5
  auth: string;
6
6
  account: string;
7
7
  api: string;
8
+ data: string;
8
9
  };
9
10
  export type BaseClientOptions = {
10
11
  session: string;
@@ -23,8 +24,6 @@ export declare class BaseClient {
23
24
  me(): Promise<SelfUser>;
24
25
  static getUser(userId: string, opts?: CreateTrpcClientOptions): Promise<PublicUser>;
25
26
  getUser(userId: string): Promise<PublicUser>;
26
- static getUsers(userIds: string[], opts?: CreateTrpcClientOptions): Promise<PublicUser[]>;
27
- getUsers(userIds: string[]): Promise<PublicUser[]>;
28
27
  searchUsers(search: string): Promise<PublicUser[]>;
29
28
  updateProfile(data: RouterInputs['user']['updateProfile']): Promise<RouterOutputs['user']['updateProfile']>;
30
29
  static isCryptoTransactionDone({ idOrHash, network, opts, }: {
@@ -1,11 +1,12 @@
1
1
  import type { SecrecyClient, UserAppNotifications, UserAppSettings } from '../index.js';
2
2
  import type { JwtPayload } from 'jsonwebtoken';
3
- import { type RouterOutputs, type RouterInputs } from '../client.js';
3
+ import { type RouterOutputs, type ApiClient, type RouterInputs } from '../client.js';
4
+ import { type KeyPair } from './types/index.js';
4
5
  export declare class SecrecyAppClient {
5
6
  #private;
6
7
  jwt: string;
7
8
  jwtDecoded: JwtPayload;
8
- constructor(uaJwt: string, client: SecrecyClient);
9
+ constructor(uaJwt: string, _client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
9
10
  get userId(): string;
10
11
  get appId(): string;
11
12
  getJwt(): Promise<string>;
@@ -1,24 +1,31 @@
1
1
  import type { ProgressCallback, SecrecyClient } from '../index.js';
2
- import type { DataMetadata, DataStorageType, LocalData, Node, NodeFull, NodeType } from './types/index.js';
3
- import { type RouterInputs, type RouterOutputs } from '../client.js';
2
+ import type { DataMetadata, DataStorageType, KeyPair, LocalData, Node, NodeFull, NodeType } from './types/index.js';
3
+ import { type RouterInputs, type ApiClient, type RouterOutputs } from '../client.js';
4
4
  import { type Progress } from '../types.js';
5
5
  import { FileTypeResult } from 'file-type';
6
+ import { DownloadDataFromLinkOptions } from './data-link.js';
6
7
  export declare class SecrecyCloudClient {
7
8
  #private;
8
- constructor(client: SecrecyClient);
9
+ constructor(client: SecrecyClient, keys: KeyPair, apiClient: ApiClient);
9
10
  addDataToHistory({ dataId, nodeId, }: {
10
11
  dataId: string;
11
12
  nodeId: string;
12
13
  }): Promise<NodeFull>;
13
- uploadData({ storageType, data, encrypted, encryptProgress, uploadProgress, signal, meta, }: {
14
+ uploadData(opts: {
14
15
  storageType: DataStorageType;
15
16
  data: globalThis.File | Uint8Array<ArrayBuffer>;
17
+ password?: string;
16
18
  encrypted?: boolean;
17
19
  encryptProgress?: ProgressCallback;
18
20
  uploadProgress?: ProgressCallback;
19
21
  signal?: AbortSignal;
20
22
  meta?: FileTypeResult | true;
21
- }): Promise<LocalData>;
23
+ }): Promise<LocalData & {
24
+ sharing: {
25
+ password: string;
26
+ encryptedDataKey: string;
27
+ } | null;
28
+ }>;
22
29
  uploadDataInCloud({ data, name, nodeId, encryptProgress, uploadProgress, storageType, signal, }: {
23
30
  data: globalThis.File | Uint8Array<ArrayBuffer>;
24
31
  name: string;
@@ -31,9 +38,9 @@ export declare class SecrecyCloudClient {
31
38
  deletedNodes(): Promise<Node[]>;
32
39
  sharedNodes(): Promise<Node[]>;
33
40
  nodesSharedWithMe(type?: NodeType): Promise<Node[]>;
34
- deleteNodeSharing({ nodeId, destPubKey, }: {
41
+ deleteNodeSharing({ nodeId, userId, }: {
35
42
  nodeId: string;
36
- destPubKey: string;
43
+ userId: string;
37
44
  }): Promise<boolean>;
38
45
  duplicateNode({ nodeId, folderId, name, }: {
39
46
  nodeId: string;
@@ -54,7 +61,7 @@ export declare class SecrecyCloudClient {
54
61
  dataMetadata({ id }: {
55
62
  id: string;
56
63
  }): Promise<DataMetadata>;
57
- shareNode(accesses: RouterInputs['cloud']['shareNode']['accesses'], progress?: ProgressCallback): Promise<RouterOutputs['cloud']['shareNodeFinish']>;
64
+ shareNode(input: RouterInputs['cloud']['shareNode'], progress?: ProgressCallback): Promise<RouterOutputs['cloud']['shareNodeFinish']>;
58
65
  updateNode({ nodeId, name, isFavorite, deletedAt, }: {
59
66
  nodeId: string;
60
67
  name?: string | null | undefined;
@@ -96,7 +103,7 @@ export declare class SecrecyCloudClient {
96
103
  name: string;
97
104
  nodeId?: string;
98
105
  }): Promise<NodeFull>;
99
- private readonly encryptNodesForIdentities;
106
+ private readonly encryptNodesForUsers;
100
107
  reportData({ id, reasons, }: Omit<RouterInputs['cloud']['reportData'], 'encryptedDataKey'>): Promise<RouterOutputs['cloud']['reportData']>;
101
108
  updateDataStorageType(input: RouterInputs['cloud']['moveToStorageType']): Promise<{
102
109
  isMoved: boolean;
@@ -129,32 +136,32 @@ export declare class SecrecyCloudClient {
129
136
  isMatching: false;
130
137
  details: {
131
138
  missingNodeAccesses: {
132
- pubKey: string;
139
+ userId: string;
133
140
  nodeId: string;
134
141
  }[];
135
142
  missingDataAccesses: {
136
- pubKey: string;
143
+ userId: string;
137
144
  nodeId: string;
138
145
  dataId: string;
139
146
  }[];
140
147
  invalidRightsAccesses: {
141
- pubKey: string;
148
+ userId: string;
142
149
  nodeId: string;
143
150
  expect: {
144
151
  rights: "delete" | "read" | "write";
145
152
  } & {
146
- addAccess: "delete" | "read" | "write" | null;
147
- sharingAddAccess: "delete" | "read" | "write" | null;
148
- delAccess: "delete" | "read" | "write" | null;
149
- sharingDelAccess: "delete" | "read" | "write" | null;
153
+ addAccess?: "delete" | "read" | "write" | null | undefined;
154
+ sharingAddAccess?: "delete" | "read" | "write" | null | undefined;
155
+ delAccess?: "delete" | "read" | "write" | null | undefined;
156
+ sharingDelAccess?: "delete" | "read" | "write" | null | undefined;
150
157
  };
151
158
  current: {
152
159
  rights: "delete" | "read" | "write";
153
160
  } & {
154
- addAccess: "delete" | "read" | "write" | null;
155
- sharingAddAccess: "delete" | "read" | "write" | null;
156
- delAccess: "delete" | "read" | "write" | null;
157
- sharingDelAccess: "delete" | "read" | "write" | null;
161
+ addAccess?: "delete" | "read" | "write" | null | undefined;
162
+ sharingAddAccess?: "delete" | "read" | "write" | null | undefined;
163
+ delAccess?: "delete" | "read" | "write" | null | undefined;
164
+ sharingDelAccess?: "delete" | "read" | "write" | null | undefined;
158
165
  };
159
166
  }[];
160
167
  };
@@ -189,5 +196,6 @@ export declare class SecrecyCloudClient {
189
196
  createdByOrgId: string | null;
190
197
  createdByAppId: string | null;
191
198
  }>;
199
+ downloadDataFromLink(input: DownloadDataFromLinkOptions): Promise<Uint8Array<ArrayBuffer>>;
192
200
  private _handleDataContent;
193
201
  }
@@ -1,5 +1,7 @@
1
+ import { type ApiClient } from '../client.js';
1
2
  import type { SecrecyClient } from '../index.js';
3
+ import { type KeyPair } from './types/index.js';
2
4
  export declare class SecrecyDbClient {
3
5
  #private;
4
- constructor(client: SecrecyClient);
6
+ constructor(_client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
5
7
  }
@@ -1,9 +1,10 @@
1
- import { type RouterInputs } from '../client.js';
1
+ import { type ApiClient, type RouterInputs } from '../client.js';
2
2
  import type { DraftMail, Mail, NewMail, ReceivedMail, SecrecyClient, SentMail, WaitingReceivedMail } from '../index.js';
3
+ import { type KeyPair } from './types/index.js';
3
4
  import { type ApiMail } from './types/mail.js';
4
5
  export declare class SecrecyMailClient {
5
6
  #private;
6
- constructor(client: SecrecyClient);
7
+ constructor(client: SecrecyClient, keys: KeyPair, apiClient: ApiClient);
7
8
  get({ id }: {
8
9
  id: string;
9
10
  }): Promise<Mail>;
@@ -1,8 +1,9 @@
1
- import { RouterInputs, RouterOutputs } from '../client.js';
1
+ import { RouterInputs, RouterOutputs, type ApiClient } from '../client.js';
2
2
  import type { SecrecyClient } from '../index.js';
3
+ import { type KeyPair } from './types/index.js';
3
4
  export declare class SecrecyOrganizationClient {
4
5
  #private;
5
- constructor(client: SecrecyClient);
6
+ constructor(_client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
6
7
  create(input: RouterInputs['org']['create']): Promise<RouterOutputs['org']['create']>;
7
8
  update(input: Omit<RouterInputs['org']['update'], 'billingProfileStripeCustomerId'>): Promise<RouterOutputs['org']['update']>;
8
9
  addMember(input: RouterInputs['org']['addMember']): Promise<RouterOutputs['org']['addMember']>;
@@ -1,4 +1,6 @@
1
1
  import type { SecrecyClient } from '../index.js';
2
+ import { type ApiClient } from '../client.js';
3
+ import { type KeyPair } from './types/index.js';
2
4
  interface SuccessPayResponse<T> {
3
5
  success: true;
4
6
  data: T;
@@ -10,7 +12,7 @@ interface ErrorPayResponse {
10
12
  export type SecrecyPayResponse<T> = SuccessPayResponse<T> | ErrorPayResponse;
11
13
  export declare class SecrecyPayClient {
12
14
  #private;
13
- constructor(client: SecrecyClient);
15
+ constructor(client: SecrecyClient, _keys: KeyPair, _apiClient: ApiClient);
14
16
  confirmPaymentIntent({ paymentIntentId, secrecyIdWhoCreatedPaymentIntent, secrecyIdWhoNeedToConfirmPaymentIntent, amount, currency, }: {
15
17
  paymentIntentId: string;
16
18
  secrecyIdWhoCreatedPaymentIntent: string;
@@ -1,8 +1,9 @@
1
- import { type RouterInputs, type RouterOutputs } from '../client.js';
1
+ import { type RouterInputs, type RouterOutputs, type ApiClient } from '../client.js';
2
2
  import type { SecrecyClient } from '../index.js';
3
+ import { type KeyPair } from './types/index.js';
3
4
  export declare class SecrecyPseudonymClient {
4
5
  #private;
5
- constructor(client: SecrecyClient);
6
+ constructor(client: SecrecyClient, keys: KeyPair, apiClient: ApiClient);
6
7
  askForLabel(input: RouterInputs['pseudonym']['askForLabel']): Promise<RouterOutputs['pseudonym']['askForLabel']>;
7
8
  askForUser(input: RouterInputs['pseudonym']['askForUser']): Promise<RouterOutputs['pseudonym']['askForUser']>;
8
9
  cross(input: RouterInputs['pseudonym']['cross']): Promise<RouterOutputs['pseudonym']['cross']>;
@@ -1,8 +1,9 @@
1
- import type { RouterInputs, RouterOutputs } from '../client.js';
1
+ import type { RouterInputs, ApiClient, RouterOutputs } from '../client.js';
2
2
  import type { SecrecyClient } from '../index.js';
3
+ import type { KeyPair } from './types/index.js';
3
4
  export declare class SecrecyUserClient {
4
5
  #private;
5
- constructor(client: SecrecyClient);
6
+ constructor(_client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
6
7
  answerInvitation(input: RouterInputs['contacts']['answerInvitation']): Promise<RouterOutputs['contacts']['answerInvitation']>;
7
8
  cancelInvitation(input: RouterInputs['contacts']['cancelInvitation']): Promise<RouterOutputs['contacts']['cancelInvitation']>;
8
9
  createInvitation(input: RouterInputs['contacts']['createInvitation']): Promise<RouterOutputs['contacts']['createInvitation']>;
@@ -1,4 +1,4 @@
1
- import type { ApiData, InternalData, DataMetadata } from '../types/index.js';
2
- export declare function apiDataToInternal(apiData: ApiData, keyPairs: Record<string, string>): InternalData;
1
+ import type { ApiData, InternalData, DataMetadata, KeyPair } from '../types/index.js';
2
+ export declare function apiDataToInternal(apiData: ApiData, keyPair: KeyPair): InternalData;
3
3
  export declare function internalDataToExternalData(internal: InternalData): DataMetadata;
4
- export declare function apiDataToExternal(apiData: ApiData, keyPairs: Record<string, string>): DataMetadata;
4
+ export declare function apiDataToExternal(apiData: ApiData, keyPair: KeyPair): DataMetadata;
@@ -1,6 +1,8 @@
1
- import { type Mail } from '../../index.js';
1
+ import { type Mail, type SecrecyClient } from '../../index.js';
2
+ import { type KeyPair } from '../types/index.js';
2
3
  import { type ApiMail } from '../types/mail.js';
3
- export declare function convertInternalMailToExternal({ mail, keyPairs, }: {
4
+ export declare function convertInternalMailToExternal({ client, mail, keyPair, }: {
4
5
  mail: ApiMail;
5
- keyPairs: Record<string, string>;
6
+ client: SecrecyClient;
7
+ keyPair: KeyPair;
6
8
  }): Promise<Mail>;
@@ -1,6 +1,6 @@
1
- import type { Node, ApiNode, ApiNodeFull, InternalNodeFull, NodeFull, ApiNodeParent, ApiNodeForEncryption, InternalMinimalNodeForEncryption } from '../types/index.js';
2
- export declare function apiNodeFullToInternalFull(apiNodeFull: ApiNodeFull, keyPairs: Record<string, string>): Promise<InternalNodeFull>;
1
+ import type { Node, ApiNode, ApiNodeFull, InternalNodeFull, NodeFull, KeyPair, ApiNodeParent, ApiNodeForEncryption, InternalMinimalNodeForEncryption } from '../types/index.js';
2
+ export declare function apiNodeFullToInternalFull(apiNodeFull: ApiNodeFull, keyPair: KeyPair): Promise<InternalNodeFull>;
3
3
  export declare function internalNodeFullToNodeFull(internal: InternalNodeFull): NodeFull;
4
- export declare function apiNodeToExternalNodeFull(apiNodeFull: ApiNodeFull, keyPairs: Record<string, string>): Promise<NodeFull>;
5
- export declare function apiNodeToExternal(apiNode: ApiNode | ApiNodeParent, keyPairs: Record<string, string>): Promise<Node>;
6
- export declare function apiNodeForEncryptionToInternal(apiNode: ApiNodeForEncryption, keyPairs: Record<string, string>): Promise<InternalMinimalNodeForEncryption>;
4
+ export declare function apiNodeToExternalNodeFull(apiNodeFull: ApiNodeFull, keyPair: KeyPair): Promise<NodeFull>;
5
+ export declare function apiNodeToExternal(apiNode: ApiNode | ApiNodeParent, keyPair: KeyPair): Promise<Node>;
6
+ export declare function apiNodeForEncryptionToInternal(apiNode: ApiNodeForEncryption, keyPair: KeyPair): Promise<InternalMinimalNodeForEncryption>;
@@ -0,0 +1,37 @@
1
+ import z from 'zod';
2
+ import { ProgressCallback } from '.';
3
+ import { Progress } from 'ky';
4
+ export declare const downloadDataLinkSchema: z.ZodUnion<readonly [z.ZodObject<{
5
+ name: z.ZodString;
6
+ md5: z.ZodString;
7
+ md5Encrypted: z.ZodNullable<z.ZodString>;
8
+ size: z.ZodCoercedBigInt<unknown>;
9
+ parts: z.ZodArray<z.ZodObject<{
10
+ order: z.ZodNumber;
11
+ md5: z.ZodString;
12
+ contentUrl: z.ZodString;
13
+ }, z.core.$strip>>;
14
+ mime: z.ZodString;
15
+ isEncrypted: z.ZodBoolean;
16
+ }, z.core.$strip>, z.ZodObject<{
17
+ name: z.ZodString;
18
+ md5: z.ZodString;
19
+ md5Encrypted: z.ZodNullable<z.ZodString>;
20
+ size: z.ZodCoercedBigInt<unknown>;
21
+ bytes: z.ZodString;
22
+ mime: z.ZodString;
23
+ isEncrypted: z.ZodBoolean;
24
+ }, z.core.$strip>]>;
25
+ export type DownloadDataFromLinkOptions = {
26
+ dataLinkSlug: string;
27
+ crypto?: {
28
+ password: string;
29
+ key: string;
30
+ };
31
+ decryptProgress?: ProgressCallback;
32
+ downloadProgress?: (progress: Progress) => void;
33
+ signal?: AbortSignal;
34
+ };
35
+ export declare function downloadDataFromLink(opts: DownloadDataFromLinkOptions & {
36
+ dataUrl?: string;
37
+ }): Promise<Uint8Array<ArrayBuffer>>;
@@ -0,0 +1,2 @@
1
+ export declare const downloadFileLite: (file: BlobPart, name: string) => Promise<void>;
2
+ export declare const downloadFileSmart: (file: BlobPart, name: string) => Promise<boolean>;
@@ -6,17 +6,16 @@ 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, type RouterOutputs } from '../client.js';
9
+ import { ApiClient, type RouterInputs } from '../client.js';
10
+ import { type KeyPair } from './types/index.js';
10
11
  import { SecrecyUserClient } from './SecrecyUserClient.js';
11
12
  import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
12
13
  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
- identities: AccessIdentity[];
19
- keyPairs: Record<string, string>;
18
+ uaKeys: KeyPair;
20
19
  uaJwt: string;
21
20
  apiClient?: ApiClient;
22
21
  secrecyUrls?: Partial<SecrecyUrls>;
@@ -34,13 +33,6 @@ export declare class SecrecyClient extends BaseClient {
34
33
  pseudonym: SecrecyPseudonymClient;
35
34
  constructor(opts: SecrecyClientOptions);
36
35
  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>;
43
36
  decryptAnonymous(data: Uint8Array): Uint8Array;
44
37
  logout(sessionId?: string | null | undefined): Promise<void>;
45
- getIdentities(input: RouterInputs['identity']['getMany']): Promise<RouterOutputs['identity']['getMany']>;
46
38
  }
@@ -1,8 +1,7 @@
1
1
  import type { StoreBuddy } from '../utils/store-buddy.js';
2
- import type { AccessIdentity } from './types/identity.js';
2
+ import { type KeyPair } from './types/index.js';
3
3
  export declare function getStorage(session?: boolean | undefined): {
4
- identities: StoreBuddy<AccessIdentity[] | null>;
5
- keyPairs: StoreBuddy<Record<string, string> | null>;
4
+ userAppKeys: StoreBuddy<KeyPair | null>;
6
5
  userAppSession: StoreBuddy<string | null>;
7
6
  jwt: StoreBuddy<string | null>;
8
7
  };
@@ -4,20 +4,16 @@ 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>;
7
12
  export declare const secrecyUserApp: z.ZodReadonly<z.ZodObject<{
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
- sharedByPubKey: z.ZodString;
18
- groupOwnerPubKey: z.ZodString;
19
- }, z.core.$strip>], "kind">>;
20
- keyPairs: z.ZodRecord<z.ZodString, z.ZodString>;
13
+ keys: z.ZodObject<{
14
+ publicKey: z.ZodString;
15
+ privateKey: z.ZodString;
16
+ }, z.core.$strict>;
21
17
  jwt: z.ZodString;
22
18
  uaSession: z.ZodString;
23
19
  }, 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<PublicUser>;
16
+ recipients: Array<Omit<PublicUser, 'publicKey'>>;
17
17
  temporaryRecipients: TemporaryMailUser[];
18
18
  attachments: Array<{
19
19
  id: string;
@@ -24,7 +24,6 @@ export interface BaseMail {
24
24
  export interface ReceivedMail extends BaseMail {
25
25
  type: 'received';
26
26
  sender: PublicUser;
27
- senderPublicKey: string;
28
27
  }
29
28
  export interface InternalSentMail {
30
29
  user: {
@@ -1,19 +1,17 @@
1
1
  import { type RouterOutputs } from '../../client.js';
2
- import type { DataMetadata, InternalData, UserAppOrg } from './index.js';
3
- export type Permissions = ApiNode['identities'][number];
2
+ import type { DataMetadata, InternalData, PublicUser } from './index.js';
3
+ export type Permissions = ApiNode['users'][number][1];
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;
9
8
  };
10
9
  export interface NodeBreadcrumbItem {
11
10
  id: string;
12
11
  name: string;
13
12
  }
14
13
  export interface NodeBreadcrumbItemWithPubKey extends NodeBreadcrumbItem {
15
- sharedByPubKey: string;
16
- identityPubKey: string;
14
+ pubKey: string;
17
15
  }
18
16
  export interface NodeSize {
19
17
  size: bigint;
@@ -33,10 +31,9 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
33
31
  sizes: NodeSize;
34
32
  name: string;
35
33
  breadcrumb: T[];
36
- owner: UserAppOrg;
37
- accesses: NodeAccess<U>[];
38
- permissions: Permissions;
39
- identities: Record<string, Permissions>;
34
+ owner: PublicUser;
35
+ access: NodeAccess<U>;
36
+ users: Array<[PublicUser, Permissions]>;
40
37
  currentDataId: string | null;
41
38
  parentId: string | null;
42
39
  }
@@ -75,16 +72,16 @@ export type EncryptedNodeInfos = {
75
72
  };
76
73
  export type ShareNodeDetails = {
77
74
  missingNodeAccesses: {
78
- pubKey: string;
75
+ userId: string;
79
76
  nodeId: string;
80
77
  }[];
81
78
  missingDataAccesses: {
82
- pubKey: string;
79
+ userId: string;
83
80
  dataId: string;
84
81
  nodeId: string;
85
82
  }[];
86
83
  invalidRightsAccesses: {
87
- pubKey: string;
84
+ userId: string;
88
85
  current: Permissions;
89
86
  nodeId: string;
90
87
  expect: Permissions;
@@ -1,18 +1,3 @@
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
- }>;
@@ -0,0 +1,38 @@
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';
6
+ export type UploadDataOptions = {
7
+ storageType: DataStorageType;
8
+ data: globalThis.File | Uint8Array<ArrayBuffer>;
9
+ password?: string;
10
+ encrypted?: boolean;
11
+ encryptProgress?: ProgressCallback;
12
+ uploadProgress?: ProgressCallback;
13
+ signal?: AbortSignal;
14
+ meta?: FileTypeResult | true;
15
+ };
16
+ export declare function uploadData({ storageType, data, password, forcePassword, encrypted, encryptProgress, uploadProgress, signal, meta, keyPair, apiClient, }: UploadDataOptions & {
17
+ keyPair?: KeyPair;
18
+ apiClient?: ApiClient;
19
+ forcePassword?: boolean;
20
+ }): Promise<LocalData & {
21
+ sharing: {
22
+ password: string;
23
+ encryptedDataKey: string;
24
+ } | null;
25
+ }>;
26
+ export type CreateDataLinkOptions = RouterInputs['cloud']['createDataLink'];
27
+ export declare function createPublicDataLink({ apiClient, ...opts }: CreateDataLinkOptions & Pick<{
28
+ apiClient?: ApiClient;
29
+ }, 'apiClient'>): Promise<{
30
+ id: string;
31
+ name: string;
32
+ slug: string;
33
+ expireAt: Date | null;
34
+ dataId: string;
35
+ createdByUserId: string | null;
36
+ createdByOrgId: string | null;
37
+ createdByAppId: string | null;
38
+ }>;