@volley/vwr-loader 1.5.0 → 1.7.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/dist/cli.js +84 -24
- package/dist/cli.js.map +1 -1
- package/dist/{datadog.d.ts → vwr/src/datadog.d.ts} +7 -3
- package/dist/vwr/src/datadog.d.ts.map +1 -0
- package/dist/{datadog.js → vwr/src/datadog.js} +6 -5
- package/dist/vwr/src/datadog.js.map +1 -0
- package/dist/{envDefaults.d.ts → vwr/src/envDefaults.d.ts} +1 -0
- package/dist/vwr/src/envDefaults.d.ts.map +1 -0
- package/dist/vwr/src/envDefaults.js +67 -0
- package/dist/vwr/src/envDefaults.js.map +1 -0
- package/dist/vwr/src/iframe.d.ts +25 -0
- package/dist/vwr/src/iframe.d.ts.map +1 -0
- package/dist/vwr/src/iframe.js +82 -0
- package/dist/vwr/src/iframe.js.map +1 -0
- package/dist/vwr/src/logger.d.ts +15 -0
- package/dist/vwr/src/logger.d.ts.map +1 -0
- package/dist/{logger.js → vwr/src/logger.js} +30 -46
- package/dist/vwr/src/logger.js.map +1 -0
- package/dist/vwr/src/native/app-lifecycle/factory.d.ts +7 -0
- package/dist/vwr/src/native/app-lifecycle/factory.d.ts.map +1 -0
- package/dist/vwr/src/native/app-lifecycle/factory.js +68 -0
- package/dist/vwr/src/native/app-lifecycle/factory.js.map +1 -0
- package/dist/vwr/src/native/app-lifecycle/rpc.d.ts +15 -0
- package/dist/vwr/src/native/app-lifecycle/rpc.d.ts.map +1 -0
- package/dist/vwr/src/native/app-lifecycle/rpc.js +46 -0
- package/dist/vwr/src/native/app-lifecycle/rpc.js.map +1 -0
- package/dist/vwr/src/native/capacitor-bridge/rpc.d.ts +33 -0
- package/dist/vwr/src/native/capacitor-bridge/rpc.d.ts.map +1 -0
- package/dist/vwr/src/native/capacitor-bridge/rpc.js +129 -0
- package/dist/vwr/src/native/capacitor-bridge/rpc.js.map +1 -0
- package/dist/vwr/src/native/device-info/factory.d.ts +9 -0
- package/dist/vwr/src/native/device-info/factory.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/factory.js +28 -0
- package/dist/vwr/src/native/device-info/factory.js.map +1 -0
- package/dist/vwr/src/native/device-info/firetvCollector.d.ts +9 -0
- package/dist/vwr/src/native/device-info/firetvCollector.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/firetvCollector.js +180 -0
- package/dist/vwr/src/native/device-info/firetvCollector.js.map +1 -0
- package/dist/vwr/src/native/device-info/getDeviceId.d.ts +13 -0
- package/dist/vwr/src/native/device-info/getDeviceId.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/getDeviceId.js +137 -0
- package/dist/vwr/src/native/device-info/getDeviceId.js.map +1 -0
- package/dist/vwr/src/native/device-info/lgCollector.d.ts +8 -0
- package/dist/vwr/src/native/device-info/lgCollector.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/lgCollector.js +136 -0
- package/dist/vwr/src/native/device-info/lgCollector.js.map +1 -0
- package/dist/vwr/src/native/device-info/mobileCollector.d.ts +9 -0
- package/dist/vwr/src/native/device-info/mobileCollector.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/mobileCollector.js +47 -0
- package/dist/vwr/src/native/device-info/mobileCollector.js.map +1 -0
- package/dist/vwr/src/native/device-info/rpc.d.ts +51 -0
- package/dist/vwr/src/native/device-info/rpc.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/rpc.js +46 -0
- package/dist/vwr/src/native/device-info/rpc.js.map +1 -0
- package/dist/vwr/src/native/device-info/samsungCollector.d.ts +9 -0
- package/dist/vwr/src/native/device-info/samsungCollector.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/samsungCollector.js +86 -0
- package/dist/vwr/src/native/device-info/samsungCollector.js.map +1 -0
- package/dist/vwr/src/native/device-info/webCollector.d.ts +4 -0
- package/dist/vwr/src/native/device-info/webCollector.d.ts.map +1 -0
- package/dist/vwr/src/native/device-info/webCollector.js +56 -0
- package/dist/vwr/src/native/device-info/webCollector.js.map +1 -0
- package/dist/vwr/src/native/native-bridge/rpc.d.ts +33 -0
- package/dist/vwr/src/native/native-bridge/rpc.d.ts.map +1 -0
- package/dist/vwr/src/native/native-bridge/rpc.js +114 -0
- package/dist/vwr/src/native/native-bridge/rpc.js.map +1 -0
- package/dist/vwr/src/native/screensaver-prevention/LGLunaService.d.ts +14 -0
- package/dist/vwr/src/native/screensaver-prevention/LGLunaService.d.ts.map +1 -0
- package/dist/vwr/src/native/screensaver-prevention/LGLunaService.js +187 -0
- package/dist/vwr/src/native/screensaver-prevention/LGLunaService.js.map +1 -0
- package/dist/vwr/src/native/screensaver-prevention/rpc.d.ts +27 -0
- package/dist/vwr/src/native/screensaver-prevention/rpc.d.ts.map +1 -0
- package/dist/vwr/src/native/screensaver-prevention/rpc.js +71 -0
- package/dist/vwr/src/native/screensaver-prevention/rpc.js.map +1 -0
- package/dist/vwr/src/observability.d.ts +35 -0
- package/dist/vwr/src/observability.d.ts.map +1 -0
- package/dist/vwr/src/observability.js +68 -0
- package/dist/vwr/src/observability.js.map +1 -0
- package/dist/vwr/src/shellEnvDefaults.d.ts +15 -0
- package/dist/vwr/src/shellEnvDefaults.d.ts.map +1 -0
- package/dist/vwr/src/shellEnvDefaults.js +34 -0
- package/dist/vwr/src/shellEnvDefaults.js.map +1 -0
- package/dist/vwr/src/types.d.ts +56 -0
- package/dist/vwr/src/types.d.ts.map +1 -0
- package/dist/vwr/src/types.js +27 -0
- package/dist/vwr/src/types.js.map +1 -0
- package/dist/vwr/src/urlUtils.d.ts +17 -0
- package/dist/vwr/src/urlUtils.d.ts.map +1 -0
- package/dist/vwr/src/urlUtils.js +42 -0
- package/dist/vwr/src/urlUtils.js.map +1 -0
- package/dist/vwr/src/vwrBootstrap.d.ts +26 -0
- package/dist/vwr/src/vwrBootstrap.d.ts.map +1 -0
- package/dist/vwr/src/vwrBootstrap.js +176 -0
- package/dist/vwr/src/vwrBootstrap.js.map +1 -0
- package/dist/{vwrConfig.d.ts → vwr/src/vwrConfig.d.ts} +5 -0
- package/dist/vwr/src/vwrConfig.d.ts.map +1 -0
- package/dist/{vwrConfig.js → vwr/src/vwrConfig.js} +24 -7
- package/dist/vwr/src/vwrConfig.js.map +1 -0
- package/{src → dist/vwr-loader}/index.html +1 -1
- package/dist/vwr-loader/src/__mocks__/@datadog/browser-logs.d.ts.map +1 -0
- package/dist/vwr-loader/src/__mocks__/@datadog/browser-logs.js.map +1 -0
- package/dist/vwr-loader/src/__mocks__/@datadog/browser-rum.d.ts.map +1 -0
- package/dist/vwr-loader/src/__mocks__/@datadog/browser-rum.js.map +1 -0
- package/dist/vwr-loader/src/__mocks__/invalidVwrModule.d.ts +2 -0
- package/dist/vwr-loader/src/__mocks__/invalidVwrModule.d.ts.map +1 -0
- package/dist/vwr-loader/src/__mocks__/invalidVwrModule.js +2 -0
- package/dist/vwr-loader/src/__mocks__/invalidVwrModule.js.map +1 -0
- package/dist/vwr-loader/src/__mocks__/vwrModule.d.ts.map +1 -0
- package/dist/vwr-loader/src/__mocks__/vwrModule.js.map +1 -0
- package/dist/vwr-loader/src/amplitudeFlagFetcher.d.ts.map +1 -0
- package/dist/vwr-loader/src/amplitudeFlagFetcher.js.map +1 -0
- package/dist/vwr-loader/src/errors/InitializationError.d.ts.map +1 -0
- package/dist/vwr-loader/src/errors/InitializationError.js.map +1 -0
- package/dist/vwr-loader/src/errors/ensureError.d.ts.map +1 -0
- package/dist/vwr-loader/src/errors/ensureError.js.map +1 -0
- package/dist/vwr-loader/src/errors/index.d.ts.map +1 -0
- package/dist/vwr-loader/src/errors/index.js.map +1 -0
- package/dist/vwr-loader/src/exitHandler.d.ts.map +1 -0
- package/dist/{exitHandler.js → vwr-loader/src/exitHandler.js} +2 -3
- package/dist/vwr-loader/src/exitHandler.js.map +1 -0
- package/dist/vwr-loader/src/getEnvironment.d.ts.map +1 -0
- package/dist/vwr-loader/src/getEnvironment.js.map +1 -0
- package/dist/vwr-loader/src/getShellVersion.d.ts.map +1 -0
- package/dist/vwr-loader/src/getShellVersion.js.map +1 -0
- package/dist/vwr-loader/src/index.d.ts +8 -0
- package/dist/vwr-loader/src/index.d.ts.map +1 -0
- package/dist/vwr-loader/src/index.js +6 -0
- package/dist/vwr-loader/src/index.js.map +1 -0
- package/dist/vwr-loader/src/loadVwr.d.ts.map +1 -0
- package/dist/{loadVwr.js → vwr-loader/src/loadVwr.js} +36 -27
- package/dist/vwr-loader/src/loadVwr.js.map +1 -0
- package/dist/vwr-loader/src/logger.d.ts +4 -0
- package/dist/vwr-loader/src/logger.d.ts.map +1 -0
- package/dist/vwr-loader/src/logger.js +10 -0
- package/dist/vwr-loader/src/logger.js.map +1 -0
- package/dist/vwr-loader/src/main.d.ts +2 -0
- package/dist/vwr-loader/src/main.d.ts.map +1 -0
- package/dist/vwr-loader/src/main.js +96 -0
- package/dist/vwr-loader/src/main.js.map +1 -0
- package/dist/vwr-loader/src/polyfills.d.ts.map +1 -0
- package/dist/vwr-loader/src/polyfills.js.map +1 -0
- package/dist/{test-setup.d.ts.map → vwr-loader/src/test-setup.d.ts.map} +1 -1
- package/dist/vwr-loader/src/test-setup.js.map +1 -0
- package/package.json +13 -12
- package/dist/__mocks__/@datadog/browser-logs.d.ts.map +0 -1
- package/dist/__mocks__/@datadog/browser-logs.js.map +0 -1
- package/dist/__mocks__/@datadog/browser-rum.d.ts.map +0 -1
- package/dist/__mocks__/@datadog/browser-rum.js.map +0 -1
- package/dist/__mocks__/vwrModule.d.ts.map +0 -1
- package/dist/__mocks__/vwrModule.js.map +0 -1
- package/dist/amplitudeFlagFetcher.d.ts.map +0 -1
- package/dist/amplitudeFlagFetcher.js.map +0 -1
- package/dist/assets/profiler-BRmTNL9s.js +0 -2
- package/dist/assets/profiler-BRmTNL9s.js.map +0 -1
- package/dist/assets/startRecording-CuFdVhxx.js +0 -3
- package/dist/assets/startRecording-CuFdVhxx.js.map +0 -1
- package/dist/datadog.d.ts.map +0 -1
- package/dist/datadog.js.map +0 -1
- package/dist/envDefaults.d.ts.map +0 -1
- package/dist/envDefaults.js +0 -74
- package/dist/envDefaults.js.map +0 -1
- package/dist/errors/InitializationError.d.ts.map +0 -1
- package/dist/errors/InitializationError.js.map +0 -1
- package/dist/errors/ensureError.d.ts.map +0 -1
- package/dist/errors/ensureError.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/exitHandler.d.ts.map +0 -1
- package/dist/exitHandler.js.map +0 -1
- package/dist/getDeviceId.d.ts +0 -26
- package/dist/getDeviceId.d.ts.map +0 -1
- package/dist/getDeviceId.js +0 -209
- package/dist/getDeviceId.js.map +0 -1
- package/dist/getEnvironment.d.ts.map +0 -1
- package/dist/getEnvironment.js.map +0 -1
- package/dist/getShellVersion.d.ts.map +0 -1
- package/dist/getShellVersion.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.html +0 -25
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/loadVwr.d.ts.map +0 -1
- package/dist/loadVwr.js.map +0 -1
- package/dist/logger.d.ts +0 -12
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/main.js +0 -12
- package/dist/main.js.map +0 -1
- package/dist/polyfills.d.ts.map +0 -1
- package/dist/polyfills.js.map +0 -1
- package/dist/test-setup.js.map +0 -1
- package/dist/types.d.ts +0 -103
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/vwrConfig.d.ts.map +0 -1
- package/dist/vwrConfig.js.map +0 -1
- package/src/__mocks__/@datadog/browser-logs.ts +0 -35
- package/src/__mocks__/@datadog/browser-rum.ts +0 -27
- package/src/__mocks__/vwrModule.ts +0 -3
- package/src/amplitudeFlagFetcher.test.ts +0 -175
- package/src/amplitudeFlagFetcher.ts +0 -105
- package/src/datadog.ts +0 -55
- package/src/envDefaults.ts +0 -94
- package/src/errors/InitializationError.ts +0 -105
- package/src/errors/ensureError.ts +0 -6
- package/src/errors/index.ts +0 -16
- package/src/exitHandler.test.ts +0 -373
- package/src/exitHandler.ts +0 -232
- package/src/getDeviceId.test.ts +0 -298
- package/src/getDeviceId.ts +0 -224
- package/src/getEnvironment.test.ts +0 -417
- package/src/getEnvironment.ts +0 -144
- package/src/getShellVersion.test.ts +0 -403
- package/src/getShellVersion.ts +0 -132
- package/src/index.ts +0 -7
- package/src/loadVwr.test.ts +0 -549
- package/src/loadVwr.ts +0 -357
- package/src/logger.ts +0 -121
- package/src/main.test.ts +0 -157
- package/src/main.ts +0 -127
- package/src/polyfills.ts +0 -32
- package/src/test-setup.ts +0 -5
- package/src/types.ts +0 -105
- package/src/vite-env.d.ts +0 -32
- package/src/vwrConfig.test.ts +0 -386
- package/src/vwrConfig.ts +0 -374
- /package/dist/{__mocks__ → vwr-loader/src/__mocks__}/@datadog/browser-logs.d.ts +0 -0
- /package/dist/{__mocks__ → vwr-loader/src/__mocks__}/@datadog/browser-logs.js +0 -0
- /package/dist/{__mocks__ → vwr-loader/src/__mocks__}/@datadog/browser-rum.d.ts +0 -0
- /package/dist/{__mocks__ → vwr-loader/src/__mocks__}/@datadog/browser-rum.js +0 -0
- /package/dist/{__mocks__ → vwr-loader/src/__mocks__}/vwrModule.d.ts +0 -0
- /package/dist/{__mocks__ → vwr-loader/src/__mocks__}/vwrModule.js +0 -0
- /package/dist/{amplitudeFlagFetcher.d.ts → vwr-loader/src/amplitudeFlagFetcher.d.ts} +0 -0
- /package/dist/{amplitudeFlagFetcher.js → vwr-loader/src/amplitudeFlagFetcher.js} +0 -0
- /package/dist/{errors → vwr-loader/src/errors}/InitializationError.d.ts +0 -0
- /package/dist/{errors → vwr-loader/src/errors}/InitializationError.js +0 -0
- /package/dist/{errors → vwr-loader/src/errors}/ensureError.d.ts +0 -0
- /package/dist/{errors → vwr-loader/src/errors}/ensureError.js +0 -0
- /package/dist/{errors → vwr-loader/src/errors}/index.d.ts +0 -0
- /package/dist/{errors → vwr-loader/src/errors}/index.js +0 -0
- /package/dist/{exitHandler.d.ts → vwr-loader/src/exitHandler.d.ts} +0 -0
- /package/dist/{getEnvironment.d.ts → vwr-loader/src/getEnvironment.d.ts} +0 -0
- /package/dist/{getEnvironment.js → vwr-loader/src/getEnvironment.js} +0 -0
- /package/dist/{getShellVersion.d.ts → vwr-loader/src/getShellVersion.d.ts} +0 -0
- /package/dist/{getShellVersion.js → vwr-loader/src/getShellVersion.js} +0 -0
- /package/dist/{loadVwr.d.ts → vwr-loader/src/loadVwr.d.ts} +0 -0
- /package/dist/{polyfills.d.ts → vwr-loader/src/polyfills.d.ts} +0 -0
- /package/dist/{polyfills.js → vwr-loader/src/polyfills.js} +0 -0
- /package/dist/{test-setup.d.ts → vwr-loader/src/test-setup.d.ts} +0 -0
- /package/dist/{test-setup.js → vwr-loader/src/test-setup.js} +0 -0
package/src/vwrConfig.ts
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import type { ILogger } from "@volley/logger"
|
|
2
|
-
|
|
3
|
-
import { ENV_DEFAULTS } from "./envDefaults"
|
|
4
|
-
|
|
5
|
-
export type VWRConfig = {
|
|
6
|
-
hubUrl: string
|
|
7
|
-
vwrUrl: string
|
|
8
|
-
launchUrl: string | undefined
|
|
9
|
-
platformApiUrl: string
|
|
10
|
-
platformAuthApiUrl: string
|
|
11
|
-
trustedDomains: Array<string>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type VWRConfigRequest = {
|
|
15
|
-
configUrl: string
|
|
16
|
-
configFile: string
|
|
17
|
-
platform: string
|
|
18
|
-
deviceId: string
|
|
19
|
-
environment: string
|
|
20
|
-
shellVersion: string
|
|
21
|
-
timeout?: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type ConfigSource =
|
|
25
|
-
| "local"
|
|
26
|
-
| "device"
|
|
27
|
-
| "shellVersion"
|
|
28
|
-
| "environment"
|
|
29
|
-
| "defaults"
|
|
30
|
-
|
|
31
|
-
export type ConfigFetchAttempt = {
|
|
32
|
-
source: ConfigSource
|
|
33
|
-
success: boolean
|
|
34
|
-
duration_ms: number
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type VWRConfigResult = {
|
|
38
|
-
config: VWRConfig
|
|
39
|
-
source: ConfigSource
|
|
40
|
-
attempts: ConfigFetchAttempt[]
|
|
41
|
-
total_duration_ms: number
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const DEFAULT_CONFIG_TIMEOUT = 2000
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Build a URL from a base and relative path, handling missing trailing slashes.
|
|
48
|
-
*
|
|
49
|
-
* The URL constructor resolves relative paths against the "directory" of the base URL,
|
|
50
|
-
* which is defined as everything up to (but not including) the last path segment.
|
|
51
|
-
* Without a trailing slash, the last segment is treated as a "file" and gets replaced.
|
|
52
|
-
*
|
|
53
|
-
* Example:
|
|
54
|
-
* new URL("a/b.json", "https://x.com/config") → "https://x.com/a/b.json" (wrong)
|
|
55
|
-
* new URL("a/b.json", "https://x.com/config/") → "https://x.com/config/a/b.json" (correct)
|
|
56
|
-
*
|
|
57
|
-
* This helper normalizes the base URL to ensure correct resolution.
|
|
58
|
-
*/
|
|
59
|
-
const buildUrl = (path: string, base: string): URL => {
|
|
60
|
-
const normalizedBase = base.endsWith("/") ? base : `${base}/`
|
|
61
|
-
return new URL(path, normalizedBase)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
class VWRConfigFetcher {
|
|
65
|
-
private readonly defaults: VWRConfig
|
|
66
|
-
private readonly timeout: number
|
|
67
|
-
private readonly logger: ILogger
|
|
68
|
-
private readonly configUrl: string
|
|
69
|
-
private readonly configFile: string
|
|
70
|
-
private readonly platform: string
|
|
71
|
-
private readonly deviceId: string
|
|
72
|
-
private readonly environment: string
|
|
73
|
-
private readonly shellVersion: string
|
|
74
|
-
|
|
75
|
-
constructor(request: VWRConfigRequest, logger: ILogger) {
|
|
76
|
-
this.defaults = getDefaultConfig(request.environment)
|
|
77
|
-
this.timeout = request.timeout ?? DEFAULT_CONFIG_TIMEOUT
|
|
78
|
-
this.logger = logger
|
|
79
|
-
this.configUrl = request.configUrl
|
|
80
|
-
this.configFile = request.configFile
|
|
81
|
-
this.platform = request.platform
|
|
82
|
-
this.deviceId = request.deviceId
|
|
83
|
-
this.environment = request.environment
|
|
84
|
-
this.shellVersion = request.shellVersion
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async fetch(): Promise<VWRConfigResult> {
|
|
88
|
-
const fetchStartTime = performance.now()
|
|
89
|
-
|
|
90
|
-
this.logger.debug(
|
|
91
|
-
"[VWR Config] Fetching config with priority: local → device → shellVersion → environment → defaults"
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
// Fetch all configs in parallel for performance, with timing
|
|
95
|
-
const [
|
|
96
|
-
localResult,
|
|
97
|
-
deviceResult,
|
|
98
|
-
shellVersionResult,
|
|
99
|
-
environmentResult,
|
|
100
|
-
] = await Promise.all([
|
|
101
|
-
this.timedFetch("local", () => this.tryGetLocalConfig()),
|
|
102
|
-
this.timedFetch("device", () => this.tryGetDeviceConfig()),
|
|
103
|
-
this.timedFetch("shellVersion", () =>
|
|
104
|
-
this.tryGetShellVersionConfig()
|
|
105
|
-
),
|
|
106
|
-
this.timedFetch("environment", () =>
|
|
107
|
-
this.tryGetEnvironmentConfig()
|
|
108
|
-
),
|
|
109
|
-
])
|
|
110
|
-
|
|
111
|
-
const total_duration_ms = Math.round(performance.now() - fetchStartTime)
|
|
112
|
-
const attempts: ConfigFetchAttempt[] = [
|
|
113
|
-
localResult.attempt,
|
|
114
|
-
deviceResult.attempt,
|
|
115
|
-
shellVersionResult.attempt,
|
|
116
|
-
environmentResult.attempt,
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
// Return first successful config in priority order
|
|
120
|
-
if (localResult.config !== null) {
|
|
121
|
-
this.logger.debug(
|
|
122
|
-
"[VWR Config] ✓ Using config from: local",
|
|
123
|
-
localResult.config
|
|
124
|
-
)
|
|
125
|
-
return {
|
|
126
|
-
config: localResult.config,
|
|
127
|
-
source: "local",
|
|
128
|
-
attempts,
|
|
129
|
-
total_duration_ms,
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (deviceResult.config !== null) {
|
|
133
|
-
this.logger.debug(
|
|
134
|
-
"[VWR Config] ✓ Using config from: device",
|
|
135
|
-
deviceResult.config
|
|
136
|
-
)
|
|
137
|
-
return {
|
|
138
|
-
config: deviceResult.config,
|
|
139
|
-
source: "device",
|
|
140
|
-
attempts,
|
|
141
|
-
total_duration_ms,
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (shellVersionResult.config !== null) {
|
|
145
|
-
this.logger.debug(
|
|
146
|
-
"[VWR Config] ✓ Using config from: shellVersion",
|
|
147
|
-
shellVersionResult.config
|
|
148
|
-
)
|
|
149
|
-
return {
|
|
150
|
-
config: shellVersionResult.config,
|
|
151
|
-
source: "shellVersion",
|
|
152
|
-
attempts,
|
|
153
|
-
total_duration_ms,
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (environmentResult.config !== null) {
|
|
157
|
-
this.logger.debug(
|
|
158
|
-
"[VWR Config] ✓ Using config from: environment",
|
|
159
|
-
environmentResult.config
|
|
160
|
-
)
|
|
161
|
-
return {
|
|
162
|
-
config: environmentResult.config,
|
|
163
|
-
source: "environment",
|
|
164
|
-
attempts,
|
|
165
|
-
total_duration_ms,
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// All fetches failed, use defaults
|
|
170
|
-
this.logger.warn(
|
|
171
|
-
"[VWR Config] All config fetches failed, using built-in defaults"
|
|
172
|
-
)
|
|
173
|
-
return {
|
|
174
|
-
config: this.defaults,
|
|
175
|
-
source: "defaults",
|
|
176
|
-
attempts,
|
|
177
|
-
total_duration_ms,
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
private async timedFetch(
|
|
182
|
-
source: Exclude<ConfigSource, "defaults">,
|
|
183
|
-
fetchFn: () => Promise<VWRConfig | null>
|
|
184
|
-
): Promise<{ config: VWRConfig | null; attempt: ConfigFetchAttempt }> {
|
|
185
|
-
const startTime = performance.now()
|
|
186
|
-
const config = await fetchFn()
|
|
187
|
-
const duration_ms = Math.round(performance.now() - startTime)
|
|
188
|
-
|
|
189
|
-
return {
|
|
190
|
-
config,
|
|
191
|
-
attempt: {
|
|
192
|
-
source,
|
|
193
|
-
success: config !== null,
|
|
194
|
-
duration_ms,
|
|
195
|
-
},
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private async tryGetLocalConfig(): Promise<VWRConfig | null> {
|
|
200
|
-
try {
|
|
201
|
-
const url = buildUrl(
|
|
202
|
-
this.configFile,
|
|
203
|
-
ENV_DEFAULTS["local"]?.configUrl ?? ""
|
|
204
|
-
)
|
|
205
|
-
this.logger.debug(`[VWR Config] Trying local: ${url}`)
|
|
206
|
-
return this.tryFetchConfig(url)
|
|
207
|
-
} catch (error) {
|
|
208
|
-
this.logger.error(
|
|
209
|
-
`[VWR Config] URL construction failed for local config: ${error}`
|
|
210
|
-
)
|
|
211
|
-
return null
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private async tryGetDeviceConfig(): Promise<VWRConfig | null> {
|
|
216
|
-
try {
|
|
217
|
-
const url = buildUrl(
|
|
218
|
-
`device/${this.platform}/${this.deviceId}/${this.configFile}`,
|
|
219
|
-
this.configUrl
|
|
220
|
-
)
|
|
221
|
-
this.logger.debug(`[VWR Config] Trying device: ${url}`)
|
|
222
|
-
return this.tryFetchConfig(url)
|
|
223
|
-
} catch (error) {
|
|
224
|
-
this.logger.error(
|
|
225
|
-
`[VWR Config] URL construction failed for device config: ${error}`
|
|
226
|
-
)
|
|
227
|
-
return null
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
private async tryGetEnvironmentConfig(): Promise<VWRConfig | null> {
|
|
232
|
-
try {
|
|
233
|
-
const url = buildUrl(
|
|
234
|
-
`environments/${this.environment}/${this.configFile}`,
|
|
235
|
-
this.configUrl
|
|
236
|
-
)
|
|
237
|
-
this.logger.debug(`[VWR Config] Trying environment: ${url}`)
|
|
238
|
-
return this.tryFetchConfig(url)
|
|
239
|
-
} catch (error) {
|
|
240
|
-
this.logger.error(
|
|
241
|
-
`[VWR Config] URL construction failed for environment config: ${error}`
|
|
242
|
-
)
|
|
243
|
-
return null
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
private async tryGetShellVersionConfig(): Promise<VWRConfig | null> {
|
|
248
|
-
try {
|
|
249
|
-
const url = buildUrl(
|
|
250
|
-
`shellVersion/${this.environment}/${this.platform}/${this.shellVersion}/${this.configFile}`,
|
|
251
|
-
this.configUrl
|
|
252
|
-
)
|
|
253
|
-
this.logger.debug(`[VWR Config] Trying shellVersion: ${url}`)
|
|
254
|
-
return this.tryFetchConfig(url)
|
|
255
|
-
} catch (error) {
|
|
256
|
-
this.logger.error(
|
|
257
|
-
`[VWR Config] URL construction failed for shellVersion config: ${error}`
|
|
258
|
-
)
|
|
259
|
-
return null
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
private async tryFetchConfig(url: URL): Promise<VWRConfig | null> {
|
|
264
|
-
const controller = new AbortController()
|
|
265
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout)
|
|
266
|
-
|
|
267
|
-
try {
|
|
268
|
-
const response = await fetch(
|
|
269
|
-
new Request(url, {
|
|
270
|
-
headers: { "Content-Type": "application/json" },
|
|
271
|
-
signal: controller.signal,
|
|
272
|
-
})
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
if (!response.ok) {
|
|
276
|
-
clearTimeout(timeoutId)
|
|
277
|
-
return null
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const config = await response.json()
|
|
281
|
-
clearTimeout(timeoutId)
|
|
282
|
-
return this.parseConfig(config)
|
|
283
|
-
} catch {
|
|
284
|
-
clearTimeout(timeoutId)
|
|
285
|
-
return null
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
private parseConfig(config: Partial<VWRConfig>): VWRConfig {
|
|
290
|
-
const result: VWRConfig = {
|
|
291
|
-
hubUrl: config.hubUrl || this.defaults.hubUrl,
|
|
292
|
-
vwrUrl: config.vwrUrl || this.defaults.vwrUrl,
|
|
293
|
-
launchUrl: config.launchUrl,
|
|
294
|
-
platformApiUrl:
|
|
295
|
-
config.platformApiUrl || this.defaults.platformApiUrl,
|
|
296
|
-
platformAuthApiUrl:
|
|
297
|
-
config.platformAuthApiUrl || this.defaults.platformAuthApiUrl,
|
|
298
|
-
trustedDomains:
|
|
299
|
-
Array.isArray(config.trustedDomains) &&
|
|
300
|
-
config.trustedDomains.length > 0
|
|
301
|
-
? [...config.trustedDomains]
|
|
302
|
-
: [...this.defaults.trustedDomains],
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// Ensure vwrUrl origin is in trustedDomains
|
|
306
|
-
const vwrUrlOrigin = new URL(result.vwrUrl).origin
|
|
307
|
-
if (!result.trustedDomains.includes(vwrUrlOrigin)) {
|
|
308
|
-
result.trustedDomains.push(vwrUrlOrigin)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// Ensure hubUrl origin is in trustedDomains
|
|
312
|
-
const hubUrlOrigin = new URL(result.hubUrl).origin
|
|
313
|
-
if (!result.trustedDomains.includes(hubUrlOrigin)) {
|
|
314
|
-
result.trustedDomains.push(hubUrlOrigin)
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// launchUrl is optional - only add to trustedDomains if explicitly set
|
|
318
|
-
if (result.launchUrl) {
|
|
319
|
-
try {
|
|
320
|
-
const launchUrlOrigin = new URL(result.launchUrl).origin
|
|
321
|
-
if (!result.trustedDomains.includes(launchUrlOrigin)) {
|
|
322
|
-
result.trustedDomains.push(launchUrlOrigin)
|
|
323
|
-
}
|
|
324
|
-
} catch {
|
|
325
|
-
// Invalid launchUrl - skip adding to trustedDomains
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return result
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export const getVWRConfig = async (
|
|
334
|
-
request: VWRConfigRequest,
|
|
335
|
-
logger: ILogger
|
|
336
|
-
): Promise<VWRConfigResult> => {
|
|
337
|
-
return new VWRConfigFetcher(request, logger).fetch()
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export const validateConfig = (config: VWRConfig): boolean => {
|
|
341
|
-
if (!config.vwrUrl) return false
|
|
342
|
-
|
|
343
|
-
if (!config.hubUrl) return false
|
|
344
|
-
|
|
345
|
-
// launchUrl is optional, allow undefined
|
|
346
|
-
|
|
347
|
-
if (!Array.isArray(config.trustedDomains)) return false
|
|
348
|
-
else if (config.trustedDomains.length === 0) return false
|
|
349
|
-
|
|
350
|
-
return true
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
const getDefaultConfig = (environment: string): VWRConfig => {
|
|
354
|
-
const defaults = ENV_DEFAULTS[environment]
|
|
355
|
-
|
|
356
|
-
if (!defaults) {
|
|
357
|
-
throw new Error(
|
|
358
|
-
`[VWR Config] Unknown environment: ${environment}. Valid: local, dev, staging, prod`
|
|
359
|
-
)
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
return {
|
|
363
|
-
hubUrl: defaults.hubUrl,
|
|
364
|
-
vwrUrl: defaults.vwrUrl,
|
|
365
|
-
launchUrl: undefined,
|
|
366
|
-
platformApiUrl: defaults.platformApiUrl,
|
|
367
|
-
platformAuthApiUrl: defaults.platformAuthApiUrl,
|
|
368
|
-
trustedDomains: [
|
|
369
|
-
new URL(defaults.hubUrl).origin,
|
|
370
|
-
new URL(defaults.vwrUrl).origin,
|
|
371
|
-
...(defaults.trustedOrigins ?? []),
|
|
372
|
-
],
|
|
373
|
-
}
|
|
374
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|