User-visible changes in @endo/pass-style:
- Deprecates
assertChecker. UseFailin the confirm/reject pattern instead, as supported by@endo/errors/rejector.js. - Enables
passStyleOfto make errors passable as a side-effect when SES locks down withhardenTamingset tounsafe, which impacts errors on V8 starting with Node.js 21, and similar engines, that own astackgetter and setter that would otherwise be repaired as a side-effect ofharden. - Updates
CopyArray<T>to be aReadonlyArray<Passable>. We know dynamically that the CopyArray is hardened, so this typing statically reveals where mutation is attempted. UsePassable[]if you want to have a mutable array that contains only passable values.
- The exported function name
isObjectis ambiguous. It is unclear whether it includes functions or not. (It does.) To avoid this confusion, we're deprecatingisObjectand suggesting to use the new exportisPrimitiveinstead, that has the opposite answer. IOW, for allx,isObject(x) === !isPrimitive(x)
- Fixes, without qualification, so that the package initializes on platforms
that lack
ArrayBuffer.prototype.transferToImmutableand recognizes immutable ArrayBuffers as having a pass-style ofbyteArrayon platforms have asliceToImmutable, even if that is emulated with a shim usingslice, even if they lacktransferToImmutable.
BROKEN BUT PATCHED in 1.6.2, contains a fix but published with broken dependency versions. Inadvertently published without amending workspace protocol dependencies.
- Fixes so that the package initializes on platforms that lack
ArrayBuffer.prototype.transferToImmutableand recognizes immutable ArrayBuffers as having a pass-style ofbyteArrayon platforms have asliceToImmutable, even if that is emulated with a shim usingslice, even if they lacktransferToImmutable.
BROKEN BUT PATCHED in 1.6.2, this version introduced a dependence on the
underlying platform supporting ArrayBuffer.prototype.transferToImmutable.
The patch restores the ability to use pass-style on older platforms without
the immutable ArrayBuffer shim (as entrained by ses).
- Introduces support for
byteArray.
deeplyFulfilledmoved from @endo/marshal to @endo/pass-style. @endo/marshal still reexports it, to avoid breaking old importers. But importers should be upgraded to importdeeplyFulfilleddirectly from @endo/pass-style.
- Adds
toThrowableas a generalization oftoPassableErrorthat also admits copy data containing passable errors, but still without passable caps, i.e, without remotables or promises. This is in support of the exo boundary throwing only throwables, to ease security review.
- Exports
isWellFormedStringandassertWellFormedString. Unfortunately the standardString.prototype.isWellFormedfirst coerces its input to string, leading it to claim that some non-strings are well-formed strings. By contrast,isWellFormedStringandassertWellFormedStringwill not judge any non-strings to be well-formed strings.- Previously, all JavaScript strings were considered Passable with
passStyleOf(str) === 'string'. Our tentative plan is that only well-formed Unicode strings will be considered Passable. For all others,passStyleOf(str)throws a diagnostic error. This would bring us into closer conformance to the OCapN standard, which prohibits sending non-well-formed strings, and requires non-well-formed strings to be rejected when received. Applications that had previously handled non-well-formed strings successfully (even if inadvertantly) may then start experiences these failure. We are also uncertain about the performance impact of this extra check, since it is linear in the size of strings. - Thus, in this release we introduce the environment option
ONLY_WELL_FORMED_STRINGS_PASSABLEas a feature flag. To abstract over this switch, we also exportassertPassableString. For now, ifONLY_WELL_FORMED_STRINGS_PASSABLEenvironment option is'enabled', thenassertPassableStringis the same asassertWellFormedString. OtherwiseassertPassableStringjust asserts thatstris a string. In a bash shell, for example, you could setto turn this feature on.export ONLY_WELL_FORMED_STRINGS_PASSABLE=enabled - Currently,
ONLY_WELL_FORMED_STRINGS_PASSABLEdefaults to'disabled'because we do not yet know the performance impact. Later, if we decide we can afford it, we'll first change the default to'enabled'and ultimately remove the switch altogether. Be prepared for these changes.
- Previously, all JavaScript strings were considered Passable with
- Now supports
AggegateError,error.errors,error.cause.- A
Passableerror can now include anerror.causeproperty whose value is aPassableerror. - An
AggregateErrorcan be aPassableerror. - A
Passableerror can now include anerror.errorsproperty whose value is aCopyArrayofPassableerrors. - The previously internal
toPassableErroris more general and exported for general use. If its error agument is alreadyPassable,toPassableErrorwill return it. Otherwise, it will extract from it info for making aPassableerror, and useannotateErrorto attach the original error to the returnedPassableerror as a note. This node will show up on the SESconsoleas additional diagnostic info associated with the returnedPassableerror.
- A