Socket
Socket
Sign inDemoInstall

@ledgerhq/hw-transport-webauthn

Package Overview
Dependencies
8
Maintainers
12
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.74.2 to 5.0.0-alpha.3

185

lib/TransportWebAuthn.js

@@ -6,9 +6,6 @@ "use strict";

});
exports.default = void 0;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _hwTransport = _interopRequireDefault(require("@ledgerhq/hw-transport"));
var _hwTransport = require("@ledgerhq/hw-transport");
var _hwTransport2 = _interopRequireDefault(_hwTransport);
var _errors = require("@ledgerhq/errors");

@@ -22,11 +19,3 @@

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var attemptExchange = function attemptExchange(apdu, timeout, scrambleKey) {
const attemptExchange = (apdu, timeout, scrambleKey) => {
if (!scrambleKey) {

@@ -40,7 +29,6 @@ throw new _errors.TransportError("transport.setScrambleKey must be used to set a scramble key. Refer to documentation.", "NoScrambleKey");

return navigator.credentials
// $FlowFixMe
return navigator.credentials // $FlowFixMe
.get({
publicKey: {
timeout: timeout,
timeout,
challenge: new Uint8Array(32),

@@ -52,9 +40,5 @@ allowCredentials: [{

}
})
// $FlowFixMe
.then(function (r) {
return Buffer.from(r.response.signature);
});
}) // $FlowFixMe
.then(r => Buffer.from(r.response.signature));
};
/**

@@ -68,127 +52,68 @@ * WebAuthn Transport implementation

var TransportWebAuthn = function (_Transport) {
_inherits(TransportWebAuthn, _Transport);
function TransportWebAuthn() {
_classCallCheck(this, TransportWebAuthn);
class TransportWebAuthn extends _hwTransport.default {
constructor(...args) {
super(...args);
this.scrambleKey = void 0;
}
return _possibleConstructorReturn(this, (TransportWebAuthn.__proto__ || Object.getPrototypeOf(TransportWebAuthn)).apply(this, arguments));
static async open() {
return new TransportWebAuthn();
}
/**
* Exchange with the device using APDU protocol.
* @param apdu
* @returns a promise of apdu response
*/
_createClass(TransportWebAuthn, [{
key: "exchange",
async exchange(apdu) {
(0, _logs.log)("apdu", "=> " + apdu.toString("hex"));
const res = await attemptExchange(apdu, this.exchangeTimeout, this.scrambleKey);
(0, _logs.log)("apdu", "<= " + res.toString("hex"));
return res;
}
/**
* A scramble key is a string that xor the data exchanged.
* It depends on the device app you need to exchange with.
* For instance it can be "BTC" for the bitcoin app, "B0L0S" for the dashboard.
*
* @example
* transport.setScrambleKey("B0L0S")
*/
/**
* Exchange with the device using APDU protocol.
* @param apdu
* @returns a promise of apdu response
*/
value: function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(apdu) {
var res;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
(0, _logs.log)("apdu", "=> " + apdu.toString("hex"));
_context.next = 3;
return attemptExchange(apdu, this.exchangeTimeout, this.scrambleKey);
case 3:
res = _context.sent;
setScrambleKey(scrambleKey) {
this.scrambleKey = Buffer.from(scrambleKey, "ascii");
}
(0, _logs.log)("apdu", "<= " + res.toString("hex"));
return _context.abrupt("return", res);
close() {
return Promise.resolve();
}
case 6:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
}
function exchange(_x) {
return _ref.apply(this, arguments);
}
exports.default = TransportWebAuthn;
return exchange;
}()
TransportWebAuthn.isSupported = () => Promise.resolve(!!navigator.credentials);
/**
* A scramble key is a string that xor the data exchanged.
* It depends on the device app you need to exchange with.
* For instance it can be "BTC" for the bitcoin app, "B0L0S" for the dashboard.
*
* @example
* transport.setScrambleKey("B0L0S")
*/
TransportWebAuthn.list = () => navigator.credentials ? [null] : [];
}, {
key: "setScrambleKey",
value: function setScrambleKey(scrambleKey) {
this.scrambleKey = Buffer.from(scrambleKey, "ascii");
}
}, {
key: "close",
value: function close() {
return Promise.resolve();
}
}], [{
key: "open",
/*
*/
value: function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
return _context2.abrupt("return", new TransportWebAuthn());
case 1:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function open() {
return _ref2.apply(this, arguments);
}
return open;
}()
/*
*/
}]);
return TransportWebAuthn;
}(_hwTransport2.default);
TransportWebAuthn.isSupported = function () {
return Promise.resolve(!!navigator.credentials);
};
TransportWebAuthn.list = function () {
return navigator.credentials ? [null] : [];
};
TransportWebAuthn.listen = function (observer) {
TransportWebAuthn.listen = observer => {
if (!navigator.credentials) {
observer.error(new _errors.TransportError("WebAuthn not supported", "NotSupported"));
return { unsubscribe: function unsubscribe() {} };
return {
unsubscribe: () => {}
};
}
observer.next({ type: "add", descriptor: null });
observer.next({
type: "add",
descriptor: null
});
observer.complete();
return { unsubscribe: function unsubscribe() {} };
return {
unsubscribe: () => {}
};
};
exports.default = TransportWebAuthn;
//# sourceMappingURL=TransportWebAuthn.js.map
{
"name": "@ledgerhq/hw-transport-webauthn",
"version": "4.74.2",
"version": "5.0.0-alpha.3+0b49d08",
"description": "Ledger Hardware Wallet Web implementation of the communication layer, using WebAuthN api",

@@ -29,6 +29,6 @@ "keywords": [

"dependencies": {
"@ledgerhq/devices": "^4.74.2",
"@ledgerhq/errors": "^4.74.2",
"@ledgerhq/hw-transport": "^4.74.2",
"@ledgerhq/logs": "^4.72.0"
"@ledgerhq/devices": "^5.0.0-alpha.3+0b49d08",
"@ledgerhq/errors": "^5.0.0-alpha.3+0b49d08",
"@ledgerhq/hw-transport": "^5.0.0-alpha.3+0b49d08",
"@ledgerhq/logs": "^5.0.0-alpha.3+0b49d08"
},

@@ -46,3 +46,3 @@ "devDependencies": {

},
"gitHead": "5f74b291e1bfd836d23a829a5948f7273af16359"
"gitHead": "0b49d08dedc19562fefbd2148292cc0995a0d4ae"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc