diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000000..e47b3326b1e --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +/dist +/src/bundles/ diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000000..b5b69ba1a4c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,21 @@ +/* global module */ +module.exports = { + extends: ['airbnb', 'plugin:prettier/recommended'], + env: { + es6: true, // supports new ES6 globals (e.g., new types such as Set) + }, + rules: { + 'implicit-arrow-linebreak': 'off', + 'function-paren-newline': 'off', + 'arrow-parens': 'off', + strict: 'off', + 'no-console': 'off', + 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + 'no-return-assign': 'off', + 'no-param-reassign': 'off', + 'no-restricted-syntax': ['off', 'ForOfStatement'], + 'no-unused-expressions': 'off', + 'no-loop-func': 'off', + 'import/prefer-default-export': 'off', // contrary to Agoric standard + }, +}; diff --git a/.gitignore b/.gitignore index ad46b30886f..485e458fc8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# emacs +*~ + # Logs logs *.log diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000000..011726d2368 --- /dev/null +++ b/.npmignore @@ -0,0 +1,15 @@ +# demo +scripts + +# non-applicable src +src/old +.misc + +# embedded local package +agoric-evaluate/node_modules + +# test +test + +# Travis CI +.circleci diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..10b90cd0ec9 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +# Proposal Realms +/proposal-realms \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000000..6e778b4fb9c --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,4 @@ +{ + "trailingComma": "all", + "singleQuote": true +} diff --git a/core/assays.js b/core/assays.js new file mode 100644 index 00000000000..5e98e5b106d --- /dev/null +++ b/core/assays.js @@ -0,0 +1,244 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import Nat from '@agoric/nat'; +import harden from '@agoric/harden'; + +import { insist } from '../util/insist'; +import { + sameStructure, + mustBeSameStructure, + mustBeComparable, +} from '../util/sameStructure'; + +// This assays.js module treats labels as black boxes. It is not aware +// of issuers, and so can handle labels whose issuers are merely +// presences of remote issuers. + +// Return an assay, which makes amounts, validates amounts, and +// provides set operations over amounts. An amount is a pass-by-copy +// description of some set of erights. An amount has a label and a +// quantity. All amounts made by the same assay have the same label +// but differ in quantity. +// +// An assay is pass-by-presence, but is not designed to be usefully +// passed. Rather, we expect each vat that needs to operate on amounts +// will have its own local assay to do so. +// +// The default assay makes the default kind of amount. The default +// kind of amount is a labeled natural number describing a quantity of +// fungible erights. The label describes what kinds of rights these +// are. This is a form of labeled unit, as in unit typing. +function makeNatAssay(label) { + mustBeComparable(label); + + // memoize well formedness check of amounts + const brand = new WeakSet(); + + const assay = harden({ + getLabel() { + return label; + }, + + // Given the raw quantity that this kind of amount would label, return + // an amount so labeling that quantity. + make(allegedQuantity) { + const amount = harden({ label, quantity: Nat(allegedQuantity) }); + brand.add(amount); + return amount; + }, + + // Is this an amount object made by this assay? If so, return + // it. Otherwise error. + vouch(amount) { + insist(brand.has(amount))`\ +Unrecognized amount: ${amount}`; + return amount; + }, + + // Is this like an amount object made by this assay, such as one + // received by pass-by-copy from an otherwise-identical remote + // amount? On success, return an amount object made by this + // assay. Otherwise error. + // + // Until we have good support for pass-by-construction, the full + // assay style is too awkward to use remotely. See + // mintTestAssay. So coerce also accepts a bare number which it + // will coerce to a labeled number via assay.make. + coerce(allegedAmount) { + if (typeof allegedAmount === 'number') { + // Will throw on inappropriate number + return assay.make(allegedAmount); + } + if (brand.has(allegedAmount)) { + return allegedAmount; + } + const { label: allegedLabel, quantity } = allegedAmount; + mustBeSameStructure(label, allegedLabel, 'Unrecognized label'); + // Will throw on inappropriate quantity + return assay.make(quantity); + }, + + // Return the raw quantity that this amount labels. + quantity(amount) { + return assay.vouch(amount).quantity; + }, + + // Represents the empty set of erights, i.e., no erights + empty() { + return assay.make(0); + }, + + isEmpty(amount) { + return assay.quantity(amount) === 0; + }, + + // Set inclusion of erights. + // Does the set of erights described by `leftAmount` include all + // the erights described by `rightAmount`? + includes(leftAmount, rightAmount) { + return assay.quantity(leftAmount) >= assay.quantity(rightAmount); + }, + + // Set union of erights. + // Describe all the erights described by `leftAmount` and those + // described by `rightAmount`. + with(leftAmount, rightAmount) { + return assay.make( + assay.quantity(leftAmount) + assay.quantity(rightAmount), + ); + }, + + // Covering set subtraction of erights. + // If leftAmount does not include rightAmount, error. + // Describe the erights described by `leftAmount` and not described + // by `rightAmount`. + without(leftAmount, rightAmount) { + return assay.make( + assay.quantity(leftAmount) - assay.quantity(rightAmount), + ); + }, + }); + return assay; +} +harden(makeNatAssay); + +// A uniAssay makes uni amounts, which are either empty or have unique +// descriptions. The quantity must either be null, in which case it is +// empty, or be some truthy comparable value, in which case it +// represents a single unique unit described by that truthy +// quantity. Combining two uni amounts with different truthy +// quantities fails, as they represent non-combinable rights. +function makeUniAssayMaker(descriptionCoercer = d => d) { + function makeUniAssay(label) { + mustBeComparable(label); + + const brand = new WeakSet(); + + const emptyAmount = harden({ label, quantity: null }); + brand.add(emptyAmount); + + const assay = harden({ + getLabel() { + return label; + }, + + make(optDescription) { + if (optDescription === null) { + return emptyAmount; + } + insist(!!optDescription)`\ +Uni optDescription must be either null or truthy ${optDescription}`; + mustBeComparable(optDescription); + + const description = descriptionCoercer(optDescription); + insist(!!description)`\ +Uni description must be truthy ${description}`; + mustBeComparable(description); + + const amount = harden({ label, quantity: description }); + brand.add(amount); + return amount; + }, + + vouch(amount) { + insist(brand.has(amount))`\ +Unrecognized amount: ${amount}`; + return amount; + }, + + coerce(allegedMetaAmount) { + if (brand.has(allegedMetaAmount)) { + return allegedMetaAmount; + } + const { label: allegedLabel, quantity } = allegedMetaAmount; + mustBeSameStructure(label, allegedLabel, 'Unrecognized label'); + return assay.make(quantity); + }, + + quantity(amount) { + return assay.vouch(amount).quantity; + }, + + empty() { + return emptyAmount; + }, + + isEmpty(amount) { + return assay.quantity(amount) === null; + }, + + includes(leftAmount, rightAmount) { + const leftQuant = assay.quantity(leftAmount); + const rightQuant = assay.quantity(rightAmount); + if (rightQuant === null) { + return true; + } + return sameStructure(leftQuant, rightQuant); + }, + + with(leftAmount, rightAmount) { + const leftQuant = assay.quantity(leftAmount); + const rightQuant = assay.quantity(rightAmount); + if (leftQuant === null) { + return rightAmount; + } + if (rightQuant === null) { + return leftAmount; + } + if (sameStructure(leftQuant, rightQuant)) { + // The "throw" is useless since insist(false) will unconditionally + // throw anyway. Rather, it informs IDEs of this control flow. + throw insist(false)`\ +Even identical non-empty uni amounts cannot be added together ${leftAmount}`; + } else { + // The "throw" is useless since insist(false) will unconditionally + // throw anyway. Rather, it informs IDEs of this control flow. + throw insist(false)`\ +Cannot combine different uni descriptions ${leftAmount} vs ${rightAmount}`; + } + }, + + without(leftAmount, rightAmount) { + const leftQuant = assay.quantity(leftAmount); + const rightQuant = assay.quantity(rightAmount); + if (rightQuant === null) { + return leftAmount; + } + insist(leftQuant !== null)`\ +Empty left does not include ${rightAmount}`; + + mustBeSameStructure( + leftQuant, + rightQuant, + 'Cannot subtract different uni descriptions', + ); + return emptyAmount; + }, + }); + return assay; + } + return harden(makeUniAssay); +} +harden(makeUniAssayMaker); + +export { makeNatAssay, makeUniAssayMaker }; diff --git a/core/contractHost.js b/core/contractHost.js new file mode 100644 index 00000000000..78febdc4526 --- /dev/null +++ b/core/contractHost.js @@ -0,0 +1,170 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import Nat from '@agoric/nat'; +import harden from '@agoric/harden'; + +import { makePrivateName } from '../util/PrivateName'; +import { allSettled } from '../util/allSettled'; +import { insist } from '../util/insist'; +import { mustBeSameStructure, allComparable } from '../util/sameStructure'; +import { makeUniAssayMaker } from './assays'; +import { makeMint } from './issuers'; +import makePromise from '../util/makePromise'; + +function makeContractHost(E, evaluate) { + // Maps from seat identity to seats + const seats = makePrivateName(); + // from seat identity to invite description. + const seatDescriptions = makePrivateName(); + // from installation to source code string + const installationSources = makePrivateName(); + + function descriptionCoercer(allegedDescription) { + const seatDesc = seatDescriptions.get(allegedDescription.seatIdentity); + mustBeSameStructure(seatDesc, allegedDescription); + return seatDesc; + } + const makeUniAssay = makeUniAssayMaker(descriptionCoercer); + const inviteMint = makeMint('contract host', makeUniAssay); + const inviteIssuer = inviteMint.getIssuer(); + const inviteAssay = inviteIssuer.getAssay(); + + function redeem(allegedInvitePayment) { + const allegedInviteAmount = allegedInvitePayment.getXferBalance(); + const inviteAmount = inviteAssay.vouch(allegedInviteAmount); + insist(!inviteAssay.isEmpty(inviteAmount))`\ +No invites left`; + const desc = inviteAssay.quantity(inviteAmount); + const { seatIdentity } = desc; + return E.resolve( + inviteIssuer.slash(inviteAmount, allegedInvitePayment), + ).then(_ => seats.get(seatIdentity)); + } + + // The contract host is designed to have a long-lived credible + // identity. + const contractHost = harden({ + getInviteIssuer() { + return inviteIssuer; + }, + + // The `contractSrc` is code for a contract function parameterized + // by `terms` and `inviteMaker`. `spawn` evaluates this code, + // calls that function to start the contract, and returns whatever + // the contract returns. + // + // TODO: The `spawn` method should spin off a new vat for each new + // contract instance. In the current single-vat implementation we + // could evaluate the contractSrc to a contract during install + // rather than spawn. However, once we spin off a new vat per + // spawn, we'll need to evaluate per-spawn anyway. Even though we + // do not save on evaluations, this currying enables us to avoid + // re-sending the contract source code, and it enables us to use + // the installation in descriptions rather than the source code + // itself. + install(contractSrc) { + const installation = harden({ + spawn(termsP) { + contractSrc = `${contractSrc}`; + const contract = evaluate(contractSrc, { + Nat, + harden, + console, + E, + makePromise, + }); + + return E.resolve(allComparable(termsP)).then(terms => { + const inviteMaker = harden({ + // Used by the contract to make invites for credibly + // participating in the contract. The returned invite + // can be redeemed for this seat. The inviteMaker + // contributes the description `{ installation, terms, + // seatIdentity, seatDesc }`. If this contract host + // redeems an invite, then the contractSrc and terms are + // accurate. The seatDesc is according to that + // contractSrc code. + make(seatDesc, seat, name = 'an invite payment') { + const seatIdentity = harden({}); + const seatDescription = harden({ + installation, + terms, + seatIdentity, + seatDesc, + }); + seats.init(seatIdentity, seat); + seatDescriptions.init(seatIdentity, seatDescription); + const inviteAmount = inviteAssay.make(seatDescription); + // This should be the only use of the invite mint, to + // make an invite purse whose quantity describes this + // seat. This invite purse makes the invite payment, + // and then the invite purse is dropped, in the sense + // that it becomes inaccessible. But it is not yet + // collectable. Until the returned invite payment is + // deposited, it will retain the invite purse, as the + // invite purse contains the (uselss in this case) + // usage rights. + const invitePurse = inviteMint.mint(inviteAmount, name); + return invitePurse.withdrawAll(name); + }, + redeem, + }); + return contract(terms, inviteMaker); + }); + }, + }); + installationSources.init(installation, contractSrc); + return installation; + }, + + // Verify that this is a genuine installation and show its source + // code. Thus, all genuine installations are transparent if one + // has their contractHost. + getInstallationSourceCode(installationP) { + return E.resolve(installationP).then(installation => + installationSources.get(installation), + ); + }, + + // If this is an invite payment made by an inviteMaker of this contract + // host, redeem it for the associated seat. Else error. Redeeming + // consumes the invite payment and also transfers the use rights. + redeem(allegedInvitePaymentP) { + return E.resolve(allegedInvitePaymentP).then(allegedInvitePayment => { + return redeem(allegedInvitePayment); + }); + }, + }); + return contractHost; +} +harden(makeContractHost); + +function makeCollect(E, log) { + function collect(seatP, winPurseP, refundPurseP, name = 'collecting') { + const results = harden([ + E(seatP) + .getWinnings() + .then(winnings => E(winPurseP).depositAll(winnings)), + // TODO Bug if we replace the comma above with the uncommented + // out ".then(_ => undefined)," below, somehow we end up trying + // to marshal an array with holes, rather than an array with + // undefined elements. This remains true whether we use + // Promise.all or allSettled + /* .then(_ => undefined), */ + E(seatP) + .getRefund() + .then(refund => refund && E(refundPurseP).depositAll(refund)), + ]); + const doneP = allSettled(results); + E.resolve(doneP).then(([wins, refs]) => { + log(`${name} wins: `, wins, ` refs: `, refs); + }); + // Use Promise.all here rather than allSettled in order to + // propagate rejection. + return Promise.all(results); + } + return harden(collect); +} +harden(makeCollect); + +export { makeContractHost, makeCollect }; diff --git a/core/coveredCall.js b/core/coveredCall.js new file mode 100644 index 00000000000..295899f5de7 --- /dev/null +++ b/core/coveredCall.js @@ -0,0 +1,55 @@ +/* global E */ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +function coveredCall(terms, inviteMaker) { + const [ + escrowExchangeInstallationP, + moneyNeeded, + stockNeeded, + timerP, + deadline, + ] = terms; + + const pairP = E(escrowExchangeInstallationP).spawn( + harden([moneyNeeded, stockNeeded]), + ); + + const aliceEscrowSeatP = E.resolve(pairP).then(pair => + inviteMaker.redeem(pair[0]), + ); + const bobEscrowSeatP = E.resolve(pairP).then(pair => + inviteMaker.redeem(pair[1]), + ); + + // Seats + + E(timerP) + .delayUntil(deadline) + .then(_ => E(bobEscrowSeatP).cancel('expired')); + + const bobSeat = harden({ + offer(stockPayment) { + const sIssuer = stockNeeded.label.issuer; + return E(sIssuer) + .getExclusive(stockNeeded, stockPayment, 'prePay') + .then(prePayment => { + E(bobEscrowSeatP).offer(prePayment); + return inviteMaker.make('holder', aliceEscrowSeatP); + }); + }, + getWinnings() { + return E(bobEscrowSeatP).getWinnings(); + }, + getRefund() { + return E(bobEscrowSeatP).getRefund(); + }, + }); + + return inviteMaker.make('writer', bobSeat); +} + +const coveredCallSrc = `(${coveredCall})`; + +export { coveredCall, coveredCallSrc }; diff --git a/core/escrow.js b/core/escrow.js new file mode 100644 index 00000000000..cac53ec4714 --- /dev/null +++ b/core/escrow.js @@ -0,0 +1,96 @@ +/* global E makePromise */ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +// For clarity, the code below internally speaks of a scenario is +// which Alice is trading some of her money for some of Bob's +// stock. However, for generality, the API does not expose names like +// "alice", "bob", "money", or "stock". Rather, Alice and Bob are +// players 0 and 1. Money are the rights transfered from player 0 to +// 1, and Stock are the rights transfered from 1 to 0. + +function escrowExchange(terms, inviteMaker) { + const [moneyNeeded, stockNeeded] = terms; + + function makeTransfer(amount, srcPaymentP) { + const { issuer } = amount.label; + const escrowP = E(issuer).getExclusive(amount, srcPaymentP, 'escrow'); + const winnings = makePromise(); + const refund = makePromise(); + return harden({ + phase1() { + return escrowP; + }, + phase2() { + winnings.res(escrowP); + refund.res(null); + }, + abort(reason) { + winnings.reject(reason); + refund.res(escrowP); + }, + getWinnings() { + return winnings.p; + }, + getRefund() { + return refund.p; + }, + }); + } + + // Promise wiring + + const moneyPayment = makePromise(); + const moneyTransfer = makeTransfer(moneyNeeded, moneyPayment.p); + + const stockPayment = makePromise(); + const stockTransfer = makeTransfer(stockNeeded, stockPayment.p); + + // TODO Use cancellation tokens instead. + const aliceCancel = makePromise(); + const bobCancel = makePromise(); + + // Set it all in motion optimistically. + + const decisionP = Promise.race([ + Promise.all([moneyTransfer.phase1(), stockTransfer.phase1()]), + aliceCancel.p, + bobCancel.p, + ]); + decisionP.then( + _ => { + moneyTransfer.phase2(); + stockTransfer.phase2(); + }, + reason => { + moneyTransfer.abort(reason); + stockTransfer.abort(reason); + }, + ); + + // Seats + + const aliceSeat = harden({ + offer: moneyPayment.res, + cancel: aliceCancel.reject, + getWinnings: stockTransfer.getWinnings, + getRefund: moneyTransfer.getRefund, + }); + + const bobSeat = harden({ + offer: stockPayment.res, + cancel: bobCancel.reject, + getWinnings: moneyTransfer.getWinnings, + getRefund: stockTransfer.getRefund, + }); + + return harden([ + inviteMaker.make('left', aliceSeat), + inviteMaker.make('right', bobSeat), + ]); +} + +const escrowExchangeSrc = `(${escrowExchange})`; + +export { escrowExchange, escrowExchangeSrc }; diff --git a/core/issuers.chainmail b/core/issuers.chainmail new file mode 100644 index 00000000000..109b81ee4e1 --- /dev/null +++ b/core/issuers.chainmail @@ -0,0 +1,56 @@ +class Assay[Quantity] { + type Label = { issuer: Issuer, description }; + type Amount = { label: Label, quantity: Quantity }; + + getLabel() ::Label; + make(allegedQuantity ?Quantity) ::Amount; + vouch(amount ?Amount) ::Amount + coerce(amountLike ?Amount) ::Amount; + quantity(amount ?Amount) ::Quantity; + empty() ::Amount; + isEmpty(amount ?Amount) ::boolean; + includes(leftAmount ?Amount, rightAmount ?Amount) ::boolean; + with(leftAmount ?Amount, rightAmount ?Amount) ::Amount; + without(leftAmount ?Amount, rightAmount ?Amount) ::Amount; +} +makeNatAssay(label ::Label) ::Assay; +makeMetaSingleAssayMaker( + baseLabelToAssayFn ::(Label -> Assay)) ::(Label -> Assay); + +class Issuer[Assay] { + type Amount = Assay.Amount; + getLabel() ::{ issuer ::Issuer, description }; + getAssay() ::Assay; + makeEmptyPurse(name ?String) ::Purse; + + class Mint { + getIssuer() Issuer; + mint(initialBalance ?Amount, name ?String) ::Purse; + } + class Payment { + getIssuer() ::Issuer; + getXferBalance() ::Amount; + } + class Purse { + getIssuer() ::Issuer; + getXferBalance() ::Amount; + getUseBalance() ::Amount; + deposit(amount ?Amount, srcPaymentP ?reveal[Promise]) ::Amount; + withdraw(amount ?Amount, name ?String) ::Purse; + } +} +makeMint(description, makeAssay ::(Label -> Assay)) ::Issuer[Assay].Mint; + +class Peg[RemoteIssuer, LocalIssuer] { + getLocalIssuer() ::LocalIssuer; + getRemoteIssuer() ::reveal; + retain(remoteAmount ?reveal, + remotePaymentP ?reveal, + name ?String) ::LocalIssuer.Payment; + redeem(localAmount ?LocalIssuer.Amount, + localPayment ?LocalIssuer.Payment, + name ?String) ::reveal; +} +makePeg(E, + remoteIssuerP ?reveal[Issuer], + makeAssay ::(Label -> Assay)) ::Peg; diff --git a/core/issuers.js b/core/issuers.js new file mode 100644 index 00000000000..348d0f1dc94 --- /dev/null +++ b/core/issuers.js @@ -0,0 +1,250 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +import { makePrivateName } from '../util/PrivateName'; +import { insist } from '../util/insist'; +import { makeNatAssay } from './assays'; + +function makeMint(description, makeAssay = makeNatAssay) { + insist(description)`\ +Description must be truthy: ${description}`; + + // Map from purse or payment to the transfer rights it currently + // holds. Transfer rights can move via payments, or they can cause a + // transfer of both the transfer and use rights by depositing it + // into a purse. + const xferRights = makePrivateName(); + + // Map from purse to useRights, where useRights do not include the + // right to transfer. Creating a payment moves some xferRights into the + // payment, but no useRights. Depositing a payment into another + // purse transfers both the xferRights and the useRights. + const useRights = makePrivateName(); + + // Map from payment to the home purse the payment came from. When the + // payment is deposited elsewhere, useRights are transfered from the + // home purse to the destination purse. + const homePurses = makePrivateName(); + + // src is a purse or payment. Return a fresh payment. One internal + // function used for both cases, since they are so similar. + function takePayment(amount, isPurse, src, _name) { + // eslint-disable-next-line no-use-before-define + amount = assay.coerce(amount); + _name = `${_name}`; + if (isPurse) { + insist(useRights.has(src))`\ +Purse expected: ${src}`; + } else { + insist(homePurses.has(src))`\ +Payment expected: ${src}`; + } + const srcOldXferAmount = xferRights.get(src); + // eslint-disable-next-line no-use-before-define + const srcNewXferAmount = assay.without(srcOldXferAmount, amount); + + // ///////////////// commit point ////////////////// + // All queries above passed with no side effects. + // During side effects below, any early exits should be made into + // fatal turn aborts. + + const payment = harden({ + getIssuer() { + // eslint-disable-next-line no-use-before-define + return issuer; + }, + getXferBalance() { + return xferRights.get(payment); + }, + }); + xferRights.set(src, srcNewXferAmount); + xferRights.init(payment, amount); + const homePurse = isPurse ? src : homePurses.get(src); + homePurses.init(payment, homePurse); + return payment; + } + + const issuer = harden({ + getLabel() { + // eslint-disable-next-line no-use-before-define + return assay.getLabel(); + }, + + getAssay() { + // eslint-disable-next-line no-use-before-define + return assay; + }, + + makeEmptyPurse(name = 'a purse') { + // eslint-disable-next-line no-use-before-define + return mint.mint(assay.empty(), name); // mint and issuer call each other + }, + + getExclusive(amount, srcPaymentP, name = 'a payment') { + return Promise.resolve(srcPaymentP).then(srcPayment => + takePayment(amount, false, srcPayment, name), + ); + }, + + getExclusiveAll(srcPaymentP, name = 'a payment') { + return Promise.resolve(srcPaymentP).then(srcPayment => + takePayment(xferRights.get(srcPayment), false, srcPayment, name), + ); + }, + + slash(amount, srcPaymentP) { + // We deposit the alleged payment, rather than just doing a get + // exclusive on it, in order to consume the usage erights as well. + const sinkPurse = issuer.makeEmptyPurse('sink purse'); + return sinkPurse.deposit(amount, srcPaymentP); + }, + + slashAll(srcPaymentP) { + const sinkPurse = issuer.makeEmptyPurse('sink purse'); + return sinkPurse.depositAll(srcPaymentP); + }, + }); + + const label = harden({ issuer, description }); + + const assay = makeAssay(label); + + function depositInto(purse, amount, srcPayment) { + amount = assay.coerce(amount); + const purseOldXferAmount = xferRights.get(purse); + const srcOldXferAmount = xferRights.get(srcPayment); + // Also checks that the union is representable + const purseNewXferAmount = assay.with(purseOldXferAmount, amount); + const srcNewXferAmount = assay.without(srcOldXferAmount, amount); + + const homePurse = homePurses.get(srcPayment); + const purseOldUseAmount = useRights.get(purse); + const homeOldUseAmount = useRights.get(homePurse); + // Also checks that the union is representable + const purseNewUseAmount = assay.with(purseOldUseAmount, amount); + const homeNewUseAmount = assay.without(homeOldUseAmount, amount); + + // ///////////////// commit point ////////////////// + // All queries above passed with no side effects. + // During side effects below, any early exits should be made into + // fatal turn aborts. + + xferRights.set(srcPayment, srcNewXferAmount); + xferRights.set(purse, purseNewXferAmount); + useRights.set(homePurse, homeNewUseAmount); + useRights.set(purse, purseNewUseAmount); + + return amount; + } + + const mint = harden({ + getIssuer() { + return issuer; + }, + mint(initialBalance, _name = 'a purse') { + initialBalance = assay.coerce(initialBalance); + _name = `${_name}`; + + const purse = harden({ + getIssuer() { + return issuer; + }, + getXferBalance() { + return xferRights.get(purse); + }, + getUseBalance() { + return useRights.get(purse); + }, + deposit(amount, srcPaymentP) { + return Promise.resolve(srcPaymentP).then(srcPayment => { + return depositInto(purse, amount, srcPayment); + }); + }, + depositAll(srcPaymentP) { + return Promise.resolve(srcPaymentP).then(srcPayment => { + return depositInto(purse, xferRights.get(srcPayment), srcPayment); + }); + }, + withdraw(amount, name = 'a withdrawal payment') { + return takePayment(amount, true, purse, name); + }, + withdrawAll(name = 'a withdrawal payment') { + return takePayment(xferRights.get(purse), true, purse, name); + }, + }); + xferRights.init(purse, initialBalance); + useRights.init(purse, initialBalance); + return purse; + }, + }); + return mint; +} +harden(makeMint); + +// Creates a local issuer that locally represents a remotely issued +// currency. Returns a promise for a peg object that asynchonously +// converts between the two. The local currency is synchronously +// transferable locally. +function makePeg(E, remoteIssuerP, makeAssay = makeNatAssay) { + const remoteLabelP = E(remoteIssuerP).getLabel(); + + // The remoteLabel is a local copy of the remote pass-by-copy + // label. It has a presence of the remote issuer and a copy of the + // description. + return Promise.resolve(remoteLabelP).then(remoteLabel => { + // Retaining remote currency deposits it in here. + // Redeeming local currency withdraws remote from here. + const backingPurseP = E(remoteIssuerP).makeEmptyPurse('backing'); + + const { description } = remoteLabel; + const localMint = makeMint(description, makeAssay); + const localIssuer = localMint.getIssuer(); + const localLabel = localIssuer.getLabel(); + + function localAmountOf(remoteAmount) { + return harden({ + label: localLabel, + quantity: remoteAmount.quantity, + }); + } + + function remoteAmountOf(localAmount) { + return harden({ + label: remoteLabel, + quantity: localAmount.quantity, + }); + } + + return harden({ + getLocalIssuer() { + return localIssuer; + }, + + getRemoteIssuer() { + return remoteIssuerP; + }, + + retainAll(remotePaymentP, name = 'backed') { + return E(backingPurseP) + .depositAll(remotePaymentP) + .then(remoteAmount => + localMint + .mint(localAmountOf(remoteAmount), `${name} purse`) + .withdrawAll(name), + ); + }, + + redeemAll(localPayment, name = 'redeemed') { + return localIssuer + .slashAll(localPayment) + .then(localAmount => + E(backingPurseP).withdraw(remoteAmountOf(localAmount), name), + ); + }, + }); + }); +} +harden(makePeg); + +export { makeMint, makePeg }; diff --git a/index.js b/index.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/more/handoff/corkboard.js b/more/handoff/corkboard.js new file mode 100644 index 00000000000..2d4947d1cac --- /dev/null +++ b/more/handoff/corkboard.js @@ -0,0 +1,33 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +// Allows multiple parties to store values for retrieval by others. +function makeCorkboard(name) { + const namedEntries = new Map(); + const orderedEntries = []; + + return harden({ + lookup(propertyName) { + if (!namedEntries.has(propertyName)) { + return undefined; + } + return namedEntries.get(propertyName)[0]; + }, + addEntry(key, value) { + if (namedEntries.has(key)) { + throw new Error(`Corkboard ${name} already has an entry for ${key}.`); + } + orderedEntries.push([key, value]); + namedEntries.set(key, [value, orderedEntries.length]); + return orderedEntries.length; + }, + getName() { + return name; + }, + // TODO(hibbert) retrieve by numbered position + }); +} +harden(makeCorkboard()); + +export { makeCorkboard }; diff --git a/more/handoff/corkboardAssay.js b/more/handoff/corkboardAssay.js new file mode 100644 index 00000000000..d6869d6c9ca --- /dev/null +++ b/more/handoff/corkboardAssay.js @@ -0,0 +1,132 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; +import { + mustBeComparable, + mustBeSameStructure, + sameStructure, +} from '../../util/sameStructure'; +import { insist } from '../../util/insist'; +import { makePrivateName } from '../../util/PrivateName'; + +// A CorkboardAssay vouches for Corkboards, which allow vats to connect to one +// another in a lightweight way. Corkboards can not be combined or split. +// The quantity must be a unique string. The empty value may be useful for empty +// purses. +function makeCorkboardAssayMaker(descriptionCoercer = d => d) { + function makeCorkboardAssay(label = 'generic') { + mustBeComparable(label); + + const brand = makePrivateName(); + + const emptyAmount = harden({ label, quantity: null }); + brand.init(emptyAmount); + + const assay = harden({ + getLabel() { + return label; + }, + + make(optDescription) { + if (optDescription === null) { + return emptyAmount; + } + insist(!!optDescription)`\ +Corkboard optDescription must be either null or truthy ${optDescription}`; + mustBeComparable(optDescription); + + const description = descriptionCoercer(optDescription); + insist(!!description)`\ +Corkboard description must be truthy ${description}`; + mustBeComparable(description); + + const amount = harden(description); + brand.init(amount); + return amount; + }, + + vouch(amount) { + insist(brand.has(amount))`\ +Unrecognized amount: ${amount}`; + return amount; + }, + + coerce(allegedMetaAmount) { + if (brand.has(allegedMetaAmount)) { + return allegedMetaAmount; + } + const { label: allegedLabel, quantity } = allegedMetaAmount; + mustBeSameStructure(label, allegedLabel, 'Unrecognized label'); + if (brand.has(quantity)) { + return brand.get(quantity); + } + return assay.make(quantity); + }, + + quantity(amount) { + return assay.vouch(amount).quantity; + }, + + empty() { + return emptyAmount; + }, + + isEmpty(amount) { + return assay.quantity(amount) === null; + }, + + includes(leftAmount, rightAmount) { + const leftQuant = assay.quantity(leftAmount); + const rightQuant = assay.quantity(rightAmount); + if (rightQuant === null) { + return true; + } + return leftQuant === rightQuant; + }, + + with(leftAmount, rightAmount) { + const leftQuant = assay.quantity(leftAmount); + const rightQuant = assay.quantity(rightAmount); + if (leftQuant === null) { + return rightAmount; + } + if (rightQuant === null) { + return leftAmount; + } + if (sameStructure(leftQuant, rightQuant)) { + // The "throw" is useless since insist(false) will unconditionally + // throw anyway. Rather, it informs IDEs of this control flow. + throw insist(false)`\ +Even identical non-empty uni amounts cannot be added together ${leftAmount}`; + } else { + // The "throw" is useless since insist(false) will unconditionally + // throw anyway. Rather, it informs IDEs of this control flow. + throw insist(false)`\ +Cannot combine different uni descriptions ${leftAmount} vs ${rightAmount}`; + } + }, + + without(leftAmount, rightAmount) { + const leftQuant = assay.quantity(leftAmount); + const rightQuant = assay.quantity(rightAmount); + if (rightQuant === null) { + return leftAmount; + } + insist(leftQuant !== null)`\ +Empty left does not include ${rightAmount}`; + + mustBeSameStructure( + leftQuant, + rightQuant, + 'Cannot subtract Corkboard descriptions', + ); + return emptyAmount; + }, + }); + return assay; + } + return harden(makeCorkboardAssay); +} +harden(makeCorkboardAssayMaker); + +export { makeCorkboardAssayMaker }; diff --git a/more/handoff/handoff.js b/more/handoff/handoff.js new file mode 100644 index 00000000000..3e1104290be --- /dev/null +++ b/more/handoff/handoff.js @@ -0,0 +1,44 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +import { makeCorkboardAssayMaker } from './corkboardAssay'; +import { makeCorkboard } from './corkboard'; + +function makeHandoffService() { + // I'd have used PrivateNames, but they want objects (not Strings) as Keys. + const boards = new Map(); + + const corkboardAssayMaker = makeCorkboardAssayMaker(); + const corkboardAssay = corkboardAssayMaker('root'); + + const handoffService = harden({ + // retrieve and remove from the map. + grab(key) { + if (!boards.has(key)) { + return undefined; + } + const result = boards.get(key); + // these are single-use entries. + boards.delete(key); + return result; + }, + createEntry(preferredName) { + if (boards.has(preferredName)) { + throw new Error(`Entry already exists: ${preferredName}`); + } + const corkBoard = makeCorkboard(preferredName); + boards.set(preferredName, corkBoard); + corkboardAssay.make(corkBoard); + return corkBoard; + }, + validate(allegedBoard) { + return corkboardAssay.vouch(allegedBoard); + }, + // We don't need remove, since grab can be used for that. + }); + + return handoffService; +} + +export { makeHandoffService }; diff --git a/more/pixels/pixelListAssay.js b/more/pixels/pixelListAssay.js new file mode 100644 index 00000000000..1cd62251beb --- /dev/null +++ b/more/pixels/pixelListAssay.js @@ -0,0 +1,129 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +import { insist } from '../../util/insist'; +import { + mustBeSameStructure, + mustBeComparable, +} from '../../util/sameStructure'; + +import { + insistPixelList, + includesPixelList, + withPixelList, + withoutPixelList, +} from './types/pixelList'; + +// A pixelList is a naive collection of pixels in the form: +// [ { x: 0, y: 0 }, { x: 1, y: 1} ...] +// This is less than ideal for efficiency and expressiveness but will +// do for now + +// a label is an object w/ the properties 'issuer' and 'description' +// issuer is an obj with methods like getExclusive & getEmptyPurse +// description is a string + +// our PixelLists should have the same issuer and the same description +// the description is "pixelList" + +function makePixelListAssayMaker(canvasSize) { + function makePixelListAssay(label) { + mustBeComparable(label); + + const brand = new WeakSet(); + + // our empty pixelList is an empty array + const emptyAmount = harden({ label, pixelList: [] }); + brand.add(emptyAmount); + + const assay = harden({ + getLabel() { + return label; + }, + + make(pixelList) { + mustBeComparable(pixelList); + insistPixelList(pixelList, canvasSize); + + if (pixelList.length === 0) { + return emptyAmount; + } + + const amount = harden({ label, quantity: pixelList }); + brand.add(amount); + return amount; + }, + + vouch(amount) { + insist(brand.has(amount))`\ + Unrecognized amount: ${amount}`; + return amount; + }, + + coerce(allegedPixelListAmount) { + if (brand.has(allegedPixelListAmount)) { + return allegedPixelListAmount; + } + const { + label: allegedLabel, + quantity: pixelList, + } = allegedPixelListAmount; + mustBeSameStructure(label, allegedLabel, 'Unrecognized label'); + return assay.make(pixelList); + }, + + quantity(amount) { + return assay.vouch(amount).quantity; + }, + + empty() { + return emptyAmount; + }, + + isEmpty(amount) { + return assay.quantity(amount) === []; + }, + + // does left include right? + includes(leftAmount, rightAmount) { + const leftPixelList = assay.quantity(leftAmount); + const rightPixelList = assay.quantity(rightAmount); + + return includesPixelList(leftPixelList, rightPixelList); + }, + + // set union + with(leftAmount, rightAmount) { + const leftPixelList = assay.quantity(leftAmount); + const rightPixelList = assay.quantity(rightAmount); + + return harden({ + label, + quantity: withPixelList(leftPixelList, rightPixelList), + }); + }, + + // Covering set subtraction of erights. + // If leftAmount does not include rightAmount, error. + // Describe the erights described by `leftAmount` and not described + // by `rightAmount`. + without(leftAmount, rightAmount) { + const leftPixelList = assay.quantity(leftAmount); + const rightPixelList = assay.quantity(rightAmount); + + const pixelList = withoutPixelList(leftPixelList, rightPixelList); + + return harden({ + label, + quantity: pixelList, + }); + }, + }); + return assay; + } + return harden(makePixelListAssay); +} +harden(makePixelListAssayMaker); + +export { makePixelListAssayMaker }; diff --git a/more/pixels/types/area.js b/more/pixels/types/area.js new file mode 100644 index 00000000000..2d010054a86 --- /dev/null +++ b/more/pixels/types/area.js @@ -0,0 +1,63 @@ +import { insistPixel, isLessThanOrEqual } from './pixel'; +import { insistIncludesPixel } from './pixelList'; + +import { insist } from '../../../util/insist'; + +function insistLessThanOrEqual(start, end) { + insist(isLessThanOrEqual(start, end))`/ + the starting pixel must be "less than or equal" to the ending pixel`; +} + +function insistArea(area, canvasSize) { + const properties = Object.getOwnPropertyNames(area); + insist(properties.length === 2)`\ + areas must have start, end properties only`; + + insistPixel(area.start, canvasSize); + insistPixel(area.end, canvasSize); + + insistLessThanOrEqual(area.start, area.end); + + return area; +} + +// should only be used with valid pixels - no checks +function isEqual(leftArea, rightArea) { + return leftArea.start === rightArea.start && leftArea.end === rightArea.end; +} + +// should only be used with valid pixels - no checks +// Does the area include the pixel? +function includes(area, pixel) { + const pixelAfterStartX = pixel.x >= area.start.x; + const pixelAfterStartY = pixel.y >= area.start.y; + const pixelBeforeEndX = pixel.x <= area.end.x; + const pixelBeforeEndY = pixel.y <= area.end.y; + return ( + pixelAfterStartX && pixelAfterStartY && pixelBeforeEndX && pixelBeforeEndY + ); +} + +// actually this isn't enough, we need to confirm that all the pixels +// are there, and then burn them to create the area. +function makeArea(allegedArea, pixelList, canvasSize) { + const { start, end } = allegedArea; + const area = insistArea(allegedArea, canvasSize); + + for (let { x } = start; x <= end.x; x += 1) { + for (let { y } = start; y <= end.y; y += 1) { + // check that all of the pixels within the area are included in + // the pixelList + const pixel = { x, y }; + insistIncludesPixel(pixelList, pixel); + } + } + return area; +} + +// example +// 2 x 2 area, from 2, 2 to 4, 4 +// 2 3 +// 3 4 + +export { insistArea, isEqual, makeArea, includes }; diff --git a/more/pixels/types/pixel.js b/more/pixels/types/pixel.js new file mode 100644 index 00000000000..aa77d67bb8b --- /dev/null +++ b/more/pixels/types/pixel.js @@ -0,0 +1,36 @@ +import Nat from '@agoric/nat'; + +import { insist } from '../../../util/insist'; + +function insistWithinBounds(num, canvasSize) { + Nat(num); + Nat(canvasSize); + // 0 to canvasSize - 1 + insist(num >= 0 && num < canvasSize)`\ + pixel position must be within bounds`; +} + +function insistPixel(pixel, canvasSize) { + const properties = Object.getOwnPropertyNames(pixel); + insist(properties.length === 2)`\ + pixels must have x, y properties only`; + + insistWithinBounds(pixel.x, canvasSize); + insistWithinBounds(pixel.y, canvasSize); +} + +// should only be used with valid pixels - no checks +function isEqual(leftPixel, rightPixel) { + return leftPixel.x === rightPixel.x && leftPixel.y === rightPixel.y; +} + +// upper left is 0, 0 +// lower right is NUM_PIXEL, NUM_PIXEL +// upper left is "less than" lower right + +// should only be used with valid pixels +function isLessThanOrEqual(leftPixel, rightPixel) { + return leftPixel.x <= rightPixel.x && leftPixel.y <= rightPixel.y; +} + +export { insistWithinBounds, insistPixel, isEqual, isLessThanOrEqual }; diff --git a/more/pixels/types/pixelList.js b/more/pixels/types/pixelList.js new file mode 100644 index 00000000000..eec8da1f5f1 --- /dev/null +++ b/more/pixels/types/pixelList.js @@ -0,0 +1,99 @@ +import { insistPixel, isEqual } from './pixel'; +import { passStyleOf } from '../../../util/marshal'; + +import { insist } from '../../../util/insist'; + +// pixelList is the most naive bundling of pixels +// it is just an array of pixels +function insistPixelList(pixelList, canvasSize) { + insist(passStyleOf(pixelList) === 'copyArray')`pixelList must be an array`; + for (let i = 0; i < pixelList.length; i += 1) { + insistPixel(pixelList[i], canvasSize); + } +} + +// does not check validity of the pixel or pixelList +function includesPixel(pixelList, pixel) { + let result = false; + for (const p of pixelList) { + if (isEqual(pixel, p)) { + result = true; + } + } + return result; +} + +// does not check validity of the pixel or pixelList +// does pixelList include pixel +function insistIncludesPixel(pixelList, pixel) { + insist(includesPixel(pixelList, pixel))`pixel is not in pixelList`; +} + +// does left include right? +function includesPixelList(leftPixelList, rightPixelList) { + // iterate through the pixels in the rightPixelList, see if left + // includes it + + // if rightPixelList is empty, this just returns true + for (let i = 0; i < rightPixelList.length; i += 1) { + const rightPixel = rightPixelList[i]; + const result = includesPixel(leftPixelList, rightPixel); + if (!result) { + return false; // return early if false + } + } + return true; +} + +function insistIncludesPixelList(leftPixelList, rightPixelList) { + insist(includesPixelList(leftPixelList, rightPixelList))`\ + leftPixelList is not in rightPixelList`; +} + +function withPixelList(leftPixelList, rightPixelList) { + const combinedList = Array.from(leftPixelList); + for (const rightPixel of rightPixelList) { + if (!includesPixel(leftPixelList, rightPixel)) { + combinedList.push(rightPixel); + } + } + return combinedList; +} + +// Covering set subtraction of erights. +// If leftAmount does not include rightAmount, error. +// Describe the erights described by `leftAmount` and not described +// by `rightAmount`. +function withoutPixelList(leftPixelList, rightPixelList) { + insistIncludesPixelList(leftPixelList, rightPixelList); + const leftMinusRight = []; + for (const leftPixel of leftPixelList) { + if (!includesPixel(rightPixelList, leftPixel)) { + leftMinusRight.push(leftPixel); + } + } + return leftMinusRight; +} + +function makeWholePixelList(canvasSize) { + const pixelList = []; + for (let x = 0; x < canvasSize; x += 1) { + for (let y = 0; y < canvasSize; y += 1) { + pixelList.push({ + x, + y, + }); + } + } + return pixelList; +} + +export { + insistPixelList, + includesPixel, + insistIncludesPixel, + includesPixelList, + withPixelList, + withoutPixelList, + makeWholePixelList, +}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000000..1e007d4a468 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2015 @@ +{ + "name": "ertp", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@agoric/harden": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@agoric/harden/-/harden-0.0.4.tgz", + "integrity": "sha512-WvTw2otvchy3mScAvqQcX0l6049xp6cF17/Pw0PNNqUTJtOo/84tE9OyBSjEp8wn/XBNArPaJuRjMhQpIQ775Q==", + "requires": { + "@agoric/make-hardener": "0.0.4" + } + }, + "@agoric/make-hardener": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@agoric/make-hardener/-/make-hardener-0.0.4.tgz", + "integrity": "sha512-0k/wGkIVQO3IY7p/H/5OS3BIXsRK9Qb7nHnqyvj6hzvSyumwgPp8e4rz5QaVWSen43TGJl+zQn4mW9ZZShT1aw==" + }, + "@agoric/nat": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@agoric/nat/-/nat-2.0.1.tgz", + "integrity": "sha512-puvWkoaJovQib/YaSRSGJ8Kn9rogi/yyaVa3d5znSZb5WiYfUiEKW35BfexHhAdi0VfPz2anFHoRBoBSUIijNA==" + }, + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "acorn": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", + "dev": true + }, + "acorn-jsx": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", + "integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==", + "dev": true + }, + "ajv": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", + "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "aria-query": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-3.0.0.tgz", + "integrity": "sha1-ZbP8wcoRVajJrmTW7uKX8V1RM8w=", + "dev": true, + "requires": { + "ast-types-flow": "0.0.7", + "commander": "^2.11.0" + } + }, + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" + } + }, + "ast-types-flow": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz", + "integrity": "sha1-9wtzXGvKGlycItmCw+Oef+ujva0=", + "dev": true + }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, + "axobject-query": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.0.2.tgz", + "integrity": "sha512-MCeek8ZH7hKyO1rWUbKNQBbl4l2eY0ntk7OGi+q0RlafrCnfPxC06WZA+uebCfmYp4mNU9jRBP1AhGyf8+W3ww==", + "dev": true, + "requires": { + "ast-types-flow": "0.0.7" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "buffer-shims": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", + "dev": true + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "damerau-levenshtein": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.5.tgz", + "integrity": "sha512-CBCRqFnpu715iPmw1KrdOrzRqbdFwQTwAWyyyYS42+iAgHCuXZ+/TdMgQkUENPomxEz9z1BEzuQU2Xw0kUuAgA==", + "dev": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "requires": { + "object-keys": "^1.0.12" + } + }, + "defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", + "dev": true + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true + }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eslint": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", + "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.9.1", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^4.0.3", + "eslint-utils": "^1.3.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^5.0.1", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^6.2.2", + "js-yaml": "^3.13.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^5.5.1", + "strip-ansi": "^4.0.0", + "strip-json-comments": "^2.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0" + } + }, + "eslint-config-airbnb": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-17.1.0.tgz", + "integrity": "sha512-R9jw28hFfEQnpPau01NO5K/JWMGLi6aymiF6RsnMURjTk+MqZKllCqGK/0tOvHkPi/NWSSOU2Ced/GX++YxLnw==", + "dev": true, + "requires": { + "eslint-config-airbnb-base": "^13.1.0", + "object.assign": "^4.1.0", + "object.entries": "^1.0.4" + } + }, + "eslint-config-airbnb-base": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.1.0.tgz", + "integrity": "sha512-XWwQtf3U3zIoKO1BbHh6aUhJZQweOwSt4c2JrPDg9FP3Ltv3+YfEv7jIDB8275tVnO/qOHbfuYg3kzw6Je7uWw==", + "dev": true, + "requires": { + "eslint-restricted-globals": "^0.1.1", + "object.assign": "^4.1.0", + "object.entries": "^1.0.4" + } + }, + "eslint-config-prettier": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-4.3.0.tgz", + "integrity": "sha512-sZwhSTHVVz78+kYD3t5pCWSYEdVSBR0PXnwjDRsUs8ytIrK8PLXw+6FKp8r3Z7rx4ZszdetWlXYKOHoUrrwPlA==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + } + }, + "eslint-import-resolver-node": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", + "integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "resolve": "^1.5.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "eslint-module-utils": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.0.tgz", + "integrity": "sha512-14tltLm38Eu3zS+mt0KvILC3q8jyIAH518MlG+HO0p+yK885Lb1UHTY/UgR91eOyGdmxAPb+OLoW4znqIT6Ndw==", + "dev": true, + "requires": { + "debug": "^2.6.8", + "pkg-dir": "^2.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "eslint-plugin-import": { + "version": "2.17.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.3.tgz", + "integrity": "sha512-qeVf/UwXFJbeyLbxuY8RgqDyEKCkqV7YC+E5S5uOjAp4tOc8zj01JP3ucoBM8JcEqd1qRasJSg6LLlisirfy0Q==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "contains-path": "^0.1.0", + "debug": "^2.6.9", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "^0.3.2", + "eslint-module-utils": "^2.4.0", + "has": "^1.0.3", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "read-pkg-up": "^2.0.0", + "resolve": "^1.11.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "doctrine": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "isarray": "^1.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "eslint-plugin-jsx-a11y": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.2.1.tgz", + "integrity": "sha512-cjN2ObWrRz0TTw7vEcGQrx+YltMvZoOEx4hWU8eEERDnBIU00OTq7Vr+jA7DFKxiwLNv4tTh5Pq2GUNEa8b6+w==", + "dev": true, + "requires": { + "aria-query": "^3.0.0", + "array-includes": "^3.0.3", + "ast-types-flow": "^0.0.7", + "axobject-query": "^2.0.2", + "damerau-levenshtein": "^1.0.4", + "emoji-regex": "^7.0.2", + "has": "^1.0.3", + "jsx-ast-utils": "^2.0.1" + } + }, + "eslint-plugin-prettier": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz", + "integrity": "sha512-XWX2yVuwVNLOUhQijAkXz+rMPPoCr7WFiAl8ig6I7Xn+pPVhDhzg4DxHpmbeb0iqjO9UronEA3Tb09ChnFVHHA==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-plugin-react": { + "version": "7.13.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.13.0.tgz", + "integrity": "sha512-uA5LrHylu8lW/eAH3bEQe9YdzpPaFd9yAJTwTi/i/BKTD7j6aQMKVAdGM/ML72zD6womuSK7EiGtMKuK06lWjQ==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "doctrine": "^2.1.0", + "has": "^1.0.3", + "jsx-ast-utils": "^2.1.0", + "object.fromentries": "^2.0.0", + "prop-types": "^15.7.2", + "resolve": "^1.10.1" + }, + "dependencies": { + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + } + } + }, + "eslint-restricted-globals": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz", + "integrity": "sha1-NfDVy8ZMLj7WLpO0saevBbp+1Nc=", + "dev": true + }, + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", + "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==", + "dev": true + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "dev": true + }, + "esm": { + "version": "3.2.25", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", + "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" + }, + "espree": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", + "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "dev": true, + "requires": { + "acorn": "^6.0.7", + "acorn-jsx": "^5.0.0", + "eslint-visitor-keys": "^1.0.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "external-editor": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", + "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + } + }, + "flatted": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", + "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", + "dev": true + }, + "for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "requires": { + "is-callable": "^1.1.3" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", + "dev": true + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + } + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", + "dev": true + }, + "hosted-git-info": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", + "integrity": "sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "inquirer": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.3.1.tgz", + "integrity": "sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA==", + "dev": true, + "requires": { + "ansi-escapes": "^3.2.0", + "chalk": "^2.4.2", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^2.0.0", + "lodash": "^4.17.11", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^6.4.0", + "string-width": "^2.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-callable": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", + "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "dev": true + }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "dev": true + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "dev": true, + "requires": { + "has": "^1.0.1" + } + }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "jsx-ast-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.1.0.tgz", + "integrity": "sha512-yDGDG2DS4JcqhA6blsuYbtsT09xL8AoLuUR2Gb5exrw7UEM19sBcOTq+YBBhrNbl0PUC4R4LnFu+dHg2HKeVvA==", + "dev": true, + "requires": { + "array-includes": "^3.0.3" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-inspect": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", + "integrity": "sha512-GJzfBZ6DgDAmnuaM3104jR4s1Myxr3Y3zfIyN4z3UdqN69oSRacNK8UhnobDdC+7J2AHCjGwxQubNJfE70SXXQ==", + "dev": true + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true + }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.entries": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", + "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, + "object.fromentries": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.0.tgz", + "integrity": "sha512-9iLiI6H083uiqUuvzyY6qrlmc/Gz8hLQFOcb/Ri/0xXFkSNS3ctV+CbE6yM2+AnkYfOB3dGjdzC0wrMLIhQICA==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.11.0", + "function-bind": "^1.1.1", + "has": "^1.0.1" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, + "parse-ms": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-1.0.1.tgz", + "integrity": "sha1-VjRtR0nXjyNDDKDHE4UK75GqNh0=", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + } + }, + "plur": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/plur/-/plur-1.0.0.tgz", + "integrity": "sha1-24XGgU9eXlo7Se/CjWBP7GKXUVY=", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prettier": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.1.tgz", + "integrity": "sha512-TzGRNvuUSmPgwivDqkZ9tM/qTGW9hqDKWOE9YHiyQdixlKbv7kvEqsmDPrcHJTKwthU774TQwZXVtaQ/mMsvjg==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, + "pretty-ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-2.1.0.tgz", + "integrity": "sha1-QlfCVt8/sLRR1q/6qwIYhBJpgdw=", + "dev": true, + "requires": { + "is-finite": "^1.0.1", + "parse-ms": "^1.0.0", + "plur": "^1.0.0" + } + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "re-emitter": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/re-emitter/-/re-emitter-1.1.3.tgz", + "integrity": "sha1-+p4xn/3u6zWycpbvDz03TawvUqc=", + "dev": true + }, + "react-is": { + "version": "16.8.6", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.6.tgz", + "integrity": "sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==", + "dev": true + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + } + }, + "readable-stream": { + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz", + "integrity": "sha1-z3jsb0ptHrQ9JkiMrJfwQudLf8g=", + "dev": true, + "requires": { + "buffer-shims": "~1.0.0", + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "~1.0.0", + "process-nextick-args": "~1.0.6", + "string_decoder": "~1.0.0", + "util-deprecate": "~1.0.1" + } + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "resolve": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", + "integrity": "sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "resumer": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", + "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", + "dev": true, + "requires": { + "through": "~2.3.4" + } + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "rxjs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", + "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "dev": true + }, + "ses": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/ses/-/ses-0.5.0.tgz", + "integrity": "sha512-alpPOmwrlOhg52o2ix7ZaXMCqhQ7MrZ4AR+BZSB2VmiFJ8u5L9sRIZGkfmom0Dexal6RXvNUJkx81QwXVQx9Kg==", + "requires": { + "@agoric/make-hardener": "^0.0.4", + "esm": "^3.2.5" + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + } + }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz", + "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", + "dev": true + }, + "split": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.0.tgz", + "integrity": "sha1-xDlc5oOrzSVLwo/h2rtuXCfc/64=", + "dev": true, + "requires": { + "through": "2" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "string.prototype.trim": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", + "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.0", + "function-bind": "^1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "table": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.0.tgz", + "integrity": "sha512-nHFDrxmbrkU7JAFKqKbDJXfzrX2UBsWmrieXFTGxiI5e4ncg3VqsZeI4EzNmX0ncp4XNGVeoxIWJXfCIXwrsvw==", + "dev": true, + "requires": { + "ajv": "^6.9.1", + "lodash": "^4.17.11", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "tap-out": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tap-out/-/tap-out-2.1.0.tgz", + "integrity": "sha512-LJE+TBoVbOWhwdz4+FQk40nmbIuxJLqaGvj3WauQw3NYYU5TdjoV3C0x/yq37YAvVyi+oeBXmWnxWSjJ7IEyUw==", + "dev": true, + "requires": { + "re-emitter": "1.1.3", + "readable-stream": "2.2.9", + "split": "1.0.0", + "trim": "0.0.1" + } + }, + "tap-spec": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/tap-spec/-/tap-spec-5.0.0.tgz", + "integrity": "sha512-zMDVJiE5I6Y4XGjlueGXJIX2YIkbDN44broZlnypT38Hj/czfOXrszHNNJBF/DXR8n+x6gbfSx68x04kIEHdrw==", + "dev": true, + "requires": { + "chalk": "^1.0.0", + "duplexer": "^0.1.1", + "figures": "^1.4.0", + "lodash": "^4.17.10", + "pretty-ms": "^2.1.0", + "repeat-string": "^1.5.2", + "tap-out": "^2.1.0", + "through2": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "tape": { + "version": "4.10.2", + "resolved": "https://registry.npmjs.org/tape/-/tape-4.10.2.tgz", + "integrity": "sha512-mgl23h7W2yuk3N85FOYrin2OvThTYWdwbk6XQ1pr2PMJieyW2FM/4Bu/+kD/wecb3aZ0Enm+Syinyq467OPq2w==", + "dev": true, + "requires": { + "deep-equal": "~1.0.1", + "defined": "~1.0.0", + "for-each": "~0.3.3", + "function-bind": "~1.1.1", + "glob": "~7.1.4", + "has": "~1.0.3", + "inherits": "~2.0.3", + "minimist": "~1.2.0", + "object-inspect": "~1.6.0", + "resolve": "~1.10.1", + "resumer": "~0.0.0", + "string.prototype.trim": "~1.1.2", + "through": "~2.3.8" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "resolve": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz", + "integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, + "tape-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/tape-promise/-/tape-promise-4.0.0.tgz", + "integrity": "sha512-mNi5yhWAKDuNgZCfFKeZbsXvraVOf+I8UZG+lf+aoRrzX4+jd4mpNBjYh16/VcpEMUtS0iFndBgnfxxZbtyLFw==", + "dev": true, + "requires": { + "is-promise": "^2.1.0", + "onetime": "^2.0.0" + } + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "requires": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + }, + "dependencies": { + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "trim": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", + "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=", + "dev": true + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000000..c8e1bafbcce --- /dev/null +++ b/package.json @@ -0,0 +1,52 @@ +{ + "name": "ertp", + "version": "0.0.1", + "description": "Electronic Rights Transfer Protocol (ERTP). A smart contract framework for exchanging electronic rights", + "main": "index.js", + "engines": { + "node": ">=11.0" + }, + "scripts": { + "test": "tape -r esm 'test/**/test*.js' | tap-spec", + "pretty-fix": "prettier --write '**/*.{js,jsx}'", + "pretty-check": "prettier --check '**/*.{js,jsx}'", + "lint-fix": "eslint --fix '**/*.{js,jsx}'", + "lint-check": "eslint '**/*.{js,jsx}'" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Agoric/ertp.git" + }, + "keywords": [ + "smart", + "contract", + "cryptocurrency", + "exchange", + "tokens" + ], + "author": "Agoric", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/Agoric/ertp/issues" + }, + "homepage": "https://github.com/Agoric/ertp#readme", + "dependencies": { + "@agoric/harden": "0.0.4", + "@agoric/nat": "^2.0.1", + "ses": "^0.5.0" + }, + "devDependencies": { + "eslint": "^5.16.0", + "eslint-config-airbnb": "^17.1.0", + "eslint-config-prettier": "^4.3.0", + "eslint-plugin-import": "^2.17.3", + "eslint-plugin-jsx-a11y": "^6.2.1", + "eslint-plugin-prettier": "^3.1.0", + "eslint-plugin-react": "^7.13.0", + "esm": "^3.2.25", + "prettier": "^1.17.1", + "tap-spec": "^5.0.0", + "tape": "^4.10.2", + "tape-promise": "^4.0.0" + } +} diff --git a/test/pixels/types/test-area.js b/test/pixels/types/test-area.js new file mode 100644 index 00000000000..92dec270652 --- /dev/null +++ b/test/pixels/types/test-area.js @@ -0,0 +1,102 @@ +import { test } from 'tape-promise/tape'; + +import { + insistArea, + isEqual, + makeArea, + includes, +} from '../../../more/pixels/types/area'; + +test('area insistArea', t => { + t.doesNotThrow(() => + insistArea( + { + start: { x: 0, y: 0 }, + end: { x: 2, y: 2 }, + }, + 5, + ), + ); + t.doesNotThrow(() => + insistArea( + { + start: { x: 0, y: 0 }, + end: { x: 0, y: 0 }, + }, + 5, + ), + ); + t.throws(() => + insistArea( + { + end: { x: 0, y: 0 }, + }, + 5, + ), + ); + t.throws(() => + insistArea( + { + start: { x: 0, y: 0 }, + end: { x: 3, y: 0 }, + }, + 1, + ), + ); + t.throws(() => + insistArea( + { + start: { x: 3, y: 0 }, + end: { x: 0, y: 0 }, + }, + 5, + ), + ); + t.end(); +}); + +test('area isEqual', t => { + const start = { x: 2, y: 2 }; + const end = { x: 4, y: 4 }; + t.true(isEqual({ start, end }, { start, end })); + + t.false( + isEqual( + { + start: { x: 1, y: 3 }, + end, + }, + { start, end }, + ), + ); + t.end(); +}); + +test('area includes', t => { + const start = { x: 2, y: 2 }; + const end = { x: 4, y: 4 }; + t.true(includes({ start, end }, { x: 3, y: 3 })); + t.true(includes({ start, end }, { x: 2, y: 2 })); + t.false(includes({ start, end }, { x: 0, y: 0 })); + t.end(); +}); + +test('area makeArea', t => { + // makeArea(allegedArea, pixelList, canvasSize) + const start = { x: 2, y: 2 }; + const end = { x: 4, y: 4 }; + const pixelList = [ + start, + { x: 2, y: 3 }, + { x: 2, y: 4 }, + { x: 3, y: 2 }, + { x: 3, y: 3 }, + { x: 3, y: 4 }, + { x: 4, y: 2 }, + { x: 4, y: 3 }, + end, + ]; + + t.deepEqual(makeArea({ start, end }, pixelList, 5), { start, end }); + t.end(); +}); diff --git a/test/pixels/types/test-pixel-list.js b/test/pixels/types/test-pixel-list.js new file mode 100644 index 00000000000..f4a4a789780 --- /dev/null +++ b/test/pixels/types/test-pixel-list.js @@ -0,0 +1,149 @@ +import { test } from 'tape-promise/tape'; +import harden from '@agoric/harden'; + +import { + insistPixelList, + includesPixel, + insistIncludesPixel, + includesPixelList, + withPixelList, + withoutPixelList, + makeWholePixelList, +} from '../../../more/pixels/types/pixelList'; + +test('pixelList insistPixelList', t => { + const startPixel = { x: 0, y: 0 }; + const secondPixel = { x: 0, y: 1 }; + const thirdPixel = { x: 0, y: 2 }; + const pixelList = harden([startPixel, secondPixel, thirdPixel]); + t.doesNotThrow(() => insistPixelList(pixelList, 5)); + t.throws(() => insistPixelList(startPixel, 5)); + t.throws(() => insistPixelList({}, 5)); + t.throws(() => insistPixelList([thirdPixel], 1)); + t.end(); +}); + +test('pixelList includesPixel', t => { + const startPixel = { x: 0, y: 0 }; + const secondPixel = { x: 0, y: 1 }; + const thirdPixel = { x: 0, y: 2 }; + const fourthPixel = { x: 9, y: 1 }; + const pixelList = harden([startPixel, secondPixel, thirdPixel]); + t.true(includesPixel(pixelList, startPixel)); + t.true(includesPixel(pixelList, secondPixel)); + t.true(includesPixel(pixelList, thirdPixel)); + t.false(includesPixel(pixelList, fourthPixel)); + t.end(); +}); + +test('pixelList insistIncludesPixel', t => { + const startPixel = { x: 0, y: 0 }; + const secondPixel = { x: 0, y: 1 }; + const thirdPixel = { x: 0, y: 2 }; + const fourthPixel = { x: 9, y: 1 }; + const pixelList = harden([startPixel, secondPixel, thirdPixel]); + t.doesNotThrow(() => insistIncludesPixel(pixelList, startPixel)); + t.doesNotThrow(() => insistIncludesPixel(pixelList, secondPixel)); + t.doesNotThrow(() => insistIncludesPixel(pixelList, thirdPixel)); + t.throws(() => insistIncludesPixel(pixelList, fourthPixel)); + t.end(); +}); + +test('pixelList includesPixelList', t => { + const startPixel = { x: 0, y: 0 }; + const secondPixel = { x: 0, y: 1 }; + const thirdPixel = { x: 0, y: 2 }; + const fourthPixel = { x: 9, y: 1 }; + t.true(includesPixelList(harden([]), harden([]))); + t.true(includesPixelList(harden([startPixel]), harden([]))); + t.true(includesPixelList(harden([startPixel]), harden([startPixel]))); + t.true( + includesPixelList(harden([startPixel, secondPixel]), harden([startPixel])), + ); + t.false(includesPixelList(harden([]), harden([startPixel]))); + t.false(includesPixelList(harden([startPixel]), harden([secondPixel]))); + t.false( + includesPixelList( + harden([startPixel, thirdPixel]), + harden([secondPixel, fourthPixel]), + ), + ); + t.false( + includesPixelList( + [startPixel, secondPixel, thirdPixel], + [thirdPixel, fourthPixel], + ), + ); + t.end(); +}); + +test('pixelList withPixelList', t => { + const startPixel = { x: 0, y: 0 }; + const secondPixel = { x: 0, y: 1 }; + t.deepEqual(withPixelList(harden([]), harden([])), []); + t.deepEqual(withPixelList(harden([startPixel]), harden([])), [startPixel]); + t.deepEqual(withPixelList(harden([]), harden([startPixel])), [startPixel]); + t.deepEqual(withPixelList(harden([startPixel]), harden([startPixel])), [ + startPixel, + ]); + t.deepEqual(withPixelList(harden([startPixel]), harden([secondPixel])), [ + startPixel, + secondPixel, + ]); + t.deepEqual( + withPixelList(harden([startPixel, secondPixel]), harden([secondPixel])), + [startPixel, secondPixel], + ); + t.end(); +}); + +test('pixelList withoutPixelList', t => { + const startPixel = { x: 0, y: 0 }; + const secondPixel = { x: 0, y: 1 }; + t.deepEqual(withoutPixelList(harden([]), harden([])), []); + t.deepEqual(withoutPixelList(harden([startPixel]), harden([])), [startPixel]); + t.throws(() => withoutPixelList(harden([]), harden([startPixel]))); + t.deepEqual(withoutPixelList(harden([startPixel]), harden([startPixel])), []); + t.deepEqual( + withoutPixelList(harden([startPixel, secondPixel]), harden([secondPixel])), + [startPixel], + ); + t.deepEqual( + withoutPixelList( + harden([{ x: 0, y: 0 }, { x: 0, y: 1 }, { x: 1, y: 0 }, { x: 1, y: 1 }]), + harden([{ x: 0, y: 0 }, { x: 0, y: 1 }]), + ), + [{ x: 1, y: 0 }, { x: 1, y: 1 }], + ); + + t.end(); +}); + +test('pixelList makeWholePixelList', t => { + t.deepEqual(makeWholePixelList(0), []); + t.deepEqual(makeWholePixelList(1), [ + { + x: 0, + y: 0, + }, + ]); + t.deepEqual(makeWholePixelList(2), [ + { + x: 0, + y: 0, + }, + { + x: 0, + y: 1, + }, + { + x: 1, + y: 0, + }, + { + x: 1, + y: 1, + }, + ]); + t.end(); +}); diff --git a/test/pixels/types/test-pixel.js b/test/pixels/types/test-pixel.js new file mode 100644 index 00000000000..289a341b117 --- /dev/null +++ b/test/pixels/types/test-pixel.js @@ -0,0 +1,46 @@ +import { test } from 'tape-promise/tape'; + +import { + insistWithinBounds, + insistPixel, + isEqual, + isLessThanOrEqual, +} from '../../../more/pixels/types/pixel'; + +test('pixel insistWithinBounds', t => { + t.doesNotThrow(() => insistWithinBounds(0, 1)); + t.doesNotThrow(() => insistWithinBounds(1, 2)); + t.throws(() => insistWithinBounds(2, 2)); + t.throws(() => insistWithinBounds('a', 2)); + t.throws(() => insistWithinBounds(0, 0)); + t.throws(() => insistWithinBounds(0, 'a')); + t.end(); +}); + +test('pixel insistPixel', t => { + t.doesNotThrow(() => insistPixel({ x: 0, y: 0 }, 2)); + t.doesNotThrow(() => insistPixel({ x: 0, y: 0 }, 1)); + t.throws(() => insistPixel({ x: 0, y: 0 }, 'a')); + t.throws(() => insistPixel({}, 1)); + t.throws(() => insistPixel({ x: 0, y: 0 }, undefined)); + t.throws(() => insistPixel({ x: 0, y: 3 }, 1)); + t.throws(() => insistPixel({ x: 0, y: 'a' }, 1)); + t.throws(() => insistPixel({ x: 0, y: 3, empty: true }, 1)); + t.end(); +}); + +// should only be used with valid Pixels +test('pixel isEqual', t => { + const startPixel = { x: 0, y: 0 }; + t.true(isEqual(startPixel, { x: 0, y: 0 })); + t.false(isEqual(startPixel, { x: 1, y: 0 })); + t.end(); +}); + +test('pixel isLessThanOrEqual', t => { + t.true(isLessThanOrEqual({ x: 0, y: 0 }, { x: 0, y: 0 })); + t.true(isLessThanOrEqual({ x: 0, y: 0 }, { x: 2, y: 2 })); + t.false(isLessThanOrEqual({ x: 2, y: 2 }, { x: 0, y: 0 })); + t.false(isLessThanOrEqual({ x: 1, y: 0 }, { x: 0, y: 0 })); + t.end(); +}); diff --git a/util/EMap.js b/util/EMap.js new file mode 100644 index 00000000000..c540f0600a4 --- /dev/null +++ b/util/EMap.js @@ -0,0 +1,199 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +import { makePrivateName } from './PrivateName'; +import { insist } from './insist'; + +// Maps from EMaps to encapsulated Maps. All lookups from this table +// are only queries. (Except for the one in the FlexMap constructor) +const hiddenEMap = makePrivateName(); + +// Abstract superclass with query-only methods. +class EMap { + constructor(optIterable = undefined) { + insist(new.target !== EMap)`\ +EMap is abstract`; + const newHidden = new Map(optIterable); + hiddenEMap.init(this, newHidden); + } + + snapshot() { + // copy + // eslint-disable-next-line no-use-before-define + return new FixedMap(hiddenEMap.get(this)); + } + + diverge() { + // copy + // eslint-disable-next-line no-use-before-define + return new FlexMap(hiddenEMap.get(this)); + } + + readOnlyView() { + // eslint-disable-next-line no-use-before-define + const result = new InternalReadOnlyMap(); + // Share the hidden map itself, but the readOnlyView only grants + // the ability to query it. + hiddenEMap.init(result, hiddenEMap.get(this)); + return result; + } + + // Forward query protocol from Map + + keys() { + return hiddenEMap.get(this).keys(); + } + + values() { + return hiddenEMap.get(this).values(); + } + + entries() { + return hiddenEMap.get(this).entries(); + } + + [Symbol.iterator]() { + return hiddenEMap.get(this)[Symbol.iterator](); + } + + forEach(callback) { + return hiddenEMap.get(this).forEach(callback); + } + + get(member) { + return hiddenEMap.get(this).get(member); + } + + has(member) { + return hiddenEMap.get(this).has(member); + } + + get size() { + return hiddenEMap.get(this).size; + } +} +harden(EMap); + +// Guarantees that the map contents is stable. +// TODO: Somehow arrange for this to be pass-by-copy-ish. +class FixedMap extends EMap { + constructor(optIterable = undefined) { + insist(new.target === FixedMap)`\ +FixedMap is final`; + super(optIterable); + harden(this); + } + + // override + snapshot() { + return this; + } + + // override + readOnlyView() { + return this; + } +} +harden(FixedMap); + +// Maps from FlexMaps to encapsulated Maps, a subset of +// hiddenEMap. Lookups from this table can mutate. +const hiddenFlexMap = makePrivateName(); + +// Supports mutation. +class FlexMap extends EMap { + constructor(optIterable = undefined) { + insist(new.target === FlexMap)`\ +FlexMap is final`; + super(optIterable); + // Be very scared of the following line, since it looks up on + // hiddenEMap for purposes of enabling mutation. We assume it is + // safe because the `new.target` insist check above ensures this + // constructor is being called as-if directly with `new`. We say + // "as-if" because it might be invoked by `Reflect.construct`, but + // only in an equivalent manner. + hiddenFlexMap.init(this, hiddenEMap.get(this)); + harden(this); + } + + // Like snapshot() except that this FlexMap loses ownership and + // becomes useless. + takeSnapshot() { + const hiddenMap = hiddenFlexMap.get(this); + + // Ideally we'd delete, as we would from a WeakMap. However, + // PrivateName, to emulate class private names, has no delete. + // hiddenFlexMap.delete(this); + // hiddenEMap.delete(this); + hiddenFlexMap.set(this, null); + hiddenEMap.set(this, null); + + const result = new FixedMap(); + hiddenEMap.init(result, hiddenMap); + return result; + } + + // Like diverge() except that this FlexMap loses ownership and + // becomes useless. + takeDiverge() { + const hiddenMap = hiddenFlexMap.get(this); + + // Ideally we'd delete, as we would from a WeakMap. However, + // PrivateName, to emulate class private names, has no delete. + // hiddenFlexMap.delete(this); + // hiddenEMap.delete(this); + hiddenFlexMap.set(this, null); + hiddenEMap.set(this, null); + + const result = new FlexMap(); + hiddenEMap.init(result, hiddenMap); + hiddenFlexMap.init(result, hiddenMap); + return result; + } + + // Forward update protocol from Map + + set(k, v) { + return hiddenFlexMap.get(this).set(k, v); + } + + clear() { + return hiddenFlexMap.get(this).clear(); + } + + delete(m) { + return hiddenFlexMap.get(this).delete(m); + } +} +harden(FlexMap); + +// The constructor for internal use only. The rest of the class is +// available from the pseudo-constructor ReadOnlyMap. +class InternalReadOnlyMap extends EMap { + constructor() { + super(); + harden(this); + } + + // override + readOnlyView() { + return this; + } +} + +// Fake constructor becomes the public identity of the class. +// Guarantee that an instance of ReadOnlyMap does not provide the +// ability to modify. +function ReadOnlyMap() { + insist(new.target === ReadOnlyMap)`\ +ReadOnlyMap is final`; + insist(false)`\ +Use readOnlyView() to view an existing EMap`; +} +Object.setPrototypeOf(ReadOnlyMap, EMap); +ReadOnlyMap.prototype = InternalReadOnlyMap.prototype; +ReadOnlyMap.prototype.constructor = ReadOnlyMap; +harden(ReadOnlyMap); + +export { EMap, FixedMap, FlexMap, ReadOnlyMap }; diff --git a/util/ESet.js b/util/ESet.js new file mode 100644 index 00000000000..99eddf7b12a --- /dev/null +++ b/util/ESet.js @@ -0,0 +1,195 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +import { makePrivateName } from './PrivateName'; +import { insist } from './insist'; + +// Maps from ESets to encapsulated Sets. All lookups from this table +// are only queries. (Except for the one in the FlexSet constructor) +const hiddenESet = makePrivateName(); + +// Abstract superclass with query-only methods. +class ESet { + constructor(optIterable = undefined) { + insist(new.target !== ESet)`\ +ESet is abstract`; + const newHidden = new Set(optIterable); + hiddenESet.init(this, newHidden); + } + + snapshot() { + // copy + // eslint-disable-next-line no-use-before-define + return new FixedSet(hiddenESet.get(this)); + } + + diverge() { + // copy + // eslint-disable-next-line no-use-before-define + return new FlexSet(hiddenESet.get(this)); + } + + readOnlyView() { + // eslint-disable-next-line no-use-before-define + const result = new InternalReadOnlySet(); + // Share the hidden set itself, but the readOnlyView only grants + // the ability to query it. + hiddenESet.init(result, hiddenESet.get(this)); + return result; + } + + // Forward query protocol from Set + + keys() { + return hiddenESet.get(this).keys(); + } + + values() { + return hiddenESet.get(this).values(); + } + + entries() { + return hiddenESet.get(this).entries(); + } + + [Symbol.iterator]() { + return hiddenESet.get(this)[Symbol.iterator](); + } + + forEach(callback) { + return hiddenESet.get(this).forEach(callback); + } + + has(member) { + return hiddenESet.get(this).has(member); + } + + get size() { + return hiddenESet.get(this).size; + } +} +harden(ESet); + +// Guarantees that the set contents is stable. +// TODO: Somehow arrange for this to be pass-by-copy-ish. +class FixedSet extends ESet { + constructor(optIterable = undefined) { + insist(new.target === FixedSet)`\ +FixedSet is final`; + super(optIterable); + harden(this); + } + + // override + snapshot() { + return this; + } + + // override + readOnlyView() { + return this; + } +} +harden(FixedSet); + +// Maps from FlexSets to encapsulated Sets, a subset of +// hiddenESet. Lookups from this table can mutate. +const hiddenFlexSet = makePrivateName(); + +// Supports mutation. +class FlexSet extends ESet { + constructor(optIterable = undefined) { + insist(new.target === FlexSet)`\ +FlexSet is final`; + super(optIterable); + // Be very scared of the following line, since it looks up on + // hiddenESet for purposes of enabling mutation. We assume it is + // safe because the `new.target` insist check above ensures this + // constructor is being called as-if directly with `new`. We say + // "as-if" because it might be invoked by `Reflect.construct`, but + // only in an equivalent manner. + hiddenFlexSet.init(this, hiddenESet.get(this)); + harden(this); + } + + // Like snapshot() except that this FlexSet loses ownership and + // becomes useless. + takeSnapshot() { + const hiddenSet = hiddenFlexSet.get(this); + + // Ideally we'd delete, as we would from a WeakMap. However, + // PrivateName, to emulate class private names, has no delete. + // hiddenFlexSet.delete(this); + // hiddenESet.delete(this); + hiddenFlexSet.set(this, null); + hiddenESet.set(this, null); + + const result = new FixedSet(); + hiddenESet.init(result, hiddenSet); + return result; + } + + // Like diverge() except that this FlexSet loses ownership and + // becomes useless. + takeDiverge() { + const hiddenSet = hiddenFlexSet.get(this); + + // Ideally we'd delete, as we would from a WeakMap. However, + // PrivateName, to emulate class private names, has no delete. + // hiddenFlexSet.delete(this); + // hiddenESet.delete(this); + hiddenFlexSet.set(this, null); + hiddenESet.set(this, null); + + const result = new FlexSet(); + hiddenESet.init(result, hiddenSet); + hiddenFlexSet.init(result, hiddenSet); + return result; + } + + // Forward update protocol from Set + + add(m) { + return hiddenFlexSet.get(this).add(m); + } + + clear() { + return hiddenFlexSet.get(this).clear(); + } + + delete(m) { + return hiddenFlexSet.get(this).delete(m); + } +} +harden(FlexSet); + +// The constructor for internal use only. The rest of the class is +// available from the pseudo-constructor ReadOnlySet. +class InternalReadOnlySet extends ESet { + constructor() { + super(); + harden(this); + } + + // override + readOnlyView() { + return this; + } +} + +// Fake constructor becomes the public identity of the class. +// Guarantee that an instance of ReadOnlySet does not provide the +// ability to modify. +function ReadOnlySet() { + insist(new.target === ReadOnlySet)`\ +ReadOnlySet is final`; + insist(false)`\ +Use readOnlyView() to view an existing ESet`; +} +Object.setPrototypeOf(ReadOnlySet, ESet); +ReadOnlySet.prototype = InternalReadOnlySet.prototype; +ReadOnlySet.prototype.constructor = ReadOnlySet; +harden(ReadOnlySet); + +export { ESet, FixedSet, FlexSet, ReadOnlySet }; diff --git a/util/PrivateName.js b/util/PrivateName.js new file mode 100644 index 00000000000..031ef9f2726 --- /dev/null +++ b/util/PrivateName.js @@ -0,0 +1,58 @@ +// Copyright (C) 2019 Agoric, uner Apache license 2.0 + +import harden from '@agoric/harden'; + +import { insist } from './insist'; + +function makePrivateName(...args) { + const wm = new WeakMap(...args); + return harden({ + has(key) { + return wm.has(key); + }, + init(key, value) { + insist(!wm.has(key))`\ +key already registered: ${key}`; + wm.set(key, value); + }, + get(key) { + insist(wm.has(key))`\ +key not found: ${key}`; + return wm.get(key); + }, + set(key, value) { + insist(wm.has(key))`\ +key not found: ${key}`; + wm.set(key, value); + }, + }); +} +harden(makePrivateName); + +const bootPN = makePrivateName(); + +class PrivateName { + constructor(...args) { + bootPN.init(this, makePrivateName(...args)); + harden(this); + } + + has(key) { + return bootPN.get(this).has(key); + } + + init(key, value) { + bootPN.get(this).init(key, value); + } + + get(key) { + return bootPN.get(this).get(key); + } + + set(key, value) { + return bootPN.get(this).set(key, value); + } +} +harden(PrivateName); + +export { makePrivateName, PrivateName }; diff --git a/util/allSettled.js b/util/allSettled.js new file mode 100644 index 00000000000..2b24521c925 --- /dev/null +++ b/util/allSettled.js @@ -0,0 +1,37 @@ +import harden from '@agoric/harden'; + +import makePromise from './makePromise'; + +// TODO Reconcile with spec of Promise.allSettled +function allSettled(promises) { + promises = [...promises]; + const len = promises.length; + if (len === 0) { + return []; + } + const result = makePromise(); + const list = []; + let count = len; + for (let i = 0; i < len; i += 1) { + Promise.resolve(promises[i]).then( + v => { + list[i] = v; + count -= 1; + if (count === 0) { + result.res(list); + } + }, + _ => { + list[i] = promises[i]; + count -= 1; + if (count === 0) { + result.res(list); + } + }, + ); + } + return result.p; +} +harden(allSettled); + +export { allSettled }; diff --git a/util/insist.js b/util/insist.js new file mode 100644 index 00000000000..b670cdd76f2 --- /dev/null +++ b/util/insist.js @@ -0,0 +1,38 @@ +// Copyright (C) 2019 Agoric, under Apache License 2.0 + +import harden from '@agoric/harden'; + +// Insist that expr is truthy with a tagged template literal like +// insist(expr)`....` +// 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 +// assembles 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. +function insist(flag) { + function tag(template, ...args) { + if (flag) { + return; + } + const interleaved = [template[0]]; + const parts = [template[0]]; + for (let i = 0; i < args.length; i += 1) { + interleaved.push(args[i], template[i + 1]); + parts.push('(a ', typeof args[i], ')', template[i + 1]); + } + if (args.length >= 1) { + parts.push('\nSee console for error data.'); + } + console.error(...interleaved); + throw new Error(parts.join('')); + } + return harden(tag); +} +harden(insist); + +export { insist }; diff --git a/util/makePromise.js b/util/makePromise.js new file mode 100644 index 00000000000..4b08e9bba76 --- /dev/null +++ b/util/makePromise.js @@ -0,0 +1,31 @@ +import harden from '@agoric/harden'; + +export default function makePromise() { + let res; + let rej; + const p = new Promise((resolve, reject) => { + res = resolve; + rej = reject; + }); + // Node.js adds the `domain` property which is not a standard + // property on Promise. Because we do not know it to be ocap-safe, + // we remove it. + if (p.domain) { + // deleting p.domain may break functionality. To retain current + // functionality at the expense of safety, set unsafe to true. + const unsafe = false; + if (unsafe) { + const originalDomain = p.domain; + Object.defineProperty(p, 'domain', { + get() { + return originalDomain; + }, + }); + } else { + delete p.domain; + } + } + // TODO: Retire name 'rej' as it looks too much like 'res'. + return harden({ p, res, rej, reject: rej }); +} +harden(makePromise); diff --git a/util/marshal.js b/util/marshal.js new file mode 100644 index 00000000000..7b9826fe897 --- /dev/null +++ b/util/marshal.js @@ -0,0 +1,541 @@ +import harden from '@agoric/harden'; +import Nat from '@agoric/nat'; + +// Special property name that indicates an encoding that needs special +// decoding. +const QCLASS = '@qclass'; +export { QCLASS }; + +// objects can only be passed in one of two/three forms: +// 1: pass-by-presence: all properties (own and inherited) are methods, +// the object itself is of type object, not function +// 2: pass-by-copy: all string-named own properties are data, not methods +// the object must inherit from Object.prototype or null +// 3: the empty object is pass-by-presence, for identity comparison + +// todo: maybe rename pass-by-presence to pass-as-presence, or pass-by-proxy +// or remote reference + +// all objects must be frozen + +// anything else will throw an error if you try to serialize it + +// with these restrictions, our remote call/copy protocols expose all useful +// behavior of these objects: pass-by-presence objects have no other data (so +// there's nothing else to copy), and pass-by-copy objects have no other +// behavior (so there's nothing else to invoke) + +const errorConstructors = new Map([ + ['Error', Error], + ['EvalError', EvalError], + ['RangeError', RangeError], + ['ReferenceError', ReferenceError], + ['SyntaxError', SyntaxError], + ['TypeError', TypeError], + ['URIError', URIError], +]); + +export function getErrorContructor(name) { + return errorConstructors.get(name); +} + +function isPassByCopyError(val) { + // TODO: Need a better test than instanceof + if (!(val instanceof Error)) { + return false; + } + const proto = Object.getPrototypeOf(val); + const { name } = val; + const EC = getErrorContructor(name); + if (!EC || EC.prototype !== proto) { + throw TypeError(`Must inherit from an error class .prototype ${val}`); + } + + const { + message: { value: messageStr }, + // Allow but ignore only extraneous own `stack` property. + // TODO: I began the variable below with "_". Why do I still need + // to suppress the lint complaint? + // eslint-disable-next-line no-unused-vars + stack: _optStackDesc, + ...restDescs + } = Object.getOwnPropertyDescriptors(val); + const restNames = Object.keys(restDescs); + if (restNames.length >= 1) { + throw new TypeError(`Unexpected own properties in error: ${restNames}`); + } + if (typeof messageStr !== 'string') { + throw new TypeError(`malformed error object: ${val}`); + } + return true; +} + +function isPassByCopyArray(val) { + if (!Array.isArray(val)) { + return false; + } + if (Object.getPrototypeOf(val) !== Array.prototype) { + throw new TypeError(`malformed array: ${val}`); + } + const len = val.length; + const descs = Object.getOwnPropertyDescriptors(val); + for (let i = 0; i < len; i += 1) { + const desc = descs[i]; + if (!desc) { + throw new TypeError(`arrays must not contain holes`); + } + if (!('value' in desc)) { + throw new TypeError(`arrays must not contain accessors`); + } + if (typeof desc.value === 'function') { + throw new TypeError(`arrays must not contain methods`); + } + } + if (Object.keys(descs).length !== len + 1) { + throw new TypeError(`array must not have non-indexes ${val}`); + } + return true; +} + +function isPassByCopyRecord(val) { + if (Object.getPrototypeOf(val) !== Object.prototype) { + return false; + } + const descList = Object.values(Object.getOwnPropertyDescriptors(val)); + if (descList.length === 0) { + // empty non-array objects are pass-by-presence, not pass-by-copy + return false; + } + for (const desc of descList) { + if (!('value' in desc)) { + // Should we error if we see an accessor here? + return false; + } + if (typeof desc.value === 'function') { + return false; + } + } + return true; +} + +export function mustPassByPresence(val) { + // throws exception if cannot + if (!Object.isFrozen(val)) { + throw new Error(`cannot serialize non-frozen objects like ${val}`); + } + if (typeof val !== 'object') { + throw new Error(`cannot serialize non-objects like ${val}`); + } + if (Array.isArray(val)) { + throw new Error(`Arrays cannot be pass-by-presence`); + } + if (val === null) { + throw new Error(`null cannot be pass-by-presence`); + } + + const names = Object.getOwnPropertyNames(val); + names.forEach(name => { + if (name === 'e') { + // hack to allow Vows to pass-by-presence + // TODO: Make sure .e. is gone. Then get rid of this hack. + return; + } + if (typeof val[name] !== 'function') { + throw new Error( + `cannot serialize objects with non-methods like the .${name} in ${val}`, + ); + // return false; + } + }); + + const p = Object.getPrototypeOf(val); + if (p !== null && p !== Object.prototype) { + mustPassByPresence(p); + } + // ok! +} + +// How would val be passed? For primitive values, the answer is +// * 'null' for null +// * throwing an error for an unregistered symbol +// * that value's typeof string for all other primitive values +// For frozen objects, the possible answers +// * 'copyRecord' for non-empty records with only data properties +// * 'copyArray' for arrays with only data properties +// * 'copyError' for instances of Error with only data properties +// * 'presence' for non-array objects with only method properties +// * 'promise' for genuine promises only +// * throwing an error on anything else, including thenables. +// We export passStyleOf so other algorithms can use this module's +// classification. +export function passStyleOf(val) { + const typestr = typeof val; + switch (typestr) { + case 'object': { + if (val === null) { + return 'null'; + } + if (QCLASS in val) { + // TODO Hilbert hotel + throw new Error(`property "${QCLASS}" reserved`); + } + if (!Object.isFrozen(val)) { + throw new Error(`cannot pass non-frozen objects like ${val}`); + } + if (Promise.resolve(val) === val) { + return 'promise'; + } + if (typeof val.then === 'function') { + throw new Error(`Cannot pass non-promise thenables`); + } + if (isPassByCopyError(val)) { + return 'copyError'; + } + if (isPassByCopyArray(val)) { + return 'copyArray'; + } + if (isPassByCopyRecord(val)) { + return 'copyRecord'; + } + mustPassByPresence(val); + return 'presence'; + } + case 'function': { + throw new Error(`bare functions like ${val} are disabled for now`); + } + case 'undefined': + case 'string': + case 'boolean': + case 'number': + case 'bigint': { + return typestr; + } + case 'symbol': { + if (Symbol.keyFor(val) === undefined) { + throw new TypeError('Cannot pass unregistered symbols'); + } + return typestr; + } + default: { + throw new TypeError(`unrecognized typeof ${typestr}`); + } + } +} + +// The ibid logic relies on +// * JSON.stringify on an array visiting array indexes from 0 to +// arr.length -1 in order, and not visiting anything else. +// * JSON.parse of a record (a plain object) creating an object on +// which a getOwnPropertyNames will enumerate properties in the +// same order in which they appeared in the parsed JSON string. + +function makeReplacerIbidTable() { + const ibidMap = new Map(); + let ibidCount = 0; + + return harden({ + has(obj) { + return ibidMap.has(obj); + }, + get(obj) { + return ibidMap.get(obj); + }, + add(obj) { + ibidMap.set(obj, ibidCount); + ibidCount += 1; + }, + }); +} + +function makeReviverIbidTable(cyclePolicy) { + const ibids = []; + const unfinishedIbids = new WeakSet(); + + return harden({ + get(allegedIndex) { + const index = Nat(allegedIndex); + if (index >= ibids.length) { + throw new RangeError(`ibid out of range: ${index}`); + } + const result = ibids[index]; + if (unfinishedIbids.has(result)) { + switch (cyclePolicy) { + case 'allowCycles': { + break; + } + case 'warnOfCycles': { + console.log(`Warning: ibid cycle at ${index}`); + break; + } + case 'forbidCycles': { + throw new TypeError(`Ibid cycle at ${index}`); + } + default: { + throw new TypeError(`Unrecognized cycle policy: ${cyclePolicy}`); + } + } + } + return result; + }, + register(obj) { + ibids.push(obj); + return obj; + }, + start(obj) { + ibids.push(obj); + unfinishedIbids.add(obj); + return obj; + }, + finish(obj) { + unfinishedIbids.delete(obj); + return obj; + }, + }); +} + +export function makeMarshal(serializeSlot, unserializeSlot) { + function makeReplacer(slots, slotMap) { + const ibidTable = makeReplacerIbidTable(); + + return function replacer(_, val) { + // First we handle all primitives. Some can be represented directly as + // JSON, and some must be encoded as [QCLASS] composites. + const passStyle = passStyleOf(val); + switch (passStyle) { + case 'null': { + return null; + } + case 'undefined': { + return harden({ [QCLASS]: 'undefined' }); + } + case 'string': + case 'boolean': { + return val; + } + case 'number': { + if (Number.isNaN(val)) { + return harden({ [QCLASS]: 'NaN' }); + } + if (Object.is(val, -0)) { + return harden({ [QCLASS]: '-0' }); + } + if (val === Infinity) { + return harden({ [QCLASS]: 'Infinity' }); + } + if (val === -Infinity) { + return harden({ [QCLASS]: '-Infinity' }); + } + return val; + } + case 'symbol': { + const key = Symbol.keyFor(val); + return harden({ + [QCLASS]: 'symbol', + key, + }); + } + case 'bigint': { + return harden({ + [QCLASS]: 'bigint', + digits: String(val), + }); + } + default: { + // if we've seen this object before, serialize a backref + if (ibidTable.has(val)) { + // Backreference to prior occurrence + return harden({ + [QCLASS]: 'ibid', + index: ibidTable.get(val), + }); + } + ibidTable.add(val); + + switch (passStyle) { + case 'copyRecord': + case 'copyArray': { + // console.log(`canPassByCopy: ${val}`); + // Purposely in-band for readability, but creates need for + // Hilbert hotel. + return val; + } + case 'copyError': { + // We deliberately do not share the stack, but it would + // be useful to log the stack locally so someone who has + // privileged access to the throwing Vat can correlate + // the problem with the remote Vat that gets this + // summary. If we do that, we could allocate some random + // identifier and include it in the message, to help + // with the correlation. + return harden({ + [QCLASS]: 'error', + name: `${val.name}`, + message: `${val.message}`, + }); + } + case 'presence': + case 'promise': { + // console.log(`serializeSlot: ${val}`); + return serializeSlot(val, slots, slotMap); + } + default: { + throw new TypeError(`unrecognized passStyle ${passStyle}`); + } + } + } + } + }; + } + + // val might be a primitive, a pass by (shallow) copy object, a + // remote reference, or other. We treat all other as a local object + // to be exported as a local webkey. + function serialize(val) { + const slots = []; + const slotMap = new Map(); // maps val (proxy or presence) to + // index of slots[] + return { + argsString: JSON.stringify(val, makeReplacer(slots, slotMap)), + slots, + }; + } + + function makeFullRevive(slots, cyclePolicy) { + // ibid table is shared across recursive calls to fullRevive. + const ibidTable = makeReviverIbidTable(cyclePolicy); + + // We stay close to the algorith at + // https://tc39.github.io/ecma262/#sec-json.parse , where + // fullRevive(JSON.parse(str)) is like JSON.parse(str, revive)) + // for a similar reviver. But with the following differences: + // + // Rather than pass a reviver to JSON.parse, we first call a plain + // (one argument) JSON.parse to get rawTree, and then post-process + // the rawTree with fullRevive. The kind of revive function + // handled by JSON.parse only does one step in post-order, with + // JSON.parse doing the recursion. By contrast, fullParse does its + // own recursion, enabling it to interpret ibids in the same + // pre-order in which the replacer visited them, and enabling it + // to break cycles. + // + // In order to break cycles, the potentially cyclic objects are + // not frozen during the recursion. Rather, the whole graph is + // hardened before being returned. Error objects are not + // potentially recursive, and so may be harmlessly hardened when + // they are produced. + // + // fullRevive can produce properties whose value is undefined, + // which a JSON.parse on a reviver cannot do. If a reviver returns + // undefined to JSON.parse, JSON.parse will delete the property + // instead. + // + // fullRevive creates and returns a new graph, rather than + // modifying the original tree in place. + // + // fullRevive may rely on rawTree being the result of a plain call + // to JSON.parse. However, it *cannot* rely on it having been + // produced by JSON.stringify on the replacer above, i.e., it + // cannot rely on it being a valid marshalled + // representation. Rather, fullRevive must validate that. + return function fullRevive(rawTree) { + if (Object(rawTree) !== rawTree) { + // primitives pass through + return rawTree; + } + if (QCLASS in rawTree) { + const qclass = rawTree[QCLASS]; + if (typeof qclass !== 'string') { + throw new TypeError(`invalid qclass typeof ${typeof qclass}`); + } + switch (qclass) { + // Encoding of primitives not handled by JSON + case 'undefined': { + return undefined; + } + case '-0': { + return -0; + } + case 'NaN': { + return NaN; + } + case 'Infinity': { + return Infinity; + } + case '-Infinity': { + return -Infinity; + } + case 'symbol': { + if (typeof rawTree.key !== 'string') { + throw new TypeError( + `invalid symbol key typeof ${typeof rawTree.key}`, + ); + } + return Symbol.for(rawTree.key); + } + case 'bigint': { + if (typeof rawTree.digits !== 'string') { + throw new TypeError( + `invalid digits typeof ${typeof rawTree.digits}`, + ); + } + /* eslint-disable-next-line no-undef */ + return BigInt(rawTree.digits); + } + + case 'ibid': { + return ibidTable.get(rawTree.index); + } + + case 'error': { + if (typeof rawTree.name !== 'string') { + throw new TypeError( + `invalid error name typeof ${typeof rawTree.name}`, + ); + } + if (typeof rawTree.message !== 'string') { + throw new TypeError( + `invalid error message typeof ${typeof rawTree.message}`, + ); + } + const EC = getErrorContructor(`${rawTree.name}`) || Error; + return ibidTable.register(harden(new EC(`${rawTree.message}`))); + } + + case 'slot': { + return ibidTable.register(unserializeSlot(rawTree, slots)); + } + + default: { + // TODO reverse Hilbert hotel + throw new TypeError(`unrecognized ${QCLASS} ${qclass}`); + } + } + } else if (Array.isArray(rawTree)) { + const result = ibidTable.start([]); + const len = rawTree.length; + for (let i = 0; i < len; i += 1) { + result[i] = fullRevive(rawTree[i]); + } + return ibidTable.finish(result); + } else { + const result = ibidTable.start({}); + const names = Object.getOwnPropertyNames(rawTree); + for (const name of names) { + result[name] = fullRevive(rawTree[name]); + } + return ibidTable.finish(result); + } + }; + } + + function unserialize(str, slots, cyclePolicy = 'forbidCycles') { + const rawTree = harden(JSON.parse(str)); + const fullRevive = makeFullRevive(slots, cyclePolicy); + return harden(fullRevive(rawTree)); + } + + return harden({ + serialize, + unserialize, + }); +} diff --git a/util/sameStructure.js b/util/sameStructure.js new file mode 100644 index 00000000000..0fa82e3f658 --- /dev/null +++ b/util/sameStructure.js @@ -0,0 +1,247 @@ +import harden from '@agoric/harden'; + +import { insist } from './insist'; +import { passStyleOf } from './marshal'; + +// Shim of Object.fromEntries from +// https://github.com/tc39/proposal-object-from-entries/blob/master/polyfill.js +function ObjectFromEntries(iter) { + const obj = {}; + + for (const pair of iter) { + if (Object(pair) !== pair) { + throw new TypeError('iterable for fromEntries should yield objects'); + } + + // Consistency with Map: contract is that entry has "0" and "1" keys, not + // that it is an array or iterable. + + const { '0': key, '1': val } = pair; + + Object.defineProperty(obj, key, { + configurable: true, + enumerable: true, + writable: true, + value: val, + }); + } + + return obj; +} + +// A *passable* is something that may be mashalled. It consists of a +// graph of pass-by-copy data terminating in leaves of passable +// non-pass-by-copy data. These leaves may be promises, or +// pass-by-presence objects. A *comparable* is a passable whose leaves +// contain no promises. Two comparables can be synchronously compared +// for structural equivalence. +// +// TODO: Currently, all algorithms here treat the pass-by-copy +// superstructure as a tree. This means that dags are unwound at +// potentially exponential code, and cycles cause failure to +// terminate. We must fix both problems, making all these algorthms +// graph-aware. + +// We say that a function *reveals* an X when it returns either an X +// or a promise for an X. + +// Given a passable, reveal a corresponding comparable, where each +// leaf promise of the passable has been replaced with its +// corresponding comparable. +function allComparable(passable) { + const passStyle = passStyleOf(passable); + switch (passStyle) { + case 'null': + case 'undefined': + case 'string': + case 'boolean': + case 'number': + case 'symbol': + case 'bigint': + case 'presence': + case 'copyError': { + return passable; + } + case 'promise': { + return passable.then(nonp => allComparable(nonp)); + } + case 'copyArray': { + const valPs = passable.map(p => allComparable(p)); + return Promise.all(valPs).then(vals => harden(vals)); + } + case 'copyRecord': { + const names = Object.getOwnPropertyNames(passable); + const valPs = names.map(name => allComparable(passable[name])); + return Promise.all(valPs).then(vals => + harden(ObjectFromEntries(vals.map((val, i) => [names[i], val]))), + ); + } + default: { + throw new TypeError(`unrecognized passStyle ${passStyle}`); + } + } +} +harden(allComparable); + +// Are left and right structurally equivalent comparables? This +// compares pass-by-copy data deeply until non-pass-by-copy values are +// reached. The non-pass-by-copy values at the leaves of the +// comparison may only be pass-by-presence objects. If they are +// anything else, including promises, throw an error. +// +// Pass-by-presence objects compare identities. + +function sameStructure(left, right) { + const leftStyle = passStyleOf(left); + const rightStyle = passStyleOf(right); + insist(leftStyle !== 'promise')`\ +Cannot structurally compare promises: ${left}`; + insist(rightStyle !== 'promise')`\ +Cannot structurally compare promises: ${right}`; + + if (leftStyle !== rightStyle) { + return false; + } + switch (leftStyle) { + case 'null': + case 'undefined': + case 'string': + case 'boolean': + case 'number': + case 'symbol': + case 'bigint': + case 'presence': { + return Object.is(left, right); + } + case 'copyRecord': + case 'copyArray': { + const leftNames = Object.getOwnPropertyNames(left); + const rightNames = Object.getOwnPropertyNames(right); + if (leftNames.length !== rightNames.length) { + return false; + } + for (const name of leftNames) { + // TODO: Better hasOwnProperty check + if (!Object.getOwnPropertyDescriptor(right, name)) { + return false; + } + // TODO: Make cycle tolerant + if (!sameStructure(left[name], right[name])) { + return false; + } + } + return true; + } + case 'copyError': { + return left.name === right.name && left.message === right.message; + } + default: { + throw new TypeError(`unrecognized passStyle ${leftStyle}`); + } + } +} +harden(sameStructure); + +function pathStr(path) { + if (path === null) { + return 'top'; + } + const [base, index] = path; + let i = index; + const baseStr = pathStr(base); + if (typeof i === 'string' && /^[a-zA-Z]\w*$/.test(i)) { + return `${baseStr}.${i}`; + } + if (typeof i === 'string' && `${+i}` === i) { + i = +i; + } + return `${baseStr}[${JSON.stringify(i)}]`; +} + +// TODO: Reduce redundancy between sameStructure and +// mustBeSameStructureInternal +function mustBeSameStructureInternal(left, right, message, path) { + function complain(problem) { + const template = harden([ + `${message}: ${problem} at ${pathStr(path)}: (`, + ') vs (', + ')', + ]); + insist(false)(template, left, right); + } + + const leftStyle = passStyleOf(left); + const rightStyle = passStyleOf(right); + if (leftStyle === 'promise') { + complain('Promise on left'); + } + if (rightStyle === 'promise') { + complain('Promise on right'); + } + + if (leftStyle !== rightStyle) { + complain('different passing style'); + } + switch (leftStyle) { + case 'null': + case 'undefined': + case 'string': + case 'boolean': + case 'number': + case 'symbol': + case 'bigint': + case 'presence': { + if (!Object.is(left, right)) { + complain('different'); + } + break; + } + case 'copyRecord': + case 'copyArray': { + const leftNames = Object.getOwnPropertyNames(left); + const rightNames = Object.getOwnPropertyNames(right); + if (leftNames.length !== rightNames.length) { + complain(`${leftNames.length} vs ${rightNames.length} own properties`); + } + for (const name of leftNames) { + // TODO: Better hasOwnProperty check + if (!Object.getOwnPropertyDescriptor(right, name)) { + complain(`${name} not found on right`); + } + // TODO: Make cycle tolerant + mustBeSameStructureInternal(left[name], right[name], message, [ + path, + name, + ]); + } + break; + } + case 'copyError': { + if (left.name !== right.name) { + complain(`different error name: ${left.name} vs ${right.name}`); + } + if (left.message !== right.message) { + complain( + `different error message: ${left.message} vs ${right.message}`, + ); + } + break; + } + default: { + complain(`unrecognized passStyle ${leftStyle}`); + break; + } + } +} +function mustBeSameStructure(left, right, message) { + mustBeSameStructureInternal(left, right, `${message}`, null); +} +harden(mustBeSameStructure); + +// If `val` would be a valid input to `sameStructure`, return +// normally. Otherwise error. +function mustBeComparable(val) { + mustBeSameStructure(val, val, 'not comparable'); +} + +export { allComparable, sameStructure, mustBeSameStructure, mustBeComparable };