@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
@@ -13,20 +13,6 @@ async function getPublicUser(client, id) {
13
13
  usersCache.set(user.id, user);
14
14
  return user;
15
15
  }
16
- async function getPublicUsers(client, ids) {
17
- let users = ids
18
- .map((id) => usersCache.get(id))
19
- .filter((u) => u !== undefined);
20
- const missingIds = ids.filter((id) => !usersCache.has(id));
21
- if (missingIds.length > 0) {
22
- const fetchedUsers = await client.user.byIds.query({
23
- ids: missingIds,
24
- });
25
- fetchedUsers.forEach((user) => usersCache.set(user.id, user));
26
- users = users.concat(fetchedUsers);
27
- }
28
- return users;
29
- }
30
16
  export class BaseClient {
31
17
  static getBaseClient = (opts = {}) => createTRPCClient(opts);
32
18
  client;
@@ -39,6 +25,7 @@ export class BaseClient {
39
25
  auth: opts.secrecyUrls?.auth ?? 'https://auth.secrecy.tech',
40
26
  account: opts.secrecyUrls?.account ?? 'https://account.secrecy.tech',
41
27
  api: opts.secrecyUrls?.api ?? 'https://api.secrecy.tech',
28
+ data: opts.secrecyUrls?.data ?? 'https://data.secrecy.tech',
42
29
  };
43
30
  this.client =
44
31
  opts.apiClient ??
@@ -71,7 +58,7 @@ export class BaseClient {
71
58
  this.sessionId !== this.#me.sessionId ||
72
59
  Date.now() - this.#me.fetchedAt > 5 * 60 * 1000) {
73
60
  const data = await this.client.user.self.query({
74
- t: Date.now(),
61
+ // t: Date.now(), // TODO needed or what?
75
62
  });
76
63
  this.#me = {
77
64
  data,
@@ -89,14 +76,6 @@ export class BaseClient {
89
76
  const user = await getPublicUser(this.client, userId);
90
77
  return user;
91
78
  }
92
- static async getUsers(userIds, opts) {
93
- const users = await getPublicUsers(this.getBaseClient(opts), userIds);
94
- return users;
95
- }
96
- async getUsers(userIds) {
97
- const users = await getPublicUsers(this.client, userIds);
98
- return users;
99
- }
100
79
  async searchUsers(search) {
101
80
  const users = await this.client.user.searchMany.query({
102
81
  search,
@@ -133,12 +112,10 @@ export class BaseClient {
133
112
  const local = getStorage(false);
134
113
  const session = getStorage(true);
135
114
  local.jwt.clear();
136
- local.identities.clear();
137
- local.keyPairs.clear();
115
+ local.userAppKeys.clear();
138
116
  local.userAppSession.clear();
139
117
  session.jwt.clear();
140
- session.identities.clear();
141
- session.keyPairs.clear();
118
+ session.userAppKeys.clear();
142
119
  session.userAppSession.clear();
143
120
  usersCache.clear();
144
121
  };
@@ -4,11 +4,15 @@ import { publicKeysCache } from '../cache.js';
4
4
  export class SecrecyAppClient {
5
5
  jwt;
6
6
  jwtDecoded;
7
- #client;
8
- constructor(uaJwt, client) {
7
+ // #client: SecrecyClient
8
+ // #keys: KeyPair;
9
+ #apiClient;
10
+ constructor(uaJwt, _client, _keys, apiClient) {
9
11
  this.jwt = uaJwt;
10
12
  this.jwtDecoded = decode(uaJwt);
11
- this.#client = client;
13
+ // this.#client = client
14
+ // this.#keys = keys;
15
+ this.#apiClient = apiClient;
12
16
  }
13
17
  get userId() {
14
18
  const sub = this.jwtDecoded.sub;
@@ -31,7 +35,7 @@ export class SecrecyAppClient {
31
35
  // if (this.jwtDecoded.exp && this.jwtDecoded.exp * 1000 < Date.now()) {
32
36
  // return this.jwt;
33
37
  // }
34
- const { jwt } = await this.#client.apiClient.auth.jwt.query({
38
+ const { jwt } = await this.#apiClient.auth.jwt.query({
35
39
  includeEmail: typeof this.jwtDecoded.email === 'string',
36
40
  });
37
41
  this.jwt = jwt;
@@ -49,19 +53,19 @@ export class SecrecyAppClient {
49
53
  return jwt;
50
54
  }
51
55
  async limits() {
52
- return await this.#client.apiClient.application.limits.query({});
56
+ return await this.#apiClient.application.limits.query({});
53
57
  }
54
58
  async metrics() {
55
- return await this.#client.apiClient.application.metrics.query({});
59
+ return await this.#apiClient.application.metrics.query({});
56
60
  }
57
61
  async quotas() {
58
- return await this.#client.apiClient.application.quotas.query({});
62
+ return await this.#apiClient.application.quotas.query({});
59
63
  }
60
64
  async isApplicationUser(input) {
61
- return await this.#client.apiClient.application.isApplicationUser.query(input);
65
+ return await this.#apiClient.application.isApplicationUser.query(input);
62
66
  }
63
67
  async updateNotifications(notifications) {
64
- const updateAppNotifications = await this.#client.apiClient.application.updateNotification.mutate({
68
+ const updateAppNotifications = await this.#apiClient.application.updateNotification.mutate({
65
69
  cloud: notifications.cloud,
66
70
  disableAllUntil: notifications.disableAllUntil,
67
71
  enableAll: notifications.enableAll,
@@ -70,7 +74,7 @@ export class SecrecyAppClient {
70
74
  return updateAppNotifications;
71
75
  }
72
76
  async notifications() {
73
- return await this.#client.apiClient.application.notification.query();
77
+ return await this.#apiClient.application.notification.query();
74
78
  }
75
79
  async userPublicKey(input, appId) {
76
80
  appId ??= this.appId;
@@ -88,7 +92,7 @@ export class SecrecyAppClient {
88
92
  ...new Set(userIds.filter((userId) => publicKeys[userId] === undefined)),
89
93
  ];
90
94
  if (missingKeys.length > 0) {
91
- const userKeysMap = await this.#client.apiClient.application.userPublicKey.query({
95
+ const userKeysMap = await this.#apiClient.application.userPublicKey.query({
92
96
  userIds: missingKeys,
93
97
  appId,
94
98
  });
@@ -109,11 +113,11 @@ export class SecrecyAppClient {
109
113
  return Array.isArray(input) ? publicKeys : publicKeys[input];
110
114
  }
111
115
  async settings() {
112
- const settings = await this.#client.apiClient.application.settings.query({});
116
+ const settings = await this.#apiClient.application.settings.query({});
113
117
  return settings;
114
118
  }
115
119
  async updateSettings(settings) {
116
- const updateAppSettings = await this.#client.apiClient.application.updateSettings.mutate({
120
+ const updateAppSettings = await this.#apiClient.application.updateSettings.mutate({
117
121
  cloudNodeDaysForDelete: settings.cloudNodeDaysForDelete,
118
122
  historyDataDaysForDelete: settings.historyDataDaysForDelete,
119
123
  historyDataMaxCount: settings.historyDataMaxCount,