@secrecy/lib 1.7.0-integration-trpc-client.38 → 1.7.0-integration-trpc-client.39

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.
@@ -35,11 +35,11 @@ export class BaseClient {
35
35
  async me() {
36
36
  return await this.client.user.self.query({});
37
37
  }
38
- static async user(userId, sessionId) {
38
+ static async getUser(userId, sessionId) {
39
39
  const user = await getPublicUser(this.getBaseClient(sessionId), userId);
40
40
  return user;
41
41
  }
42
- async user(userId) {
42
+ async getUser(userId) {
43
43
  const user = await getPublicUser(this.client, userId);
44
44
  return user;
45
45
  }
@@ -0,0 +1,27 @@
1
+ export class SecrecyUserClient {
2
+ #apiClient;
3
+ constructor(_client, _keys, apiClient) {
4
+ this.#apiClient = apiClient;
5
+ }
6
+ async answerInvitation(input) {
7
+ return await this.#apiClient.contacts.answerInvitation.mutate(input);
8
+ }
9
+ async cancelInvitation(input) {
10
+ return await this.#apiClient.contacts.cancelInvitation.mutate(input);
11
+ }
12
+ async createInvitation(input) {
13
+ return await this.#apiClient.contacts.createInvitation.mutate(input);
14
+ }
15
+ async getContacts(input) {
16
+ return await this.#apiClient.contacts.getContacts.query(input);
17
+ }
18
+ async getReceivedInvitations(input) {
19
+ return await this.#apiClient.contacts.getReceivedInvitations.query(input);
20
+ }
21
+ async getSentInvitations(input) {
22
+ return await this.#apiClient.contacts.getSentInvitations.query(input);
23
+ }
24
+ async removeContact(input) {
25
+ return await this.#apiClient.contacts.removeContact.mutate(input);
26
+ }
27
+ }
@@ -8,6 +8,7 @@ import { nodesCache, filesCache, publicKeysCache } from '../cache.js';
8
8
  import { SecrecyDbClient } from './SecrecyDbClient.js';
9
9
  import { SecrecyWalletClient } from './SecrecyWalletClient.js';
10
10
  import { SecrecyPayClient } from './SecrecyPayClient.js';
11
+ import { SecrecyUserClient } from './SecrecyUserClient.js';
11
12
  export const encryptName = async (name, nameKey) => {
12
13
  const { data } = await encryptSecretstream(sodium.from_hex(nameKey), sodium.from_string(name));
13
14
  const nameEncrypted = sodium.to_hex(data);
@@ -21,6 +22,7 @@ export class SecrecyClient extends BaseClient {
21
22
  db;
22
23
  wallet;
23
24
  pay;
25
+ user;
24
26
  constructor(uaSession, uaKeys, uaJwt) {
25
27
  super(uaSession);
26
28
  this.#keys = uaKeys;
@@ -30,6 +32,7 @@ export class SecrecyClient extends BaseClient {
30
32
  this.db = new SecrecyDbClient(this, this.#keys, this.client);
31
33
  this.wallet = new SecrecyWalletClient(this);
32
34
  this.pay = new SecrecyPayClient(this, this.#keys, this.client);
35
+ this.user = new SecrecyUserClient(this, this.#keys, this.client);
33
36
  }
34
37
  get publicKey() {
35
38
  return this.#keys.publicKey;
@@ -9,8 +9,8 @@ export declare class BaseClient {
9
9
  constructor(session: string);
10
10
  logout(sessionId?: string | null | undefined): Promise<void>;
11
11
  me(): Promise<SelfUser>;
12
- static user(userId: string, sessionId?: string | null | undefined): Promise<PublicUser>;
13
- user(userId: string): Promise<PublicUser>;
12
+ static getUser(userId: string, sessionId?: string | null | undefined): Promise<PublicUser>;
13
+ getUser(userId: string): Promise<PublicUser>;
14
14
  searchUsers(search: string): Promise<PublicUser[]>;
15
15
  updateProfile(data: RouterInputs['user']['updateProfile']): Promise<SelfUser>;
16
16
  static isCryptoTransactionDone({ idOrHash, network, }: {
@@ -0,0 +1,14 @@
1
+ import type { RouterInputs, ApiClient, RouterOutputs } from '../client.js';
2
+ import type { SecrecyClient } from '../index.js';
3
+ import type { KeyPair } from './types/index.js';
4
+ export declare class SecrecyUserClient {
5
+ #private;
6
+ constructor(_client: SecrecyClient, _keys: KeyPair, apiClient: ApiClient);
7
+ answerInvitation(input: RouterInputs['contacts']['answerInvitation']): Promise<RouterOutputs['contacts']['answerInvitation']>;
8
+ cancelInvitation(input: RouterInputs['contacts']['cancelInvitation']): Promise<RouterOutputs['contacts']['cancelInvitation']>;
9
+ createInvitation(input: RouterInputs['contacts']['createInvitation']): Promise<RouterOutputs['contacts']['createInvitation']>;
10
+ getContacts(input: RouterInputs['contacts']['getContacts']): Promise<RouterOutputs['contacts']['getContacts']>;
11
+ getReceivedInvitations(input: RouterInputs['contacts']['getReceivedInvitations']): Promise<RouterOutputs['contacts']['getReceivedInvitations']>;
12
+ getSentInvitations(input: RouterInputs['contacts']['getSentInvitations']): Promise<RouterOutputs['contacts']['getSentInvitations']>;
13
+ removeContact(input: RouterInputs['contacts']['removeContact']): Promise<RouterOutputs['contacts']['removeContact']>;
14
+ }
@@ -8,6 +8,7 @@ import { SecrecyWalletClient } from './SecrecyWalletClient.js';
8
8
  import { SecrecyPayClient } from './SecrecyPayClient.js';
9
9
  import { type RouterInputs } from '../client.js';
10
10
  import { type KeyPair } from './types/index.js';
11
+ import { SecrecyUserClient } from './SecrecyUserClient.js';
11
12
  export type NewMail = Pick<RouterInputs['mail']['createDraft'], 'body' | 'subject' | 'senderFiles' | 'recipients' | 'replyToId'>;
12
13
  export type ProgressCallback = (progress: Progress) => Promise<void>;
13
14
  export declare const encryptName: (name: string, nameKey: string) => Promise<string>;
@@ -19,6 +20,7 @@ export declare class SecrecyClient extends BaseClient {
19
20
  db: SecrecyDbClient;
20
21
  wallet: SecrecyWalletClient;
21
22
  pay: SecrecyPayClient;
23
+ user: SecrecyUserClient;
22
24
  constructor(uaSession: string, uaKeys: KeyPair, uaJwt: string);
23
25
  get publicKey(): string;
24
26
  logout(sessionId?: string | null | undefined): Promise<void>;
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.7.0-integration-trpc-client.38",
5
+ "version": "1.7.0-integration-trpc-client.39",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"