@agoric/access-token 0.4.22-other-dev-3eb1a1d.0 → 0.4.22-other-dev-d15096d.0.d15096d
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 +12 -8
- package/src/json-store.js +5 -1
- package/test/state.test.js +5 -2
- package/test/token.test.js +5 -3
- package/test/tmp.js +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/access-token",
|
|
3
|
-
"version": "0.4.22-other-dev-
|
|
3
|
+
"version": "0.4.22-other-dev-d15096d.0.d15096d",
|
|
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",
|
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "exit 0",
|
|
12
12
|
"test": "ava",
|
|
13
|
-
"test:c8": "c8 --all $C8_OPTIONS ava",
|
|
13
|
+
"test:c8": "c8 --all ${C8_OPTIONS:-} ava",
|
|
14
14
|
"test:xs": "exit 0",
|
|
15
|
-
"lint": "run-s --continue-on-error lint:*",
|
|
15
|
+
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
16
16
|
"lint-fix": "yarn lint:eslint --fix",
|
|
17
|
-
"lint:eslint": "eslint .",
|
|
18
|
-
"lint:types": "tsc"
|
|
17
|
+
"lint:eslint": "yarn run -T eslint .",
|
|
18
|
+
"lint:types": "yarn run -T tsc"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
|
|
21
22
|
"n-readlines": "^1.0.0",
|
|
22
23
|
"proper-lockfile": "^4.1.2",
|
|
23
24
|
"tmp": "^0.2.1"
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"@types/n-readlines": "^1.0.3",
|
|
27
28
|
"@types/proper-lockfile": "^4.1.2",
|
|
28
29
|
"ava": "^5.3.0",
|
|
29
|
-
"c8": "^10.1.
|
|
30
|
+
"c8": "^10.1.3"
|
|
30
31
|
},
|
|
31
32
|
"publishConfig": {
|
|
32
33
|
"access": "public"
|
|
@@ -41,7 +42,10 @@
|
|
|
41
42
|
"timeout": "2m"
|
|
42
43
|
},
|
|
43
44
|
"typeCoverage": {
|
|
44
|
-
"atLeast": 83.
|
|
45
|
+
"atLeast": 83.57
|
|
45
46
|
},
|
|
46
|
-
"
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": "^20.9 || ^22.11"
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
|
|
47
51
|
}
|
package/src/json-store.js
CHANGED
|
@@ -5,6 +5,10 @@ import process from 'process';
|
|
|
5
5
|
import lockfile from 'proper-lockfile';
|
|
6
6
|
import Readlines from 'n-readlines';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @import {LockOptions} from 'proper-lockfile';
|
|
10
|
+
*/
|
|
11
|
+
|
|
8
12
|
// TODO: Update this when we make a breaking change.
|
|
9
13
|
// const DATA_FILE = 'data.jsonlines';
|
|
10
14
|
//
|
|
@@ -159,7 +163,7 @@ function makeStorageInMemory() {
|
|
|
159
163
|
* @param {string} [dirPath] Path to a directory in which database files may be kept, or
|
|
160
164
|
* null.
|
|
161
165
|
* @param {boolean} [forceReset] If true, initialize the database to an empty state
|
|
162
|
-
* @param {null |
|
|
166
|
+
* @param {null | LockOptions['retries']} [lockRetries] If null, do not lock the database.
|
|
163
167
|
*
|
|
164
168
|
* @returns {Promise<{
|
|
165
169
|
* storage: JSONStore, // a storage API object to load and store data
|
package/test/state.test.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import
|
|
2
|
+
import tmp from 'tmp';
|
|
3
|
+
import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
|
|
3
4
|
import {
|
|
4
5
|
initJSONStore,
|
|
5
6
|
openJSONStore,
|
|
@@ -7,6 +8,8 @@ import {
|
|
|
7
8
|
isJSONStore,
|
|
8
9
|
} from '../src/json-store.js';
|
|
9
10
|
|
|
11
|
+
const tmpDir = makeTempDirFactory(tmp);
|
|
12
|
+
|
|
10
13
|
function testStorage(t, storage) {
|
|
11
14
|
t.falsy(storage.has('missing'));
|
|
12
15
|
t.is(storage.get('missing'), undefined);
|
|
@@ -39,7 +42,7 @@ function testStorage(t, storage) {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
test('storageInFile', async t => {
|
|
42
|
-
const [dbDir, cleanup] =
|
|
45
|
+
const [dbDir, cleanup] = tmpDir('testdb');
|
|
43
46
|
t.teardown(cleanup);
|
|
44
47
|
t.is(isJSONStore(dbDir), false);
|
|
45
48
|
const { storage, commit, close } = await initJSONStore(dbDir);
|
package/test/token.test.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import tmp from 'tmp';
|
|
3
|
+
import { makeTempDirFactory } from '@agoric/internal/src/tmpDir.js';
|
|
4
4
|
import { getAccessToken } from '../src/access-token.js';
|
|
5
5
|
|
|
6
|
+
const tmpDir = makeTempDirFactory(tmp);
|
|
7
|
+
|
|
6
8
|
test('access tokens', async t => {
|
|
7
|
-
const [sharedStateDir, removeCallback] =
|
|
9
|
+
const [sharedStateDir, removeCallback] = tmpDir('access-token-test');
|
|
8
10
|
const [a, b, c] = await Promise.all([
|
|
9
11
|
getAccessToken(1234, sharedStateDir),
|
|
10
12
|
getAccessToken(1234, sharedStateDir),
|
package/test/tmp.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import tmp from 'tmp';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {string} [prefix]
|
|
5
|
-
* @returns {Promise<[string, () => void]>}
|
|
6
|
-
*/
|
|
7
|
-
export const tmpDir = prefix =>
|
|
8
|
-
new Promise((resolve, reject) => {
|
|
9
|
-
// We use `unsafeCleanup` because we want to remove the directory even if it
|
|
10
|
-
// still contains files.
|
|
11
|
-
const unsafeCleanup = true;
|
|
12
|
-
tmp.dir({ unsafeCleanup, prefix }, (err, name, removeCallback) => {
|
|
13
|
-
if (err) {
|
|
14
|
-
reject(err);
|
|
15
|
-
} else {
|
|
16
|
-
resolve([name, removeCallback]);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
});
|