@equinor/fusion-framework-module-msal 11.0.0 → 11.0.1
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/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +8 -5
- package/CHANGELOG.md +0 -1212
- package/docs/api-reference.md +0 -85
- package/docs/auth-code-flow.md +0 -86
- package/docs/migration-v2-to-v4.md +0 -115
- package/docs/testing.md +0 -191
- package/docs/troubleshooting.md +0 -17
- package/docs/version-management.md +0 -67
- package/src/MsalClient.interface.ts +0 -139
- package/src/MsalClient.ts +0 -326
- package/src/MsalConfigurator.ts +0 -486
- package/src/MsalProvider.interface.ts +0 -179
- package/src/MsalProvider.ts +0 -776
- package/src/MsalProxyProvider.interface.ts +0 -72
- package/src/__tests__/MsalConfigurator.test.ts +0 -222
- package/src/__tests__/MsalProvider.test.ts +0 -74
- package/src/__tests__/create-proxy-provider.test.ts +0 -77
- package/src/__tests__/mock/create-mock-user-from-token.test.ts +0 -46
- package/src/__tests__/mock/msal-mock.test.ts +0 -613
- package/src/__tests__/versioning/resolve-version.test.ts +0 -161
- package/src/create-client-log-callback.ts +0 -102
- package/src/create-proxy-provider.ts +0 -97
- package/src/index.ts +0 -48
- package/src/mock/MsalMockClient.ts +0 -618
- package/src/mock/MsalMockConfigurator.ts +0 -305
- package/src/mock/create-mock-token.ts +0 -92
- package/src/mock/create-mock-user-from-token.ts +0 -46
- package/src/mock/create-msal-mock-client.ts +0 -25
- package/src/mock/decode-jwt-segment.ts +0 -22
- package/src/mock/index.ts +0 -30
- package/src/mock/module.ts +0 -54
- package/src/module.ts +0 -142
- package/src/msal-config-schema.ts +0 -81
- package/src/static.ts +0 -38
- package/src/telemetry-config-schema.ts +0 -25
- package/src/types.ts +0 -16
- package/src/util/compare-origin.ts +0 -18
- package/src/util/normalize-uri.ts +0 -24
- package/src/util/redirect.ts +0 -19
- package/src/v2/IAuthClient.interface.ts +0 -114
- package/src/v2/Logger.ts +0 -204
- package/src/v2/MsalProvider.interface.ts +0 -102
- package/src/v2/create-proxy-client.ts +0 -195
- package/src/v2/create-proxy-provider.ts +0 -177
- package/src/v2/map-account-info.ts +0 -23
- package/src/v2/map-authentication-result.ts +0 -28
- package/src/v2/types.ts +0 -674
- package/src/v4/create-proxy-provider.ts +0 -75
- package/src/v4/index.ts +0 -13
- package/src/v4/types.ts +0 -727
- package/src/version.ts +0 -2
- package/src/versioning/VersionError.ts +0 -64
- package/src/versioning/index.ts +0 -29
- package/src/versioning/resolve-version.ts +0 -154
- package/src/versioning/types.ts +0 -60
- package/tsconfig.json +0 -18
- package/vitest.config.ts +0 -11
package/src/version.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { SemVer } from 'semver';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Error class for version-related issues in the MSAL module.
|
|
5
|
-
*
|
|
6
|
-
* This error is thrown when there are version compatibility problems,
|
|
7
|
-
* such as requesting an incompatible major version or providing an invalid version string.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* try {
|
|
12
|
-
* resolveVersion('3.0.0'); // Assuming latest is 2.x
|
|
13
|
-
* } catch (error) {
|
|
14
|
-
* if (error instanceof VersionError) {
|
|
15
|
-
* console.error('Version error:', error.message);
|
|
16
|
-
* console.error('Requested:', error.requestedVersion);
|
|
17
|
-
* console.error('Latest:', error.latestVersion);
|
|
18
|
-
* console.error('Type:', error.type);
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* // Create a version error manually
|
|
26
|
-
* const error = VersionError.create(
|
|
27
|
-
* VersionError.Type.MajorIncompatibility,
|
|
28
|
-
* '3.0.0',
|
|
29
|
-
* '2.1.0'
|
|
30
|
-
* );
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export class VersionError extends Error {
|
|
34
|
-
/** The version that was requested by the user */
|
|
35
|
-
public readonly requestedVersion: string;
|
|
36
|
-
|
|
37
|
-
/** The latest available version in the system */
|
|
38
|
-
public readonly latestVersion: string;
|
|
39
|
-
|
|
40
|
-
/** The error name for instanceof checks */
|
|
41
|
-
static Name = 'VersionError';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Creates a new VersionError instance.
|
|
45
|
-
*
|
|
46
|
-
* @param message - The error message describing the version issue
|
|
47
|
-
* @param requestedVersion - The version that was requested (will be stored as string)
|
|
48
|
-
* @param latestVersion - The latest available version (will be stored as string)
|
|
49
|
-
* @param options - Additional error options including the error type
|
|
50
|
-
*/
|
|
51
|
-
constructor(
|
|
52
|
-
message: string,
|
|
53
|
-
requestedVersion: string | SemVer,
|
|
54
|
-
latestVersion: string | SemVer,
|
|
55
|
-
options?: ErrorOptions,
|
|
56
|
-
) {
|
|
57
|
-
super(message, options);
|
|
58
|
-
this.name = VersionError.Name;
|
|
59
|
-
|
|
60
|
-
// Store versions as strings
|
|
61
|
-
this.requestedVersion = String(requestedVersion);
|
|
62
|
-
this.latestVersion = String(latestVersion);
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/versioning/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Versioning module for MSAL module compatibility checking.
|
|
3
|
-
*
|
|
4
|
-
* This module provides comprehensive version resolution and validation functionality
|
|
5
|
-
* for the MSAL module, ensuring compatibility between different MSAL library versions.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { resolveVersion, VersionError } from '@equinor/fusion-framework-module-msal/versioning';
|
|
10
|
-
*
|
|
11
|
-
* try {
|
|
12
|
-
* const result = resolveVersion('2.1.0');
|
|
13
|
-
* console.log('Version is compatible:', result.satisfiesLatest);
|
|
14
|
-
* } catch (error) {
|
|
15
|
-
* if (error instanceof VersionError) {
|
|
16
|
-
* console.error('Version error:', error.message);
|
|
17
|
-
* }
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
// Core versioning functionality
|
|
23
|
-
export { resolveVersion } from './resolve-version';
|
|
24
|
-
|
|
25
|
-
// Error handling
|
|
26
|
-
export { VersionError } from './VersionError';
|
|
27
|
-
|
|
28
|
-
// Types
|
|
29
|
-
export type { ResolvedVersion } from './types';
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import semver, { type SemVer } from 'semver';
|
|
2
|
-
|
|
3
|
-
import { MsalModuleVersion } from '../static';
|
|
4
|
-
|
|
5
|
-
import { VersionError } from './VersionError';
|
|
6
|
-
import type { ResolvedVersion } from './types';
|
|
7
|
-
|
|
8
|
-
import { version as latestVersionString } from '../version';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Maps a version string or object to the corresponding MSAL module enum version.
|
|
12
|
-
*
|
|
13
|
-
* @param version - The version string or SemVer object to map
|
|
14
|
-
* @returns The corresponding MsalModuleVersion enum value
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* Version mapping logic:
|
|
18
|
-
* - Versions <4.0.0 (including 2.x) → MsalModuleVersion.V2
|
|
19
|
-
* - Versions 4.x → MsalModuleVersion.V4
|
|
20
|
-
* - Versions 5.x → MsalModuleVersion.V5
|
|
21
|
-
* - Versions >=6.0.0 → MsalModuleVersion.V5
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* mapVersionToEnumVersion('2.39.0') // returns MsalModuleVersion.V2
|
|
26
|
-
* mapVersionToEnumVersion('4.28.1') // returns MsalModuleVersion.V4
|
|
27
|
-
* mapVersionToEnumVersion('5.0.2') // returns MsalModuleVersion.V5
|
|
28
|
-
* mapVersionToEnumVersion('7.0.0') // returns MsalModuleVersion.V5
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
function mapVersionToEnumVersion(version: string | SemVer): MsalModuleVersion {
|
|
32
|
-
const coercedVersion = semver.coerce(version);
|
|
33
|
-
// An uncoercible version string cannot be mapped to a module version
|
|
34
|
-
if (!coercedVersion) {
|
|
35
|
-
throw new Error(`Invalid version: ${version}`);
|
|
36
|
-
}
|
|
37
|
-
// Versions before 4.0.0 (including 2.x) map to the v2-compatible module version
|
|
38
|
-
if (semver.satisfies(coercedVersion, '<4.0.0')) {
|
|
39
|
-
return MsalModuleVersion.V2;
|
|
40
|
-
}
|
|
41
|
-
// Versions before 7.0.0 (4.x and 5.x/6.x) map to the v4-compatible module version
|
|
42
|
-
if (semver.satisfies(coercedVersion, '<7.0.0')) {
|
|
43
|
-
return MsalModuleVersion.V4;
|
|
44
|
-
}
|
|
45
|
-
return MsalModuleVersion.V5;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Resolves and validates a version string against the latest available MSAL version.
|
|
50
|
-
*
|
|
51
|
-
* This function performs comprehensive version checking including:
|
|
52
|
-
* - Parsing and validating the requested version
|
|
53
|
-
* - Checking major version compatibility (throws on incompatibility)
|
|
54
|
-
* - Warning on minor version mismatches (logs warning but continues)
|
|
55
|
-
* - Ignoring patch version differences for maximum compatibility
|
|
56
|
-
*
|
|
57
|
-
* @param version - The version string or SemVer object to resolve. If not provided, defaults to latest.
|
|
58
|
-
* @returns A ResolvedVersion object containing parsed versions and compatibility information
|
|
59
|
-
*
|
|
60
|
-
* @throws {VersionError} When the requested version is invalid or incompatible
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* // Resolve a specific version
|
|
65
|
-
* const result = resolveVersion('2.1.0');
|
|
66
|
-
* console.log(result.satisfiesLatest); // true if major version matches
|
|
67
|
-
*
|
|
68
|
-
* // Resolve with SemVer object
|
|
69
|
-
* const result2 = resolveVersion(new SemVer('2.0.0'));
|
|
70
|
-
*
|
|
71
|
-
* // Default to latest version
|
|
72
|
-
* const result3 = resolveVersion();
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* // Error handling
|
|
78
|
-
* try {
|
|
79
|
-
* const result = resolveVersion('3.0.0'); // Assuming latest is 2.x
|
|
80
|
-
* } catch (error) {
|
|
81
|
-
* if (error instanceof VersionError) {
|
|
82
|
-
* console.error('Version error:', error.message);
|
|
83
|
-
* }
|
|
84
|
-
* }
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
export function resolveVersion(version?: string | SemVer): ResolvedVersion {
|
|
88
|
-
// Initialize warnings array to collect any version mismatches
|
|
89
|
-
const warnings: string[] = [];
|
|
90
|
-
|
|
91
|
-
// Parse the requested version, defaulting to latest if not provided
|
|
92
|
-
let wantedVersion = version ? semver.coerce(version) : semver.coerce(latestVersionString);
|
|
93
|
-
|
|
94
|
-
// Parse versions using coerce for backward compatibility
|
|
95
|
-
const latestVersion = semver.coerce(latestVersionString);
|
|
96
|
-
|
|
97
|
-
// This should never happen! Indicates version.ts was not generated correctly
|
|
98
|
-
// This is a critical build-time issue that needs immediate attention
|
|
99
|
-
if (!latestVersion) {
|
|
100
|
-
throw new VersionError(
|
|
101
|
-
`Failed to parse latest version "${latestVersionString}" - this indicates the version.ts file was not generated correctly. Check for import errors in the build process.`,
|
|
102
|
-
wantedVersion || '<unknown version>',
|
|
103
|
-
latestVersionString,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Validate that the requested version is a valid semver
|
|
108
|
-
if (!wantedVersion) {
|
|
109
|
-
const missingVersionWarning = new VersionError(
|
|
110
|
-
`Failed to parse requested version "${version ?? '<unknown version>'}"`,
|
|
111
|
-
version ?? '<unknown version>',
|
|
112
|
-
latestVersion,
|
|
113
|
-
);
|
|
114
|
-
warnings.push(missingVersionWarning.message);
|
|
115
|
-
wantedVersion = latestVersion;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Warn when the requested major version trails the latest major version
|
|
119
|
-
if (wantedVersion.major < latestVersion.major) {
|
|
120
|
-
const majorBehindVersionWarning = new VersionError(
|
|
121
|
-
`Requested major version ${wantedVersion.major} is behind the latest major version ${latestVersion.major}`,
|
|
122
|
-
wantedVersion,
|
|
123
|
-
latestVersion,
|
|
124
|
-
);
|
|
125
|
-
warnings.push(majorBehindVersionWarning.message);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Minor version mismatch - add warning but don't throw
|
|
129
|
-
// This helps developers stay aware of version differences without breaking functionality
|
|
130
|
-
if (wantedVersion.major === latestVersion.major && wantedVersion.minor !== latestVersion.minor) {
|
|
131
|
-
const minorMismatchWarning = new VersionError(
|
|
132
|
-
`Requested minor version ${wantedVersion.minor} is different from the latest minor version ${latestVersion.minor}`,
|
|
133
|
-
wantedVersion,
|
|
134
|
-
latestVersion,
|
|
135
|
-
);
|
|
136
|
-
warnings.push(minorMismatchWarning.message);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Find the corresponding enum version for the requested major version
|
|
140
|
-
// This is used for module configuration and feature detection
|
|
141
|
-
const enumVersion = mapVersionToEnumVersion(wantedVersion);
|
|
142
|
-
|
|
143
|
-
// Return comprehensive version resolution result
|
|
144
|
-
return {
|
|
145
|
-
wantedVersion,
|
|
146
|
-
latestVersion,
|
|
147
|
-
isLatest: wantedVersion.compare(latestVersion) === 0,
|
|
148
|
-
satisfiesLatest: wantedVersion.major === latestVersion.major,
|
|
149
|
-
enumVersion,
|
|
150
|
-
warnings: warnings.length > 0 ? warnings : undefined,
|
|
151
|
-
} satisfies ResolvedVersion;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export default resolveVersion;
|
package/src/versioning/types.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { SemVer } from 'semver';
|
|
2
|
-
import type { MsalModuleVersion } from '../static';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Result of version resolution containing parsed versions and compatibility information.
|
|
6
|
-
*
|
|
7
|
-
* This type represents the outcome of resolving a version string against the latest
|
|
8
|
-
* available MSAL version, providing detailed compatibility information for consumers.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const result: ResolvedVersion = {
|
|
13
|
-
* wantedVersion: new SemVer('2.1.0'),
|
|
14
|
-
* latestVersion: new SemVer('2.2.0'),
|
|
15
|
-
* isLatest: false,
|
|
16
|
-
* satisfiesLatest: true,
|
|
17
|
-
* enumVersion: MsalModuleVersion.V2
|
|
18
|
-
* };
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export type ResolvedVersion = {
|
|
22
|
-
/**
|
|
23
|
-
* The version that was requested and successfully parsed.
|
|
24
|
-
* This is the SemVer object representing the user's requested version.
|
|
25
|
-
*/
|
|
26
|
-
wantedVersion: SemVer;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The latest available version in the system.
|
|
30
|
-
* This represents the most recent MSAL version that the module supports.
|
|
31
|
-
*/
|
|
32
|
-
latestVersion: SemVer;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Whether the wanted version is exactly the latest version.
|
|
36
|
-
* True when wantedVersion.compare(latestVersion) === 0
|
|
37
|
-
*/
|
|
38
|
-
isLatest: boolean;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Whether the wanted version satisfies the latest major version.
|
|
42
|
-
* True when major versions match, regardless of minor/patch differences.
|
|
43
|
-
* This is the primary compatibility check for MSAL versions.
|
|
44
|
-
*/
|
|
45
|
-
satisfiesLatest: boolean;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The corresponding enum version for the wanted version.
|
|
49
|
-
* Maps the major version number to the appropriate MsalModuleVersion enum value.
|
|
50
|
-
* Used for module configuration and feature detection.
|
|
51
|
-
*/
|
|
52
|
-
enumVersion: MsalModuleVersion;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Optional array of warning messages for version mismatches.
|
|
56
|
-
* Present when there are minor version differences but major versions match.
|
|
57
|
-
* Consumers can check this field to log warnings or handle version differences.
|
|
58
|
-
*/
|
|
59
|
-
warnings?: string[];
|
|
60
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist/esm",
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"declarationDir": "./dist/types"
|
|
7
|
-
},
|
|
8
|
-
"references": [
|
|
9
|
-
{
|
|
10
|
-
"path": "../module"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"path": "../telemetry"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"include": ["src/**/*"],
|
|
17
|
-
"exclude": ["node_modules", "lib", "dist", "__tests__"]
|
|
18
|
-
}
|
package/vitest.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { defineProject } from 'vitest/config';
|
|
2
|
-
|
|
3
|
-
import { name, version } from './package.json' with { type: 'json' };
|
|
4
|
-
|
|
5
|
-
export default defineProject({
|
|
6
|
-
test: {
|
|
7
|
-
environment: 'node',
|
|
8
|
-
include: ['src/__tests__/**/*.test.ts'],
|
|
9
|
-
name: `${name}@${version}`,
|
|
10
|
-
},
|
|
11
|
-
});
|