@equinor/fusion-framework-module-msal 5.0.0 → 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.
Files changed (32) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/esm/__tests__/versioning/resolve-version.test.js +70 -140
  3. package/dist/esm/__tests__/versioning/resolve-version.test.js.map +1 -1
  4. package/dist/esm/static.js +1 -1
  5. package/dist/esm/v2/client/log/console.js +1 -1
  6. package/dist/esm/v2/provider.js +15 -15
  7. package/dist/esm/v2/provider.js.map +1 -1
  8. package/dist/esm/version.js +1 -1
  9. package/dist/esm/versioning/VersionError.js +0 -24
  10. package/dist/esm/versioning/VersionError.js.map +1 -1
  11. package/dist/esm/versioning/resolve-version.js +21 -15
  12. package/dist/esm/versioning/resolve-version.js.map +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/types/static.d.ts +1 -1
  15. package/dist/types/v2/provider.d.ts +2 -4
  16. package/dist/types/version.d.ts +1 -1
  17. package/dist/types/versioning/VersionError.d.ts +1 -26
  18. package/package.json +2 -2
  19. package/src/__tests__/versioning/resolve-version.test.ts +89 -170
  20. package/src/v2/client/log/console.ts +1 -1
  21. package/src/v2/provider.ts +18 -17
  22. package/src/version.ts +1 -1
  23. package/src/versioning/VersionError.ts +1 -40
  24. package/src/versioning/resolve-version.ts +35 -29
  25. package/dist/esm/versioning/create-version-message.js +0 -54
  26. package/dist/esm/versioning/create-version-message.js.map +0 -1
  27. package/dist/esm/versioning/static.js +0 -10
  28. package/dist/esm/versioning/static.js.map +0 -1
  29. package/dist/types/versioning/create-version-message.d.ts +0 -34
  30. package/dist/types/versioning/static.d.ts +0 -8
  31. package/src/versioning/create-version-message.ts +0 -63
  32. package/src/versioning/static.ts +0 -8
@@ -1,5 +1,5 @@
1
1
  export declare const ModuleName: "msal";
2
2
  export declare enum MsalModuleVersion {
3
3
  V2 = "v2",
4
- Latest = "5.0.0"
4
+ Latest = "5.1.0"
5
5
  }
@@ -9,6 +9,7 @@ export interface IAuthProvider {
9
9
  */
10
10
  readonly defaultConfig: any | undefined;
11
11
  readonly defaultAccount: AccountInfo | undefined;
12
+ readonly client: AuthClient;
12
13
  /**
13
14
  * Acquire token from default auth client
14
15
  * @param req Auth request options
@@ -38,14 +39,11 @@ export declare class AuthProvider implements IAuthProvider, IProxyProvider {
38
39
  #private;
39
40
  protected _config: AuthClientConfig;
40
41
  get version(): SemanticVersion;
41
- /** @deprecated */
42
- get defaultClient(): AuthClient;
43
42
  get defaultAccount(): AccountInfo | undefined;
44
43
  /** @deprecated */
45
44
  get defaultConfig(): AuthClientConfig | undefined;
46
45
  constructor(_config: AuthClientConfig);
47
- /** @deprecated */
48
- getClient(): AuthClient;
46
+ get client(): AuthClient;
49
47
  /** @deprecated */
50
48
  createClient(): AuthClient;
51
49
  handleRedirect(): Promise<null>;
@@ -1 +1 @@
1
- export declare const version = "5.0.0";
1
+ export declare const version = "5.1.0";
@@ -1,20 +1,4 @@
1
- import { VersionMessageType } from './static';
2
1
  import type { SemVer } from 'semver';
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
- declare const createVersionError: (type: VersionMessageType, requestedVersion: string | SemVer, latestVersion: string | SemVer, options?: ErrorOptions & {
16
- type?: VersionMessageType;
17
- }) => VersionError;
18
2
  /**
19
3
  * Error class for version-related issues in the MSAL module.
20
4
  *
@@ -50,14 +34,8 @@ export declare class VersionError extends Error {
50
34
  readonly requestedVersion: string;
51
35
  /** The latest available version in the system */
52
36
  readonly latestVersion: string;
53
- /** The specific type of version error that occurred */
54
- readonly type?: VersionMessageType;
55
37
  /** The error name for instanceof checks */
56
38
  static Name: string;
57
- /** Reference to the VersionMessageType enum for convenience */
58
- static Type: typeof VersionMessageType;
59
- /** Factory method for creating VersionError instances with formatted messages */
60
- static create: typeof createVersionError;
61
39
  /**
62
40
  * Creates a new VersionError instance.
63
41
  *
@@ -66,8 +44,5 @@ export declare class VersionError extends Error {
66
44
  * @param latestVersion - The latest available version (will be stored as string)
67
45
  * @param options - Additional error options including the error type
68
46
  */
69
- constructor(message: string, requestedVersion: string | SemVer, latestVersion: string | SemVer, options?: ErrorOptions & {
70
- type?: VersionMessageType;
71
- });
47
+ constructor(message: string, requestedVersion: string | SemVer, latestVersion: string | SemVer, options?: ErrorOptions);
72
48
  }
