Skip to content

Commit

Permalink
9.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorm committed Jun 28, 2023
1 parent 4c2d1ac commit 1aba848
Show file tree
Hide file tree
Showing 20 changed files with 504 additions and 358 deletions.
30 changes: 25 additions & 5 deletions dist/otpauth.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ const uintToBuf = num => {
return buf;
};

const createHmac = undefined;
const randomBytes$1 = undefined;
const timingSafeEqual$1 = undefined;

var crypto = /*#__PURE__*/Object.freeze({
__proto__: null,
createHmac: createHmac,
randomBytes: randomBytes$1,
timingSafeEqual: timingSafeEqual$1
});

/**
* A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,
* and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.
Expand Down Expand Up @@ -790,7 +801,11 @@ const OPENSSL_JSSHA_ALGO_MAP = {
* @returns {ArrayBuffer} Digest.
*/
const hmacDigest = (algorithm, key, message) => {
{
if (crypto !== null && crypto !== void 0 && createHmac) {
const hmac = createHmac(algorithm, globalScope.Buffer.from(key));
hmac.update(globalScope.Buffer.from(message));
return hmac.digest().buffer;
} else {
const variant = OPENSSL_JSSHA_ALGO_MAP[algorithm.toUpperCase()];
if (typeof variant === "undefined") {
throw new TypeError("Unknown hash function");
Expand Down Expand Up @@ -962,8 +977,11 @@ const utf8FromBuf = buf => {
* @returns {ArrayBuffer} Random bytes.
*/
const randomBytes = size => {
{
if (!globalScope.crypto?.getRandomValues) {
if (crypto !== null && crypto !== void 0 && randomBytes$1) {
return randomBytes$1(size).buffer;
} else {
var _globalScope$crypto;
if (!((_globalScope$crypto = globalScope.crypto) !== null && _globalScope$crypto !== void 0 && _globalScope$crypto.getRandomValues)) {
throw new Error("Cryptography API not available");
}
return globalScope.crypto.getRandomValues(new Uint8Array(size)).buffer;
Expand Down Expand Up @@ -1092,7 +1110,9 @@ class Secret {
* @returns {boolean} Equality result.
*/
const timingSafeEqual = (a, b) => {
{
if (crypto !== null && crypto !== void 0 && timingSafeEqual$1) {
return timingSafeEqual$1(globalScope.Buffer.from(a), globalScope.Buffer.from(b));
} else {
if (a.length !== b.length) {
throw new TypeError("Input strings must have the same length");
}
Expand Down Expand Up @@ -1632,6 +1652,6 @@ class URI {
* Library version.
* @type {string}
*/
const version = "9.1.2";
const version = "9.1.3";

export { HOTP, Secret, TOTP, URI, version };
2 changes: 1 addition & 1 deletion dist/otpauth.esm.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.esm.min.js.map

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/otpauth.node.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const OPENSSL_JSSHA_ALGO_MAP = {
* @returns {ArrayBuffer} Digest.
*/
const hmacDigest = (algorithm, key, message) => {
if (crypto__namespace?.createHmac) {
if (crypto__namespace !== null && crypto__namespace !== void 0 && crypto__namespace.createHmac) {
const hmac = crypto__namespace.createHmac(algorithm, globalScope.Buffer.from(key));
hmac.update(globalScope.Buffer.from(message));
return hmac.digest().buffer;
Expand Down Expand Up @@ -271,10 +271,11 @@ const utf8FromBuf = buf => {
* @returns {ArrayBuffer} Random bytes.
*/
const randomBytes = size => {
if (crypto__namespace?.randomBytes) {
if (crypto__namespace !== null && crypto__namespace !== void 0 && crypto__namespace.randomBytes) {
return crypto__namespace.randomBytes(size).buffer;
} else {
if (!globalScope.crypto?.getRandomValues) {
var _globalScope$crypto;
if (!((_globalScope$crypto = globalScope.crypto) !== null && _globalScope$crypto !== void 0 && _globalScope$crypto.getRandomValues)) {
throw new Error("Cryptography API not available");
}
return globalScope.crypto.getRandomValues(new Uint8Array(size)).buffer;
Expand Down Expand Up @@ -403,7 +404,7 @@ class Secret {
* @returns {boolean} Equality result.
*/
const timingSafeEqual = (a, b) => {
if (crypto__namespace?.timingSafeEqual) {
if (crypto__namespace !== null && crypto__namespace !== void 0 && crypto__namespace.timingSafeEqual) {
return crypto__namespace.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));
} else {
if (a.length !== b.length) {
Expand Down Expand Up @@ -945,7 +946,7 @@ class URI {
* Library version.
* @type {string}
*/
const version = "9.1.2";
const version = "9.1.3";

exports.HOTP = HOTP;
exports.Secret = Secret;
Expand Down
2 changes: 1 addition & 1 deletion dist/otpauth.node.min.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.node.min.cjs.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.node.min.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.node.min.mjs.map

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions dist/otpauth.node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const OPENSSL_JSSHA_ALGO_MAP = {
* @returns {ArrayBuffer} Digest.
*/
const hmacDigest = (algorithm, key, message) => {
if (crypto?.createHmac) {
if (crypto !== null && crypto !== void 0 && crypto.createHmac) {
const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));
hmac.update(globalScope.Buffer.from(message));
return hmac.digest().buffer;
Expand Down Expand Up @@ -250,10 +250,11 @@ const utf8FromBuf = buf => {
* @returns {ArrayBuffer} Random bytes.
*/
const randomBytes = size => {
if (crypto?.randomBytes) {
if (crypto !== null && crypto !== void 0 && crypto.randomBytes) {
return crypto.randomBytes(size).buffer;
} else {
if (!globalScope.crypto?.getRandomValues) {
var _globalScope$crypto;
if (!((_globalScope$crypto = globalScope.crypto) !== null && _globalScope$crypto !== void 0 && _globalScope$crypto.getRandomValues)) {
throw new Error("Cryptography API not available");
}
return globalScope.crypto.getRandomValues(new Uint8Array(size)).buffer;
Expand Down Expand Up @@ -382,7 +383,7 @@ class Secret {
* @returns {boolean} Equality result.
*/
const timingSafeEqual = (a, b) => {
if (crypto?.timingSafeEqual) {
if (crypto !== null && crypto !== void 0 && crypto.timingSafeEqual) {
return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));
} else {
if (a.length !== b.length) {
Expand Down Expand Up @@ -924,6 +925,6 @@ class URI {
* Library version.
* @type {string}
*/
const version = "9.1.2";
const version = "9.1.3";

export { HOTP, Secret, TOTP, URI, version };
30 changes: 25 additions & 5 deletions dist/otpauth.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
return buf;
};

const createHmac = undefined;
const randomBytes$1 = undefined;
const timingSafeEqual$1 = undefined;

var crypto = /*#__PURE__*/Object.freeze({
__proto__: null,
createHmac: createHmac,
randomBytes: randomBytes$1,
timingSafeEqual: timingSafeEqual$1
});

/**
* A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,
* and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.
Expand Down Expand Up @@ -796,7 +807,11 @@
* @returns {ArrayBuffer} Digest.
*/
const hmacDigest = (algorithm, key, message) => {
{
if (crypto !== null && crypto !== void 0 && createHmac) {
const hmac = createHmac(algorithm, globalScope.Buffer.from(key));
hmac.update(globalScope.Buffer.from(message));
return hmac.digest().buffer;
} else {
const variant = OPENSSL_JSSHA_ALGO_MAP[algorithm.toUpperCase()];
if (typeof variant === "undefined") {
throw new TypeError("Unknown hash function");
Expand Down Expand Up @@ -968,8 +983,11 @@
* @returns {ArrayBuffer} Random bytes.
*/
const randomBytes = size => {
{
if (!globalScope.crypto?.getRandomValues) {
if (crypto !== null && crypto !== void 0 && randomBytes$1) {
return randomBytes$1(size).buffer;
} else {
var _globalScope$crypto;
if (!((_globalScope$crypto = globalScope.crypto) !== null && _globalScope$crypto !== void 0 && _globalScope$crypto.getRandomValues)) {
throw new Error("Cryptography API not available");
}
return globalScope.crypto.getRandomValues(new Uint8Array(size)).buffer;
Expand Down Expand Up @@ -1098,7 +1116,9 @@
* @returns {boolean} Equality result.
*/
const timingSafeEqual = (a, b) => {
{
if (crypto !== null && crypto !== void 0 && timingSafeEqual$1) {
return timingSafeEqual$1(globalScope.Buffer.from(a), globalScope.Buffer.from(b));
} else {
if (a.length !== b.length) {
throw new TypeError("Input strings must have the same length");
}
Expand Down Expand Up @@ -1638,7 +1658,7 @@
* Library version.
* @type {string}
*/
const version = "9.1.2";
const version = "9.1.3";

exports.HOTP = HOTP;
exports.Secret = Secret;
Expand Down
2 changes: 1 addition & 1 deletion dist/otpauth.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/otpauth.umd.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 1aba848

Please sign in to comment.