@openclaw/matrix 2026.5.30-beta.1 → 2026.5.31-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/api.js +4 -4
  2. package/dist/{approval-handler.runtime-nfyxbtVZ.js → approval-handler.runtime-Dzh_2MS1.js} +4 -4
  3. package/dist/{approval-ids-vw7teE3M.js → approval-ids-CXPPSyAr.js} +1 -1
  4. package/dist/{approval-reaction-auth-kAazIsvu.js → approval-reaction-auth-m-11_ajL.js} +2 -2
  5. package/dist/{channel-DwJf74NH.js → channel-BwpVY2Ne.js} +9 -9
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/{channel.runtime-6ITv13UJ.js → channel.runtime-CUBxoFwA.js} +1 -1
  8. package/dist/{cli-BXd9cN_x.js → cli-CaF5tlL-.js} +7 -7
  9. package/dist/{cli-metadata-CkMUnkMl.js → cli-metadata-gFTG9oJL.js} +1 -1
  10. package/dist/cli-metadata.js +1 -1
  11. package/dist/{client-CpSI5BON.js → client-D-t6CdHz.js} +1 -1
  12. package/dist/{config-schema-Bx-Pb1Kw.js → config-schema-DfjBrYch.js} +19 -2
  13. package/dist/contract-api.js +3 -3
  14. package/dist/{doctor-D3wfD2UP.js → doctor-BKjr6uua.js} +0 -1
  15. package/dist/{draft-stream-DQN43iqS.js → draft-stream-eaBWrjVK.js} +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/{media-text-C8b9cJiE.js → media-text-C2Wor3Gj.js} +1 -1
  18. package/dist/{messages-DyU_49Ws.js → messages-D0sumPNx.js} +3 -3
  19. package/dist/{monitor-C-w1IkPI.js → monitor-gDaABWfA.js} +20 -17
  20. package/dist/plugin-entry.handlers.runtime.js +1 -1
  21. package/dist/{profile-update-DON3UoVK.js → profile-update-Defy1W90.js} +2 -2
  22. package/dist/{reaction-events-Cf-zAwa6.js → reaction-events-Bh2u-_9j.js} +1 -1
  23. package/dist/{send-CAmsWgZ2.js → send-DHj1E9ji.js} +3 -1
  24. package/dist/{setup-bootstrap-5ki8dOiM.js → setup-bootstrap-kTPKb7jR.js} +2 -2
  25. package/dist/{setup-core-X-qaIzVT.js → setup-core-DRg3cgB8.js} +1 -1
  26. package/dist/setup-plugin-api.js +3 -3
  27. package/dist/{setup-surface-D6gS45Pz.js → setup-surface-soZQLgfu.js} +2 -2
  28. package/dist/{startup-verification-DdSXlCLn.js → startup-verification-CWLSyFen.js} +1 -1
  29. package/dist/{thread-bindings-yt8HTZo0.js → thread-bindings-DehFUArg.js} +3 -2
  30. package/dist/{tool-actions.runtime-DOh3pfFu.js → tool-actions.runtime-CU79qJ3e.js} +6 -6
  31. package/dist/{verification-BkvujZrn.js → verification-BJfjKMr8.js} +1 -1
  32. package/node_modules/@babel/runtime/package.json +1 -1
  33. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/.node-version +1 -1
  34. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/CHANGELOG.md +32 -1
  35. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/README.md +3 -3
  36. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/index.d.ts +195 -15
  37. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/index.js +6 -1
  38. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/package.json +3 -3
  39. package/node_modules/typebox/build/type/script/mapping.d.mts +5 -2
  40. package/node_modules/typebox/build/type/script/mapping.mjs +15 -8
  41. package/node_modules/typebox/build/type/script/parser.d.mts +3 -1
  42. package/node_modules/typebox/build/type/script/parser.mjs +2 -1
  43. package/node_modules/typebox/package.json +29 -29
  44. package/npm-shrinkwrap.json +15 -15
  45. package/openclaw.plugin.json +46 -0
  46. package/package.json +6 -6
@@ -1,6 +1,37 @@
1
1
  # Matrix-Rust-SDK Node.js Bindings
2
2
 
