@agoric/access-token 0.4.21-pismo-dev-0d5327f.0 → 0.4.22-dev-bf4b59f.0
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/CHANGELOG.md +9 -0
- package/jsconfig.json +1 -16
- package/package.json +5 -5
- package/src/access-token.js +7 -0
- package/src/json-store.js +11 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [0.4.21](https://github.com/Agoric/agoric-sdk/compare/@agoric/access-token@0.4.20...@agoric/access-token@0.4.21) (2023-05-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **agoric-cli:** begin separation of deploy host and script ([b091cad](https://github.com/Agoric/agoric-sdk/commit/b091cadbc652128e34d6225b6875baa5f1a9a4c7))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
### [0.4.20](https://github.com/Agoric/agoric-sdk/compare/@agoric/access-token@0.4.19...@agoric/access-token@0.4.20) (2022-10-05)
|
|
7
16
|
|
|
8
17
|
**Note:** Version bump only for package @agoric/access-token
|
package/jsconfig.json
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
// This file can contain .js-specific Typescript compiler config.
|
|
2
2
|
{
|
|
3
|
-
"
|
|
4
|
-
"target": "esnext",
|
|
5
|
-
"module": "esnext",
|
|
6
|
-
|
|
7
|
-
"noEmit": true,
|
|
8
|
-
/*
|
|
9
|
-
// The following flags are for creating .d.ts files:
|
|
10
|
-
"noEmit": false,
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"emitDeclarationOnly": true,
|
|
13
|
-
*/
|
|
14
|
-
"downlevelIteration": true,
|
|
15
|
-
"strictNullChecks": true,
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
},
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
18
4
|
"include": [
|
|
19
|
-
"exported.js",
|
|
20
5
|
"src/**/*.js",
|
|
21
6
|
"test/**/*.js"
|
|
22
7
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/access-token",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.22-dev-bf4b59f.0+bf4b59f",
|
|
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",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"lint:eslint": "eslint ."
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@agoric/assert": "0.
|
|
19
|
+
"@agoric/assert": "0.6.1-dev-bf4b59f.0+bf4b59f",
|
|
20
20
|
"n-readlines": "^1.0.0",
|
|
21
21
|
"tmp": "^0.2.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"ava": "^
|
|
25
|
-
"c8": "^7.
|
|
24
|
+
"ava": "^5.2.0",
|
|
25
|
+
"c8": "^7.13.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
],
|
|
34
34
|
"timeout": "2m"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "bf4b59f2128aca73d786429c6ef4a7c9cdfb6700"
|
|
37
37
|
}
|
package/src/access-token.js
CHANGED
|
@@ -26,6 +26,10 @@ export function generateAccessToken({
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @param {string|number} port
|
|
31
|
+
* @returns {Promise<string>}
|
|
32
|
+
*/
|
|
29
33
|
export async function getAccessToken(port) {
|
|
30
34
|
if (typeof port === 'string') {
|
|
31
35
|
const match = port.match(/^(.*:)?(\d+)$/);
|
|
@@ -47,5 +51,8 @@ export async function getAccessToken(port) {
|
|
|
47
51
|
}
|
|
48
52
|
const accessToken = storage.get(accessTokenKey);
|
|
49
53
|
await close();
|
|
54
|
+
if (typeof accessToken !== 'string') {
|
|
55
|
+
throw Error(`Could not find access token for ${port}`);
|
|
56
|
+
}
|
|
50
57
|
return accessToken;
|
|
51
58
|
}
|
package/src/json-store.js
CHANGED
|
@@ -51,7 +51,7 @@ function makeStorageInMemory() {
|
|
|
51
51
|
*/
|
|
52
52
|
function has(key) {
|
|
53
53
|
if (`${key}` !== key) {
|
|
54
|
-
throw
|
|
54
|
+
throw Error(`non-string key ${key}`);
|
|
55
55
|
}
|
|
56
56
|
return state.has(key);
|
|
57
57
|
}
|
|
@@ -74,10 +74,10 @@ function makeStorageInMemory() {
|
|
|
74
74
|
*/
|
|
75
75
|
function* getKeys(start, end) {
|
|
76
76
|
if (`${start}` !== start) {
|
|
77
|
-
throw
|
|
77
|
+
throw Error(`non-string start ${start}`);
|
|
78
78
|
}
|
|
79
79
|
if (`${end}` !== end) {
|
|
80
|
-
throw
|
|
80
|
+
throw Error(`non-string end ${end}`);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const keys = Array.from(state.keys()).sort();
|
|
@@ -100,7 +100,7 @@ function makeStorageInMemory() {
|
|
|
100
100
|
*/
|
|
101
101
|
function get(key) {
|
|
102
102
|
if (`${key}` !== key) {
|
|
103
|
-
throw
|
|
103
|
+
throw Error(`non-string key ${key}`);
|
|
104
104
|
}
|
|
105
105
|
return state.get(key);
|
|
106
106
|
}
|
|
@@ -116,10 +116,10 @@ function makeStorageInMemory() {
|
|
|
116
116
|
*/
|
|
117
117
|
function set(key, value) {
|
|
118
118
|
if (`${key}` !== key) {
|
|
119
|
-
throw
|
|
119
|
+
throw Error(`non-string key ${key}`);
|
|
120
120
|
}
|
|
121
121
|
if (`${value}` !== value) {
|
|
122
|
-
throw
|
|
122
|
+
throw Error(`non-string value ${value}`);
|
|
123
123
|
}
|
|
124
124
|
state.set(key, value);
|
|
125
125
|
}
|
|
@@ -134,7 +134,7 @@ function makeStorageInMemory() {
|
|
|
134
134
|
*/
|
|
135
135
|
function del(key) {
|
|
136
136
|
if (`${key}` !== key) {
|
|
137
|
-
throw
|
|
137
|
+
throw Error(`non-string key ${key}`);
|
|
138
138
|
}
|
|
139
139
|
state.delete(key);
|
|
140
140
|
}
|
|
@@ -229,7 +229,7 @@ function makeJSONStore(dirPath, forceReset = false) {
|
|
|
229
229
|
* serialized to a text file. If there is an existing store at the given
|
|
230
230
|
* `dirPath`, it will be reinitialized to an empty state.
|
|
231
231
|
*
|
|
232
|
-
* @param {string
|
|
232
|
+
* @param {string} [dirPath] Path to a directory in which database files may be kept.
|
|
233
233
|
* This directory need not actually exist yet (if it doesn't it will be
|
|
234
234
|
* created) but it is reserved (by the caller) for the exclusive use of this
|
|
235
235
|
* JSON store instance. If this is nullish, the JSON store created will
|
|
@@ -244,7 +244,7 @@ function makeJSONStore(dirPath, forceReset = false) {
|
|
|
244
244
|
*/
|
|
245
245
|
export function initJSONStore(dirPath) {
|
|
246
246
|
if (dirPath !== null && dirPath !== undefined && `${dirPath}` !== dirPath) {
|
|
247
|
-
throw
|
|
247
|
+
throw Error('dirPath must be a string or nullish');
|
|
248
248
|
}
|
|
249
249
|
return makeJSONStore(dirPath, true);
|
|
250
250
|
}
|
|
@@ -268,7 +268,7 @@ export function initJSONStore(dirPath) {
|
|
|
268
268
|
*/
|
|
269
269
|
export function openJSONStore(dirPath) {
|
|
270
270
|
if (`${dirPath}` !== dirPath) {
|
|
271
|
-
throw
|
|
271
|
+
throw Error('dirPath must be a string');
|
|
272
272
|
}
|
|
273
273
|
return makeJSONStore(dirPath, false);
|
|
274
274
|
}
|
|
@@ -321,11 +321,10 @@ export function setAllState(storage, stuff) {
|
|
|
321
321
|
* @returns {boolean}
|
|
322
322
|
* If the directory is present and contains the files created by initJSONStore
|
|
323
323
|
* or openJSONStore, returns true. Else returns false.
|
|
324
|
-
*
|
|
325
324
|
*/
|
|
326
325
|
export function isJSONStore(dirPath) {
|
|
327
326
|
if (`${dirPath}` !== dirPath) {
|
|
328
|
-
throw
|
|
327
|
+
throw Error('dirPath must be a string');
|
|
329
328
|
}
|
|
330
329
|
if (fs.existsSync(dirPath)) {
|
|
331
330
|
const storeFile = path.resolve(dirPath, DATA_FILE);
|