@secrecy/lib 1.74.3 → 1.75.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.
- package/dist/lib/base-client.js +26 -2
- package/dist/lib/client/SecrecyAppClient.js +13 -17
- package/dist/lib/client/SecrecyCloudClient.js +131 -135
- package/dist/lib/client/SecrecyDbClient.js +3 -7
- package/dist/lib/client/SecrecyMailClient.js +38 -48
- package/dist/lib/client/SecrecyOrganizationClient.js +10 -12
- package/dist/lib/client/SecrecyPayClient.js +1 -5
- package/dist/lib/client/SecrecyPseudonymClient.js +4 -8
- package/dist/lib/client/SecrecyUserClient.js +11 -11
- package/dist/lib/client/SecrecyWalletClient.js +0 -2
- package/dist/lib/client/convert/data.js +4 -4
- package/dist/lib/client/convert/mail.js +5 -6
- package/dist/lib/client/convert/node.js +46 -34
- package/dist/lib/client/helpers.js +17 -7
- package/dist/lib/client/index.js +48 -12
- package/dist/lib/client/storage.js +3 -2
- package/dist/lib/client/types/identity.js +18 -0
- package/dist/lib/client/types/index.js +3 -7
- package/dist/lib/client/upload.js +29 -17
- package/dist/lib/crypto/domain.js +7 -3
- package/dist/lib/index.js +1 -0
- package/dist/types/base-client.d.ts +2 -0
- package/dist/types/client/SecrecyAppClient.d.ts +2 -3
- package/dist/types/client/SecrecyCloudClient.d.ts +18 -18
- package/dist/types/client/SecrecyDbClient.d.ts +1 -3
- package/dist/types/client/SecrecyMailClient.d.ts +2 -3
- package/dist/types/client/SecrecyOrganizationClient.d.ts +2 -3
- package/dist/types/client/SecrecyPayClient.d.ts +1 -3
- package/dist/types/client/SecrecyPseudonymClient.d.ts +2 -3
- package/dist/types/client/SecrecyUserClient.d.ts +2 -3
- package/dist/types/client/convert/data.d.ts +3 -3
- package/dist/types/client/convert/mail.d.ts +3 -5
- package/dist/types/client/convert/node.d.ts +5 -5
- package/dist/types/client/index.d.ts +11 -3
- package/dist/types/client/storage.d.ts +3 -2
- package/dist/types/client/types/identity.d.ts +29 -0
- package/dist/types/client/types/index.d.ts +13 -9
- package/dist/types/client/types/mail.d.ts +2 -1
- package/dist/types/client/types/node.d.ts +12 -9
- package/dist/types/client/types/user.d.ts +15 -0
- package/dist/types/client/upload.d.ts +4 -3
- package/dist/types/client.d.ts +1438 -1050
- package/dist/types/crypto/domain.d.ts +5 -3
- package/dist/types/crypto/index.d.ts +3 -3
- package/dist/types/index.d.ts +2 -1
- package/package.json +21 -21
package/dist/lib/base-client.js
CHANGED
|
@@ -13,6 +13,20 @@ 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
|
+
}
|
|
16
30
|
export class BaseClient {
|
|
17
31
|
static getBaseClient = (opts = {}) => createTRPCClient(opts);
|
|
18
32
|
client;
|
|
@@ -76,6 +90,14 @@ export class BaseClient {
|
|
|
76
90
|
const user = await getPublicUser(this.client, userId);
|
|
77
91
|
return user;
|
|
78
92
|
}
|
|
93
|
+
static async getUsers(userIds, opts) {
|
|
94
|
+
const users = await getPublicUsers(this.getBaseClient(opts), userIds);
|
|
95
|
+
return users;
|
|
96
|
+
}
|
|
97
|
+
async getUsers(userIds) {
|
|
98
|
+
const users = await getPublicUsers(this.client, userIds);
|
|
99
|
+
return users;
|
|
100
|
+
}
|
|
79
101
|
async searchUsers(search) {
|
|
80
102
|
const users = await this.client.user.searchMany.query({
|
|
81
103
|
search,
|
|
@@ -112,10 +134,12 @@ export class BaseClient {
|
|
|
112
134
|
const local = getStorage(false);
|
|
113
135
|
const session = getStorage(true);
|
|
114
136
|
local.jwt.clear();
|
|
115
|
-
local.
|
|
137
|
+
local.identities.clear();
|
|
138
|
+
local.keyPairs.clear();
|
|
116
139
|
local.userAppSession.clear();
|
|
117
140
|
session.jwt.clear();
|
|
118
|
-
session.
|
|
141
|
+
session.identities.clear();
|
|
142
|
+
session.keyPairs.clear();
|
|
119
143
|
session.userAppSession.clear();
|
|
120
144
|
usersCache.clear();
|
|
121
145
|
};
|
|
@@ -4,15 +4,11 @@ import { publicKeysCache } from '../cache.js';
|
|
|
4
4
|
export class SecrecyAppClient {
|
|
5
5
|
jwt;
|
|
6
6
|
jwtDecoded;
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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,
|