@tstdl/base 0.92.160 → 0.92.162
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/api/types.d.ts +3 -3
- package/authentication/models/authentication-credentials.model.d.ts +2 -2
- package/authentication/models/authentication-session.model.d.ts +2 -2
- package/authentication/server/authentication.service.d.ts +6 -6
- package/authentication/server/authentication.service.js +1 -1
- package/authentication/server/helper.d.ts +5 -5
- package/authentication/server/helper.js +1 -1
- package/document-management/server/services/document-file.service.d.ts +2 -2
- package/document-management/server/services/document.service.d.ts +1 -1
- package/errors/errors.localization.js +72 -71
- package/http/client/http-client-request.d.ts +1 -1
- package/http/http-body.d.ts +2 -2
- package/http/server/node/node-http-server.js +1 -1
- package/http/utils.d.ts +3 -3
- package/image-service/imgproxy/imgproxy-image-service.js +1 -1
- package/injector/injector.js +2 -2
- package/object-storage/object-storage.d.ts +2 -2
- package/object-storage/s3/s3.object-storage.d.ts +2 -2
- package/orm/server/encryption.d.ts +2 -2
- package/orm/server/repository.d.ts +2 -3
- package/orm/server/tokens.d.ts +1 -1
- package/package.json +4 -4
- package/process/spawn.js +4 -4
- package/types/types.d.ts +1 -1
- package/utils/base64.d.ts +3 -3
- package/utils/base64.js +2 -2
- package/utils/binary.js +3 -3
- package/utils/compression.d.ts +4 -4
- package/utils/cryptography.d.ts +9 -9
- package/utils/encoding.d.ts +3 -3
- package/utils/jwt.d.ts +3 -3
- package/utils/random.d.ts +1 -1
- package/utils/stream/slice.js +2 -2
- package/utils/stream/to-bytes-stream.d.ts +1 -1
- package/utils/stream/to-bytes-stream.js +2 -2
- package/utils/type-guards.d.ts +12 -0
- package/utils/type-guards.js +15 -1
package/api/types.d.ts
CHANGED
|
@@ -92,9 +92,9 @@ export type ApiEndpoint<T extends ApiDefinition, K extends ApiEndpointKeys<T>> =
|
|
|
92
92
|
export type ApiEndpointParametersSchema<T extends ApiDefinition, K extends ApiEndpointKeys<T>> = NonUndefinable<ApiEndpoint<T, K>['parameters']>;
|
|
93
93
|
export type ApiEndpointBodySchema<T extends ApiDefinition, K extends ApiEndpointKeys<T>> = NonUndefinable<ApiEndpoint<T, K>['body']>;
|
|
94
94
|
export type ApiEndpointResultSchema<T extends ApiDefinition, K extends ApiEndpointKeys<T>> = NonUndefinable<ApiEndpoint<T, K>['result']>;
|
|
95
|
-
export type ApiBinaryType = typeof Uint8Array | typeof Blob | typeof ReadableStream
|
|
96
|
-
export type ApiInputType<T extends SchemaTestable> = T extends ApiBinaryType ? InstanceType<
|
|
97
|
-
export type ApiOutputType<T extends SchemaTestable> = T extends typeof ReadableStream ? ReadableStream<Uint8Array
|
|
95
|
+
export type ApiBinaryType = typeof Uint8Array | typeof Blob | typeof ReadableStream;
|
|
96
|
+
export type ApiInputType<T extends SchemaTestable> = T extends typeof ReadableStream ? ReadableStream<Uint8Array<ArrayBuffer>> : T extends ApiBinaryType ? InstanceType<T> : T extends typeof ServerSentEvents ? ServerSentEventsSource : T extends typeof DataStream<infer U> ? AsyncIterable<U> : T extends SchemaTestable ? SchemaOutput<T> : never;
|
|
97
|
+
export type ApiOutputType<T extends SchemaTestable> = T extends typeof ReadableStream ? ReadableStream<Uint8Array<ArrayBuffer>> : T extends typeof DataStream<infer U> ? Observable<U> : T extends SchemaTestable ? SchemaOutput<T> : never;
|
|
98
98
|
export type ApiParameters<T extends ApiDefinition, K extends ApiEndpointKeys<T>> = ApiInputType<ApiEndpointParametersSchema<T, K>>;
|
|
99
99
|
export type ApiClientBody<T extends ApiDefinition, K extends ApiEndpointKeys<T>> = ApiInputType<ApiEndpointBodySchema<T, K>>;
|
|
100
100
|
export type ApiServerBody<T extends ApiDefinition, K extends ApiEndpointKeys<T>> = ApiOutputType<ApiEndpointBodySchema<T, K>>;
|
|
@@ -5,9 +5,9 @@ export declare class AuthenticationCredentials extends Entity {
|
|
|
5
5
|
/**
|
|
6
6
|
* The salt used to hash the secret.
|
|
7
7
|
*/
|
|
8
|
-
salt: Uint8Array
|
|
8
|
+
salt: Uint8Array<ArrayBuffer>;
|
|
9
9
|
/**
|
|
10
10
|
* The hashed secret.
|
|
11
11
|
*/
|
|
12
|
-
hash: Uint8Array
|
|
12
|
+
hash: Uint8Array<ArrayBuffer>;
|
|
13
13
|
}
|
|
@@ -8,9 +8,9 @@ export declare class AuthenticationSession extends Entity {
|
|
|
8
8
|
/**
|
|
9
9
|
* The salt used to hash the refresh token.
|
|
10
10
|
*/
|
|
11
|
-
refreshTokenSalt: Uint8Array
|
|
11
|
+
refreshTokenSalt: Uint8Array<ArrayBuffer>;
|
|
12
12
|
/**
|
|
13
13
|
* The hashed refresh token.
|
|
14
14
|
*/
|
|
15
|
-
refreshTokenHash: Uint8Array
|
|
15
|
+
refreshTokenHash: Uint8Array<ArrayBuffer>;
|
|
16
16
|
}
|
|
@@ -34,10 +34,10 @@ export declare class AuthenticationServiceOptions {
|
|
|
34
34
|
* Secrets used for signing tokens and refreshTokens.
|
|
35
35
|
* If single secret is provided, multiple secrets are derived internally.
|
|
36
36
|
*/
|
|
37
|
-
secret: string | BinaryData | {
|
|
38
|
-
tokenSigningSecret: Uint8Array
|
|
39
|
-
refreshTokenSigningSecret: Uint8Array
|
|
40
|
-
secretResetTokenSigningSecret: Uint8Array
|
|
37
|
+
secret: string | BinaryData<ArrayBuffer> | {
|
|
38
|
+
tokenSigningSecret: Uint8Array<ArrayBuffer>;
|
|
39
|
+
refreshTokenSigningSecret: Uint8Array<ArrayBuffer>;
|
|
40
|
+
secretResetTokenSigningSecret: Uint8Array<ArrayBuffer>;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Token version, forces refresh on mismatch (useful if payload changes).
|
|
@@ -108,8 +108,8 @@ type CreateTokenResult<AdditionalTokenPayload extends Record> = {
|
|
|
108
108
|
type CreateRefreshTokenResult = {
|
|
109
109
|
token: string;
|
|
110
110
|
jsonToken: RefreshToken;
|
|
111
|
-
salt: Uint8Array
|
|
112
|
-
hash: Uint8Array
|
|
111
|
+
salt: Uint8Array<ArrayBuffer>;
|
|
112
|
+
hash: Uint8Array<ArrayBuffer>;
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
115
115
|
* Handles authentication on server side.
|
|
@@ -325,7 +325,7 @@ let AuthenticationService = class AuthenticationService {
|
|
|
325
325
|
async changeSecret(subject, currentSecret, newSecret) {
|
|
326
326
|
const authenticationResult = await this.authenticate(subject, currentSecret);
|
|
327
327
|
if (!authenticationResult.success) {
|
|
328
|
-
throw new
|
|
328
|
+
throw new InvalidCredentialsError();
|
|
329
329
|
}
|
|
330
330
|
await this.hooks.beforeChangeSecret.trigger({ subject });
|
|
331
331
|
await this.setCredentials(subject, newSecret);
|
|
@@ -17,7 +17,7 @@ export declare function tryGetAuthorizationTokenStringFromRequest(request: HttpS
|
|
|
17
17
|
* @returns The token or undefined if not found.
|
|
18
18
|
* @throws {InvalidTokenError} If the token is invalid.
|
|
19
19
|
*/
|
|
20
|
-
export declare function tryGetTokenFromRequest<AdditionalTokenPayload extends Record = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload> | undefined>;
|
|
20
|
+
export declare function tryGetTokenFromRequest<AdditionalTokenPayload extends Record = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData<ArrayBuffer>): Promise<Token<AdditionalTokenPayload> | undefined>;
|
|
21
21
|
/**
|
|
22
22
|
* Gets a token from a request.
|
|
23
23
|
* @param request The request to get the token from.
|
|
@@ -26,7 +26,7 @@ export declare function tryGetTokenFromRequest<AdditionalTokenPayload extends Re
|
|
|
26
26
|
* @returns The token.
|
|
27
27
|
* @throws {InvalidTokenError} If the token is invalid or not found.
|
|
28
28
|
*/
|
|
29
|
-
export declare function getTokenFromRequest<AdditionalTokenPayload extends Record = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
|
|
29
|
+
export declare function getTokenFromRequest<AdditionalTokenPayload extends Record = Record<never>>(request: HttpServerRequest, tokenVersion: number, secret: string | BinaryData<ArrayBuffer>): Promise<Token<AdditionalTokenPayload>>;
|
|
30
30
|
/**
|
|
31
31
|
* Gets a token from a token string.
|
|
32
32
|
* @param tokenString The token string to get the token from.
|
|
@@ -35,7 +35,7 @@ export declare function getTokenFromRequest<AdditionalTokenPayload extends Recor
|
|
|
35
35
|
* @returns The token.
|
|
36
36
|
* @throws {InvalidTokenError} If the token is invalid.
|
|
37
37
|
*/
|
|
38
|
-
export declare function getTokenFromString<AdditionalTokenPayload extends Record = Record<never>>(tokenString: string, tokenVersion: number, secret: string | BinaryData): Promise<Token<AdditionalTokenPayload>>;
|
|
38
|
+
export declare function getTokenFromString<AdditionalTokenPayload extends Record = Record<never>>(tokenString: string, tokenVersion: number, secret: string | BinaryData<ArrayBuffer>): Promise<Token<AdditionalTokenPayload>>;
|
|
39
39
|
/**
|
|
40
40
|
* Gets a refresh token from a token string.
|
|
41
41
|
* @param tokenString The token string to get the refresh token from.
|
|
@@ -43,7 +43,7 @@ export declare function getTokenFromString<AdditionalTokenPayload extends Record
|
|
|
43
43
|
* @returns The refresh token.
|
|
44
44
|
* @throws {InvalidTokenError} If the refresh token is invalid.
|
|
45
45
|
*/
|
|
46
|
-
export declare function getRefreshTokenFromString(tokenString: string, secret: string | BinaryData): Promise<RefreshToken>;
|
|
46
|
+
export declare function getRefreshTokenFromString(tokenString: string, secret: string | BinaryData<ArrayBuffer>): Promise<RefreshToken>;
|
|
47
47
|
/**
|
|
48
48
|
* Gets a secret reset token from a token string.
|
|
49
49
|
* @param tokenString The token string to get the secret reset token from.
|
|
@@ -51,4 +51,4 @@ export declare function getRefreshTokenFromString(tokenString: string, secret: s
|
|
|
51
51
|
* @returns The secret reset token.
|
|
52
52
|
* @throws {InvalidTokenError} If the secret reset token is invalid.
|
|
53
53
|
*/
|
|
54
|
-
export declare function getSecretResetTokenFromString(tokenString: string, secret: string | BinaryData): Promise<SecretResetToken>;
|
|
54
|
+
export declare function getSecretResetTokenFromString(tokenString: string, secret: string | BinaryData<ArrayBuffer>): Promise<SecretResetToken>;
|
|
@@ -38,7 +38,7 @@ export async function tryGetTokenFromRequest(request, tokenVersion, secret) {
|
|
|
38
38
|
if (isUndefined(tokenString)) {
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
41
|
-
return getTokenFromString(tokenString, tokenVersion, secret);
|
|
41
|
+
return await getTokenFromString(tokenString, tokenVersion, secret);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Gets a token from a request.
|
|
@@ -21,11 +21,11 @@ export declare class DocumentFileService extends Transactional {
|
|
|
21
21
|
uploadId: string;
|
|
22
22
|
uploadUrl: string;
|
|
23
23
|
}>;
|
|
24
|
-
store(documentId: string, content: Uint8Array | ReadableStream<Uint8Array
|
|
24
|
+
store(documentId: string, content: Uint8Array<ArrayBuffer> | ReadableStream<Uint8Array<ArrayBuffer>>): Promise<DocumentFileMetadata>;
|
|
25
25
|
store(documentId: string, content: {
|
|
26
26
|
uploadId: string;
|
|
27
27
|
uploadKey: string;
|
|
28
|
-
}): Promise<[DocumentFileMetadata, Uint8Array]>;
|
|
28
|
+
}): Promise<[DocumentFileMetadata, Uint8Array<ArrayBuffer>]>;
|
|
29
29
|
getContent(document: Document): Promise<Uint8Array>;
|
|
30
30
|
getContentStream(document: Document): ReadableStream<Uint8Array>;
|
|
31
31
|
getContentUrl(document: Document, download?: boolean): Promise<string>;
|
|
@@ -5,7 +5,7 @@ import type { CreateDocumentParameters, SetDocumentPropertyParameters, UpdateDoc
|
|
|
5
5
|
export declare class DocumentService extends Transactional {
|
|
6
6
|
#private;
|
|
7
7
|
readonly repository: import("../../../orm/server/repository.js").EntityRepository<Document>;
|
|
8
|
-
create(tenantId: string, { typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }: TypedOmit<CreateDocumentParameters, 'uploadId'>, contentSource: Uint8Array | ReadableStream<Uint8Array
|
|
8
|
+
create(tenantId: string, { typeId, title, subtitle, date, summary, tags, approval, comment, originalFileName, assignment, properties, metadata }: TypedOmit<CreateDocumentParameters, 'uploadId'>, contentSource: Uint8Array<ArrayBuffer> | ReadableStream<Uint8Array<ArrayBuffer>> | {
|
|
9
9
|
uploadId: string;
|
|
10
10
|
uploadKey: string;
|
|
11
11
|
}, { createUserId }: {
|
|
@@ -8,65 +8,65 @@ export const germanTstdlErrorsLocalization = {
|
|
|
8
8
|
tstdl: {
|
|
9
9
|
errors: {
|
|
10
10
|
ApiError: {
|
|
11
|
-
header: '
|
|
12
|
-
message: 'Bitte versuchen Sie es
|
|
11
|
+
header: 'Ein Serverfehler ist aufgetreten',
|
|
12
|
+
message: 'Bitte versuchen Sie es in einem Moment erneut. Sollte das Problem weiterhin bestehen, kontaktieren Sie bitte den Support.',
|
|
13
13
|
},
|
|
14
14
|
BadRequestError: {
|
|
15
|
-
header: 'Ungültige
|
|
16
|
-
message:
|
|
15
|
+
header: 'Ungültige Eingabe',
|
|
16
|
+
message: 'Bitte überprüfen Sie die eingegebenen Daten und versuchen Sie es erneut.',
|
|
17
17
|
},
|
|
18
18
|
ForbiddenError: {
|
|
19
|
-
header: 'Zugriff
|
|
20
|
-
message:
|
|
19
|
+
header: 'Zugriff verweigert',
|
|
20
|
+
message: 'Sie haben nicht die erforderlichen Berechtigungen, um diese Aktion auszuführen.',
|
|
21
21
|
},
|
|
22
22
|
InvalidCredentialsError: {
|
|
23
23
|
header: 'Ungültige Zugangsdaten',
|
|
24
|
-
message: '
|
|
24
|
+
message: 'Der Benutzername oder das Passwort ist falsch. Bitte überprüfen Sie Ihre Eingaben.',
|
|
25
25
|
},
|
|
26
26
|
InvalidTokenError: {
|
|
27
|
-
header: '
|
|
28
|
-
message: 'Bitte melden Sie sich erneut an'
|
|
27
|
+
header: 'Sitzung abgelaufen',
|
|
28
|
+
message: 'Ihre Sitzung ist abgelaufen oder ungültig. Bitte melden Sie sich erneut an.',
|
|
29
29
|
},
|
|
30
30
|
MaxBytesExceededError: {
|
|
31
|
-
header: '
|
|
32
|
-
message:
|
|
31
|
+
header: 'Datei zu groß',
|
|
32
|
+
message: 'Die ausgewählte Datei überschreitet die maximal zulässige Größe.',
|
|
33
33
|
},
|
|
34
34
|
MethodNotAllowedError: {
|
|
35
|
-
header: '
|
|
36
|
-
message:
|
|
35
|
+
header: 'Unerwarteter Fehler',
|
|
36
|
+
message: 'Ein interner Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.',
|
|
37
37
|
},
|
|
38
38
|
NotFoundError: {
|
|
39
39
|
header: 'Nicht gefunden',
|
|
40
|
-
message:
|
|
40
|
+
message: 'Das gesuchte Element konnte nicht gefunden werden. Möglicherweise wurde es verschoben oder gelöscht.',
|
|
41
41
|
},
|
|
42
42
|
NotImplementedError: {
|
|
43
|
-
header: 'Funktion nicht
|
|
44
|
-
message:
|
|
43
|
+
header: 'Funktion nicht verfügbar',
|
|
44
|
+
message: 'Diese Funktion ist noch nicht verfügbar. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut.',
|
|
45
45
|
},
|
|
46
46
|
NotSupportedError: {
|
|
47
|
-
header: '
|
|
48
|
-
message:
|
|
47
|
+
header: 'Aktion nicht unterstützt',
|
|
48
|
+
message: 'Die angeforderte Aktion wird nicht unterstützt.',
|
|
49
49
|
},
|
|
50
50
|
TimeoutError: {
|
|
51
|
-
header: 'Zeitüberschreitung',
|
|
52
|
-
message:
|
|
51
|
+
header: 'Zeitüberschreitung der Anfrage',
|
|
52
|
+
message: 'Der Server hat zu lange für eine Antwort gebraucht. Bitte überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.',
|
|
53
53
|
},
|
|
54
54
|
UnauthorizedError: {
|
|
55
|
-
header: '
|
|
56
|
-
message:
|
|
55
|
+
header: 'Anmeldung erforderlich',
|
|
56
|
+
message: 'Sie müssen angemeldet sein, um diese Aktion auszuführen. Bitte melden Sie sich an.',
|
|
57
57
|
},
|
|
58
58
|
HttpError: {
|
|
59
59
|
header: (error) => ((isDefined(error.response) && error.response.statusCode != 0)
|
|
60
|
-
? `
|
|
61
|
-
: '
|
|
62
|
-
message: getHttpErrorMessage
|
|
60
|
+
? `Fehler ${error.response.statusCode.toString()}`
|
|
61
|
+
: 'Verbindungsfehler'),
|
|
62
|
+
message: getHttpErrorMessage,
|
|
63
63
|
},
|
|
64
64
|
SecretRequirementsError: {
|
|
65
|
-
header: '
|
|
66
|
-
message: getErrorMessage
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
65
|
+
header: 'Passwort zu schwach',
|
|
66
|
+
message: getErrorMessage,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
70
|
},
|
|
71
71
|
enums: [
|
|
72
72
|
enumerationLocalization(HttpErrorReason, {
|
|
@@ -77,9 +77,9 @@ export const germanTstdlErrorsLocalization = {
|
|
|
77
77
|
[HttpErrorReason.StatusCode]: 'Antwort enthielt einen Fehler',
|
|
78
78
|
[HttpErrorReason.ErrorResponse]: 'Antwort enthielt einen Fehler',
|
|
79
79
|
[HttpErrorReason.ResponseError]: 'Fehler beim Empfang der Antwort',
|
|
80
|
-
[HttpErrorReason.Timeout]: 'Zeitüberschreitung'
|
|
81
|
-
})
|
|
82
|
-
]
|
|
80
|
+
[HttpErrorReason.Timeout]: 'Zeitüberschreitung',
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
83
|
};
|
|
84
84
|
export const englishTstdlErrorsLocalization = {
|
|
85
85
|
language: { code: 'en', name: 'English' },
|
|
@@ -87,65 +87,65 @@ export const englishTstdlErrorsLocalization = {
|
|
|
87
87
|
tstdl: {
|
|
88
88
|
errors: {
|
|
89
89
|
ApiError: {
|
|
90
|
-
header: '
|
|
91
|
-
message: 'Please try again
|
|
90
|
+
header: 'A Server Error Occurred',
|
|
91
|
+
message: 'Please try again in a moment. If the problem persists, please contact support.',
|
|
92
92
|
},
|
|
93
93
|
BadRequestError: {
|
|
94
|
-
header: '
|
|
95
|
-
message:
|
|
94
|
+
header: 'Invalid Information',
|
|
95
|
+
message: 'Please check the information you entered and try again.',
|
|
96
96
|
},
|
|
97
97
|
ForbiddenError: {
|
|
98
|
-
header: '
|
|
99
|
-
message:
|
|
98
|
+
header: 'Permission Denied',
|
|
99
|
+
message: 'You do not have the necessary permissions to perform this action.',
|
|
100
100
|
},
|
|
101
101
|
InvalidCredentialsError: {
|
|
102
|
-
header: 'Invalid
|
|
103
|
-
message: '
|
|
102
|
+
header: 'Invalid Credentials',
|
|
103
|
+
message: 'The username or password you entered is incorrect. Please check your details.',
|
|
104
104
|
},
|
|
105
105
|
InvalidTokenError: {
|
|
106
|
-
header: '
|
|
107
|
-
message: 'Please log in again'
|
|
106
|
+
header: 'Session Expired',
|
|
107
|
+
message: 'Your session has expired or is invalid. Please log in again.',
|
|
108
108
|
},
|
|
109
109
|
MaxBytesExceededError: {
|
|
110
|
-
header: '
|
|
111
|
-
message:
|
|
110
|
+
header: 'File Too Large',
|
|
111
|
+
message: 'The selected file exceeds the maximum allowed size.',
|
|
112
112
|
},
|
|
113
113
|
MethodNotAllowedError: {
|
|
114
|
-
header: '
|
|
115
|
-
message:
|
|
114
|
+
header: 'Unexpected Error',
|
|
115
|
+
message: 'An internal error occurred. Please try again later.',
|
|
116
116
|
},
|
|
117
117
|
NotFoundError: {
|
|
118
|
-
header: 'Not
|
|
119
|
-
message:
|
|
118
|
+
header: 'Not Found',
|
|
119
|
+
message: 'The item you are looking for could not be found. It may have been moved or deleted.',
|
|
120
120
|
},
|
|
121
121
|
NotImplementedError: {
|
|
122
|
-
header: '
|
|
123
|
-
message:
|
|
122
|
+
header: 'Feature Not Available',
|
|
123
|
+
message: 'This feature is not yet available. Please check back later.',
|
|
124
124
|
},
|
|
125
125
|
NotSupportedError: {
|
|
126
|
-
header: '
|
|
127
|
-
message:
|
|
126
|
+
header: 'Unsupported Action',
|
|
127
|
+
message: 'The requested action is not supported.',
|
|
128
128
|
},
|
|
129
129
|
TimeoutError: {
|
|
130
|
-
header: '
|
|
131
|
-
message:
|
|
130
|
+
header: 'Request Timed Out',
|
|
131
|
+
message: 'The server took too long to respond. Please check your internet connection and try again.',
|
|
132
132
|
},
|
|
133
133
|
UnauthorizedError: {
|
|
134
|
-
header: '
|
|
135
|
-
message:
|
|
134
|
+
header: 'Authentication Required',
|
|
135
|
+
message: 'You must be logged in to perform this action. Please log in.',
|
|
136
136
|
},
|
|
137
137
|
HttpError: {
|
|
138
138
|
header: (error) => ((isDefined(error.response) && error.response.statusCode != 0)
|
|
139
|
-
? `
|
|
140
|
-
: '
|
|
141
|
-
message: getHttpErrorMessage
|
|
139
|
+
? `Error ${error.response.statusCode.toString()}`
|
|
140
|
+
: 'Connection Error'),
|
|
141
|
+
message: getHttpErrorMessage,
|
|
142
142
|
},
|
|
143
143
|
SecretRequirementsError: {
|
|
144
|
-
header: '
|
|
145
|
-
message: getErrorMessage
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
144
|
+
header: 'Password Is Too Weak',
|
|
145
|
+
message: getErrorMessage,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
149
|
},
|
|
150
150
|
enums: [
|
|
151
151
|
enumerationLocalization(HttpErrorReason, {
|
|
@@ -156,14 +156,15 @@ export const englishTstdlErrorsLocalization = {
|
|
|
156
156
|
[HttpErrorReason.StatusCode]: 'Response contained an error',
|
|
157
157
|
[HttpErrorReason.ErrorResponse]: 'Response contained an error',
|
|
158
158
|
[HttpErrorReason.ResponseError]: 'Error while receiving the response',
|
|
159
|
-
[HttpErrorReason.Timeout]: '
|
|
160
|
-
})
|
|
161
|
-
]
|
|
159
|
+
[HttpErrorReason.Timeout]: 'Timeout',
|
|
160
|
+
}),
|
|
161
|
+
],
|
|
162
162
|
};
|
|
163
163
|
function getHttpErrorMessage(error, context) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
if (isDefined(error.response) && isNotNull(error.response.statusMessage)) {
|
|
165
|
+
return error.response.statusMessage;
|
|
166
|
+
}
|
|
167
|
+
return context.localizationService.localizeOnce({ enum: HttpErrorReason, value: error.reason });
|
|
167
168
|
}
|
|
168
169
|
function getErrorMessage(error) {
|
|
169
170
|
return error.message.replace(/\.$/u, '');
|
|
@@ -22,7 +22,7 @@ export type HttpRequestAuthorization = {
|
|
|
22
22
|
bearer?: string;
|
|
23
23
|
token?: string;
|
|
24
24
|
};
|
|
25
|
-
export type HttpFormDataObjectValue = string | number | boolean | Uint8Array | Blob;
|
|
25
|
+
export type HttpFormDataObjectValue = string | number | boolean | Uint8Array<ArrayBuffer> | Blob;
|
|
26
26
|
export type HttpFormDataObject = Record<string, OneOrMany<HttpFormDataObjectValue>>;
|
|
27
27
|
export type HttpClientRequestOptions = Partial<TypedOmit<HttpClientRequest, 'url' | 'method' | 'abortSignal' | 'abort' | 'headers' | 'query' | 'body'>> & {
|
|
28
28
|
urlParameter?: HttpUrlParametersObject | HttpUrlParameters;
|
package/http/http-body.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { UndefinableJson } from '../types/index.js';
|
|
|
2
2
|
import type { AnyIterable } from '../utils/any-iterable-iterator.js';
|
|
3
3
|
import type { HttpHeaders } from './http-headers.js';
|
|
4
4
|
import type { ReadBodyOptions } from './utils.js';
|
|
5
|
-
export type HttpBodySource = undefined | Uint8Array | Blob | AnyIterable<Uint8Array
|
|
5
|
+
export type HttpBodySource = undefined | Uint8Array<ArrayBuffer> | Blob | AnyIterable<Uint8Array<ArrayBuffer>> | ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
6
6
|
export declare class HttpBody {
|
|
7
7
|
private readonly body;
|
|
8
8
|
private readonly headers;
|
|
@@ -10,7 +10,7 @@ export declare class HttpBody {
|
|
|
10
10
|
get available(): boolean;
|
|
11
11
|
get byteLength(): number | undefined;
|
|
12
12
|
constructor(body: HttpBodySource, headers: HttpHeaders);
|
|
13
|
-
readAsBuffer(options?: ReadBodyOptions): Promise<Uint8Array
|
|
13
|
+
readAsBuffer(options?: ReadBodyOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
14
14
|
readAsText(options?: ReadBodyOptions): Promise<string>;
|
|
15
15
|
readAsJson<T = UndefinableJson>(options?: ReadBodyOptions): Promise<T>;
|
|
16
16
|
read(options?: ReadBodyOptions): Promise<string | UndefinableJson | Uint8Array>;
|
|
@@ -145,7 +145,7 @@ function writeHeaders(response, httpResponse) {
|
|
|
145
145
|
}
|
|
146
146
|
async function writeResponseBody(response, httpResponse) {
|
|
147
147
|
const simpleData = match(response.body)
|
|
148
|
-
.with({ json: P.select(P.
|
|
148
|
+
.with({ json: P.select(P.when(isDefined)) }, (json) => JSON.stringify(json))
|
|
149
149
|
.with({ text: P.select(P.nonNullable) }, (text) => text)
|
|
150
150
|
.with({ buffer: P.select(P.nonNullable) }, (buffer) => buffer)
|
|
151
151
|
.otherwise(() => undefined);
|
package/http/utils.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { HttpHeaders } from '../http/http-headers.js';
|
|
2
2
|
import type { UndefinableJson } from '../types/index.js';
|
|
3
3
|
import type { AnyIterable } from '../utils/any-iterable-iterator.js';
|
|
4
|
-
type Body = Uint8Array | Blob | AnyIterable<Uint8Array
|
|
4
|
+
type Body = Uint8Array<ArrayBuffer> | Blob | AnyIterable<Uint8Array<ArrayBuffer>> | ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
5
5
|
export type ReadBodyOptions = {
|
|
6
6
|
maxBytes?: number;
|
|
7
7
|
};
|
|
8
8
|
export type ReadBodyAsJsonOptions = ReadBodyOptions & {
|
|
9
9
|
fallbackToText?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare function readBodyAsBinaryStream(body: Body, headers: HttpHeaders, options?: ReadBodyOptions): ReadableStream<Uint8Array
|
|
12
|
-
export declare function readBodyAsBuffer(body: Body, headers: HttpHeaders, options?: ReadBodyOptions): Promise<Uint8Array
|
|
11
|
+
export declare function readBodyAsBinaryStream(body: Body, headers: HttpHeaders, options?: ReadBodyOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
12
|
+
export declare function readBodyAsBuffer(body: Body, headers: HttpHeaders, options?: ReadBodyOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
13
13
|
export declare function readBodyAsText(body: Body, headers: HttpHeaders, options?: ReadBodyOptions): Promise<string>;
|
|
14
14
|
export declare function readBodyAsTextStream(body: Body, headers: HttpHeaders, options?: ReadBodyOptions): ReadableStream<string>;
|
|
15
15
|
export declare function readBodyAsJson(body: Body, headers: HttpHeaders, options?: ReadBodyAsJsonOptions): Promise<UndefinableJson>;
|
|
@@ -58,7 +58,7 @@ let ImgproxyImageService = class ImgproxyImageService extends ImageService {
|
|
|
58
58
|
};
|
|
59
59
|
ImgproxyImageService = __decorate([
|
|
60
60
|
Singleton({
|
|
61
|
-
defaultArgumentProvider: (context) => context.resolve(IMGPROXY_IMAGE_SERVICE_CONFIG)
|
|
61
|
+
defaultArgumentProvider: (context) => context.resolve(IMGPROXY_IMAGE_SERVICE_CONFIG),
|
|
62
62
|
}),
|
|
63
63
|
__param(0, InjectArg('endpoint')),
|
|
64
64
|
__param(1, InjectArg('key')),
|
package/injector/injector.js
CHANGED
|
@@ -271,7 +271,7 @@ export class Injector {
|
|
|
271
271
|
if (isDefined(options.forwardRef) && (options.forwardRef != false)) {
|
|
272
272
|
assert(options.optional != true, 'ForwardRef does not support optional without resolveAll/injectAll as undefined is not forwardable.');
|
|
273
273
|
const forwardToken = isFunction(options.forwardRef) ? options.forwardRef() : token;
|
|
274
|
-
const forwardRef = ForwardRef.create({ typeHint:
|
|
274
|
+
const forwardRef = ForwardRef.create({ typeHint: options.forwardRefTypeHint ?? isFunction(forwardToken) ? forwardToken : undefined });
|
|
275
275
|
context.forwardRefQueue.add(() => ForwardRef.setRef(forwardRef, this._resolve(forwardToken, argument, { ...options, forwardRef: false }, context, chain.markAsForwardRef(forwardToken))));
|
|
276
276
|
context.forwardRefs.add(forwardRef);
|
|
277
277
|
return forwardRef;
|
|
@@ -296,7 +296,7 @@ export class Injector {
|
|
|
296
296
|
this.assertNotDisposed();
|
|
297
297
|
if (isDefined(options.forwardRef) && (options.forwardRef != false)) {
|
|
298
298
|
const forwardToken = isFunction(options.forwardRef) ? options.forwardRef() : token;
|
|
299
|
-
const forwardRef = ForwardRef.create({ typeHint:
|
|
299
|
+
const forwardRef = ForwardRef.create({ typeHint: options.forwardRefTypeHint ?? isFunction(forwardToken) ? forwardToken : undefined });
|
|
300
300
|
context.forwardRefQueue.add(() => ForwardRef.setRef(forwardRef, this._resolveAll(forwardToken, argument, { ...options, forwardRef: false }, context, chain.markAsForwardRef(forwardToken))));
|
|
301
301
|
context.forwardRefs.add(forwardRef);
|
|
302
302
|
return forwardRef;
|
|
@@ -87,12 +87,12 @@ export declare abstract class ObjectStorage implements Resolvable<ObjectStorageA
|
|
|
87
87
|
* Get object content
|
|
88
88
|
* @param key object key
|
|
89
89
|
*/
|
|
90
|
-
abstract getContent(key: string): Promise<Uint8Array
|
|
90
|
+
abstract getContent(key: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
91
91
|
/**
|
|
92
92
|
* Get stream of object content
|
|
93
93
|
* @param key object key
|
|
94
94
|
*/
|
|
95
|
-
abstract getContentStream(key: string): ReadableStream<Uint8Array
|
|
95
|
+
abstract getContentStream(key: string): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
96
96
|
/**
|
|
97
97
|
* Get an url which can be used to download the object without further authorization
|
|
98
98
|
* @param key object key
|
|
@@ -15,8 +15,8 @@ export declare class S3ObjectStorage extends ObjectStorage {
|
|
|
15
15
|
uploadObject(key: string, content: Uint8Array | ReadableStream<Uint8Array>, options?: UploadObjectOptions): Promise<void>;
|
|
16
16
|
copyObject(source: string, destination: string | [ObjectStorage, string], options?: CopyObjectOptions): Promise<void>;
|
|
17
17
|
moveObject(sourceKey: string, destinationKey: string | [ObjectStorage, string], options?: MoveObjectOptions): Promise<void>;
|
|
18
|
-
getContent(key: string): Promise<Uint8Array
|
|
19
|
-
getContentStream(key: string): ReadableStream<Uint8Array
|
|
18
|
+
getContent(key: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
19
|
+
getContentStream(key: string): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
20
20
|
getObjects(): Promise<S3Object[]>;
|
|
21
21
|
getObjectsCursor(): AsyncIterable<S3Object>;
|
|
22
22
|
getObject(key: string): Promise<S3Object>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param key The CryptoKey to use for encryption.
|
|
6
6
|
* @returns A promise that resolves to the encrypted byte array (version + IV + ciphertext).
|
|
7
7
|
*/
|
|
8
|
-
export declare function encryptBytes(bytes: Uint8Array
|
|
8
|
+
export declare function encryptBytes(bytes: Uint8Array<ArrayBuffer>, key: CryptoKey): Promise<Uint8Array>;
|
|
9
9
|
/**
|
|
10
10
|
* Decrypts a byte array encrypted with `encryptBytes`.
|
|
11
11
|
* Reads the version and IV from the beginning of the array.
|
|
@@ -15,4 +15,4 @@ export declare function encryptBytes(bytes: Uint8Array, key: CryptoKey): Promise
|
|
|
15
15
|
* @throws {DetailsError} If decryption fails (e.g., wrong key, corrupted data).
|
|
16
16
|
* @throws {Error} If the encryption version is invalid.
|
|
17
17
|
*/
|
|
18
|
-
export declare function decryptBytes(bytes: Uint8Array, key: CryptoKey): Promise<Uint8Array
|
|
18
|
+
export declare function decryptBytes(bytes: Uint8Array, key: CryptoKey): Promise<Uint8Array<ArrayBuffer>>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { SQL } from 'drizzle-orm';
|
|
2
2
|
import type { PgColumn, PgInsertValue, PgUpdateSetSource } from 'drizzle-orm/pg-core';
|
|
3
3
|
import { type Resolvable, resolveArgumentType } from '../../injector/interfaces.js';
|
|
4
|
-
import type { DeepPartial, OneOrMany, Paths, Type } from '../../types/index.js';
|
|
5
|
-
import type { UntaggedDeep } from '../../types/index.js';
|
|
4
|
+
import type { DeepPartial, OneOrMany, Paths, Type, UntaggedDeep } from '../../types/index.js';
|
|
6
5
|
import { Entity, type EntityMetadataAttributes, type EntityType, type EntityWithoutMetadata } from '../entity.js';
|
|
7
6
|
import type { Query } from '../query.js';
|
|
8
7
|
import type { EntityMetadataUpdate, EntityUpdate, LoadManyOptions, LoadOptions, NewEntity, Order, TargetColumnPaths } from '../repository.types.js';
|
|
@@ -24,7 +23,7 @@ type EntityRepositoryContext = {
|
|
|
24
23
|
table: PgTableFromType;
|
|
25
24
|
columnDefinitions: ColumnDefinition[];
|
|
26
25
|
columnDefinitionsMap: Map<string, ColumnDefinition>;
|
|
27
|
-
encryptionSecret: Uint8Array | undefined;
|
|
26
|
+
encryptionSecret: Uint8Array<ArrayBuffer> | undefined;
|
|
28
27
|
transformContext: TransformContext | Promise<TransformContext> | undefined;
|
|
29
28
|
};
|
|
30
29
|
type InferSelect<T extends Entity | EntityWithoutMetadata = Entity | EntityWithoutMetadata> = PgTableFromType<EntityType<T>>['$inferSelect'];
|
package/orm/server/tokens.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ENCRYPTION_SECRET: import("../../injector/token.js").InjectionToken<Uint8Array<
|
|
1
|
+
export declare const ENCRYPTION_SECRET: import("../../injector/token.js").InjectionToken<Uint8Array<ArrayBuffer>, never>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.92.
|
|
3
|
+
"version": "0.92.162",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -165,9 +165,9 @@
|
|
|
165
165
|
"mongodb": "^6.18",
|
|
166
166
|
"nodemailer": "^7.0",
|
|
167
167
|
"pg": "^8.16",
|
|
168
|
-
"playwright": "^1.
|
|
168
|
+
"playwright": "^1.55",
|
|
169
169
|
"preact": "^10.27",
|
|
170
|
-
"preact-render-to-string": "^6.
|
|
170
|
+
"preact-render-to-string": "^6.6",
|
|
171
171
|
"sharp": "^0.34",
|
|
172
172
|
"undici": "^7.14",
|
|
173
173
|
"urlpattern-polyfill": "^10.1"
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
"typedoc-github-wiki-theme": "2.1",
|
|
197
197
|
"typedoc-plugin-markdown": "4.8",
|
|
198
198
|
"typedoc-plugin-missing-exports": "4.1",
|
|
199
|
-
"typescript": "5.
|
|
199
|
+
"typescript": "5.9",
|
|
200
200
|
"typescript-eslint": "8.40"
|
|
201
201
|
},
|
|
202
202
|
"overrides": {
|
package/process/spawn.js
CHANGED
|
@@ -33,16 +33,16 @@ export async function spawnCommand(command, args) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
async function readOutputBytes() {
|
|
36
|
-
return readBinaryStream(readable);
|
|
36
|
+
return await readBinaryStream(readable);
|
|
37
37
|
}
|
|
38
38
|
async function readOutput() {
|
|
39
|
-
return readTextStream(readable.pipeThrough(decodeTextStream()));
|
|
39
|
+
return await readTextStream(readable.pipeThrough(decodeTextStream()));
|
|
40
40
|
}
|
|
41
41
|
async function readErrorBytes() {
|
|
42
|
-
return readBinaryStream(stderr);
|
|
42
|
+
return await readBinaryStream(stderr);
|
|
43
43
|
}
|
|
44
44
|
async function readError() {
|
|
45
|
-
return readTextStream(stderr.pipeThrough(decodeTextStream()));
|
|
45
|
+
return await readTextStream(stderr.pipeThrough(decodeTextStream()));
|
|
46
46
|
}
|
|
47
47
|
const signalPromise = new Promise((resolve) => process.on('close', (code, signal) => resolve({ code, signal })));
|
|
48
48
|
const nonZeroExitCodeError = new LazyPromise(async () => {
|
package/types/types.d.ts
CHANGED
|
@@ -190,7 +190,7 @@ export type DeepPartialObject<T> = {
|
|
|
190
190
|
};
|
|
191
191
|
export type DeepPartialArray<T> = DeepPartial<T>[];
|
|
192
192
|
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
193
|
-
export type BinaryData =
|
|
193
|
+
export type BinaryData<T extends ArrayBufferLike = ArrayBufferLike> = ArrayBufferView<T> | T;
|
|
194
194
|
export type Paths<T extends Record> = T extends object ? {
|
|
195
195
|
[K in keyof T]-?: K extends string | number ? `${K}` | `${K}.${Paths<T[K]>}` : never;
|
|
196
196
|
}[keyof T] : never;
|
package/utils/base64.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { BinaryData } from '../types/index.js';
|
|
2
2
|
export declare function encodeBase64(array: BinaryData, bytesOffset?: number, bytesLength?: number): string;
|
|
3
|
-
export declare function decodeBase64(base64: string): Uint8Array
|
|
3
|
+
export declare function decodeBase64(base64: string): Uint8Array<ArrayBuffer>;
|
|
4
4
|
export declare function encodeBase64Url(array: BinaryData, bytesOffset?: number, length?: number): string;
|
|
5
|
-
export declare function decodeBase64Url(base64Url: string): Uint8Array
|
|
5
|
+
export declare function decodeBase64Url(base64Url: string): Uint8Array<ArrayBuffer>;
|
|
6
6
|
export declare function base64ToBase64Url(input: string): string;
|
|
7
7
|
export declare function base64UrlToBase64(input: string): string;
|
|
8
8
|
export declare function utf8ArrayToString(bytes: Uint8Array): string;
|
|
9
|
-
export declare function stringToUtf8Array(string: string): Uint8Array
|
|
9
|
+
export declare function stringToUtf8Array(string: string): Uint8Array<ArrayBuffer>;
|
package/utils/base64.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers, no-bitwise */
|
|
2
2
|
import { supportsBuffer } from '../supports.js';
|
|
3
3
|
import { toUint8Array } from './binary.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isArrayBufferLike, isDefined } from './type-guards.js';
|
|
5
5
|
export function encodeBase64(array, bytesOffset, bytesLength) {
|
|
6
6
|
let arrayBuffer;
|
|
7
7
|
let offset;
|
|
8
8
|
let length;
|
|
9
|
-
if (
|
|
9
|
+
if (isArrayBufferLike(array)) {
|
|
10
10
|
arrayBuffer = array;
|
|
11
11
|
}
|
|
12
12
|
else {
|
package/utils/binary.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { supportsBuffer } from '../supports.js';
|
|
2
|
-
import { assert,
|
|
2
|
+
import { assert, isArrayBufferLike, isUint8Array } from './type-guards.js';
|
|
3
3
|
/**
|
|
4
4
|
* Get ArrayBuffer from binary data
|
|
5
5
|
* @param data data to get ArrayBuffer from
|
|
6
6
|
* @param clone force cloning (might still clone if datas underlying buffer is larger than its view)
|
|
7
7
|
*/
|
|
8
8
|
export function toArrayBuffer(data, clone = false) {
|
|
9
|
-
if (
|
|
9
|
+
if (isArrayBufferLike(data)) {
|
|
10
10
|
return clone ? data.slice(0) : data;
|
|
11
11
|
}
|
|
12
12
|
if (!clone && (data.byteOffset == 0) && (data.byteLength == data.buffer.byteLength)) {
|
|
@@ -20,7 +20,7 @@ export function toArrayBuffer(data, clone = false) {
|
|
|
20
20
|
* @param clone whether to clone buffer or not
|
|
21
21
|
*/
|
|
22
22
|
export function toUint8Array(data, clone = false) {
|
|
23
|
-
if (
|
|
23
|
+
if (isArrayBufferLike(data)) {
|
|
24
24
|
return clone
|
|
25
25
|
? new Uint8Array(data.slice(0))
|
|
26
26
|
: new Uint8Array(data);
|
package/utils/compression.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as NodeStream from 'node:stream';
|
|
2
2
|
import type * as NodeZlib from 'node:zlib';
|
|
3
3
|
export interface CompressionResult {
|
|
4
|
-
toBuffer(): Promise<Uint8Array
|
|
4
|
+
toBuffer(): Promise<Uint8Array<ArrayBuffer>>;
|
|
5
5
|
toHex(): Promise<string>;
|
|
6
6
|
toBase64(): Promise<string>;
|
|
7
7
|
toBase64Url(): Promise<string>;
|
|
@@ -23,6 +23,6 @@ export declare function decompressString(input: string, encoding: BufferEncoding
|
|
|
23
23
|
export declare function decompress(buffer: NodeZlib.InputType, algorithm: 'gzip' | 'deflate' | 'deflate-raw', options?: NodeZlib.ZlibOptions): DecompressionResult;
|
|
24
24
|
export declare function decompress(buffer: NodeZlib.InputType, algorithm: 'brotli', options?: NodeZlib.BrotliOptions): DecompressionResult;
|
|
25
25
|
export declare function decompress(buffer: NodeZlib.InputType, algorithm: CompressionAlgorithm, options?: NodeZlib.ZlibOptions | NodeZlib.BrotliOptions): DecompressionResult;
|
|
26
|
-
export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: 'gzip' | 'deflate' | 'deflate-raw', options?: NodeZlib.ZlibOptions): ReadableStream<Uint8Array
|
|
27
|
-
export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: 'brotli', options?: NodeZlib.BrotliOptions): ReadableStream<Uint8Array
|
|
28
|
-
export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: CompressionAlgorithm, options?: NodeZlib.ZlibOptions | NodeZlib.BrotliOptions): ReadableStream<Uint8Array
|
|
26
|
+
export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: 'gzip' | 'deflate' | 'deflate-raw', options?: NodeZlib.ZlibOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
27
|
+
export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: 'brotli', options?: NodeZlib.BrotliOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
28
|
+
export declare function decompressStream(stream: NodeStream.Readable | ReadableStream, algorithm: CompressionAlgorithm, options?: NodeZlib.ZlibOptions | NodeZlib.BrotliOptions): ReadableStream<Uint8Array<ArrayBuffer>>;
|
package/utils/cryptography.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type SignAlgorithm = Parameters<typeof globalThis.crypto.subtle.sign>[0];
|
|
|
10
10
|
export type KeyAlgorithm = Parameters<typeof globalThis.crypto.subtle.generateKey>[0];
|
|
11
11
|
export type DeriveAlgorithm = Parameters<typeof globalThis.crypto.subtle.deriveBits>['0'];
|
|
12
12
|
export type KeyType = 'raw' | 'pkcs8' | 'spki' | 'jwk';
|
|
13
|
-
export type Key = JsonWebKey | BinaryData
|
|
13
|
+
export type Key = JsonWebKey | BinaryData<ArrayBuffer>;
|
|
14
14
|
export type ScryptOptions = {
|
|
15
15
|
cost?: number;
|
|
16
16
|
blockSize?: number;
|
|
@@ -35,27 +35,27 @@ export type SignResult = CryptionResult;
|
|
|
35
35
|
* @param key key
|
|
36
36
|
* @param data data to encrypt. Encodes string to utf8
|
|
37
37
|
*/
|
|
38
|
-
export declare function encrypt(algorithm: CryptionAlgorithm, key: CryptoKey, data: BinaryData | string): CryptionResult;
|
|
38
|
+
export declare function encrypt(algorithm: CryptionAlgorithm, key: CryptoKey, data: BinaryData<ArrayBuffer> | string): CryptionResult;
|
|
39
39
|
/**
|
|
40
40
|
* Decrypt data
|
|
41
41
|
* @param algorithm algorithm as supported by Web Crypto API
|
|
42
42
|
* @param key key
|
|
43
43
|
* @param data data to decrypt
|
|
44
44
|
*/
|
|
45
|
-
export declare function decrypt(algorithm: CryptionAlgorithm, key: CryptoKey, bytes: BinaryData): DecryptionResult;
|
|
45
|
+
export declare function decrypt(algorithm: CryptionAlgorithm, key: CryptoKey, bytes: BinaryData<ArrayBuffer>): DecryptionResult;
|
|
46
46
|
/**
|
|
47
47
|
* Hashes data
|
|
48
48
|
* @param algorithm algorithm as supported by Web Crypto API
|
|
49
49
|
* @param data data to encrypt. Encodes string to utf8
|
|
50
50
|
*/
|
|
51
|
-
export declare function digest(algorithm: HashAlgorithmIdentifier, data: BinaryData | string): DigestResult;
|
|
51
|
+
export declare function digest(algorithm: HashAlgorithmIdentifier, data: BinaryData<ArrayBuffer> | string): DigestResult;
|
|
52
52
|
/**
|
|
53
53
|
* Signs data
|
|
54
54
|
* @param algorithm algorithm as supported by Web Crypto API
|
|
55
55
|
* @param key key
|
|
56
56
|
* @param data data to sign
|
|
57
57
|
*/
|
|
58
|
-
export declare function sign(algorithm: SignAlgorithm, key: CryptoKey, data: BinaryData | string): SignResult;
|
|
58
|
+
export declare function sign(algorithm: SignAlgorithm, key: CryptoKey, data: BinaryData<ArrayBuffer> | string): SignResult;
|
|
59
59
|
/**
|
|
60
60
|
* Verifies data
|
|
61
61
|
* @param algorithm algorithm as supported by Web Crypto API
|
|
@@ -63,7 +63,7 @@ export declare function sign(algorithm: SignAlgorithm, key: CryptoKey, data: Bin
|
|
|
63
63
|
* @param signature signature
|
|
64
64
|
* @param data data to verify using provided signature
|
|
65
65
|
*/
|
|
66
|
-
export declare function verify(algorithm: SignAlgorithm, key: CryptoKey, signature: BinaryData | string, data: BinaryData | string): Promise<boolean>;
|
|
66
|
+
export declare function verify(algorithm: SignAlgorithm, key: CryptoKey, signature: BinaryData<ArrayBuffer> | string, data: BinaryData<ArrayBuffer> | string): Promise<boolean>;
|
|
67
67
|
/**
|
|
68
68
|
* Imports a HMAC CryptoKey
|
|
69
69
|
* @param algorithm hash algorithm
|
|
@@ -91,7 +91,7 @@ export declare function importEcdsaKey(curve: EcdsaCurve, key: Key | string, ext
|
|
|
91
91
|
* @param key binary key
|
|
92
92
|
* @param extractable whether the key can be used for exportKey
|
|
93
93
|
*/
|
|
94
|
-
export declare function importPbkdf2Key(key: BinaryData | string, extractable?: boolean): Promise<CryptoKey>;
|
|
94
|
+
export declare function importPbkdf2Key(key: BinaryData<ArrayBuffer> | string, extractable?: boolean): Promise<CryptoKey>;
|
|
95
95
|
/**
|
|
96
96
|
* Generates a new ECDSA CryptoKeyPair
|
|
97
97
|
* @param curve ECDSA cruve to use
|
|
@@ -118,5 +118,5 @@ export declare function deriveBytes(algorithm: DeriveAlgorithm, baseKey: CryptoK
|
|
|
118
118
|
* @param length length of each Uint8Array in bytes, if single number is provided, it is used for every array
|
|
119
119
|
* @param count how many Uint8Arrays to derive
|
|
120
120
|
*/
|
|
121
|
-
export declare function deriveBytesMultiple<const Lengths extends readonly number[]>(algorithm: DeriveAlgorithm, baseKey: CryptoKey, lengths: Lengths): Promise<ReadonlyTuple<Uint8Array
|
|
122
|
-
export declare function deriveBytesMultiple<const C extends number>(algorithm: DeriveAlgorithm, baseKey: CryptoKey, length: C, count: number): Promise<ReadonlyTuple<Uint8Array
|
|
121
|
+
export declare function deriveBytesMultiple<const Lengths extends readonly number[]>(algorithm: DeriveAlgorithm, baseKey: CryptoKey, lengths: Lengths): Promise<ReadonlyTuple<Uint8Array<ArrayBuffer>, Lengths['length']>>;
|
|
122
|
+
export declare function deriveBytesMultiple<const C extends number>(algorithm: DeriveAlgorithm, baseKey: CryptoKey, length: C, count: number): Promise<ReadonlyTuple<Uint8Array<ArrayBuffer>, C>>;
|
package/utils/encoding.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ import type { BinaryData } from '../types/index.js';
|
|
|
4
4
|
* @param text text to encode
|
|
5
5
|
* @returns utf8 encoded text
|
|
6
6
|
*/
|
|
7
|
-
export declare function encodeUtf8(text: string): Uint8Array
|
|
7
|
+
export declare function encodeUtf8(text: string): Uint8Array<ArrayBuffer>;
|
|
8
8
|
/**
|
|
9
9
|
* Encodes text stream to utf8 bytes stream
|
|
10
10
|
*/
|
|
11
|
-
export declare function encodeUtf8Stream(): TransformStream<string, Uint8Array
|
|
11
|
+
export declare function encodeUtf8Stream(): TransformStream<string, Uint8Array<ArrayBuffer>>;
|
|
12
12
|
/**
|
|
13
13
|
* Decodes buffer to string
|
|
14
14
|
* @param buffer buffer to decode
|
|
@@ -33,4 +33,4 @@ export declare function encodeHex(buffer: BinaryData): string;
|
|
|
33
33
|
* @param hex hex string to decode
|
|
34
34
|
* @returns decoded buffer
|
|
35
35
|
*/
|
|
36
|
-
export declare function decodeHex(hex: string): Uint8Array
|
|
36
|
+
export declare function decodeHex(hex: string): Uint8Array<ArrayBuffer>;
|
package/utils/jwt.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ export type JwtTokenParseResult<T extends JwtToken = JwtToken> = {
|
|
|
18
18
|
signature: string;
|
|
19
19
|
};
|
|
20
20
|
bytes: {
|
|
21
|
-
header: Uint8Array
|
|
22
|
-
payload: Uint8Array
|
|
23
|
-
signature: Uint8Array
|
|
21
|
+
header: Uint8Array<ArrayBuffer>;
|
|
22
|
+
payload: Uint8Array<ArrayBuffer>;
|
|
23
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
24
24
|
};
|
|
25
25
|
string: {
|
|
26
26
|
header: string;
|
package/utils/random.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @param count number of bytes to get
|
|
8
8
|
* @param allowUnsafe whether to allow sharing the underlying pool
|
|
9
9
|
*/
|
|
10
|
-
export declare function getRandomBytes(count: number, allowUnsafe?: boolean): Uint8Array
|
|
10
|
+
export declare function getRandomBytes(count: number, allowUnsafe?: boolean): Uint8Array<ArrayBuffer>;
|
|
11
11
|
/**
|
|
12
12
|
* Generate a cryptographically secure random string (in terms of source of randomness).
|
|
13
13
|
* @param length length of string
|
package/utils/stream/slice.js
CHANGED
|
@@ -31,7 +31,7 @@ export function sliceStream(stream, offset, length, type = 'bytes') {
|
|
|
31
31
|
},
|
|
32
32
|
async cancel(reason) {
|
|
33
33
|
await reader.cancel(reason);
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
const byobReader = toBytesStream(stream).getReader({ mode: 'byob' });
|
|
@@ -70,6 +70,6 @@ export function sliceStream(stream, offset, length, type = 'bytes') {
|
|
|
70
70
|
},
|
|
71
71
|
async cancel(reason) {
|
|
72
72
|
await byobReader.cancel(reason);
|
|
73
|
-
}
|
|
73
|
+
},
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type ToBytesStreamOptions = {
|
|
2
2
|
ignoreCancel?: boolean;
|
|
3
3
|
};
|
|
4
|
-
export declare function toBytesStream(stream: ReadableStream<ArrayBufferView
|
|
4
|
+
export declare function toBytesStream(stream: ReadableStream<ArrayBufferView<ArrayBuffer>>, options?: ToBytesStreamOptions): ReadableStream<Uint8Array>;
|
|
@@ -23,7 +23,7 @@ export function toBytesStream(stream, options) {
|
|
|
23
23
|
else {
|
|
24
24
|
await byobReader.cancel(reason);
|
|
25
25
|
}
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
catch { /* Ignore */ }
|
|
@@ -72,6 +72,6 @@ export function toBytesStream(stream, options) {
|
|
|
72
72
|
else {
|
|
73
73
|
await reader.cancel(reason);
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
},
|
|
76
76
|
});
|
|
77
77
|
}
|
package/utils/type-guards.d.ts
CHANGED
|
@@ -131,6 +131,18 @@ export declare const assertArrayBuffer: AssertFunction<ArrayBuffer>;
|
|
|
131
131
|
export declare const assertNotArrayBuffer: AssertNotFunction<ArrayBuffer>;
|
|
132
132
|
export declare const assertArrayBufferPass: AssertPassFunction<ArrayBuffer>;
|
|
133
133
|
export declare const assertNotArrayBufferPass: AssertNotPassFunction<ArrayBuffer>;
|
|
134
|
+
export declare const isSharedArrayBuffer: IsFunction<SharedArrayBuffer>;
|
|
135
|
+
export declare const isNotSharedArrayBuffer: IsNotFunction<SharedArrayBuffer>;
|
|
136
|
+
export declare const assertSharedArrayBuffer: AssertFunction<SharedArrayBuffer>;
|
|
137
|
+
export declare const assertNotSharedArrayBuffer: AssertNotFunction<SharedArrayBuffer>;
|
|
138
|
+
export declare const assertSharedArrayBufferPass: AssertPassFunction<SharedArrayBuffer>;
|
|
139
|
+
export declare const assertNotSharedArrayBufferPass: AssertNotPassFunction<SharedArrayBuffer>;
|
|
140
|
+
export declare const isArrayBufferLike: IsFunction<ArrayBufferLike>;
|
|
141
|
+
export declare const isNotArrayBufferLike: IsNotFunction<ArrayBufferLike>;
|
|
142
|
+
export declare const assertArrayBufferLike: AssertFunction<ArrayBufferLike>;
|
|
143
|
+
export declare const assertNotArrayBufferLike: AssertNotFunction<ArrayBufferLike>;
|
|
144
|
+
export declare const assertArrayBufferLikePass: AssertPassFunction<ArrayBufferLike>;
|
|
145
|
+
export declare const assertNotArrayBufferLikePass: AssertNotPassFunction<ArrayBufferLike>;
|
|
134
146
|
export declare const isArrayBufferView: IsFunction<ArrayBufferView>;
|
|
135
147
|
export declare const isNotArrayBufferView: IsNotFunction<ArrayBufferView>;
|
|
136
148
|
export declare const assertArrayBufferView: AssertFunction<ArrayBufferView>;
|
package/utils/type-guards.js
CHANGED
|
@@ -188,6 +188,20 @@ export const assertArrayBuffer = arrayBufferGuards.assertArrayBuffer;
|
|
|
188
188
|
export const assertNotArrayBuffer = arrayBufferGuards.assertNotArrayBuffer;
|
|
189
189
|
export const assertArrayBufferPass = arrayBufferGuards.assertArrayBufferPass;
|
|
190
190
|
export const assertNotArrayBufferPass = arrayBufferGuards.assertNotArrayBufferPass;
|
|
191
|
+
const sharedArrayBufferGuards = createInstanceGuards('SharedArrayBuffer', SharedArrayBuffer);
|
|
192
|
+
export const isSharedArrayBuffer = sharedArrayBufferGuards.isSharedArrayBuffer;
|
|
193
|
+
export const isNotSharedArrayBuffer = sharedArrayBufferGuards.isNotSharedArrayBuffer;
|
|
194
|
+
export const assertSharedArrayBuffer = sharedArrayBufferGuards.assertSharedArrayBuffer;
|
|
195
|
+
export const assertNotSharedArrayBuffer = sharedArrayBufferGuards.assertNotSharedArrayBuffer;
|
|
196
|
+
export const assertSharedArrayBufferPass = sharedArrayBufferGuards.assertSharedArrayBufferPass;
|
|
197
|
+
export const assertNotSharedArrayBufferPass = sharedArrayBufferGuards.assertNotSharedArrayBufferPass;
|
|
198
|
+
const arrayBufferLikeGuards = createGuards('ArrayBufferLike', (value) => isArrayBuffer(value) || isSharedArrayBuffer(value));
|
|
199
|
+
export const isArrayBufferLike = arrayBufferLikeGuards.isArrayBufferLike;
|
|
200
|
+
export const isNotArrayBufferLike = arrayBufferLikeGuards.isNotArrayBufferLike;
|
|
201
|
+
export const assertArrayBufferLike = arrayBufferLikeGuards.assertArrayBufferLike;
|
|
202
|
+
export const assertNotArrayBufferLike = arrayBufferLikeGuards.assertNotArrayBufferLike;
|
|
203
|
+
export const assertArrayBufferLikePass = arrayBufferLikeGuards.assertArrayBufferLikePass;
|
|
204
|
+
export const assertNotArrayBufferLikePass = arrayBufferLikeGuards.assertNotArrayBufferLikePass;
|
|
191
205
|
const arrayBufferViewGuards = createGuards('ArrayBufferView', (value) => ArrayBuffer.isView(value));
|
|
192
206
|
export const isArrayBufferView = arrayBufferViewGuards.isArrayBufferView;
|
|
193
207
|
export const isNotArrayBufferView = arrayBufferViewGuards.isNotArrayBufferView;
|
|
@@ -195,7 +209,7 @@ export const assertArrayBufferView = arrayBufferViewGuards.assertArrayBufferView
|
|
|
195
209
|
export const assertNotArrayBufferView = arrayBufferViewGuards.assertNotArrayBufferView;
|
|
196
210
|
export const assertArrayBufferViewPass = arrayBufferViewGuards.assertArrayBufferViewPass;
|
|
197
211
|
export const assertNotArrayBufferViewPass = arrayBufferViewGuards.assertNotArrayBufferViewPass;
|
|
198
|
-
const binaryDataGuards = createGuards('BinaryData', (value) => (
|
|
212
|
+
const binaryDataGuards = createGuards('BinaryData', (value) => (isArrayBufferLike(value) || isArrayBufferView(value)));
|
|
199
213
|
export const isBinaryData = binaryDataGuards.isBinaryData;
|
|
200
214
|
export const isNotBinaryData = binaryDataGuards.isNotBinaryData;
|
|
201
215
|
export const assertBinaryData = binaryDataGuards.assertBinaryData;
|