@equinor/fusion-framework-module-msal-node 1.0.7 → 1.1.0-next.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 +43 -0
- package/dist/esm/AuthProvider.js +2 -2
- package/dist/esm/AuthProvider.js.map +1 -1
- package/dist/esm/AuthProviderInteractive.js +3 -3
- package/dist/esm/AuthProviderInteractive.js.map +1 -1
- package/dist/esm/AuthTokenProvider.js +3 -2
- package/dist/esm/AuthTokenProvider.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AuthProvider.d.ts +10 -4
- package/dist/types/AuthProvider.interface.d.ts +7 -3
- package/dist/types/AuthProviderInteractive.d.ts +6 -2
- package/dist/types/AuthTokenProvider.d.ts +11 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/AuthProvider.interface.ts +6 -3
- package/src/AuthProvider.ts +7 -5
- package/src/AuthProviderInteractive.ts +7 -5
- package/src/AuthTokenProvider.ts +3 -2
- package/src/version.ts +1 -1
|
@@ -29,12 +29,14 @@ export declare class AuthProvider implements IAuthProvider {
|
|
|
29
29
|
* Acquires an access token for the specified scopes.
|
|
30
30
|
*
|
|
31
31
|
* @param options - An object containing the options for acquiring the token.
|
|
32
|
-
* @param options.scopes - An array of strings representing the scopes for which the access token is requested.
|
|
32
|
+
* @param options.request.scopes - An array of strings representing the scopes for which the access token is requested.
|
|
33
33
|
* @returns A promise that resolves to the acquired access token as a string.
|
|
34
34
|
* @throws An error if the token acquisition process fails.
|
|
35
35
|
*/
|
|
36
36
|
acquireAccessToken(options: {
|
|
37
|
-
|
|
37
|
+
request: {
|
|
38
|
+
scopes: string[];
|
|
39
|
+
};
|
|
38
40
|
}): Promise<string>;
|
|
39
41
|
/**
|
|
40
42
|
* Initiates the login process with the specified options.
|
|
@@ -47,7 +49,9 @@ export declare class AuthProvider implements IAuthProvider {
|
|
|
47
49
|
* This method is not supported and is intended to be overridden by `AuthProviderInteractive`.
|
|
48
50
|
*/
|
|
49
51
|
login(_options: {
|
|
50
|
-
|
|
52
|
+
request: {
|
|
53
|
+
scopes: string[];
|
|
54
|
+
};
|
|
51
55
|
}): Promise<AuthenticationResult>;
|
|
52
56
|
/**
|
|
53
57
|
* Logs out the user by clearing the token cache and removing all accounts.
|
|
@@ -76,6 +80,8 @@ export declare class AuthProvider implements IAuthProvider {
|
|
|
76
80
|
* @throws {@link SilentTokenAcquisitionError} If an error occurs during silent token acquisition.
|
|
77
81
|
*/
|
|
78
82
|
acquireToken(options: {
|
|
79
|
-
|
|
83
|
+
request: {
|
|
84
|
+
scopes: string[];
|
|
85
|
+
};
|
|
80
86
|
}): Promise<AuthenticationResult>;
|
|
81
87
|
}
|
|
@@ -26,7 +26,9 @@ export interface IAuthProvider {
|
|
|
26
26
|
* This method is not supported and should not be used to initiate login unless interactive mode is enabled.
|
|
27
27
|
*/
|
|
28
28
|
login(options: {
|
|
29
|
-
|
|
29
|
+
request: {
|
|
30
|
+
scopes: string[];
|
|
31
|
+
};
|
|
30
32
|
}): Promise<AuthenticationResult>;
|
|
31
33
|
/**
|
|
32
34
|
* This method is present for compatibility but will never trigger a user logout flow unless interactive mode is configured.
|
|
@@ -41,7 +43,7 @@ export interface IAuthProvider {
|
|
|
41
43
|
* Acquires an access token for the specified scopes.
|
|
42
44
|
*
|
|
43
45
|
* @param options - An object specifying the required scopes and an optional `interactive` flag.
|
|
44
|
-
* - `scopes`: The scopes for which the token is requested.
|
|
46
|
+
* - `request.scopes`: The scopes for which the token is requested.
|
|
45
47
|
* - `interactive`: If true, may trigger an interactive login if silent acquisition fails (not supported unless interactive mode is enabled).
|
|
46
48
|
* @returns A Promise that resolves to a string representing the acquired access token.
|
|
47
49
|
*
|
|
@@ -49,7 +51,9 @@ export interface IAuthProvider {
|
|
|
49
51
|
* This is the primary method for obtaining tokens for API calls or resource access.
|
|
50
52
|
*/
|
|
51
53
|
acquireAccessToken(options: {
|
|
52
|
-
|
|
54
|
+
request: {
|
|
55
|
+
scopes: string[];
|
|
56
|
+
};
|
|
53
57
|
interactive?: boolean;
|
|
54
58
|
}): Promise<string>;
|
|
55
59
|
}
|
|
@@ -48,7 +48,9 @@ export declare class AuthProviderInteractive extends AuthProvider {
|
|
|
48
48
|
* authentication server setup fails.
|
|
49
49
|
*/
|
|
50
50
|
login(options: {
|
|
51
|
-
|
|
51
|
+
request: {
|
|
52
|
+
scopes: string[];
|
|
53
|
+
};
|
|
52
54
|
}): Promise<AuthenticationResult>;
|
|
53
55
|
/**
|
|
54
56
|
* Acquires an authentication token for the specified scopes.
|
|
@@ -67,7 +69,9 @@ export declare class AuthProviderInteractive extends AuthProvider {
|
|
|
67
69
|
* @throws {@link SilentTokenAcquisitionError} If an error occurs during silent token acquisition.
|
|
68
70
|
*/
|
|
69
71
|
acquireToken(options: {
|
|
70
|
-
|
|
72
|
+
request: {
|
|
73
|
+
scopes: string[];
|
|
74
|
+
};
|
|
71
75
|
}): Promise<AuthenticationResult>;
|
|
72
76
|
}
|
|
73
77
|
export {};
|
|
@@ -22,7 +22,11 @@ export declare class AuthTokenProvider implements IAuthProvider {
|
|
|
22
22
|
*
|
|
23
23
|
* @throws Error Always throws to indicate login is not supported.
|
|
24
24
|
*/
|
|
25
|
-
login(
|
|
25
|
+
login(_options: {
|
|
26
|
+
request: {
|
|
27
|
+
scopes: string[];
|
|
28
|
+
};
|
|
29
|
+
}): Promise<AuthenticationResult>;
|
|
26
30
|
/**
|
|
27
31
|
* Not supported in token-only mode. Always throws an error if called.
|
|
28
32
|
*
|
|
@@ -36,8 +40,13 @@ export declare class AuthTokenProvider implements IAuthProvider {
|
|
|
36
40
|
*
|
|
37
41
|
* This is the only supported operation for this provider. No token refresh or acquisition logic is performed.
|
|
38
42
|
*
|
|
43
|
+
* @param _options - Options parameter (ignored in token-only mode)
|
|
39
44
|
* @returns The static access token as a string.
|
|
40
45
|
*/
|
|
41
|
-
acquireAccessToken(
|
|
46
|
+
acquireAccessToken(_options: {
|
|
47
|
+
request: {
|
|
48
|
+
scopes: string[];
|
|
49
|
+
};
|
|
50
|
+
}): Promise<string>;
|
|
42
51
|
}
|
|
43
52
|
export default AuthTokenProvider;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.
|
|
1
|
+
export declare const version = "1.1.0-next.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-module-msal-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-next.0",
|
|
4
4
|
"description": "Fusion Framework module for secure Azure AD authentication in Node.js using MSAL. Supports interactive, silent, and token-only authentication modes with encrypted token storage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@azure/msal-node": "^3.7.3",
|
|
37
37
|
"@azure/msal-node-extensions": "^1.5.11",
|
|
38
38
|
"open": "^10.1.1",
|
|
39
|
-
"@equinor/fusion-framework-module": "^5.0.
|
|
39
|
+
"@equinor/fusion-framework-module": "^5.0.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"typescript": "^5.8.2"
|
|
@@ -26,7 +26,7 @@ export interface IAuthProvider {
|
|
|
26
26
|
* @remarks
|
|
27
27
|
* This method is not supported and should not be used to initiate login unless interactive mode is enabled.
|
|
28
28
|
*/
|
|
29
|
-
login(options: { scopes: string[] }): Promise<AuthenticationResult>;
|
|
29
|
+
login(options: { request: { scopes: string[] } }): Promise<AuthenticationResult>;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* This method is present for compatibility but will never trigger a user logout flow unless interactive mode is configured.
|
|
@@ -42,12 +42,15 @@ export interface IAuthProvider {
|
|
|
42
42
|
* Acquires an access token for the specified scopes.
|
|
43
43
|
*
|
|
44
44
|
* @param options - An object specifying the required scopes and an optional `interactive` flag.
|
|
45
|
-
* - `scopes`: The scopes for which the token is requested.
|
|
45
|
+
* - `request.scopes`: The scopes for which the token is requested.
|
|
46
46
|
* - `interactive`: If true, may trigger an interactive login if silent acquisition fails (not supported unless interactive mode is enabled).
|
|
47
47
|
* @returns A Promise that resolves to a string representing the acquired access token.
|
|
48
48
|
*
|
|
49
49
|
* @remarks
|
|
50
50
|
* This is the primary method for obtaining tokens for API calls or resource access.
|
|
51
51
|
*/
|
|
52
|
-
acquireAccessToken(options: {
|
|
52
|
+
acquireAccessToken(options: {
|
|
53
|
+
request: { scopes: string[] };
|
|
54
|
+
interactive?: boolean;
|
|
55
|
+
}): Promise<string>;
|
|
53
56
|
}
|
package/src/AuthProvider.ts
CHANGED
|
@@ -37,11 +37,11 @@ export class AuthProvider implements IAuthProvider {
|
|
|
37
37
|
* Acquires an access token for the specified scopes.
|
|
38
38
|
*
|
|
39
39
|
* @param options - An object containing the options for acquiring the token.
|
|
40
|
-
* @param options.scopes - An array of strings representing the scopes for which the access token is requested.
|
|
40
|
+
* @param options.request.scopes - An array of strings representing the scopes for which the access token is requested.
|
|
41
41
|
* @returns A promise that resolves to the acquired access token as a string.
|
|
42
42
|
* @throws An error if the token acquisition process fails.
|
|
43
43
|
*/
|
|
44
|
-
public async acquireAccessToken(options: { scopes: string[] }): Promise<string> {
|
|
44
|
+
public async acquireAccessToken(options: { request: { scopes: string[] } }): Promise<string> {
|
|
45
45
|
const { accessToken } = await this.acquireToken(options);
|
|
46
46
|
return accessToken;
|
|
47
47
|
}
|
|
@@ -56,7 +56,7 @@ export class AuthProvider implements IAuthProvider {
|
|
|
56
56
|
* @remarks
|
|
57
57
|
* This method is not supported and is intended to be overridden by `AuthProviderInteractive`.
|
|
58
58
|
*/
|
|
59
|
-
public async login(_options: { scopes: string[] }): Promise<AuthenticationResult> {
|
|
59
|
+
public async login(_options: { request: { scopes: string[] } }): Promise<AuthenticationResult> {
|
|
60
60
|
throw new AuthServerError('Login not supported, use AuthProviderInteractive instead');
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -94,7 +94,9 @@ export class AuthProvider implements IAuthProvider {
|
|
|
94
94
|
* @throws {@link NoAccountsError} If no accounts are found in the cache and interactive login is not allowed.
|
|
95
95
|
* @throws {@link SilentTokenAcquisitionError} If an error occurs during silent token acquisition.
|
|
96
96
|
*/
|
|
97
|
-
public async acquireToken(options: {
|
|
97
|
+
public async acquireToken(options: {
|
|
98
|
+
request: { scopes: string[] };
|
|
99
|
+
}): Promise<AuthenticationResult> {
|
|
98
100
|
const account = await this.getAccount();
|
|
99
101
|
if (!account) {
|
|
100
102
|
throw new NoAccountsError('No accounts found in cache');
|
|
@@ -102,7 +104,7 @@ export class AuthProvider implements IAuthProvider {
|
|
|
102
104
|
|
|
103
105
|
try {
|
|
104
106
|
const tokenResponse = await this._client.acquireTokenSilent({
|
|
105
|
-
scopes: options.scopes,
|
|
107
|
+
scopes: options.request.scopes,
|
|
106
108
|
account,
|
|
107
109
|
});
|
|
108
110
|
return tokenResponse;
|
|
@@ -61,8 +61,8 @@ export class AuthProviderInteractive extends AuthProvider {
|
|
|
61
61
|
* @throws Will throw an error if the PKCE code generation, browser opening, or
|
|
62
62
|
* authentication server setup fails.
|
|
63
63
|
*/
|
|
64
|
-
public async login(options: { scopes: string[] }): Promise<AuthenticationResult> {
|
|
65
|
-
const { scopes } = options;
|
|
64
|
+
public async login(options: { request: { scopes: string[] } }): Promise<AuthenticationResult> {
|
|
65
|
+
const { scopes } = options.request;
|
|
66
66
|
const { port, onOpen } = this.#options.server;
|
|
67
67
|
|
|
68
68
|
// Generate a new PKCE code verifier and challenge
|
|
@@ -105,10 +105,12 @@ export class AuthProviderInteractive extends AuthProvider {
|
|
|
105
105
|
* @throws {@link NoAccountsError} If no accounts are found in the cache and interactive login is not allowed.
|
|
106
106
|
* @throws {@link SilentTokenAcquisitionError} If an error occurs during silent token acquisition.
|
|
107
107
|
*/
|
|
108
|
-
public async acquireToken(options: {
|
|
109
|
-
|
|
108
|
+
public async acquireToken(options: {
|
|
109
|
+
request: { scopes: string[] };
|
|
110
|
+
}): Promise<AuthenticationResult> {
|
|
111
|
+
const { scopes } = options.request ?? { scopes: [] };
|
|
110
112
|
if ((await this.getAccount()) === null) {
|
|
111
|
-
return this.login({ scopes });
|
|
113
|
+
return this.login({ request: { scopes } });
|
|
112
114
|
}
|
|
113
115
|
return super.acquireToken(options);
|
|
114
116
|
}
|
package/src/AuthTokenProvider.ts
CHANGED
|
@@ -26,7 +26,7 @@ export class AuthTokenProvider implements IAuthProvider {
|
|
|
26
26
|
*
|
|
27
27
|
* @throws Error Always throws to indicate login is not supported.
|
|
28
28
|
*/
|
|
29
|
-
login(): Promise<AuthenticationResult> {
|
|
29
|
+
login(_options: { request: { scopes: string[] } }): Promise<AuthenticationResult> {
|
|
30
30
|
throw new Error('Method not supported in token mode');
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -46,9 +46,10 @@ export class AuthTokenProvider implements IAuthProvider {
|
|
|
46
46
|
*
|
|
47
47
|
* This is the only supported operation for this provider. No token refresh or acquisition logic is performed.
|
|
48
48
|
*
|
|
49
|
+
* @param _options - Options parameter (ignored in token-only mode)
|
|
49
50
|
* @returns The static access token as a string.
|
|
50
51
|
*/
|
|
51
|
-
async acquireAccessToken(): Promise<string> {
|
|
52
|
+
async acquireAccessToken(_options: { request: { scopes: string[] } }): Promise<string> {
|
|
52
53
|
return this.#accessToken;
|
|
53
54
|
}
|
|
54
55
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '1.0.
|
|
2
|
+
export const version = '1.1.0-next.0';
|