73
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-msal",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "Microsoft Authentication Library (MSAL) integration module for Fusion Framework",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "@types/semver": "^7.5.0",
41
41
  "semver": "^7.5.4",
42
42
  "zod": "^4.1.8",
43
- "@equinor/fusion-framework-module": "^5.0.1"
43
+ "@equinor/fusion-framework-module": "^5.0.3"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.8.2"
@@ -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
 
6
5
  // Mock the static module to avoid test failures when package version changes
7
6
  // This ensures tests remain stable regardless of package.json version bumps
@@ -16,14 +15,6 @@ vi.mock('../../static', () => ({
16
15
  import { MsalModuleVersion } from '../../static';
17
16
 
18
17
  describe('resolveVersion', () => {
19
- describe('mock verification', () => {
20
- it('should use mocked version for consistent testing', () => {
21
- // Verify that our mock is working and we're using the fixed version
22
- expect(MsalModuleVersion.Latest).toBe('4.0.9');
23
- expect(MsalModuleVersion.V2).toBe('v2');
24
- });
25
- });
26
-
27
18
  describe('successful version resolution', () => {
28
19
  it('should resolve a valid version string', () => {
29
20
  const result = resolveVersion('2.1.0');
@@ -64,192 +55,120 @@ describe('resolveVersion', () => {
64
55
  expect(result.isLatest).toBe(true);
65
56
  });
66
57
 
67
- it('should handle patch version differences without warnings', () => {
68
- const result = resolveVersion('4.0.8');
69
-
70
- expect(result.satisfiesLatest).toBe(true);
71
- expect(result.isLatest).toBe(false);
72
- expect(result.warnings).toBeUndefined();
73
- });
74
-
75
- it('should handle minor version differences with warnings', () => {
76
- const result = resolveVersion('4.1.0');
77
-
78
- expect(result.satisfiesLatest).toBe(true);
79
- expect(result.isLatest).toBe(false);
80
- expect(result.warnings).toBeDefined();
81
- expect(result.warnings).toHaveLength(1);
82
- expect(result.warnings?.[0]).toContain('Minor version mismatch');
83
- });
84
-
85
58
  it('should find correct enum version for major version', () => {
86
59
  const result = resolveVersion('2.5.0');
87
60
 
88
61
  expect(result.enumVersion).toBe(MsalModuleVersion.V2);
89
62
  expect(result.satisfiesLatest).toBe(false); // 2.x is not compatible with 4.x
90
63
  });
64
+ });
91
65
 
92
- it('should throw error when no matching major version exists in enum', () => {
93
- // Version 3.0.0 should throw because there's no enum for major version 3
94
- expect(() => resolveVersion('3.0.0')).toThrow(VersionError);
66
+ describe('version comparison and warnings', () => {
67
+ it('should identify version states correctly', () => {
68
+ // Exact latest version
69
+ expect(resolveVersion('4.0.9').isLatest).toBe(true);
70
+
71
+ // Patch difference (satisfies but not latest)
72
+ const patchResult = resolveVersion('4.0.8');
73
+ expect(patchResult.isLatest).toBe(false);
74
+ expect(patchResult.satisfiesLatest).toBe(true);
75
+ expect(patchResult.warnings).toBeUndefined();
76
+
77
+ // Minor difference (satisfies with warning)
78
+ const minorResult = resolveVersion('4.1.0');
79
+ expect(minorResult.isLatest).toBe(false);
80
+ expect(minorResult.satisfiesLatest).toBe(true);
81
+ expect(minorResult.warnings).toBeDefined();
82
+ expect(minorResult.warnings?.[0]).toContain(
83
+ 'Requested minor version 1 is different from the latest minor version 0',
84
+ );
85
+
86
+ // Major difference (doesn't satisfy with warning)
87
+ const majorResult = resolveVersion('5.0.0');
88
+ expect(majorResult.satisfiesLatest).toBe(false);
89
+ expect(majorResult.warnings).toBeDefined();
90
+ expect(majorResult.warnings?.[0]).toContain(
91
+ 'Requested major version 5 is greater than the latest major version 4',
92
+ );
93
+ });
94
+
95
+ it('should handle versions without matching enum with warnings', () => {
96
+ // Lower major version
97
+ const lowerResult = resolveVersion('3.0.0');
98
+ expect(lowerResult.enumVersion).toBe('4.0.9'); // Falls back to latest
99
+ expect(lowerResult.warnings).toBeDefined();
100
+ expect(lowerResult.warnings?.[0]).toContain(
101
+ 'Requested major version 3 is behind the latest major version 4',
102
+ );
103
+
104
+ // Zero version
105
+ const zeroResult = resolveVersion('0.0.0');
106
+ expect(zeroResult.enumVersion).toBe('4.0.9'); // Falls back to latest
107
+ expect(zeroResult.warnings).toBeDefined();
108
+ expect(zeroResult.warnings?.[0]).toContain(
109
+ 'Requested major version 0 is behind the latest major version 4',
110
+ );
95
111
  });
96
112
  });
97
113
 
98
114
  describe('error handling', () => {
99
- it('should throw VersionError for invalid version string', () => {
100
- expect(() => resolveVersion('invalid-version')).toThrow(VersionError);
115
+ it('should handle invalid version strings gracefully', () => {
116
+ const invalidVersions = ['invalid-version', 'not-a-version', 'invalid', 'bad.version'];
117
+
118
+ invalidVersions.forEach((invalidVersion) => {
119
+ const result = resolveVersion(invalidVersion);
120
+ expect(result.warnings).toBeDefined();
121
+ expect(result.warnings).toHaveLength(1);
122
+ expect(result.warnings?.[0]).toContain(
123
+ `Failed to parse requested version "${invalidVersion}"`,
124
+ );
125
+ // Should fall back to latest version
126
+ expect(result.wantedVersion.version).toBe('4.0.9');
127
+ });
101
128
  });
102
129
 
103
- it('should not throw for malformed version (coerce handles it)', () => {
104
- // semver.coerce('2.') returns '2.0.0', so it doesn't throw
130
+ it('should handle malformed but coercible versions', () => {
131
+ // semver.coerce handles these gracefully
105
132
  expect(() => resolveVersion('2.')).not.toThrow();
106
- });
107
-
108
- it('should throw VersionError for non-semver string', () => {
109
- expect(() => resolveVersion('not-a-version')).toThrow(VersionError);
110
- });
111
-
112
- it('should throw VersionError for major version incompatibility', () => {
113
- expect(() => resolveVersion('5.0.0')).toThrow(VersionError);
114
- });
115
-
116
- it('should throw VersionError for very high major version', () => {
117
- expect(() => resolveVersion('999.0.0')).toThrow(VersionError);
118
- });
119
-
120
- it('should include correct error type for major incompatibility', () => {
121
- try {
122
- resolveVersion('5.0.0');
123
- expect.fail('Should have thrown VersionError');
124
- } catch (error) {
125
- expect(error).toBeInstanceOf(VersionError);
126
- const versionError = error as VersionError;
127
- expect(versionError.type).toBe('major-incompatibility');
128
- expect(versionError.requestedVersion).toBe('5.0.0');
129
- expect(versionError.latestVersion).toBe('4.0.9');
130
- }
131
- });
132
-
133
- it('should include correct error type for invalid version', () => {
134
- try {
135
- resolveVersion('invalid');
136
- expect.fail('Should have thrown VersionError');
137
- } catch (error) {
138
- expect(error).toBeInstanceOf(VersionError);
139
- expect((error as VersionError).type).toBe('invalid-version');
140
- }
141
- });
142
- });
143
-
144
- describe('version comparison logic', () => {
145
- it('should correctly identify latest version', () => {
146
- const result = resolveVersion('4.0.9');
147
- expect(result.isLatest).toBe(true);
148
- });
149
-
150
- it('should correctly identify non-latest version', () => {
151
- const result = resolveVersion('4.0.8');
152
- expect(result.isLatest).toBe(false);
153
- });
154
-
155
- it('should correctly identify satisfying version', () => {
156
- const result = resolveVersion('4.1.0');
157
- expect(result.satisfiesLatest).toBe(true);
158
- });
159
-
160
- it('should correctly identify non-satisfying version', () => {
161
- expect(() => resolveVersion('5.0.0')).toThrow();
162
- });
163
-
164
- it('should throw error for major versions without enum values', () => {
165
- // Version 3.0.0 should throw because there's no enum for major version 3
166
- expect(() => resolveVersion('3.0.0')).toThrow(VersionError);
167
- });
168
- });
169
-
170
- describe('warning behavior', () => {
171
- it('should warn on minor version mismatch', () => {
172
- const result = resolveVersion('4.1.0');
173
-
174
- expect(result.warnings).toBeDefined();
175
- expect(result.warnings).toHaveLength(1);
176
- expect(result.warnings?.[0]).toContain('Minor version mismatch');
177
- });
178
-
179
- it('should not warn on patch version differences', () => {
180
- const result = resolveVersion('4.0.8');
181
-
182
- expect(result.warnings).toBeUndefined();
183
- });
184
-
185
- it('should not warn on exact version match', () => {
186
- const result = resolveVersion('4.0.9');
187
-
188
- expect(result.warnings).toBeUndefined();
189
- });
190
-
191
- it('should warn with correct version information', () => {
192
- const result = resolveVersion('4.2.0');
193
-
194
- expect(result.warnings).toBeDefined();
195
- expect(result.warnings).toHaveLength(1);
196
- expect(result.warnings?.[0]).toContain('4.2.0');
197
- expect(result.warnings?.[0]).toContain('4.0.9');
133
+ expect(() => resolveVersion('4')).not.toThrow();
198
134
  });
199
135
  });
200
136
 
201
137
  describe('edge cases', () => {
202
- it('should handle version with pre-release identifiers (coerce strips them)', () => {
203
- const result = resolveVersion('4.0.9-beta.1');
204
-
205
- expect(result.satisfiesLatest).toBe(true);
206
- expect(result.wantedVersion.version).toBe('4.0.9'); // coerce strips pre-release
207
- });
208
-
209
- it('should handle version with build metadata (coerce strips them)', () => {
210
- const result = resolveVersion('4.0.9+build.123');
211
-
212
- expect(result.satisfiesLatest).toBe(true);
213
- expect(result.wantedVersion.version).toBe('4.0.9'); // coerce strips build metadata
214
- });
215
-
216
- it('should handle very long version strings (coerce strips them)', () => {
217
- const longVersion = '4.0.9-beta.1.alpha.2+build.123.456';
218
- const result = resolveVersion(longVersion);
219
-
220
- expect(result.satisfiesLatest).toBe(true);
221
- expect(result.wantedVersion.version).toBe('4.0.9'); // coerce strips pre-release and build
222
- });
223
-
224
- it('should throw error for zero versions without enum values', () => {
225
- // Version 0.0.0 should throw because there's no enum for major version 0
226
- expect(() => resolveVersion('0.0.0')).toThrow(VersionError);
227
- });
228
- });
229
-
230
- describe('return value structure', () => {
231
- it('should return object with all required properties', () => {
232
- const result = resolveVersion('2.1.0');
233
-
234
- expect(result).toHaveProperty('wantedVersion');
235
- expect(result).toHaveProperty('latestVersion');
236
- expect(result).toHaveProperty('isLatest');
237
- expect(result).toHaveProperty('satisfiesLatest');
238
- expect(result).toHaveProperty('enumVersion');
239
-
240
- expect(typeof result.isLatest).toBe('boolean');
241
- expect(typeof result.satisfiesLatest).toBe('boolean');
242
- expect(result.wantedVersion).toBeInstanceOf(SemVer);
243
- expect(result.latestVersion).toBeInstanceOf(SemVer);
244
- expect(typeof result.enumVersion).toBe('string');
138
+ it('should handle complex version strings with pre-release and build metadata', () => {
139
+ const testCases = [
140
+ { input: '4.0.9-beta.1', expected: '4.0.9' },
141
+ { input: '4.0.9+build.123', expected: '4.0.9' },
142
+ { input: '4.0.9-beta.1.alpha.2+build.123.456', expected: '4.0.9' },
143
+ ];
144
+
145
+ testCases.forEach(({ input, expected }) => {
146
+ const result = resolveVersion(input);
147
+ expect(result.satisfiesLatest).toBe(true);
148
+ expect(result.wantedVersion.version).toBe(expected);
149
+ });
245
150
  });
246
151
 
247
- it('should have consistent latest version across calls', () => {
152
+ it('should return consistent structure across calls', () => {
248
153
  const result1 = resolveVersion('2.0.0');
249
154
  const result2 = resolveVersion('4.0.0');
250
155
 
156
+ // Latest version should be consistent
251
157
  expect(result1.latestVersion.version).toBe(result2.latestVersion.version);
252
158
  expect(result1.latestVersion.version).toBe('4.0.9');
159
+
160
+ // Structure should be consistent
161
+ expect(result1).toHaveProperty('wantedVersion');
162
+ expect(result1).toHaveProperty('latestVersion');
163
+ expect(result1).toHaveProperty('isLatest');
164
+ expect(result1).toHaveProperty('satisfiesLatest');
165
+ expect(result1).toHaveProperty('enumVersion');
166
+
167
+ expect(result1.wantedVersion).toBeInstanceOf(SemVer);
168
+ expect(result1.latestVersion).toBeInstanceOf(SemVer);
169
+ expect(typeof result1.isLatest).toBe('boolean');
170
+ expect(typeof result1.satisfiesLatest).toBe('boolean');
171
+ expect(typeof result1.enumVersion).toBe('string');
253
172
  });
254
173
  });
255
174
  });
@@ -27,7 +27,7 @@ export class ConsoleLogger extends Logger {
27
27
  /** @inheritdoc */
28
28
  protected loggerCallback(lvl: LogLevel, msg: string, _containsPii?: boolean): void {
29
29
  console[this.getLogType(lvl)](
30
- `%c FUSION::MSAL %c %s`,
30
+ '%c FUSION::MSAL %c %s',
31
31
  'border: 1px solid;',
32
32
  'border: none;',
33
33
  msg,
@@ -17,6 +17,8 @@ export interface IAuthProvider {
17
17
  readonly defaultConfig: any | undefined;
18
18
  readonly defaultAccount: AccountInfo | undefined;
19
19
 
20
+ readonly client: AuthClient;
21
+
20
22
  /**
21
23
  * Acquire token from default auth client
22
24
  * @param req Auth request options
@@ -52,13 +54,8 @@ export class AuthProvider implements IAuthProvider, IProxyProvider {
52
54
  return new SemanticVersion(MsalModuleVersion.Latest);
53
55
  }
54
56
 
55
- /** @deprecated */
56
- get defaultClient(): AuthClient {
57
- return this.getClient();
58
- }
59
-
60
57
  get defaultAccount(): AccountInfo | undefined {
61
- return this.defaultClient.account;
58
+ return this.client.account;
62
59
  }
63
60
 
64
61
  /** @deprecated */
@@ -70,8 +67,7 @@ export class AuthProvider implements IAuthProvider, IProxyProvider {
70
67
  this.#client = this.createClient();
71
68
  }
72
69
 
73
- /** @deprecated */
74
- getClient(): AuthClient {
70
+ get client(): AuthClient {
75
71
  return this.#client;
76
72
  }
77
73
 
@@ -91,11 +87,10 @@ export class AuthProvider implements IAuthProvider, IProxyProvider {
91
87
  async handleRedirect() {
92
88
  const { redirectUri } = this.defaultConfig || {};
93
89
  if (window.location.pathname === redirectUri) {
94
- const client = this.defaultClient;
95
- const logger = client.getLogger();
96
- const { requestOrigin } = client;
90
+ const logger = this.client.getLogger();
91
+ const { requestOrigin } = this.client;
97
92
 
98
- await client.handleRedirectPromise();
93
+ await this.client.handleRedirectPromise();
99
94
  if (requestOrigin === redirectUri) {
100
95
  logger.warning(`detected callback loop from url ${redirectUri}, redirecting to root`);
101
96
  window.location.replace('/');
@@ -107,7 +102,7 @@ export class AuthProvider implements IAuthProvider, IProxyProvider {
107
102
  }
108
103
 
109
104
  acquireToken(req: AuthRequest): ReturnType<IAuthProvider['acquireToken']> {
110
- return this.defaultClient.acquireToken(req);
105
+ return this.client.acquireToken(req);
111
106
  }
112
107
 
113
108
  async acquireAccessToken(req: AuthRequest) {
@@ -117,15 +112,15 @@ export class AuthProvider implements IAuthProvider, IProxyProvider {
117
112
 
118
113
  async login(options?: { onlyIfRequired?: boolean }) {
119
114
  // skip login if already logged in and has valid claims
120
- if (options?.onlyIfRequired && this.defaultClient.hasValidClaims) {
115
+ if (options?.onlyIfRequired && this.client.hasValidClaims) {
121
116
  return;
122
117
  }
123
- await this.defaultClient.login();
118
+ await this.client.login();
124
119
  }
125
120
 
126
121
  async logout(options?: { redirectUri?: string }): Promise<void> {
127
122
  // TODO - might have an option for popup or redirect
128
- await this.defaultClient.logoutRedirect({
123
+ await this.client.logoutRedirect({
129
124
  postLogoutRedirectUri: options?.redirectUri,
130
125
  account: this.defaultAccount,
131
126
  });
@@ -145,10 +140,16 @@ export class AuthProvider implements IAuthProvider, IProxyProvider {
145
140
 
146
141
  _createProxyProvider_v2(): IAuthProvider {
147
142
  return new Proxy(this, {
148
- get: (target: AuthProvider, prop) => {
143
+ get: (target: AuthProvider, prop: keyof AuthProvider) => {
149
144
  switch (prop) {
150
145
  case 'version':
151
146
  return target.version;
147
+ case 'client':
148
+ return target.client;
149
+ // @ts-expect-error - this is deprecated since version 5.0.1
150
+ case 'defaultClient':
151
+ console.warn('defaultClient is deprecated, use client instead');
152
+ return target.client;
152
153
  case 'defaultAccount':
153
154
  return target.defaultAccount;
154
155
  case 'defaultConfig':
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '5.0.0';
2
+ export const version = '5.1.0';
@@ -1,33 +1,5 @@
1
- import { VersionMessageType } from './static';
2
- import { createVersionMessage } from './create-version-message';
3
1
  import type { SemVer } from 'semver';
4
2
 
5
- /**
6
- * Creates a VersionError instance with a formatted message.
7
- *
8
- * This is a helper function that creates a VersionError with a human-readable
9
- * message based on the error type and version information.
10
- *
11
- * @param type - The type of version error
12
- * @param requestedVersion - The version that was requested
13
- * @param latestVersion - The latest available version
14
- * @param options - Additional error options including the error type
15
- * @returns A new VersionError instance with formatted message
16
- */
17
- const createVersionError = (
18
- type: VersionMessageType,
19
- requestedVersion: string | SemVer,
20
- latestVersion: string | SemVer,
21
- options?: ErrorOptions & { type?: VersionMessageType },
22
- ): VersionError => {
23
- return new VersionError(
24
- createVersionMessage(type, requestedVersion, latestVersion),
25
- requestedVersion,
26
- latestVersion,
27
- { ...options, type },
28
- );
29
- };
30
-
31
3
  /**
32
4
  * Error class for version-related issues in the MSAL module.
33
5
  *
@@ -65,18 +37,9 @@ export class VersionError extends Error {
65
37
  /** The latest available version in the system */
66
38
  public readonly latestVersion: string;
67
39
 
68
- /** The specific type of version error that occurred */
69
- public readonly type?: VersionMessageType;
70
-
71
40
  /** The error name for instanceof checks */
72
41
  static Name = 'VersionError';
73
42
 
74
- /** Reference to the VersionMessageType enum for convenience */
75
- static Type = VersionMessageType;
76
-
77
- /** Factory method for creating VersionError instances with formatted messages */
78
- static create: typeof createVersionError = createVersionError;
79
-
80
43
  /**
81
44
  * Creates a new VersionError instance.
82
45
  *
@@ -89,7 +52,7 @@ export class VersionError extends Error {
89
52
  message: string,
90
53
  requestedVersion: string | SemVer,
91
54
  latestVersion: string | SemVer,
92
- options?: ErrorOptions & { type?: VersionMessageType },
55
+ options?: ErrorOptions,
93
56
  ) {
94
57
  super(message, options);
95
58
  this.name = VersionError.Name;
@@ -97,7 +60,5 @@ export class VersionError extends Error {
97
60
  // Store versions as strings
98
61
  this.requestedVersion = String(requestedVersion);
99
62
  this.latestVersion = String(latestVersion);
100
-
101
- this.type = options?.type;
102
63
  }
103
64
  }