New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@agoric/assert

Package Overview
Dependencies
Maintainers
5
Versions
2115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agoric/assert - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

src/types.js

13

CHANGELOG.md

@@ -6,2 +6,15 @@ # Change Log

## [0.0.9](https://github.com/Agoric/agoric-sdk/compare/@agoric/assert@0.0.8...@agoric/assert@0.0.9) (2020-08-31)
### Bug Fixes
* reduce inconsistency among our linting rules ([#1492](https://github.com/Agoric/agoric-sdk/issues/1492)) ([b6b675e](https://github.com/Agoric/agoric-sdk/commit/b6b675e2de110e2af19cad784a66220cab21dacf))
* seal payload used for quoted details ([#1610](https://github.com/Agoric/agoric-sdk/issues/1610)) ([1acd5ba](https://github.com/Agoric/agoric-sdk/commit/1acd5baa3e7f0185823c929409f8aecddab36a3a))
* update JS typings ([20941e6](https://github.com/Agoric/agoric-sdk/commit/20941e675302ee5905e4825638e661065ad5d3f9))
## [0.0.8](https://github.com/Agoric/agoric-sdk/compare/@agoric/assert@0.0.7...@agoric/assert@0.0.8) (2020-06-30)

@@ -8,0 +21,0 @@

35

package.json
{
"name": "@agoric/assert",
"version": "0.0.8",
"version": "0.0.9",
"description": "Assert expression support that protects sensitive data",

@@ -11,5 +11,7 @@ "main": "src/assert.js",

"build": "exit 0",
"test": "tape -r esm test/**/test*.js",
"lint-fix": "eslint --fix '**/*.js'",
"lint-check": "eslint '**/*.js'",
"test": "ava",
"lint-fix": "yarn lint --fix",
"lint-check": "yarn lint",
"lint": "yarn lint:types && eslint '**/*.js'",
"lint:types": "tsc -p jsconfig.json",
"lint-fix-jessie": "eslint -c '.eslintrc-jessie.js' --fix '**/*.js'",

@@ -32,10 +34,6 @@ "lint-check-jessie": "eslint -c '.eslintrc-jessie.js' '**/*.js'"

"homepage": "https://github.com/Agoric/agoric-sdk#readme",
"dependencies": {
"@agoric/harden": "^0.0.8"
},
"devDependencies": {
"esm": "^3.2.25",
"tap-spec": "^5.0.0",
"tape": "^4.11.0",
"tape-promise": "^4.0.0"
"@agoric/install-ses": "^0.3.0",
"ava": "^3.11.1",
"esm": "^3.2.25"
},

@@ -46,2 +44,10 @@ "files": [

],
"ava": {
"files": [
"test/**/test-*.js"
],
"require": [
"esm"
]
},
"eslintConfig": {

@@ -55,2 +61,5 @@ "extends": [

},
"globals": {
"harden": "readonly"
},
"rules": {

@@ -61,2 +70,4 @@ "implicit-arrow-linebreak": "off",

"strict": "off",
"prefer-destructuring": "off",
"no-else-return": "off",
"no-console": "off",

@@ -92,3 +103,3 @@ "no-unused-vars": [

},
"gitHead": "d74ea289800c2fc52c005674a55b2412385f57d9"
"gitHead": "709048cc133b0b2b26a9774315c18c5e828ea6ab"
}
// Copyright (C) 2019 Agoric, under Apache License 2.0
// @ts-check
import './types';
// This module assumes the de-facto standard `console` host object.

@@ -8,6 +11,2 @@ // To the extent that this `console` is considered a resource,

import rawHarden from '@agoric/harden';
const harden = /** @type {<T>(x: T) => T} */ (rawHarden);
/**

@@ -55,3 +54,3 @@ * Prepend the correct indefinite article onto a noun, typically a typeof result

const declassifiers = new WeakSet();
const declassifiers = new WeakMap();

@@ -78,3 +77,2 @@ /**

* @typedef {Object} StringablePayload
* @property {*} payload The original payload
* @property {() => string} toString How to print the payload

@@ -88,6 +86,5 @@ *

const result = Object.freeze({
payload,
toString: Object.freeze(() => cycleTolerantStringify(payload)),
});
declassifiers.add(result);
declassifiers.set(result, payload);
return result;

@@ -131,3 +128,3 @@ }

*
* @param {TemplateStringsArray} template The template to format
* @param {TemplateStringsArray | string[]} template The template to format
* @param {any[]} args Arguments to the template

@@ -147,3 +144,3 @@ * @returns {Complainer} The complainer for these details

argStr = `${arg}`;
arg = arg.payload;
arg = declassifiers.get(arg);
} else {

@@ -155,3 +152,3 @@ argStr = `(${an(typeof arg)})`;

// between each interleaved).
const priorWithoutSpace = interleaved.pop().replace(/ $/, '');
const priorWithoutSpace = (interleaved.pop() || '').replace(/ $/, '');
if (priorWithoutSpace !== '') {

@@ -191,2 +188,3 @@ interleaved.push(priorWithoutSpace);

* @param {Details} [optDetails] The details of what was asserted
* @returns {never}
*/

@@ -203,26 +201,9 @@ function fail(optDetails = details`Assert failed`) {

/**
* assert that expr is truthy, with an optional details to describe
* the assertion. It is a tagged template literal like
* ```js
* assert(expr, details`....`);`
* ```
* If expr is falsy, then the template contents are reported to the
* console and also in a thrown error.
*
* The literal portions of the template are assumed non-sensitive, as
* are the `typeof` types of the substitution values. These are
* assembled into the thrown error message. The actual contents of the
* substitution values are assumed sensitive, to be revealed to the
* console only. We assume only the virtual platform's owner can read
* what is written to the console, where the owner is in a privileged
* position over computation running on that platform.
*
* The optional `optDetails` can be a string for backwards compatibility
* with the nodejs assertion library.
* @param {*} flag The truthy/falsy value
* @param {Details} [optDetails] The details to throw
* @returns {asserts flag}
*/
function assert(flag, optDetails = details`Check failed`) {
if (!flag) {
fail(optDetails);
throw fail(optDetails);
}

@@ -236,2 +217,3 @@ }

* @param {Details} [optDetails] The details to throw
* @returns {void}
*/

@@ -248,8 +230,8 @@ function equal(

* Assert an expected typeof result.
*
* @param {*} specimen The value to get the typeof
* @type {AssertTypeof}
* @param {any} specimen The value to get the typeof
* @param {string} typename The expected name
* @param {Details} [optDetails] The details to throw
*/
function assertTypeof(specimen, typename, optDetails) {
const assertTypeof = (specimen, typename, optDetails) => {
assert(

@@ -269,9 +251,32 @@ typeof typename === 'string',

equal(typeof specimen, typename, optDetails);
}
};
assert.equal = equal;
assert.fail = fail;
assert.typeof = assertTypeof;
harden(assert);
/**
* assert that expr is truthy, with an optional details to describe
* the assertion. It is a tagged template literal like
* ```js
* assert(expr, details`....`);`
* ```
* If expr is falsy, then the template contents are reported to the
* console and also in a thrown error.
*
* The literal portions of the template are assumed non-sensitive, as
* are the `typeof` types of the substitution values. These are
* assembled into the thrown error message. The actual contents of the
* substitution values are assumed sensitive, to be revealed to the
* console only. We assume only the virtual platform's owner can read
* what is written to the console, where the owner is in a privileged
* position over computation running on that platform.
*
* The optional `optDetails` can be a string for backwards compatibility
* with the nodejs assertion library.
* @type {typeof assert & { typeof: AssertTypeof, fail: typeof fail, equal: typeof equal }}
*/
const assertCombined = Object.assign(assert, {
equal,
fail,
typeof: assertTypeof,
});
harden(assertCombined);
export { assert, details, q, an };
export { assertCombined as assert, details, q, an };
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