3
- ## UNRELEASED
3
+ ## v0.6.0 - 2026-05-18
4
+
5
+ - Update matrix-rust-sdk to 0.17.0
6
+
7
+ - Check the user ID in the `sender_device_keys` property of Olm-encrypted
8
+ to-device events to prevent sender spoofing by homeserver owners.
9
+ [#6553](https://github.com/matrix-org/matrix-rust-sdk/pull/6553)
10
+ - **BREAKING:** The `only_allow_trusted_devices` and
11
+ `error_on_verified_user_problem` fields of the `EncryptionSettings` have
12
+ been replaced with the `CollectStrategy` enum.
13
+ - **BREAKING:** The `ShieldStateCode::SentInClear` enum variant has been
14
+ removed.
15
+ - **BREAKING:** A new `ShieldStateCode::MismatchedSender` enum variant has been
16
+ added.
17
+
18
+ - Add support for Node.JS 26, and drop support for Node.JS 25. [#76](https://github.com/matrix-org/matrix-rust-sdk-crypto-nodejs/pull/76)
19
+ - Support Node-API Version 8. [#77](https://github.com/matrix-org/matrix-rust-sdk-crypto-nodejs/pull/77)
20
+
21
+ ## v0.5.1 - 2026-04-22
22
+
23
+ - Try to fix release script. [#72](https://github.com/matrix-org/matrix-rust-sdk-crypto-nodejs/pull/72)
24
+
25
+ ## v0.5.0 - 2026-04-20
26
+
27
+ - Support Node.JS 25, drop support for 22. [#68](https://github.com/matrix-org/matrix-rust-sdk-crypto-nodejs/pull/68)
28
+ - `OlmMachine.bootstrap_cross_signing` now returns the requests required to
29
+ upload the cross-signing keys to the server. [#67](https://github.com/matrix-org/matrix-rust-sdk-crypto-nodejs/pull/67)
30
+ - Add new functions `OlmMachine.export_secrets_for_secret_storage` and
31
+ `OlmMachine.import_secrets_from_secret_storage`, along with associated
32
+ types, for reading and writing to Secret Storage. [#67](https://github.com/matrix-org/matrix-rust-sdk-crypto-nodejs/pull/67)
33
+ - Add a new function `OlmMachine.get_device` to get information about a
34
+ device. [#67](https://github.com/matrix-org/matrix-rust-sdk-crypto-nodejs/pull/67)
4
35
 
5
36
  ## v0.4.0 - 2026-01-08
6
37
 
@@ -99,10 +99,10 @@ The binding is compatible with, and tested against, the Node.js
99
99
  versions that are in “current” or “active” states,
100
100
  according to [the Node.js Releases
101
101
  Page](https://nodejs.org/en/about/releases/), _and_ which are
102
- compatible with [NAPI v6 (Node.js
103
- API)](https://nodejs.org/api/n-api.html#node-api-version-matrix). It
102
+ compatible with [Node-API (formerly N-API)
103
+ v8)](https://nodejs.org/api/n-api.html#node-api-version-matrix). It
104
104
  means that this binding will work with the following versions:
105
- 22.0.0 and 24.0.0.
105
+ v24 and v26.
106
106
 
107
107
  Once the Rust compiler, Node.js and npm are installed, you can run the
108
108
  following commands:
@@ -13,6 +13,76 @@ export const enum EncryptionAlgorithm {
13
13
  /** Megolm version 1 using AES-256 and SHA-256. */
14
14
  MegolmV1AesSha2 = 1
15
15
  }
16
+ /**
17
+ * Strategy to collect the devices that should receive room keys for the
18
+ * current discussion.
19
+ */
20
+ export const enum CollectStrategy {
21
+ /**
22
+ * Share with all (unblacklisted) devices.
23
+ *
24
+ * Not recommended, per the guidance of [MSC4153].
25
+ *
26
+ * (Used by Element X and Element Web in the legacy, non-"exclude insecure
27
+ * devices" mode.)
28
+ *
29
+ * [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
30
+ */
31
+ AllDevices = 0,
32
+ /**
33
+ * Share with all devices, except errors for *verified* users cause sharing
34
+ * to fail with an error.
35
+ *
36
+ * In this strategy, if a verified user has an unsigned device,
37
+ * key sharing will fail with a
38
+ * [`SessionRecipientCollectionError::VerifiedUserHasUnsignedDevice`].
39
+ * If a verified user has replaced their identity, key
40
+ * sharing will fail with a
41
+ * [`SessionRecipientCollectionError::VerifiedUserChangedIdentity`].
42
+ *
43
+ * Otherwise, keys are shared with unsigned devices as normal.
44
+ *
45
+ * Once the problematic devices are blacklisted or whitelisted the
46
+ * caller can retry to share a second time.
47
+ *
48
+ * Not recommended, per the guidance of [MSC4153].
49
+ *
50
+ * [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
51
+ */
52
+ ErrorOnVerifiedUserProblem = 1,
53
+ /**
54
+ * Share based on identity. Only distribute to devices signed by their
55
+ * owner. If a user has no published identity he will not receive
56
+ * any room keys.
57
+ *
58
+ * This is the recommended strategy: it is compliant with the guidance of
59
+ * [MSC4153].
60
+ *
61
+ * (Used by Element Web and Element X in the "exclude insecure devices"
62
+ * mode.)
63
+ *
64
+ * [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
65
+ */
66
+ IdentityBasedStrategy = 2,
67
+ /**
68
+ * Only share keys with devices that we "trust". A device is trusted if any
69
+ * of the following is true:
70
+ * - It was manually marked as trusted.
71
+ * - It was marked as verified via interactive verification.
72
+ * - It is signed by its owner identity, and this identity has been
73
+ * trusted via interactive verification.
74
+ * - It is the current own device of the user.
75
+ *
76
+ * This strategy is compliant with [MSC4153], but is probably too strict
77
+ * for normal use.
78
+ *
79
+ * (Used by Element Web when "only send messages to verified users" is
80
+ * enabled.)
81
+ *
82
+ * [MSC4153]: https://github.com/matrix-org/matrix-doc/pull/4153
83
+ */
84
+ OnlyTrustedDevices = 3
85
+ }
16
86
  /**
17
87
  * Take a look at [`matrix_sdk_common::deserialized_responses::ShieldState`]
18
88
  * for more info.
@@ -36,8 +106,11 @@ export const enum ShieldStateCode {
36
106
  UnsignedDevice = 2,
37
107
  /** The sender hasn't been verified by the Client's user. */
38
108
  UnverifiedIdentity = 3,
39
- /** An unencrypted event in an encrypted room. */
40
- SentInClear = 4,
109
+ /**
110
+ * The `sender` field on the event does not match the owner of the device
111
+ * that established the Megolm session.
112
+ */
113
+ MismatchedSender = 4,
41
114
  /** The sender was previously verified but changed their identity. */
42
115
  VerificationViolation = 5,
43
116
  None = 6
@@ -221,6 +294,21 @@ export declare class BackupKeys {
221
294
  /** The version that we are using for backups. */
222
295
  backupVersion?: string
223
296
  }
297
+ /** A device represents a E2EE capable client of an user. */
298
+ export declare class Device {
299
+ /**
300
+ * Is this device considered to be verified.
301
+ *
302
+ * This method returns true if either the `is_locally_trusted`
303
+ * method returns `true` or if the `is_cross_signing_trusted`
304
+ * method returns `true`.
305
+ */
306
+ isVerified(): boolean
307
+ /** Is this device considered to be verified using cross signing. */
308
+ isCrossSigningTrusted(): boolean
309
+ /** Is this device cross-signed by its owner? */
310
+ isCrossSignedByOwner(): boolean
311
+ }
224
312
  /**
225
313
  * Settings for an encrypted room.
226
314
  *
@@ -243,16 +331,10 @@ export declare class EncryptionSettings {
243
331
  */
244
332
  historyVisibility: HistoryVisibility
245
333
  /**
246
- * Should untrusted devices receive the room key, or should they be
247
- * excluded from the conversation.
334
+ * The strategy used to distribute the room keys to participant.
335
+ * Default will send to all devices.
248
336
  */
249
- onlyAllowTrustedDevices: boolean
250
- /**
251
- * Should keys be shared with a verified user with an unverified device
252
- * or when a verified user has replaced their identity. Otherwise
253
- * keys are shared with unsigned devices as normal.
254
- */
255
- errorOnVerifiedUserProblem: boolean
337
+ sharingStrategy: CollectStrategy
256
338
  /** Create a new `EncryptionSettings` with default values. */
257
339
  constructor()
258
340
  }
@@ -401,10 +483,15 @@ export declare class OlmMachine {
401
483
  /** Get the public parts of our Olm identity keys. */
402
484
  get identityKeys(): IdentityKeys
403
485
  /**
404
- * Handle a to-device and one-time key counts from a sync response.
486
+ * Handle to-device events and one-time key counts from a sync response.
487
+ *
488
+ * This will decrypt and handle to-device events, returning a two-element
489
+ * array where:
405
490
  *
406
- * This will decrypt and handle to-device events returning the
407
- * decrypted versions of them, as a JSON-encoded string.
491
+ * * The first element is an array containing the decrypted to-device
492
+ * events as JSON-encoded strings.
493
+ * * The second element is an array containing information about room keys
494
+ * received as part of those decrypted to-device events.
408
495
  *
409
496
  * To decrypt an event from the room timeline, please use
410
497
  * `decrypt_room_event`.
@@ -416,6 +503,8 @@ export declare class OlmMachine {
416
503
  * response.
417
504
  * * `one_time_keys_count`, the current one-time keys counts that the sync
418
505
  * response returned.
506
+ * * `unused_fallback_keys`, the list of unused fallback keys the
507
+ * homeserver knows about.
419
508
  */
420
509
  receiveSyncChanges(toDeviceEvents: string, changedDevices: DeviceLists, oneTimeKeyCounts: Record<string, number>, unusedFallbackKeys: Array<string>): Promise<string>
421
510
  /**
@@ -527,6 +616,9 @@ export declare class OlmMachine {
527
616
  * Create a new cross signing identity and get the upload request
528
617
  * to push the new public keys to the server.
529
618
  *
619
+ * Returns the requests that need to be sent to the server to upload the
620
+ * required keys and signatures.
621
+ *
530
622
  * Warning: This will delete any existing cross signing keys that
531
623
  * might exist on the server and thus will reset the trust
532
624
  * between all the devices.
@@ -543,7 +635,7 @@ export declare class OlmMachine {
543
635
  * the same request multiple times, setting this argument to false
544
636
  * enables you to reuse the same request.
545
637
  */
546
- bootstrapCrossSigning(reset: boolean): Promise<void>
638
+ bootstrapCrossSigning(reset: boolean): Promise<CrossSigningBootstrapRequests>
547
639
  /**
548
640
  * Sign the given message using our device key and if available
549
641
  * cross-signing master key.
@@ -627,6 +719,25 @@ export declare class OlmMachine {
627
719
  * `OlmMachine` after this `close` method has been called.
628
720
  */
629
721
  close(): void
722
+ /**
723
+ * Export the client's secrets to store in Secret Storage, encrypted using
724
+ * the given secret storage key.
725
+ *
726
+ * Returns the items to store in account data.
727
+ *
728
+ * Currently only exports the cross-signing keys.
729
+ */
730
+ exportSecretsForSecretStorage(secretStorageKey: SecretStorageKey): Promise<SecretStorageItems>
731
+ /**
732
+ * Import secrets from Secret Storage, and sign the device's key with the
733
+ * user's self-signing key.
734
+ *
735
+ * Returns a signature upload request to upload the signature to the
736
+ * server.
737
+ */
738
+ importSecretsFromSecretStorage(secretStorageKey: SecretStorageKey, items: SecretStorageItems): Promise<SignatureUploadRequest>
739
+ /** Get information about a device. */
740
+ getDevice(userId: UserId, deviceId: DeviceId, timeout?: number | undefined | null): Promise<Device | null>
630
741
  }
631
742
  /**
632
743
  * Struct representing the state of our private cross signing keys,
@@ -803,6 +914,25 @@ export declare class KeysBackupRequest {
803
914
  /** Get its request type. */
804
915
  get type(): RequestType
805
916
  }
917
+ /** The requests needed to upload the cross-signing data to the server */
918
+ export declare class CrossSigningBootstrapRequests {
919
+ /**
920
+ * The request to upload the device's keys.
921
+ *
922
+ * Could be `None` if the device keys have already been uploaded.
923
+ */
924
+ readonly uploadKeysReq?: KeysUploadRequest
925
+ /**
926
+ * The request to upload the cross-signing keys, as a JSON-encoded string.
927
+ *
928
+ * This request does not have a request ID, and `mark_request_as_sent` does
929
+ * not need to be called for this request, so only the request body is
930
+ * provided.
931
+ */
932
+ readonly uploadSigningKeysReq: string
933
+ /** The request to upload the cross-signing signatures. */
934
+ readonly uploadSignaturesReq: SignatureUploadRequest
935
+ }
806
936
  /** A decrypted room event. */
807
937
  export declare class DecryptedRoomEvent {
808
938
  /** The JSON-encoded decrypted event. */
@@ -841,6 +971,56 @@ export declare class DecryptedRoomEvent {
841
971
  */
842
972
  shieldState(strict: boolean): ShieldState | null
843
973
  }
974
+ /** A key for encrypting/decrypting data in secret storage */
975
+ export declare class SecretStorageKey {
976
+ /** Create a new random [`SecretStorageKey`]. */
977
+ static createRandomKey(): SecretStorageKey
978
+ /** Create a new passphrase-based [`SecretStorageKey`]. */
979
+ static createFromPassphrase(passphrase: string): SecretStorageKey
980
+ /**
981
+ * Restore a [`SecretStorageKey`] from the given input and the description
982
+ * of the key.
983
+ *
984
+ * The [`SecretStorageKeyEventContent`] will contain the description of the
985
+ * [`SecretStorageKey`]. The constructor will check if the provided input
986
+ * string matches to the description.
987
+ *
988
+ * The input can be a passphrase or a Base58 export of the
989
+ * [`SecretStorageKey`].
990
+ */
991
+ static fromAccountData(input: string, eventType: string, content: string): SecretStorageKey
992
+ /** Export the [`SecretStorageKey`] as a base58-encoded string. */
993
+ toBase58(): string
994
+ /**
995
+ * Encrypt a secret string as a Secret Storage secret.
996
+ *
997
+ * Returns the JSON-encoded contents to store in Account Data.
998
+ */
999
+ encrypt(plaintext: string, secretName: string): string
1000
+ /**
1001
+ * Decrypt the given Secret Storage item, given as the JSON-encoded
1002
+ * contents.
1003
+ */
1004
+ decrypt(accountDataContentJson: string, secretName: string): string
1005
+ /**
1006
+ * The info about the [`SecretStorageKey`], as an item for storing in
1007
+ * account data.
1008
+ *
1009
+ * Returns a JSON-encoded object.
1010
+ */
1011
+ accountDataContent(): string
1012
+ /** The unique ID of this [`SecretStorageKey`]. */
1013
+ keyId(): string
1014
+ /** The event type of this [`SecretStorageKey`] for storing in account data. */
1015
+ eventType(): string
1016
+ }
1017
+ /** The account data items containing the secrets, encoded as JSON */
1018
+ export declare class SecretStorageItems {
1019
+ masterKey: string
1020
+ userSigningKey: string
1021
+ selfSigningKey: string
1022
+ constructor(items: Record<string, string>)
1023
+ }
844
1024
  /** Information on E2E device updates. */
845
1025
  export declare class DeviceLists {
846
1026
  /** Create an empty `DeviceLists`. */
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { Attachment, EncryptedAttachment, BackupDecryptionKey, MegolmV1BackupKey, RoomKeyCounts, BackupKeys, EncryptionAlgorithm, EncryptionSettings, ShieldColor, ShieldStateCode, ShieldState, HistoryVisibility, UserId, DeviceId, DeviceKeyId, DeviceKeyAlgorithm, DeviceKeyAlgorithmName, RoomId, ServerName, StoreType, OlmMachine, CrossSigningStatus, KeysUploadRequest, KeysQueryRequest, KeysClaimRequest, ToDeviceRequest, SignatureUploadRequest, RoomMessageRequest, KeysBackupRequest, RequestType, DecryptedRoomEvent, DeviceLists, Signatures, Signature, MaybeSignature, SignatureVerification, SignatureState, Ed25519PublicKey, Ed25519Signature, Curve25519PublicKey, IdentityKeys, Versions, getVersions } = nativeBinding
313
+ const { Attachment, EncryptedAttachment, BackupDecryptionKey, MegolmV1BackupKey, RoomKeyCounts, BackupKeys, Device, EncryptionAlgorithm, EncryptionSettings, CollectStrategy, ShieldColor, ShieldStateCode, ShieldState, HistoryVisibility, UserId, DeviceId, DeviceKeyId, DeviceKeyAlgorithm, DeviceKeyAlgorithmName, RoomId, ServerName, StoreType, OlmMachine, CrossSigningStatus, KeysUploadRequest, KeysQueryRequest, KeysClaimRequest, ToDeviceRequest, SignatureUploadRequest, RoomMessageRequest, KeysBackupRequest, RequestType, CrossSigningBootstrapRequests, DecryptedRoomEvent, SecretStorageKey, SecretStorageItems, DeviceLists, Signatures, Signature, MaybeSignature, SignatureVerification, SignatureState, Ed25519PublicKey, Ed25519Signature, Curve25519PublicKey, IdentityKeys, Versions, getVersions } = nativeBinding
314
314
 
315
315
  module.exports.Attachment = Attachment
316
316
  module.exports.EncryptedAttachment = EncryptedAttachment
@@ -318,8 +318,10 @@ module.exports.BackupDecryptionKey = BackupDecryptionKey
318
318
  module.exports.MegolmV1BackupKey = MegolmV1BackupKey
319
319
  module.exports.RoomKeyCounts = RoomKeyCounts
320
320
  module.exports.BackupKeys = BackupKeys
321
+ module.exports.Device = Device
321
322
  module.exports.EncryptionAlgorithm = EncryptionAlgorithm
322
323
  module.exports.EncryptionSettings = EncryptionSettings
324
+ module.exports.CollectStrategy = CollectStrategy
323
325
  module.exports.ShieldColor = ShieldColor
324
326
  module.exports.ShieldStateCode = ShieldStateCode
325
327
  module.exports.ShieldState = ShieldState
@@ -342,7 +344,10 @@ module.exports.SignatureUploadRequest = SignatureUploadRequest
342
344
  module.exports.RoomMessageRequest = RoomMessageRequest
343
345
  module.exports.KeysBackupRequest = KeysBackupRequest
344
346
  module.exports.RequestType = RequestType
347
+ module.exports.CrossSigningBootstrapRequests = CrossSigningBootstrapRequests
345
348
  module.exports.DecryptedRoomEvent = DecryptedRoomEvent
349
+ module.exports.SecretStorageKey = SecretStorageKey
350
+ module.exports.SecretStorageItems = SecretStorageItems
346
351
  module.exports.DeviceLists = DeviceLists
347
352
  module.exports.Signatures = Signatures
348
353
  module.exports.Signature = Signature
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matrix-org/matrix-sdk-crypto-nodejs",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "repository": {
@@ -19,13 +19,13 @@
19
19
  "devDependencies": {
20
20
  "@napi-rs/cli": "^2.18.4",
21
21
  "jest": "^29.7.0",
22
- "prettier": "^3.3.3",
22
+ "prettier": "~3.3.3",
23
23
  "typedoc": "^0.26.11",
24
24
  "typescript": "^5.6.3",
25
25
  "yargs-parser": "~21.1.1"
26
26
  },
27
27
  "engines": {
28
- "node": ">= 22"
28
+ "node": ">= 24"
29
29
  },
30
30
  "scripts": {
31
31
  "lint": "prettier --check .",
@@ -164,10 +164,13 @@ export type TExtendsMapping<Input extends [unknown, unknown, unknown, unknown, u
164
164
  export declare function ExtendsMapping(input: [unknown, unknown, unknown, unknown, unknown, unknown] | []): unknown;
165
165
  export type TBaseMapping<Input extends [unknown, unknown, unknown] | unknown> = (Input extends ['(', infer Type extends T.TSchema, ')'] ? Type : Input extends infer Type extends T.TSchema ? Type : never);
166
166
  export declare function BaseMapping(input: [unknown, unknown, unknown] | unknown): unknown;
167
+ export type TWithMapping<Input extends [unknown, unknown] | []> = (Input extends ['with', infer Options extends Record<PropertyKey, unknown>] ? Options : []);
168
+ export declare function WithMapping(input: [unknown, unknown] | []): unknown;
167
169
  type TFactorIndexArray<Type extends T.TSchema, IndexArray extends unknown[]> = (IndexArray extends [infer Left extends T.TSchema[], ...infer Right extends unknown[]] ? (Left extends [infer Indexer extends T.TSchema] ? TFactorIndexArray<C.TIndexDeferred<Type, Indexer>, Right> : Left extends [] ? TFactorIndexArray<T.TArray<Type>, Right> : T.TNever) : Type);
168
170
  type TFactorExtends<Type extends T.TSchema, Extends extends unknown[]> = (Extends extends [infer Right extends T.TSchema, infer True extends T.TSchema, infer False extends T.TSchema] ? C.TConditionalDeferred<Type, Right, True, False> : Type);
169
- export type TFactorMapping<Input extends [unknown, unknown, unknown, unknown]> = (Input extends [infer KeyOf extends boolean, infer Type extends T.TSchema, infer IndexArray extends unknown[], infer Extend extends unknown[]] ? KeyOf extends true ? TFactorExtends<C.TKeyOfDeferred<TFactorIndexArray<Type, IndexArray>>, Extend> : TFactorExtends<TFactorIndexArray<Type, IndexArray>, Extend> : never);
170
- export declare function FactorMapping(input: [unknown, unknown, unknown, unknown]): unknown;
171
+ type TFactorWith<Type extends T.TSchema, With extends unknown> = (With extends Record<PropertyKey, unknown> ? C.TOptionsDeferred<Type, With> : Type);
172
+ export type TFactorMapping<Input extends [unknown, unknown, unknown, unknown, unknown]> = (Input extends [infer KeyOf extends boolean, infer Type extends T.TSchema, infer IndexArray extends unknown[], infer Extend extends unknown[], infer WithClause extends unknown] ? TFactorWith<KeyOf extends true ? TFactorExtends<C.TKeyOfDeferred<TFactorIndexArray<Type, IndexArray>>, Extend> : TFactorExtends<TFactorIndexArray<Type, IndexArray>, Extend>, WithClause> : never);
173
+ export declare function FactorMapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
171
174
  type TExprBinaryMapping<Left extends T.TSchema, Rest extends unknown[]> = (Rest extends [infer Operator extends unknown, infer Right extends T.TSchema, infer Next extends unknown[]] ? (TExprBinaryMapping<Right, Next> extends infer Schema extends T.TSchema ? (Operator extends '&' ? (Schema extends T.TIntersect<infer Types extends T.TSchema[]> ? T.TIntersect<[Left, ...Types]> : T.TIntersect<[Left, Schema]>) : Operator extends '|' ? (Schema extends T.TUnion<infer Types extends T.TSchema[]> ? T.TUnion<[Left, ...Types]> : T.TUnion<[Left, Schema]>) : never) : never) : Left);
172
175
  export type TExprTermTailMapping<Input extends [unknown, unknown, unknown] | []> = (Input);
173
176
  export declare function ExprTermTailMapping(input: [unknown, unknown, unknown] | []): unknown;
@@ -185,27 +185,34 @@ export function BaseMapping(input) {
185
185
  ? input[1]
186
186
  : input;
187
187
  }
188
+ export function WithMapping(input) {
189
+ return Guard.IsEqual(input.length, 2) ? input[1] : [];
190
+ }
188
191
  // deno-coverage-ignore-start
189
- // ...
190
- const FactorIndexArray = (Type, indexArray) => {
192
+ function FactorIndexArray(Type, indexArray) {
191
193
  return indexArray.reduce((result, left) => {
192
194
  const _left = left;
193
195
  return (Guard.IsEqual(_left.length, 1) ? C.IndexDeferred(result, _left[0]) :
194
196
  Guard.IsEqual(_left.length, 0) ? T.Array(result) :
195
197
  Unreachable());
196
198
  }, Type);
197
- };
199
+ }
198
200
  // deno-coverage-ignore-stop
199
- const FactorExtends = (type, extend) => {
201
+ function FactorExtends(type, extend) {
200
202
  return Guard.IsEqual(extend.length, 3)
201
203
  ? C.ConditionalDeferred(type, extend[0], extend[1], extend[2])
202
204
  : type;
203
- };
205
+ }
206
+ function FactorWith(type, withClause) {
207
+ return Guard.IsArray(withClause) && Guard.IsEqual(withClause.length, 0)
208
+ ? type
209
+ : C.OptionsDeferred(type, withClause);
210
+ }
204
211
  export function FactorMapping(input) {
205
- const [keyOf, type, indexArray, extend] = input;
206
- return keyOf
212
+ const [keyOf, type, indexArray, extend, withClause] = input;
213
+ return FactorWith(keyOf
207
214
  ? FactorExtends(C.KeyOfDeferred(FactorIndexArray(type, indexArray)), extend)
208
- : FactorExtends(FactorIndexArray(type, indexArray), extend);
215
+ : FactorExtends(FactorIndexArray(type, indexArray), extend), withClause);
209
216
  }
210
217
  // deno-coverage-ignore-start
211
218
  function ExprBinaryMapping(left, rest) {
@@ -43,7 +43,8 @@ export type TIndexArray_0<Input extends string, Result extends unknown[] = []> =
43
43
  export type TIndexArray<Input extends string> = TIndexArray_0<Input> extends [infer _0 extends ([unknown, unknown, unknown] | [unknown, unknown])[], infer Input extends string] ? [S.TIndexArrayMapping<_0>, Input] : [];
44
44
  export type TExtends<Input extends string> = ((Token.TConst<'extends', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<'?', Input> extends [infer _2, infer Input extends string] ? (TType<Input> extends [infer _3, infer Input extends string] ? (Token.TConst<':', Input> extends [infer _4, infer Input extends string] ? (TType<Input> extends [infer _5, infer Input extends string] ? [[_0, _1, _2, _3, _4, _5], Input] : []) : []) : []) : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExtendsMapping<_0>, Input] : [];
45
45
  export type TBase<Input extends string> = ((Token.TConst<'(', Input> extends [infer _0, infer Input extends string] ? (TType<Input> extends [infer _1, infer Input extends string] ? (Token.TConst<')', Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : TKeyword<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Object_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTuple<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TTemplateLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TLiteral<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TConstructor<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : T_Function_<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TMapped<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TOptions<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TGenericCall<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : TReference<Input> extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | unknown, infer Input extends string] ? [S.TBaseMapping<_0>, Input] : [];
46
- export type TFactor<Input extends string> = (TKeyOf<Input> extends [infer _0, infer Input extends string] ? (TBase<Input> extends [infer _1, infer Input extends string] ? (TIndexArray<Input> extends [infer _2, infer Input extends string] ? (TExtends<Input> extends [infer _3, infer Input extends string] ? [[_0, _1, _2, _3], Input] : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TFactorMapping<_0>, Input] : [];
46
+ export type TWith<Input extends string> = ((Token.TConst<'with', Input> extends [infer _0, infer Input extends string] ? (TJsonObject<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown] | [], infer Input extends string] ? [S.TWithMapping<_0>, Input] : [];
47
+ export type TFactor<Input extends string> = (TKeyOf<Input> extends [infer _0, infer Input extends string] ? (TBase<Input> extends [infer _1, infer Input extends string] ? (TIndexArray<Input> extends [infer _2, infer Input extends string] ? (TExtends<Input> extends [infer _3, infer Input extends string] ? (TWith<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TFactorMapping<_0>, Input] : [];
47
48
  export type TExprTermTail<Input extends string> = ((Token.TConst<'&', Input> extends [infer _0, infer Input extends string] ? (TFactor<Input> extends [infer _1, infer Input extends string] ? (TExprTermTail<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExprTermTailMapping<_0>, Input] : [];
48
49
  export type TExprTerm<Input extends string> = (TFactor<Input> extends [infer _0, infer Input extends string] ? (TExprTermTail<Input> extends [infer _1, infer Input extends string] ? [[_0, _1], Input] : []) : []) extends [infer _0 extends [unknown, unknown], infer Input extends string] ? [S.TExprTermMapping<_0>, Input] : [];
49
50
  export type TExprTail<Input extends string> = ((Token.TConst<'|', Input> extends [infer _0, infer Input extends string] ? (TExprTerm<Input> extends [infer _1, infer Input extends string] ? (TExprTail<Input> extends [infer _2, infer Input extends string] ? [[_0, _1, _2], Input] : []) : []) : []) extends [infer _0, infer Input extends string] ? [_0, Input] : [[], Input] extends [infer _0, infer Input extends string] ? [_0, Input] : []) extends [infer _0 extends [unknown, unknown, unknown] | [], infer Input extends string] ? [S.TExprTailMapping<_0>, Input] : [];
@@ -172,6 +173,7 @@ export declare const IndexArray_0: (input: string, result?: unknown[]) => [unkno
172
173
  export declare const IndexArray: (input: string) => [unknown, string] | [];
173
174
  export declare const Extends: (input: string) => [unknown, string] | [];
174
175
  export declare const Base: (input: string) => [unknown, string] | [];
176
+ export declare const With: (input: string) => [unknown, string] | [];
175
177
  export declare const Factor: (input: string) => [unknown, string] | [];
176
178
  export declare const ExprTermTail: (input: string) => [unknown, string] | [];
177
179
  export declare const ExprTerm: (input: string) => [unknown, string] | [];
@@ -47,7 +47,8 @@ export const IndexArray_0 = (input, result = []) => If(If(If(Token.Const('[', in
47
47
  export const IndexArray = (input) => If(IndexArray_0(input), ([_0, input]) => [S.IndexArrayMapping(_0), input]);
48
48
  export const Extends = (input) => If(If(If(Token.Const('extends', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const('?', input), ([_2, input]) => If(Type(input), ([_3, input]) => If(Token.Const(':', input), ([_4, input]) => If(Type(input), ([_5, input]) => [[_0, _1, _2, _3, _4, _5], input])))))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExtendsMapping(_0), input]);
49
49
  export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(Keyword(input), ([_0, input]) => [_0, input], () => If(_Object_(input), ([_0, input]) => [_0, input], () => If(Tuple(input), ([_0, input]) => [_0, input], () => If(TemplateLiteral(input), ([_0, input]) => [_0, input], () => If(Literal(input), ([_0, input]) => [_0, input], () => If(Constructor(input), ([_0, input]) => [_0, input], () => If(_Function_(input), ([_0, input]) => [_0, input], () => If(Mapped(input), ([_0, input]) => [_0, input], () => If(Options(input), ([_0, input]) => [_0, input], () => If(GenericCall(input), ([_0, input]) => [_0, input], () => If(Reference(input), ([_0, input]) => [_0, input], () => [])))))))))))), ([_0, input]) => [S.BaseMapping(_0), input]);
50
- export const Factor = (input) => If(If(KeyOf(input), ([_0, input]) => If(Base(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends(input), ([_3, input]) => [[_0, _1, _2, _3], input])))), ([_0, input]) => [S.FactorMapping(_0), input]);
50
+ export const With = (input) => If(If(If(Token.Const('with', input), ([_0, input]) => If(JsonObject(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithMapping(_0), input]);
51
+ export const Factor = (input) => If(If(KeyOf(input), ([_0, input]) => If(Base(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends(input), ([_3, input]) => If(With(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S.FactorMapping(_0), input]);
51
52
  export const ExprTermTail = (input) => If(If(If(Token.Const('&', input), ([_0, input]) => If(Factor(input), ([_1, input]) => If(ExprTermTail(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExprTermTailMapping(_0), input]);
52
53
  export const ExprTerm = (input) => If(If(Factor(input), ([_0, input]) => If(ExprTermTail(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.ExprTermMapping(_0), input]);
53
54
  export const ExprTail = (input) => If(If(If(Token.Const('|', input), ([_0, input]) => If(ExprTerm(input), ([_1, input]) => If(ExprTail(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExprTailMapping(_0), input]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.1.38",
4
+ "version": "1.1.39",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
@@ -16,22 +16,6 @@
16
16
  "types": "./build/index.d.mts",
17
17
  "module": "./build/index.mjs",
18
18
  "exports": {
19
- "./guard": {
20
- "import": "./build/guard/index.mjs",
21
- "default": "./build/guard/index.mjs"
22
- },
23
- "./error": {
24
- "import": "./build/error/index.mjs",
25
- "default": "./build/error/index.mjs"
26
- },
27
- "./compile": {
28
- "import": "./build/compile/index.mjs",
29
- "default": "./build/compile/index.mjs"
30
- },
31
- "./system": {
32
- "import": "./build/system/index.mjs",
33
- "default": "./build/system/index.mjs"
34
- },
35
19
  "./format": {
36
20
  "import": "./build/format/index.mjs",
37
21
  "default": "./build/format/index.mjs"
@@ -44,10 +28,26 @@
44
28
  "import": "./build/schema/index.mjs",
45
29
  "default": "./build/schema/index.mjs"
46
30
  },
31
+ "./compile": {
32
+ "import": "./build/compile/index.mjs",
33
+ "default": "./build/compile/index.mjs"
34
+ },
47
35
  "./value": {
48
36
  "import": "./build/value/index.mjs",
49
37
  "default": "./build/value/index.mjs"
50
38
  },
39
+ "./guard": {
40
+ "import": "./build/guard/index.mjs",
41
+ "default": "./build/guard/index.mjs"
42
+ },
43
+ "./system": {
44
+ "import": "./build/system/index.mjs",
45
+ "default": "./build/system/index.mjs"
46
+ },
47
+ "./error": {
48
+ "import": "./build/error/index.mjs",
49
+ "default": "./build/error/index.mjs"
50
+ },
51
51
  ".": {
52
52
  "import": "./build/index.mjs",
53
53
  "default": "./build/index.mjs"
@@ -55,18 +55,6 @@
55
55
  },
56
56
  "typesVersions": {
57
57
  "*": {
58
- "guard": [
59
- "./build/guard/index.d.mts"
60
- ],
61
- "error": [
62
- "./build/error/index.d.mts"
63
- ],
64
- "compile": [
65
- "./build/compile/index.d.mts"
66
- ],
67
- "system": [
68
- "./build/system/index.d.mts"
69
- ],
70
58
  "format": [
71
59
  "./build/format/index.d.mts"
72
60
  ],
@@ -76,9 +64,21 @@
76
64
  "schema": [
77
65
  "./build/schema/index.d.mts"
78
66
  ],
67
+ "compile": [
68
+ "./build/compile/index.d.mts"
69
+ ],
79
70
  "value": [
80
71
  "./build/value/index.d.mts"
81
72
  ],
73
+ "guard": [
74
+ "./build/guard/index.d.mts"
75
+ ],
76
+ "system": [
77
+ "./build/system/index.d.mts"
78
+ ],
79
+ "error": [
80
+ "./build/error/index.d.mts"
81
+ ],
82
82
  ".": [
83
83
  "./build/index.d.mts"
84
84
  ]