@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.
- package/dist/lib/base-client.js +4 -27
- package/dist/lib/client/SecrecyAppClient.js +17 -13
- package/dist/lib/client/SecrecyCloudClient.js +156 -368
- package/dist/lib/client/SecrecyDbClient.js +7 -3
- package/dist/lib/client/SecrecyMailClient.js +48 -38
- package/dist/lib/client/SecrecyOrganizationClient.js +12 -10
- package/dist/lib/client/SecrecyPayClient.js +5 -1
- package/dist/lib/client/SecrecyPseudonymClient.js +8 -4
- package/dist/lib/client/SecrecyUserClient.js +11 -11
- package/dist/lib/client/SecrecyWalletClient.js +2 -0
- package/dist/lib/client/convert/data.js +4 -4
- package/dist/lib/client/convert/mail.js +6 -5
- package/dist/lib/client/convert/node.js +34 -46
- package/dist/lib/client/data-link.js +77 -0
- package/dist/lib/client/download.js +84 -0
- package/dist/lib/client/helpers.js +11 -18
- package/dist/lib/client/index.js +12 -48
- package/dist/lib/client/storage.js +2 -3
- package/dist/lib/client/types/index.js +7 -3
- package/dist/lib/client/upload.js +252 -0
- package/dist/lib/client.js +7 -0
- package/dist/lib/crypto/data.js +3 -0
- package/dist/lib/crypto/domain.js +123 -12
- package/dist/lib/crypto/helpers.js +23 -0
- package/dist/lib/index.js +0 -1
- package/dist/types/base-client.d.ts +1 -2
- package/dist/types/client/SecrecyAppClient.d.ts +3 -2
- package/dist/types/client/SecrecyCloudClient.d.ts +28 -20
- package/dist/types/client/SecrecyDbClient.d.ts +3 -1
- package/dist/types/client/SecrecyMailClient.d.ts +3 -2
- package/dist/types/client/SecrecyOrganizationClient.d.ts +3 -2
- package/dist/types/client/SecrecyPayClient.d.ts +3 -1
- package/dist/types/client/SecrecyPseudonymClient.d.ts +3 -2
- package/dist/types/client/SecrecyUserClient.d.ts +3 -2
- package/dist/types/client/convert/data.d.ts +3 -3
- package/dist/types/client/convert/mail.d.ts +5 -3
- package/dist/types/client/convert/node.d.ts +5 -5
- package/dist/types/client/data-link.d.ts +37 -0
- package/dist/types/client/download.d.ts +2 -0
- package/dist/types/client/index.d.ts +3 -11
- package/dist/types/client/storage.d.ts +2 -3
- package/dist/types/client/types/index.d.ts +9 -13
- package/dist/types/client/types/mail.d.ts +1 -2
- package/dist/types/client/types/node.d.ts +9 -12
- package/dist/types/client/types/user.d.ts +0 -15
- package/dist/types/client/upload.d.ts +38 -0
- package/dist/types/client.d.ts +6174 -681
- package/dist/types/crypto/domain.d.ts +36 -8
- package/dist/types/crypto/helpers.d.ts +12 -0
- package/dist/types/crypto/index.d.ts +3 -3
- package/dist/types/index.d.ts +1 -2
- package/package.json +4 -2
- package/dist/lib/client/types/identity.js +0 -18
- package/dist/types/client/types/identity.d.ts +0 -29
package/dist/lib/base-client.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
137
|
-
local.keyPairs.clear();
|
|
115
|
+
local.userAppKeys.clear();
|
|
138
116
|
local.userAppSession.clear();
|
|
139
117
|
session.jwt.clear();
|
|
140
|
-
session.
|
|
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
|
-
|
|
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.#
|
|
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.#
|
|
56
|
+
return await this.#apiClient.application.limits.query({});
|
|
53
57
|
}
|
|
54
58
|
async metrics() {
|
|
55
|
-
return await this.#
|
|
59
|
+
return await this.#apiClient.application.metrics.query({});
|
|
56
60
|
}
|
|
57
61
|
async quotas() {
|
|
58
|
-
return await this.#
|
|
62
|
+
return await this.#apiClient.application.quotas.query({});
|
|
59
63
|
}
|
|
60
64
|
async isApplicationUser(input) {
|
|
61
|
-
return await this.#
|
|
65
|
+
return await this.#apiClient.application.isApplicationUser.query(input);
|
|
62
66
|
}
|
|
63
67
|
async updateNotifications(notifications) {
|
|
64
|
-
const updateAppNotifications = await this.#
|
|
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.#
|
|
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.#
|
|
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.#
|
|
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.#
|
|
120
|
+
const updateAppSettings = await this.#apiClient.application.updateSettings.mutate({
|
|
117
121
|
cloudNodeDaysForDelete: settings.cloudNodeDaysForDelete,
|
|
118
122
|
historyDataDaysForDelete: settings.historyDataDaysForDelete,
|
|
119
123
|
historyDataMaxCount: settings.historyDataMaxCount,
|