-
Notifications
You must be signed in to change notification settings - Fork 472
/
Versioning.ts
44 lines (38 loc) · 1.25 KB
/
Versioning.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2019-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import DefaultBrowserBehavior from '../browserbehavior/DefaultBrowserBehavior';
export default class Versioning {
static X_AMZN_VERSION = 'X-Amzn-Version';
static X_AMZN_USER_AGENT = 'X-Amzn-User-Agent';
/**
* Return string representation of SDK name
*/
static get sdkName(): string {
return 'amazon-chime-sdk-js';
}
/**
* Return string representation of SDK version
*/
static get sdkVersion(): string {
return '1.14.8';
}
/**
* Return low-resolution string representation of SDK user agent (e.g. `chrome-78`)
*/
static get sdkUserAgentLowResolution(): string {
const browserBehavior = new DefaultBrowserBehavior();
return `${browserBehavior.name()}-${browserBehavior.majorVersion()}`;
}
/**
* Return URL with versioning information appended
*/
static urlWithVersion(url: string): string {
const urlWithVersion = new URL(url);
urlWithVersion.searchParams.append(Versioning.X_AMZN_VERSION, Versioning.sdkVersion);
urlWithVersion.searchParams.append(
Versioning.X_AMZN_USER_AGENT,
Versioning.sdkUserAgentLowResolution
);
return urlWithVersion.toString();
}
}