@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.
@@ -65,7 +65,7 @@ class Identity {
65
65
  }
66
66
  if (!password) {
67
67
  // @ts-ignore
68
- const importee = await import('./home/runner/work/peernet/peernet/src/prompts/password.js');
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.2.24",
3
+ "version": "1.2.25",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
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 normalizeNodePromptImport = () => ({
31
- name: 'normalize-node-prompt-import',
32
- writeBundle: async () => {
33
- const filePath = 'exports/identity.js'
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 === './src/prompts/password.js' ? './prompts/password.js' : 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
- './prompts/password.js',
140
- './src/prompts/password.js',
141
- './prompts/password/browser.js',
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'],
@@ -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)