@deephaven-enterprise/auth-nodejs 1.20240723.107-alpha-auth-nodejs.23563 → 1.20240723.110-beta
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/dist/keyPairUtils.d.ts +11 -16
- package/dist/keyPairUtils.js +8 -15
- package/dist/loginUtils.js +4 -22
- package/package.json +10 -5
package/dist/keyPairUtils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Base64KeyPair, Base64Nonce, Base64PrivateKey, Base64PublicKey, Base64Signature, KeyPairType, PasswordCredentials } from './types.js';
|
|
1
|
+
import type { AuthenticatedClient, Base64KeyPair, Base64Nonce, Base64PrivateKey, Base64PublicKey, Base64Signature, KeyPairType, Username } from './types.js';
|
|
3
2
|
/**
|
|
4
3
|
* Generate a base64 encoded asymmetric key pair using eliptic curve.
|
|
5
4
|
* @returns The base64 encoded public and private keys.
|
|
@@ -22,34 +21,30 @@ export declare function keyWithSentinel(type: KeyPairType, key: Base64PublicKey
|
|
|
22
21
|
export declare function signWithPrivateKey(nonce: Base64Nonce, privateKey: Base64PrivateKey): Base64Signature;
|
|
23
22
|
/**
|
|
24
23
|
* Delete a list of public keys for a user.
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param credentials The credentials to use for authentication.
|
|
24
|
+
* @param dheClient An authenticated DHE client to use for the request.
|
|
25
|
+
* @param userName The user name to delete the keys for.
|
|
28
26
|
* @param publicKeys The list of public keys to delete.
|
|
29
27
|
* @param type The algorithm type used to generate the key.
|
|
30
28
|
* @returns A promise that resolves when the keys have been deleted.
|
|
31
29
|
*/
|
|
32
|
-
export declare function deletePublicKeys({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
credentials: PasswordCredentials;
|
|
30
|
+
export declare function deletePublicKeys({ dheClient, userName, publicKeys, type, }: {
|
|
31
|
+
dheClient: AuthenticatedClient;
|
|
32
|
+
userName: Username;
|
|
36
33
|
publicKeys: Base64PublicKey[];
|
|
37
34
|
type: KeyPairType;
|
|
38
35
|
}): Promise<void>;
|
|
39
36
|
/**
|
|
40
37
|
* Upload a public key to a DHE server.
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param credentials The credentials to use for authentication.
|
|
38
|
+
* @param dheClient An authenticated DHE client to use for the request.
|
|
39
|
+
* @param userName The user name to associate with the key.
|
|
44
40
|
* @param publicKey The base64 encoded public key.
|
|
45
41
|
* @param comment A comment to associate with the key.
|
|
46
42
|
* @param type The type of key pair.
|
|
47
43
|
* @returns The response from the server.
|
|
48
44
|
*/
|
|
49
|
-
export declare function uploadPublicKey({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
credentials: PasswordCredentials;
|
|
45
|
+
export declare function uploadPublicKey({ dheClient, userName, publicKey, comment, type, }: {
|
|
46
|
+
dheClient: AuthenticatedClient;
|
|
47
|
+
userName: Username;
|
|
53
48
|
comment: string;
|
|
54
49
|
publicKey: Base64PublicKey;
|
|
55
50
|
type: KeyPairType;
|
package/dist/keyPairUtils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { generateKeyPairSync, sign } from 'node:crypto';
|
|
2
|
-
import { createClient } from './clientUtils.js';
|
|
3
2
|
/*
|
|
4
3
|
* Named curve to use for generating key pairs.
|
|
5
4
|
* Note that 'prime256v1' is synonymous with 'secp256r1'.
|
|
@@ -58,19 +57,16 @@ export function signWithPrivateKey(nonce, privateKey) {
|
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
59
|
* Delete a list of public keys for a user.
|
|
61
|
-
* @param
|
|
62
|
-
* @param
|
|
63
|
-
* @param credentials The credentials to use for authentication.
|
|
60
|
+
* @param dheClient An authenticated DHE client to use for the request.
|
|
61
|
+
* @param userName The user name to delete the keys for.
|
|
64
62
|
* @param publicKeys The list of public keys to delete.
|
|
65
63
|
* @param type The algorithm type used to generate the key.
|
|
66
64
|
* @returns A promise that resolves when the keys have been deleted.
|
|
67
65
|
*/
|
|
68
|
-
export async function deletePublicKeys({
|
|
69
|
-
const dheClient = await createClient(dhe, serverUrl);
|
|
70
|
-
await dheClient.login(credentials);
|
|
66
|
+
export async function deletePublicKeys({ dheClient, userName, publicKeys, type, }) {
|
|
71
67
|
const { dbAclWriterHost, dbAclWriterPort } = await dheClient.getServerConfigValues();
|
|
72
68
|
const encodedAlgorithm = encodeURIComponent(type.toUpperCase());
|
|
73
|
-
const encodedUserName = encodeURIComponent(
|
|
69
|
+
const encodedUserName = encodeURIComponent(userName);
|
|
74
70
|
const authToken = await dheClient.createAuthToken('DbAclWriteServer');
|
|
75
71
|
const apiUrl = `https://${dbAclWriterHost}:${dbAclWriterPort}/acl/publickey/${encodedUserName}`;
|
|
76
72
|
const deletePromises = publicKeys.map(publicKey => {
|
|
@@ -89,20 +85,17 @@ export async function deletePublicKeys({ dhe, serverUrl, credentials, publicKeys
|
|
|
89
85
|
}
|
|
90
86
|
/**
|
|
91
87
|
* Upload a public key to a DHE server.
|
|
92
|
-
* @param
|
|
93
|
-
* @param
|
|
94
|
-
* @param credentials The credentials to use for authentication.
|
|
88
|
+
* @param dheClient An authenticated DHE client to use for the request.
|
|
89
|
+
* @param userName The user name to associate with the key.
|
|
95
90
|
* @param publicKey The base64 encoded public key.
|
|
96
91
|
* @param comment A comment to associate with the key.
|
|
97
92
|
* @param type The type of key pair.
|
|
98
93
|
* @returns The response from the server.
|
|
99
94
|
*/
|
|
100
|
-
export async function uploadPublicKey({
|
|
101
|
-
const dheClient = await createClient(dhe, serverUrl);
|
|
102
|
-
await dheClient.login(credentials);
|
|
95
|
+
export async function uploadPublicKey({ dheClient, userName, publicKey, comment, type, }) {
|
|
103
96
|
const { dbAclWriterHost, dbAclWriterPort } = await dheClient.getServerConfigValues();
|
|
104
97
|
const body = {
|
|
105
|
-
user:
|
|
98
|
+
user: userName,
|
|
106
99
|
encodedStr: keyWithSentinel(type, publicKey),
|
|
107
100
|
algorithm: type.toUpperCase(),
|
|
108
101
|
comment,
|
package/dist/loginUtils.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
// Have to use full path with extension in order to get type safety.
|
|
2
|
-
// deephaven/web-client-ui/issues/2273 to address the underlying issue.
|
|
3
|
-
import Log from '@deephaven/log/dist/Log.js';
|
|
4
1
|
import { keyWithSentinel, signWithPrivateKey } from './keyPairUtils.js';
|
|
5
|
-
const logger = Log.module('@deephaven-enterprise/auth-nodejs:loginUtils');
|
|
6
2
|
/**
|
|
7
3
|
* Authenticate a given client with username and password. Return the
|
|
8
4
|
* authenticated client.
|
|
@@ -11,14 +7,7 @@ const logger = Log.module('@deephaven-enterprise/auth-nodejs:loginUtils');
|
|
|
11
7
|
* @returns The authenticated client.
|
|
12
8
|
*/
|
|
13
9
|
export async function loginClientWithPassword(dheClient, credentials) {
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
await dheClient.login(credentials);
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
logger.error('An error occurred when signing in with username / password', err);
|
|
20
|
-
throw err;
|
|
21
|
-
}
|
|
10
|
+
await dheClient.login(credentials);
|
|
22
11
|
return dheClient;
|
|
23
12
|
}
|
|
24
13
|
/**
|
|
@@ -28,17 +17,10 @@ export async function loginClientWithPassword(dheClient, credentials) {
|
|
|
28
17
|
* @returns The authenticated client.
|
|
29
18
|
*/
|
|
30
19
|
export async function loginClientWithKeyPair(dheClient, credentials) {
|
|
31
|
-
logger.debug('Login with private key:', credentials.username);
|
|
32
20
|
const { username, keyPair, operateAs = username } = credentials;
|
|
33
21
|
const { type, publicKey, privateKey } = keyPair;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
await dheClient.challengeResponse(signedNonce, keyWithSentinel(type, publicKey), username, operateAs);
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
logger.error('An error occurred when signing in with public / private key', err);
|
|
41
|
-
throw err;
|
|
42
|
-
}
|
|
22
|
+
const { nonce } = await dheClient.getChallengeNonce();
|
|
23
|
+
const signedNonce = signWithPrivateKey(nonce, privateKey);
|
|
24
|
+
await dheClient.challengeResponse(signedNonce, keyWithSentinel(type, publicKey), username, operateAs);
|
|
43
25
|
return dheClient;
|
|
44
26
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven-enterprise/auth-nodejs",
|
|
3
|
-
"version": "1.20240723.
|
|
3
|
+
"version": "1.20240723.110-beta",
|
|
4
4
|
"description": "Deephaven Enterprise Auth Utils for NodeJS",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/deephaven-ent/iris.git",
|
|
11
|
+
"directory": "web/client-ui/packages/auth-nodejs"
|
|
12
|
+
},
|
|
8
13
|
"private": false,
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"main": "dist/index.js",
|
|
@@ -17,11 +22,11 @@
|
|
|
17
22
|
"build": "tsc --build"
|
|
18
23
|
},
|
|
19
24
|
"dependencies": {
|
|
20
|
-
"@deephaven/
|
|
21
|
-
"@deephaven/utils": "^0.97.0"
|
|
22
|
-
"@deephaven-enterprise/jsapi-types": "file:../jsapi-types"
|
|
25
|
+
"@deephaven-enterprise/jsapi-types": "^1.20240723.110-beta",
|
|
26
|
+
"@deephaven/utils": "^0.97.0"
|
|
23
27
|
},
|
|
24
28
|
"publishConfig": {
|
|
25
29
|
"access": "public"
|
|
26
|
-
}
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "860c04760627d9da25263781b9b1ba3f02fc2c78"
|
|
27
32
|
}
|