@secrecy/lib 1.80.0 → 1.82.0
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { publicKeysCache } from '../cache.js';
|
|
1
2
|
import { encryptCryptoBox, generateCryptoBoxKeyPair, sodium, } from '../index.js';
|
|
2
3
|
export class SecrecyGroupClient {
|
|
3
4
|
#client;
|
|
@@ -57,4 +58,35 @@ export class SecrecyGroupClient {
|
|
|
57
58
|
async updateMember(input) {
|
|
58
59
|
return this.#client.apiClient.group.updateMember.mutate(input);
|
|
59
60
|
}
|
|
61
|
+
async publicKeys(input) {
|
|
62
|
+
const groupIds = Array.isArray(input) ? input : [input];
|
|
63
|
+
if (groupIds.length === 0) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
const publicKeys = Object.fromEntries(groupIds
|
|
67
|
+
.map((groupId) => [
|
|
68
|
+
groupId,
|
|
69
|
+
publicKeysCache.get(`groupPublicKey:${groupId}`),
|
|
70
|
+
])
|
|
71
|
+
.filter(([_, key]) => key !== undefined));
|
|
72
|
+
const missingKeys = [
|
|
73
|
+
...new Set(groupIds.filter((groupId) => publicKeys[groupId] === undefined)),
|
|
74
|
+
];
|
|
75
|
+
if (missingKeys.length > 0) {
|
|
76
|
+
const groupKeysMap = await this.#client.apiClient.group.publicKeys.query({
|
|
77
|
+
groupIds: missingKeys,
|
|
78
|
+
});
|
|
79
|
+
if ('publicKey' in groupKeysMap) {
|
|
80
|
+
throw Error('Should not happen!');
|
|
81
|
+
}
|
|
82
|
+
if (Object.keys(groupKeysMap.publicKeys).length !== missingKeys.length) {
|
|
83
|
+
throw new Error("Unable to load some user's public keys!");
|
|
84
|
+
}
|
|
85
|
+
for (const [groupId, publicKey] of Object.entries(groupKeysMap.publicKeys)) {
|
|
86
|
+
publicKeys[groupId] = publicKey;
|
|
87
|
+
publicKeysCache.set(`groupPublicKey:${groupId}`, publicKey);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return publicKeys;
|
|
91
|
+
}
|
|
60
92
|
}
|
|
@@ -12,4 +12,5 @@ export declare class SecrecyGroupClient {
|
|
|
12
12
|
transferOwnership(input: RouterInputs['group']['transferOwnership']): Promise<RouterOutputs['group']['transferOwnership']>;
|
|
13
13
|
update(input: RouterInputs['group']['update']): Promise<RouterOutputs['group']['update']>;
|
|
14
14
|
updateMember(input: RouterInputs['group']['updateMember']): Promise<RouterOutputs['group']['updateMember']>;
|
|
15
|
+
publicKeys(input: string[]): Promise<Record<string, string>>;
|
|
15
16
|
}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -6278,6 +6278,10 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
6278
6278
|
id: string;
|
|
6279
6279
|
identityPubKey: string;
|
|
6280
6280
|
name: string;
|
|
6281
|
+
members: {
|
|
6282
|
+
identityPubKey: string;
|
|
6283
|
+
role: "ADMIN" | "MEMBER";
|
|
6284
|
+
}[];
|
|
6281
6285
|
};
|
|
6282
6286
|
};
|
|
6283
6287
|
meta: any;
|
|
@@ -6291,6 +6295,10 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
6291
6295
|
id: string;
|
|
6292
6296
|
identityPubKey: string;
|
|
6293
6297
|
name: string;
|
|
6298
|
+
members: {
|
|
6299
|
+
identityPubKey: string;
|
|
6300
|
+
role: "ADMIN" | "MEMBER";
|
|
6301
|
+
}[];
|
|
6294
6302
|
}[];
|
|
6295
6303
|
};
|
|
6296
6304
|
meta: any;
|
|
@@ -6359,6 +6367,19 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
|
|
|
6359
6367
|
};
|
|
6360
6368
|
meta: any;
|
|
6361
6369
|
}>;
|
|
6370
|
+
publicKeys: import("@trpc/server").TRPCQueryProcedure<{
|
|
6371
|
+
input: {
|
|
6372
|
+
groupId: string;
|
|
6373
|
+
} | {
|
|
6374
|
+
groupIds: string[];
|
|
6375
|
+
};
|
|
6376
|
+
output: {
|
|
6377
|
+
publicKey: string;
|
|
6378
|
+
} | {
|
|
6379
|
+
publicKeys: Record<string, string>;
|
|
6380
|
+
};
|
|
6381
|
+
meta: any;
|
|
6382
|
+
}>;
|
|
6362
6383
|
}>;
|
|
6363
6384
|
}>>;
|
|
6364
6385
|
export declare const getTrpcGuestClient: ({ url }?: {
|
|
@@ -12632,6 +12653,10 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
12632
12653
|
id: string;
|
|
12633
12654
|
identityPubKey: string;
|
|
12634
12655
|
name: string;
|
|
12656
|
+
members: {
|
|
12657
|
+
identityPubKey: string;
|
|
12658
|
+
role: "ADMIN" | "MEMBER";
|
|
12659
|
+
}[];
|
|
12635
12660
|
};
|
|
12636
12661
|
};
|
|
12637
12662
|
meta: any;
|
|
@@ -12645,6 +12670,10 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
12645
12670
|
id: string;
|
|
12646
12671
|
identityPubKey: string;
|
|
12647
12672
|
name: string;
|
|
12673
|
+
members: {
|
|
12674
|
+
identityPubKey: string;
|
|
12675
|
+
role: "ADMIN" | "MEMBER";
|
|
12676
|
+
}[];
|
|
12648
12677
|
}[];
|
|
12649
12678
|
};
|
|
12650
12679
|
meta: any;
|
|
@@ -12713,6 +12742,19 @@ export declare const getTrpcGuestClient: ({ url }?: {
|
|
|
12713
12742
|
};
|
|
12714
12743
|
meta: any;
|
|
12715
12744
|
}>;
|
|
12745
|
+
publicKeys: import("@trpc/server").TRPCQueryProcedure<{
|
|
12746
|
+
input: {
|
|
12747
|
+
groupId: string;
|
|
12748
|
+
} | {
|
|
12749
|
+
groupIds: string[];
|
|
12750
|
+
};
|
|
12751
|
+
output: {
|
|
12752
|
+
publicKey: string;
|
|
12753
|
+
} | {
|
|
12754
|
+
publicKeys: Record<string, string>;
|
|
12755
|
+
};
|
|
12756
|
+
meta: any;
|
|
12757
|
+
}>;
|
|
12716
12758
|
}>;
|
|
12717
12759
|
}>>;
|
|
12718
12760
|
export type ApiClient = ReturnType<typeof createTRPCClient>;
|
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.
|
|
5
|
+
"version": "1.82.0",
|
|
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.
|
|
79
|
+
"@secrecy/trpc-api-types": "1.37.0-dev.1",
|
|
80
80
|
"@trpc/client": "11.6.0",
|
|
81
81
|
"@trpc/server": "^11.6.0",
|
|
82
82
|
"@types/libsodium-wrappers-sumo": "^0.7.8",
|