@aws-sdk/util-user-agent-browser
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.1.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.0.0...v3.1.0) (2020-12-23) | ||
### Features | ||
* standardize user agent value ([#1775](https://github.com/aws/aws-sdk-js-v3/issues/1775)) ([388b180](https://github.com/aws/aws-sdk-js-v3/commit/388b18071146171b42d283a93f9590cb23956e1a)) | ||
# [3.0.0](https://github.com/aws/aws-sdk-js-v3/compare/v1.0.0-rc.10...v3.0.0) (2020-12-15) | ||
@@ -8,0 +19,0 @@ |
@@ -1,1 +0,7 @@ | ||
export declare function defaultUserAgent(packageName: string, packageVersion: string): string; | ||
import { Provider, UserAgent } from "@aws-sdk/types"; | ||
import { DefaultUserAgentOptions } from "./configurations"; | ||
/** | ||
* Default provider to the user agent in browsers. It's a best effort to infer | ||
* the device information. It uses bowser library to detect the browser and virsion | ||
*/ | ||
export declare const defaultUserAgent: ({ serviceId, clientVersion, }: DefaultUserAgentOptions) => Provider<UserAgent>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defaultUserAgent = void 0; | ||
function defaultUserAgent(packageName, packageVersion) { | ||
const originUserAgent = typeof navigator !== "undefined" && typeof navigator.userAgent === "string" ? navigator.userAgent : ""; | ||
return `aws-sdk-js-v3-${packageName}/${packageVersion} ${originUserAgent}`; | ||
} | ||
const bowser_1 = require("bowser"); | ||
/** | ||
* Default provider to the user agent in browsers. It's a best effort to infer | ||
* the device information. It uses bowser library to detect the browser and virsion | ||
*/ | ||
const defaultUserAgent = ({ serviceId, clientVersion, }) => async () => { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
const parsedUA = ((_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) ? bowser_1.parse(window.navigator.userAgent) : undefined; | ||
const sections = [ | ||
// sdk-metadata | ||
["aws-sdk-js", clientVersion], | ||
// os-metadata | ||
[`os/${((_b = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os) === null || _b === void 0 ? void 0 : _b.name) || "other"}`, (_c = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os) === null || _c === void 0 ? void 0 : _c.version], | ||
// language-metadata | ||
// ECMAScript edition doesn't matter in JS. | ||
["lang/js"], | ||
// browser vendor and version. | ||
["md/browser", `${(_e = (_d = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.browser) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : "unknown"}_${(_g = (_f = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.browser) === null || _f === void 0 ? void 0 : _f.version) !== null && _g !== void 0 ? _g : "unknown"}`], | ||
]; | ||
if (serviceId) { | ||
// api-metadata | ||
// service Id may not appear in non-AWS clients | ||
sections.push([`api/${serviceId}`, clientVersion]); | ||
} | ||
return sections; | ||
}; | ||
exports.defaultUserAgent = defaultUserAgent; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsU0FBZ0IsZ0JBQWdCLENBQUMsV0FBbUIsRUFBRSxjQUFzQjtJQUMxRSxNQUFNLGVBQWUsR0FDbkIsT0FBTyxTQUFTLEtBQUssV0FBVyxJQUFJLE9BQU8sU0FBUyxDQUFDLFNBQVMsS0FBSyxRQUFRLENBQUMsQ0FBQyxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQztJQUN6RyxPQUFPLGlCQUFpQixXQUFXLElBQUksY0FBYyxJQUFJLGVBQWUsRUFBRSxDQUFDO0FBQzdFLENBQUM7QUFKRCw0Q0FJQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiB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LyBzZXJ2aWNlIElkIG1heSBub3QgYXBwZWFyIGluIG5vbi1BV1MgY2xpZW50c1xuICAgIHNlY3Rpb25zLnB1c2goW2BhcGkvJHtzZXJ2aWNlSWR9YCwgY2xpZW50VmVyc2lvbl0pO1xuICB9XG5cbiAgcmV0dXJuIHNlY3Rpb25zO1xufTtcbiJdfQ== |
@@ -1,1 +0,7 @@ | ||
export declare function defaultUserAgent(packageName: string, packageVersion: string): string; | ||
import { Provider, UserAgent } from "@aws-sdk/types"; | ||
import { DefaultUserAgentOptions } from "./configurations"; | ||
/** | ||
* Default provider to the user agent in browsers. It's a best effort to infer | ||
* the device information. It uses bowser library to detect the browser and virsion | ||
*/ | ||
export declare const defaultUserAgent: ({ serviceId, clientVersion, }: DefaultUserAgentOptions) => Provider<UserAgent>; |
@@ -1,5 +0,34 @@ | ||
export function defaultUserAgent(packageName, packageVersion) { | ||
var originUserAgent = typeof navigator !== "undefined" && typeof navigator.userAgent === "string" ? navigator.userAgent : ""; | ||
return "aws-sdk-js-v3-" + packageName + "/" + packageVersion + " " + originUserAgent; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxVQUFVLGdCQUFnQixDQUFDLFdBQW1CLEVBQUUsY0FBc0I7SUFDMUUsSUFBTSxlQUFlLEdBQ25CLE9BQU8sU0FBUyxLQUFLLFdBQVcsSUFBSSxPQUFPLFNBQVMsQ0FBQyxTQUFTLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7SUFDekcsT0FBTyxtQkFBaUIsV0FBVyxTQUFJLGNBQWMsU0FBSSxlQUFpQixDQUFDO0FBQzdFLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gZGVmYXVsdFVzZXJBZ2VudChwYWNrYWdlTmFtZTogc3RyaW5nLCBwYWNrYWdlVmVyc2lvbjogc3RyaW5nKTogc3RyaW5nIHtcbiAgY29uc3Qgb3JpZ2luVXNlckFnZW50ID1cbiAgICB0eXBlb2YgbmF2aWdhdG9yICE9PSBcInVuZGVmaW5lZFwiICYmIHR5cGVvZiBuYXZpZ2F0b3IudXNlckFnZW50ID09PSBcInN0cmluZ1wiID8gbmF2aWdhdG9yLnVzZXJBZ2VudCA6IFwiXCI7XG4gIHJldHVybiBgYXdzLXNkay1qcy12My0ke3BhY2thZ2VOYW1lfS8ke3BhY2thZ2VWZXJzaW9ufSAke29yaWdpblVzZXJBZ2VudH1gO1xufVxuIl19 | ||
import { __awaiter, __generator } from "tslib"; | ||
import { parse } from "bowser"; | ||
/** | ||
* Default provider to the user agent in browsers. It's a best effort to infer | ||
* the device information. It uses bowser library to detect the browser and virsion | ||
*/ | ||
export var defaultUserAgent = function (_a) { | ||
var serviceId = _a.serviceId, clientVersion = _a.clientVersion; | ||
return function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var parsedUA, sections; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
return __generator(this, function (_h) { | ||
parsedUA = ((_a = window === null || window === void 0 ? void 0 : window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) ? parse(window.navigator.userAgent) : undefined; | ||
sections = [ | ||
// sdk-metadata | ||
["aws-sdk-js", clientVersion], | ||
// os-metadata | ||
["os/" + (((_b = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os) === null || _b === void 0 ? void 0 : _b.name) || "other"), (_c = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os) === null || _c === void 0 ? void 0 : _c.version], | ||
// language-metadata | ||
// ECMAScript edition doesn't matter in JS. | ||
["lang/js"], | ||
// browser vendor and version. | ||
["md/browser", ((_e = (_d = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.browser) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : "unknown") + "_" + ((_g = (_f = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.browser) === null || _f === void 0 ? void 0 : _f.version) !== null && _g !== void 0 ? _g : "unknown")], | ||
]; | ||
if (serviceId) { | ||
// api-metadata | ||
// service Id may not appear in non-AWS clients | ||
sections.push(["api/" + serviceId, clientVersion]); | ||
} | ||
return [2 /*return*/, sections]; | ||
}); | ||
}); }; | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLE9BQU8sRUFBRSxLQUFLLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFJL0I7OztHQUdHO0FBQ0gsTUFBTSxDQUFDLElBQU0sZ0JBQWdCLEdBQUcsVUFBQyxFQUdQO1FBRnhCLFNBQVMsZUFBQSxFQUNULGFBQWEsbUJBQUE7SUFDcUMsT0FBQTs7OztZQUM1QyxRQUFRLEdBQUcsT0FBQSxNQUFNLGFBQU4sTUFBTSx1QkFBTixNQUFNLENBQUUsU0FBUywwQ0FBRSxTQUFTLEVBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUM7WUFDeEYsUUFBUSxHQUFjO2dCQUMxQixlQUFlO2dCQUNmLENBQUMsWUFBWSxFQUFFLGFBQWEsQ0FBQztnQkFDN0IsY0FBYztnQkFDZCxDQUFDLFNBQU0sT0FBQSxRQUFRLGFBQVIsUUFBUSx1QkFBUixRQUFRLENBQUUsRUFBRSwwQ0FBRSxJQUFJLEtBQUksT0FBTyxDQUFFLFFBQUUsUUFBUSxhQU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cnZpY2VJZH1gLCBjbGllbnRWZXJzaW9uXSk7XG4gIH1cblxuICByZXR1cm4gc2VjdGlvbnM7XG59O1xuIl19 |
{ | ||
"name": "@aws-sdk/util-user-agent-browser", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"scripts": { | ||
@@ -20,8 +20,12 @@ "prepublishOnly": "yarn build:cjs && yarn build:es", | ||
"license": "Apache-2.0", | ||
"react-native": { | ||
"./index": "./index.native" | ||
}, | ||
"dependencies": { | ||
"@aws-sdk/types": "3.1.0", | ||
"bowser": "^2.11.0", | ||
"tslib": "^1.8.0" | ||
}, | ||
"devDependencies": { | ||
"@aws-sdk/protocol-http": "3.0.0", | ||
"@aws-sdk/types": "3.0.0", | ||
"@aws-sdk/protocol-http": "3.1.0", | ||
"@types/jest": "^26.0.4", | ||
@@ -28,0 +32,0 @@ "jest": "^26.1.0", |
# @aws-sdk/util-user-agent-browser | ||
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-user-agent-browser/rc.svg)](https://www.npmjs.com/package/@aws-sdk/util-user-agent-browser) | ||
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-user-agent-browser/latest.svg)](https://www.npmjs.com/package/@aws-sdk/util-user-agent-browser) | ||
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-user-agent-browser.svg)](https://www.npmjs.com/package/@aws-sdk/util-user-agent-browser) | ||
@@ -5,0 +5,0 @@ |
@@ -1,5 +0,34 @@ | ||
export function defaultUserAgent(packageName: string, packageVersion: string): string { | ||
const originUserAgent = | ||
typeof navigator !== "undefined" && typeof navigator.userAgent === "string" ? navigator.userAgent : ""; | ||
return `aws-sdk-js-v3-${packageName}/${packageVersion} ${originUserAgent}`; | ||
} | ||
import { Provider, UserAgent } from "@aws-sdk/types"; | ||
import { parse } from "bowser"; | ||
import { DefaultUserAgentOptions } from "./configurations"; | ||
/** | ||
* Default provider to the user agent in browsers. It's a best effort to infer | ||
* the device information. It uses bowser library to detect the browser and virsion | ||
*/ | ||
export const defaultUserAgent = ({ | ||
serviceId, | ||
clientVersion, | ||
}: DefaultUserAgentOptions): Provider<UserAgent> => async () => { | ||
const parsedUA = window?.navigator?.userAgent ? parse(window.navigator.userAgent) : undefined; | ||
const sections: UserAgent = [ | ||
// sdk-metadata | ||
["aws-sdk-js", clientVersion], | ||
// os-metadata | ||
[`os/${parsedUA?.os?.name || "other"}`, parsedUA?.os?.version], | ||
// language-metadata | ||
// ECMAScript edition doesn't matter in JS. | ||
["lang/js"], | ||
// browser vendor and version. | ||
["md/browser", `${parsedUA?.browser?.name ?? "unknown"}_${parsedUA?.browser?.version ?? "unknown"}`], | ||
]; | ||
if (serviceId) { | ||
// api-metadata | ||
// service Id may not appear in non-AWS clients | ||
sections.push([`api/${serviceId}`, clientVersion]); | ||
} | ||
return sections; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66780
4
21
239
3
1
+ Added@aws-sdk/types@3.1.0
+ Addedbowser@^2.11.0
+ Added@aws-sdk/types@3.1.0(transitive)
+ Addedbowser@2.11.0(transitive)