@appsemble/node-utils 0.37.5 → 0.37.6
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/README.md +3 -3
- package/authentication.d.ts +9 -1
- package/authentication.js +14 -5
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Node Utilities
|
|
2
2
|
|
|
3
3
|
> NodeJS utilities used by Appsemble internally.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/node-utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.37.6)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.37.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.37.6/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/authentication.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export declare const CREDENTIALS_ENV_VAR = "APPSEMBLE_CLIENT_CREDENTIALS";
|
|
2
2
|
export declare function getService(remote: string): string;
|
|
3
|
-
export
|
|
3
|
+
export interface Keyring {
|
|
4
|
+
findCredentials: (service: string) => Promise<{
|
|
5
|
+
account: string;
|
|
6
|
+
password: string;
|
|
7
|
+
}[]>;
|
|
8
|
+
setPassword: (service: string, account: string, password: string) => Promise<void>;
|
|
9
|
+
deletePassword: (service: string, account: string) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare function getKeyring(): Promise<Keyring>;
|
|
4
12
|
/**
|
|
5
13
|
* Login to the server using OAuth2 client credentials.
|
|
6
14
|
*
|
package/authentication.js
CHANGED
|
@@ -6,15 +6,24 @@ const authorizedRemotes = new Set();
|
|
|
6
6
|
export function getService(remote) {
|
|
7
7
|
return `appsemble://${new URL(remote).host}`;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
async function importKeyring() {
|
|
10
10
|
try {
|
|
11
|
-
|
|
12
|
-
return keytar;
|
|
11
|
+
return await import('@napi-rs/keyring');
|
|
13
12
|
}
|
|
14
13
|
catch {
|
|
15
|
-
throw new AppsembleError('Couldn’t
|
|
14
|
+
throw new AppsembleError('Couldn’t access the system keyring. Reinstall @appsemble/cli, or pass --client-credentials on the command line.');
|
|
16
15
|
}
|
|
17
16
|
}
|
|
17
|
+
export async function getKeyring() {
|
|
18
|
+
const { AsyncEntry, findCredentialsAsync } = await importKeyring();
|
|
19
|
+
return {
|
|
20
|
+
findCredentials: (service) => findCredentialsAsync(service),
|
|
21
|
+
setPassword: (service, account, password) => new AsyncEntry(service, account).setPassword(password),
|
|
22
|
+
async deletePassword(service, account) {
|
|
23
|
+
await new AsyncEntry(service, account).deletePassword();
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
18
27
|
async function getClientCredentials(remote, inputCredentials) {
|
|
19
28
|
if (inputCredentials) {
|
|
20
29
|
return inputCredentials;
|
|
@@ -24,7 +33,7 @@ async function getClientCredentials(remote, inputCredentials) {
|
|
|
24
33
|
logger.info(`Detected client credentials from ${CREDENTIALS_ENV_VAR} environment variable`);
|
|
25
34
|
return envCredentials;
|
|
26
35
|
}
|
|
27
|
-
const { findCredentials } = await
|
|
36
|
+
const { findCredentials } = await getKeyring();
|
|
28
37
|
const choices = await findCredentials(getService(remote));
|
|
29
38
|
if (choices.length === 0) {
|
|
30
39
|
throw new AppsembleError(`No client credentials found. Register them using:\n\nappsemble login --remote ${remote}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/node-utils",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.6",
|
|
4
4
|
"description": "NodeJS utilities used by Appsemble internally.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -40,13 +40,14 @@
|
|
|
40
40
|
"test": "vitest"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@appsemble/lang-sdk": "0.37.
|
|
44
|
-
"@appsemble/types": "0.37.
|
|
45
|
-
"@appsemble/utils": "0.37.
|
|
43
|
+
"@appsemble/lang-sdk": "0.37.6",
|
|
44
|
+
"@appsemble/types": "0.37.6",
|
|
45
|
+
"@appsemble/utils": "0.37.6",
|
|
46
46
|
"@formatjs/fast-memoize": "^2.0.0",
|
|
47
47
|
"@fortawesome/fontawesome-free": "^6.0.0",
|
|
48
48
|
"@inquirer/prompts": "^8.0.0",
|
|
49
49
|
"@kubernetes/client-node": "1.4.0",
|
|
50
|
+
"@napi-rs/keyring": "^1.3.0",
|
|
50
51
|
"@odata/parser": "^0.2.0",
|
|
51
52
|
"@types/koa": "^2.0.0",
|
|
52
53
|
"axios": "^1.0.0",
|
|
@@ -69,7 +70,6 @@
|
|
|
69
70
|
"intl-messageformat": "^11.0.0",
|
|
70
71
|
"ipaddr.js": "^2.4.0",
|
|
71
72
|
"jsonschema": "~1.4.1",
|
|
72
|
-
"keytar": "^7.0.0",
|
|
73
73
|
"koa": "^3.0.0",
|
|
74
74
|
"koa-compose": "^4.0.0",
|
|
75
75
|
"koa-mount": "^4.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"lodash": "^4.0.0",
|
|
84
84
|
"lodash-es": "^4.0.0",
|
|
85
85
|
"logform": "^2.0.0",
|
|
86
|
-
"memfs": "4.
|
|
86
|
+
"memfs": "4.68.1",
|
|
87
87
|
"mime-types": "^2.0.0",
|
|
88
88
|
"minio": "^8.0.7",
|
|
89
89
|
"mustache": "^4.0.0",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"@types/uuid": "10.0.0",
|
|
116
116
|
"axios-mock-adapter": "1.22.0",
|
|
117
117
|
"axios-test-instance": "7.0.0",
|
|
118
|
-
"vitest": "
|
|
118
|
+
"vitest": "4.1.10"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"prettier": "^3"
|