Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@agoric/marshal

Package Overview
Dependencies
Maintainers
5
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/marshal - npm Package Compare versions

Comparing version 0.5.1-dev-1e431b2.0 to 0.5.1-dev-1f30fa9.0

src/typeGuards.js

10

index.js

@@ -7,2 +7,3 @@ export { mapIterable, filterIterable } from './src/helpers/iter-helpers.js';

getTag,
hasOwnPropertyOf,
} from './src/helpers/passStyle-helpers.js';

@@ -21,8 +22,3 @@

export {
passStyleOf,
assertPassable,
everyPassableChild,
somePassableChild,
} from './src/passStyleOf.js';
export { passStyleOf, assertPassable } from './src/passStyleOf.js';

@@ -47,2 +43,2 @@ export { pureCopy, sameValueZero } from './src/pureCopy.js';

isCopyArray,
} from './src/assertPassStyleOf.js';
} from './src/typeGuards.js';
{
"name": "@agoric/marshal",
"version": "0.5.1-dev-1e431b2.0+1e431b2",
"version": "0.5.1-dev-1f30fa9.0+1f30fa9",
"description": "marshal",

@@ -15,4 +15,2 @@ "type": "module",

"test:xs": "exit 0",
"pretty-fix": "prettier --write '**/*.js'",
"pretty-check": "prettier --check '**/*.js'",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",

@@ -38,10 +36,9 @@ "lint-check": "yarn lint",

"dependencies": {
"@agoric/assert": "0.3.16-dev-1e431b2.0+1e431b2",
"@agoric/eventual-send": "0.14.1-dev-1e431b2.0+1e431b2",
"@agoric/eventual-send": "0.14.1-dev-1f30fa9.0+1f30fa9",
"@agoric/nat": "^4.1.0",
"@agoric/promise-kit": "0.2.30-dev-1e431b2.0+1e431b2"
"@agoric/promise-kit": "0.2.30-dev-1f30fa9.0+1f30fa9"
},
"devDependencies": {
"@agoric/lockdown": "0.1.2-dev-1e431b2.0+1e431b2",
"@endo/ses-ava": "^0.2.8",
"@endo/lockdown": "^0.1.2",
"@endo/ses-ava": "^0.2.14",
"ava": "^3.12.1",

@@ -60,6 +57,2 @@ "c8": "^7.7.2"

},
"prettier": {
"trailingComma": "all",
"singleQuote": true
},
"publishConfig": {

@@ -74,3 +67,3 @@ "access": "public"

},
"gitHead": "1e431b2d5fbcc61dc25d0559533ade1f84fb2134"
"gitHead": "1f30fa9e5db18bd8f910818de2e460d8dbee9b4a"
}
// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -5,0 +4,0 @@

/* eslint-disable no-use-before-define */
// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>
import { assert, details as X } from '@agoric/assert';
import { E } from '@agoric/eventual-send';

@@ -17,2 +15,3 @@ import { isObject } from './helpers/passStyle-helpers.js';

const { ownKeys } = Reflect;
const { details: X } = assert;

@@ -19,0 +18,0 @@ const makeConverter = (mirrorConverter = undefined) => {

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -8,3 +7,2 @@

import './internal-types.js';
import '@agoric/assert/exported.js';
import { assertChecker, checkNormalProperty } from './passStyle-helpers.js';

@@ -48,9 +46,4 @@

// Recursively validate that each member is passable.
CopyArrayHelper.every(candidate, v => !!passStyleOfRecur(v));
candidate.every(v => !!passStyleOfRecur(v));
},
every: (passable, fn) =>
// Note that we explicitly call `fn` with only the arguments we want
// to provide.
passable.every((v, i) => fn(v, i)),
});
// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -14,3 +13,2 @@

import './internal-types.js';
import '@agoric/assert/exported.js';

@@ -22,3 +20,2 @@ const { details: X } = assert;

getOwnPropertyDescriptors,
entries,
prototype: objectPrototype,

@@ -67,9 +64,4 @@ } = Object;

// Recursively validate that each member is passable.
CopyRecordHelper.every(candidate, v => !!passStyleOfRecur(v));
Object.values(candidate).every(v => !!passStyleOfRecur(v));
},
every: (passable, fn) =>
// Note that we explicitly call `fn` with only the arguments we want
// to provide.
entries(passable).every(([k, v]) => fn(v, k)),
});
// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -8,3 +7,2 @@

import './internal-types.js';
import '@agoric/assert/exported.js';
import { assertChecker } from './passStyle-helpers.js';

@@ -58,3 +56,3 @@

const proto = getPrototypeOf(candidate);
const { name } = candidate;
const { name } = proto;
const EC = getErrorConstructor(name);

@@ -69,2 +67,3 @@ if (!EC || EC.prototype !== proto) {

const {
// Must allow `cause`, `errors`
message: mDesc,

@@ -101,4 +100,2 @@ // Allow but ignore only extraneous own `stack` property.

},
every: (_passable, _fn) => true,
});

@@ -105,0 +102,0 @@

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference path="../extra-types.d.ts" />

@@ -30,8 +29,2 @@

* ) => void} assertValid
*
* @property {(passable: Passable,
* fn: (passable: Passable, index: any) => boolean
* ) => boolean} every
* For recuring through the nested passable structure. Like
* `Array.prototype.every`, return `false` to stop early.
*/
// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -8,3 +7,2 @@

import './internal-types.js';
import '@agoric/assert/exported.js';

@@ -11,0 +9,0 @@ const { details: X, quote: q } = assert;

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -8,3 +7,2 @@

import './internal-types.js';
import '@agoric/assert/exported.js';
import {

@@ -11,0 +9,0 @@ assertChecker,

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -15,3 +14,2 @@

import './internal-types.js';
import '@agoric/assert/exported.js';

@@ -55,6 +53,4 @@ const { details: X } = assert;

// Recursively validate that each member is passable.
TaggedHelper.every(candidate, v => !!passStyleOfRecur(v));
!!passStyleOfRecur(candidate.payload);
},
every: (passable, fn) => fn(passable.payload, 'payload'),
});
// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>
import { assert, details as X, q } from '@agoric/assert';
import { assertChecker, PASS_STYLE } from './helpers/passStyle-helpers.js';

@@ -15,2 +13,4 @@ import {

const { quote: q, details: X } = assert;
const { prototype: functionPrototype } = Function;

@@ -17,0 +17,0 @@ const {

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>
import { assert, details as X } from '@agoric/assert';
import { PASS_STYLE } from './helpers/passStyle-helpers.js';

@@ -11,2 +9,3 @@ import { assertPassable } from './passStyleOf.js';

const { create, prototype: objectPrototype } = Object;
const { details: X } = assert;

@@ -13,0 +12,0 @@ export const makeTagged = (tag, payload) => {

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>
import { Nat } from '@agoric/nat';
import { assert, details as X, q } from '@agoric/assert';
import { QCLASS } from './marshal.js';

@@ -18,2 +16,3 @@

const { stringify: quote } = JSON;
const { quote: q, details: X } = assert;

@@ -20,0 +19,0 @@ /**

// @ts-check
/// <reference types="ses"/>
import { assert, details as X } from '@agoric/assert';
import { makeMarshal } from './marshal.js';

@@ -8,2 +8,4 @@

const { details: X } = assert;
/** @type {ConvertValToSlot<any>} */

@@ -10,0 +12,0 @@ const doNotConvertValToSlot = val =>

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>
import { Nat } from '@agoric/nat';
import { assert, details as X, q } from '@agoric/assert';
import { passStyleOf } from './passStyleOf.js';

@@ -24,2 +22,3 @@

const { getOwnPropertyDescriptors, defineProperties, is, fromEntries } = Object;
const { details: X, quote: q } = assert;

@@ -82,2 +81,3 @@ /**

if (slotMap.has(val)) {
// TODO assert that it's the same iface as before
slotIndex = slotMap.get(val);

@@ -94,2 +94,3 @@ assert.typeof(slotIndex, 'number');

// TODO explore removing this special case
if (iface === undefined) {

@@ -129,2 +130,4 @@ return harden({

marshalSaveError(err);
// Must encode `cause`, `errors`.
// nested non-passable errors must be ok from here.
return harden({

@@ -286,2 +289,4 @@ [QCLASS]: 'error',

}
// TODO SECURITY HAZARD: must enfoce that remotable vs promise
// is according to the encoded string.
const slot = slots[Number(Nat(index))];

@@ -387,2 +392,3 @@ const val = convertSlotToVal(slot, iface);

case 'error': {
// Must decode `cause` and `errors` properties
const { name, message, errorId } = rawTree;

@@ -405,2 +411,6 @@ assert.typeof(

: `Remote${EC.name}(${errorId})`;
// Due to a defect in the SES type definition, the next line is
// fails a type check.
// Pending https://github.com/endojs/endo/issues/977
// @ts-ignore-next-line
const error = assert.error(`${message}`, EC, { errorName });

@@ -407,0 +417,0 @@ return error;

// @ts-check
// eslint-disable-next-line spaced-comment
/// <reference types="ses"/>

@@ -31,5 +30,5 @@

* accidents.
* @returns {{passStyleOf: PassStyleOf, HelperTable: any}}
* @returns {PassStyleOf}
*/
const makePassStyleOfKit = passStyleHelpers => {
const makePassStyleOf = passStyleHelpers => {
const HelperTable = {

@@ -183,6 +182,6 @@ __proto__: null,

};
return harden({ passStyleOf, HelperTable });
return harden(passStyleOf);
};
const { passStyleOf, HelperTable } = makePassStyleOfKit([
export const passStyleOf = makePassStyleOf([
CopyArrayHelper,

@@ -194,3 +193,2 @@ CopyRecordHelper,

]);
export { passStyleOf };

@@ -201,17 +199,1 @@ export const assertPassable = val => {

harden(assertPassable);
export const everyPassableChild = (passable, fn) => {
const passStyle = passStyleOf(passable);
const helper = HelperTable[passStyle];
if (helper) {
// everyPassable guards .every so that each helper only gets a
// genuine passable of its own flavor.
return helper.every(passable, fn);
}
return true;
};
harden(everyPassableChild);
export const somePassableChild = (passable, fn) =>
!everyPassableChild(passable, (v, i) => !fn(v, i));
harden(somePassableChild);
// @ts-check
import { assert, details as X, q } from '@agoric/assert';
import { getTag } from './helpers/passStyle-helpers.js';

@@ -9,2 +8,3 @@ import { makeTagged } from './makeTagged.js';

const { is } = Object;
const { details: X, quote: q } = assert;

@@ -11,0 +11,0 @@ /**

// @ts-nocheck TODO Fix the recursive types to it checks. Will this
// require a .d.ts file? I don't know.
// eslint-disable-next-line spaced-comment
/// <reference path="extra-types.d.ts" />

@@ -101,2 +100,12 @@

/**
* @template T
* @typedef {T[]} CopyArray
*/
/**
* @template T
* @typedef {Record<string, T>} CopyRecord
*/
/**
* @typedef {{

@@ -103,0 +112,0 @@ * [PASS_STYLE]: 'tagged',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc