@secrecy/lib 1.74.0-feat-groups-identity.2 → 1.74.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.
@@ -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;
@@ -75,6 +89,14 @@ export class BaseClient {
75
89
  const user = await getPublicUser(this.client, userId);
76
90
  return user;
77
91
  }
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
+ }
78
100
  async searchUsers(search) {
79
101
  const users = await this.client.user.searchMany.query({
80
102
  search,
@@ -92,4 +92,7 @@ export class SecrecyClient extends BaseClient {
92
92
  publicKeysCache.clear();
93
93
  await super.logout(sessionId);
94
94
  }
95
+ async getIdentities(input) {
96
+ return await this.client.identity.getMany.query(input);
97
+ }
95
98
  }
@@ -23,6 +23,8 @@ export declare class BaseClient {
23
23
  me(): Promise<SelfUser>;
24
24
  static getUser(userId: string, opts?: CreateTrpcClientOptions): Promise<PublicUser>;
25
25
  getUser(userId: string): Promise<PublicUser>;
26
+ static getUsers(userIds: string[], opts?: CreateTrpcClientOptions): Promise<PublicUser[]>;
27
+ getUsers(userIds: string[]): Promise<PublicUser[]>;
26
28
  searchUsers(search: string): Promise<PublicUser[]>;
27
29
  updateProfile(data: RouterInputs['user']['updateProfile']): Promise<RouterOutputs['user']['updateProfile']>;
28
30
  static isCryptoTransactionDone({ idOrHash, network, opts, }: {
@@ -6,7 +6,7 @@ import { SecrecyAppClient } from './SecrecyAppClient.js';
6
6
  import { SecrecyDbClient } from './SecrecyDbClient.js';
7
7
  import { SecrecyWalletClient } from './SecrecyWalletClient.js';
8
8
  import { SecrecyPayClient } from './SecrecyPayClient.js';
9
- import { ApiClient, type RouterInputs } from '../client.js';
9
+ import { ApiClient, type RouterInputs, type RouterOutputs } from '../client.js';
10
10
  import { SecrecyUserClient } from './SecrecyUserClient.js';
11
11
  import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
12
12
  import { SecrecyOrganizationClient } from './SecrecyOrganizationClient.js';
@@ -42,4 +42,5 @@ export declare class SecrecyClient extends BaseClient {
42
42
  get uaIdentity(): Readonly<UserAppIdentity>;
43
43
  decryptAnonymous(data: Uint8Array): Uint8Array;
44
44
  logout(sessionId?: string | null | undefined): Promise<void>;
45
+ getIdentities(input: RouterInputs['identity']['getMany']): Promise<RouterOutputs['identity']['getMany']>;
45
46
  }
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.74.0-feat-groups-identity.2",
5
+ "version": "1.74.0-feat-groups-identity.4",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"