@equinor/fusion-framework-module-msal 5.0.1 → 5.1.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 +28 -0
- package/dist/esm/__tests__/versioning/resolve-version.test.js +70 -140
- package/dist/esm/__tests__/versioning/resolve-version.test.js.map +1 -1
- package/dist/esm/static.js +1 -1
- package/dist/esm/v2/provider.js +15 -15
- package/dist/esm/v2/provider.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/versioning/VersionError.js +0 -24
- package/dist/esm/versioning/VersionError.js.map +1 -1
- package/dist/esm/versioning/resolve-version.js +21 -15
- package/dist/esm/versioning/resolve-version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/static.d.ts +1 -1
- package/dist/types/v2/provider.d.ts +2 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/types/versioning/VersionError.d.ts +1 -26
- package/package.json +2 -2
- package/src/__tests__/versioning/resolve-version.test.ts +89 -170
- package/src/v2/provider.ts +18 -17
- package/src/version.ts +1 -1
- package/src/versioning/VersionError.ts +1 -40
- package/src/versioning/resolve-version.ts +35 -29
- package/dist/esm/versioning/create-version-message.js +0 -54
- package/dist/esm/versioning/create-version-message.js.map +0 -1
- package/dist/esm/versioning/static.js +0 -10
- package/dist/esm/versioning/static.js.map +0 -1
- package/dist/types/versioning/create-version-message.d.ts +0 -34
- package/dist/types/versioning/static.d.ts +0 -8
- package/src/versioning/create-version-message.ts +0 -63
- package/src/versioning/static.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 5.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3573](https://github.com/equinor/fusion-framework/pull/3573) [`b42b116`](https://github.com/equinor/fusion-framework/commit/b42b11616487c534e8e01f2df126e2ad05ce6a8f) Thanks [@odinr](https://github.com/odinr)! - Refactored AuthProvider to use a cleaner `client` property instead of deprecated `defaultClient`.
|
|
8
|
+
|
|
9
|
+
- Added `client` property to IAuthProvider interface
|
|
10
|
+
- Replaced deprecated `defaultClient` getter with `client` getter
|
|
11
|
+
- Updated internal references to use private `#client` field
|
|
12
|
+
- Maintained backward compatibility through proxy provider with deprecation warning
|
|
13
|
+
|
|
14
|
+
- [#3572](https://github.com/equinor/fusion-framework/pull/3572) [`2d90f8b`](https://github.com/equinor/fusion-framework/commit/2d90f8b3806aa3deec5ca60142d38118748b1d3e) Thanks [@odinr](https://github.com/odinr)! - Refactored MSAL versioning module to use warnings instead of errors for version incompatibilities.
|
|
15
|
+
|
|
16
|
+
**Changes:**
|
|
17
|
+
|
|
18
|
+
- Removed `create-version-message.ts` and `static.ts` utility files
|
|
19
|
+
- Modified `resolveVersion()` to collect warnings for version mismatches instead of throwing errors
|
|
20
|
+
- Simplified `VersionError` class by removing factory methods and type enum references
|
|
21
|
+
- Updated tests to reflect new warning-based behavior
|
|
22
|
+
|
|
23
|
+
**Breaking Changes:**
|
|
24
|
+
|
|
25
|
+
- Version resolution now returns warnings for incompatible versions instead of throwing errors
|
|
26
|
+
- This change is backward compatible as existing code will continue to work, but error handling behavior has changed
|
|
27
|
+
|
|
28
|
+
**Migration:**
|
|
29
|
+
If your code previously caught `VersionError` exceptions for version incompatibilities, you should now check the `warnings` array in the resolution result instead.
|
|
30
|
+
|
|
3
31
|
## 5.0.1
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest';
|
|
2
2
|
import { SemVer } from 'semver';
|
|
3
3
|
import { resolveVersion } from '../../versioning/resolve-version';
|
|
4
|
-
import { VersionError } from '../../versioning/VersionError';
|
|
5
4
|
// Mock the static module to avoid test failures when package version changes
|
|
6
5
|
// This ensures tests remain stable regardless of package.json version bumps
|
|
7
6
|
vi.mock('../../static', () => ({
|
|
@@ -13,13 +12,6 @@ vi.mock('../../static', () => ({
|
|
|
13
12
|
// Import the mocked version
|
|
14
13
|
import { MsalModuleVersion } from '../../static';
|
|
15
14
|
describe('resolveVersion', () => {
|
|
16
|
-
describe('mock verification', () => {
|
|
17
|
-
it('should use mocked version for consistent testing', () => {
|
|
18
|
-
// Verify that our mock is working and we're using the fixed version
|
|
19
|
-
expect(MsalModuleVersion.Latest).toBe('4.0.9');
|
|
20
|
-
expect(MsalModuleVersion.V2).toBe('v2');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
15
|
describe('successful version resolution', () => {
|
|
24
16
|
it('should resolve a valid version string', () => {
|
|
25
17
|
const result = resolveVersion('2.1.0');
|
|
@@ -51,156 +43,94 @@ describe('resolveVersion', () => {
|
|
|
51
43
|
expect(result.wantedVersion.version).toBe('4.0.9');
|
|
52
44
|
expect(result.isLatest).toBe(true);
|
|
53
45
|
});
|
|
54
|
-
it('should handle patch version differences without warnings', () => {
|
|
55
|
-
const result = resolveVersion('4.0.8');
|
|
56
|
-
expect(result.satisfiesLatest).toBe(true);
|
|
57
|
-
expect(result.isLatest).toBe(false);
|
|
58
|
-
expect(result.warnings).toBeUndefined();
|
|
59
|
-
});
|
|
60
|
-
it('should handle minor version differences with warnings', () => {
|
|
61
|
-
const result = resolveVersion('4.1.0');
|
|
62
|
-
expect(result.satisfiesLatest).toBe(true);
|
|
63
|
-
expect(result.isLatest).toBe(false);
|
|
64
|
-
expect(result.warnings).toBeDefined();
|
|
65
|
-
expect(result.warnings).toHaveLength(1);
|
|
66
|
-
expect(result.warnings?.[0]).toContain('Minor version mismatch');
|
|
67
|
-
});
|
|
68
46
|
it('should find correct enum version for major version', () => {
|
|
69
47
|
const result = resolveVersion('2.5.0');
|
|
70
48
|
expect(result.enumVersion).toBe(MsalModuleVersion.V2);
|
|
71
49
|
expect(result.satisfiesLatest).toBe(false); // 2.x is not compatible with 4.x
|
|
72
50
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
});
|
|
52
|
+
describe('version comparison and warnings', () => {
|
|
53
|
+
it('should identify version states correctly', () => {
|
|
54
|
+
// Exact latest version
|
|
55
|
+
expect(resolveVersion('4.0.9').isLatest).toBe(true);
|
|
56
|
+
// Patch difference (satisfies but not latest)
|
|
57
|
+
const patchResult = resolveVersion('4.0.8');
|
|
58
|
+
expect(patchResult.isLatest).toBe(false);
|
|
59
|
+
expect(patchResult.satisfiesLatest).toBe(true);
|
|
60
|
+
expect(patchResult.warnings).toBeUndefined();
|
|
61
|
+
// Minor difference (satisfies with warning)
|
|
62
|
+
const minorResult = resolveVersion('4.1.0');
|
|
63
|
+
expect(minorResult.isLatest).toBe(false);
|
|
64
|
+
expect(minorResult.satisfiesLatest).toBe(true);
|
|
65
|
+
expect(minorResult.warnings).toBeDefined();
|
|
66
|
+
expect(minorResult.warnings?.[0]).toContain('Requested minor version 1 is different from the latest minor version 0');
|
|
67
|
+
// Major difference (doesn't satisfy with warning)
|
|
68
|
+
const majorResult = resolveVersion('5.0.0');
|
|
69
|
+
expect(majorResult.satisfiesLatest).toBe(false);
|
|
70
|
+
expect(majorResult.warnings).toBeDefined();
|
|
71
|
+
expect(majorResult.warnings?.[0]).toContain('Requested major version 5 is greater than the latest major version 4');
|
|
72
|
+
});
|
|
73
|
+
it('should handle versions without matching enum with warnings', () => {
|
|
74
|
+
// Lower major version
|
|
75
|
+
const lowerResult = resolveVersion('3.0.0');
|
|
76
|
+
expect(lowerResult.enumVersion).toBe('4.0.9'); // Falls back to latest
|
|
77
|
+
expect(lowerResult.warnings).toBeDefined();
|
|
78
|
+
expect(lowerResult.warnings?.[0]).toContain('Requested major version 3 is behind the latest major version 4');
|
|
79
|
+
// Zero version
|
|
80
|
+
const zeroResult = resolveVersion('0.0.0');
|
|
81
|
+
expect(zeroResult.enumVersion).toBe('4.0.9'); // Falls back to latest
|
|
82
|
+
expect(zeroResult.warnings).toBeDefined();
|
|
83
|
+
expect(zeroResult.warnings?.[0]).toContain('Requested major version 0 is behind the latest major version 4');
|
|
76
84
|
});
|
|
77
85
|
});
|
|
78
86
|
describe('error handling', () => {
|
|
79
|
-
it('should
|
|
80
|
-
|
|
87
|
+
it('should handle invalid version strings gracefully', () => {
|
|
88
|
+
const invalidVersions = ['invalid-version', 'not-a-version', 'invalid', 'bad.version'];
|
|
89
|
+
invalidVersions.forEach((invalidVersion) => {
|
|
90
|
+
const result = resolveVersion(invalidVersion);
|
|
91
|
+
expect(result.warnings).toBeDefined();
|
|
92
|
+
expect(result.warnings).toHaveLength(1);
|
|
93
|
+
expect(result.warnings?.[0]).toContain(`Failed to parse requested version "${invalidVersion}"`);
|
|
94
|
+
// Should fall back to latest version
|
|
95
|
+
expect(result.wantedVersion.version).toBe('4.0.9');
|
|
96
|
+
});
|
|
81
97
|
});
|
|
82
|
-
it('should
|
|
83
|
-
// semver.coerce
|
|
98
|
+
it('should handle malformed but coercible versions', () => {
|
|
99
|
+
// semver.coerce handles these gracefully
|
|
84
100
|
expect(() => resolveVersion('2.')).not.toThrow();
|
|
85
|
-
|
|
86
|
-
it('should throw VersionError for non-semver string', () => {
|
|
87
|
-
expect(() => resolveVersion('not-a-version')).toThrow(VersionError);
|
|
88
|
-
});
|
|
89
|
-
it('should throw VersionError for major version incompatibility', () => {
|
|
90
|
-
expect(() => resolveVersion('5.0.0')).toThrow(VersionError);
|
|
91
|
-
});
|
|
92
|
-
it('should throw VersionError for very high major version', () => {
|
|
93
|
-
expect(() => resolveVersion('999.0.0')).toThrow(VersionError);
|
|
94
|
-
});
|
|
95
|
-
it('should include correct error type for major incompatibility', () => {
|
|
96
|
-
try {
|
|
97
|
-
resolveVersion('5.0.0');
|
|
98
|
-
expect.fail('Should have thrown VersionError');
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
expect(error).toBeInstanceOf(VersionError);
|
|
102
|
-
const versionError = error;
|
|
103
|
-
expect(versionError.type).toBe('major-incompatibility');
|
|
104
|
-
expect(versionError.requestedVersion).toBe('5.0.0');
|
|
105
|
-
expect(versionError.latestVersion).toBe('4.0.9');
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
it('should include correct error type for invalid version', () => {
|
|
109
|
-
try {
|
|
110
|
-
resolveVersion('invalid');
|
|
111
|
-
expect.fail('Should have thrown VersionError');
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
expect(error).toBeInstanceOf(VersionError);
|
|
115
|
-
expect(error.type).toBe('invalid-version');
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
describe('version comparison logic', () => {
|
|
120
|
-
it('should correctly identify latest version', () => {
|
|
121
|
-
const result = resolveVersion('4.0.9');
|
|
122
|
-
expect(result.isLatest).toBe(true);
|
|
123
|
-
});
|
|
124
|
-
it('should correctly identify non-latest version', () => {
|
|
125
|
-
const result = resolveVersion('4.0.8');
|
|
126
|
-
expect(result.isLatest).toBe(false);
|
|
127
|
-
});
|
|
128
|
-
it('should correctly identify satisfying version', () => {
|
|
129
|
-
const result = resolveVersion('4.1.0');
|
|
130
|
-
expect(result.satisfiesLatest).toBe(true);
|
|
131
|
-
});
|
|
132
|
-
it('should correctly identify non-satisfying version', () => {
|
|
133
|
-
expect(() => resolveVersion('5.0.0')).toThrow();
|
|
134
|
-
});
|
|
135
|
-
it('should throw error for major versions without enum values', () => {
|
|
136
|
-
// Version 3.0.0 should throw because there's no enum for major version 3
|
|
137
|
-
expect(() => resolveVersion('3.0.0')).toThrow(VersionError);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe('warning behavior', () => {
|
|
141
|
-
it('should warn on minor version mismatch', () => {
|
|
142
|
-
const result = resolveVersion('4.1.0');
|
|
143
|
-
expect(result.warnings).toBeDefined();
|
|
144
|
-
expect(result.warnings).toHaveLength(1);
|
|
145
|
-
expect(result.warnings?.[0]).toContain('Minor version mismatch');
|
|
146
|
-
});
|
|
147
|
-
it('should not warn on patch version differences', () => {
|
|
148
|
-
const result = resolveVersion('4.0.8');
|
|
149
|
-
expect(result.warnings).toBeUndefined();
|
|
150
|
-
});
|
|
151
|
-
it('should not warn on exact version match', () => {
|
|
152
|
-
const result = resolveVersion('4.0.9');
|
|
153
|
-
expect(result.warnings).toBeUndefined();
|
|
154
|
-
});
|
|
155
|
-
it('should warn with correct version information', () => {
|
|
156
|
-
const result = resolveVersion('4.2.0');
|
|
157
|
-
expect(result.warnings).toBeDefined();
|
|
158
|
-
expect(result.warnings).toHaveLength(1);
|
|
159
|
-
expect(result.warnings?.[0]).toContain('4.2.0');
|
|
160
|
-
expect(result.warnings?.[0]).toContain('4.0.9');
|
|
101
|
+
expect(() => resolveVersion('4')).not.toThrow();
|
|
161
102
|
});
|
|
162
103
|
});
|
|
163
104
|
describe('edge cases', () => {
|
|
164
|
-
it('should handle version with pre-release
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const longVersion = '4.0.9-beta.1.alpha.2+build.123.456';
|
|
176
|
-
const result = resolveVersion(longVersion);
|
|
177
|
-
expect(result.satisfiesLatest).toBe(true);
|
|
178
|
-
expect(result.wantedVersion.version).toBe('4.0.9'); // coerce strips pre-release and build
|
|
179
|
-
});
|
|
180
|
-
it('should throw error for zero versions without enum values', () => {
|
|
181
|
-
// Version 0.0.0 should throw because there's no enum for major version 0
|
|
182
|
-
expect(() => resolveVersion('0.0.0')).toThrow(VersionError);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
describe('return value structure', () => {
|
|
186
|
-
it('should return object with all required properties', () => {
|
|
187
|
-
const result = resolveVersion('2.1.0');
|
|
188
|
-
expect(result).toHaveProperty('wantedVersion');
|
|
189
|
-
expect(result).toHaveProperty('latestVersion');
|
|
190
|
-
expect(result).toHaveProperty('isLatest');
|
|
191
|
-
expect(result).toHaveProperty('satisfiesLatest');
|
|
192
|
-
expect(result).toHaveProperty('enumVersion');
|
|
193
|
-
expect(typeof result.isLatest).toBe('boolean');
|
|
194
|
-
expect(typeof result.satisfiesLatest).toBe('boolean');
|
|
195
|
-
expect(result.wantedVersion).toBeInstanceOf(SemVer);
|
|
196
|
-
expect(result.latestVersion).toBeInstanceOf(SemVer);
|
|
197
|
-
expect(typeof result.enumVersion).toBe('string');
|
|
105
|
+
it('should handle complex version strings with pre-release and build metadata', () => {
|
|
106
|
+
const testCases = [
|
|
107
|
+
{ input: '4.0.9-beta.1', expected: '4.0.9' },
|
|
108
|
+
{ input: '4.0.9+build.123', expected: '4.0.9' },
|
|
109
|
+
{ input: '4.0.9-beta.1.alpha.2+build.123.456', expected: '4.0.9' },
|
|
110
|
+
];
|
|
111
|
+
testCases.forEach(({ input, expected }) => {
|
|
112
|
+
const result = resolveVersion(input);
|
|
113
|
+
expect(result.satisfiesLatest).toBe(true);
|
|
114
|
+
expect(result.wantedVersion.version).toBe(expected);
|
|
115
|
+
});
|
|
198
116
|
});
|
|
199
|
-
it('should
|
|
117
|
+
it('should return consistent structure across calls', () => {
|
|
200
118
|
const result1 = resolveVersion('2.0.0');
|
|
201
119
|
const result2 = resolveVersion('4.0.0');
|
|
120
|
+
// Latest version should be consistent
|
|
202
121
|
expect(result1.latestVersion.version).toBe(result2.latestVersion.version);
|
|
203
122
|
expect(result1.latestVersion.version).toBe('4.0.9');
|
|
123
|
+
// Structure should be consistent
|
|
124
|
+
expect(result1).toHaveProperty('wantedVersion');
|
|
125
|
+
expect(result1).toHaveProperty('latestVersion');
|
|
126
|
+
expect(result1).toHaveProperty('isLatest');
|
|
127
|
+
expect(result1).toHaveProperty('satisfiesLatest');
|
|
128
|
+
expect(result1).toHaveProperty('enumVersion');
|
|
129
|
+
expect(result1.wantedVersion).toBeInstanceOf(SemVer);
|
|
130
|
+
expect(result1.latestVersion).toBeInstanceOf(SemVer);
|
|
131
|
+
expect(typeof result1.isLatest).toBe('boolean');
|
|
132
|
+
expect(typeof result1.satisfiesLatest).toBe('boolean');
|
|
133
|
+
expect(typeof result1.enumVersion).toBe('string');
|
|
204
134
|
});
|
|
205
135
|
});
|
|
206
136
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-version.test.js","sourceRoot":"","sources":["../../../../src/__tests__/versioning/resolve-version.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-version.test.js","sourceRoot":"","sources":["../../../../src/__tests__/versioning/resolve-version.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,6EAA6E;AAC7E,4EAA4E;AAC5E,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7B,iBAAiB,EAAE;QACjB,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,OAAO,EAAE,uCAAuC;KACzD;CACF,CAAC,CAAC,CAAC;AAEJ,4BAA4B;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC7C,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC/C,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;YAEvC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC;gBAC3B,aAAa,EAAE,MAAM,CA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CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAClD,MAAM,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAE9C,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACrD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACrD,MAAM,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAChD,MAAM,CAAC,OAAO,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACvD,MAAM,CAAC,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/esm/static.js
CHANGED
|
@@ -3,6 +3,6 @@ export const ModuleName = 'msal';
|
|
|
3
3
|
export var MsalModuleVersion;
|
|
4
4
|
(function (MsalModuleVersion) {
|
|
5
5
|
MsalModuleVersion["V2"] = "v2";
|
|
6
|
-
MsalModuleVersion["Latest"] = "5.0
|
|
6
|
+
MsalModuleVersion["Latest"] = "5.1.0";
|
|
7
7
|
})(MsalModuleVersion || (MsalModuleVersion = {}));
|
|
8
8
|
//# sourceMappingURL=static.js.map
|
package/dist/esm/v2/provider.js
CHANGED
|
@@ -8,12 +8,8 @@ export class AuthProvider {
|
|
|
8
8
|
get version() {
|
|
9
9
|
return new SemanticVersion(MsalModuleVersion.Latest);
|
|
10
10
|
}
|
|
11
|
-
/** @deprecated */
|
|
12
|
-
get defaultClient() {
|
|
13
|
-
return this.getClient();
|
|
14
|
-
}
|
|
15
11
|
get defaultAccount() {
|
|
16
|
-
return this.
|
|
12
|
+
return this.client.account;
|
|
17
13
|
}
|
|
18
14
|
/** @deprecated */
|
|
19
15
|
get defaultConfig() {
|
|
@@ -23,8 +19,7 @@ export class AuthProvider {
|
|
|
23
19
|
this._config = _config;
|
|
24
20
|
this.#client = this.createClient();
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
getClient() {
|
|
22
|
+
get client() {
|
|
28
23
|
return this.#client;
|
|
29
24
|
}
|
|
30
25
|
/** @deprecated */
|
|
@@ -37,10 +32,9 @@ export class AuthProvider {
|
|
|
37
32
|
async handleRedirect() {
|
|
38
33
|
const { redirectUri } = this.defaultConfig || {};
|
|
39
34
|
if (window.location.pathname === redirectUri) {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
await client.handleRedirectPromise();
|
|
35
|
+
const logger = this.client.getLogger();
|
|
36
|
+
const { requestOrigin } = this.client;
|
|
37
|
+
await this.client.handleRedirectPromise();
|
|
44
38
|
if (requestOrigin === redirectUri) {
|
|
45
39
|
logger.warning(`detected callback loop from url ${redirectUri}, redirecting to root`);
|
|
46
40
|
window.location.replace('/');
|
|
@@ -52,7 +46,7 @@ export class AuthProvider {
|
|
|
52
46
|
return null;
|
|
53
47
|
}
|
|
54
48
|
acquireToken(req) {
|
|
55
|
-
return this.
|
|
49
|
+
return this.client.acquireToken(req);
|
|
56
50
|
}
|
|
57
51
|
async acquireAccessToken(req) {
|
|
58
52
|
const token = await this.acquireToken(req);
|
|
@@ -60,14 +54,14 @@ export class AuthProvider {
|
|
|
60
54
|
}
|
|
61
55
|
async login(options) {
|
|
62
56
|
// skip login if already logged in and has valid claims
|
|
63
|
-
if (options?.onlyIfRequired && this.
|
|
57
|
+
if (options?.onlyIfRequired && this.client.hasValidClaims) {
|
|
64
58
|
return;
|
|
65
59
|
}
|
|
66
|
-
await this.
|
|
60
|
+
await this.client.login();
|
|
67
61
|
}
|
|
68
62
|
async logout(options) {
|
|
69
63
|
// TODO - might have an option for popup or redirect
|
|
70
|
-
await this.
|
|
64
|
+
await this.client.logoutRedirect({
|
|
71
65
|
postLogoutRedirectUri: options?.redirectUri,
|
|
72
66
|
account: this.defaultAccount,
|
|
73
67
|
});
|
|
@@ -89,6 +83,12 @@ export class AuthProvider {
|
|
|
89
83
|
switch (prop) {
|
|
90
84
|
case 'version':
|
|
91
85
|
return target.version;
|
|
86
|
+
case 'client':
|
|
87
|
+
return target.client;
|
|
88
|
+
// @ts-expect-error - this is deprecated since version 5.0.1
|
|
89
|
+
case 'defaultClient':
|
|
90
|
+
console.warn('defaultClient is deprecated, use client instead');
|
|
91
|
+
return target.client;
|
|
92
92
|
case 'defaultAccount':
|
|
93
93
|
return target.defaultAccount;
|
|
94
94
|
case 'defaultConfig':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/v2/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,gBAAgB,EAAoB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/v2/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,gBAAgB,EAAoB,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAyCnE,MAAM,OAAO,YAAY;IAgBD;IAftB,OAAO,CAAa;IAEpB,IAAI,OAAO;QACT,OAAO,IAAI,eAAe,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAA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E;gBACtD,QAAQ,IAAI,EAAE,CAAC;oBACb,KAAK,SAAS;wBACZ,OAAO,MAAM,CAAC,OAAO,CAAC;oBACxB,KAAK,QAAQ;wBACX,OAAO,MAAM,CAAC,MAAM,CAAC;oBACvB,4DAA4D;oBAC5D,KAAK,eAAe;wBAClB,OAAO,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;wBAChE,OAAO,MAAM,CAAC,MAAM,CAAC;oBACvB,KAAK,gBAAgB;wBACnB,OAAO,MAAM,CAAC,cAAc,CAAC;oBAC/B,KAAK,eAAe;wBAClB,OAAO,MAAM,CAAC,aAAa,CAAC;oBAC9B,KAAK,cAAc;wBACjB,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC1C,KAAK,oBAAoB;wBACvB,OAAO,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAChD,KAAK,OAAO;wBACV,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACnC,KAAK,gBAAgB;wBACnB,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC5C,KAAK,qBAAqB;wBACxB,OAAO,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import { VersionMessageType } from './static';
|
|
2
|
-
import { createVersionMessage } from './create-version-message';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a VersionError instance with a formatted message.
|
|
5
|
-
*
|
|
6
|
-
* This is a helper function that creates a VersionError with a human-readable
|
|
7
|
-
* message based on the error type and version information.
|
|
8
|
-
*
|
|
9
|
-
* @param type - The type of version error
|
|
10
|
-
* @param requestedVersion - The version that was requested
|
|
11
|
-
* @param latestVersion - The latest available version
|
|
12
|
-
* @param options - Additional error options including the error type
|
|
13
|
-
* @returns A new VersionError instance with formatted message
|
|
14
|
-
*/
|
|
15
|
-
const createVersionError = (type, requestedVersion, latestVersion, options) => {
|
|
16
|
-
return new VersionError(createVersionMessage(type, requestedVersion, latestVersion), requestedVersion, latestVersion, { ...options, type });
|
|
17
|
-
};
|
|
18
1
|
/**
|
|
19
2
|
* Error class for version-related issues in the MSAL module.
|
|
20
3
|
*
|
|
@@ -50,14 +33,8 @@ export class VersionError extends Error {
|
|
|
50
33
|
requestedVersion;
|
|
51
34
|
/** The latest available version in the system */
|
|
52
35
|
latestVersion;
|
|
53
|
-
/** The specific type of version error that occurred */
|
|
54
|
-
type;
|
|
55
36
|
/** The error name for instanceof checks */
|
|
56
37
|
static Name = 'VersionError';
|
|
57
|
-
/** Reference to the VersionMessageType enum for convenience */
|
|
58
|
-
static Type = VersionMessageType;
|
|
59
|
-
/** Factory method for creating VersionError instances with formatted messages */
|
|
60
|
-
static create = createVersionError;
|
|
61
38
|
/**
|
|
62
39
|
* Creates a new VersionError instance.
|
|
63
40
|
*
|
|
@@ -72,7 +49,6 @@ export class VersionError extends Error {
|
|
|
72
49
|
// Store versions as strings
|
|
73
50
|
this.requestedVersion = String(requestedVersion);
|
|
74
51
|
this.latestVersion = String(latestVersion);
|
|
75
|
-
this.type = options?.type;
|
|
76
52
|
}
|
|
77
53
|
}
|
|
78
54
|
//# sourceMappingURL=VersionError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionError.js","sourceRoot":"","sources":["../../../src/versioning/VersionError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VersionError.js","sourceRoot":"","sources":["../../../src/versioning/VersionError.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,iDAAiD;IACjC,gBAAgB,CAAS;IAEzC,iDAAiD;IACjC,aAAa,CAAS;IAEtC,2CAA2C;IAC3C,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC;IAE7B;;;;;;;OAOG;IACH,YACE,OAAe,EACf,gBAAiC,EACjC,aAA8B,EAC9B,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAE9B,4BAA4B;QAC5B,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC"}
|
|
@@ -46,35 +46,41 @@ export function resolveVersion(version) {
|
|
|
46
46
|
// Parse the requested version, defaulting to latest if not provided
|
|
47
47
|
const versionString = version || MsalModuleVersion.Latest;
|
|
48
48
|
// Parse versions using coerce for backward compatibility
|
|
49
|
-
const wantedVersion = semver.coerce(versionString);
|
|
50
49
|
const latestVersion = semver.coerce(MsalModuleVersion.Latest);
|
|
51
|
-
// Validate that the requested version is a valid semver
|
|
52
|
-
if (!wantedVersion) {
|
|
53
|
-
throw VersionError.create(VersionError.Type.InvalidVersion, versionString, MsalModuleVersion.Latest);
|
|
54
|
-
}
|
|
55
50
|
// This should never happen! Indicates version.ts was not generated correctly
|
|
56
51
|
// This is a critical build-time issue that needs immediate attention
|
|
57
52
|
if (!latestVersion) {
|
|
58
|
-
throw VersionError
|
|
53
|
+
throw new VersionError(`Failed to parse latest version "${MsalModuleVersion.Latest}" - this indicates the version.ts file was not generated correctly. Check for import errors in the build process.`, versionString, MsalModuleVersion.Latest);
|
|
54
|
+
}
|
|
55
|
+
let wantedVersion = semver.coerce(versionString);
|
|
56
|
+
// Validate that the requested version is a valid semver
|
|
57
|
+
if (!wantedVersion) {
|
|
58
|
+
const missingVersionWarning = new VersionError(`Failed to parse requested version "${versionString}"`, versionString, MsalModuleVersion.Latest);
|
|
59
|
+
warnings.push(missingVersionWarning.message);
|
|
60
|
+
wantedVersion = latestVersion;
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
throw VersionError.create(VersionError.Type.MajorIncompatibility, String(wantedVersion), String(latestVersion));
|
|
62
|
+
if (wantedVersion.major < latestVersion.major) {
|
|
63
|
+
const majorBehindVersionWarning = new VersionError(`Requested major version ${wantedVersion.major} is behind the latest major version ${latestVersion.major}`, wantedVersion, latestVersion);
|
|
64
|
+
warnings.push(majorBehindVersionWarning.message);
|
|
64
65
|
}
|
|
65
66
|
// Minor version mismatch - add warning but don't throw
|
|
66
67
|
// This helps developers stay aware of version differences without breaking functionality
|
|
67
68
|
if (wantedVersion.major === latestVersion.major && wantedVersion.minor !== latestVersion.minor) {
|
|
68
|
-
const minorMismatchWarning = VersionError
|
|
69
|
+
const minorMismatchWarning = new VersionError(`Requested minor version ${wantedVersion.minor} is different from the latest minor version ${latestVersion.minor}`, wantedVersion, latestVersion);
|
|
69
70
|
warnings.push(minorMismatchWarning.message);
|
|
70
71
|
}
|
|
71
72
|
// Find the corresponding enum version for the requested major version
|
|
72
73
|
// This is used for module configuration and feature detection
|
|
73
|
-
|
|
74
|
-
// If no matching enum version is found,
|
|
75
|
-
//
|
|
74
|
+
let enumVersion = Object.values(MsalModuleVersion).find((x) => semver.coerce(x)?.major === wantedVersion.major);
|
|
75
|
+
// If no matching enum version is found, fall back to the latest available
|
|
76
|
+
// This allows forward compatibility with future versions
|
|
76
77
|
if (!enumVersion) {
|
|
77
|
-
|
|
78
|
+
enumVersion = MsalModuleVersion.Latest;
|
|
79
|
+
// Only warn if this is a future version (higher than latest)
|
|
80
|
+
if (wantedVersion.major > latestVersion.major) {
|
|
81
|
+
const fallbackWarning = new VersionError(`Requested major version ${wantedVersion.major} is greater than the latest major version ${latestVersion.major}. Falling back to latest version.`, wantedVersion, latestVersion);
|
|
82
|
+
warnings.push(fallbackWarning.message);
|
|
83
|
+
}
|
|
78
84
|
}
|
|
79
85
|
// Return comprehensive version resolution result
|
|
80
86
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-version.js","sourceRoot":"","sources":["../../../src/versioning/resolve-version.ts"],"names":[],"mappings":"AAAA,OAAO,MAAuB,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,cAAc,CAAC,OAAyB;IACtD,8DAA8D;IAC9D,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,oEAAoE;IACpE,MAAM,aAAa,GAAG,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC;IAE1D,yDAAyD;IACzD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"resolve-version.js","sourceRoot":"","sources":["../../../src/versioning/resolve-version.ts"],"names":[],"mappings":"AAAA,OAAO,MAAuB,MAAM,QAAQ,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,cAAc,CAAC,OAAyB;IACtD,8DAA8D;IAC9D,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,oEAAoE;IACpE,MAAM,aAAa,GAAG,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC;IAE1D,yDAAyD;IACzD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE9D,6EAA6E;IAC7E,qEAAqE;IACrE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,YAAY,CACpB,mCAAmC,iBA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