@agoric/access-token 0.4.22-dev-488dec7.0.488dec7 → 0.4.22-dev-b85a94d.0.b85a94d
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/package.json +3 -5
- package/src/json-store.js +15 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/access-token",
|
|
3
|
-
"version": "0.4.22-dev-
|
|
3
|
+
"version": "0.4.22-dev-b85a94d.0.b85a94d",
|
|
4
4
|
"description": "Persistent credentials for Agoric users, backed by a simple JSON file",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/access-token.js",
|
|
@@ -18,13 +18,11 @@
|
|
|
18
18
|
"lint:types": "yarn run -T tsgo --tsBuildInfoFile tsconfig.tsgo.tsbuildinfo"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@agoric/internal": "0.3.3-dev-
|
|
22
|
-
"n-readlines": "^1.0.0",
|
|
21
|
+
"@agoric/internal": "0.3.3-dev-b85a94d.0.b85a94d",
|
|
23
22
|
"proper-lockfile": "^4.1.2",
|
|
24
23
|
"tmp": "^0.2.1"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@types/n-readlines": "^1.0.3",
|
|
28
26
|
"@types/proper-lockfile": "^4.1.2",
|
|
29
27
|
"ava": "^7.0.0",
|
|
30
28
|
"c8": "^10.1.3"
|
|
@@ -50,5 +48,5 @@
|
|
|
50
48
|
"engines": {
|
|
51
49
|
"node": "^20.9 || ^22.11"
|
|
52
50
|
},
|
|
53
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b85a94d36a78e1fac36766d1cb9649c5db9e869c"
|
|
54
52
|
}
|
package/src/json-store.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import fs from 'node:fs';
|
|
2
|
+
import fs, { createReadStream } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import process from 'node:process';
|
|
5
|
+
import { createInterface } from 'node:readline';
|
|
5
6
|
import lockfile from 'proper-lockfile';
|
|
6
|
-
import Readlines from 'n-readlines';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @import {LockOptions} from 'proper-lockfile';
|
|
@@ -197,9 +197,20 @@ async function makeJSONStore(
|
|
|
197
197
|
if (forceReset) {
|
|
198
198
|
safeUnlink(storeFile);
|
|
199
199
|
} else {
|
|
200
|
-
let lines;
|
|
201
200
|
try {
|
|
202
|
-
|
|
201
|
+
// Read file line by line using node:readline (replacement for .split('\n'))
|
|
202
|
+
const fileStream = createReadStream(storeFile);
|
|
203
|
+
const rl = createInterface({
|
|
204
|
+
input: fileStream,
|
|
205
|
+
crlfDelay: Infinity,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
for await (const line of rl) {
|
|
209
|
+
if (line.trim()) {
|
|
210
|
+
const [key, value] = JSON.parse(line);
|
|
211
|
+
storage.set(key, value);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
203
214
|
} catch (e) {
|
|
204
215
|
// storeFile will be missing the first time we try to use it. That's OK;
|
|
205
216
|
// commit will create it.
|
|
@@ -207,14 +218,6 @@ async function makeJSONStore(
|
|
|
207
218
|
throw e;
|
|
208
219
|
}
|
|
209
220
|
}
|
|
210
|
-
if (lines) {
|
|
211
|
-
let line = lines.next();
|
|
212
|
-
while (line) {
|
|
213
|
-
const [key, value] = JSON.parse(line.toString());
|
|
214
|
-
storage.set(key, value);
|
|
215
|
-
line = lines.next();
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
221
|
}
|
|
219
222
|
}
|
|
220
223
|
|