Skip to content

Commit

Permalink
Revert "9.3.0"
Browse files Browse the repository at this point in the history
This reverts commit a6511af.
  • Loading branch information
hectorm committed Jun 2, 2024
1 parent a6511af commit 3081f2f
Show file tree
Hide file tree
Showing 23 changed files with 185 additions and 932 deletions.
20 changes: 10 additions & 10 deletions dist/otpauth.esm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! otpauth 9.3.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth
//! noble-hashes 1.4.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes
/// <reference types="./otpauth.d.ts" />
// @license otpauth 9.2.4 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth
// @license noble-hashes 1.4.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes
// @ts-nocheck
/// <reference types="./otpauth.d.ts" />
/**
* Converts an integer to an Uint8Array.
* @param {number} num Integer.
Expand Down Expand Up @@ -1144,12 +1144,12 @@ const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);
* @param {Uint8Array} message Message.
* @returns {Uint8Array} Digest.
*/ const hmacDigest = (algorithm, key, message)=>{
if (hmac) {
{
const hash = OPENSSL_NOBLE_HASHES[algorithm.toUpperCase()];
if (!hash) throw new TypeError("Unknown hash function");
if (typeof hash === "undefined") {
throw new TypeError("Unknown hash function");
}
return hmac(hash, key, message);
} else {
throw new Error("Missing HMAC function");
}
};

Expand Down Expand Up @@ -1260,11 +1260,11 @@ const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);
/**
* TextEncoder instance.
* @type {TextEncoder|null}
*/ const ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;
*/ const ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder("utf-8") : null;
/**
* TextDecoder instance.
* @type {TextDecoder|null}
*/ const DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;
*/ const DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder("utf-8") : null;
/**
* Converts an UTF-8 string to an Uint8Array.
* @param {string} str String.
Expand Down Expand Up @@ -1861,6 +1861,6 @@ const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);
/**
* Library version.
* @type {string}
*/ const version = "9.3.0";
*/ const version = "9.2.4";

export { HOTP, Secret, TOTP, URI, version };
12 changes: 6 additions & 6 deletions 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.

44 changes: 38 additions & 6 deletions dist/otpauth.node.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! otpauth 9.3.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth
/// <reference types="./otpauth.d.ts" />
// @license otpauth 9.2.4 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth
// @ts-nocheck
/// <reference types="./otpauth.d.ts" />
'use strict';

var crypto = require('node:crypto');
Expand Down Expand Up @@ -41,6 +41,20 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
return arr;
};

const hmac = undefined;

const sha1 = undefined;

const sha224 = undefined;
const sha256 = undefined;
const sha384 = undefined;
const sha512 = undefined;

const sha3_224 = undefined;
const sha3_256 = undefined;
const sha3_384 = undefined;
const sha3_512 = undefined;

/**
* "globalThis" ponyfill.
* @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)
Expand Down Expand Up @@ -70,6 +84,20 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
return undefined;
})();

/**
* OpenSSL-Noble hashes map.
* @type {Object.<string, sha1|sha224|sha256|sha384|sha512|sha3_224|sha3_256|sha3_384|sha3_512>}
*/ const OPENSSL_NOBLE_HASHES = {
SHA1: sha1,
SHA224: sha224,
SHA256: sha256,
SHA384: sha384,
SHA512: sha512,
"SHA3-224": sha3_224,
"SHA3-256": sha3_256,
"SHA3-384": sha3_384,
"SHA3-512": sha3_512
};
/**
* Calculates an HMAC digest.
* In Node.js, the command "openssl list -digest-algorithms" displays the available digest algorithms.
Expand All @@ -83,7 +111,11 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
hmac.update(globalScope.Buffer.from(message));
return hmac.digest();
} else {
throw new Error("Missing HMAC function");
const hash = OPENSSL_NOBLE_HASHES[algorithm.toUpperCase()];
if (typeof hash === "undefined") {
throw new TypeError("Unknown hash function");
}
return hmac(hash, key, message);
}
};

Expand Down Expand Up @@ -194,11 +226,11 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
/**
* TextEncoder instance.
* @type {TextEncoder|null}
*/ const ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;
*/ const ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder("utf-8") : null;
/**
* TextDecoder instance.
* @type {TextDecoder|null}
*/ const DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;
*/ const DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder("utf-8") : null;
/**
* Converts an UTF-8 string to an Uint8Array.
* @param {string} str String.
Expand Down Expand Up @@ -799,7 +831,7 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
/**
* Library version.
* @type {string}
*/ const version = "9.3.0";
*/ const version = "9.2.4";

exports.HOTP = HOTP;
exports.Secret = Secret;
Expand Down
14 changes: 7 additions & 7 deletions 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.

14 changes: 7 additions & 7 deletions 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.

44 changes: 38 additions & 6 deletions dist/otpauth.node.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! otpauth 9.3.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth
/// <reference types="./otpauth.d.ts" />
// @license otpauth 9.2.4 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth
// @ts-nocheck
/// <reference types="./otpauth.d.ts" />
import * as crypto from 'node:crypto';

/**
Expand All @@ -20,6 +20,20 @@ import * as crypto from 'node:crypto';
return arr;
};

const hmac = undefined;

const sha1 = undefined;

const sha224 = undefined;
const sha256 = undefined;
const sha384 = undefined;
const sha512 = undefined;

const sha3_224 = undefined;
const sha3_256 = undefined;
const sha3_384 = undefined;
const sha3_512 = undefined;

/**
* "globalThis" ponyfill.
* @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)
Expand Down Expand Up @@ -49,6 +63,20 @@ import * as crypto from 'node:crypto';
return undefined;
})();

/**
* OpenSSL-Noble hashes map.
* @type {Object.<string, sha1|sha224|sha256|sha384|sha512|sha3_224|sha3_256|sha3_384|sha3_512>}
*/ const OPENSSL_NOBLE_HASHES = {
SHA1: sha1,
SHA224: sha224,
SHA256: sha256,
SHA384: sha384,
SHA512: sha512,
"SHA3-224": sha3_224,
"SHA3-256": sha3_256,
"SHA3-384": sha3_384,
"SHA3-512": sha3_512
};
/**
* Calculates an HMAC digest.
* In Node.js, the command "openssl list -digest-algorithms" displays the available digest algorithms.
Expand All @@ -62,7 +90,11 @@ import * as crypto from 'node:crypto';
hmac.update(globalScope.Buffer.from(message));
return hmac.digest();
} else {
throw new Error("Missing HMAC function");
const hash = OPENSSL_NOBLE_HASHES[algorithm.toUpperCase()];
if (typeof hash === "undefined") {
throw new TypeError("Unknown hash function");
}
return hmac(hash, key, message);
}
};

Expand Down Expand Up @@ -173,11 +205,11 @@ import * as crypto from 'node:crypto';
/**
* TextEncoder instance.
* @type {TextEncoder|null}
*/ const ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;
*/ const ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder("utf-8") : null;
/**
* TextDecoder instance.
* @type {TextDecoder|null}
*/ const DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;
*/ const DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder("utf-8") : null;
/**
* Converts an UTF-8 string to an Uint8Array.
* @param {string} str String.
Expand Down Expand Up @@ -778,6 +810,6 @@ import * as crypto from 'node:crypto';
/**
* Library version.
* @type {string}
*/ const version = "9.3.0";
*/ const version = "9.2.4";

export { HOTP, Secret, TOTP, URI, version };
Loading

0 comments on commit 3081f2f

Please sign in to comment.