remove Nat from SES and import it instead
MODIFY
package-lock.json
package-lock.json
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+ "@agoric/nat": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@agoric/nat/-/nat-2.0.0.tgz",
+ "integrity": "sha512-ElXHhMkiue2sLE4tYcqCug+9N44d9NUk04hD/pLJsgdKhnm4E+ZNAr5QpX0Ce3yVQPQe3DEOtR2cZiOmcAO76g=="
+ },
"@babel/code-frame": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",

MODIFY
package.json
package.json
"test": "node scripts/build-intermediate.js && tape -r esm test/**/*.js",
"just-test": "tape -r esm test/**/*.js",
"build-intermediate": "node scripts/build-intermediate.js",
- "build": "git submodule update --init --recursive && node scripts/build-intermediate.js && rollup --format=iife --output.name=SES --output.exports=named --sourcemap --file=dist/ses-shim.js -- src/index.js",
+ "build": "git submodule update --init --recursive && node scripts/build-intermediate.js && rollup -c",
"pretty-fix": "prettier --write 'src/**/*.{js,jsx}' 'test/**/*.{js,jsx}'",
"pretty-check": "prettier --check 'src/**/*.{js,jsx}' 'test/**/*.{js,jsx}'",
"lint-fix": "eslint --fix 'src/**/*.{js,jsx}' 'test/**/*.{js,jsx}'",
"tape": "^4.9.2"
},
"dependencies": {
+ "@agoric/nat": "^2.0.0",
"esm": "^3.2.4"
},
"repository": {

ADD
rollup.config.js
+import resolve from 'rollup-plugin-node-resolve';
+
+export default {
+ input: 'src/index.js',
+ output: {
+ file: 'dist/ses-shim.js',
+ exports: 'named',
+ format: 'iife',
+ name: 'SES',
+ sourcemap: true,
+ },
+ plugins: [resolve()],
+};

MODIFY
scripts/build-intermediate.js
scripts/build-intermediate.js
const rollup = require('rollup');
+const resolve = require('rollup-plugin-node-resolve');
const fs = require('fs');
function bundle() {
return rollup
- .rollup({ input: 'src/bundle/index' })
- .then(bundle =>
- bundle.generate({ format: 'iife', sourcemap: true, name: 'makeBundle' }),
+ .rollup({
+ input: 'src/bundle/index',
+ plugins: [resolve()],
+ })
+ .then(b =>
+ b.generate({ format: 'iife', sourcemap: true, name: 'makeBundle' }),
);
}

MODIFY
src/bundle/index.js
src/bundle/index.js
// See the License for the specific language governing permissions and
// limitations under the License.
+import Nat from '@agoric/nat';
+
import {
createSESWithRealmConstructor,
createSESInThisRealm,
} from './createSES';
import def from './def';
-import Nat from './nat';
export { createSESWithRealmConstructor, createSESInThisRealm, def, Nat };

DELETE
src/bundle/nat.js
-// Copyright (C) 2011 Google Inc.
-// Copyright (C) 2018 Agoric
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * Is allegenNum a number in the contiguous range of exactly and
- * unambiguously representable natural numbers (non-negative integers)?
- *
- * <p>See <a href=
- * "https://code.google.com/p/google-caja/issues/detail?id=1801"
- * >Issue 1801: Nat must include at most (2**53)-1</a>
- * and <a href=
- * "https://mail.mozilla.org/pipermail/es-discuss/2013-July/031716.html"
- * >Allen Wirfs-Brock's suggested phrasing</a> on es-discuss.
- */
-export default function Nat(allegedNum) {
- // TODO simplify by using Number.isSafeInteger
- if (typeof allegedNum !== 'number') {
- throw new RangeError('not a number');
- }
- // eslint-disable-next-line no-self-compare
- if (allegedNum !== allegedNum) {
- throw new RangeError('NaN not natural');
- }
- if (allegedNum < 0) {
- throw new RangeError('negative');
- }
- if (allegedNum % 1 !== 0) {
- throw new RangeError('not integral');
- }
- if (allegedNum > Number.MAX_SAFE_INTEGER) {
- throw new RangeError('too big');
- }
- return allegedNum;
-}

remove Nat from SES and import it instead