@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
@@ -11,7 +11,9 @@ import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
11
11
  import { decryptAnonymous } from '../crypto/index.js';
12
12
  import { SecrecyOrganizationClient } from './SecrecyOrganizationClient.js';
13
13
  export class SecrecyClient extends BaseClient {
14
- #keys;
14
+ #groupIdentities;
15
+ #uaIdentity;
16
+ #keyPairs;
15
17
  cloud;
16
18
  mail;
17
19
  app;
@@ -36,22 +38,53 @@ export class SecrecyClient extends BaseClient {
36
38
  }
37
39
  },
38
40
  });
39
- this.#keys = opts.uaKeys;
40
- this.cloud = new SecrecyCloudClient(this, this.#keys, this.client);
41
- this.mail = new SecrecyMailClient(this, this.#keys, this.client);
42
- this.app = new SecrecyAppClient(opts.uaJwt, this, this.#keys, this.client);
43
- this.db = new SecrecyDbClient(this, this.#keys, this.client);
44
- this.organization = new SecrecyOrganizationClient(this, this.#keys, this.client);
41
+ this.#keyPairs = opts.keyPairs;
42
+ this.#groupIdentities = opts.identities.filter((i) => i.kind === 'GROUP');
43
+ const uaIdentities = opts.identities.filter((i) => i.kind === 'USER_APP');
44
+ if (!uaIdentities[0]) {
45
+ throw new Error('One USER_APP identity is required');
46
+ }
47
+ this.#uaIdentity = uaIdentities[0];
48
+ this.cloud = new SecrecyCloudClient(this);
49
+ this.mail = new SecrecyMailClient(this);
50
+ this.app = new SecrecyAppClient(opts.uaJwt, this);
51
+ this.db = new SecrecyDbClient(this);
52
+ this.organization = new SecrecyOrganizationClient(this);
45
53
  this.wallet = new SecrecyWalletClient(this);
46
- this.pay = new SecrecyPayClient(this, this.#keys, this.client);
47
- this.user = new SecrecyUserClient(this, this.#keys, this.client);
48
- this.pseudonym = new SecrecyPseudonymClient(this, this.#keys, this.client);
54
+ this.pay = new SecrecyPayClient(this);
55
+ this.user = new SecrecyUserClient(this);
56
+ this.pseudonym = new SecrecyPseudonymClient(this);
49
57
  }
50
58
  get publicKey() {
51
- return this.#keys.publicKey;
59
+ return this.#uaIdentity.identityPubKey;
60
+ }
61
+ get apiClient() {
62
+ return this.client;
63
+ }
64
+ get keyPairs() {
65
+ return this.#keyPairs;
66
+ }
67
+ getPrivateKey(pubKey) {
68
+ const privateKey = this.#keyPairs[pubKey];
69
+ if (privateKey === undefined) {
70
+ throw new Error(`Missing private key for public key ${pubKey}`);
71
+ }
72
+ return privateKey;
73
+ }
74
+ get uaPrivateKey() {
75
+ return this.getPrivateKey(this.#uaIdentity.identityPubKey);
76
+ }
77
+ get groupIdentities() {
78
+ return this.#groupIdentities;
79
+ }
80
+ get uaIdentity() {
81
+ return this.#uaIdentity;
52
82
  }
53
83
  decryptAnonymous(data) {
54
- return decryptAnonymous(data, this.#keys);
84
+ return decryptAnonymous(data, {
85
+ publicKey: this.#uaIdentity.identityPubKey,
86
+ privateKey: this.uaPrivateKey,
87
+ });
55
88
  }
56
89
  async logout(sessionId) {
57
90
  nodesCache.clear();
@@ -59,4 +92,7 @@ export class SecrecyClient extends BaseClient {
59
92
  publicKeysCache.clear();
60
93
  await super.logout(sessionId);
61
94
  }
95
+ async getIdentities(input) {
96
+ return await this.client.identity.getMany.query(input);
97
+ }
62
98
  }
@@ -1,7 +1,8 @@
1
1
  import { storeBuddy } from '../utils/store-buddy.js';
2
2
  export function getStorage(session) {
3
3
  const userAppSession = storeBuddy(`secrecy.user_app_session`, session).init(null);
4
- const userAppKeys = storeBuddy(`secrecy.user_app_keys`, session).init(null);
4
+ const identities = storeBuddy(`secrecy.identities`, session).init(null);
5
+ const keyPairs = storeBuddy(`secrecy.key_pairs`, session).init(null);
5
6
  const jwt = storeBuddy(`secrecy.jwt`, session).init(null);
6
- return { userAppKeys, userAppSession, jwt };
7
+ return { identities, keyPairs, userAppSession, jwt };
7
8
  }
@@ -0,0 +1,19 @@
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
+ groupRole: z.enum(['ADMIN', 'MEMBER']),
13
+ sharedByPubKey: z.string(),
14
+ groupOwnerPubKey: z.string(),
15
+ });
16
+ export const accessIdentitySchema = z.discriminatedUnion('kind', [
17
+ userAppSchema,
18
+ groupSchema,
19
+ ]);
@@ -1,13 +1,9 @@
1
1
  import { z } from 'zod';
2
- const keyPair = z
3
- .object({
4
- publicKey: z.string(),
5
- privateKey: z.string(),
6
- })
7
- .strict();
2
+ import { accessIdentitySchema } from './identity.js';
8
3
  export const secrecyUserApp = z
9
4
  .object({
10
- keys: keyPair,
5
+ identities: accessIdentitySchema.array(),
6
+ keyPairs: z.record(z.string(), z.string()),
11
7
  jwt: z.string(),
12
8
  uaSession: z.string(),
13
9
  })
@@ -11,11 +11,11 @@ import { promiseAllLimit } from '../utils/promise.js';
11
11
  import { encryptDataAndKey } from '../crypto/domain.js';
12
12
  import { derivePassword, generatePassword } from '../crypto/helpers.js';
13
13
  import { decryptCryptoBox, encryptSecretBox } from '../crypto/index.js';
14
- export async function uploadData({ storageType, data, password, forcePassword = false, encrypted = true, encryptProgress, uploadProgress, signal, meta, keyPair, apiClient, }) {
14
+ export async function uploadData({ storageType, data, password, forcePassword = false, encrypted = true, encryptProgress, uploadProgress, signal, meta, uaIdentity, keyPairs, apiClient, }) {
15
15
  if (!encrypted && (password || forcePassword)) {
16
16
  throw new Error('Cannot share unencrypted data with a password!');
17
17
  }
18
- if (encrypted && !password && !forcePassword && !keyPair) {
18
+ if (encrypted && !password && !forcePassword && !uaIdentity) {
19
19
  throw new Error('Cannot share encrypted data without a password!');
20
20
  }
21
21
  apiClient ??= getTrpcGuestClient();
@@ -37,7 +37,7 @@ export async function uploadData({ storageType, data, password, forcePassword =
37
37
  if (storageType === 'lite' && dataBuffer.byteLength > kiloToBytes(1024)) {
38
38
  throw new Error('The data is too big for lite upload!');
39
39
  }
40
- if (!keyPair && storageType === 'cold') {
40
+ if (!uaIdentity && storageType === 'cold') {
41
41
  throw new Error('Cold storage is only for logged users!');
42
42
  }
43
43
  const compressed = encrypted ? compress(dataBuffer) : dataBuffer;
@@ -45,7 +45,8 @@ export async function uploadData({ storageType, data, password, forcePassword =
45
45
  ? await encryptDataAndKey({
46
46
  data: compressed,
47
47
  progress: encryptProgress,
48
- keyPair,
48
+ uaIdentity,
49
+ keyPairs,
49
50
  signal,
50
51
  })
51
52
  : {
@@ -73,13 +74,17 @@ export async function uploadData({ storageType, data, password, forcePassword =
73
74
  key = dataKey;
74
75
  }
75
76
  else {
76
- if (!keyPair) {
77
+ if (!uaIdentity) {
77
78
  throw new Error('Unable to encrypt data without keyPair!');
78
79
  }
79
80
  if (!data.key) {
80
81
  throw new Error('Unable to encrypt data without key!');
81
82
  }
82
- key = decryptCryptoBox(sodium.from_hex(data.key), data.keyPair.pub, keyPair.privateKey);
83
+ const priv = keyPairs?.[data.keyPair.pub];
84
+ if (typeof priv !== 'string') {
85
+ throw new Error('Unable to encrypt data without keyPair!');
86
+ }
87
+ key = decryptCryptoBox(sodium.from_hex(data.key), data.keyPair.pub, priv);
83
88
  }
84
89
  // NOTE: Process to create a sharing for a auth client (todo: endpoint)
85
90
  return {
@@ -105,7 +110,6 @@ export async function uploadData({ storageType, data, password, forcePassword =
105
110
  type: 'unencrypted',
106
111
  content: Buffer.from(encryptedData),
107
112
  md5: md5Data,
108
- sizeEncrypted: undefined,
109
113
  size: BigInt(dataBuffer.byteLength),
110
114
  ...filetype,
111
115
  };
@@ -120,7 +124,9 @@ export async function uploadData({ storageType, data, password, forcePassword =
120
124
  id: uploadData.id,
121
125
  storageType: 'lite',
122
126
  size: uploadDataArgs.size,
123
- sizeEncrypted: uploadDataArgs.sizeEncrypted ?? null,
127
+ sizeEncrypted: uploadDataArgs.type === 'encrypted'
128
+ ? uploadDataArgs.sizeEncrypted
129
+ : null,
124
130
  data: dataBuffer,
125
131
  ...filetype,
126
132
  };
@@ -145,7 +151,6 @@ export async function uploadData({ storageType, data, password, forcePassword =
145
151
  type: 'unencrypted',
146
152
  md5: md5Data,
147
153
  size: BigInt(dataBuffer.byteLength),
148
- sizeEncrypted: undefined,
149
154
  ...filetype,
150
155
  };
151
156
  const uploadDataCaller = storageType === 's3'
@@ -155,12 +160,6 @@ export async function uploadData({ storageType, data, password, forcePassword =
155
160
  signal,
156
161
  });
157
162
  if (uploadData.parts.length === 0) {
158
- if (uploadData.type === 'authed' &&
159
- (typeof keyPair === 'undefined' ||
160
- typeof keyPair === 'string' ||
161
- uploadData.keyPair.pub !== keyPair.publicKey)) {
162
- throw new Error('The public key does not match with cached key!');
163
- }
164
163
  await uploadProgress?.({
165
164
  total: encryptedData.byteLength,
166
165
  current: encryptedData.byteLength,
@@ -171,7 +170,9 @@ export async function uploadData({ storageType, data, password, forcePassword =
171
170
  id: uploadData.id,
172
171
  storageType: storageType,
173
172
  size: uploadDataArgs.size,
174
- sizeEncrypted: uploadDataArgs.sizeEncrypted ?? null,
173
+ sizeEncrypted: uploadDataArgs.type === 'encrypted'
174
+ ? uploadDataArgs.sizeEncrypted
175
+ : null,
175
176
  data: dataBuffer,
176
177
  ...filetype,
177
178
  };
@@ -231,7 +232,9 @@ export async function uploadData({ storageType, data, password, forcePassword =
231
232
  id: uploadData.id,
232
233
  storageType: storageType,
233
234
  size: uploadDataArgs.size,
234
- sizeEncrypted: uploadDataArgs.sizeEncrypted ?? null,
235
+ sizeEncrypted: uploadDataArgs.type === 'encrypted'
236
+ ? uploadDataArgs.sizeEncrypted
237
+ : null,
235
238
  data: dataBuffer,
236
239
  ...filetype,
237
240
  };
@@ -46,7 +46,7 @@ function decrypt(header, key) {
46
46
  };
47
47
  }
48
48
  export const CHUNK_SIZE = 8192;
49
- export async function encryptSecretStream(key, data, progress, abort) {
49
+ export async function encryptSecretStream(key, data, progress, signal) {
50
50
  await setup();
51
51
  const { encrypt: crypt, destroy, header } = encrypt(key);
52
52
  const encryptedChunk = CHUNK_SIZE + sodium.crypto_secretstream_xchacha20poly1305_ABYTES;
@@ -69,7 +69,7 @@ export async function encryptSecretStream(key, data, progress, abort) {
69
69
  });
70
70
  let lastPercent = total / max;
71
71
  for (const chunk of chunks(data, CHUNK_SIZE)) {
72
- if (abort?.signal.aborted === true) {
72
+ if (signal?.aborted === true) {
73
73
  throw new Error(`Encrypt aborted`);
74
74
  }
75
75
  spark.append(chunk.buffer);
@@ -102,7 +102,7 @@ export async function encryptSecretStream(key, data, progress, abort) {
102
102
  md5: spark.end(),
103
103
  };
104
104
  }
105
- export async function decryptSecretStream(key, data, progress, abort) {
105
+ export async function decryptSecretStream(key, data, progress, signal) {
106
106
  await setup();
107
107
  const header = data.slice(0, sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES);
108
108
  data = data.slice(sodium.crypto_secretstream_xchacha20poly1305_HEADERBYTES);
@@ -118,7 +118,7 @@ export async function decryptSecretStream(key, data, progress, abort) {
118
118
  let total = 0;
119
119
  let lastPercent = total / max;
120
120
  for (const chunk of chunks(data, chunkSize)) {
121
- if (abort?.signal.aborted === true) {
121
+ if (signal?.aborted === true) {
122
122
  throw new Error(`Decrypt aborted`);
123
123
  }
124
124
  const messageTag = decryptFn(chunk);
@@ -10,10 +10,10 @@ import { concatenate } from '../utils/array.js';
10
10
  * If a string is provided as keypair, it should be considered as guest with password case.
11
11
  * If keypair is not provided, then we generate a key to be used as password for guest too.
12
12
  */
13
- export async function encryptDataAndKey({ data, keyPair, progress, signal, }) {
13
+ export async function encryptDataAndKey({ data, uaIdentity, keyPairs, progress, signal, }) {
14
14
  const dataKey = secretStreamKeygen();
15
15
  const { data: encryptedData, md5: md5Data, md5Encrypted, } = await encrypt(dataKey, data, progress, signal);
16
- if (!keyPair) {
16
+ if (!uaIdentity || !keyPairs) {
17
17
  return {
18
18
  encryptedData,
19
19
  dataKey,
@@ -21,7 +21,11 @@ export async function encryptDataAndKey({ data, keyPair, progress, signal, }) {
21
21
  md5Encrypted,
22
22
  };
23
23
  }
24
- const encDataKey = encryptCryptoBox(dataKey, keyPair.publicKey, keyPair.privateKey);
24
+ const priv = keyPairs[uaIdentity.identityPubKey];
25
+ if (!priv) {
26
+ throw new Error('No private key found for user app identity');
27
+ }
28
+ const encDataKey = encryptCryptoBox(dataKey, uaIdentity.identityPubKey, priv);
25
29
  return {
26
30
  encryptedDataKey: encDataKey,
27
31
  encryptedData,
@@ -39,19 +43,15 @@ const encryptedContentFromParts = async (arg) => {
39
43
  onDownloadProgress: (pr) => {
40
44
  arg.onProgress(`${arg.dataId}-${part.order}`, pr);
41
45
  },
42
- signal: arg.signal,
46
+ signal: arg.signal ?? null,
43
47
  })
44
48
  .arrayBuffer());
45
49
  const md5Part = await md5(buf);
46
50
  if (md5Part !== part.md5) {
47
51
  throw new Error(`Invalid md5 for part ${part.order} of data ${arg.dataId}`);
48
52
  }
49
- if (typeof parts[arg.dataId] === 'undefined') {
50
- parts[arg.dataId] = [{ data: buf, order: part.order }];
51
- }
52
- else {
53
- parts[arg.dataId].push({ data: buf, order: part.order });
54
- }
53
+ parts[arg.dataId] ??= [];
54
+ parts[arg.dataId].push({ data: buf, order: part.order });
55
55
  };
56
56
  await promiseAllLimit(3, arg.dataParts.map((p) => async () => byPart(p)));
57
57
  return concatenate(...parts[arg.dataId].sort((a, b) => a.order - b.order).map((p) => p.data));
package/dist/lib/index.js CHANGED
@@ -1,6 +1,7 @@
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';
4
5
  export * from './client/helpers.js';
5
6
  export * from './sodium.js';
6
7
  export * from './utils/store-buddy.js';
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  // lz4-ts @license BSD-3-Clause / Copyright (c) 2015, Pierre Curto / 2016, oov. All rights reserved.
2
3
  /**
3
4
  * Copyright (c) 2015, Pierre Curto
@@ -8,8 +8,8 @@ export const secrecyApplications = [
8
8
  ];
9
9
  function getEnv() {
10
10
  if (typeof window === 'undefined') {
11
- return process.env.VERCEL_ENV
12
- ? process.env.VERCEL_ENV
11
+ return process.env['VERCEL_ENV']
12
+ ? process.env['VERCEL_ENV']
13
13
  : 'production';
14
14
  }
15
15
  if (window.location.hostname.includes('secrecy.tech')) {
@@ -24,10 +24,10 @@ function getEnv() {
24
24
  return 'production';
25
25
  }
26
26
  const env = getEnv();
27
- const secrecyUrl = process.env.NEXT_PUBLIC_IS_SECRECY_INTERNAL !== 'true'
27
+ const secrecyUrl = process.env['NEXT_PUBLIC_IS_SECRECY_INTERNAL'] !== 'true'
28
28
  ? 'www.secrecy.tech'
29
- : (process.env.VERCEL_URL ??
30
- process.env.NEXT_PUBLIC_VERCEL_URL ??
29
+ : (process.env['VERCEL_URL'] ??
30
+ process.env['NEXT_PUBLIC_VERCEL_URL'] ??
31
31
  'www.secrecy.tech');
32
32
  function withPath(origin, path) {
33
33
  if (!path) {
package/dist/lib/utils.js CHANGED
@@ -2,7 +2,7 @@ export const kiloToBytes = (kb) => kb * 1024;
2
2
  export const gigaToBytes = (gb) => gb * 2 ** 30;
3
3
  // Returns the first "primary" email that's found, else returns the first email in the array.
4
4
  export const getPreferedEmail = (emails) => {
5
- if (emails.length === 0) {
5
+ if (!emails[0]) {
6
6
  throw new Error("There's no email!");
7
7
  }
8
8
  return emails.find(({ isPrimary }) => isPrimary) ?? emails[0];
@@ -55,7 +55,7 @@ export const encrypt = process.env.NODE_ENV !== 'test'
55
55
  });
56
56
  }
57
57
  : async (key, dataToEncrypt, progress, signal) => {
58
- return encryptSecretStream(key, dataToEncrypt);
58
+ return encryptSecretStream(key, dataToEncrypt, progress, signal);
59
59
  };
60
60
  export const decrypt = process.env.NODE_ENV !== 'test'
61
61
  ? async (key, dataToDecrypt, progress, signal) => {
@@ -100,5 +100,5 @@ export const decrypt = process.env.NODE_ENV !== 'test'
100
100
  });
101
101
  }
102
102
  : async (key, dataToDecrypt, progress, signal) => {
103
- return decryptSecretStream(key, dataToDecrypt);
103
+ return decryptSecretStream(key, dataToDecrypt, progress, signal);
104
104
  };
@@ -1,4 +1,4 @@
1
- import { type ApiClient, type RouterOutputs, type RouterInputs, CreateTrpcClientOptions } from './client.js';
1
+ import { type ApiClient, type RouterOutputs, type RouterInputs, type CreateTrpcClientOptions } from './client.js';
2
2
  import { type InfuraNetwork, type PublicUser } from './index.js';
3
3
  import { type SelfUser } from './client/types/user.js';
4
4
  export type SecrecyUrls = {
@@ -24,6 +24,8 @@ export declare class BaseClient {
24
24
  me(): Promise<SelfUser>;
25
25
  static getUser(userId: string, opts?: CreateTrpcClientOptions): Promise<PublicUser>;
26
26
  getUser(userId: string): Promise<PublicUser>;
27
+ static getUsers(userIds: string[], opts?: CreateTrpcClientOptions): Promise<PublicUser[]>;
28
+ getUsers(userIds: string[]): Promise<PublicUser[]>;
27
29
  searchUsers(search: string): Promise<PublicUser[]>;
28
30
  updateProfile(data: RouterInputs['user']['updateProfile']): Promise<RouterOutputs['user']['updateProfile']>;
29
31
  static isCryptoTransactionDone({ idOrHash, network, opts, }: {
@@ -1,12 +1,11 @@
1
1
  import type { SecrecyClient, UserAppNotifications, UserAppSettings } from '../index.js';
2
2
  import type { JwtPayload } from 'jsonwebtoken';
3
- import { type RouterOutputs, type ApiClient, type RouterInputs } from '../client.js';
4
- import { type KeyPair } from './types/index.js';
3
+ import { type RouterOutputs, type RouterInputs } from '../client.js';
5
4
  export declare class SecrecyAppClient {
6
5
  #private;
7
6
  jwt: string;
8
7
  jwtDecoded: JwtPayload;
9
- constructor(uaJwt: string, _client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
8
+ constructor(uaJwt: string, client: SecrecyClient);
10
9
  get userId(): string;
11
10
  get appId(): string;
12
11
  getJwt(): Promise<string>;
@@ -1,11 +1,11 @@
1
1
  import type { ProgressCallback, SecrecyClient, UploadDataOptions } from '../index.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';
2
+ import type { DataMetadata, DataStorageType, LocalData, Node, NodeFull, NodeType } from './types/index.js';
4
3
  import { type Progress } from '../types.js';
5
- import { DownloadDataFromLinkOptions } from './data-link.js';
4
+ import { type RouterInputs, type RouterOutputs } from '../client.js';
5
+ import { type DownloadDataFromLinkOptions } from './data-link.js';
6
6
  export declare class SecrecyCloudClient {
7
7
  #private;
8
- constructor(client: SecrecyClient, keys: KeyPair, apiClient: ApiClient);
8
+ constructor(client: SecrecyClient);
9
9
  addDataToHistory({ dataId, nodeId, }: {
10
10
  dataId: string;
11
11
  nodeId: string;
@@ -28,9 +28,9 @@ export declare class SecrecyCloudClient {
28
28
  deletedNodes(): Promise<Node[]>;
29
29
  sharedNodes(): Promise<Node[]>;
30
30
  nodesSharedWithMe(type?: NodeType): Promise<Node[]>;
31
- deleteNodeSharing({ nodeId, userId, }: {
31
+ deleteNodeSharing({ nodeId, destPubKey, }: {
32
32
  nodeId: string;
33
- userId: string;
33
+ destPubKey: string;
34
34
  }): Promise<boolean>;
35
35
  duplicateNode({ nodeId, folderId, name, }: {
36
36
  nodeId: string;
@@ -51,7 +51,7 @@ export declare class SecrecyCloudClient {
51
51
  dataMetadata({ id }: {
52
52
  id: string;
53
53
  }): Promise<DataMetadata>;
54
- shareNode(input: RouterInputs['cloud']['shareNode'], progress?: ProgressCallback): Promise<RouterOutputs['cloud']['shareNodeFinish']>;
54
+ shareNode(accesses: RouterInputs['cloud']['shareNode']['accesses'], progress?: ProgressCallback): Promise<RouterOutputs['cloud']['shareNodeFinish']>;
55
55
  updateNode({ nodeId, name, isFavorite, deletedAt, }: {
56
56
  nodeId: string;
57
57
  name?: string | null | undefined;
@@ -93,7 +93,7 @@ export declare class SecrecyCloudClient {
93
93
  name: string;
94
94
  nodeId?: string;
95
95
  }): Promise<NodeFull>;
96
- private readonly encryptNodesForUsers;
96
+ private readonly encryptNodesForIdentities;
97
97
  reportData({ id, reasons, }: Omit<RouterInputs['cloud']['reportData'], 'encryptedDataKey'>): Promise<RouterOutputs['cloud']['reportData']>;
98
98
  updateDataStorageType(input: RouterInputs['cloud']['moveToStorageType']): Promise<{
99
99
  isMoved: boolean;
@@ -126,32 +126,32 @@ export declare class SecrecyCloudClient {
126
126
  isMatching: false;
127
127
  details: {
128
128
  missingNodeAccesses: {
129
- userId: string;
129
+ pubKey: string;
130
130
  nodeId: string;
131
131
  }[];
132
132
  missingDataAccesses: {
133
- userId: string;
133
+ pubKey: string;
134
134
  nodeId: string;
135
135
  dataId: string;
136
136
  }[];
137
137
  invalidRightsAccesses: {
138
- userId: string;
138
+ pubKey: string;
139
139
  nodeId: string;
140
140
  expect: {
141
141
  rights: "delete" | "read" | "write";
142
142
  } & {
143
- addAccess?: "delete" | "read" | "write" | null | undefined;
144
- sharingAddAccess?: "delete" | "read" | "write" | null | undefined;
145
- delAccess?: "delete" | "read" | "write" | null | undefined;
146
- sharingDelAccess?: "delete" | "read" | "write" | null | undefined;
143
+ addAccess: "delete" | "read" | "write" | null;
144
+ sharingAddAccess: "delete" | "read" | "write" | null;
145
+ delAccess: "delete" | "read" | "write" | null;
146
+ sharingDelAccess: "delete" | "read" | "write" | null;
147
147
  };
148
148
  current: {
149
149
  rights: "delete" | "read" | "write";
150
150
  } & {
151
- addAccess?: "delete" | "read" | "write" | null | undefined;
152
- sharingAddAccess?: "delete" | "read" | "write" | null | undefined;
153
- delAccess?: "delete" | "read" | "write" | null | undefined;
154
- sharingDelAccess?: "delete" | "read" | "write" | null | undefined;
151
+ addAccess: "delete" | "read" | "write" | null;
152
+ sharingAddAccess: "delete" | "read" | "write" | null;
153
+ delAccess: "delete" | "read" | "write" | null;
154
+ sharingDelAccess: "delete" | "read" | "write" | null;
155
155
  };
156
156
  }[];
157
157
  };
@@ -1,7 +1,4 @@
1
- import { type ApiClient } from '../client.js';
2
1
  import type { SecrecyClient } from '../index.js';
3
- import { type KeyPair } from './types/index.js';
4
2
  export declare class SecrecyDbClient {
5
- #private;
6
- constructor(_client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
3
+ constructor(_client: SecrecyClient);
7
4
  }
@@ -1,10 +1,9 @@
1
- import { type ApiClient, type RouterInputs } from '../client.js';
1
+ import { 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';
4
3
  import { type ApiMail } from './types/mail.js';
5
4
  export declare class SecrecyMailClient {
6
5
  #private;
7
- constructor(client: SecrecyClient, keys: KeyPair, apiClient: ApiClient);
6
+ constructor(client: SecrecyClient);
8
7
  get({ id }: {
9
8
  id: string;
10
9
  }): Promise<Mail>;
@@ -1,9 +1,8 @@
1
- import { RouterInputs, RouterOutputs, type ApiClient } from '../client.js';
1
+ import type { RouterInputs, RouterOutputs } from '../client.js';
2
2
  import type { SecrecyClient } from '../index.js';
3
- import { type KeyPair } from './types/index.js';
4
3
  export declare class SecrecyOrganizationClient {
5
4
  #private;
6
- constructor(_client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
5
+ constructor(client: SecrecyClient);
7
6
  create(input: RouterInputs['org']['create']): Promise<RouterOutputs['org']['create']>;
8
7
  update(input: Omit<RouterInputs['org']['update'], 'billingProfileStripeCustomerId'>): Promise<RouterOutputs['org']['update']>;
9
8
  addMember(input: RouterInputs['org']['addMember']): Promise<RouterOutputs['org']['addMember']>;
@@ -1,6 +1,4 @@
1
1
  import type { SecrecyClient } from '../index.js';
2
- import { type ApiClient } from '../client.js';
3
- import { type KeyPair } from './types/index.js';
4
2
  interface SuccessPayResponse<T> {
5
3
  success: true;
6
4
  data: T;
@@ -12,7 +10,7 @@ interface ErrorPayResponse {
12
10
  export type SecrecyPayResponse<T> = SuccessPayResponse<T> | ErrorPayResponse;
13
11
  export declare class SecrecyPayClient {
14
12
  #private;
15
- constructor(client: SecrecyClient, _keys: KeyPair, _apiClient: ApiClient);
13
+ constructor(client: SecrecyClient);
16
14
  confirmPaymentIntent({ paymentIntentId, secrecyIdWhoCreatedPaymentIntent, secrecyIdWhoNeedToConfirmPaymentIntent, amount, currency, }: {
17
15
  paymentIntentId: string;
18
16
  secrecyIdWhoCreatedPaymentIntent: string;
@@ -1,9 +1,8 @@
1
- import { type RouterInputs, type RouterOutputs, type ApiClient } from '../client.js';
1
+ import { type RouterInputs, type RouterOutputs } from '../client.js';
2
2
  import type { SecrecyClient } from '../index.js';
3
- import { type KeyPair } from './types/index.js';
4
3
  export declare class SecrecyPseudonymClient {
5
4
  #private;
6
- constructor(client: SecrecyClient, keys: KeyPair, apiClient: ApiClient);
5
+ constructor(client: SecrecyClient);
7
6
  askForLabel(input: RouterInputs['pseudonym']['askForLabel']): Promise<RouterOutputs['pseudonym']['askForLabel']>;
8
7
  askForUser(input: RouterInputs['pseudonym']['askForUser']): Promise<RouterOutputs['pseudonym']['askForUser']>;
9
8
  cross(input: RouterInputs['pseudonym']['cross']): Promise<RouterOutputs['pseudonym']['cross']>;
@@ -1,9 +1,8 @@
1
- import type { RouterInputs, ApiClient, RouterOutputs } from '../client.js';
1
+ import type { RouterInputs, RouterOutputs } from '../client.js';
2
2
  import type { SecrecyClient } from '../index.js';
3
- import type { KeyPair } from './types/index.js';
4
3
  export declare class SecrecyUserClient {
5
4
  #private;
6
- constructor(_client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
5
+ constructor(client: SecrecyClient);
7
6
  answerInvitation(input: RouterInputs['contacts']['answerInvitation']): Promise<RouterOutputs['contacts']['answerInvitation']>;
8
7
  cancelInvitation(input: RouterInputs['contacts']['cancelInvitation']): Promise<RouterOutputs['contacts']['cancelInvitation']>;
9
8
  createInvitation(input: RouterInputs['contacts']['createInvitation']): Promise<RouterOutputs['contacts']['createInvitation']>;
@@ -1,4 +1,4 @@
1
- import type { ApiData, InternalData, DataMetadata, KeyPair } from '../types/index.js';
2
- export declare function apiDataToInternal(apiData: ApiData, keyPair: KeyPair): InternalData;
1
+ import type { ApiData, InternalData, DataMetadata } from '../types/index.js';
2
+ export declare function apiDataToInternal(apiData: ApiData, keyPairs: Record<string, string>): InternalData;
3
3
  export declare function internalDataToExternalData(internal: InternalData): DataMetadata;
4
- export declare function apiDataToExternal(apiData: ApiData, keyPair: KeyPair): DataMetadata;
4
+ export declare function apiDataToExternal(apiData: ApiData, keyPairs: Record<string, string>): DataMetadata;
@@ -1,8 +1,6 @@
1
- import { type Mail, type SecrecyClient } from '../../index.js';
2
- import { type KeyPair } from '../types/index.js';
1
+ import { type Mail } from '../../index.js';
3
2
  import { type ApiMail } from '../types/mail.js';
4
- export declare function convertInternalMailToExternal({ client, mail, keyPair, }: {
3
+ export declare function convertInternalMailToExternal({ mail, keyPairs, }: {
5
4
  mail: ApiMail;
6
- client: SecrecyClient;
7
- keyPair: KeyPair;
5
+ keyPairs: Record<string, string>;
8
6
  }): Promise<Mail>;
@@ -1,6 +1,6 @@
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>;
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>;
3
3
  export declare function internalNodeFullToNodeFull(internal: InternalNodeFull): NodeFull;
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>;
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>;