fix: restore capdata leniency
MODIFY
packages/marshal/src/encodeToCapData.js
packages/marshal/src/encodeToCapData.js
@@ -413,14 +413,12 @@ export const makeDecodeFromCapData = ({
jsonEncoded,
decodeFromCapData,
);
- const passStyle = passStyleOf(decoded);
- if (passStyle === 'remotable' || passStyle === 'promise') {
+ // BEWARE: capdata does not check that `decoded` is
+ // a promise or a remotable, since that would break some
+ // capdata clients. We are deprecating capdata, and these clients
+ // will need to update before switching to smallcaps.
return decoded;
}
- assert.fail(
- X`internal: decodeRemotableFromCapData option must return a remotable or promise: ${decoded}`,
- );
- }
case 'error': {
const decoded = decodeErrorFromCapData(
jsonEncoded,

MODIFY
packages/marshal/test/test-marshal-capdata.js
packages/marshal/test/test-marshal-capdata.js
@@ -407,3 +407,23 @@ test('capdata proto problems', t => {
// Fails before https://github.com/endojs/endo/issues/1303 fix
t.deepEqual(fromCapData(wrongProtoCapData), wrongProto);
});
+
+test('capdata slot leniency', t => {
+ const { unserialize: fromCapData } = makeMarshal(
+ undefined,
+ _slot => ({
+ name: 'I should not be in a slot',
+ }),
+ {
+ errorTagging: 'off',
+ serializeBodyFormat: 'capdata',
+ },
+ );
+ t.deepEqual(
+ fromCapData({
+ body: '[{"@qclass":"slot","index":0}]',
+ slots: ['ignored'],
+ }),
+ [{ name: 'I should not be in a slot' }],
+ );
+});

fix: restore capdata leniency (#1338)