Comparing version 1.1.1 to 1.2.0
103
bundle.js
@@ -342,5 +342,5 @@ (function () { | ||
var messageObject = JSON.parse(message.data); | ||
var intentUrl = messageObject['intentURL']; | ||
messageObject['intentURL']; | ||
var errorCode = messageObject['errorCode']; | ||
messageObject['errorCode']; | ||
var responseObject = null; | ||
@@ -667,10 +667,38 @@ if (messageObject.hasOwnProperty('data')) { | ||
const ErrorCodes = { | ||
OK: 0, | ||
OTHER_ERROR: 1, | ||
BAD_REQUEST: 2, | ||
CONFIGURATION_UNSUPPORTED: 3, | ||
DEVICE_INELIGIBLE: 4, | ||
TIMEOUT: 5 | ||
}; | ||
const ErrorNames = { | ||
"0": "OK", | ||
"1": "OTHER_ERROR", | ||
"2": "BAD_REQUEST", | ||
"3": "CONFIGURATION_UNSUPPORTED", | ||
"4": "DEVICE_INELIGIBLE", | ||
"5": "TIMEOUT" | ||
}; | ||
function makeError(msg, err) { | ||
const code = err != null ? err.errorCode : 1; // Default to OTHER_ERROR | ||
const type = ErrorNames[('' + code)]; | ||
const error = new Error(msg); | ||
error.metaData = { type, code }; | ||
return error; | ||
} | ||
// Feature detection (yes really) | ||
// For IE and Edge detection, see https://stackoverflow.com/questions/31757852#31757969 | ||
// and https://stackoverflow.com/questions/56360225#56361977 | ||
var isBrowser = (typeof navigator !== 'undefined') && !!navigator.userAgent; | ||
var isSafari = isBrowser && navigator.userAgent.match(/Safari\//) | ||
const isBrowser = (typeof navigator !== 'undefined') && !!navigator.userAgent; | ||
const isSafari = isBrowser | ||
&& navigator.userAgent.match(/Safari\//) | ||
&& !navigator.userAgent.match(/Chrome\//); | ||
var isEDGE = isBrowser && /(Edge\/)|(edg\/)/i.test(navigator.userAgent); | ||
var isIE = isBrowser && /(MSIE 9|MSIE 10|rv:11.0)/i.test(navigator.userAgent); | ||
const isSupportedSafari = isBrowser | ||
&& navigator.userAgent.match(/Safari\/(1[3456789])/) | ||
&& !navigator.userAgent.match(/Chrome\//); | ||
const isEDGE = isBrowser && /(Edge\/)|(edg\/)/i.test(navigator.userAgent); | ||
const isIE = isBrowser && /(MSIE 9|MSIE 10|rv:11.0)/i.test(navigator.userAgent); | ||
var _backend = null; | ||
@@ -680,3 +708,3 @@ function getBackend() { | ||
return _backend; | ||
var supportChecker = new Promise(function (resolve, reject) { | ||
const supportChecker = new Promise(function (resolve, reject) { | ||
function notSupported() { | ||
@@ -687,3 +715,3 @@ resolve({ u2f: null }); | ||
return notSupported(); | ||
if (isSafari) | ||
if (isSafari && !isSupportedSafari) | ||
// Safari doesn't support U2F, and the Safari-FIDO-U2F | ||
@@ -693,3 +721,3 @@ // extension lacks full support (Multi-facet apps), so we | ||
return notSupported(); | ||
var hasNativeSupport = (typeof window.u2f !== 'undefined') && | ||
const hasNativeSupport = (typeof window.u2f !== 'undefined') && | ||
(typeof window.u2f.sign === 'function'); | ||
@@ -722,28 +750,5 @@ if (hasNativeSupport) | ||
} | ||
var ErrorCodes = { | ||
OK: 0, | ||
OTHER_ERROR: 1, | ||
BAD_REQUEST: 2, | ||
CONFIGURATION_UNSUPPORTED: 3, | ||
DEVICE_INELIGIBLE: 4, | ||
TIMEOUT: 5 | ||
}; | ||
var ErrorNames = { | ||
"0": "OK", | ||
"1": "OTHER_ERROR", | ||
"2": "BAD_REQUEST", | ||
"3": "CONFIGURATION_UNSUPPORTED", | ||
"4": "DEVICE_INELIGIBLE", | ||
"5": "TIMEOUT" | ||
}; | ||
function makeError(msg, err) { | ||
var code = err != null ? err.errorCode : 1; // Default to OTHER_ERROR | ||
var type = ErrorNames[('' + code)]; | ||
var error = new Error(msg); | ||
error.metaData = { type: type, code: code }; | ||
return error; | ||
} | ||
function isSupported() { | ||
return getBackend() | ||
.then(function (backend) { return !!backend.u2f; }); | ||
.then(backend => !!backend.u2f); | ||
} | ||
@@ -767,6 +772,7 @@ function _ensureSupport(backend) { | ||
: Array.isArray(value) | ||
? value.slice() : [value]; | ||
? [...value] | ||
: [value]; | ||
} | ||
function register(registerRequests, signRequests, timeout) { | ||
var _registerRequests = arrayify(registerRequests); | ||
const _registerRequests = arrayify(registerRequests); | ||
if (typeof signRequests === 'number' && typeof timeout === 'undefined') { | ||
@@ -776,7 +782,7 @@ timeout = signRequests; | ||
} | ||
var _signRequests = arrayify(signRequests); | ||
const _signRequests = arrayify(signRequests); | ||
return getBackend() | ||
.then(function (backend) { | ||
_ensureSupport(backend); | ||
var u2f = backend.u2f; | ||
const { u2f } = backend; | ||
return new Promise(function (resolve, reject) { | ||
@@ -791,3 +797,3 @@ function callback(response) { | ||
} | ||
var appId = _registerRequests[0].appId; | ||
const appId = _registerRequests[0].appId; | ||
u2f.register(appId, _registerRequests, _signRequests, callback, timeout); | ||
@@ -798,9 +804,8 @@ }); | ||
function sign(signRequests, timeout) { | ||
var _signRequests = arrayify(signRequests); | ||
const _signRequests = arrayify(signRequests); | ||
return getBackend() | ||
.then(function (backend) { | ||
_ensureSupport(backend); | ||
var u2f = backend.u2f; | ||
const { u2f } = backend; | ||
return new Promise(function (resolve, reject) { | ||
var _a; | ||
function callback(response) { | ||
@@ -814,12 +819,7 @@ if (response.errorCode) | ||
} | ||
var appId = _signRequests[0].appId; | ||
var challenge = _signRequests[0].challenge; | ||
var registeredKeys = (_a = []).concat.apply(_a, _signRequests | ||
.map(function (_a) { | ||
var version = _a.version, keyHandle = _a.keyHandle, appId = _a.appId; | ||
return arrayify(keyHandle) | ||
.map(function (keyHandle) { | ||
return ({ version: version, keyHandle: keyHandle, appId: appId }); | ||
}); | ||
})); | ||
const appId = _signRequests[0].appId; | ||
const challenge = _signRequests[0].challenge; | ||
const registeredKeys = [].concat(..._signRequests | ||
.map(({ version, keyHandle, appId }) => arrayify(keyHandle) | ||
.map(keyHandle => ({ version, keyHandle, appId })))); | ||
u2f.sign(appId, challenge, registeredKeys, callback, timeout); | ||
@@ -831,2 +831,3 @@ }); | ||
var u2fApi = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
ErrorCodes: ErrorCodes, | ||
@@ -833,0 +834,0 @@ ErrorNames: ErrorNames, |
'use strict'; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var u2fApi = require("./lib/u2f-api"); | ||
__export(require("./lib/u2f-api")); | ||
const u2fApi = require("./lib/u2f-api"); | ||
__exportStar(require("./lib/u2f-api"), exports); | ||
exports.default = u2fApi; | ||
//# sourceMappingURL=index.js.map |
@@ -1,43 +0,3 @@ | ||
export interface RegisterRequest { | ||
version: string; | ||
appId: string; | ||
challenge: string; | ||
} | ||
export interface SignRequest extends RegisterRequest { | ||
keyHandle: string; | ||
} | ||
export interface RegisterResponse { | ||
clientData: string; | ||
registrationData: string; | ||
version: string; | ||
} | ||
export interface SignResponse { | ||
clientData: string; | ||
keyHandle: string; | ||
signatureData: string; | ||
} | ||
export declare type Transport = 'bt' | 'ble' | 'nfc' | 'usb'; | ||
export declare type Transports = Array<Transport>; | ||
export interface RegisteredKey { | ||
version: string; | ||
keyHandle: string; | ||
transports: Transports; | ||
appId: string; | ||
} | ||
export declare const ErrorCodes: { | ||
OK: number; | ||
OTHER_ERROR: number; | ||
BAD_REQUEST: number; | ||
CONFIGURATION_UNSUPPORTED: number; | ||
DEVICE_INELIGIBLE: number; | ||
TIMEOUT: number; | ||
}; | ||
export declare const ErrorNames: { | ||
"0": string; | ||
"1": string; | ||
"2": string; | ||
"3": string; | ||
"4": string; | ||
"5": string; | ||
}; | ||
import { ErrorCodes, ErrorNames, RegisterRequest, SignRequest, RegisterResponse, SignResponse, Transport, Transports, RegisteredKey } from './types'; | ||
export { ErrorCodes, ErrorNames, RegisterRequest, SignRequest, RegisterResponse, SignResponse, Transport, Transports, RegisteredKey, }; | ||
export declare function isSupported(): Promise<boolean>; | ||
@@ -44,0 +4,0 @@ export declare function ensureSupport(): Promise<void>; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sign = exports.register = exports.ensureSupport = exports.isSupported = exports.ErrorNames = exports.ErrorCodes = void 0; | ||
// @ts-ignore | ||
var generated_google_u2f_api_1 = require("./generated-google-u2f-api"); | ||
const generated_google_u2f_api_1 = require("./generated-google-u2f-api"); | ||
const types_1 = require("./types"); | ||
Object.defineProperty(exports, "ErrorCodes", { enumerable: true, get: function () { return types_1.ErrorCodes; } }); | ||
Object.defineProperty(exports, "ErrorNames", { enumerable: true, get: function () { return types_1.ErrorNames; } }); | ||
// Feature detection (yes really) | ||
// For IE and Edge detection, see https://stackoverflow.com/questions/31757852#31757969 | ||
// and https://stackoverflow.com/questions/56360225#56361977 | ||
var isBrowser = (typeof navigator !== 'undefined') && !!navigator.userAgent; | ||
var isSafari = isBrowser && navigator.userAgent.match(/Safari\//) | ||
const isBrowser = (typeof navigator !== 'undefined') && !!navigator.userAgent; | ||
const isSafari = isBrowser | ||
&& navigator.userAgent.match(/Safari\//) | ||
&& !navigator.userAgent.match(/Chrome\//); | ||
var isEDGE = isBrowser && /(Edge\/)|(edg\/)/i.test(navigator.userAgent); | ||
var isIE = isBrowser && /(MSIE 9|MSIE 10|rv:11.0)/i.test(navigator.userAgent); | ||
const isSupportedSafari = isBrowser | ||
&& navigator.userAgent.match(/Safari\/(1[3456789])/) | ||
&& !navigator.userAgent.match(/Chrome\//); | ||
const isEDGE = isBrowser && /(Edge\/)|(edg\/)/i.test(navigator.userAgent); | ||
const isIE = isBrowser && /(MSIE 9|MSIE 10|rv:11.0)/i.test(navigator.userAgent); | ||
var _backend = null; | ||
@@ -17,3 +25,3 @@ function getBackend() { | ||
return _backend; | ||
var supportChecker = new Promise(function (resolve, reject) { | ||
const supportChecker = new Promise(function (resolve, reject) { | ||
function notSupported() { | ||
@@ -24,3 +32,3 @@ resolve({ u2f: null }); | ||
return notSupported(); | ||
if (isSafari) | ||
if (isSafari && !isSupportedSafari) | ||
// Safari doesn't support U2F, and the Safari-FIDO-U2F | ||
@@ -30,3 +38,3 @@ // extension lacks full support (Multi-facet apps), so we | ||
return notSupported(); | ||
var hasNativeSupport = (typeof window.u2f !== 'undefined') && | ||
const hasNativeSupport = (typeof window.u2f !== 'undefined') && | ||
(typeof window.u2f.sign === 'function'); | ||
@@ -59,28 +67,5 @@ if (hasNativeSupport) | ||
} | ||
exports.ErrorCodes = { | ||
OK: 0, | ||
OTHER_ERROR: 1, | ||
BAD_REQUEST: 2, | ||
CONFIGURATION_UNSUPPORTED: 3, | ||
DEVICE_INELIGIBLE: 4, | ||
TIMEOUT: 5 | ||
}; | ||
exports.ErrorNames = { | ||
"0": "OK", | ||
"1": "OTHER_ERROR", | ||
"2": "BAD_REQUEST", | ||
"3": "CONFIGURATION_UNSUPPORTED", | ||
"4": "DEVICE_INELIGIBLE", | ||
"5": "TIMEOUT" | ||
}; | ||
function makeError(msg, err) { | ||
var code = err != null ? err.errorCode : 1; // Default to OTHER_ERROR | ||
var type = exports.ErrorNames[('' + code)]; | ||
var error = new Error(msg); | ||
error.metaData = { type: type, code: code }; | ||
return error; | ||
} | ||
function isSupported() { | ||
return getBackend() | ||
.then(function (backend) { return !!backend.u2f; }); | ||
.then(backend => !!backend.u2f); | ||
} | ||
@@ -106,6 +91,7 @@ exports.isSupported = isSupported; | ||
: Array.isArray(value) | ||
? value.slice() : [value]; | ||
? [...value] | ||
: [value]; | ||
} | ||
function register(registerRequests, signRequests, timeout) { | ||
var _registerRequests = arrayify(registerRequests); | ||
const _registerRequests = arrayify(registerRequests); | ||
if (typeof signRequests === 'number' && typeof timeout === 'undefined') { | ||
@@ -115,11 +101,11 @@ timeout = signRequests; | ||
} | ||
var _signRequests = arrayify(signRequests); | ||
const _signRequests = arrayify(signRequests); | ||
return getBackend() | ||
.then(function (backend) { | ||
_ensureSupport(backend); | ||
var u2f = backend.u2f; | ||
const { u2f } = backend; | ||
return new Promise(function (resolve, reject) { | ||
function callback(response) { | ||
if (response.errorCode) | ||
reject(makeError("Registration failed", response)); | ||
reject(types_1.makeError("Registration failed", response)); | ||
else { | ||
@@ -130,3 +116,3 @@ delete response.errorCode; | ||
} | ||
var appId = _registerRequests[0].appId; | ||
const appId = _registerRequests[0].appId; | ||
u2f.register(appId, _registerRequests, _signRequests, callback, timeout); | ||
@@ -138,12 +124,11 @@ }); | ||
function sign(signRequests, timeout) { | ||
var _signRequests = arrayify(signRequests); | ||
const _signRequests = arrayify(signRequests); | ||
return getBackend() | ||
.then(function (backend) { | ||
_ensureSupport(backend); | ||
var u2f = backend.u2f; | ||
const { u2f } = backend; | ||
return new Promise(function (resolve, reject) { | ||
var _a; | ||
function callback(response) { | ||
if (response.errorCode) | ||
reject(makeError("Sign failed", response)); | ||
reject(types_1.makeError("Sign failed", response)); | ||
else { | ||
@@ -154,12 +139,7 @@ delete response.errorCode; | ||
} | ||
var appId = _signRequests[0].appId; | ||
var challenge = _signRequests[0].challenge; | ||
var registeredKeys = (_a = []).concat.apply(_a, _signRequests | ||
.map(function (_a) { | ||
var version = _a.version, keyHandle = _a.keyHandle, appId = _a.appId; | ||
return arrayify(keyHandle) | ||
.map(function (keyHandle) { | ||
return ({ version: version, keyHandle: keyHandle, appId: appId }); | ||
}); | ||
})); | ||
const appId = _signRequests[0].appId; | ||
const challenge = _signRequests[0].challenge; | ||
const registeredKeys = [].concat(..._signRequests | ||
.map(({ version, keyHandle, appId }) => arrayify(keyHandle) | ||
.map(keyHandle => ({ version, keyHandle, appId })))); | ||
u2f.sign(appId, challenge, registeredKeys, callback, timeout); | ||
@@ -170,2 +150,1 @@ }); | ||
exports.sign = sign; | ||
//# sourceMappingURL=u2f-api.js.map |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"author": "Gustaf Räntilä <g.rantila@gmail.com>", | ||
@@ -18,8 +18,6 @@ "repository": { | ||
"build:lib": "scripts/build.sh", | ||
"build:rollup": "node_modules/.bin/rimraf bundle.js && node_modules/.bin/rollup dist-bundle/index.bundle.js --file bundle.js --format iife", | ||
"build:rollup": "rimraf bundle.js && rollup dist-bundle/index.bundle.js --file bundle.js --format iife", | ||
"build": "yarn build:lib && yarn build:rollup", | ||
"test": "node_modules/.bin/mocha dist/test", | ||
"test": "jest --no-cache", | ||
"buildtest": "npm run build && npm run test", | ||
"travis-deploy-once": "travis-deploy-once", | ||
"semantic-release": "semantic-release", | ||
"cz": "git-cz" | ||
@@ -43,18 +41,17 @@ }, | ||
"devDependencies": { | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "5.x", | ||
"already": "1.x", | ||
"chai": "4.x", | ||
"commitizen": "3.x", | ||
"cz-conventional-changelog": "2.x", | ||
"jsdom": "11.x", | ||
"mocha": "6.x", | ||
"@types/jest": "^26.0.13", | ||
"@types/node": "^14.6.4", | ||
"already": "1.13.1", | ||
"commitizen": "4.2.1", | ||
"cz-conventional-changelog": "3.3.0", | ||
"get-stream": "^6.0.0", | ||
"jest": "^26.4.2", | ||
"jsdom": "16.4.0", | ||
"pre-commit": "1.x", | ||
"rimraf": "2.x", | ||
"rollup": "^1.17.0", | ||
"semantic-release": "15.x", | ||
"source-map-support": "0.x", | ||
"travis-deploy-once": "5.x", | ||
"ts-node": "^8.3.0", | ||
"typescript": "3.x" | ||
"rimraf": "3.0.2", | ||
"rollup": "^2.26.10", | ||
"ts-jest": "^26.3.0", | ||
"ts-node": "^9.0.0", | ||
"typescript": "4.0.2", | ||
"u2f": "^0.1.3" | ||
}, | ||
@@ -61,0 +58,0 @@ "config": { |
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
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
15
0
65299
11
1696