@ac-kit/crypto-mac 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +52 -0
- package/dist/hmac-core.d.ts +29 -0
- package/dist/hmac-core.d.ts.map +1 -0
- package/dist/hmac-core.js +60 -0
- package/dist/hmac-core.js.map +1 -0
- package/dist/hmac-md5.d.ts +7 -0
- package/dist/hmac-md5.d.ts.map +1 -0
- package/dist/hmac-md5.js +12 -0
- package/dist/hmac-md5.js.map +1 -0
- package/dist/hmac-sha1.d.ts +11 -0
- package/dist/hmac-sha1.d.ts.map +1 -0
- package/dist/hmac-sha1.js +23 -0
- package/dist/hmac-sha1.js.map +1 -0
- package/dist/hmac-sha224.d.ts +6 -0
- package/dist/hmac-sha224.d.ts.map +1 -0
- package/dist/hmac-sha224.js +11 -0
- package/dist/hmac-sha224.js.map +1 -0
- package/dist/hmac-sha256.d.ts +11 -0
- package/dist/hmac-sha256.d.ts.map +1 -0
- package/dist/hmac-sha256.js +23 -0
- package/dist/hmac-sha256.js.map +1 -0
- package/dist/hmac-sha384.d.ts +11 -0
- package/dist/hmac-sha384.d.ts.map +1 -0
- package/dist/hmac-sha384.js +23 -0
- package/dist/hmac-sha384.js.map +1 -0
- package/dist/hmac-sha512.d.ts +11 -0
- package/dist/hmac-sha512.d.ts.map +1 -0
- package/dist/hmac-sha512.js +23 -0
- package/dist/hmac-sha512.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @ac-kit/crypto-mac
|
|
2
|
+
|
|
3
|
+
A **message authentication code** answers one question: did this exact message
|
|
4
|
+
come from someone holding the shared key? A plain hash cannot — anyone who
|
|
5
|
+
changes the message can recompute the hash to match. HMAC mixes a secret key
|
|
6
|
+
into the hash, so only a key holder can produce a tag that verifies.
|
|
7
|
+
|
|
8
|
+
Reach for it when signing an API request, authenticating a webhook payload,
|
|
9
|
+
stamping a session cookie, or deriving a token that must not be forgeable.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { sha256Ts } from "@ac-kit/crypto-hash";
|
|
13
|
+
import { hmacSha256Ts, hmacVerify } from "@ac-kit/crypto-mac";
|
|
14
|
+
|
|
15
|
+
const key = new TextEncoder().encode("shared secret");
|
|
16
|
+
const message = new TextEncoder().encode("transfer 100 to alice");
|
|
17
|
+
|
|
18
|
+
const tag = hmacSha256Ts(key, message);
|
|
19
|
+
const authentic = hmacVerify(sha256Ts, 64, key, message, tag);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`hmacVerify` compares in constant time, so a wrong tag takes as long to reject
|
|
23
|
+
as a right one — never compare tags with `===`.
|
|
24
|
+
|
|
25
|
+
## What it exposes
|
|
26
|
+
|
|
27
|
+
- `hmac(hash, blockSizeBytes, key, message, tagLengthBytes?)` — the generic
|
|
28
|
+
RFC 2104 construction over any hash function.
|
|
29
|
+
- `hmacVerify(hash, blockSizeBytes, key, message, tag)` — constant-time
|
|
30
|
+
comparison against a freshly computed tag.
|
|
31
|
+
- Named wrappers binding one hash each: `hmacMd5`, `hmacSha1`, `hmacSha224`,
|
|
32
|
+
`hmacSha256`, `hmacSha384`, `hmacSha512`.
|
|
33
|
+
|
|
34
|
+
Wrappers come in two shapes. A bare name (`hmacSha256`) prefers the Web Crypto
|
|
35
|
+
kernel and returns `Uint8Array | Promise<Uint8Array>`; the `Ts` suffix
|
|
36
|
+
(`hmacSha256Ts`) is always the TypeScript kernel and always synchronous. MD5 and
|
|
37
|
+
SHA-224 have no Web Crypto equivalent, so each offers a single synchronous
|
|
38
|
+
function.
|
|
39
|
+
|
|
40
|
+
Portable: no Node.js built-ins, so it runs unchanged in browsers, Deno, Bun and
|
|
41
|
+
edge runtimes.
|
|
42
|
+
|
|
43
|
+
See the
|
|
44
|
+
[generated API docs](https://anthochamp.github.io/node-essentials/api/crypto-mac/)
|
|
45
|
+
for the full reference.
|
|
46
|
+
|
|
47
|
+
## Further reading
|
|
48
|
+
|
|
49
|
+
- [RFC 2104](https://www.rfc-editor.org/rfc/rfc2104) — the HMAC specification
|
|
50
|
+
(authoritative).
|
|
51
|
+
- [FIPS 198-1](https://csrc.nist.gov/pubs/fips/198-1/final) — the NIST standard
|
|
52
|
+
this implements (authoritative).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMAC (RFC 2104 / FIPS 198-1): a keyed-hash message authentication code built
|
|
3
|
+
* from any hash function and its compression function's block size — both
|
|
4
|
+
* supplied explicitly by the caller (e.g. `hmac(sha256Ts, 64, key, message)`),
|
|
5
|
+
* matching every other block-size-parametrized primitive in `crypto/hash`
|
|
6
|
+
* (`merkleDamgardPad`) rather than a hash-algorithm registry; the caller owns
|
|
7
|
+
* algorithm specificities.
|
|
8
|
+
*
|
|
9
|
+
* @param hash A one-shot, synchronous hash function — the TS kernel of
|
|
10
|
+
* whichever algorithm the caller has chosen (e.g. `sha256Ts`), never the
|
|
11
|
+
* Web-Crypto-preferring dual kernel, since that one's `Promise`-returning
|
|
12
|
+
* shape doesn't fit HMAC's handful of nested synchronous calls.
|
|
13
|
+
* @param blockSizeBytes `hash`'s compression function's block size — 64 for
|
|
14
|
+
* MD5/SHA-1/SHA-224/SHA-256, 128 for SHA-384/SHA-512.
|
|
15
|
+
* @param tagLengthBytes Truncates the returned tag to this many bytes (RFC 2104
|
|
16
|
+
* §5). Defaults to the full untruncated output.
|
|
17
|
+
*/
|
|
18
|
+
export declare function hmac<THashReturnArrayBuffer extends ArrayBufferLike>(hash: (data: Uint8Array) => Uint8Array<THashReturnArrayBuffer>, blockSizeBytes: number, key: Uint8Array, message: Uint8Array, tagLengthBytes?: number): Uint8Array<THashReturnArrayBuffer>;
|
|
19
|
+
/**
|
|
20
|
+
* Verifies `tag` against a freshly computed HMAC, comparing in constant time
|
|
21
|
+
* via `@ac-kit/crypto-safe`'s `constantTimeBytesIsEqual`. Unlike
|
|
22
|
+
* `constantTimeBytesIsEqual` itself — which throws on a length mismatch, since
|
|
23
|
+
* its own callers always know the expected length in advance — a length
|
|
24
|
+
* mismatch here is ordinary invalid input (the tag is attacker-controlled at
|
|
25
|
+
* this boundary, e.g. a modified or truncated tag from a Wycheproof `"invalid"`
|
|
26
|
+
* test vector) and simply fails verification rather than throwing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function hmacVerify(hash: (data: Uint8Array) => Uint8Array, blockSizeBytes: number, key: Uint8Array, message: Uint8Array, tag: Uint8Array): boolean;
|
|
29
|
+
//# sourceMappingURL=hmac-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-core.d.ts","sourceRoot":"","sources":["../src/hmac-core.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,sBAAsB,SAAS,eAAe,EAClE,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC,sBAAsB,CAAC,EAC9D,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,UAAU,EACnB,cAAc,CAAC,EAAE,MAAM,GACrB,UAAU,CAAC,sBAAsB,CAAC,CAgBpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EACtC,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,UAAU,GACb,OAAO,CAMT"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { concatBytes } from "@ac-kit/core";
|
|
2
|
+
import { constantTimeBytesIsEqual } from "@ac-kit/crypto-safe";
|
|
3
|
+
/**
|
|
4
|
+
* HMAC (RFC 2104 / FIPS 198-1): a keyed-hash message authentication code built
|
|
5
|
+
* from any hash function and its compression function's block size — both
|
|
6
|
+
* supplied explicitly by the caller (e.g. `hmac(sha256Ts, 64, key, message)`),
|
|
7
|
+
* matching every other block-size-parametrized primitive in `crypto/hash`
|
|
8
|
+
* (`merkleDamgardPad`) rather than a hash-algorithm registry; the caller owns
|
|
9
|
+
* algorithm specificities.
|
|
10
|
+
*
|
|
11
|
+
* @param hash A one-shot, synchronous hash function — the TS kernel of
|
|
12
|
+
* whichever algorithm the caller has chosen (e.g. `sha256Ts`), never the
|
|
13
|
+
* Web-Crypto-preferring dual kernel, since that one's `Promise`-returning
|
|
14
|
+
* shape doesn't fit HMAC's handful of nested synchronous calls.
|
|
15
|
+
* @param blockSizeBytes `hash`'s compression function's block size — 64 for
|
|
16
|
+
* MD5/SHA-1/SHA-224/SHA-256, 128 for SHA-384/SHA-512.
|
|
17
|
+
* @param tagLengthBytes Truncates the returned tag to this many bytes (RFC 2104
|
|
18
|
+
* §5). Defaults to the full untruncated output.
|
|
19
|
+
*/
|
|
20
|
+
export function hmac(hash, blockSizeBytes, key, message, tagLengthBytes) {
|
|
21
|
+
const blockSizedKey = deriveBlockSizedKey_(hash, blockSizeBytes, key);
|
|
22
|
+
const ipad = new Uint8Array(blockSizeBytes);
|
|
23
|
+
const opad = new Uint8Array(blockSizeBytes);
|
|
24
|
+
for (let index = 0; index < blockSizeBytes; index++) {
|
|
25
|
+
const keyByte = blockSizedKey[index];
|
|
26
|
+
ipad[index] = keyByte ^ 0x36;
|
|
27
|
+
opad[index] = keyByte ^ 0x5c;
|
|
28
|
+
}
|
|
29
|
+
const innerDigest = hash(concatBytes(ipad, message));
|
|
30
|
+
const tag = hash(concatBytes(opad, innerDigest));
|
|
31
|
+
return tagLengthBytes === undefined ? tag : tag.subarray(0, tagLengthBytes);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Verifies `tag` against a freshly computed HMAC, comparing in constant time
|
|
35
|
+
* via `@ac-kit/crypto-safe`'s `constantTimeBytesIsEqual`. Unlike
|
|
36
|
+
* `constantTimeBytesIsEqual` itself — which throws on a length mismatch, since
|
|
37
|
+
* its own callers always know the expected length in advance — a length
|
|
38
|
+
* mismatch here is ordinary invalid input (the tag is attacker-controlled at
|
|
39
|
+
* this boundary, e.g. a modified or truncated tag from a Wycheproof `"invalid"`
|
|
40
|
+
* test vector) and simply fails verification rather than throwing.
|
|
41
|
+
*/
|
|
42
|
+
export function hmacVerify(hash, blockSizeBytes, key, message, tag) {
|
|
43
|
+
const expected = hmac(hash, blockSizeBytes, key, message, tag.length);
|
|
44
|
+
return (expected.length === tag.length && constantTimeBytesIsEqual(expected, tag));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* FIPS 198-1 §4: keys longer than the block size are shortened by hashing them
|
|
48
|
+
* first; keys shorter than the block size are zero-padded on the right. A key
|
|
49
|
+
* already exactly `blockSizeBytes` long needs neither step.
|
|
50
|
+
*/
|
|
51
|
+
function deriveBlockSizedKey_(hash, blockSizeBytes, key) {
|
|
52
|
+
const baseKey = key.length > blockSizeBytes ? hash(key) : key;
|
|
53
|
+
if (baseKey.length === blockSizeBytes) {
|
|
54
|
+
return baseKey;
|
|
55
|
+
}
|
|
56
|
+
const blockSizedKey = new Uint8Array(blockSizeBytes);
|
|
57
|
+
blockSizedKey.set(baseKey);
|
|
58
|
+
return blockSizedKey;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=hmac-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-core.js","sourceRoot":"","sources":["../src/hmac-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,IAAI,CACnB,IAA8D,EAC9D,cAAsB,EACtB,GAAe,EACf,OAAmB,EACnB,cAAuB;IAEvB,MAAM,aAAa,GAAG,oBAAoB,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;IAEtE,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC;IAE5C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,cAAc,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAE,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;IAC9B,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAEjD,OAAO,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACzB,IAAsC,EACtC,cAAsB,EACtB,GAAe,EACf,OAAmB,EACnB,GAAe;IAEf,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAEtE,OAAO,CACN,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,IAAI,wBAAwB,CAAC,QAAQ,EAAE,GAAG,CAAC,CACzE,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAC5B,IAAsC,EACtC,cAAsB,EACtB,GAAe;IAEf,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAE9D,IAAI,OAAO,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;QACvC,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC;IACrD,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAE3B,OAAO,aAAa,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMAC-MD5 (RFC 2104), legacy — needed only for interop, never a new design's
|
|
3
|
+
* default; see `@ac-kit/crypto-hash`'s `md5` for the same caveat one level
|
|
4
|
+
* down. No Web Crypto kernel, matching `md5` itself.
|
|
5
|
+
*/
|
|
6
|
+
export declare function hmacMd5(key: Uint8Array, message: Uint8Array): Uint8Array;
|
|
7
|
+
//# sourceMappingURL=hmac-md5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-md5.d.ts","sourceRoot":"","sources":["../src/hmac-md5.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,UAAU,CAExE"}
|
package/dist/hmac-md5.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { md5 } from "@ac-kit/crypto-hash";
|
|
2
|
+
import { hmac } from "./hmac-core.js";
|
|
3
|
+
const BLOCK_SIZE_BYTES = 64;
|
|
4
|
+
/**
|
|
5
|
+
* HMAC-MD5 (RFC 2104), legacy — needed only for interop, never a new design's
|
|
6
|
+
* default; see `@ac-kit/crypto-hash`'s `md5` for the same caveat one level
|
|
7
|
+
* down. No Web Crypto kernel, matching `md5` itself.
|
|
8
|
+
*/
|
|
9
|
+
export function hmacMd5(key, message) {
|
|
10
|
+
return hmac(md5, BLOCK_SIZE_BYTES, key, message);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=hmac-md5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-md5.js","sourceRoot":"","sources":["../src/hmac-md5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAe,EAAE,OAAmB;IAC3D,OAAO,IAAI,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MaybePromiseLike } from "@ac-kit/core";
|
|
2
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
3
|
+
export declare function hmacSha1Ts(key: Uint8Array, message: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
4
|
+
/**
|
|
5
|
+
* HMAC-SHA-1 (RFC 2104), legacy interop only. Prefers the Web Crypto kernel
|
|
6
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
7
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
8
|
+
* dual-kernel shape as `sha1`/`sha256` in `@ac-kit/crypto-hash`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hmacSha1(key: Uint8Array<ArrayBuffer>, message: Uint8Array<ArrayBuffer>): MaybePromiseLike<Uint8Array<ArrayBuffer>>;
|
|
11
|
+
//# sourceMappingURL=hmac-sha1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha1.d.ts","sourceRoot":"","sources":["../src/hmac-sha1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,0EAA0E;AAC1E,wBAAgB,UAAU,CACzB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,UAAU,GACjB,UAAU,CAAC,WAAW,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACvB,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,EAC5B,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAC9B,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAS3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sha1Js } from "@ac-kit/crypto-hash";
|
|
2
|
+
import { hmac } from "./hmac-core.js";
|
|
3
|
+
const BLOCK_SIZE_BYTES = 64;
|
|
4
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
5
|
+
export function hmacSha1Ts(key, message) {
|
|
6
|
+
return hmac(sha1Js, BLOCK_SIZE_BYTES, key, message);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* HMAC-SHA-1 (RFC 2104), legacy interop only. Prefers the Web Crypto kernel
|
|
10
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
11
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
12
|
+
* dual-kernel shape as `sha1`/`sha256` in `@ac-kit/crypto-hash`.
|
|
13
|
+
*/
|
|
14
|
+
export function hmacSha1(key, message) {
|
|
15
|
+
if (typeof crypto === "undefined" || !crypto.subtle) {
|
|
16
|
+
return hmacSha1Ts(key, message);
|
|
17
|
+
}
|
|
18
|
+
return crypto.subtle
|
|
19
|
+
.importKey("raw", key, { name: "HMAC", hash: "SHA-1" }, false, ["sign"])
|
|
20
|
+
.then((cryptoKey) => crypto.subtle.sign("HMAC", cryptoKey, message))
|
|
21
|
+
.then((signature) => new Uint8Array(signature));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=hmac-sha1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha1.js","sourceRoot":"","sources":["../src/hmac-sha1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CACzB,GAAe,EACf,OAAmB;IAEnB,OAAO,IAAI,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACvB,GAA4B,EAC5B,OAAgC;IAEhC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrD,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,MAAM,CAAC,MAAM;SAClB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;SACvE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SACnE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha224.d.ts","sourceRoot":"","sources":["../src/hmac-sha224.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,UAAU,CAE3E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { sha224 } from "@ac-kit/crypto-hash";
|
|
2
|
+
import { hmac } from "./hmac-core.js";
|
|
3
|
+
const BLOCK_SIZE_BYTES = 64;
|
|
4
|
+
/**
|
|
5
|
+
* HMAC-SHA-224 (RFC 2104). No Web Crypto kernel, matching `sha224` itself — no
|
|
6
|
+
* engine recognises the algorithm name.
|
|
7
|
+
*/
|
|
8
|
+
export function hmacSha224(key, message) {
|
|
9
|
+
return hmac(sha224, BLOCK_SIZE_BYTES, key, message);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=hmac-sha224.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha224.js","sourceRoot":"","sources":["../src/hmac-sha224.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe,EAAE,OAAmB;IAC9D,OAAO,IAAI,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MaybePromiseLike } from "@ac-kit/core";
|
|
2
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
3
|
+
export declare function hmacSha256Ts(key: Uint8Array, message: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
4
|
+
/**
|
|
5
|
+
* HMAC-SHA-256 (RFC 2104). Prefers the Web Crypto kernel
|
|
6
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
7
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
8
|
+
* dual-kernel shape as `sha256` in `@ac-kit/crypto-hash`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hmacSha256(key: Uint8Array<ArrayBuffer>, message: Uint8Array<ArrayBuffer>): MaybePromiseLike<Uint8Array<ArrayBuffer>>;
|
|
11
|
+
//# sourceMappingURL=hmac-sha256.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha256.d.ts","sourceRoot":"","sources":["../src/hmac-sha256.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,0EAA0E;AAC1E,wBAAgB,YAAY,CAC3B,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,UAAU,GACjB,UAAU,CAAC,WAAW,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,EAC5B,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAC9B,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAS3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sha256Ts } from "@ac-kit/crypto-hash";
|
|
2
|
+
import { hmac } from "./hmac-core.js";
|
|
3
|
+
const BLOCK_SIZE_BYTES = 64;
|
|
4
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
5
|
+
export function hmacSha256Ts(key, message) {
|
|
6
|
+
return hmac(sha256Ts, BLOCK_SIZE_BYTES, key, message);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* HMAC-SHA-256 (RFC 2104). Prefers the Web Crypto kernel
|
|
10
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
11
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
12
|
+
* dual-kernel shape as `sha256` in `@ac-kit/crypto-hash`.
|
|
13
|
+
*/
|
|
14
|
+
export function hmacSha256(key, message) {
|
|
15
|
+
if (typeof crypto === "undefined" || !crypto.subtle) {
|
|
16
|
+
return hmacSha256Ts(key, message);
|
|
17
|
+
}
|
|
18
|
+
return crypto.subtle
|
|
19
|
+
.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"])
|
|
20
|
+
.then((cryptoKey) => crypto.subtle.sign("HMAC", cryptoKey, message))
|
|
21
|
+
.then((signature) => new Uint8Array(signature));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=hmac-sha256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha256.js","sourceRoot":"","sources":["../src/hmac-sha256.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAC3B,GAAe,EACf,OAAmB;IAEnB,OAAO,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACzB,GAA4B,EAC5B,OAAgC;IAEhC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrD,OAAO,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,MAAM;SAClB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;SACzE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SACnE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MaybePromiseLike } from "@ac-kit/core";
|
|
2
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
3
|
+
export declare function hmacSha384Ts(key: Uint8Array, message: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
4
|
+
/**
|
|
5
|
+
* HMAC-SHA-384 (RFC 2104). Prefers the Web Crypto kernel
|
|
6
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
7
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
8
|
+
* dual-kernel shape as `sha384` in `@ac-kit/crypto-hash`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hmacSha384(key: Uint8Array<ArrayBuffer>, message: Uint8Array<ArrayBuffer>): MaybePromiseLike<Uint8Array<ArrayBuffer>>;
|
|
11
|
+
//# sourceMappingURL=hmac-sha384.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha384.d.ts","sourceRoot":"","sources":["../src/hmac-sha384.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,0EAA0E;AAC1E,wBAAgB,YAAY,CAC3B,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,UAAU,GACjB,UAAU,CAAC,WAAW,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,EAC5B,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAC9B,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAS3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sha384Ts } from "@ac-kit/crypto-hash";
|
|
2
|
+
import { hmac } from "./hmac-core.js";
|
|
3
|
+
const BLOCK_SIZE_BYTES = 128;
|
|
4
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
5
|
+
export function hmacSha384Ts(key, message) {
|
|
6
|
+
return hmac(sha384Ts, BLOCK_SIZE_BYTES, key, message);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* HMAC-SHA-384 (RFC 2104). Prefers the Web Crypto kernel
|
|
10
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
11
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
12
|
+
* dual-kernel shape as `sha384` in `@ac-kit/crypto-hash`.
|
|
13
|
+
*/
|
|
14
|
+
export function hmacSha384(key, message) {
|
|
15
|
+
if (typeof crypto === "undefined" || !crypto.subtle) {
|
|
16
|
+
return hmacSha384Ts(key, message);
|
|
17
|
+
}
|
|
18
|
+
return crypto.subtle
|
|
19
|
+
.importKey("raw", key, { name: "HMAC", hash: "SHA-384" }, false, ["sign"])
|
|
20
|
+
.then((cryptoKey) => crypto.subtle.sign("HMAC", cryptoKey, message))
|
|
21
|
+
.then((signature) => new Uint8Array(signature));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=hmac-sha384.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha384.js","sourceRoot":"","sources":["../src/hmac-sha384.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAC3B,GAAe,EACf,OAAmB;IAEnB,OAAO,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACzB,GAA4B,EAC5B,OAAgC;IAEhC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrD,OAAO,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,MAAM;SAClB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;SACzE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SACnE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MaybePromiseLike } from "@ac-kit/core";
|
|
2
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
3
|
+
export declare function hmacSha512Ts(key: Uint8Array, message: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
4
|
+
/**
|
|
5
|
+
* HMAC-SHA-512 (RFC 2104). Prefers the Web Crypto kernel
|
|
6
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
7
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
8
|
+
* dual-kernel shape as `sha512` in `@ac-kit/crypto-hash`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hmacSha512(key: Uint8Array<ArrayBuffer>, message: Uint8Array<ArrayBuffer>): MaybePromiseLike<Uint8Array<ArrayBuffer>>;
|
|
11
|
+
//# sourceMappingURL=hmac-sha512.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha512.d.ts","sourceRoot":"","sources":["../src/hmac-sha512.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,0EAA0E;AAC1E,wBAAgB,YAAY,CAC3B,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,UAAU,GACjB,UAAU,CAAC,WAAW,CAAC,CAEzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,EAC5B,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAC9B,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAS3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sha512Ts } from "@ac-kit/crypto-hash";
|
|
2
|
+
import { hmac } from "./hmac-core.js";
|
|
3
|
+
const BLOCK_SIZE_BYTES = 128;
|
|
4
|
+
/** The TS kernel, always available — see the module doc in `index.ts`. */
|
|
5
|
+
export function hmacSha512Ts(key, message) {
|
|
6
|
+
return hmac(sha512Ts, BLOCK_SIZE_BYTES, key, message);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* HMAC-SHA-512 (RFC 2104). Prefers the Web Crypto kernel
|
|
10
|
+
* (`crypto.subtle.importKey` + `.sign`, real `Promise`) when available; falls
|
|
11
|
+
* back to the TS kernel (synchronous, no `Promise` allocation) otherwise — same
|
|
12
|
+
* dual-kernel shape as `sha512` in `@ac-kit/crypto-hash`.
|
|
13
|
+
*/
|
|
14
|
+
export function hmacSha512(key, message) {
|
|
15
|
+
if (typeof crypto === "undefined" || !crypto.subtle) {
|
|
16
|
+
return hmacSha512Ts(key, message);
|
|
17
|
+
}
|
|
18
|
+
return crypto.subtle
|
|
19
|
+
.importKey("raw", key, { name: "HMAC", hash: "SHA-512" }, false, ["sign"])
|
|
20
|
+
.then((cryptoKey) => crypto.subtle.sign("HMAC", cryptoKey, message))
|
|
21
|
+
.then((signature) => new Uint8Array(signature));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=hmac-sha512.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmac-sha512.js","sourceRoot":"","sources":["../src/hmac-sha512.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAC3B,GAAe,EACf,OAAmB;IAEnB,OAAO,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACzB,GAA4B,EAC5B,OAAgC;IAEhC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrD,OAAO,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,MAAM;SAClB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;SACzE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SACnE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMAC (RFC 2104 / FIPS 198-1) — a keyed-hash message authentication code.
|
|
3
|
+
*
|
|
4
|
+
* `_hmac-core.ts`'s `hmac()`/`hmacVerify()` are the generic construction,
|
|
5
|
+
* parametrized by hash function and block size; every named export below is a
|
|
6
|
+
* thin wrapper binding one specific hash. Wrappers for algorithms with a Web
|
|
7
|
+
* Crypto kernel (`crypto.subtle.sign`/`.importKey`) come in the same pair as
|
|
8
|
+
* their `@ac-kit/crypto-hash` counterpart: a `*Ts` name (always the TS kernel,
|
|
9
|
+
* synchronous) and a bare name (prefers Web Crypto, `Uint8Array |
|
|
10
|
+
* Promise<Uint8Array>`). MD5 and SHA-224 have no Web Crypto kernel, matching
|
|
11
|
+
* `md5`/`sha224` themselves, so each gets one synchronous function.
|
|
12
|
+
*/
|
|
13
|
+
export * from "./hmac-core.js";
|
|
14
|
+
export * from "./hmac-md5.js";
|
|
15
|
+
export * from "./hmac-sha1.js";
|
|
16
|
+
export * from "./hmac-sha224.js";
|
|
17
|
+
export * from "./hmac-sha256.js";
|
|
18
|
+
export * from "./hmac-sha384.js";
|
|
19
|
+
export * from "./hmac-sha512.js";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMAC (RFC 2104 / FIPS 198-1) — a keyed-hash message authentication code.
|
|
3
|
+
*
|
|
4
|
+
* `_hmac-core.ts`'s `hmac()`/`hmacVerify()` are the generic construction,
|
|
5
|
+
* parametrized by hash function and block size; every named export below is a
|
|
6
|
+
* thin wrapper binding one specific hash. Wrappers for algorithms with a Web
|
|
7
|
+
* Crypto kernel (`crypto.subtle.sign`/`.importKey`) come in the same pair as
|
|
8
|
+
* their `@ac-kit/crypto-hash` counterpart: a `*Ts` name (always the TS kernel,
|
|
9
|
+
* synchronous) and a bare name (prefers Web Crypto, `Uint8Array |
|
|
10
|
+
* Promise<Uint8Array>`). MD5 and SHA-224 have no Web Crypto kernel, matching
|
|
11
|
+
* `md5`/`sha224` themselves, so each gets one synchronous function.
|
|
12
|
+
*/
|
|
13
|
+
export * from "./hmac-core.js";
|
|
14
|
+
export * from "./hmac-md5.js";
|
|
15
|
+
export * from "./hmac-sha1.js";
|
|
16
|
+
export * from "./hmac-sha224.js";
|
|
17
|
+
export * from "./hmac-sha256.js";
|
|
18
|
+
export * from "./hmac-sha384.js";
|
|
19
|
+
export * from "./hmac-sha512.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ac-kit/crypto-mac",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Message authentication codes: generic hmac() and hmacVerify() plus named MD5, SHA-1 and SHA-2 HMAC wrappers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"authentication",
|
|
7
|
+
"crypto",
|
|
8
|
+
"hmac",
|
|
9
|
+
"mac"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://anthochamp.github.io/node-essentials/api/crypto-mac/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/anthochamp/node-essentials/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "BSD-3-Clause",
|
|
16
|
+
"author": "Anthony Champagne <dev@anthonychampagne.fr>",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/anthochamp/node-essentials.git",
|
|
20
|
+
"directory": "packages/crypto-mac"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"compile": "tsc -p ./tsconfig.build.json -outDir dist",
|
|
40
|
+
"compile:check": "tsc -noEmit -p ./tsconfig.json",
|
|
41
|
+
"clean": "rimraf dist",
|
|
42
|
+
"build": "yarn clean && yarn compile",
|
|
43
|
+
"test": "yarn run -T vitest run",
|
|
44
|
+
"prepack": "yarn build"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@ac-kit/core": "^0.1.0",
|
|
48
|
+
"@ac-kit/crypto-hash": "^0.1.0",
|
|
49
|
+
"@ac-kit/crypto-safe": "^0.1.0",
|
|
50
|
+
"@types/web": "^0.0.354"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@ac-kit/fixture-crypto": "0.1.0",
|
|
54
|
+
"@ac-kit/tsconfig": "0.1.0",
|
|
55
|
+
"@ac-kit/typedoc-config": "0.1.0",
|
|
56
|
+
"@ac-kit/vitest-config": "0.1.0",
|
|
57
|
+
"@types/node": "26.5.1",
|
|
58
|
+
"@typescript/native": "typescript@7.0.2",
|
|
59
|
+
"rimraf": "6.1.3",
|
|
60
|
+
"typedoc": "0.28.20",
|
|
61
|
+
"typescript": "@typescript/typescript6@6.0.2",
|
|
62
|
+
"vite": "8.3.0",
|
|
63
|
+
"vitest": "5.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"vitest": ">=4.0.0"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=24"
|
|
70
|
+
}
|
|
71
|
+
}
|