quantumcoin 7.0.9 → 7.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-SDK.md +1 -5
- package/README.md +18 -3
- package/SPEC.md +2 -63
- package/config.js +10 -2
- package/examples/example.js +0 -5
- package/examples/example.ts +0 -5
- package/examples/node_modules/.bin/esbuild +16 -0
- package/examples/node_modules/.bin/esbuild.cmd +17 -0
- package/examples/node_modules/.bin/esbuild.ps1 +28 -0
- package/examples/node_modules/.bin/sdkgen +16 -0
- package/examples/node_modules/.bin/sdkgen.cmd +17 -0
- package/examples/node_modules/.bin/sdkgen.ps1 +28 -0
- package/examples/node_modules/.bin/tsx +16 -0
- package/examples/node_modules/.bin/tsx.cmd +17 -0
- package/examples/node_modules/.bin/tsx.ps1 +28 -0
- package/examples/node_modules/.package-lock.json +235 -0
- package/examples/node_modules/@esbuild/win32-x64/README.md +3 -0
- package/examples/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
- package/examples/node_modules/@esbuild/win32-x64/package.json +20 -0
- package/examples/node_modules/esbuild/LICENSE.md +21 -0
- package/examples/node_modules/esbuild/README.md +3 -0
- package/examples/node_modules/esbuild/bin/esbuild +223 -0
- package/examples/node_modules/esbuild/install.js +289 -0
- package/examples/node_modules/esbuild/lib/main.d.ts +716 -0
- package/examples/node_modules/esbuild/lib/main.js +2532 -0
- package/examples/node_modules/esbuild/package.json +49 -0
- package/examples/node_modules/get-tsconfig/LICENSE +21 -0
- package/examples/node_modules/get-tsconfig/README.md +235 -0
- package/examples/node_modules/get-tsconfig/dist/index.cjs +7 -0
- package/examples/node_modules/get-tsconfig/dist/index.d.cts +2088 -0
- package/examples/node_modules/get-tsconfig/dist/index.d.mts +2088 -0
- package/examples/node_modules/get-tsconfig/dist/index.mjs +7 -0
- package/examples/node_modules/get-tsconfig/package.json +46 -0
- package/examples/node_modules/quantum-coin-js-sdk/.github/workflows/publish-npmjs.yaml +22 -0
- package/examples/node_modules/quantum-coin-js-sdk/LICENSE +21 -0
- package/examples/node_modules/quantum-coin-js-sdk/LICENSE-wasm_exec.js.txt +30 -0
- package/examples/node_modules/quantum-coin-js-sdk/README.md +1665 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/README.md +14 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/conversion-example.js +19 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-create-contract.js +396 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-encode-decode-rlp.js +225 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-event-pack-unpack.js +391 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-misc.js +101 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send-signRawTransaction.js +318 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send.js +116 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +70 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +961 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +35 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet.js +43 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/example.js +405 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/package-lock.json +134 -0
- package/examples/node_modules/quantum-coin-js-sdk/example/package.json +15 -0
- package/examples/node_modules/quantum-coin-js-sdk/index.d.ts +1024 -0
- package/examples/node_modules/quantum-coin-js-sdk/index.js +3062 -0
- package/examples/node_modules/quantum-coin-js-sdk/package.json +34 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-32.json +1 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-36.json +1 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-48.json +1 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/generate-verify-vectors.js +91 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.preinit.test.js +41 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.test.js +686 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-keytype5-context-null.test.js +107 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-transaction.test.js +196 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/sign-verify.test.js +311 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.relay.test.js +131 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.rpc.test.js +103 -0
- package/examples/node_modules/quantum-coin-js-sdk/tests/verify-vectors.json +95035 -0
- package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.d.ts +9 -0
- package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.js +16 -0
- package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.d.ts +0 -0
- package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.js +587 -0
- package/examples/node_modules/resolve-pkg-maps/LICENSE +21 -0
- package/examples/node_modules/resolve-pkg-maps/README.md +216 -0
- package/examples/node_modules/resolve-pkg-maps/dist/index.cjs +1 -0
- package/examples/node_modules/resolve-pkg-maps/dist/index.d.cts +11 -0
- package/examples/node_modules/resolve-pkg-maps/dist/index.d.mts +11 -0
- package/examples/node_modules/resolve-pkg-maps/dist/index.mjs +1 -0
- package/examples/node_modules/resolve-pkg-maps/package.json +42 -0
- package/examples/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +22 -0
- package/examples/node_modules/seed-words/BUILD.md +7 -0
- package/examples/node_modules/seed-words/LICENSE +121 -0
- package/examples/node_modules/seed-words/README.md +67 -0
- package/examples/node_modules/seed-words/dist/seedwords.d.ts +39 -0
- package/examples/node_modules/seed-words/package.json +27 -0
- package/examples/node_modules/seed-words/seedwords.js +315 -0
- package/examples/node_modules/seed-words/seedwords.txt +65536 -0
- package/examples/node_modules/seed-words/tsconfig.json +21 -0
- package/examples/node_modules/tsx/LICENSE +21 -0
- package/examples/node_modules/tsx/README.md +32 -0
- package/examples/node_modules/tsx/dist/cjs/api/index.cjs +1 -0
- package/examples/node_modules/tsx/dist/cjs/api/index.d.cts +35 -0
- package/examples/node_modules/tsx/dist/cjs/api/index.d.mts +35 -0
- package/examples/node_modules/tsx/dist/cjs/api/index.mjs +1 -0
- package/examples/node_modules/tsx/dist/cjs/index.cjs +1 -0
- package/examples/node_modules/tsx/dist/cjs/index.mjs +1 -0
- package/examples/node_modules/tsx/dist/cli.cjs +54 -0
- package/examples/node_modules/tsx/dist/cli.mjs +55 -0
- package/examples/node_modules/tsx/dist/client-BQVF1NaW.mjs +1 -0
- package/examples/node_modules/tsx/dist/client-D6NvIMSC.cjs +1 -0
- package/examples/node_modules/tsx/dist/esm/api/index.cjs +1 -0
- package/examples/node_modules/tsx/dist/esm/api/index.d.cts +35 -0
- package/examples/node_modules/tsx/dist/esm/api/index.d.mts +35 -0
- package/examples/node_modules/tsx/dist/esm/api/index.mjs +1 -0
- package/examples/node_modules/tsx/dist/esm/index.cjs +2 -0
- package/examples/node_modules/tsx/dist/esm/index.mjs +2 -0
- package/examples/node_modules/tsx/dist/get-pipe-path-BHW2eJdv.mjs +1 -0
- package/examples/node_modules/tsx/dist/get-pipe-path-BoR10qr8.cjs +1 -0
- package/examples/node_modules/tsx/dist/index-7AaEi15b.mjs +14 -0
- package/examples/node_modules/tsx/dist/index-BWFBUo6r.cjs +1 -0
- package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +1 -0
- package/examples/node_modules/tsx/dist/index-gckBtVBf.cjs +14 -0
- package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +3 -0
- package/examples/node_modules/tsx/dist/lexer-DgIbo0BU.cjs +3 -0
- package/examples/node_modules/tsx/dist/loader.cjs +1 -0
- package/examples/node_modules/tsx/dist/loader.mjs +1 -0
- package/examples/node_modules/tsx/dist/node-features-_8ZFwP_x.mjs +1 -0
- package/examples/node_modules/tsx/dist/node-features-roYmp9jK.cjs +1 -0
- package/examples/node_modules/tsx/dist/package-CeBgXWuR.mjs +1 -0
- package/examples/node_modules/tsx/dist/package-Dxt5kIHw.cjs +1 -0
- package/examples/node_modules/tsx/dist/patch-repl.cjs +1 -0
- package/examples/node_modules/tsx/dist/patch-repl.mjs +1 -0
- package/examples/node_modules/tsx/dist/preflight.cjs +1 -0
- package/examples/node_modules/tsx/dist/preflight.mjs +1 -0
- package/examples/node_modules/tsx/dist/register-2sWVXuRQ.cjs +1 -0
- package/examples/node_modules/tsx/dist/register-B7jrtLTO.mjs +1 -0
- package/examples/node_modules/tsx/dist/register-CFH5oNdT.mjs +4 -0
- package/examples/node_modules/tsx/dist/register-D46fvsV_.cjs +4 -0
- package/examples/node_modules/tsx/dist/repl.cjs +3 -0
- package/examples/node_modules/tsx/dist/repl.mjs +3 -0
- package/examples/node_modules/tsx/dist/require-D4F1Lv60.cjs +1 -0
- package/examples/node_modules/tsx/dist/require-DQxpCAr4.mjs +1 -0
- package/examples/node_modules/tsx/dist/suppress-warnings.cjs +1 -0
- package/examples/node_modules/tsx/dist/suppress-warnings.mjs +1 -0
- package/examples/node_modules/tsx/dist/temporary-directory-B83uKxJF.cjs +1 -0
- package/examples/node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs +1 -0
- package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +5 -0
- package/examples/node_modules/tsx/package.json +68 -0
- package/examples/offline-signing.js +0 -2
- package/examples/offline-signing.ts +0 -1
- package/examples/package-lock.json +424 -73
- package/examples/package.json +2 -2
- package/examples/wallet-offline.js +10 -9
- package/examples/wallet-offline.ts +1 -9
- package/generate-sdk.js +4 -6
- package/package.json +2 -2
- package/src/abi/interface.js +13 -7
- package/src/abi/js-abi-coder.js +23 -18
- package/src/constants.d.ts +0 -5
- package/src/constants.js +0 -7
- package/src/contract/contract-factory.js +9 -3
- package/src/contract/contract.js +9 -3
- package/src/errors/index.js +12 -0
- package/src/index.d.ts +0 -3
- package/src/providers/extra-providers.js +20 -6
- package/src/providers/json-rpc-provider.js +15 -5
- package/src/providers/provider.d.ts +0 -2
- package/src/providers/provider.js +1 -3
- package/src/utils/address.d.ts +0 -14
- package/src/utils/address.js +12 -49
- package/src/utils/hashing.d.ts +0 -6
- package/src/utils/hashing.js +8 -23
- package/src/utils/index.d.ts +0 -3
- package/src/utils/rlp.js +7 -4
- package/src/wallet/wallet.d.ts +11 -13
- package/src/wallet/wallet.js +135 -96
- package/test/security/malformed-input.test.js +295 -1
- package/test/unit/address-wallet.test.js +277 -128
- package/test/unit/address-wallet.test.ts +276 -127
- package/test/unit/hashing.test.js +0 -11
- package/test/unit/hashing.test.ts +0 -11
- package/test/unit/providers.test.js +3 -1
- package/test/unit/providers.test.ts +3 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# resolve-pkg-maps
|
|
2
|
+
|
|
3
|
+
Utils to resolve `package.json` subpath & conditional [`exports`](https://nodejs.org/api/packages.html#exports)/[`imports`](https://nodejs.org/api/packages.html#imports) in resolvers.
|
|
4
|
+
|
|
5
|
+
Implements the [ESM resolution algorithm](https://nodejs.org/api/esm.html#resolver-algorithm-specification). Tested [against Node.js](/tests/) for accuracy.
|
|
6
|
+
|
|
7
|
+
<sub>Support this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️</sub>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
### Resolving `exports`
|
|
12
|
+
|
|
13
|
+
_utils/package.json_
|
|
14
|
+
```json5
|
|
15
|
+
{
|
|
16
|
+
// ...
|
|
17
|
+
"exports": {
|
|
18
|
+
"./reverse": {
|
|
19
|
+
"require": "./file.cjs",
|
|
20
|
+
"default": "./file.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
// ...
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { resolveExports } from 'resolve-pkg-maps'
|
|
29
|
+
|
|
30
|
+
const [packageName, packageSubpath] = parseRequest('utils/reverse')
|
|
31
|
+
|
|
32
|
+
const resolvedPaths: string[] = resolveExports(
|
|
33
|
+
getPackageJson(packageName).exports,
|
|
34
|
+
packageSubpath,
|
|
35
|
+
['import', ...otherConditions]
|
|
36
|
+
)
|
|
37
|
+
// => ['./file.mjs']
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Resolving `imports`
|
|
41
|
+
|
|
42
|
+
_package.json_
|
|
43
|
+
```json5
|
|
44
|
+
{
|
|
45
|
+
// ...
|
|
46
|
+
"imports": {
|
|
47
|
+
"#supports-color": {
|
|
48
|
+
"node": "./index.js",
|
|
49
|
+
"default": "./browser.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
// ...
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { resolveImports } from 'resolve-pkg-maps'
|
|
58
|
+
|
|
59
|
+
const resolvedPaths: string[] = resolveImports(
|
|
60
|
+
getPackageJson('.').imports,
|
|
61
|
+
'#supports-color',
|
|
62
|
+
['node', ...otherConditions]
|
|
63
|
+
)
|
|
64
|
+
// => ['./index.js']
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API
|
|
68
|
+
|
|
69
|
+
### resolveExports(exports, request, conditions)
|
|
70
|
+
|
|
71
|
+
Returns: `string[]`
|
|
72
|
+
|
|
73
|
+
Resolves the `request` based on `exports` and `conditions`. Returns an array of paths (e.g. in case a fallback array is matched).
|
|
74
|
+
|
|
75
|
+
#### exports
|
|
76
|
+
|
|
77
|
+
Type:
|
|
78
|
+
```ts
|
|
79
|
+
type Exports = PathOrMap | readonly PathOrMap[]
|
|
80
|
+
|
|
81
|
+
type PathOrMap = string | PathConditionsMap
|
|
82
|
+
|
|
83
|
+
type PathConditionsMap = {
|
|
84
|
+
[condition: string]: PathConditions | null
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The [`exports` property](https://nodejs.org/api/packages.html#exports) value in `package.json`.
|
|
89
|
+
|
|
90
|
+
#### request
|
|
91
|
+
|
|
92
|
+
Type: `string`
|
|
93
|
+
|
|
94
|
+
The package subpath to resolve. Assumes a normalized path is passed in (eg. [repeating slashes `//`](https://github.com/nodejs/node/issues/44316)).
|
|
95
|
+
|
|
96
|
+
It _should not_ start with `/` or `./`.
|
|
97
|
+
|
|
98
|
+
Example: if the full import path is `some-package/subpath/file`, the request is `subpath/file`.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
#### conditions
|
|
102
|
+
|
|
103
|
+
Type: `readonly string[]`
|
|
104
|
+
|
|
105
|
+
An array of conditions to use when resolving the request. For reference, Node.js's default conditions are [`['node', 'import']`](https://nodejs.org/api/esm.html#:~:text=defaultConditions%20is%20the%20conditional%20environment%20name%20array%2C%20%5B%22node%22%2C%20%22import%22%5D.).
|
|
106
|
+
|
|
107
|
+
The order of this array does not matter; the order of condition keys in the export map is what matters instead.
|
|
108
|
+
|
|
109
|
+
Not all conditions in the array need to be met to resolve the request. It just needs enough to resolve to a path.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### resolveImports(imports, request, conditions)
|
|
114
|
+
|
|
115
|
+
Returns: `string[]`
|
|
116
|
+
|
|
117
|
+
Resolves the `request` based on `imports` and `conditions`. Returns an array of paths (e.g. in case a fallback array is matched).
|
|
118
|
+
|
|
119
|
+
#### imports
|
|
120
|
+
|
|
121
|
+
Type:
|
|
122
|
+
```ts
|
|
123
|
+
type Imports = {
|
|
124
|
+
[condition: string]: PathOrMap | readonly PathOrMap[] | null
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
type PathOrMap = string | Imports
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The [`imports` property](https://nodejs.org/api/packages.html#imports) value in `package.json`.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
#### request
|
|
134
|
+
|
|
135
|
+
Type: `string`
|
|
136
|
+
|
|
137
|
+
The request resolve. Assumes a normalized path is passed in (eg. [repeating slashes `//`](https://github.com/nodejs/node/issues/44316)).
|
|
138
|
+
|
|
139
|
+
> **Note:** In Node.js, imports resolutions are limited to requests prefixed with `#`. However, this package does not enforce that requirement in case you want to add custom support for non-prefixed entries.
|
|
140
|
+
|
|
141
|
+
#### conditions
|
|
142
|
+
|
|
143
|
+
Type: `readonly string[]`
|
|
144
|
+
|
|
145
|
+
An array of conditions to use when resolving the request. For reference, Node.js's default conditions are [`['node', 'import']`](https://nodejs.org/api/esm.html#:~:text=defaultConditions%20is%20the%20conditional%20environment%20name%20array%2C%20%5B%22node%22%2C%20%22import%22%5D.).
|
|
146
|
+
|
|
147
|
+
The order of this array does not matter; the order of condition keys in the import map is what matters instead.
|
|
148
|
+
|
|
149
|
+
Not all conditions in the array need to be met to resolve the request. It just needs enough to resolve to a path.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### Errors
|
|
154
|
+
|
|
155
|
+
#### `ERR_PACKAGE_PATH_NOT_EXPORTED`
|
|
156
|
+
- If the request is not exported by the export map
|
|
157
|
+
|
|
158
|
+
#### `ERR_PACKAGE_IMPORT_NOT_DEFINED`
|
|
159
|
+
- If the request is not defined by the import map
|
|
160
|
+
|
|
161
|
+
#### `ERR_INVALID_PACKAGE_CONFIG`
|
|
162
|
+
|
|
163
|
+
- If an object contains properties that are both paths and conditions (e.g. start with and without `.`)
|
|
164
|
+
- If an object contains numeric properties
|
|
165
|
+
|
|
166
|
+
#### `ERR_INVALID_PACKAGE_TARGET`
|
|
167
|
+
- If a resolved exports path is not a valid path (e.g. not relative or has protocol)
|
|
168
|
+
- If a resolved path includes `..` or `node_modules`
|
|
169
|
+
- If a resolved path is a type that cannot be parsed
|
|
170
|
+
|
|
171
|
+
## FAQ
|
|
172
|
+
|
|
173
|
+
### Why do the APIs return an array of paths?
|
|
174
|
+
|
|
175
|
+
`exports`/`imports` supports passing in a [fallback array](https://github.com/jkrems/proposal-pkg-exports/#:~:text=Whenever%20there%20is,to%20new%20cases.) to provide fallback paths if the previous one is invalid:
|
|
176
|
+
|
|
177
|
+
```json5
|
|
178
|
+
{
|
|
179
|
+
"exports": {
|
|
180
|
+
"./feature": [
|
|
181
|
+
"./file.js",
|
|
182
|
+
"./fallback.js"
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Node.js's implementation [picks the first valid path (without attempting to resolve it)](https://github.com/nodejs/node/issues/44282#issuecomment-1220151715) and throws an error if it can't be resolved. Node.js's fallback array is designed for [forward compatibility with features](https://github.com/jkrems/proposal-pkg-exports/#:~:text=providing%20forwards%20compatiblitiy%20for%20new%20features) (e.g. protocols) that can be immediately/inexpensively validated:
|
|
189
|
+
|
|
190
|
+
```json5
|
|
191
|
+
{
|
|
192
|
+
"exports": {
|
|
193
|
+
"./core-polyfill": ["std:core-module", "./core-polyfill.js"]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
However, [Webpack](https://webpack.js.org/guides/package-exports/#alternatives) and [TypeScript](https://github.com/microsoft/TypeScript/blob/71e852922888337ef51a0e48416034a94a6c34d9/src/compiler/moduleSpecifiers.ts#L695) have deviated from this behavior and attempts to resolve the next path if a path cannot be resolved.
|
|
199
|
+
|
|
200
|
+
By returning an array of matched paths instead of just the first one, the user can decide which behavior to adopt.
|
|
201
|
+
|
|
202
|
+
### How is it different from [`resolve.exports`](https://github.com/lukeed/resolve.exports)?
|
|
203
|
+
|
|
204
|
+
`resolve.exports` only resolves `exports`, whereas this package resolves both `exports` & `imports`. This comparison will only cover resolving `exports`.
|
|
205
|
+
|
|
206
|
+
- Despite it's name, `resolve.exports` handles more than just `exports`. It takes in the entire `package.json` object to handle resolving `.` and [self-references](https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-name). This package only accepts `exports`/`imports` maps from `package.json` and is scoped to only resolving what's defined in the maps.
|
|
207
|
+
|
|
208
|
+
- `resolve.exports` accepts the full request (e.g. `foo/bar`), whereas this package only accepts the requested subpath (e.g. `bar`).
|
|
209
|
+
|
|
210
|
+
- `resolve.exports` only returns the first result in a fallback array. This package returns an array of results for the user to decide how to handle it.
|
|
211
|
+
|
|
212
|
+
- `resolve.exports` supports [subpath folder mapping](https://nodejs.org/docs/latest-v16.x/api/packages.html#subpath-folder-mappings) (deprecated in Node.js v16 & removed in v17) but seems to [have a bug](https://github.com/lukeed/resolve.exports/issues/7). This package does not support subpath folder mapping because Node.js has removed it in favor of using subpath patterns.
|
|
213
|
+
|
|
214
|
+
- Neither resolvers rely on a file-system
|
|
215
|
+
|
|
216
|
+
This package also addresses many of the bugs in `resolve.exports`, demonstrated in [this test](/tests/exports/compare-resolve.exports.ts).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const d=r=>r!==null&&typeof r=="object",s=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),g="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",P="ERR_PACKAGE_IMPORT_NOT_DEFINED",R=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,u=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,n,o,c)=>{if(t==null)return[];if(typeof t=="string"){const[e,...i]=t.split(u);if(e===".."||i.some(l=>O.test(l)))throw s(E,`Invalid "${r}" target "${t}" defined in the package config`);return[c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(e=>f(r,e,n,o,c));if(d(t)){for(const e of Object.keys(t)){if(R.test(e))throw s(g,"Cannot contain numeric property keys");if(e==="default"||o.includes(e))return f(r,t[e],n,o,c)}return[]}throw s(E,`Invalid "${r}" target "${t}"`)},a="*",v=(r,t)=>{const n=r.indexOf(a),o=t.indexOf(a);return n===o?t.length>r.length:o>n};function A(r,t){if(!t.includes(a)&&r.hasOwnProperty(t))return[t];let n,o;for(const c of Object.keys(r))if(c.includes(a)){const[e,i,l]=c.split(a);if(l===void 0&&t.startsWith(e)&&t.endsWith(i)){const _=t.slice(e.length,-i.length||void 0);_&&(!n||v(n,c))&&(n=c,o=_)}}return[n,o]}const p=r=>Object.keys(r).reduce((t,n)=>{const o=n===""||n[0]!==".";if(t===void 0||t===o)return o;throw s(g,'"exports" cannot contain some keys starting with "." and some not')},void 0),w=/^\w+:/,m=(r,t,n)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||d(r)&&p(r))&&(r={".":r});const[o,c]=A(r,t),e=f(h.Export,r[o],t,n,c);if(e.length===0)throw s(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of e)if(!i.startsWith("./")&&!w.test(i))throw s(E,`Invalid "exports" target "${i}" defined in the package config`);return e},T=(r,t,n)=>{if(!r)throw new Error('"imports" is required');const[o,c]=A(r,t),e=f(h.Import,r[o],t,n,c);if(e.length===0)throw s(P,`Package import specifier "${t}" is not defined in package`);return e};exports.resolveExports=m,exports.resolveImports=T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type PathConditionsMap = {
|
|
2
|
+
[condition: string]: PathConditions | null;
|
|
3
|
+
};
|
|
4
|
+
type PathOrMap = string | PathConditionsMap;
|
|
5
|
+
type PathConditions = PathOrMap | readonly PathOrMap[];
|
|
6
|
+
|
|
7
|
+
declare const resolveExports: (exports: PathConditions, request: string, conditions: readonly string[]) => string[];
|
|
8
|
+
|
|
9
|
+
declare const resolveImports: (imports: PathConditionsMap, request: string, conditions: readonly string[]) => string[];
|
|
10
|
+
|
|
11
|
+
export { PathConditions, PathConditionsMap, resolveExports, resolveImports };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type PathConditionsMap = {
|
|
2
|
+
[condition: string]: PathConditions | null;
|
|
3
|
+
};
|
|
4
|
+
type PathOrMap = string | PathConditionsMap;
|
|
5
|
+
type PathConditions = PathOrMap | readonly PathOrMap[];
|
|
6
|
+
|
|
7
|
+
declare const resolveExports: (exports: PathConditions, request: string, conditions: readonly string[]) => string[];
|
|
8
|
+
|
|
9
|
+
declare const resolveImports: (imports: PathConditionsMap, request: string, conditions: readonly string[]) => string[];
|
|
10
|
+
|
|
11
|
+
export { PathConditions, PathConditionsMap, resolveExports, resolveImports };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",P="ERR_PACKAGE_IMPORT_NOT_DEFINED",R=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return[];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return[c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R.test(n))throw a(_,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return[]}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return[t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g)}}return[e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n},T=(r,t,e)=>{if(!r)throw new Error('"imports" is required');const[o,c]=d(r,t),n=f(h.Import,r[o],t,e,c);if(n.length===0)throw a(P,`Package import specifier "${t}" is not defined in package`);return n};export{v as resolveExports,T as resolveImports};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "resolve-pkg-maps",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Resolve package.json exports & imports maps",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"node.js",
|
|
7
|
+
"package.json",
|
|
8
|
+
"exports",
|
|
9
|
+
"imports"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": "privatenumber/resolve-pkg-maps",
|
|
13
|
+
"funding": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Hiroki Osame",
|
|
16
|
+
"email": "hiroki.osame@gmail.com"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"module": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
25
|
+
"exports": {
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.cts",
|
|
28
|
+
"default": "./dist/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/index.d.mts",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"imports": {
|
|
36
|
+
"#resolve-pkg-maps": {
|
|
37
|
+
"types": "./src/index.ts",
|
|
38
|
+
"development": "./src/index.ts",
|
|
39
|
+
"default": "./dist/index.mjs"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Publish Package to npmjs
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
id-token: write
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
# Setup .npmrc file to publish to npm
|
|
14
|
+
- uses: actions/setup-node@v4
|
|
15
|
+
with:
|
|
16
|
+
node-version: '20.x'
|
|
17
|
+
registry-url: 'https://registry.npmjs.org'
|
|
18
|
+
- run: npm install
|
|
19
|
+
- run: npm ci
|
|
20
|
+
- run: npm publish --provenance --access public
|
|
21
|
+
env:
|
|
22
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not
|
|
43
|
+
limited to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
+
in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
+
protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or successor version of such
|
|
58
|
+
directive); and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty, and any national
|
|
61
|
+
implementations thereof.
|
|
62
|
+
|
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
+
including without limitation commercial, advertising or promotional
|
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the
|
|
118
|
+
Work.
|
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
+
party to this document and has no duty or obligation with respect to
|
|
121
|
+
this CC0 or use of the Work.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<a name="module_seed-words"></a>
|
|
2
|
+
|
|
3
|
+
## seed-words
|
|
4
|
+
Seed Words is a list of English words to be used in mnemonic seed phrases. There are a total of 256 x 256 = 65536 words. They can be used to represent any arbitrary 2 byte array with a single
|
|
5
|
+
|
|
6
|
+
**Example**
|
|
7
|
+
```js
|
|
8
|
+
Requires Node.js version v20.18.1 or higher
|
|
9
|
if (initResult === false) {
|
|
1
10
|
console.log("error initializing");
|
|
2
11
|
} else {
|
|
3
12
|
console.log("initialized");
|
|
4
13
|
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
* [seed-words](#module_seed-words)
|
|
17
|
+
* [~initialize()](#module_seed-words..initialize) ⇒ <code>Promise.<boolean></code>
|
|
18
|
+
* [~getAllSeedWords()](#module_seed-words..getAllSeedWords) ⇒ <code>array</code>
|
|
19
|
+
* [~getWordListFromSeedArray(seedArray)](#module_seed-words..getWordListFromSeedArray) ⇒ <code>array</code>
|
|
20
|
+
* [~getSeedArrayFromWordList(wordList)](#module_seed-words..getSeedArrayFromWordList) ⇒ <code>array</code>
|
|
21
|
+
* [~doesSeedWordExist(word)](#module_seed-words..doesSeedWordExist) ⇒ <code>boolean</code>
|
|
22
|
+
|
|
23
|
+
<a name="module_seed-words..initialize"></a>
|
|
24
|
+
|
|
25
|
+
### seed-words~initialize() ⇒ <code>Promise.<boolean></code>
|
|
26
|
+
The initialize function has to be called before attempting to invoke any other function. This function should be called only once.
|
|
27
|
+
|
|
28
|
+
**Kind**: inner method of [<code>seed-words</code>](#module_seed-words)
|
|
29
|
+
**Returns**: <code>Promise.<boolean></code> - Returns a promise of type boolean; true if the initialization succeeded, else false.
|
|
30
|
+
<a name="module_seed-words..getAllSeedWords"></a>
|
|
31
|
+
|
|
32
|
+
### seed-words~getAllSeedWords() ⇒ <code>array</code>
|
|
33
|
+
The getAllSeedWords function returns all the seed words in an array.
|
|
34
|
+
|
|
35
|
+
**Kind**: inner method of [<code>seed-words</code>](#module_seed-words)
|
|
36
|
+
**Returns**: <code>array</code> - Returns an array with the list of all seed words.
|
|
37
|
+
<a name="module_seed-words..getWordListFromSeedArray"></a>
|
|
38
|
+
|
|
39
|
+
### seed-words~getWordListFromSeedArray(seedArray) ⇒ <code>array</code>
|
|
40
|
+
The getWordListFromSeedArray function returns the word list corresponding to a byte array.
|
|
41
|
+
|
|
42
|
+
**Kind**: inner method of [<code>seed-words</code>](#module_seed-words)
|
|
43
|
+
**Returns**: <code>array</code> - Returns the array of words (string) corresponding to the input seed array. Returns null on failure. This function can fail if the seedArray is invalid or initialize() hasn't been called.
|
|
44
|
+
|
|
45
|
+
| Param | Type | Description |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| seedArray | <code>array</code> | An array of bytes. This array should have an even number of elements. |
|
|
48
|
+
|
|
49
|
+
<a name="module_seed-words..getSeedArrayFromWordList"></a>
|
|
50
|
+
|
|
51
|
+
### seed-words~getSeedArrayFromWordList(wordList) ⇒ <code>array</code>
|
|
52
|
+
The getSeedArrayFromWordList function a byte array that corresponds to the seed word list.
|
|
53
|
+
|
|
54
|
+
**Kind**: inner method of [<code>seed-words</code>](#module_seed-words)
|
|
55
|
+
**Returns**: <code>array</code> - Returns an array of bytes that correspond to the wordList. Returns null on failure. This function can fail if initialize() function was not called or the word doesn't exist.
|
|
56
|
+
|
|
57
|
+
| Param | Type | Description |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| wordList | <code>array</code> | An array of seed words. |
|
|
60
|
+
|
|
61
|
+
<a name="module_seed-words..doesSeedWordExist"></a>
|
|
62
|
+
|
|
63
|
+
### seed-words~doesSeedWordExist(word) ⇒ <code>boolean</code>
|
|
64
|
+
The doesSeedWordExist function returns the word list corresponding to a byte array.
|
|
65
|
+
|
|
66
|
+
**Kind**: inner method of [<code>seed-words</code>](#module_seed-words)
|
|
67
|
+
**Returns**: <code>boolean</code> - Returns true if the seed word exists. Returns false if it doesn't exist. Returns null on failure. This function can fail if initialize() function was not called.
|
|
68
|
+
|
|
69
|
+
| Param | Type | Description |
|
|
70
|
+
| --- | --- | --- |
|
|
71
|
+
| word | <code>string</code> | A seed word to find whether it exists in the list or not. |
|
|
72
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The initialize function has to be called before attempting to invoke any other function. This function should be called only once.
|
|
3
|
+
*
|
|
4
|
+
* @async
|
|
5
|
+
* @function initialize
|
|
6
|
+
* @return {Promise<boolean>} Returns a promise of type boolean; true if the initialization succeeded, else false.
|
|
7
|
+
*/
|
|
8
|
+
export function initialize(): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* The getWordListFromSeedArray function returns the word list corresponding to a byte array.
|
|
11
|
+
*
|
|
12
|
+
* @function getWordListFromSeedArray
|
|
13
|
+
* @param {array} seedArray - An array of bytes. This array should have an even number of elements.
|
|
14
|
+
* @return {array} Returns the array of words (string) corresponding to the input seed array. Returns null on failure. This function can fail if the seedArray is invalid or initialize() hasn't been called.
|
|
15
|
+
*/
|
|
16
|
+
export function getWordListFromSeedArray(seedArray: any[]): any[];
|
|
17
|
+
/**
|
|
18
|
+
* The doesSeedWordExist function returns the word list corresponding to a byte array.
|
|
19
|
+
*
|
|
20
|
+
* @function doesSeedWordExist
|
|
21
|
+
* @param {string} word - A seed word to find whether it exists in the list or not.
|
|
22
|
+
* @return {boolean} Returns true if the seed word exists. Returns false if it doesn't exist. Returns null on failure. This function can fail if initialize() function was not called.
|
|
23
|
+
*/
|
|
24
|
+
export function doesSeedWordExist(word: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The getAllSeedWords function returns all the seed words in an array.
|
|
27
|
+
*
|
|
28
|
+
* @function getAllSeedWords
|
|
29
|
+
* @return {array} Returns an array with the list of all seed words.
|
|
30
|
+
*/
|
|
31
|
+
export function getAllSeedWords(): any[];
|
|
32
|
+
/**
|
|
33
|
+
* The getSeedArrayFromWordList function a byte array that corresponds to the seed word list.
|
|
34
|
+
*
|
|
35
|
+
* @function getSeedArrayFromWordList
|
|
36
|
+
* @param {array} wordList - An array of seed words.
|
|
37
|
+
* @return {array} Returns an array of bytes that correspond to the wordList. Returns null on failure. This function can fail if initialize() function was not called or the word doesn't exist.
|
|
38
|
+
*/
|
|
39
|
+
export function getSeedArrayFromWordList(wordList: any[]): any[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "seed-words",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Seed Words JS SDK",
|
|
5
|
+
"main": "seedwords.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "npx -p typescript tsc seedwords.js --declaration --allowJs --emitDeclarationOnly --outDir dist && jsdoc2md seedwords.js >README.md"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/quantumcoinproject/seed-words.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"seed-words",
|
|
16
|
+
"seed-phrases",
|
|
17
|
+
"mnemonics",
|
|
18
|
+
"seeds",
|
|
19
|
+
"quantumcoin"
|
|
20
|
+
],
|
|
21
|
+
"author": "QuantumCoin Community",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/quantumcoinproject/seed-words/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/quantumcoinproject/seed-words#readme"
|
|
27
|
+
}
|