@secrecy/lib 1.75.0-feat-groups-identity.5 → 1.75.0-feat-groups-identity.6

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.
@@ -15,6 +15,9 @@ export class SecrecyAppClient {
15
15
  if (!sub) {
16
16
  throw new Error('No sub in JWT');
17
17
  }
18
+ if (sub !== this.#client.uaIdentity.userId) {
19
+ throw new Error(`UserId mismatch: ${sub} !== ${this.#client.uaIdentity.userId}`);
20
+ }
18
21
  return sub;
19
22
  }
20
23
  get appId() {
@@ -24,6 +27,9 @@ export class SecrecyAppClient {
24
27
  if (!aud) {
25
28
  throw new Error('No aud in JWT');
26
29
  }
30
+ if (aud !== this.#client.uaIdentity.appId) {
31
+ throw new Error(`AppId mismatch: ${aud} !== ${this.#client.uaIdentity.appId}`);
32
+ }
27
33
  return aud;
28
34
  }
29
35
  async getJwt() {
@@ -0,0 +1,33 @@
1
+ export class SecrecyGroupClient {
2
+ #client;
3
+ constructor(client) {
4
+ this.#client = client;
5
+ }
6
+ async addMember(input) {
7
+ return this.#client.apiClient.group.addMember.mutate(input);
8
+ }
9
+ async create(input) {
10
+ return this.#client.apiClient.group.create.mutate(input);
11
+ }
12
+ async deleteMember(input) {
13
+ return this.#client.apiClient.group.deleteMember.mutate(input);
14
+ }
15
+ async delete(input) {
16
+ return this.#client.apiClient.group.delete.mutate(input);
17
+ }
18
+ async get(input) {
19
+ return this.#client.apiClient.group.get.query(input);
20
+ }
21
+ async getMany(input) {
22
+ return this.#client.apiClient.group.getMany.query(input);
23
+ }
24
+ async transferOwnership(input) {
25
+ return this.#client.apiClient.group.transferOwnership.mutate(input);
26
+ }
27
+ async update(input) {
28
+ return this.#client.apiClient.group.update.mutate(input);
29
+ }
30
+ async updateMember(input) {
31
+ return this.#client.apiClient.group.updateMember.mutate(input);
32
+ }
33
+ }
@@ -0,0 +1,15 @@
1
+ export class SecrecyIdentityClient {
2
+ #client;
3
+ constructor(client) {
4
+ this.#client = client;
5
+ }
6
+ async get(input) {
7
+ return await this.#client.apiClient.identity.get.query(input);
8
+ }
9
+ async getMany(input) {
10
+ return await this.#client.apiClient.identity.getMany.query(input);
11
+ }
12
+ async list(input) {
13
+ return await this.#client.apiClient.identity.list.query(input);
14
+ }
15
+ }
@@ -79,19 +79,20 @@ export async function apiNodeFullToInternalFull(apiNodeFull, keyPairs) {
79
79
  function internalNodeToNode(internal) {
80
80
  const node = {
81
81
  ...internal,
82
- // breadcrumb: internal.breadcrumb.map((b) => ({
83
- // id: b.id,
84
- // name: b.name,
85
- // })),
86
- // access: {
87
- // isRoot: internal.access.isRoot,
88
- // sharedByPubKey: internal.access.sharedByPubKey,
89
- // rights: internal.access.rights,
90
- // addAccess: internal.access.addAccess,
91
- // delAccess: internal.access.delAccess,
92
- // sharingAddAccess: internal.access.sharingAddAccess,
93
- // sharingDelAccess: internal.access.sharingDelAccess,
94
- // },
82
+ breadcrumb: internal.breadcrumb.map((b) => ({
83
+ id: b.id,
84
+ name: b.name,
85
+ })),
86
+ accesses: internal.accesses.map((a) => ({
87
+ isRoot: a.isRoot,
88
+ identityPubKey: a.identityPubKey,
89
+ sharedByPubKey: a.sharedByPubKey,
90
+ rights: a.rights,
91
+ addAccess: a.addAccess,
92
+ delAccess: a.delAccess,
93
+ sharingAddAccess: a.sharingAddAccess,
94
+ sharingDelAccess: a.sharingDelAccess,
95
+ })),
95
96
  };
96
97
  return node;
97
98
  }
@@ -10,6 +10,8 @@ import { SecrecyUserClient } from './SecrecyUserClient.js';
10
10
  import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
11
11
  import { decryptAnonymous } from '../crypto/index.js';
12
12
  import { SecrecyOrganizationClient } from './SecrecyOrganizationClient.js';
13
+ import { SecrecyGroupClient } from './SecrecyGroupClient.js';
14
+ import { SecrecyIdentityClient } from './SecrecyIdentityClient.js';
13
15
  export class SecrecyClient extends BaseClient {
14
16
  #groupIdentities;
15
17
  #uaIdentity;
@@ -23,6 +25,8 @@ export class SecrecyClient extends BaseClient {
23
25
  pay;
24
26
  user;
25
27
  pseudonym;
28
+ group;
29
+ identity;
26
30
  constructor(opts) {
27
31
  super({
28
32
  session: opts.uaSession,
@@ -54,6 +58,8 @@ export class SecrecyClient extends BaseClient {
54
58
  this.pay = new SecrecyPayClient(this);
55
59
  this.user = new SecrecyUserClient(this);
56
60
  this.pseudonym = new SecrecyPseudonymClient(this);
61
+ this.group = new SecrecyGroupClient(this);
62
+ this.identity = new SecrecyIdentityClient(this);
57
63
  }
58
64
  get publicKey() {
59
65
  return this.#uaIdentity.identityPubKey;
@@ -92,7 +98,4 @@ export class SecrecyClient extends BaseClient {
92
98
  publicKeysCache.clear();
93
99
  await super.logout(sessionId);
94
100
  }
95
- async getIdentities(input) {
96
- return await this.client.identity.getMany.query(input);
97
- }
98
101
  }
@@ -0,0 +1,15 @@
1
+ import type { RouterInputs, RouterOutputs } from '../client.js';
2
+ import type { SecrecyClient } from '../index.js';
3
+ export declare class SecrecyGroupClient {
4
+ #private;
5
+ constructor(client: SecrecyClient);
6
+ addMember(input: RouterInputs['group']['addMember']): Promise<RouterOutputs['group']['addMember']>;
7
+ create(input: RouterInputs['group']['create']): Promise<RouterOutputs['group']['create']>;
8
+ deleteMember(input: RouterInputs['group']['deleteMember']): Promise<RouterOutputs['group']['deleteMember']>;
9
+ delete(input: RouterInputs['group']['delete']): Promise<RouterOutputs['group']['delete']>;
10
+ get(input: RouterInputs['group']['get']): Promise<RouterOutputs['group']['get']>;
11
+ getMany(input: RouterInputs['group']['getMany']): Promise<RouterOutputs['group']['getMany']>;
12
+ transferOwnership(input: RouterInputs['group']['transferOwnership']): Promise<RouterOutputs['group']['transferOwnership']>;
13
+ update(input: RouterInputs['group']['update']): Promise<RouterOutputs['group']['update']>;
14
+ updateMember(input: RouterInputs['group']['updateMember']): Promise<RouterOutputs['group']['updateMember']>;
15
+ }
@@ -0,0 +1,9 @@
1
+ import type { RouterInputs, RouterOutputs } from '../client.js';
2
+ import type { SecrecyClient } from '../index.js';
3
+ export declare class SecrecyIdentityClient {
4
+ #private;
5
+ constructor(client: SecrecyClient);
6
+ get(input: RouterInputs['identity']['get']): Promise<RouterOutputs['identity']['get']>;
7
+ getMany(input: RouterInputs['identity']['getMany']): Promise<RouterOutputs['identity']['getMany']>;
8
+ list(input: RouterInputs['identity']['list']): Promise<RouterOutputs['identity']['list']>;
9
+ }
@@ -6,11 +6,13 @@ 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 { type ApiClient, type RouterInputs, type RouterOutputs } from '../client.js';
9
+ import { type ApiClient, type RouterInputs } from '../client.js';
10
10
  import { SecrecyUserClient } from './SecrecyUserClient.js';
11
11
  import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
12
12
  import { SecrecyOrganizationClient } from './SecrecyOrganizationClient.js';
13
13
  import type { AccessIdentity, GroupIdentity, UserAppIdentity } from './types/identity.js';
14
+ import { SecrecyGroupClient } from './SecrecyGroupClient.js';
15
+ import { SecrecyIdentityClient } from './SecrecyIdentityClient.js';
14
16
  export type NewMail = Pick<RouterInputs['mail']['createDraft'], 'body' | 'subject' | 'senderFiles' | 'recipients' | 'replyToId'>;
15
17
  export type ProgressCallback = (progress: SecretStreamProgress) => Promise<void>;
16
18
  export interface SecrecyClientOptions {
@@ -32,6 +34,8 @@ export declare class SecrecyClient extends BaseClient {
32
34
  pay: SecrecyPayClient;
33
35
  user: SecrecyUserClient;
34
36
  pseudonym: SecrecyPseudonymClient;
37
+ group: SecrecyGroupClient;
38
+ identity: SecrecyIdentityClient;
35
39
  constructor(opts: SecrecyClientOptions);
36
40
  get publicKey(): string;
37
41
  get apiClient(): Readonly<ApiClient>;
@@ -42,5 +46,4 @@ export declare class SecrecyClient extends BaseClient {
42
46
  get uaIdentity(): Readonly<UserAppIdentity>;
43
47
  decryptAnonymous(data: Uint8Array): Uint8Array;
44
48
  logout(sessionId?: string | null | undefined): Promise<void>;
45
- getIdentities(input: RouterInputs['identity']['getMany']): Promise<RouterOutputs['identity']['getMany']>;
46
49
  }
@@ -5866,6 +5866,178 @@ export declare const createTRPCClient: (opts: CreateTrpcClientOptions) => import
5866
5866
  meta: any;
5867
5867
  }>;
5868
5868
  }>;
5869
+ group: import("@trpc/server").TRPCDecorateCreateRouterOptions<{
5870
+ addMember: import("@trpc/server").TRPCMutationProcedure<{
5871
+ input: {
5872
+ fromPubKey: string;
5873
+ id: string;
5874
+ encPriv: string;
5875
+ pubKey: string;
5876
+ role?: "ADMIN" | "MEMBER" | undefined;
5877
+ };
5878
+ output: {
5879
+ member: {
5880
+ createdAt: Date;
5881
+ role: "ADMIN" | "MEMBER";
5882
+ groupId: string;
5883
+ identityPubKey: string;
5884
+ sharedByPubKey: string;
5885
+ encPriv: string;
5886
+ initiatorAppId: string;
5887
+ initiatorUserId: string;
5888
+ };
5889
+ };
5890
+ meta: any;
5891
+ }>;
5892
+ create: import("@trpc/server").TRPCMutationProcedure<{
5893
+ input: {
5894
+ fromPubKey: string;
5895
+ name: string;
5896
+ encPriv: string;
5897
+ pubKey: string;
5898
+ };
5899
+ output: {
5900
+ group: {
5901
+ id: string;
5902
+ createdAt: Date;
5903
+ name: string;
5904
+ updatedAt: Date;
5905
+ identityPubKey: string;
5906
+ ownerPubKey: string;
5907
+ organizationId: string | null;
5908
+ applicationId: string | null;
5909
+ initiatorAppId: string;
5910
+ initiatorUserId: string;
5911
+ };
5912
+ };
5913
+ meta: any;
5914
+ }>;
5915
+ deleteMember: import("@trpc/server").TRPCMutationProcedure<{
5916
+ input: {
5917
+ id: string;
5918
+ pubKey: string;
5919
+ };
5920
+ output: {
5921
+ member: {
5922
+ createdAt: Date;
5923
+ role: "ADMIN" | "MEMBER";
5924
+ groupId: string;
5925
+ identityPubKey: string;
5926
+ sharedByPubKey: string;
5927
+ encPriv: string;
5928
+ initiatorAppId: string;
5929
+ initiatorUserId: string;
5930
+ };
5931
+ };
5932
+ meta: any;
5933
+ }>;
5934
+ delete: import("@trpc/server").TRPCMutationProcedure<{
5935
+ input: {
5936
+ id: string;
5937
+ };
5938
+ output: {
5939
+ group: {
5940
+ id: string;
5941
+ createdAt: Date;
5942
+ name: string;
5943
+ updatedAt: Date;
5944
+ identityPubKey: string;
5945
+ ownerPubKey: string;
5946
+ organizationId: string | null;
5947
+ applicationId: string | null;
5948
+ initiatorAppId: string;
5949
+ initiatorUserId: string;
5950
+ };
5951
+ };
5952
+ meta: any;
5953
+ }>;
5954
+ get: import("@trpc/server").TRPCQueryProcedure<{
5955
+ input: {
5956
+ id: string;
5957
+ };
5958
+ output: {
5959
+ group: {
5960
+ id: string;
5961
+ name: string;
5962
+ };
5963
+ };
5964
+ meta: any;
5965
+ }>;
5966
+ getMany: import("@trpc/server").TRPCQueryProcedure<{
5967
+ input: {
5968
+ ids: string[];
5969
+ };
5970
+ output: {
5971
+ groups: {
5972
+ id: string;
5973
+ name: string;
5974
+ }[];
5975
+ };
5976
+ meta: any;
5977
+ }>;
5978
+ transferOwnership: import("@trpc/server").TRPCMutationProcedure<{
5979
+ input: {
5980
+ id: string;
5981
+ pubKey: string;
5982
+ };
5983
+ output: {
5984
+ group: {
5985
+ id: string;
5986
+ createdAt: Date;
5987
+ name: string;
5988
+ updatedAt: Date;
5989
+ identityPubKey: string;
5990
+ ownerPubKey: string;
5991
+ organizationId: string | null;
5992
+ applicationId: string | null;
5993
+ initiatorAppId: string;
5994
+ initiatorUserId: string;
5995
+ };
5996
+ };
5997
+ meta: any;
5998
+ }>;
5999
+ updateMember: import("@trpc/server").TRPCMutationProcedure<{
6000
+ input: {
6001
+ id: string;
6002
+ pubKey: string;
6003
+ role: "ADMIN" | "MEMBER";
6004
+ };
6005
+ output: {
6006
+ member: {
6007
+ createdAt: Date;
6008
+ role: "ADMIN" | "MEMBER";
6009
+ groupId: string;
6010
+ identityPubKey: string;
6011
+ sharedByPubKey: string;
6012
+ encPriv: string;
6013
+ initiatorAppId: string;
6014
+ initiatorUserId: string;
6015
+ };
6016
+ };
6017
+ meta: any;
6018
+ }>;
6019
+ update: import("@trpc/server").TRPCMutationProcedure<{
6020
+ input: {
6021
+ id: string;
6022
+ name: string;
6023
+ };
6024
+ output: {
6025
+ group: {
6026
+ id: string;
6027
+ createdAt: Date;
6028
+ name: string;
6029
+ updatedAt: Date;
6030
+ identityPubKey: string;
6031
+ ownerPubKey: string;
6032
+ organizationId: string | null;
6033
+ applicationId: string | null;
6034
+ initiatorAppId: string;
6035
+ initiatorUserId: string;
6036
+ };
6037
+ };
6038
+ meta: any;
6039
+ }>;
6040
+ }>;
5869
6041
  }>>;
5870
6042
  export declare const getTrpcGuestClient: ({ url }?: {
5871
6043
  url?: string;
@@ -11726,5 +11898,177 @@ export declare const getTrpcGuestClient: ({ url }?: {
11726
11898
  meta: any;
11727
11899
  }>;
11728
11900
  }>;
11901
+ group: import("@trpc/server").TRPCDecorateCreateRouterOptions<{
11902
+ addMember: import("@trpc/server").TRPCMutationProcedure<{
11903
+ input: {
11904
+ fromPubKey: string;
11905
+ id: string;
11906
+ encPriv: string;
11907
+ pubKey: string;
11908
+ role?: "ADMIN" | "MEMBER" | undefined;
11909
+ };
11910
+ output: {
11911
+ member: {
11912
+ createdAt: Date;
11913
+ role: "ADMIN" | "MEMBER";
11914
+ groupId: string;
11915
+ identityPubKey: string;
11916
+ sharedByPubKey: string;
11917
+ encPriv: string;
11918
+ initiatorAppId: string;
11919
+ initiatorUserId: string;
11920
+ };
11921
+ };
11922
+ meta: any;
11923
+ }>;
11924
+ create: import("@trpc/server").TRPCMutationProcedure<{
11925
+ input: {
11926
+ fromPubKey: string;
11927
+ name: string;
11928
+ encPriv: string;
11929
+ pubKey: string;
11930
+ };
11931
+ output: {
11932
+ group: {
11933
+ id: string;
11934
+ createdAt: Date;
11935
+ name: string;
11936
+ updatedAt: Date;
11937
+ identityPubKey: string;
11938
+ ownerPubKey: string;
11939
+ organizationId: string | null;
11940
+ applicationId: string | null;
11941
+ initiatorAppId: string;
11942
+ initiatorUserId: string;
11943
+ };
11944
+ };
11945
+ meta: any;
11946
+ }>;
11947
+ deleteMember: import("@trpc/server").TRPCMutationProcedure<{
11948
+ input: {
11949
+ id: string;
11950
+ pubKey: string;
11951
+ };
11952
+ output: {
11953
+ member: {
11954
+ createdAt: Date;
11955
+ role: "ADMIN" | "MEMBER";
11956
+ groupId: string;
11957
+ identityPubKey: string;
11958
+ sharedByPubKey: string;
11959
+ encPriv: string;
11960
+ initiatorAppId: string;
11961
+ initiatorUserId: string;
11962
+ };
11963
+ };
11964
+ meta: any;
11965
+ }>;
11966
+ delete: import("@trpc/server").TRPCMutationProcedure<{
11967
+ input: {
11968
+ id: string;
11969
+ };
11970
+ output: {
11971
+ group: {
11972
+ id: string;
11973
+ createdAt: Date;
11974
+ name: string;
11975
+ updatedAt: Date;
11976
+ identityPubKey: string;
11977
+ ownerPubKey: string;
11978
+ organizationId: string | null;
11979
+ applicationId: string | null;
11980
+ initiatorAppId: string;
11981
+ initiatorUserId: string;
11982
+ };
11983
+ };
11984
+ meta: any;
11985
+ }>;
11986
+ get: import("@trpc/server").TRPCQueryProcedure<{
11987
+ input: {
11988
+ id: string;
11989
+ };
11990
+ output: {
11991
+ group: {
11992
+ id: string;
11993
+ name: string;
11994
+ };
11995
+ };
11996
+ meta: any;
11997
+ }>;
11998
+ getMany: import("@trpc/server").TRPCQueryProcedure<{
11999
+ input: {
12000
+ ids: string[];
12001
+ };
12002
+ output: {
12003
+ groups: {
12004
+ id: string;
12005
+ name: string;
12006
+ }[];
12007
+ };
12008
+ meta: any;
12009
+ }>;
12010
+ transferOwnership: import("@trpc/server").TRPCMutationProcedure<{
12011
+ input: {
12012
+ id: string;
12013
+ pubKey: string;
12014
+ };
12015
+ output: {
12016
+ group: {
12017
+ id: string;
12018
+ createdAt: Date;
12019
+ name: string;
12020
+ updatedAt: Date;
12021
+ identityPubKey: string;
12022
+ ownerPubKey: string;
12023
+ organizationId: string | null;
12024
+ applicationId: string | null;
12025
+ initiatorAppId: string;
12026
+ initiatorUserId: string;
12027
+ };
12028
+ };
12029
+ meta: any;
12030
+ }>;
12031
+ updateMember: import("@trpc/server").TRPCMutationProcedure<{
12032
+ input: {
12033
+ id: string;
12034
+ pubKey: string;
12035
+ role: "ADMIN" | "MEMBER";
12036
+ };
12037
+ output: {
12038
+ member: {
12039
+ createdAt: Date;
12040
+ role: "ADMIN" | "MEMBER";
12041
+ groupId: string;
12042
+ identityPubKey: string;
12043
+ sharedByPubKey: string;
12044
+ encPriv: string;
12045
+ initiatorAppId: string;
12046
+ initiatorUserId: string;
12047
+ };
12048
+ };
12049
+ meta: any;
12050
+ }>;
12051
+ update: import("@trpc/server").TRPCMutationProcedure<{
12052
+ input: {
12053
+ id: string;
12054
+ name: string;
12055
+ };
12056
+ output: {
12057
+ group: {
12058
+ id: string;
12059
+ createdAt: Date;
12060
+ name: string;
12061
+ updatedAt: Date;
12062
+ identityPubKey: string;
12063
+ ownerPubKey: string;
12064
+ organizationId: string | null;
12065
+ applicationId: string | null;
12066
+ initiatorAppId: string;
12067
+ initiatorUserId: string;
12068
+ };
12069
+ };
12070
+ meta: any;
12071
+ }>;
12072
+ }>;
11729
12073
  }>>;
11730
12074
  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.75.0-feat-groups-identity.5",
5
+ "version": "1.75.0-feat-groups-identity.6",
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.25",
79
+ "@secrecy/trpc-api-types": "1.33.0-feat-groups-identity.31",
80
80
  "@trpc/client": "11.6.0",
81
81
  "@trpc/server": "^11.6.0",
82
82
  "@types/libsodium-wrappers-sumo": "^0.7.8",