win-sso 2.0.0-beta.2 → 2.0.0-beta.3

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.
@@ -0,0 +1,3 @@
1
+ import { WinSso } from "./win-sso.ts";
2
+ import { osSupported } from "./os-supported.ts";
3
+ export { WinSso, osSupported };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns true if the current platform is supported by the win-sso module. Only Windows OSs are supported.
3
+ * If false, all other methods in the module will throw.
4
+ * @returns {boolean} Is the os supported
5
+ */
6
+ export declare function osSupported(): boolean;
@@ -0,0 +1,2 @@
1
+ import debugInit from 'debug';
2
+ export declare const debug: debugInit.Debugger;
@@ -0,0 +1,8 @@
1
+ interface IWinSsoAddon {
2
+ createAuthContext(securityPackage: string, targetHost: string | undefined, applicationData: Buffer, flags: number | undefined): number;
3
+ freeAuthContext(authContextId: number): void;
4
+ getLogonUserName(): string;
5
+ createAuthRequest(authContextId: number): Buffer;
6
+ createAuthResponse(authContextId: number, inToken: Buffer): Buffer;
7
+ }
8
+ export type { IWinSsoAddon };
@@ -0,0 +1,64 @@
1
+ import type { PeerCertificate } from "node:tls";
2
+ /**
3
+ * Creates authentication tokens for NTLM or Negotiate handshake using the executing users credentials.
4
+ */
5
+ export declare class WinSso {
6
+ private static NEGOTIATE_NTLM2_KEY;
7
+ private authContextId;
8
+ private securityPackage;
9
+ /**
10
+ * Creates an authentication context for SSO.
11
+ * This allocates memory buffers, the freeAuthContext method should be called
12
+ * to free them (on error or after authentication is no longer needed)
13
+ * @param {string} securityPackage The name of the security package (NTLM or Negotiate)
14
+ * @param {string|undefined} targetHost The FQDN hostname of the target (optional for NTLM, required for Kerberos)
15
+ * @param {PeerCertificate|undefined} peerCert The certificate of the target server
16
+ * (optional, for HTTPS channel binding)
17
+ * @param {number|undefined} flags Flags to set in the authentication context
18
+ * If not set, NTML defaults to no flags, while Negotiate defaults to ISC_REQ_MUTUAL_AUTH | ISC_REQ_SEQUENCE_DETECT
19
+ * (optional, allows customizing security features)
20
+ */
21
+ constructor(securityPackage: string, targetHost: string | undefined, peerCert: PeerCertificate | undefined, flags: number | undefined);
22
+ /**
23
+ * Retrieves the username of the logged in user
24
+ * @returns {string} user name including domain
25
+ */
26
+ static getLogonUserName(): string;
27
+ /**
28
+ * Transforms target TLS certificate into a channel binding application data buffer
29
+ * @param {PeerCertificate} peerCert Target TLS certificate
30
+ * @returns {Buffer} Application data buffer
31
+ */
32
+ private getChannelBindingsApplicationData;
33
+ /**
34
+ * Releases all allocated resources for the authorization context.
35
+ * Should be called when the context is no longer required, such as when the
36
+ * socket was closed.
37
+ */
38
+ freeAuthContext(): void;
39
+ /**
40
+ * Creates an authentication request token
41
+ * @returns {Buffer} Raw token buffer
42
+ */
43
+ createAuthRequest(): Buffer;
44
+ /**
45
+ * Creates an authentication request header
46
+ * @returns {string} The www-authenticate header
47
+ */
48
+ createAuthRequestHeader(): string;
49
+ /**
50
+ * Creates an authentication response token
51
+ * @param {string} inTokenHeader The www-authentication header received from the target
52
+ * in response to the authentication request
53
+ * @returns {Buffer} Raw token buffer. May be empty if Negotiate handshake is complete.
54
+ */
55
+ createAuthResponse(inTokenHeader: string): Buffer;
56
+ private isNtlmV1;
57
+ /**
58
+ * Creates an authentication response header
59
+ * @param {string} inTokenHeader The www-authentication header received from the target
60
+ * in response to the authentication request
61
+ * @returns {string} The www-authenticate header. May be an empty string if Negotiate handshake is complete.
62
+ */
63
+ createAuthResponseHeader(inTokenHeader: string): string;
64
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "win-sso",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "NTLM single-sign-on for Node.js. Only Windows OS supported.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {