@iotize/device-client.js
Version:
IoTize Device client for Javascript
43 lines (42 loc) • 2.21 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var converter_1 = require("./command/converter");
var format_helper_1 = require("../format/format-helper");
var APDUError = /** @class */ (function (_super) {
__extends(APDUError, _super);
function APDUError(code, message, frame) {
var _this = _super.call(this, message) || this;
_this.code = code;
_this.frame = frame;
return _this;
}
APDUError.responseCodeError = function (responseCode, data) {
throw new APDUError(APDUError.Code.APDUResponseCodeError, "APDU response code is an error code (0x" + format_helper_1.FormatHelper.toHexString(responseCode) + "). Frame: 0x" + format_helper_1.FormatHelper.toHexString(data), data);
};
APDUError.frameSizePayloadTooSmall = function (expectedSize, frame) {
return new APDUError(APDUError.Code.APDUSizeTooSmall, "Frame is too small: " + frame.length + " byte(s). Expected size " + expectedSize + " byte(s)", frame);
};
APDUError.frameSizeTooSmall = function (frame) {
return new APDUError(APDUError.Code.APDUSizeTooSmall, "Frame is too small: " + frame.length + " byte(s). Minimal frame size for an APDU is " + converter_1.APDUCommandConverter.MIN_APDU_SIZE, frame);
};
return APDUError;
}(Error));
exports.APDUError = APDUError;
(function (APDUError) {
var Code;
(function (Code) {
Code["APDUSizeTooSmall"] = "APDUSizeTooSmall";
Code["APDUResponseCodeError"] = "APDUResponseCodeError";
})(Code = APDUError.Code || (APDUError.Code = {}));
})(APDUError = exports.APDUError || (exports.APDUError = {}));
exports.APDUError = APDUError;