@secrecy/lib 1.30.0 → 1.32.0-feat-user-data-management.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/client/SecrecyCloudClient.js +12 -9
- package/dist/types/client.d.ts +178 -60
- package/package.json +2 -2
|
@@ -65,16 +65,19 @@ export class SecrecyCloudClient {
|
|
|
65
65
|
percent: 0,
|
|
66
66
|
});
|
|
67
67
|
if (uploadData.parts.length === 0) {
|
|
68
|
+
if (uploadData.keyPair.pub !== this.#keys.publicKey) {
|
|
69
|
+
throw new Error('The public key does not match with cached key!');
|
|
70
|
+
}
|
|
68
71
|
await uploadProgress?.({
|
|
69
72
|
total: encryptedData.byteLength,
|
|
70
73
|
current: encryptedData.byteLength,
|
|
71
74
|
percent: 1,
|
|
72
75
|
});
|
|
73
|
-
return uploadData.
|
|
76
|
+
return uploadData.id;
|
|
74
77
|
}
|
|
75
78
|
const uploadDataPartEnd = async (md5, order) => {
|
|
76
79
|
const { isUploadPartEnded } = await this.#apiClient.cloud.uploadDataPartEnd.mutate({
|
|
77
|
-
dataId: uploadData.
|
|
80
|
+
dataId: uploadData.id,
|
|
78
81
|
md5,
|
|
79
82
|
order,
|
|
80
83
|
});
|
|
@@ -82,12 +85,12 @@ export class SecrecyCloudClient {
|
|
|
82
85
|
};
|
|
83
86
|
const uploadEnded = async () => {
|
|
84
87
|
const { isUploadEnded } = await this.#apiClient.cloud.uploadDataEnd.mutate({
|
|
85
|
-
dataId: uploadData.
|
|
88
|
+
dataId: uploadData.id,
|
|
86
89
|
});
|
|
87
90
|
return isUploadEnded;
|
|
88
91
|
};
|
|
89
92
|
const chunkParts = new Array();
|
|
90
|
-
for (const [index, chunk] of enumerate(chunks(encryptedData, Number(uploadData.
|
|
93
|
+
for (const [index, chunk] of enumerate(chunks(encryptedData, Number(uploadData.partSize)))) {
|
|
91
94
|
chunkParts.push({
|
|
92
95
|
order: index + 1,
|
|
93
96
|
data: chunk,
|
|
@@ -113,7 +116,7 @@ export class SecrecyCloudClient {
|
|
|
113
116
|
for (const [key, value] of Object.entries(part.fields)) {
|
|
114
117
|
formData.append(key, value);
|
|
115
118
|
}
|
|
116
|
-
formData.append('data', new Blob([chunk.data]), `${uploadData.
|
|
119
|
+
formData.append('data', new Blob([chunk.data]), `${uploadData.id}-${chunk.order}`);
|
|
117
120
|
await axios.post(part.url, formData, {
|
|
118
121
|
onUploadProgress: (progressEvent) => {
|
|
119
122
|
onProgress(part.order, progressEvent);
|
|
@@ -126,8 +129,8 @@ export class SecrecyCloudClient {
|
|
|
126
129
|
await byPart(p);
|
|
127
130
|
}));
|
|
128
131
|
await uploadEnded();
|
|
129
|
-
dataContentCache.set(uploadData.
|
|
130
|
-
return uploadData.
|
|
132
|
+
dataContentCache.set(uploadData.id, dataBuffer);
|
|
133
|
+
return uploadData.id;
|
|
131
134
|
}
|
|
132
135
|
async uploadDataInCloud({ data, name, nodeId, encryptProgress, uploadProgress, signal, }) {
|
|
133
136
|
const dataId = await this.uploadData({
|
|
@@ -335,12 +338,12 @@ export class SecrecyCloudClient {
|
|
|
335
338
|
return decompress(src);
|
|
336
339
|
};
|
|
337
340
|
const encryptedContent = dataContent.type === 'lite'
|
|
338
|
-
? dataContent.content
|
|
341
|
+
? new Uint8Array(dataContent.content)
|
|
339
342
|
: dataContent.type === 'cloud'
|
|
340
343
|
? await encryptedContentFromParts(dataContent.parts)
|
|
341
344
|
: // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
342
345
|
dataContent.maybeContent !== null
|
|
343
|
-
? dataContent.maybeContent
|
|
346
|
+
? new Uint8Array(dataContent.maybeContent)
|
|
344
347
|
: dataContent.maybeParts !== null
|
|
345
348
|
? await encryptedContentFromParts(dataContent.maybeParts)
|
|
346
349
|
: null;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -185,6 +185,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
185
185
|
avatar: string | null;
|
|
186
186
|
isSearchable: boolean;
|
|
187
187
|
}[];
|
|
188
|
+
currentUserId: string;
|
|
188
189
|
};
|
|
189
190
|
_output_out: {
|
|
190
191
|
users: {
|
|
@@ -194,6 +195,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
194
195
|
avatar: string | null;
|
|
195
196
|
isSearchable: boolean;
|
|
196
197
|
}[];
|
|
198
|
+
currentUserId: string;
|
|
197
199
|
};
|
|
198
200
|
}, unknown>>;
|
|
199
201
|
};
|
|
@@ -1945,11 +1947,13 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
1945
1947
|
};
|
|
1946
1948
|
_output_in: {
|
|
1947
1949
|
sessionId: string;
|
|
1950
|
+
userId: string;
|
|
1948
1951
|
} & {
|
|
1949
1952
|
masterKeySalt: string;
|
|
1950
1953
|
};
|
|
1951
1954
|
_output_out: {
|
|
1952
1955
|
sessionId: string;
|
|
1956
|
+
userId: string;
|
|
1953
1957
|
} & {
|
|
1954
1958
|
masterKeySalt: string;
|
|
1955
1959
|
};
|
|
@@ -3150,7 +3154,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3150
3154
|
}>;
|
|
3151
3155
|
_meta: object;
|
|
3152
3156
|
_ctx_out: {
|
|
3153
|
-
session:
|
|
3157
|
+
session: SecrecySession;
|
|
3154
3158
|
req: {
|
|
3155
3159
|
headers: Headers;
|
|
3156
3160
|
body: ReadableStream<Uint8Array> | null;
|
|
@@ -3164,10 +3168,14 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
3164
3168
|
_input_in: {
|
|
3165
3169
|
dataId: string;
|
|
3166
3170
|
nodeId: string;
|
|
3171
|
+
} & {
|
|
3172
|
+
appId?: string | null | undefined;
|
|
3167
3173
|
};
|
|
3168
3174
|
_input_out: {
|
|
3169
3175
|
dataId: string;
|
|
3170
3176
|
nodeId: string;
|
|
3177
|
+
} & {
|
|
3178
|
+
appId?: string | null | undefined;
|
|
3171
3179
|
};
|
|
3172
3180
|
_output_in: {
|
|
3173
3181
|
isDeleted: boolean;
|
|
@@ -4042,8 +4050,8 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4042
4050
|
min?: Date | undefined;
|
|
4043
4051
|
} | undefined;
|
|
4044
4052
|
size?: {
|
|
4045
|
-
max?: bigint | undefined;
|
|
4046
|
-
min?: bigint | undefined;
|
|
4053
|
+
max?: string | bigint | undefined;
|
|
4054
|
+
min?: string | bigint | undefined;
|
|
4047
4055
|
} | undefined;
|
|
4048
4056
|
appIds?: string[] | undefined;
|
|
4049
4057
|
sharedCount?: {
|
|
@@ -4080,68 +4088,86 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4080
4088
|
} | undefined;
|
|
4081
4089
|
};
|
|
4082
4090
|
_output_in: {
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
pub: string;
|
|
4086
|
-
encPriv: string;
|
|
4087
|
-
}[];
|
|
4088
|
-
nodes: {
|
|
4089
|
-
id: string;
|
|
4090
|
-
createdAt: Date;
|
|
4091
|
-
deletedAt: Date | null;
|
|
4092
|
-
name: string;
|
|
4093
|
-
updatedAt: Date;
|
|
4094
|
-
history: {
|
|
4095
|
-
createdAt: Date;
|
|
4096
|
-
dataId: string;
|
|
4097
|
-
size: bigint;
|
|
4098
|
-
storageType: "s3" | "lite";
|
|
4099
|
-
}[];
|
|
4100
|
-
access: {
|
|
4091
|
+
data: {
|
|
4092
|
+
keyPairs: {
|
|
4101
4093
|
appId: string;
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4094
|
+
pub: string;
|
|
4095
|
+
encPriv: string;
|
|
4096
|
+
}[];
|
|
4097
|
+
nodes: {
|
|
4106
4098
|
id: string;
|
|
4099
|
+
createdAt: Date;
|
|
4100
|
+
deletedAt: Date | null;
|
|
4107
4101
|
name: string;
|
|
4108
|
-
|
|
4109
|
-
|
|
4102
|
+
updatedAt: Date;
|
|
4103
|
+
history: {
|
|
4104
|
+
createdAt: Date;
|
|
4105
|
+
dataId: string;
|
|
4106
|
+
size: bigint;
|
|
4107
|
+
storageType: "s3" | "lite";
|
|
4108
|
+
}[];
|
|
4109
|
+
access: {
|
|
4110
|
+
appId: string;
|
|
4111
|
+
nameKey: string;
|
|
4112
|
+
};
|
|
4113
|
+
totalSize: bigint;
|
|
4114
|
+
breadcrumb: {
|
|
4115
|
+
id: string;
|
|
4116
|
+
name: string;
|
|
4117
|
+
nameKey: string | null;
|
|
4118
|
+
pubKey: string;
|
|
4119
|
+
}[];
|
|
4120
|
+
sharedCount: number;
|
|
4110
4121
|
}[];
|
|
4111
|
-
|
|
4112
|
-
|
|
4122
|
+
};
|
|
4123
|
+
pagination: {
|
|
4124
|
+
next: number | null;
|
|
4125
|
+
prev: number | null;
|
|
4126
|
+
last: number;
|
|
4127
|
+
perPage: number;
|
|
4128
|
+
totalItems: number;
|
|
4129
|
+
};
|
|
4113
4130
|
};
|
|
4114
4131
|
_output_out: {
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
pub: string;
|
|
4118
|
-
encPriv: string;
|
|
4119
|
-
}[];
|
|
4120
|
-
nodes: {
|
|
4121
|
-
id: string;
|
|
4122
|
-
createdAt: Date;
|
|
4123
|
-
deletedAt: Date | null;
|
|
4124
|
-
name: string;
|
|
4125
|
-
updatedAt: Date;
|
|
4126
|
-
history: {
|
|
4127
|
-
createdAt: Date;
|
|
4128
|
-
dataId: string;
|
|
4129
|
-
size: bigint;
|
|
4130
|
-
storageType: "s3" | "lite";
|
|
4131
|
-
}[];
|
|
4132
|
-
access: {
|
|
4132
|
+
data: {
|
|
4133
|
+
keyPairs: {
|
|
4133
4134
|
appId: string;
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4135
|
+
pub: string;
|
|
4136
|
+
encPriv: string;
|
|
4137
|
+
}[];
|
|
4138
|
+
nodes: {
|
|
4138
4139
|
id: string;
|
|
4140
|
+
createdAt: Date;
|
|
4141
|
+
deletedAt: Date | null;
|
|
4139
4142
|
name: string;
|
|
4140
|
-
|
|
4141
|
-
|
|
4143
|
+
updatedAt: Date;
|
|
4144
|
+
history: {
|
|
4145
|
+
createdAt: Date;
|
|
4146
|
+
dataId: string;
|
|
4147
|
+
size: bigint;
|
|
4148
|
+
storageType: "s3" | "lite";
|
|
4149
|
+
}[];
|
|
4150
|
+
access: {
|
|
4151
|
+
appId: string;
|
|
4152
|
+
nameKey: string;
|
|
4153
|
+
};
|
|
4154
|
+
totalSize: bigint;
|
|
4155
|
+
breadcrumb: {
|
|
4156
|
+
id: string;
|
|
4157
|
+
name: string;
|
|
4158
|
+
nameKey: string | null;
|
|
4159
|
+
pubKey: string;
|
|
4160
|
+
}[];
|
|
4161
|
+
sharedCount: number;
|
|
4142
4162
|
}[];
|
|
4143
|
-
|
|
4144
|
-
|
|
4163
|
+
};
|
|
4164
|
+
pagination: {
|
|
4165
|
+
next: number | null;
|
|
4166
|
+
prev: number | null;
|
|
4167
|
+
last: number;
|
|
4168
|
+
perPage: number;
|
|
4169
|
+
totalItems: number;
|
|
4170
|
+
};
|
|
4145
4171
|
};
|
|
4146
4172
|
}, unknown>>;
|
|
4147
4173
|
};
|
|
@@ -4400,22 +4426,32 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4400
4426
|
dataKey: string;
|
|
4401
4427
|
};
|
|
4402
4428
|
_output_in: {
|
|
4403
|
-
|
|
4429
|
+
id: string;
|
|
4430
|
+
keyPair: {
|
|
4431
|
+
pub: string;
|
|
4432
|
+
encPriv: string;
|
|
4433
|
+
};
|
|
4434
|
+
key: string;
|
|
4435
|
+
partSize: bigint;
|
|
4404
4436
|
parts: {
|
|
4405
4437
|
fields: Record<string, string>;
|
|
4406
4438
|
url: string;
|
|
4407
4439
|
order: number;
|
|
4408
4440
|
}[];
|
|
4409
|
-
dataPartSize: bigint;
|
|
4410
4441
|
};
|
|
4411
4442
|
_output_out: {
|
|
4412
|
-
|
|
4443
|
+
id: string;
|
|
4444
|
+
keyPair: {
|
|
4445
|
+
pub: string;
|
|
4446
|
+
encPriv: string;
|
|
4447
|
+
};
|
|
4448
|
+
key: string;
|
|
4449
|
+
partSize: bigint;
|
|
4413
4450
|
parts: {
|
|
4414
4451
|
fields: Record<string, string>;
|
|
4415
4452
|
url: string;
|
|
4416
4453
|
order: number;
|
|
4417
4454
|
}[];
|
|
4418
|
-
dataPartSize: bigint;
|
|
4419
4455
|
};
|
|
4420
4456
|
}, unknown>>;
|
|
4421
4457
|
};
|
|
@@ -4483,9 +4519,19 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4483
4519
|
};
|
|
4484
4520
|
_output_in: {
|
|
4485
4521
|
id: string;
|
|
4522
|
+
keyPair: {
|
|
4523
|
+
pub: string;
|
|
4524
|
+
encPriv: string;
|
|
4525
|
+
};
|
|
4526
|
+
key: string;
|
|
4486
4527
|
};
|
|
4487
4528
|
_output_out: {
|
|
4488
4529
|
id: string;
|
|
4530
|
+
keyPair: {
|
|
4531
|
+
pub: string;
|
|
4532
|
+
encPriv: string;
|
|
4533
|
+
};
|
|
4534
|
+
key: string;
|
|
4489
4535
|
};
|
|
4490
4536
|
}, unknown>>;
|
|
4491
4537
|
};
|
|
@@ -4994,7 +5040,7 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
4994
5040
|
}>;
|
|
4995
5041
|
_meta: object;
|
|
4996
5042
|
_ctx_out: {
|
|
4997
|
-
session:
|
|
5043
|
+
session: SecrecySession;
|
|
4998
5044
|
req: {
|
|
4999
5045
|
headers: Headers;
|
|
5000
5046
|
body: ReadableStream<Uint8Array> | null;
|
|
@@ -5007,9 +5053,17 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
5007
5053
|
};
|
|
5008
5054
|
_input_in: {
|
|
5009
5055
|
id: string;
|
|
5056
|
+
} & {
|
|
5057
|
+
force?: boolean | undefined;
|
|
5058
|
+
} & {
|
|
5059
|
+
appId?: string | null | undefined;
|
|
5010
5060
|
};
|
|
5011
5061
|
_input_out: {
|
|
5012
5062
|
id: string;
|
|
5063
|
+
} & {
|
|
5064
|
+
force?: boolean | undefined;
|
|
5065
|
+
} & {
|
|
5066
|
+
appId?: string | null | undefined;
|
|
5013
5067
|
};
|
|
5014
5068
|
_output_in: {
|
|
5015
5069
|
isDeleted: boolean;
|
|
@@ -18206,12 +18260,14 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
18206
18260
|
_input_in: {
|
|
18207
18261
|
lastname?: string | null | undefined;
|
|
18208
18262
|
firstname?: string | null | undefined;
|
|
18263
|
+
avatar?: string | null | undefined;
|
|
18209
18264
|
isSearchable?: boolean | undefined;
|
|
18210
18265
|
lang?: "fr" | "en" | null | undefined;
|
|
18211
18266
|
};
|
|
18212
18267
|
_input_out: {
|
|
18213
18268
|
lastname?: string | null | undefined;
|
|
18214
18269
|
firstname?: string | null | undefined;
|
|
18270
|
+
avatar?: string | null | undefined;
|
|
18215
18271
|
isSearchable?: boolean | undefined;
|
|
18216
18272
|
lang?: "fr" | "en" | null | undefined;
|
|
18217
18273
|
};
|
|
@@ -18247,6 +18303,68 @@ export declare const createTRPCClient: (session?: string | null | undefined, onA
|
|
|
18247
18303
|
};
|
|
18248
18304
|
}, unknown>>;
|
|
18249
18305
|
};
|
|
18306
|
+
myApps: {
|
|
18307
|
+
query: import("@trpc/client").Resolver<import("@trpc/server").BuildProcedure<"query", {
|
|
18308
|
+
_config: import("@trpc/server").RootConfig<{
|
|
18309
|
+
ctx: {
|
|
18310
|
+
req: {
|
|
18311
|
+
headers: Headers;
|
|
18312
|
+
body: ReadableStream<Uint8Array> | null;
|
|
18313
|
+
};
|
|
18314
|
+
res: {
|
|
18315
|
+
headers: Headers;
|
|
18316
|
+
};
|
|
18317
|
+
session: SecrecySession | null;
|
|
18318
|
+
locale: Locales;
|
|
18319
|
+
ls: TranslationFunctions;
|
|
18320
|
+
};
|
|
18321
|
+
meta: object;
|
|
18322
|
+
errorShape: {
|
|
18323
|
+
message: string;
|
|
18324
|
+
code: import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER;
|
|
18325
|
+
data: _trpc_server_dist_error_formatter.DefaultErrorData;
|
|
18326
|
+
} | {
|
|
18327
|
+
data: {
|
|
18328
|
+
zodError: import("zod").typeToFlattenedError<any, string> | null;
|
|
18329
|
+
code: import("@trpc/server/rpc").TRPC_ERROR_CODE_KEY;
|
|
18330
|
+
httpStatus: number;
|
|
18331
|
+
path?: string;
|
|
18332
|
+
stack?: string;
|
|
18333
|
+
};
|
|
18334
|
+
message: string;
|
|
18335
|
+
code: import("@trpc/server/rpc").TRPC_ERROR_CODE_NUMBER;
|
|
18336
|
+
};
|
|
18337
|
+
transformer: typeof superjson;
|
|
18338
|
+
}>;
|
|
18339
|
+
_meta: object;
|
|
18340
|
+
_ctx_out: {
|
|
18341
|
+
session: SecrecySession;
|
|
18342
|
+
req: {
|
|
18343
|
+
headers: Headers;
|
|
18344
|
+
body: ReadableStream<Uint8Array> | null;
|
|
18345
|
+
};
|
|
18346
|
+
res: {
|
|
18347
|
+
headers: Headers;
|
|
18348
|
+
};
|
|
18349
|
+
locale: Locales;
|
|
18350
|
+
ls: TranslationFunctions;
|
|
18351
|
+
};
|
|
18352
|
+
_input_in: {};
|
|
18353
|
+
_input_out: {};
|
|
18354
|
+
_output_in: {
|
|
18355
|
+
apps: Record<string, {
|
|
18356
|
+
name: string;
|
|
18357
|
+
logo: string | null;
|
|
18358
|
+
}>;
|
|
18359
|
+
};
|
|
18360
|
+
_output_out: {
|
|
18361
|
+
apps: Record<string, {
|
|
18362
|
+
name: string;
|
|
18363
|
+
logo: string | null;
|
|
18364
|
+
}>;
|
|
18365
|
+
};
|
|
18366
|
+
}, unknown>>;
|
|
18367
|
+
};
|
|
18250
18368
|
};
|
|
18251
18369
|
};
|
|
18252
18370
|
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.
|
|
5
|
+
"version": "1.32.0-feat-user-data-management.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/anonymize-org/lib.git"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@secrecy/lib-utils": "^1.0.18",
|
|
77
|
-
"@secrecy/trpc-api-types": "1.27.0-feat-
|
|
77
|
+
"@secrecy/trpc-api-types": "1.27.0-feat-add-manage-user-data-and-profiles.1",
|
|
78
78
|
"@trpc/client": "10.45.2",
|
|
79
79
|
"@trpc/server": "10.45.2",
|
|
80
80
|
"@types/libsodium-wrappers-sumo": "^0.7.8",
|