@secrecy/lib 1.73.6 → 1.74.0-feat-groups-identity.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 (41) hide show
  1. package/dist/lib/base-client.js +5 -3
  2. package/dist/lib/client/SecrecyAppClient.js +13 -17
  3. package/dist/lib/client/SecrecyCloudClient.js +129 -137
  4. package/dist/lib/client/SecrecyDbClient.js +3 -7
  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 +4 -4
  12. package/dist/lib/client/convert/mail.js +5 -6
  13. package/dist/lib/client/convert/node.js +46 -34
  14. package/dist/lib/client/helpers.js +17 -11
  15. package/dist/lib/client/index.js +45 -12
  16. package/dist/lib/client/storage.js +3 -2
  17. package/dist/lib/client/types/identity.js +18 -0
  18. package/dist/lib/client/types/index.js +3 -7
  19. package/dist/lib/index.js +1 -0
  20. package/dist/types/client/SecrecyAppClient.d.ts +2 -3
  21. package/dist/types/client/SecrecyCloudClient.d.ts +18 -18
  22. package/dist/types/client/SecrecyDbClient.d.ts +1 -3
  23. package/dist/types/client/SecrecyMailClient.d.ts +2 -3
  24. package/dist/types/client/SecrecyOrganizationClient.d.ts +2 -3
  25. package/dist/types/client/SecrecyPayClient.d.ts +1 -3
  26. package/dist/types/client/SecrecyPseudonymClient.d.ts +2 -3
  27. package/dist/types/client/SecrecyUserClient.d.ts +2 -3
  28. package/dist/types/client/convert/data.d.ts +3 -3
  29. package/dist/types/client/convert/mail.d.ts +3 -5
  30. package/dist/types/client/convert/node.d.ts +5 -5
  31. package/dist/types/client/index.d.ts +9 -2
  32. package/dist/types/client/storage.d.ts +3 -2
  33. package/dist/types/client/types/identity.d.ts +29 -0
  34. package/dist/types/client/types/index.d.ts +13 -9
  35. package/dist/types/client/types/mail.d.ts +2 -1
  36. package/dist/types/client/types/node.d.ts +12 -9
  37. package/dist/types/client/types/user.d.ts +15 -0
  38. package/dist/types/client.d.ts +679 -513
  39. package/dist/types/crypto/index.d.ts +3 -3
  40. package/dist/types/index.d.ts +2 -1
  41. package/package.json +2 -2
@@ -57,7 +57,7 @@ export class BaseClient {
57
57
  this.sessionId !== this.#me.sessionId ||
58
58
  Date.now() - this.#me.fetchedAt > 5 * 60 * 1000) {
59
59
  const data = await this.client.user.self.query({
60
- // t: Date.now(), // TODO needed or what?
60
+ t: Date.now(),
61
61
  });
62
62
  this.#me = {
63
63
  data,
@@ -111,10 +111,12 @@ export class BaseClient {
111
111
  const local = getStorage(false);
112
112
  const session = getStorage(true);
113
113
  local.jwt.clear();
114
- local.userAppKeys.clear();
114
+ local.identities.clear();
115
+ local.keyPairs.clear();
115
116
  local.userAppSession.clear();
116
117
  session.jwt.clear();
117
- session.userAppKeys.clear();
118
+ session.identities.clear();
119
+ session.keyPairs.clear();
118
120
  session.userAppSession.clear();
119
121
  usersCache.clear();
120
122
  };
@@ -4,15 +4,11 @@ import { publicKeysCache } from '../cache.js';
4
4
  export class SecrecyAppClient {
5
5
  jwt;
6
6
  jwtDecoded;
7
- // #client: SecrecyClient
8
- // #keys: KeyPair;
9
- #apiClient;
10
- constructor(uaJwt, _client, _keys, apiClient) {
7
+ #client;
8
+ constructor(uaJwt, client) {
11
9
  this.jwt = uaJwt;
12
10
  this.jwtDecoded = decode(uaJwt);
13
- // this.#client = client
14
- // this.#keys = keys;
15
- this.#apiClient = apiClient;
11
+ this.#client = client;
16
12
  }
17
13
  get userId() {
18
14
  const sub = this.jwtDecoded.sub;
@@ -35,7 +31,7 @@ export class SecrecyAppClient {
35
31
  // if (this.jwtDecoded.exp && this.jwtDecoded.exp * 1000 < Date.now()) {
36
32
  // return this.jwt;
37
33
  // }
38
- const { jwt } = await this.#apiClient.auth.jwt.query({
34
+ const { jwt } = await this.#client.apiClient.auth.jwt.query({
39
35
  includeEmail: typeof this.jwtDecoded.email === 'string',
40
36
  });
41
37
  this.jwt = jwt;
@@ -53,19 +49,19 @@ export class SecrecyAppClient {
53
49
  return jwt;
54
50
  }
55
51
  async limits() {
56
- return await this.#apiClient.application.limits.query({});
52
+ return await this.#client.apiClient.application.limits.query({});
57
53
  }
58
54
  async metrics() {
59
- return await this.#apiClient.application.metrics.query({});
55
+ return await this.#client.apiClient.application.metrics.query({});
60
56
  }
61
57
  async quotas() {
62
- return await this.#apiClient.application.quotas.query({});
58
+ return await this.#client.apiClient.application.quotas.query({});
63
59
  }
64
60
  async isApplicationUser(input) {
65
- return await this.#apiClient.application.isApplicationUser.query(input);
61
+ return await this.#client.apiClient.application.isApplicationUser.query(input);
66
62
  }
67
63
  async updateNotifications(notifications) {
68
- const updateAppNotifications = await this.#apiClient.application.updateNotification.mutate({
64
+ const updateAppNotifications = await this.#client.apiClient.application.updateNotification.mutate({
69
65
  cloud: notifications.cloud,
70
66
  disableAllUntil: notifications.disableAllUntil,
71
67
  enableAll: notifications.enableAll,
@@ -74,7 +70,7 @@ export class SecrecyAppClient {
74
70
  return updateAppNotifications;
75
71
  }
76
72
  async notifications() {
77
- return await this.#apiClient.application.notification.query();
73
+ return await this.#client.apiClient.application.notification.query();
78
74
  }
79
75
  async userPublicKey(input, appId) {
80
76
  appId ??= this.appId;
@@ -92,7 +88,7 @@ export class SecrecyAppClient {
92
88
  ...new Set(userIds.filter((userId) => publicKeys[userId] === undefined)),
93
89
  ];
94
90
  if (missingKeys.length > 0) {
95
- const userKeysMap = await this.#apiClient.application.userPublicKey.query({
91
+ const userKeysMap = await this.#client.apiClient.application.userPublicKey.query({
96
92
  userIds: missingKeys,
97
93
  appId,
98
94
  });
@@ -113,11 +109,11 @@ export class SecrecyAppClient {
113
109
  return Array.isArray(input) ? publicKeys : publicKeys[input];
114
110
  }
115
111
  async settings() {
116
- const settings = await this.#apiClient.application.settings.query({});
112
+ const settings = await this.#client.apiClient.application.settings.query({});
117
113
  return settings;
118
114
  }
119
115
  async updateSettings(settings) {
120
- const updateAppSettings = await this.#apiClient.application.updateSettings.mutate({
116
+ const updateAppSettings = await this.#client.apiClient.application.updateSettings.mutate({
121
117
  cloudNodeDaysForDelete: settings.cloudNodeDaysForDelete,
122
118
  historyDataDaysForDelete: settings.historyDataDaysForDelete,
123
119
  historyDataMaxCount: settings.historyDataMaxCount,