@deephaven-enterprise/auth-nodejs 2026.1.41 → 2026.1.43
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 +56 -1
- package/dist/index.d.ts +19 -4
- package/dist/index.js +9 -4
- package/dist/keyPairUtils.d.ts +4 -3
- package/dist/loginUtils.d.ts +19 -3
- package/dist/loginUtils.js +30 -1
- package/dist/types.d.ts +1 -4
- package/package.json +3 -2
- package/dist/clientUtils.d.ts +0 -11
- package/dist/clientUtils.js +0 -17
package/README.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
1
|
# @deephaven-enterprise/auth-nodejs
|
|
2
2
|
|
|
3
|
-
Deephaven Enterprise
|
|
3
|
+
Deephaven Enterprise authentication utilities for Node.js.
|
|
4
|
+
|
|
5
|
+
Helpers for authenticating against a Deephaven Enterprise server from a Node.js
|
|
6
|
+
process, including key pair signing and login utilities.
|
|
7
|
+
|
|
8
|
+
This is a low-level building block. For most applications, use
|
|
9
|
+
[`@deephaven-enterprise/jsapi-nodejs`](../jsapi-nodejs), which wires
|
|
10
|
+
authentication together with the JS API and worker connections for you.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
`login` takes a connected (but not yet authenticated) Enterprise client — see
|
|
15
|
+
[`@deephaven-enterprise/client-utils`](../client-utils) for creating one — and
|
|
16
|
+
returns it authenticated:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import {
|
|
20
|
+
createPasswordCredentials,
|
|
21
|
+
login,
|
|
22
|
+
} from '@deephaven-enterprise/auth-nodejs';
|
|
23
|
+
|
|
24
|
+
// `unauthenticatedClient` comes from `createEnterpriseClient` (client-utils).
|
|
25
|
+
const credentials = createPasswordCredentials('my-username', 'my-password');
|
|
26
|
+
const authenticatedClient = await login(unauthenticatedClient, credentials);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Key-pair authentication is also supported. Generate a key pair, upload the
|
|
30
|
+
public key for a user, then log in with the private key:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import {
|
|
34
|
+
generateBase64KeyPair,
|
|
35
|
+
login,
|
|
36
|
+
uploadPublicKey,
|
|
37
|
+
type Username,
|
|
38
|
+
} from '@deephaven-enterprise/auth-nodejs';
|
|
39
|
+
|
|
40
|
+
const userName = 'my-username' as Username;
|
|
41
|
+
const keyPair = generateBase64KeyPair();
|
|
42
|
+
|
|
43
|
+
// Upload the public key using an already-authenticated client.
|
|
44
|
+
await uploadPublicKey({
|
|
45
|
+
dheClient: authenticatedClient,
|
|
46
|
+
userName,
|
|
47
|
+
publicKey: keyPair.publicKey,
|
|
48
|
+
comment: 'my-service key',
|
|
49
|
+
type: keyPair.type,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Later, authenticate a fresh client with the key pair.
|
|
53
|
+
const client = await login(unauthenticatedClient, {
|
|
54
|
+
type: 'keyPair',
|
|
55
|
+
username: userName,
|
|
56
|
+
keyPair,
|
|
57
|
+
});
|
|
58
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type AuthenticatedEnterpriseClient, type UnauthenticatedEnterpriseClient, createEnterpriseClient } from '@deephaven-enterprise/client-utils';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `AuthenticatedEnterpriseClient` from
|
|
4
|
+
* `@deephaven-enterprise/client-utils` instead.
|
|
5
|
+
*/
|
|
6
|
+
export type AuthenticatedClient = AuthenticatedEnterpriseClient;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `UnauthenticatedEnterpriseClient` from
|
|
9
|
+
* `@deephaven-enterprise/client-utils` instead.
|
|
10
|
+
*/
|
|
11
|
+
export type UnauthenticatedClient = UnauthenticatedEnterpriseClient;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `createEnterpriseClient` from `@deephaven-enterprise/client-utils`
|
|
14
|
+
* instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare const createClient: typeof createEnterpriseClient;
|
|
17
|
+
export * from './keyPairUtils.ts';
|
|
18
|
+
export * from './types.ts';
|
|
19
|
+
export * from './loginUtils.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createEnterpriseClient, } from '@deephaven-enterprise/client-utils';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `createEnterpriseClient` from `@deephaven-enterprise/client-utils`
|
|
4
|
+
* instead.
|
|
5
|
+
*/
|
|
6
|
+
export const createClient = createEnterpriseClient;
|
|
7
|
+
export * from "./keyPairUtils.js";
|
|
8
|
+
export * from "./types.js";
|
|
9
|
+
export * from "./loginUtils.js";
|
package/dist/keyPairUtils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthenticatedEnterpriseClient } from '@deephaven-enterprise/client-utils';
|
|
2
|
+
import type { Base64KeyPair, Base64Nonce, Base64PrivateKey, Base64PublicKey, Base64Signature, KeyPairType, Username } from './types.ts';
|
|
2
3
|
/**
|
|
3
4
|
* Generate a base64 encoded asymmetric key pair using eliptic curve.
|
|
4
5
|
* @returns The base64 encoded public and private keys.
|
|
@@ -30,7 +31,7 @@ export declare function signWithPrivateKey(nonce: Base64Nonce, privateKey: Base6
|
|
|
30
31
|
* @returns A promise that resolves when the keys have been deleted.
|
|
31
32
|
*/
|
|
32
33
|
export declare function deletePublicKeys({ dheClient, userName, publicKeys, type, }: {
|
|
33
|
-
dheClient:
|
|
34
|
+
dheClient: AuthenticatedEnterpriseClient;
|
|
34
35
|
userName: Username;
|
|
35
36
|
publicKeys: Base64PublicKey[];
|
|
36
37
|
type: KeyPairType;
|
|
@@ -45,7 +46,7 @@ export declare function deletePublicKeys({ dheClient, userName, publicKeys, type
|
|
|
45
46
|
* @returns The response from the server.
|
|
46
47
|
*/
|
|
47
48
|
export declare function uploadPublicKey({ dheClient, userName, publicKey, comment, type, }: {
|
|
48
|
-
dheClient:
|
|
49
|
+
dheClient: AuthenticatedEnterpriseClient;
|
|
49
50
|
userName: Username;
|
|
50
51
|
comment: string;
|
|
51
52
|
publicKey: Base64PublicKey;
|
package/dist/loginUtils.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthenticatedEnterpriseClient, UnauthenticatedEnterpriseClient } from '@deephaven-enterprise/client-utils';
|
|
2
|
+
import type { PasswordCredentials, KeyPairCredentials } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Create a PasswordCredentials object from a username and password.
|
|
5
|
+
* @param username The username for the credentials.
|
|
6
|
+
* @param password The password for the credentials.
|
|
7
|
+
* @returns A PasswordCredentials object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createPasswordCredentials(username: string, password: string): PasswordCredentials;
|
|
10
|
+
/**
|
|
11
|
+
* Authenticate a given client with the provided credentials. Return the
|
|
12
|
+
* authenticated client.
|
|
13
|
+
* @param dheClient The DHE client to authenticate.
|
|
14
|
+
* @param credentials The credentials to use for authentication.
|
|
15
|
+
* @returns The authenticated client.
|
|
16
|
+
*/
|
|
17
|
+
export declare function login(dheClient: UnauthenticatedEnterpriseClient, credentials: PasswordCredentials | KeyPairCredentials): Promise<AuthenticatedEnterpriseClient>;
|
|
2
18
|
/**
|
|
3
19
|
* Authenticate a given client with username and password. Return the
|
|
4
20
|
* authenticated client.
|
|
@@ -6,11 +22,11 @@ import type { AuthenticatedClient, PasswordCredentials, KeyPairCredentials, Unau
|
|
|
6
22
|
* @param credentials The user / password credentials to use for authentication.
|
|
7
23
|
* @returns The authenticated client.
|
|
8
24
|
*/
|
|
9
|
-
export declare function loginClientWithPassword(dheClient:
|
|
25
|
+
export declare function loginClientWithPassword(dheClient: UnauthenticatedEnterpriseClient, credentials: PasswordCredentials): Promise<AuthenticatedEnterpriseClient>;
|
|
10
26
|
/**
|
|
11
27
|
* Authenticate a given client with a key pair. Return the authenticated client.
|
|
12
28
|
* @param dheClient The DHE client to authenticate.
|
|
13
29
|
* @param credentials The key pair credentials to use for authentication.
|
|
14
30
|
* @returns The authenticated client.
|
|
15
31
|
*/
|
|
16
|
-
export declare function loginClientWithKeyPair(dheClient:
|
|
32
|
+
export declare function loginClientWithKeyPair(dheClient: UnauthenticatedEnterpriseClient, credentials: KeyPairCredentials): Promise<AuthenticatedEnterpriseClient>;
|
package/dist/loginUtils.js
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
|
-
import { keyWithSentinel, signWithPrivateKey } from
|
|
1
|
+
import { keyWithSentinel, signWithPrivateKey } from "./keyPairUtils.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a PasswordCredentials object from a username and password.
|
|
4
|
+
* @param username The username for the credentials.
|
|
5
|
+
* @param password The password for the credentials.
|
|
6
|
+
* @returns A PasswordCredentials object.
|
|
7
|
+
*/
|
|
8
|
+
export function createPasswordCredentials(username, password) {
|
|
9
|
+
return {
|
|
10
|
+
type: 'password',
|
|
11
|
+
username: username,
|
|
12
|
+
token: password,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Authenticate a given client with the provided credentials. Return the
|
|
17
|
+
* authenticated client.
|
|
18
|
+
* @param dheClient The DHE client to authenticate.
|
|
19
|
+
* @param credentials The credentials to use for authentication.
|
|
20
|
+
* @returns The authenticated client.
|
|
21
|
+
*/
|
|
22
|
+
export async function login(dheClient, credentials) {
|
|
23
|
+
if (credentials.type === 'keyPair') {
|
|
24
|
+
return loginClientWithKeyPair(dheClient, credentials);
|
|
25
|
+
}
|
|
26
|
+
if (credentials.type === 'password') {
|
|
27
|
+
return loginClientWithPassword(dheClient, credentials);
|
|
28
|
+
}
|
|
29
|
+
throw new Error('Unsupported credentials type');
|
|
30
|
+
}
|
|
2
31
|
/**
|
|
3
32
|
* Authenticate a given client with username and password. Return the
|
|
4
33
|
* authenticated client.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { Brand } from '@deephaven/utils/dist/TypeUtils.
|
|
2
|
-
import type { EnterpriseClient } from '@deephaven-enterprise/jsapi-types';
|
|
3
|
-
export type AuthenticatedClient = Brand<'AuthenticatedClient', EnterpriseClient>;
|
|
4
|
-
export type UnauthenticatedClient = Brand<'UnauthenticatedClient', EnterpriseClient>;
|
|
1
|
+
import type { Brand } from '@deephaven/utils/dist/TypeUtils.d.ts';
|
|
5
2
|
export type Base64Nonce = Brand<'Base64Nonce', string>;
|
|
6
3
|
export type Base64Signature = Brand<'Base64Signature', string>;
|
|
7
4
|
export type Base64PrivateKey = Brand<'Base64PrivateKey', string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven-enterprise/auth-nodejs",
|
|
3
|
-
"version": "2026.1.
|
|
3
|
+
"version": "2026.1.43",
|
|
4
4
|
"description": "Deephaven Enterprise Auth Utils for NodeJS",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"build": "tsc --build"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@deephaven-enterprise/
|
|
25
|
+
"@deephaven-enterprise/client-utils": "2026.1.43",
|
|
26
|
+
"@deephaven-enterprise/jsapi-types": "2026.1.43",
|
|
26
27
|
"@deephaven/utils": "^0.97.0"
|
|
27
28
|
},
|
|
28
29
|
"publishConfig": {
|
package/dist/clientUtils.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ConnectOptions, EnterpriseDhType as DheType } from '@deephaven-enterprise/jsapi-types';
|
|
2
|
-
import type { UnauthenticatedClient } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Create a connected, unauthenticated DHE client.
|
|
5
|
-
* @param dhe DHE JsApi.
|
|
6
|
-
* @param serverUrl The DHE server URL.
|
|
7
|
-
* @param connectOptions Optional connection options.
|
|
8
|
-
* @returns A connected, unauthenticated DHE client.
|
|
9
|
-
*/
|
|
10
|
-
export declare function createClient(dhe: DheType, serverUrl: URL, connectOptions?: ConnectOptions): Promise<UnauthenticatedClient>;
|
|
11
|
-
export default createClient;
|
package/dist/clientUtils.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a connected, unauthenticated DHE client.
|
|
3
|
-
* @param dhe DHE JsApi.
|
|
4
|
-
* @param serverUrl The DHE server URL.
|
|
5
|
-
* @param connectOptions Optional connection options.
|
|
6
|
-
* @returns A connected, unauthenticated DHE client.
|
|
7
|
-
*/
|
|
8
|
-
export async function createClient(dhe, serverUrl, connectOptions) {
|
|
9
|
-
const dheClient = new dhe.Client(serverUrl.toString(), connectOptions);
|
|
10
|
-
return new Promise(resolve => {
|
|
11
|
-
const unsubscribe = dheClient.addEventListener(dhe.Client.EVENT_CONNECT, () => {
|
|
12
|
-
unsubscribe();
|
|
13
|
-
resolve(dheClient);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export default createClient;
|