@secrecy/lib 1.75.9 → 1.76.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,13 +1,32 @@
1
+ import { encryptCryptoBox, generateCryptoBoxKeyPair, sodium, } from '../index.js';
1
2
  export class SecrecyGroupClient {
2
3
  #client;
3
4
  constructor(client) {
4
5
  this.#client = client;
5
6
  }
6
7
  async addMember(input) {
7
- return this.#client.apiClient.group.addMember.mutate(input);
8
+ const groupIdentity = this.#client.groupIdentities.find((g) => g.groupId === input.id);
9
+ if (!groupIdentity) {
10
+ throw new Error('Group identity not found');
11
+ }
12
+ const opts = {
13
+ pubKey: input.pubKey,
14
+ role: input.role,
15
+ fromPubKey: this.#client.uaIdentity.identityPubKey,
16
+ id: input.id,
17
+ encPriv: sodium.to_hex(encryptCryptoBox(sodium.from_hex(groupIdentity.identityPubKey), input.pubKey, this.#client.uaPrivateKey)),
18
+ };
19
+ return this.#client.apiClient.group.addMember.mutate(opts);
8
20
  }
9
21
  async create(input) {
10
- return this.#client.apiClient.group.create.mutate(input);
22
+ const keyPair = generateCryptoBoxKeyPair();
23
+ const opts = {
24
+ name: input.name,
25
+ fromPubKey: this.#client.uaIdentity.identityPubKey,
26
+ pubKey: keyPair.publicKey,
27
+ encPriv: sodium.to_hex(encryptCryptoBox(sodium.from_hex(keyPair.privateKey), this.#client.uaIdentity.identityPubKey, this.#client.uaPrivateKey)),
28
+ };
29
+ return this.#client.apiClient.group.create.mutate(opts);
11
30
  }
12
31
  async deleteMember(input) {
13
32
  return this.#client.apiClient.group.deleteMember.mutate(input);
@@ -1,10 +1,10 @@
1
1
  import type { RouterInputs, RouterOutputs } from '../client.js';
2
- import type { SecrecyClient } from '../index.js';
2
+ import { type SecrecyClient } from '../index.js';
3
3
  export declare class SecrecyGroupClient {
4
4
  #private;
5
5
  constructor(client: SecrecyClient);
6
- addMember(input: RouterInputs['group']['addMember']): Promise<RouterOutputs['group']['addMember']>;
7
- create(input: RouterInputs['group']['create']): Promise<RouterOutputs['group']['create']>;
6
+ addMember(input: Pick<RouterInputs['group']['addMember'], 'pubKey' | 'role' | 'id'>): Promise<RouterOutputs['group']['addMember']>;
7
+ create(input: Pick<RouterInputs['group']['create'], 'name'>): Promise<RouterOutputs['group']['create']>;
8
8
  deleteMember(input: RouterInputs['group']['deleteMember']): Promise<RouterOutputs['group']['deleteMember']>;
9
9
  delete(input: RouterInputs['group']['delete']): Promise<RouterOutputs['group']['delete']>;
10
10
  get(input: RouterInputs['group']['get']): Promise<RouterOutputs['group']['get']>;
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.9",
5
+ "version": "1.76.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/anonymize-org/lib.git"