@leofcoin/peernet 1.2.24 → 1.2.25
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/exports/identity.js +1 -1
- package/package.json +1 -1
- package/rollup.config.js +10 -23
- package/test/peernet.test.js +7 -0
package/exports/identity.js
CHANGED
|
@@ -65,7 +65,7 @@ class Identity {
|
|
|
65
65
|
}
|
|
66
66
|
if (!password) {
|
|
67
67
|
// @ts-ignore
|
|
68
|
-
const importee = await import('./
|
|
68
|
+
const importee = await import('./prompts/password.js');
|
|
69
69
|
password = await importee.default();
|
|
70
70
|
}
|
|
71
71
|
const accountExists = await globalThis.accountStore.has('public');
|
package/package.json
CHANGED
package/rollup.config.js
CHANGED
|
@@ -27,20 +27,10 @@ const walk = async (dir) => {
|
|
|
27
27
|
|
|
28
28
|
const isHashedChunk = (runtimePath) => /-[A-Za-z0-9_-]{8,}\.js$/.test(runtimePath)
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const code = await readFile(filePath, 'utf8')
|
|
35
|
-
const normalized = code
|
|
36
|
-
.replaceAll("'./src/prompts/password.js'", "'./prompts/password.js'")
|
|
37
|
-
.replace(/(["'])\.\/Users\/[^"']*\/src\/prompts\/password\.js\1/g, '$1./prompts/password.js$1')
|
|
38
|
-
|
|
39
|
-
if (normalized !== code) {
|
|
40
|
-
await writeFile(filePath, normalized)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
})
|
|
30
|
+
const isPromptImport = (id) =>
|
|
31
|
+
id === './prompts/password.js' ||
|
|
32
|
+
id === './src/prompts/password.js' ||
|
|
33
|
+
id.endsWith('/src/prompts/password.js')
|
|
44
34
|
|
|
45
35
|
const runtimeFirstExports = ({ exportsDir = 'exports', declarationsDir = 'exports/types' } = {}) => ({
|
|
46
36
|
name: 'runtime-first-exports',
|
|
@@ -124,7 +114,7 @@ export default [
|
|
|
124
114
|
output: {
|
|
125
115
|
format: 'es',
|
|
126
116
|
dir: 'exports',
|
|
127
|
-
paths: (id) => (id
|
|
117
|
+
paths: (id) => (isPromptImport(id) ? './prompts/password.js' : id)
|
|
128
118
|
},
|
|
129
119
|
plugins: [
|
|
130
120
|
typescript({
|
|
@@ -132,15 +122,12 @@ export default [
|
|
|
132
122
|
outDir: 'exports',
|
|
133
123
|
declarationDir: 'exports/types'
|
|
134
124
|
}
|
|
135
|
-
})
|
|
136
|
-
normalizeNodePromptImport()
|
|
125
|
+
})
|
|
137
126
|
],
|
|
138
|
-
external:
|
|
139
|
-
|
|
140
|
-
'./
|
|
141
|
-
'./prompts/password/
|
|
142
|
-
'./prompts/password/node.js'
|
|
143
|
-
]
|
|
127
|
+
external: (id) =>
|
|
128
|
+
isPromptImport(id) ||
|
|
129
|
+
id === './prompts/password/browser.js' ||
|
|
130
|
+
id === './prompts/password/node.js'
|
|
144
131
|
},
|
|
145
132
|
{
|
|
146
133
|
input: ['./src/prompts/password/browser.js'],
|
package/test/peernet.test.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import test from 'node:test'
|
|
2
2
|
import assert from 'node:assert/strict'
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
3
4
|
|
|
4
5
|
import Peernet from '../exports/peernet.js'
|
|
5
6
|
import Identity, { resolveAccountWallets } from '../exports/identity.js'
|
|
@@ -18,6 +19,12 @@ const options = {
|
|
|
18
19
|
const password = 'password'
|
|
19
20
|
const peernet = await new Peernet(options, password)
|
|
20
21
|
|
|
22
|
+
test('node bundle uses a portable password prompt import', async () => {
|
|
23
|
+
const identityBundle = await readFile(new URL('../exports/identity.js', import.meta.url), 'utf8')
|
|
24
|
+
assert.match(identityBundle, /import\(['"]\.\/prompts\/password\.js['"]\)/)
|
|
25
|
+
assert.doesNotMatch(identityBundle, /(?:\/home\/|\/Users\/|[A-Za-z]:\\)/)
|
|
26
|
+
})
|
|
27
|
+
|
|
21
28
|
test('initializes with provided options', () => {
|
|
22
29
|
assert.equal(peernet.network, options.network)
|
|
23
30
|
assert.equal(peernet.version, options.version)
|