types are now moved to another directory
This commit is contained in:
parent
519dcbc0fd
commit
cf5ddfbb3b
|
@ -1,18 +1,19 @@
|
|||
'use strict'
|
||||
|
||||
const resolve = require('@rollup/plugin-node-resolve').nodeResolve
|
||||
const replace = require('@rollup/plugin-replace')
|
||||
const { terser } = require('rollup-plugin-terser')
|
||||
const typescriptPlugin = require('@rollup/plugin-typescript')
|
||||
const commonjs = require('@rollup/plugin-commonjs')
|
||||
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import { terser } from 'rollup-plugin-terser'
|
||||
import typescriptPlugin from '@rollup/plugin-typescript'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const pkgJson = require('../package.json')
|
||||
import { dirname, join } from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import { move } from 'fs-extra'
|
||||
import { directories, name as _name, dependencies, peerDependencies, exports, types } from '../package.json'
|
||||
|
||||
const rootDir = path.join(__dirname, '..')
|
||||
const dstDir = path.join(rootDir, pkgJson.directories.dist)
|
||||
const srcDir = path.join(rootDir, 'src', 'ts')
|
||||
const rootDir = join(__dirname, '..')
|
||||
const dstDir = join(rootDir, directories.dist)
|
||||
const srcDir = join(rootDir, 'src', 'ts')
|
||||
|
||||
function camelise (str) {
|
||||
return str.replace(/-([a-z])/g,
|
||||
|
@ -22,30 +23,40 @@ function camelise (str) {
|
|||
}
|
||||
|
||||
const regex = /^(?:(?<scope>@.*?)\/)?(?<name>.*)/ // We are going to take only the package name part if there is a scope, e.g. @my-org/package-name
|
||||
const { name } = pkgJson.name.match(regex).groups
|
||||
const { name } = _name.match(regex).groups
|
||||
const pkgCamelisedName = camelise(name)
|
||||
|
||||
const input = path.join(srcDir, 'index.ts')
|
||||
if (fs.existsSync(input) !== true) throw new Error('The entry point should be index.ts')
|
||||
const input = join(srcDir, 'index.ts')
|
||||
if (existsSync(input) !== true) throw new Error('The entry point should be index.ts')
|
||||
|
||||
const tsBundleOptions = {
|
||||
tsconfig: join(rootDir, 'tsconfig.json'),
|
||||
outDir: undefined, // ignore outDir in tsconfig.json
|
||||
exclude: ['test/**/*', 'src/**/*.spec.ts', './build/typings/global-this-pkg.d.ts']
|
||||
}
|
||||
|
||||
const external = [...Object.keys(pkgJson.dependencies || {}), ...Object.keys(pkgJson.peerDependencies || {})]
|
||||
const external = [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {})]
|
||||
|
||||
const sourcemapOutputOptions = {
|
||||
sourcemap: 'inline',
|
||||
sourcemapExcludeSources: true
|
||||
}
|
||||
|
||||
module.exports = [
|
||||
function moveDirPlugin (srcDir, dstDir) {
|
||||
return {
|
||||
name: 'move-dir',
|
||||
async closeBundle () {
|
||||
move(srcDir, dstDir, { overwrite: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default [
|
||||
{ // ESM for browsers
|
||||
input: input,
|
||||
output: [
|
||||
{
|
||||
file: path.join(rootDir, pkgJson.exports['.'].default),
|
||||
file: join(rootDir, exports['.'].default),
|
||||
...sourcemapOutputOptions,
|
||||
format: 'es'
|
||||
}
|
||||
|
@ -63,16 +74,16 @@ module.exports = [
|
|||
input: input,
|
||||
output: [
|
||||
{
|
||||
file: path.join(dstDir, 'bundles/iife.js'),
|
||||
file: join(dstDir, 'bundles/iife.js'),
|
||||
format: 'iife',
|
||||
name: pkgCamelisedName
|
||||
},
|
||||
{
|
||||
file: path.join(dstDir, 'bundles/esm.js'),
|
||||
file: join(dstDir, 'bundles/esm.js'),
|
||||
format: 'es'
|
||||
},
|
||||
{
|
||||
file: path.join(dstDir, 'bundles/umd.js'),
|
||||
file: join(dstDir, 'bundles/umd.js'),
|
||||
format: 'umd',
|
||||
name: pkgCamelisedName
|
||||
}
|
||||
|
@ -93,7 +104,7 @@ module.exports = [
|
|||
{ // Node ESM with declaration files
|
||||
input: input,
|
||||
output: {
|
||||
file: path.join(rootDir, pkgJson.exports['.'].node.import),
|
||||
file: join(rootDir, exports['.'].node.import),
|
||||
...sourcemapOutputOptions,
|
||||
format: 'es'
|
||||
},
|
||||
|
@ -104,12 +115,13 @@ module.exports = [
|
|||
}),
|
||||
typescriptPlugin({
|
||||
...tsBundleOptions,
|
||||
// outDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)),
|
||||
declaration: true,
|
||||
outDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import)),
|
||||
declarationDir: path.join(rootDir, path.dirname(pkgJson.exports['.'].node.import), 'types'),
|
||||
declarationDir: 'types',
|
||||
declarationMap: true
|
||||
}),
|
||||
commonjs({ extensions: ['.js', '.ts'] }) // the ".ts" extension is required
|
||||
commonjs({ extensions: ['.js', '.cjs', '.ts'] }), // the ".ts" extension is required
|
||||
moveDirPlugin(join(rootDir, dirname(exports['.'].node.import), 'types'), join(rootDir, dirname(types)))
|
||||
],
|
||||
external
|
||||
},
|
||||
|
@ -117,12 +129,12 @@ module.exports = [
|
|||
input: input,
|
||||
output: [
|
||||
{
|
||||
file: path.join(rootDir, pkgJson.exports['.'].node.require),
|
||||
file: join(rootDir, exports['.'].node.require),
|
||||
...sourcemapOutputOptions,
|
||||
format: 'cjs'
|
||||
},
|
||||
{
|
||||
file: path.join(rootDir, pkgJson.exports['.'].node.require).slice(0, -4) + '.js', // .js extension instead of .cjs for Node 10 support
|
||||
file: join(rootDir, exports['.'].node.require).slice(0, -4) + '.js', // .js extension instead of .cjs for Node 10 support
|
||||
...sourcemapOutputOptions,
|
||||
format: 'cjs'
|
||||
}
|
||||
|
@ -133,7 +145,7 @@ module.exports = [
|
|||
preventAssignment: true
|
||||
}),
|
||||
typescriptPlugin(tsBundleOptions),
|
||||
commonjs({ extensions: ['.js', '.ts'] }) // the ".ts" extension is required
|
||||
commonjs({ extensions: ['.js', '.cjs', '.ts'] }) // the ".ts" extension is required
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
16
docs/API.md
16
docs/API.md
|
@ -153,7 +153,7 @@ A promise that resolves to a boolean that is either true (a probably prime numbe
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/isProbablyPrime.ts#L21)
|
||||
[src/ts/isProbablyPrime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/isProbablyPrime.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
|
@ -317,7 +317,7 @@ A promise that resolves to a bigint probable prime of bitLength bits.
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/prime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/prime.ts#L21)
|
||||
[src/ts/prime.ts:21](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/prime.ts#L21)
|
||||
|
||||
___
|
||||
|
||||
|
@ -346,7 +346,7 @@ A bigint probable prime of bitLength bits.
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/prime.ts:100](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/prime.ts#L100)
|
||||
[src/ts/prime.ts:100](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/prime.ts#L100)
|
||||
|
||||
___
|
||||
|
||||
|
@ -374,7 +374,7 @@ A cryptographically secure random bigint between [min,max]
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/randBetween.ts#L15)
|
||||
[src/ts/randBetween.ts:15](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/randBetween.ts#L15)
|
||||
|
||||
___
|
||||
|
||||
|
@ -402,7 +402,7 @@ A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/randBits.ts#L14)
|
||||
[src/ts/randBits.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/randBits.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
|
@ -430,7 +430,7 @@ A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/randBits.ts#L45)
|
||||
[src/ts/randBits.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/randBits.ts#L45)
|
||||
|
||||
___
|
||||
|
||||
|
@ -458,7 +458,7 @@ A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBytes.ts:12](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/randBytes.ts#L12)
|
||||
[src/ts/randBytes.ts:12](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/randBytes.ts#L12)
|
||||
|
||||
___
|
||||
|
||||
|
@ -486,7 +486,7 @@ A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
|
|||
|
||||
#### Defined in
|
||||
|
||||
[src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/f11626d/src/ts/randBytes.ts#L46)
|
||||
[src/ts/randBytes.ts:46](https://github.com/juanelas/bigint-crypto-utils/blob/519dcbc/src/ts/randBytes.ts#L46)
|
||||
|
||||
___
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"@types/chai": "^4.2.14",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"chai": "^4.3.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"glob": "^7.1.6",
|
||||
"json5": "^2.2.0",
|
||||
"minimatch": "^3.0.4",
|
||||
|
@ -3039,6 +3040,20 @@
|
|||
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fs-extra": {
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
|
||||
"integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
|
@ -3516,9 +3531,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/is-callable": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.3.tgz",
|
||||
"integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==",
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz",
|
||||
"integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
|
@ -3993,6 +4008,18 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
|
||||
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsx-ast-utils": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.2.0.tgz",
|
||||
|
@ -6396,6 +6423,15 @@
|
|||
"through": "^2.3.8"
|
||||
}
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
@ -8927,6 +8963,17 @@
|
|||
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
|
||||
"dev": true
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
|
||||
"integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
|
@ -9261,9 +9308,9 @@
|
|||
}
|
||||
},
|
||||
"is-callable": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.3.tgz",
|
||||
"integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==",
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz",
|
||||
"integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==",
|
||||
"dev": true
|
||||
},
|
||||
"is-core-module": {
|
||||
|
@ -9610,6 +9657,16 @@
|
|||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
|
||||
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6",
|
||||
"universalify": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"jsx-ast-utils": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.2.0.tgz",
|
||||
|
@ -11429,6 +11486,12 @@
|
|||
"through": "^2.3.8"
|
||||
}
|
||||
},
|
||||
"universalify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
|
||||
"dev": true
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"engines": {
|
||||
"node": ">=10.4.0"
|
||||
},
|
||||
"types": "./dist/esm/types/index.d.ts",
|
||||
"types": "./types/index.d.ts",
|
||||
"main": "./dist/cjs/index.node.cjs",
|
||||
"browser": "./dist/esm/index.browser.js",
|
||||
"module": "./dist/esm/index.node.js",
|
||||
|
@ -36,11 +36,10 @@
|
|||
},
|
||||
"default": "./dist/esm/index.browser.js"
|
||||
},
|
||||
"./node-js": "./dist/cjs/index.node.js",
|
||||
"./esm-browser-bundle": "./dist/bundles/esm.js",
|
||||
"./iife-browser-bundle": "./dist/bundles/iife.js",
|
||||
"./umd-browser-bundle": "./dist/bundles/umd.js",
|
||||
"./types": "./dist/esm/types/index.d.ts"
|
||||
"./types": "./types/index.d.ts"
|
||||
},
|
||||
"directories": {
|
||||
"build": "./build",
|
||||
|
@ -93,6 +92,7 @@
|
|||
"@types/chai": "^4.2.14",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"chai": "^4.3.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"glob": "^7.1.6",
|
||||
"json5": "^2.2.0",
|
||||
"minimatch": "^3.0.4",
|
||||
|
|
|
@ -41,6 +41,7 @@ import * as {{PKG_CAMELCASE}} from '{{PKG_NAME}}'
|
|||
The appropriate version for browser or node is automatically exported.
|
||||
|
||||
> `{{PKG_NAME}}` uses [ES2020 BigInt](https://tc39.es/ecma262/#sec-bigint-objects), so take into account that:
|
||||
>
|
||||
> 1. If you experience issues using webpack/babel to create your production bundles, you may edit the supported browsers list and leave only [supported browsers and versions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility). The browsers list is usually located in your project's `package.json` or the `.browserslistrc` file.
|
||||
> 2. In order to use `{{PKG_NAME}}` with TypeScript you need to set `target`, and `lib` and `module` if in use, to `ES2020` in your project's `tsconfig.json`.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||
// "lib": [ "es2020" ], /* Specify library files to be included in the compilation. */
|
||||
"allowJs": true, /* Allow javascript files to be compiled. */
|
||||
"outDir": ".dst", /* If not set we cannot import .js files without a warning that is going to be overwritten. outDir is not going to be used in any case */
|
||||
// "outDir": ".dst", /* If not set we cannot import .js files without a warning that is going to be overwritten. outDir is not going to be used in any case */
|
||||
"checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'react', 'react-jsx', 'react-jsxdev', 'preserve' or 'react-native'. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/// <reference types="node" />
|
||||
export declare function fromBuffer(buf: Uint8Array | Buffer): bigint;
|
||||
//# sourceMappingURL=fromBuffer.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"fromBuffer.d.ts","sourceRoot":"","sources":["../src/ts/fromBuffer.ts"],"names":[],"mappings":";AAAA,wBAAgB,UAAU,CAAE,GAAG,EAAE,UAAU,GAAC,MAAM,GAAG,MAAM,CAO1D"}
|
|
@ -0,0 +1,7 @@
|
|||
export { abs, bitLength, eGcd, gcd, lcm, max, min, modInv, modPow, toZn } from 'bigint-mod-arith';
|
||||
export { isProbablyPrime } from './isProbablyPrime';
|
||||
export { prime, primeSync } from './prime';
|
||||
export { randBetween } from './randBetween';
|
||||
export { randBits, randBitsSync } from './randBits';
|
||||
export { randBytes, randBytesSync } from './randBytes';
|
||||
//# sourceMappingURL=index.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEjG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA"}
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* The test first tries if any of the first 250 small primes are a factor of the input number and then passes several
|
||||
* iterations of Miller-Rabin Probabilistic Primality Test (FIPS 186-4 C.3.1)
|
||||
*
|
||||
* @param w - A positive integer to be tested for primality
|
||||
* @param iterations - The number of iterations for the primality test. The value shall be consistent with Table C.1, C.2 or C.3
|
||||
* @param disableWorkers - Disable the use of workers for the primality test
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* w MUST be >= 0
|
||||
*
|
||||
* @returns A promise that resolves to a boolean that is either true (a probably prime number) or false (definitely composite)
|
||||
*/
|
||||
export declare function isProbablyPrime(w: number | bigint, iterations?: number, disableWorkers?: boolean): Promise<boolean>;
|
||||
export declare function _isProbablyPrime(w: bigint, iterations: number): boolean;
|
||||
export declare function _isProbablyPrimeWorkerUrl(): string;
|
||||
//# sourceMappingURL=isProbablyPrime.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"isProbablyPrime.d.ts","sourceRoot":"","sources":["../src/ts/isProbablyPrime.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAE,CAAC,EAAE,MAAM,GAAC,MAAM,EAAE,UAAU,GAAE,MAAW,EAAE,cAAc,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAqD7H;AAED,wBAAgB,gBAAgB,CAAE,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CA0TxE;AAED,wBAAgB,yBAAyB,IAAK,MAAM,CAOnD"}
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator.
|
||||
* The browser version uses web workers to parallelise prime look up. Therefore, it does not lock the UI
|
||||
* main process, and it can be much faster (if several cores or cpu are available).
|
||||
* The node version can also use worker_threads if they are available (enabled by default with Node 11 and
|
||||
* and can be enabled at runtime executing node --experimental-worker with node >=10.5.0).
|
||||
*
|
||||
* @param bitLength - The required bit length for the generated prime
|
||||
* @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* bitLength MUST be > 0
|
||||
*
|
||||
* @returns A promise that resolves to a bigint probable prime of bitLength bits.
|
||||
*/
|
||||
export declare function prime(bitLength: number, iterations?: number): Promise<bigint>;
|
||||
/**
|
||||
* A probably-prime (Miller-Rabin), cryptographically-secure, random-number generator.
|
||||
* The sync version is NOT RECOMMENDED since it won't use workers and thus it'll be slower and may freeze thw window in browser's javascript. Please consider using prime() instead.
|
||||
*
|
||||
* @param bitLength - The required bit length for the generated prime
|
||||
* @param iterations - The number of iterations for the Miller-Rabin Probabilistic Primality Test
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* bitLength MUST be > 0
|
||||
*
|
||||
* @returns A bigint probable prime of bitLength bits.
|
||||
*/
|
||||
export declare function primeSync(bitLength: number, iterations?: number): bigint;
|
||||
//# sourceMappingURL=prime.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"prime.d.ts","sourceRoot":"","sources":["../src/ts/prime.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAiElF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,GAAG,MAAM,CAO7E"}
|
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Returns a cryptographically secure random integer between [min,max]. Both numbers must be >=0
|
||||
* @param max Returned value will be <= max
|
||||
* @param min Returned value will be >= min
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* Arguments MUST be: max > 0 && min >=0 && max > min
|
||||
*
|
||||
* @returns A cryptographically secure random bigint between [min,max]
|
||||
*/
|
||||
export declare function randBetween(max: bigint, min?: bigint): bigint;
|
||||
//# sourceMappingURL=randBetween.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"randBetween.d.ts","sourceRoot":"","sources":["../src/ts/randBetween.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAW,GAAG,MAAM,CAUlE"}
|
|
@ -0,0 +1,25 @@
|
|||
/// <reference types="node" />
|
||||
/**
|
||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||
*
|
||||
* @param bitLength - The desired number of random bits
|
||||
* @param forceLength - If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* bitLength MUST be > 0
|
||||
*
|
||||
* @returns A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
|
||||
*/
|
||||
export declare function randBits(bitLength: number, forceLength?: boolean): Promise<Uint8Array | Buffer>;
|
||||
/**
|
||||
* Secure random bits for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||
* @param bitLength - The desired number of random bits
|
||||
* @param forceLength - If we want to force the output to have a specific bit length. It basically forces the msb to be 1
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* bitLength MUST be > 0
|
||||
*
|
||||
* @returns A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bits
|
||||
*/
|
||||
export declare function randBitsSync(bitLength: number, forceLength?: boolean): Uint8Array | Buffer;
|
||||
//# sourceMappingURL=randBits.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"randBits.d.ts","sourceRoot":"","sources":["../src/ts/randBits.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,UAAU,GAAC,MAAM,CAAC,CAmBrG;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,UAAU,GAAC,MAAM,CAehG"}
|
|
@ -0,0 +1,26 @@
|
|||
/// <reference types="node" />
|
||||
/**
|
||||
* Secure random bytes for both node and browsers. Node version uses crypto.randomBytes() and browser one self.crypto.getRandomValues()
|
||||
*
|
||||
* @param byteLength - The desired number of random bytes
|
||||
* @param forceLength - If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* byteLength MUST be > 0
|
||||
*
|
||||
* @returns A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
|
||||
*/
|
||||
export declare function randBytes(byteLength: number, forceLength?: boolean): Promise<Uint8Array | Buffer>;
|
||||
/**
|
||||
* Secure random bytes for both node and browsers. Node version uses crypto.randomFill() and browser one self.crypto.getRandomValues()
|
||||
*
|
||||
* @param byteLength - The desired number of random bytes
|
||||
* @param forceLength - If we want to force the output to have a bit length of 8*byteLength. It basically forces the msb to be 1
|
||||
*
|
||||
* @throws {RangeError}
|
||||
* byteLength MUST be > 0
|
||||
*
|
||||
* @returns A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure random bytes
|
||||
*/
|
||||
export declare function randBytesSync(byteLength: number, forceLength?: boolean): Uint8Array | Buffer;
|
||||
//# sourceMappingURL=randBytes.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"randBytes.d.ts","sourceRoot":"","sources":["../src/ts/randBytes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAE,UAAU,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,OAAO,CAAC,UAAU,GAAC,MAAM,CAAC,CAqB9F;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,UAAU,GAAC,MAAM,CAkBlG"}
|
|
@ -0,0 +1,14 @@
|
|||
export declare function _workerUrl(workerCode: string): string;
|
||||
declare let _useWorkers: boolean;
|
||||
export { _useWorkers };
|
||||
export interface WorkerToMainMsg {
|
||||
isPrime: boolean;
|
||||
value: bigint;
|
||||
id: number;
|
||||
}
|
||||
export interface MainToWorkerMsg {
|
||||
rnd: bigint;
|
||||
iterations: number;
|
||||
id: number;
|
||||
}
|
||||
//# sourceMappingURL=workerUtils.d.ts.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"workerUtils.d.ts","sourceRoot":"","sources":["../src/ts/workerUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,QAAA,IAAI,WAAW,SAAQ,CAAA;AAiBvB,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,MAAM,CAAA;CACX"}
|
Loading…
Reference in New Issue