@secrecy/lib 1.73.6 → 1.74.0-feat-groups-identity.1
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.
- package/dist/lib/base-client.js +5 -3
- package/dist/lib/client/SecrecyAppClient.js +13 -17
- package/dist/lib/client/SecrecyCloudClient.js +129 -137
- package/dist/lib/client/SecrecyDbClient.js +3 -7
- package/dist/lib/client/SecrecyMailClient.js +38 -48
- package/dist/lib/client/SecrecyOrganizationClient.js +10 -12
- package/dist/lib/client/SecrecyPayClient.js +1 -5
- package/dist/lib/client/SecrecyPseudonymClient.js +4 -8
- package/dist/lib/client/SecrecyUserClient.js +11 -11
- package/dist/lib/client/SecrecyWalletClient.js +0 -2
- package/dist/lib/client/convert/data.js +4 -4
- package/dist/lib/client/convert/mail.js +5 -6
- package/dist/lib/client/convert/node.js +46 -34
- package/dist/lib/client/helpers.js +17 -11
- package/dist/lib/client/index.js +45 -12
- package/dist/lib/client/storage.js +3 -2
- package/dist/lib/client/types/identity.js +18 -0
- package/dist/lib/client/types/index.js +3 -7
- package/dist/lib/index.js +1 -0
- package/dist/types/client/SecrecyAppClient.d.ts +2 -3
- package/dist/types/client/SecrecyCloudClient.d.ts +18 -18
- package/dist/types/client/SecrecyDbClient.d.ts +1 -3
- package/dist/types/client/SecrecyMailClient.d.ts +2 -3
- package/dist/types/client/SecrecyOrganizationClient.d.ts +2 -3
- package/dist/types/client/SecrecyPayClient.d.ts +1 -3
- package/dist/types/client/SecrecyPseudonymClient.d.ts +2 -3
- package/dist/types/client/SecrecyUserClient.d.ts +2 -3
- package/dist/types/client/convert/data.d.ts +3 -3
- package/dist/types/client/convert/mail.d.ts +3 -5
- package/dist/types/client/convert/node.d.ts +5 -5
- package/dist/types/client/index.d.ts +9 -2
- package/dist/types/client/storage.d.ts +3 -2
- package/dist/types/client/types/identity.d.ts +29 -0
- package/dist/types/client/types/index.d.ts +13 -9
- package/dist/types/client/types/mail.d.ts +2 -1
- package/dist/types/client/types/node.d.ts +12 -9
- package/dist/types/client/types/user.d.ts +15 -0
- package/dist/types/client.d.ts +679 -513
- package/dist/types/crypto/index.d.ts +3 -3
- package/dist/types/index.d.ts +2 -1
- package/package.json +2 -2
package/dist/lib/client/index.js
CHANGED
|
@@ -11,7 +11,9 @@ import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
|
|
|
11
11
|
import { decryptAnonymous } from '../crypto/index.js';
|
|
12
12
|
import { SecrecyOrganizationClient } from './SecrecyOrganizationClient.js';
|
|
13
13
|
export class SecrecyClient extends BaseClient {
|
|
14
|
-
#
|
|
14
|
+
#groupIdentities;
|
|
15
|
+
#uaIdentity;
|
|
16
|
+
#keyPairs;
|
|
15
17
|
cloud;
|
|
16
18
|
mail;
|
|
17
19
|
app;
|
|
@@ -36,22 +38,53 @@ export class SecrecyClient extends BaseClient {
|
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
40
|
});
|
|
39
|
-
this.#
|
|
40
|
-
this
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
this.#keyPairs = opts.keyPairs;
|
|
42
|
+
this.#groupIdentities = opts.identities.filter((i) => i.kind === 'GROUP');
|
|
43
|
+
const uaIdentities = opts.identities.filter((i) => i.kind === 'USER_APP');
|
|
44
|
+
if (uaIdentities.length !== 1) {
|
|
45
|
+
throw new Error('One USER_APP identity is required');
|
|
46
|
+
}
|
|
47
|
+
this.#uaIdentity = uaIdentities[0];
|
|
48
|
+
this.cloud = new SecrecyCloudClient(this);
|
|
49
|
+
this.mail = new SecrecyMailClient(this);
|
|
50
|
+
this.app = new SecrecyAppClient(opts.uaJwt, this);
|
|
51
|
+
this.db = new SecrecyDbClient(this);
|
|
52
|
+
this.organization = new SecrecyOrganizationClient(this);
|
|
45
53
|
this.wallet = new SecrecyWalletClient(this);
|
|
46
|
-
this.pay = new SecrecyPayClient(this
|
|
47
|
-
this.user = new SecrecyUserClient(this
|
|
48
|
-
this.pseudonym = new SecrecyPseudonymClient(this
|
|
54
|
+
this.pay = new SecrecyPayClient(this);
|
|
55
|
+
this.user = new SecrecyUserClient(this);
|
|
56
|
+
this.pseudonym = new SecrecyPseudonymClient(this);
|
|
49
57
|
}
|
|
50
58
|
get publicKey() {
|
|
51
|
-
return this.#
|
|
59
|
+
return this.#uaIdentity.identityPubKey;
|
|
60
|
+
}
|
|
61
|
+
get apiClient() {
|
|
62
|
+
return this.client;
|
|
63
|
+
}
|
|
64
|
+
get keyPairs() {
|
|
65
|
+
return this.#keyPairs;
|
|
66
|
+
}
|
|
67
|
+
getPrivateKey(pubKey) {
|
|
68
|
+
const privateKey = this.#keyPairs[pubKey];
|
|
69
|
+
if (privateKey === undefined) {
|
|
70
|
+
throw new Error(`Missing private key for public key ${pubKey}`);
|
|
71
|
+
}
|
|
72
|
+
return privateKey;
|
|
73
|
+
}
|
|
74
|
+
get uaPrivateKey() {
|
|
75
|
+
return this.getPrivateKey(this.#uaIdentity.identityPubKey);
|
|
76
|
+
}
|
|
77
|
+
get groupIdentities() {
|
|
78
|
+
return this.#groupIdentities;
|
|
79
|
+
}
|
|
80
|
+
get uaIdentity() {
|
|
81
|
+
return this.#uaIdentity;
|
|
52
82
|
}
|
|
53
83
|
decryptAnonymous(data) {
|
|
54
|
-
return decryptAnonymous(data,
|
|
84
|
+
return decryptAnonymous(data, {
|
|
85
|
+
publicKey: this.#uaIdentity.identityPubKey,
|
|
86
|
+
privateKey: this.uaPrivateKey,
|
|
87
|
+
});
|
|
55
88
|
}
|
|
56
89
|
async logout(sessionId) {
|
|
57
90
|
nodesCache.clear();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { storeBuddy } from '../utils/store-buddy.js';
|
|
2
2
|
export function getStorage(session) {
|
|
3
3
|
const userAppSession = storeBuddy(`secrecy.user_app_session`, session).init(null);
|
|
4
|
-
const
|
|
4
|
+
const identities = storeBuddy(`secrecy.identities`, session).init(null);
|
|
5
|
+
const keyPairs = storeBuddy(`secrecy.key_pairs`, session).init(null);
|
|
5
6
|
const jwt = storeBuddy(`secrecy.jwt`, session).init(null);
|
|
6
|
-
return {
|
|
7
|
+
return { identities, keyPairs, userAppSession, jwt };
|
|
7
8
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export const userAppSchema = z.object({
|
|
3
|
+
kind: z.literal('USER_APP'),
|
|
4
|
+
identityPubKey: z.string(),
|
|
5
|
+
userId: z.string(),
|
|
6
|
+
appId: z.string(),
|
|
7
|
+
});
|
|
8
|
+
export const groupSchema = z.object({
|
|
9
|
+
kind: z.literal('GROUP'),
|
|
10
|
+
identityPubKey: z.string(),
|
|
11
|
+
groupId: z.string(),
|
|
12
|
+
sharedByPubKey: z.string(),
|
|
13
|
+
groupOwnerPubKey: z.string(),
|
|
14
|
+
});
|
|
15
|
+
export const accessIdentitySchema = z.discriminatedUnion('kind', [
|
|
16
|
+
userAppSchema,
|
|
17
|
+
groupSchema,
|
|
18
|
+
]);
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
.object({
|
|
4
|
-
publicKey: z.string(),
|
|
5
|
-
privateKey: z.string(),
|
|
6
|
-
})
|
|
7
|
-
.strict();
|
|
2
|
+
import { accessIdentitySchema } from './identity.js';
|
|
8
3
|
export const secrecyUserApp = z
|
|
9
4
|
.object({
|
|
10
|
-
|
|
5
|
+
identities: accessIdentitySchema.array(),
|
|
6
|
+
keyPairs: z.record(z.string(), z.string()),
|
|
11
7
|
jwt: z.string(),
|
|
12
8
|
uaSession: z.string(),
|
|
13
9
|
})
|
package/dist/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './crypto/index.js';
|
|
3
3
|
export { BaseClient } from './base-client.js';
|
|
4
|
+
export * from './client/types/identity.js';
|
|
4
5
|
export * from './client/helpers.js';
|
|
5
6
|
export * from './sodium.js';
|
|
6
7
|
export * from './utils/store-buddy.js';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { SecrecyClient, UserAppNotifications, UserAppSettings } from '../index.js';
|
|
2
2
|
import type { JwtPayload } from 'jsonwebtoken';
|
|
3
|
-
import { type RouterOutputs, type
|
|
4
|
-
import { type KeyPair } from './types/index.js';
|
|
3
|
+
import { type RouterOutputs, type RouterInputs } from '../client.js';
|
|
5
4
|
export declare class SecrecyAppClient {
|
|
6
5
|
#private;
|
|
7
6
|
jwt: string;
|
|
8
7
|
jwtDecoded: JwtPayload;
|
|
9
|
-
constructor(uaJwt: string,
|
|
8
|
+
constructor(uaJwt: string, client: SecrecyClient);
|
|
10
9
|
get userId(): string;
|
|
11
10
|
get appId(): string;
|
|
12
11
|
getJwt(): Promise<string>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ProgressCallback, SecrecyClient } from '../index.js';
|
|
2
|
-
import type { DataMetadata, DataStorageType,
|
|
3
|
-
import { type RouterInputs, type
|
|
2
|
+
import type { DataMetadata, DataStorageType, LocalData, Node, NodeFull, NodeType } from './types/index.js';
|
|
3
|
+
import { type RouterInputs, type RouterOutputs } from '../client.js';
|
|
4
4
|
import { type Progress } from '../types.js';
|
|
5
5
|
import { FileTypeResult } from 'file-type';
|
|
6
6
|
export declare class SecrecyCloudClient {
|
|
7
7
|
#private;
|
|
8
|
-
constructor(client: SecrecyClient
|
|
8
|
+
constructor(client: SecrecyClient);
|
|
9
9
|
addDataToHistory({ dataId, nodeId, }: {
|
|
10
10
|
dataId: string;
|
|
11
11
|
nodeId: string;
|
|
@@ -31,9 +31,9 @@ export declare class SecrecyCloudClient {
|
|
|
31
31
|
deletedNodes(): Promise<Node[]>;
|
|
32
32
|
sharedNodes(): Promise<Node[]>;
|
|
33
33
|
nodesSharedWithMe(type?: NodeType): Promise<Node[]>;
|
|
34
|
-
deleteNodeSharing({ nodeId,
|
|
34
|
+
deleteNodeSharing({ nodeId, destPubKey, }: {
|
|
35
35
|
nodeId: string;
|
|
36
|
-
|
|
36
|
+
destPubKey: string;
|
|
37
37
|
}): Promise<boolean>;
|
|
38
38
|
duplicateNode({ nodeId, folderId, name, }: {
|
|
39
39
|
nodeId: string;
|
|
@@ -54,7 +54,7 @@ export declare class SecrecyCloudClient {
|
|
|
54
54
|
dataMetadata({ id }: {
|
|
55
55
|
id: string;
|
|
56
56
|
}): Promise<DataMetadata>;
|
|
57
|
-
shareNode(
|
|
57
|
+
shareNode(accesses: RouterInputs['cloud']['shareNode']['accesses'], progress?: ProgressCallback): Promise<RouterOutputs['cloud']['shareNodeFinish']>;
|
|
58
58
|
updateNode({ nodeId, name, isFavorite, deletedAt, }: {
|
|
59
59
|
nodeId: string;
|
|
60
60
|
name?: string | null | undefined;
|
|
@@ -96,7 +96,7 @@ export declare class SecrecyCloudClient {
|
|
|
96
96
|
name: string;
|
|
97
97
|
nodeId?: string;
|
|
98
98
|
}): Promise<NodeFull>;
|
|
99
|
-
private readonly
|
|
99
|
+
private readonly encryptNodesForIdentities;
|
|
100
100
|
reportData({ id, reasons, }: Omit<RouterInputs['cloud']['reportData'], 'encryptedDataKey'>): Promise<RouterOutputs['cloud']['reportData']>;
|
|
101
101
|
updateDataStorageType(input: RouterInputs['cloud']['moveToStorageType']): Promise<{
|
|
102
102
|
isMoved: boolean;
|
|
@@ -129,32 +129,32 @@ export declare class SecrecyCloudClient {
|
|
|
129
129
|
isMatching: false;
|
|
130
130
|
details: {
|
|
131
131
|
missingNodeAccesses: {
|
|
132
|
-
|
|
132
|
+
pubKey: string;
|
|
133
133
|
nodeId: string;
|
|
134
134
|
}[];
|
|
135
135
|
missingDataAccesses: {
|
|
136
|
-
|
|
136
|
+
pubKey: string;
|
|
137
137
|
nodeId: string;
|
|
138
138
|
dataId: string;
|
|
139
139
|
}[];
|
|
140
140
|
invalidRightsAccesses: {
|
|
141
|
-
|
|
141
|
+
pubKey: string;
|
|
142
142
|
nodeId: string;
|
|
143
143
|
expect: {
|
|
144
144
|
rights: "delete" | "read" | "write";
|
|
145
145
|
} & {
|
|
146
|
-
addAccess
|
|
147
|
-
sharingAddAccess
|
|
148
|
-
delAccess
|
|
149
|
-
sharingDelAccess
|
|
146
|
+
addAccess: "delete" | "read" | "write" | null;
|
|
147
|
+
sharingAddAccess: "delete" | "read" | "write" | null;
|
|
148
|
+
delAccess: "delete" | "read" | "write" | null;
|
|
149
|
+
sharingDelAccess: "delete" | "read" | "write" | null;
|
|
150
150
|
};
|
|
151
151
|
current: {
|
|
152
152
|
rights: "delete" | "read" | "write";
|
|
153
153
|
} & {
|
|
154
|
-
addAccess
|
|
155
|
-
sharingAddAccess
|
|
156
|
-
delAccess
|
|
157
|
-
sharingDelAccess
|
|
154
|
+
addAccess: "delete" | "read" | "write" | null;
|
|
155
|
+
sharingAddAccess: "delete" | "read" | "write" | null;
|
|
156
|
+
delAccess: "delete" | "read" | "write" | null;
|
|
157
|
+
sharingDelAccess: "delete" | "read" | "write" | null;
|
|
158
158
|
};
|
|
159
159
|
}[];
|
|
160
160
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { type ApiClient } from '../client.js';
|
|
2
1
|
import type { SecrecyClient } from '../index.js';
|
|
3
|
-
import { type KeyPair } from './types/index.js';
|
|
4
2
|
export declare class SecrecyDbClient {
|
|
5
3
|
#private;
|
|
6
|
-
constructor(
|
|
4
|
+
constructor(client: SecrecyClient);
|
|
7
5
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RouterInputs } from '../client.js';
|
|
2
2
|
import type { DraftMail, Mail, NewMail, ReceivedMail, SecrecyClient, SentMail, WaitingReceivedMail } from '../index.js';
|
|
3
|
-
import { type KeyPair } from './types/index.js';
|
|
4
3
|
import { type ApiMail } from './types/mail.js';
|
|
5
4
|
export declare class SecrecyMailClient {
|
|
6
5
|
#private;
|
|
7
|
-
constructor(client: SecrecyClient
|
|
6
|
+
constructor(client: SecrecyClient);
|
|
8
7
|
get({ id }: {
|
|
9
8
|
id: string;
|
|
10
9
|
}): Promise<Mail>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RouterInputs, RouterOutputs
|
|
1
|
+
import { RouterInputs, RouterOutputs } from '../client.js';
|
|
2
2
|
import type { SecrecyClient } from '../index.js';
|
|
3
|
-
import { type KeyPair } from './types/index.js';
|
|
4
3
|
export declare class SecrecyOrganizationClient {
|
|
5
4
|
#private;
|
|
6
|
-
constructor(
|
|
5
|
+
constructor(client: SecrecyClient);
|
|
7
6
|
create(input: RouterInputs['org']['create']): Promise<RouterOutputs['org']['create']>;
|
|
8
7
|
update(input: Omit<RouterInputs['org']['update'], 'billingProfileStripeCustomerId'>): Promise<RouterOutputs['org']['update']>;
|
|
9
8
|
addMember(input: RouterInputs['org']['addMember']): Promise<RouterOutputs['org']['addMember']>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { SecrecyClient } from '../index.js';
|
|
2
|
-
import { type ApiClient } from '../client.js';
|
|
3
|
-
import { type KeyPair } from './types/index.js';
|
|
4
2
|
interface SuccessPayResponse<T> {
|
|
5
3
|
success: true;
|
|
6
4
|
data: T;
|
|
@@ -12,7 +10,7 @@ interface ErrorPayResponse {
|
|
|
12
10
|
export type SecrecyPayResponse<T> = SuccessPayResponse<T> | ErrorPayResponse;
|
|
13
11
|
export declare class SecrecyPayClient {
|
|
14
12
|
#private;
|
|
15
|
-
constructor(client: SecrecyClient
|
|
13
|
+
constructor(client: SecrecyClient);
|
|
16
14
|
confirmPaymentIntent({ paymentIntentId, secrecyIdWhoCreatedPaymentIntent, secrecyIdWhoNeedToConfirmPaymentIntent, amount, currency, }: {
|
|
17
15
|
paymentIntentId: string;
|
|
18
16
|
secrecyIdWhoCreatedPaymentIntent: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { type RouterInputs, type RouterOutputs
|
|
1
|
+
import { type RouterInputs, type RouterOutputs } from '../client.js';
|
|
2
2
|
import type { SecrecyClient } from '../index.js';
|
|
3
|
-
import { type KeyPair } from './types/index.js';
|
|
4
3
|
export declare class SecrecyPseudonymClient {
|
|
5
4
|
#private;
|
|
6
|
-
constructor(client: SecrecyClient
|
|
5
|
+
constructor(client: SecrecyClient);
|
|
7
6
|
askForLabel(input: RouterInputs['pseudonym']['askForLabel']): Promise<RouterOutputs['pseudonym']['askForLabel']>;
|
|
8
7
|
askForUser(input: RouterInputs['pseudonym']['askForUser']): Promise<RouterOutputs['pseudonym']['askForUser']>;
|
|
9
8
|
cross(input: RouterInputs['pseudonym']['cross']): Promise<RouterOutputs['pseudonym']['cross']>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { RouterInputs,
|
|
1
|
+
import type { RouterInputs, RouterOutputs } from '../client.js';
|
|
2
2
|
import type { SecrecyClient } from '../index.js';
|
|
3
|
-
import type { KeyPair } from './types/index.js';
|
|
4
3
|
export declare class SecrecyUserClient {
|
|
5
4
|
#private;
|
|
6
|
-
constructor(
|
|
5
|
+
constructor(client: SecrecyClient);
|
|
7
6
|
answerInvitation(input: RouterInputs['contacts']['answerInvitation']): Promise<RouterOutputs['contacts']['answerInvitation']>;
|
|
8
7
|
cancelInvitation(input: RouterInputs['contacts']['cancelInvitation']): Promise<RouterOutputs['contacts']['cancelInvitation']>;
|
|
9
8
|
createInvitation(input: RouterInputs['contacts']['createInvitation']): Promise<RouterOutputs['contacts']['createInvitation']>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiData, InternalData, DataMetadata
|
|
2
|
-
export declare function apiDataToInternal(apiData: ApiData,
|
|
1
|
+
import type { ApiData, InternalData, DataMetadata } from '../types/index.js';
|
|
2
|
+
export declare function apiDataToInternal(apiData: ApiData, keyPairs: Record<string, string>): InternalData;
|
|
3
3
|
export declare function internalDataToExternalData(internal: InternalData): DataMetadata;
|
|
4
|
-
export declare function apiDataToExternal(apiData: ApiData,
|
|
4
|
+
export declare function apiDataToExternal(apiData: ApiData, keyPairs: Record<string, string>): DataMetadata;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { type Mail
|
|
2
|
-
import { type KeyPair } from '../types/index.js';
|
|
1
|
+
import { type Mail } from '../../index.js';
|
|
3
2
|
import { type ApiMail } from '../types/mail.js';
|
|
4
|
-
export declare function convertInternalMailToExternal({
|
|
3
|
+
export declare function convertInternalMailToExternal({ mail, keyPairs, }: {
|
|
5
4
|
mail: ApiMail;
|
|
6
|
-
|
|
7
|
-
keyPair: KeyPair;
|
|
5
|
+
keyPairs: Record<string, string>;
|
|
8
6
|
}): Promise<Mail>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Node, ApiNode, ApiNodeFull, InternalNodeFull, NodeFull,
|
|
2
|
-
export declare function apiNodeFullToInternalFull(apiNodeFull: ApiNodeFull,
|
|
1
|
+
import type { Node, ApiNode, ApiNodeFull, InternalNodeFull, NodeFull, ApiNodeParent, ApiNodeForEncryption, InternalMinimalNodeForEncryption } from '../types/index.js';
|
|
2
|
+
export declare function apiNodeFullToInternalFull(apiNodeFull: ApiNodeFull, keyPairs: Record<string, string>): Promise<InternalNodeFull>;
|
|
3
3
|
export declare function internalNodeFullToNodeFull(internal: InternalNodeFull): NodeFull;
|
|
4
|
-
export declare function apiNodeToExternalNodeFull(apiNodeFull: ApiNodeFull,
|
|
5
|
-
export declare function apiNodeToExternal(apiNode: ApiNode | ApiNodeParent,
|
|
6
|
-
export declare function apiNodeForEncryptionToInternal(apiNode: ApiNodeForEncryption,
|
|
4
|
+
export declare function apiNodeToExternalNodeFull(apiNodeFull: ApiNodeFull, keyPairs: Record<string, string>): Promise<NodeFull>;
|
|
5
|
+
export declare function apiNodeToExternal(apiNode: ApiNode | ApiNodeParent, keyPairs: Record<string, string>): Promise<Node>;
|
|
6
|
+
export declare function apiNodeForEncryptionToInternal(apiNode: ApiNodeForEncryption, keyPairs: Record<string, string>): Promise<InternalMinimalNodeForEncryption>;
|
|
@@ -7,15 +7,16 @@ import { SecrecyDbClient } from './SecrecyDbClient.js';
|
|
|
7
7
|
import { SecrecyWalletClient } from './SecrecyWalletClient.js';
|
|
8
8
|
import { SecrecyPayClient } from './SecrecyPayClient.js';
|
|
9
9
|
import { ApiClient, type RouterInputs } from '../client.js';
|
|
10
|
-
import { type KeyPair } from './types/index.js';
|
|
11
10
|
import { SecrecyUserClient } from './SecrecyUserClient.js';
|
|
12
11
|
import { SecrecyPseudonymClient } from './SecrecyPseudonymClient.js';
|
|
13
12
|
import { SecrecyOrganizationClient } from './SecrecyOrganizationClient.js';
|
|
13
|
+
import type { AccessIdentity, GroupIdentity, UserAppIdentity } from './types/identity.js';
|
|
14
14
|
export type NewMail = Pick<RouterInputs['mail']['createDraft'], 'body' | 'subject' | 'senderFiles' | 'recipients' | 'replyToId'>;
|
|
15
15
|
export type ProgressCallback = (progress: SecretStreamProgress) => Promise<void>;
|
|
16
16
|
export interface SecrecyClientOptions {
|
|
17
17
|
uaSession: string;
|
|
18
|
-
|
|
18
|
+
identities: AccessIdentity[];
|
|
19
|
+
keyPairs: Record<string, string>;
|
|
19
20
|
uaJwt: string;
|
|
20
21
|
apiClient?: ApiClient;
|
|
21
22
|
secrecyUrls?: Partial<SecrecyUrls>;
|
|
@@ -33,6 +34,12 @@ export declare class SecrecyClient extends BaseClient {
|
|
|
33
34
|
pseudonym: SecrecyPseudonymClient;
|
|
34
35
|
constructor(opts: SecrecyClientOptions);
|
|
35
36
|
get publicKey(): string;
|
|
37
|
+
get apiClient(): Readonly<ApiClient>;
|
|
38
|
+
get keyPairs(): Readonly<Record<string, string>>;
|
|
39
|
+
getPrivateKey(pubKey: string): string;
|
|
40
|
+
get uaPrivateKey(): string;
|
|
41
|
+
get groupIdentities(): ReadonlyArray<Readonly<GroupIdentity>>;
|
|
42
|
+
get uaIdentity(): Readonly<UserAppIdentity>;
|
|
36
43
|
decryptAnonymous(data: Uint8Array): Uint8Array;
|
|
37
44
|
logout(sessionId?: string | null | undefined): Promise<void>;
|
|
38
45
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { StoreBuddy } from '../utils/store-buddy.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { AccessIdentity } from './types/identity.js';
|
|
3
3
|
export declare function getStorage(session?: boolean | undefined): {
|
|
4
|
-
|
|
4
|
+
identities: StoreBuddy<AccessIdentity[] | null>;
|
|
5
|
+
keyPairs: StoreBuddy<Record<string, string> | null>;
|
|
5
6
|
userAppSession: StoreBuddy<string | null>;
|
|
6
7
|
jwt: StoreBuddy<string | null>;
|
|
7
8
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export declare const userAppSchema: z.ZodObject<{
|
|
3
|
+
kind: z.ZodLiteral<"USER_APP">;
|
|
4
|
+
identityPubKey: z.ZodString;
|
|
5
|
+
userId: z.ZodString;
|
|
6
|
+
appId: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const groupSchema: z.ZodObject<{
|
|
9
|
+
kind: z.ZodLiteral<"GROUP">;
|
|
10
|
+
identityPubKey: z.ZodString;
|
|
11
|
+
groupId: z.ZodString;
|
|
12
|
+
sharedByPubKey: z.ZodString;
|
|
13
|
+
groupOwnerPubKey: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const accessIdentitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
16
|
+
kind: z.ZodLiteral<"USER_APP">;
|
|
17
|
+
identityPubKey: z.ZodString;
|
|
18
|
+
userId: z.ZodString;
|
|
19
|
+
appId: z.ZodString;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
kind: z.ZodLiteral<"GROUP">;
|
|
22
|
+
identityPubKey: z.ZodString;
|
|
23
|
+
groupId: z.ZodString;
|
|
24
|
+
sharedByPubKey: z.ZodString;
|
|
25
|
+
groupOwnerPubKey: z.ZodString;
|
|
26
|
+
}, z.core.$strip>], "kind">;
|
|
27
|
+
export type AccessIdentity = z.infer<typeof accessIdentitySchema>;
|
|
28
|
+
export type UserAppIdentity = z.infer<typeof userAppSchema>;
|
|
29
|
+
export type GroupIdentity = z.infer<typeof groupSchema>;
|
|
@@ -4,16 +4,20 @@ export type * from './data.js';
|
|
|
4
4
|
export type * from './node.js';
|
|
5
5
|
export type * from './mail.js';
|
|
6
6
|
export type * from './user.js';
|
|
7
|
-
declare const keyPair: z.ZodObject<{
|
|
8
|
-
publicKey: z.ZodString;
|
|
9
|
-
privateKey: z.ZodString;
|
|
10
|
-
}, z.core.$strict>;
|
|
11
|
-
export type KeyPair = z.infer<typeof keyPair>;
|
|
12
7
|
export declare const secrecyUserApp: z.ZodReadonly<z.ZodObject<{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
identities: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
kind: z.ZodLiteral<"USER_APP">;
|
|
10
|
+
identityPubKey: z.ZodString;
|
|
11
|
+
userId: z.ZodString;
|
|
12
|
+
appId: z.ZodString;
|
|
13
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
14
|
+
kind: z.ZodLiteral<"GROUP">;
|
|
15
|
+
identityPubKey: z.ZodString;
|
|
16
|
+
groupId: z.ZodString;
|
|
17
|
+
sharedByPubKey: z.ZodString;
|
|
18
|
+
groupOwnerPubKey: z.ZodString;
|
|
19
|
+
}, z.core.$strip>], "kind">>;
|
|
20
|
+
keyPairs: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
17
21
|
jwt: z.ZodString;
|
|
18
22
|
uaSession: z.ZodString;
|
|
19
23
|
}, z.core.$strict>>;
|
|
@@ -13,7 +13,7 @@ export interface BaseMail {
|
|
|
13
13
|
deletedAt: Date | null;
|
|
14
14
|
openedAt: Date | null;
|
|
15
15
|
isAltered: boolean;
|
|
16
|
-
recipients: Array<
|
|
16
|
+
recipients: Array<PublicUser>;
|
|
17
17
|
temporaryRecipients: TemporaryMailUser[];
|
|
18
18
|
attachments: Array<{
|
|
19
19
|
id: string;
|
|
@@ -24,6 +24,7 @@ export interface BaseMail {
|
|
|
24
24
|
export interface ReceivedMail extends BaseMail {
|
|
25
25
|
type: 'received';
|
|
26
26
|
sender: PublicUser;
|
|
27
|
+
senderPublicKey: string;
|
|
27
28
|
}
|
|
28
29
|
export interface InternalSentMail {
|
|
29
30
|
user: {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { type RouterOutputs } from '../../client.js';
|
|
2
|
-
import type { DataMetadata, InternalData,
|
|
3
|
-
export type Permissions = ApiNode['
|
|
2
|
+
import type { DataMetadata, InternalData, UserAppOrg } from './index.js';
|
|
3
|
+
export type Permissions = ApiNode['identities'][number];
|
|
4
4
|
export type Rights = Permissions['rights'];
|
|
5
5
|
export type NodeAccess<T extends Record<string, unknown> = Record<string, unknown>> = T & Permissions & {
|
|
6
6
|
isRoot: boolean;
|
|
7
7
|
sharedByPubKey: string;
|
|
8
|
+
identityPubKey: string;
|
|
8
9
|
};
|
|
9
10
|
export interface NodeBreadcrumbItem {
|
|
10
11
|
id: string;
|
|
11
12
|
name: string;
|
|
12
13
|
}
|
|
13
14
|
export interface NodeBreadcrumbItemWithPubKey extends NodeBreadcrumbItem {
|
|
14
|
-
|
|
15
|
+
sharedByPubKey: string;
|
|
16
|
+
identityPubKey: string;
|
|
15
17
|
}
|
|
16
18
|
export interface NodeSize {
|
|
17
19
|
size: bigint;
|
|
@@ -31,9 +33,10 @@ export interface Node<T extends NodeBreadcrumbItem = NodeBreadcrumbItem, U exten
|
|
|
31
33
|
sizes: NodeSize;
|
|
32
34
|
name: string;
|
|
33
35
|
breadcrumb: T[];
|
|
34
|
-
owner:
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
owner: UserAppOrg;
|
|
37
|
+
accesses: NodeAccess<U>[];
|
|
38
|
+
permissions: Permissions;
|
|
39
|
+
identities: Record<string, Permissions>;
|
|
37
40
|
currentDataId: string | null;
|
|
38
41
|
parentId: string | null;
|
|
39
42
|
}
|
|
@@ -72,16 +75,16 @@ export type EncryptedNodeInfos = {
|
|
|
72
75
|
};
|
|
73
76
|
export type ShareNodeDetails = {
|
|
74
77
|
missingNodeAccesses: {
|
|
75
|
-
|
|
78
|
+
pubKey: string;
|
|
76
79
|
nodeId: string;
|
|
77
80
|
}[];
|
|
78
81
|
missingDataAccesses: {
|
|
79
|
-
|
|
82
|
+
pubKey: string;
|
|
80
83
|
dataId: string;
|
|
81
84
|
nodeId: string;
|
|
82
85
|
}[];
|
|
83
86
|
invalidRightsAccesses: {
|
|
84
|
-
|
|
87
|
+
pubKey: string;
|
|
85
88
|
current: Permissions;
|
|
86
89
|
nodeId: string;
|
|
87
90
|
expect: Permissions;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
import { type RouterOutputs } from '../../client.js';
|
|
2
2
|
export type SelfUser = RouterOutputs['user']['self'];
|
|
3
3
|
export type PublicUser = RouterOutputs['user']['byId'];
|
|
4
|
+
export type UserAppOrg = RouterOutputs['cloud']['nodeById']['owner'];
|
|
5
|
+
export type AccessIdentity = RouterOutputs['identity']['list']['identities'][number];
|
|
6
|
+
export type PublicAccessIdentity = RouterOutputs['identity']['get']['identity'];
|
|
7
|
+
export type PublicUserAppIdentity = Extract<PublicAccessIdentity, {
|
|
8
|
+
kind: 'USER_APP';
|
|
9
|
+
}>;
|
|
10
|
+
export type PublicGroupIdentity = Extract<PublicAccessIdentity, {
|
|
11
|
+
kind: 'GROUP';
|
|
12
|
+
}>;
|
|
13
|
+
export type UserAppIdentity = Extract<AccessIdentity, {
|
|
14
|
+
kind: 'USER_APP';
|
|
15
|
+
}>;
|
|
16
|
+
export type GroupIdentity = Extract<AccessIdentity, {
|
|
17
|
+
kind: 'GROUP';
|
|
18
|
+
}>;
|