@secrecy/lib 1.75.0-feat-groups-identity.2 → 1.75.0-feat-groups-identity.4
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.
|
@@ -88,22 +88,35 @@ export class SecrecyAppClient {
|
|
|
88
88
|
...new Set(userIds.filter((userId) => publicKeys[userId] === undefined)),
|
|
89
89
|
];
|
|
90
90
|
if (missingKeys.length > 0) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
if (missingKeys.length === 1) {
|
|
92
|
+
const userKey = await this.#client.apiClient.application.userPublicKey.query({
|
|
93
|
+
id: missingKeys[0],
|
|
94
|
+
appId,
|
|
95
|
+
});
|
|
96
|
+
if (userKey.appId !== appId) {
|
|
97
|
+
throw new Error(`AppId mismatch: ${userKey.appId} !== ${appId}`);
|
|
98
|
+
}
|
|
99
|
+
publicKeys[missingKeys[0]] = userKey.publicKey;
|
|
100
|
+
publicKeysCache.set(`userPublicKey:${missingKeys[0]}-${appId}`, userKey.publicKey);
|
|
97
101
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
else {
|
|
103
|
+
const userKeysMap = await this.#client.apiClient.application.usersPublicKey.query({
|
|
104
|
+
userIds: missingKeys,
|
|
105
|
+
appId,
|
|
106
|
+
});
|
|
107
|
+
if ('publicKey' in userKeysMap) {
|
|
108
|
+
throw Error('Should not happen!');
|
|
109
|
+
}
|
|
110
|
+
if (userKeysMap.appId !== appId) {
|
|
111
|
+
throw new Error(`AppId mismatch: ${userKeysMap.appId} !== ${appId}`);
|
|
112
|
+
}
|
|
113
|
+
if (Object.keys(userKeysMap.publicKeys).length !== missingKeys.length) {
|
|
114
|
+
throw new Error("Unable to load some user's public keys!");
|
|
115
|
+
}
|
|
116
|
+
for (const [userId, userPublicKey] of Object.entries(userKeysMap.publicKeys)) {
|
|
117
|
+
publicKeys[userId] = userPublicKey;
|
|
118
|
+
publicKeysCache.set(`userPublicKey:${userId}-${appId}`, userPublicKey);
|
|
119
|
+
}
|
|
107
120
|
}
|
|
108
121
|
}
|
|
109
122
|
return Array.isArray(input) ? publicKeys : publicKeys[input];
|
|
@@ -39,10 +39,12 @@ async function apiNodeToInternal(apiNode, keyPairs) {
|
|
|
39
39
|
access.nameKey = sodium.to_hex(key);
|
|
40
40
|
}
|
|
41
41
|
const firstAccess = internal.accesses[0];
|
|
42
|
-
if (!firstAccess
|
|
42
|
+
if (!firstAccess) {
|
|
43
43
|
throw new Error('No access found for node ' + internal.id);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
if (firstAccess.nameKey !== null) {
|
|
46
|
+
internal.name = sodium.to_string(await decryptSecretStream(sodium.from_hex(firstAccess.nameKey), sodium.from_hex(internal.name)));
|
|
47
|
+
}
|
|
46
48
|
for (const b of internal.breadcrumb) {
|
|
47
49
|
if (b.nameKey === null) {
|
|
48
50
|
continue;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -244,6 +244,17 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
244
244
|
meta: any;
|
|
245
245
|
}>;
|
|
246
246
|
userPublicKey: import("@trpc/server").TRPCQueryProcedure<{
|
|
247
|
+
input: {
|
|
248
|
+
id: string;
|
|
249
|
+
appId?: string | undefined;
|
|
250
|
+
};
|
|
251
|
+
output: {
|
|
252
|
+
appId: string;
|
|
253
|
+
publicKey: string;
|
|
254
|
+
};
|
|
255
|
+
meta: any;
|
|
256
|
+
}>;
|
|
257
|
+
usersPublicKey: import("@trpc/server").TRPCQueryProcedure<{
|
|
247
258
|
input: {
|
|
248
259
|
userId: string;
|
|
249
260
|
appId?: string | undefined;
|
|
@@ -4976,9 +4987,10 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
4976
4987
|
kind: "GROUP";
|
|
4977
4988
|
identityPubKey: string;
|
|
4978
4989
|
groupId: string;
|
|
4990
|
+
groupOwnerPubKey: string;
|
|
4979
4991
|
encPriv: string;
|
|
4980
4992
|
sharedByPubKey: string;
|
|
4981
|
-
|
|
4993
|
+
groupRole: "ADMIN" | "MEMBER";
|
|
4982
4994
|
})[];
|
|
4983
4995
|
};
|
|
4984
4996
|
meta: any;
|
|
@@ -5006,9 +5018,10 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
5006
5018
|
kind: "GROUP";
|
|
5007
5019
|
identityPubKey: string;
|
|
5008
5020
|
groupId: string;
|
|
5021
|
+
groupOwnerPubKey: string;
|
|
5009
5022
|
encPriv: string;
|
|
5010
5023
|
sharedByPubKey: string;
|
|
5011
|
-
|
|
5024
|
+
groupRole: "ADMIN" | "MEMBER";
|
|
5012
5025
|
})[] | null;
|
|
5013
5026
|
};
|
|
5014
5027
|
meta: any;
|
|
@@ -5681,15 +5694,6 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
5681
5694
|
};
|
|
5682
5695
|
meta: any;
|
|
5683
5696
|
}>;
|
|
5684
|
-
publicKey: import("@trpc/server").TRPCQueryProcedure<{
|
|
5685
|
-
input: {
|
|
5686
|
-
id: string;
|
|
5687
|
-
};
|
|
5688
|
-
output: {
|
|
5689
|
-
pub: string;
|
|
5690
|
-
};
|
|
5691
|
-
meta: any;
|
|
5692
|
-
}>;
|
|
5693
5697
|
self: import("@trpc/server").TRPCQueryProcedure<{
|
|
5694
5698
|
input: {
|
|
5695
5699
|
t?: number | undefined;
|
|
@@ -5816,6 +5820,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
5816
5820
|
kind: "GROUP";
|
|
5817
5821
|
identityPubKey: string;
|
|
5818
5822
|
groupId: string;
|
|
5823
|
+
groupOwnerPubKey: string;
|
|
5819
5824
|
};
|
|
5820
5825
|
};
|
|
5821
5826
|
meta: any;
|
|
@@ -5834,6 +5839,7 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
5834
5839
|
kind: "GROUP";
|
|
5835
5840
|
identityPubKey: string;
|
|
5836
5841
|
groupId: string;
|
|
5842
|
+
groupOwnerPubKey: string;
|
|
5837
5843
|
})[];
|
|
5838
5844
|
};
|
|
5839
5845
|
meta: any;
|
|
@@ -5851,9 +5857,10 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
5851
5857
|
kind: "GROUP";
|
|
5852
5858
|
identityPubKey: string;
|
|
5853
5859
|
groupId: string;
|
|
5860
|
+
groupOwnerPubKey: string;
|
|
5854
5861
|
encPriv: string;
|
|
5855
5862
|
sharedByPubKey: string;
|
|
5856
|
-
|
|
5863
|
+
groupRole: "ADMIN" | "MEMBER";
|
|
5857
5864
|
})[];
|
|
5858
5865
|
};
|
|
5859
5866
|
meta: any;
|
|
@@ -6097,6 +6104,17 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
6097
6104
|
meta: any;
|
|
6098
6105
|
}>;
|
|
6099
6106
|
userPublicKey: import("@trpc/server").TRPCQueryProcedure<{
|
|
6107
|
+
input: {
|
|
6108
|
+
id: string;
|
|
6109
|
+
appId?: string | undefined;
|
|
6110
|
+
};
|
|
6111
|
+
output: {
|
|
6112
|
+
appId: string;
|
|
6113
|
+
publicKey: string;
|
|
6114
|
+
};
|
|
6115
|
+
meta: any;
|
|
6116
|
+
}>;
|
|
6117
|
+
usersPublicKey: import("@trpc/server").TRPCQueryProcedure<{
|
|
6100
6118
|
input: {
|
|
6101
6119
|
userId: string;
|
|
6102
6120
|
appId?: string | undefined;
|
|
@@ -10829,9 +10847,10 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
10829
10847
|
kind: "GROUP";
|
|
10830
10848
|
identityPubKey: string;
|
|
10831
10849
|
groupId: string;
|
|
10850
|
+
groupOwnerPubKey: string;
|
|
10832
10851
|
encPriv: string;
|
|
10833
10852
|
sharedByPubKey: string;
|
|
10834
|
-
|
|
10853
|
+
groupRole: "ADMIN" | "MEMBER";
|
|
10835
10854
|
})[];
|
|
10836
10855
|
};
|
|
10837
10856
|
meta: any;
|
|
@@ -10859,9 +10878,10 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
10859
10878
|
kind: "GROUP";
|
|
10860
10879
|
identityPubKey: string;
|
|
10861
10880
|
groupId: string;
|
|
10881
|
+
groupOwnerPubKey: string;
|
|
10862
10882
|
encPriv: string;
|
|
10863
10883
|
sharedByPubKey: string;
|
|
10864
|
-
|
|
10884
|
+
groupRole: "ADMIN" | "MEMBER";
|
|
10865
10885
|
})[] | null;
|
|
10866
10886
|
};
|
|
10867
10887
|
meta: any;
|
|
@@ -11534,15 +11554,6 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
11534
11554
|
};
|
|
11535
11555
|
meta: any;
|
|
11536
11556
|
}>;
|
|
11537
|
-
publicKey: import("@trpc/server").TRPCQueryProcedure<{
|
|
11538
|
-
input: {
|
|
11539
|
-
id: string;
|
|
11540
|
-
};
|
|
11541
|
-
output: {
|
|
11542
|
-
pub: string;
|
|
11543
|
-
};
|
|
11544
|
-
meta: any;
|
|
11545
|
-
}>;
|
|
11546
11557
|
self: import("@trpc/server").TRPCQueryProcedure<{
|
|
11547
11558
|
input: {
|
|
11548
11559
|
t?: number | undefined;
|
|
@@ -11669,6 +11680,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
11669
11680
|
kind: "GROUP";
|
|
11670
11681
|
identityPubKey: string;
|
|
11671
11682
|
groupId: string;
|
|
11683
|
+
groupOwnerPubKey: string;
|
|
11672
11684
|
};
|
|
11673
11685
|
};
|
|
11674
11686
|
meta: any;
|
|
@@ -11687,6 +11699,7 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
11687
11699
|
kind: "GROUP";
|
|
11688
11700
|
identityPubKey: string;
|
|
11689
11701
|
groupId: string;
|
|
11702
|
+
groupOwnerPubKey: string;
|
|
11690
11703
|
})[];
|
|
11691
11704
|
};
|
|
11692
11705
|
meta: any;
|
|
@@ -11704,9 +11717,10 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
11704
11717
|
kind: "GROUP";
|
|
11705
11718
|
identityPubKey: string;
|
|
11706
11719
|
groupId: string;
|
|
11720
|
+
groupOwnerPubKey: string;
|
|
11707
11721
|
encPriv: string;
|
|
11708
11722
|
sharedByPubKey: string;
|
|
11709
|
-
|
|
11723
|
+
groupRole: "ADMIN" | "MEMBER";
|
|
11710
11724
|
})[];
|
|
11711
11725
|
};
|
|
11712
11726
|
meta: any;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@secrecy/lib",
|
|
3
3
|
"author": "Anonymize <anonymize@gmail.com>",
|
|
4
4
|
"description": "Anonymize Secrecy Library",
|
|
5
|
-
"version": "1.75.0-feat-groups-identity.
|
|
5
|
+
"version": "1.75.0-feat-groups-identity.4",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/anonymize-org/lib.git"
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@js-temporal/polyfill": "^0.5.1",
|
|
79
|
-
"@secrecy/trpc-api-types": "1.33.0-feat-groups-identity.
|
|
79
|
+
"@secrecy/trpc-api-types": "1.33.0-feat-groups-identity.25",
|
|
80
80
|
"@trpc/client": "11.6.0",
|
|
81
81
|
"@trpc/server": "^11.6.0",
|
|
82
82
|
"@types/libsodium-wrappers-sumo": "^0.7.8",
|