@tstdl/base 0.92.161 → 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.
Files changed (34) hide show
  1. package/api/types.d.ts +3 -3
  2. package/authentication/models/authentication-credentials.model.d.ts +2 -2
  3. package/authentication/models/authentication-session.model.d.ts +2 -2
  4. package/authentication/server/authentication.service.d.ts +6 -6
  5. package/authentication/server/helper.d.ts +5 -5
  6. package/authentication/server/helper.js +1 -1
  7. package/document-management/server/services/document-file.service.d.ts +2 -2
  8. package/document-management/server/services/document.service.d.ts +1 -1
  9. package/http/client/http-client-request.d.ts +1 -1
  10. package/http/http-body.d.ts +2 -2
  11. package/http/utils.d.ts +3 -3
  12. package/image-service/imgproxy/imgproxy-image-service.js +1 -1
  13. package/injector/injector.js +2 -2
  14. package/object-storage/object-storage.d.ts +2 -2
  15. package/object-storage/s3/s3.object-storage.d.ts +2 -2
  16. package/orm/server/encryption.d.ts +2 -2
  17. package/orm/server/repository.d.ts +2 -3
  18. package/orm/server/tokens.d.ts +1 -1
  19. package/package.json +2 -2
  20. package/process/spawn.js +4 -4
  21. package/types/types.d.ts +1 -1
  22. package/utils/base64.d.ts +3 -3
  23. package/utils/base64.js +2 -2
  24. package/utils/binary.js +3 -3
  25. package/utils/compression.d.ts +4 -4
  26. package/utils/cryptography.d.ts +9 -9
  27. package/utils/encoding.d.ts +3 -3
  28. package/utils/jwt.d.ts +3 -3
  29. package/utils/random.d.ts +1 -1
  30. package/utils/stream/slice.js +2 -2
  31. package/utils/stream/to-bytes-stream.d.ts +1 -1
  32. package/utils/stream/to-bytes-stream.js +2 -2
  33. package/utils/type-guards.d.ts +12 -0
  34. 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<any>;
96
- export type ApiInputType<T extends SchemaTestable> = T extends ApiBinaryType ? InstanceType<ApiBinaryType> : 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> : T extends typeof DataStream<infer U> ? Observable<U> : T extends SchemaTestable ? SchemaOutput<T> : never;
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.
@@ -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>): Promise<DocumentFileMetadata>;
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 }: {
@@ -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;
@@ -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> | ReadableStream<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>;
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> | ReadableStream<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')),
@@ -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: (options.forwardRefTypeHint ?? isFunction(forwardToken)) ? forwardToken : undefined });
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: (options.forwardRefTypeHint ?? isFunction(forwardToken)) ? forwardToken : undefined });
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, key: CryptoKey): Promise<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'];
@@ -1 +1 @@
1
- export declare const ENCRYPTION_SECRET: import("../../injector/token.js").InjectionToken<Uint8Array<ArrayBufferLike>, never>;
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.161",
3
+ "version": "0.92.162",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -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.8",
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 = ArrayBuffer | ArrayBufferView;
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 { isArrayBuffer, isDefined } from './type-guards.js';
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 (isArrayBuffer(array)) {
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, isArrayBuffer, isUint8Array } from './type-guards.js';
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 (isArrayBuffer(data)) {
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 (isArrayBuffer(data)) {
23
+ if (isArrayBufferLike(data)) {
24
24
  return clone
25
25
  ? new Uint8Array(data.slice(0))
26
26
  : new Uint8Array(data);
@@ -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>>;
@@ -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, Lengths['length']>>;
122
- export declare function deriveBytesMultiple<const C extends number>(algorithm: DeriveAlgorithm, baseKey: CryptoKey, length: C, count: number): Promise<ReadonlyTuple<Uint8Array, C>>;
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>>;
@@ -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
@@ -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>, options?: ToBytesStreamOptions): ReadableStream<Uint8Array>;
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
  }
@@ -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>;
@@ -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) => (isArrayBuffer(value) || isArrayBufferView(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;