@equinor/fusion-framework-vite-plugin-spa 3.1.4 → 3.1.6
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 +14 -0
- package/dist/esm/version.js +1 -1
- package/dist/html/bootstrap.js +99 -14
- package/dist/html/bootstrap.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/html/index.html.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @equinor/fusion-framework-vite-plugin-spa
|
|
2
2
|
|
|
3
|
+
## 3.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`0b34d5d`](https://github.com/equinor/fusion-framework/commit/0b34d5d895c740a77fc995abeca910fdca1cf633)]:
|
|
8
|
+
- @equinor/fusion-framework-module-msal@7.1.0
|
|
9
|
+
|
|
10
|
+
## 3.1.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`21458e5`](https://github.com/equinor/fusion-framework/commit/21458e5e7585f0bf266c66d6f4135396fd7c1529)]:
|
|
15
|
+
- @equinor/fusion-framework-module-telemetry@4.6.3
|
|
16
|
+
|
|
3
17
|
## 3.1.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/esm/version.js
CHANGED
package/dist/html/bootstrap.js
CHANGED
|
@@ -153,8 +153,8 @@ function requireRe () {
|
|
|
153
153
|
|
|
154
154
|
// ## Pre-release Version Identifier
|
|
155
155
|
// A numeric identifier, or a non-numeric identifier.
|
|
156
|
-
// Non-
|
|
157
|
-
// Therefore non-
|
|
156
|
+
// Non-numeric identifiers include numeric identifiers but can be longer.
|
|
157
|
+
// Therefore non-numeric identifiers must go first.
|
|
158
158
|
|
|
159
159
|
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
|
|
160
160
|
}|${src[t.NUMERICIDENTIFIER]})`);
|
|
@@ -850,7 +850,7 @@ function requireDiff () {
|
|
|
850
850
|
return prefix + 'patch'
|
|
851
851
|
}
|
|
852
852
|
|
|
853
|
-
// high and low are
|
|
853
|
+
// high and low are prereleases
|
|
854
854
|
return 'prerelease'
|
|
855
855
|
};
|
|
856
856
|
|
|
@@ -2409,7 +2409,7 @@ function requireSubset () {
|
|
|
2409
2409
|
// - If LT
|
|
2410
2410
|
// - If LT.semver is greater than any < or <= comp in C, return false
|
|
2411
2411
|
// - If LT is <=, and LT.semver does not satisfy every C, return false
|
|
2412
|
-
// - If
|
|
2412
|
+
// - If LT.semver has a prerelease, and not in prerelease mode
|
|
2413
2413
|
// - If no C has a prerelease and the LT.semver tuple, return false
|
|
2414
2414
|
// - Else return true
|
|
2415
2415
|
|
|
@@ -8043,7 +8043,7 @@ class Doc {
|
|
|
8043
8043
|
const version$7 = {
|
|
8044
8044
|
major: 4,
|
|
8045
8045
|
minor: 3,
|
|
8046
|
-
patch:
|
|
8046
|
+
patch: 6,
|
|
8047
8047
|
};
|
|
8048
8048
|
|
|
8049
8049
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
@@ -9405,11 +9405,9 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
|
|
|
9405
9405
|
if (keyResult instanceof Promise) {
|
|
9406
9406
|
throw new Error("Async schemas not supported in object keys currently");
|
|
9407
9407
|
}
|
|
9408
|
-
// Numeric string fallback: if key
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
keyResult.issues.length &&
|
|
9412
|
-
keyResult.issues.some((iss) => iss.code === "invalid_type" && iss.expected === "number");
|
|
9408
|
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
9409
|
+
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
9410
|
+
const checkNumericKey = typeof key === "string" && number$2.test(key) && keyResult.issues.length;
|
|
9413
9411
|
if (checkNumericKey) {
|
|
9414
9412
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
9415
9413
|
if (retryResult instanceof Promise) {
|
|
@@ -17062,7 +17060,7 @@ function finalize$1(ctx, schema) {
|
|
|
17062
17060
|
}
|
|
17063
17061
|
}
|
|
17064
17062
|
// When ref was extracted to $defs, remove properties that match the definition
|
|
17065
|
-
if (refSchema.$ref) {
|
|
17063
|
+
if (refSchema.$ref && refSeen.def) {
|
|
17066
17064
|
for (const key in schema) {
|
|
17067
17065
|
if (key === "$ref" || key === "allOf")
|
|
17068
17066
|
continue;
|
|
@@ -23160,7 +23158,7 @@ class TelemetryConfigurator extends BaseConfigBuilder {
|
|
|
23160
23158
|
}
|
|
23161
23159
|
|
|
23162
23160
|
// Generated by genversion.
|
|
23163
|
-
const version$5 = '4.6.
|
|
23161
|
+
const version$5 = '4.6.3';
|
|
23164
23162
|
|
|
23165
23163
|
/**
|
|
23166
23164
|
* Enum representing the severity levels of telemetry items.
|
|
@@ -40465,7 +40463,7 @@ const createClientLogCallback = (provider, metadata, scope) => {
|
|
|
40465
40463
|
};
|
|
40466
40464
|
|
|
40467
40465
|
// Generated by genversion.
|
|
40468
|
-
const version$2 = '7.
|
|
40466
|
+
const version$2 = '7.1.0';
|
|
40469
40467
|
|
|
40470
40468
|
/**
|
|
40471
40469
|
* Zod schema for telemetry configuration validation.
|
|
@@ -40490,6 +40488,7 @@ const MsalConfigSchema = z.object({
|
|
|
40490
40488
|
provider: z.custom().optional(),
|
|
40491
40489
|
requiresAuth: z.boolean().optional(),
|
|
40492
40490
|
redirectUri: z.string().optional(),
|
|
40491
|
+
authCode: z.string().optional(),
|
|
40493
40492
|
version: z.string().transform((x) => String(semver.coerce(x))),
|
|
40494
40493
|
telemetry: TelemetryConfigSchema,
|
|
40495
40494
|
});
|
|
@@ -40557,6 +40556,37 @@ class MsalConfigurator extends BaseConfigBuilder {
|
|
|
40557
40556
|
this.#msalConfig = config;
|
|
40558
40557
|
return this;
|
|
40559
40558
|
}
|
|
40559
|
+
/**
|
|
40560
|
+
* Sets a backend-issued authorization code for token exchange.
|
|
40561
|
+
*
|
|
40562
|
+
* This enables the MSAL module to exchange a backend-generated auth code for tokens
|
|
40563
|
+
* during initialization, allowing users to be automatically signed in without triggering
|
|
40564
|
+
* an interactive MSAL login flow. The auth code is exchanged before the requiresAuth check,
|
|
40565
|
+
* so tokens are cached and no login prompt appears.
|
|
40566
|
+
*
|
|
40567
|
+
* This follows Microsoft's standard SPA Auth Code Flow pattern and is compatible with
|
|
40568
|
+
* MSAL Browser's acquireTokenByCode() method.
|
|
40569
|
+
*
|
|
40570
|
+
* @param authCode - The authorization code issued by the backend
|
|
40571
|
+
* @returns The configurator instance for method chaining
|
|
40572
|
+
*
|
|
40573
|
+
* @example
|
|
40574
|
+
* ```typescript
|
|
40575
|
+
* // Backend provides auth code in HTML/config
|
|
40576
|
+
* const config = { auth: { code: getAuthCodeFromBackend() } };
|
|
40577
|
+
* configurator.setAuthCode(config.auth.code);
|
|
40578
|
+
* ```
|
|
40579
|
+
*
|
|
40580
|
+
* @remarks
|
|
40581
|
+
* - Auth codes are single-use and short-lived (typically 5-10 minutes)
|
|
40582
|
+
* - The exchange happens during module initialization before requiresAuth check
|
|
40583
|
+
* - If exchange fails, the provider falls back to standard MSAL authentication flows
|
|
40584
|
+
* - Requires backend to be configured with SPA Auth Code support
|
|
40585
|
+
*/
|
|
40586
|
+
setAuthCode(authCode) {
|
|
40587
|
+
this._set('authCode', async () => authCode);
|
|
40588
|
+
return this;
|
|
40589
|
+
}
|
|
40560
40590
|
/**
|
|
40561
40591
|
* Sets whether authentication is required for the application.
|
|
40562
40592
|
*
|
|
@@ -41443,6 +41473,7 @@ class MsalProvider extends BaseModuleProvider {
|
|
|
41443
41473
|
#client;
|
|
41444
41474
|
#telemetry;
|
|
41445
41475
|
#requiresAuth;
|
|
41476
|
+
#authCode;
|
|
41446
41477
|
/**
|
|
41447
41478
|
* The MSAL module version enum value indicating the API compatibility level.
|
|
41448
41479
|
*
|
|
@@ -41500,6 +41531,9 @@ class MsalProvider extends BaseModuleProvider {
|
|
|
41500
41531
|
});
|
|
41501
41532
|
this.#requiresAuth = config.requiresAuth;
|
|
41502
41533
|
this.#telemetry = config.telemetry;
|
|
41534
|
+
// Extract auth code from config if present
|
|
41535
|
+
// This will be used during initialize to exchange for tokens
|
|
41536
|
+
this.#authCode = config.authCode;
|
|
41503
41537
|
// Validate required client configuration
|
|
41504
41538
|
if (!config.client) {
|
|
41505
41539
|
const error = new Error('Client is required, please provide a valid client in the configuration');
|
|
@@ -41515,12 +41549,17 @@ class MsalProvider extends BaseModuleProvider {
|
|
|
41515
41549
|
*
|
|
41516
41550
|
* This method must be called before using any authentication operations. It performs:
|
|
41517
41551
|
* - Client initialization
|
|
41552
|
+
* - Auth code exchange (if backend-issued code provided)
|
|
41518
41553
|
* - Redirect result handling (if returning from auth flow)
|
|
41519
41554
|
* - Automatic login attempt if requiresAuth is enabled and no valid session exists
|
|
41520
41555
|
*
|
|
41521
41556
|
* @returns Promise that resolves when initialization is complete
|
|
41522
41557
|
*
|
|
41523
41558
|
* @remarks
|
|
41559
|
+
* Auth code exchange happens before the requiresAuth check, allowing automatic sign-in
|
|
41560
|
+
* without user interaction when a valid backend-issued code is provided. If exchange fails,
|
|
41561
|
+
* the provider falls back to standard MSAL authentication flows.
|
|
41562
|
+
*
|
|
41524
41563
|
* The provider will attempt automatic login with empty scopes if requiresAuth is true.
|
|
41525
41564
|
* Apps should call acquireToken with actual scopes after initialization completes.
|
|
41526
41565
|
*/
|
|
@@ -41528,6 +41567,52 @@ class MsalProvider extends BaseModuleProvider {
|
|
|
41528
41567
|
const measurement = this._trackMeasurement('initialize', TelemetryLevel.Debug);
|
|
41529
41568
|
// Initialize the underlying MSAL client first
|
|
41530
41569
|
await this.#client.initialize();
|
|
41570
|
+
// Priority 0: Exchange auth code if provided by backend
|
|
41571
|
+
// This must happen before the requiresAuth check so tokens are cached
|
|
41572
|
+
if (this.#authCode) {
|
|
41573
|
+
try {
|
|
41574
|
+
this._trackEvent('initialize.exchanging-auth-code', TelemetryLevel.Information);
|
|
41575
|
+
// Use MSAL's acquireTokenByCode to exchange backend auth code for tokens
|
|
41576
|
+
// This follows Microsoft's standard SPA Auth Code Flow pattern
|
|
41577
|
+
const clientId = this.#client.clientId;
|
|
41578
|
+
if (!clientId) {
|
|
41579
|
+
throw new Error('Client ID is required for auth code exchange');
|
|
41580
|
+
}
|
|
41581
|
+
// Exchange the auth code for tokens using the client ID's default scope.
|
|
41582
|
+
// The `/.default` scope represents all permissions configured for this app in Entra ID,
|
|
41583
|
+
// ensuring the exchanged tokens have the correct app-level permissions without requiring
|
|
41584
|
+
// the caller to specify scopes. This follows MSAL's recommended SPA auth code pattern.
|
|
41585
|
+
// This method is inherited from PublicClientApplication (MSAL Browser v4+)
|
|
41586
|
+
const result = await this.#client.acquireTokenByCode({
|
|
41587
|
+
code: this.#authCode,
|
|
41588
|
+
scopes: [`${clientId}/.default`],
|
|
41589
|
+
});
|
|
41590
|
+
// Successfully exchanged auth code - set active account
|
|
41591
|
+
if (result.account) {
|
|
41592
|
+
this.#client.setActiveAccount(result.account);
|
|
41593
|
+
this._trackEvent('initialize.auth-code-exchanged-account', TelemetryLevel.Information, {
|
|
41594
|
+
properties: {
|
|
41595
|
+
username: result.account.username,
|
|
41596
|
+
},
|
|
41597
|
+
});
|
|
41598
|
+
}
|
|
41599
|
+
}
|
|
41600
|
+
catch (error) {
|
|
41601
|
+
// Auth code exchange failed - log and fall back to standard flows
|
|
41602
|
+
this._trackException('initialize.auth-code-exchange-failed', TelemetryLevel.Warning, {
|
|
41603
|
+
exception: error instanceof Error ? error : new Error(String(error)),
|
|
41604
|
+
properties: {
|
|
41605
|
+
message: error instanceof Error ? error.message : String(error),
|
|
41606
|
+
reason: 'Auth code exchange failed, falling back to standard authentication flows',
|
|
41607
|
+
},
|
|
41608
|
+
});
|
|
41609
|
+
// Continue to requiresAuth check - will trigger standard login if needed
|
|
41610
|
+
}
|
|
41611
|
+
finally {
|
|
41612
|
+
// Clear auth code to avoid repeated attempts
|
|
41613
|
+
this.#authCode = undefined;
|
|
41614
|
+
}
|
|
41615
|
+
}
|
|
41531
41616
|
// Only attempt authentication if this provider requires it
|
|
41532
41617
|
if (this.#requiresAuth) {
|
|
41533
41618
|
// Priority 1: Check if returning from redirect-based authentication
|
|
@@ -44820,7 +44905,7 @@ async function registerServiceWorker(framework) {
|
|
|
44820
44905
|
}
|
|
44821
44906
|
|
|
44822
44907
|
// Generated by genversion.
|
|
44823
|
-
const version = '3.1.
|
|
44908
|
+
const version = '3.1.6';
|
|
44824
44909
|
|
|
44825
44910
|
// Allow dynamic import without vite
|
|
44826
44911
|
const importWithoutVite = (path) => import(/* @vite-ignore */ path);
|