@santi020k/auth-recovery 0.4.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 +21 -0
- package/README.md +36 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Santiago Molina
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# `@santi020k/auth-recovery`
|
|
2
|
+
|
|
3
|
+
Web Crypto-compatible, consumer-owned one-time recovery-code primitives. Codes use an unambiguous uppercase alphabet,
|
|
4
|
+
carry approximately 99 bits of entropy, and are displayed as four groups of five characters. Storage receives only a
|
|
5
|
+
versioned HMAC-SHA-256 digest scoped to a stable subject ID and an application-specific secret pepper.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
const codes = await issueRecoveryCodes({
|
|
9
|
+
pepper: env.AUTH_RECOVERY_PEPPER,
|
|
10
|
+
store: recoveryStore,
|
|
11
|
+
subject: user.id,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Render or download `codes` once over an already authenticated, protected flow.
|
|
15
|
+
// The package and store provide no plaintext retrieval API.
|
|
16
|
+
|
|
17
|
+
const consumed = await consumeRecoveryCode({
|
|
18
|
+
code: submittedCode,
|
|
19
|
+
pepper: env.AUTH_RECOVERY_PEPPER,
|
|
20
|
+
store: recoveryStore,
|
|
21
|
+
subject: user.id,
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The consumer implements `RecoveryCodeStore`. `consumeRecoveryCodeAtomically` must match an unused digest and delete or
|
|
26
|
+
mark it used in the same database transaction; a read followed by a later write is not sufficient. The consumer also
|
|
27
|
+
owns the transaction and policy for `replaceRecoveryCodes`, including whether issuing a new set invalidates every old
|
|
28
|
+
code.
|
|
29
|
+
|
|
30
|
+
Never persist, log, email, or return plaintext codes after the one issuance response. Keep the pepper in the consumer's
|
|
31
|
+
secret manager, use at least 32 bytes, and isolate it from authentication secrets used by other products. Pepper
|
|
32
|
+
rotation requires an explicit forward-recovery plan because existing digests will no longer match.
|
|
33
|
+
|
|
34
|
+
This package does not decide who may recover an account. Identity proof, owner/admin authority, rate limits, alerts,
|
|
35
|
+
audit records, session revocation, UI, and support procedures remain consumer-owned. A valid code should normally be
|
|
36
|
+
followed by revoking existing sessions and completing the application's documented recovery ceremony.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface RecoveryCodeDigestRecord {
|
|
2
|
+
digest: string;
|
|
3
|
+
}
|
|
4
|
+
export interface ConsumeRecoveryCodeInput extends RecoveryCodeDigestRecord {
|
|
5
|
+
subject: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ReplaceRecoveryCodesInput {
|
|
8
|
+
records: readonly RecoveryCodeDigestRecord[];
|
|
9
|
+
subject: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Storage is implemented and owned by each consumer. The atomic consume method
|
|
13
|
+
* must match an unused digest and mark/delete it in one transaction so two
|
|
14
|
+
* concurrent requests cannot both succeed. Replacement policy, auditing,
|
|
15
|
+
* authorization, and recovery approval remain consumer responsibilities.
|
|
16
|
+
*/
|
|
17
|
+
export interface RecoveryCodeStore {
|
|
18
|
+
consumeRecoveryCodeAtomically(input: ConsumeRecoveryCodeInput): Promise<boolean>;
|
|
19
|
+
replaceRecoveryCodes(input: ReplaceRecoveryCodesInput): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export interface RecoveryCodeCryptoOptions {
|
|
22
|
+
crypto?: Crypto;
|
|
23
|
+
}
|
|
24
|
+
export interface IssueRecoveryCodesOptions extends RecoveryCodeCryptoOptions {
|
|
25
|
+
count?: number;
|
|
26
|
+
pepper: string | Uint8Array;
|
|
27
|
+
store: RecoveryCodeStore;
|
|
28
|
+
subject: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ConsumeRecoveryCodeOptions extends RecoveryCodeCryptoOptions {
|
|
31
|
+
code: string;
|
|
32
|
+
pepper: string | Uint8Array;
|
|
33
|
+
store: RecoveryCodeStore;
|
|
34
|
+
subject: string;
|
|
35
|
+
}
|
|
36
|
+
export interface DigestRecoveryCodeOptions extends RecoveryCodeCryptoOptions {
|
|
37
|
+
code: string;
|
|
38
|
+
pepper: string | Uint8Array;
|
|
39
|
+
subject: string;
|
|
40
|
+
}
|
|
41
|
+
/** Accepts ASCII case, spaces, and hyphens; rejects ambiguous or lookalike characters. */
|
|
42
|
+
export declare function normalizeRecoveryCode(value: string): string;
|
|
43
|
+
/** Generates a 20-character code with approximately 99 bits of unbiased entropy. */
|
|
44
|
+
export declare function generateRecoveryCode(options?: RecoveryCodeCryptoOptions): string;
|
|
45
|
+
/** Returns a deterministic, versioned HMAC digest scoped to both pepper and stable subject ID. */
|
|
46
|
+
export declare function digestRecoveryCode(options: DigestRecoveryCodeOptions): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Replaces the consumer-owned digest set, then returns the new plaintext codes.
|
|
49
|
+
* Plaintext is never passed to storage and cannot be retrieved through this API.
|
|
50
|
+
*/
|
|
51
|
+
export declare function issueRecoveryCodes(options: IssueRecoveryCodesOptions): Promise<readonly string[]>;
|
|
52
|
+
/** Digests a candidate and delegates its single-use decision to the store's atomic consume operation. */
|
|
53
|
+
export declare function consumeRecoveryCode(options: ConsumeRecoveryCodeOptions): Promise<boolean>;
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAyB,SAAQ,wBAAwB;IACxE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,6BAA6B,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjF,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,yBAA0B,SAAQ,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PEPPER_BYTES = 32;
|
|
7
|
+
const DIGEST_PREFIX = "v1.";
|
|
8
|
+
const DIGEST_DOMAIN = "santi020k-auth-recovery:v1";
|
|
9
|
+
const NORMALIZABLE_SEPARATORS = new Set(["\t", "\n", "\r", " ", "-"]);
|
|
10
|
+
function resolveCrypto(value) {
|
|
11
|
+
return value ?? globalThis.crypto;
|
|
12
|
+
}
|
|
13
|
+
function includesControlCharacter(value) {
|
|
14
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
15
|
+
const codeUnit = value.charCodeAt(index);
|
|
16
|
+
if (codeUnit <= 31 || codeUnit === 127)
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
function normalizeSubject(value) {
|
|
22
|
+
if (value !== value.trim() || value.length === 0 || value.length > 256 || includesControlCharacter(value)) {
|
|
23
|
+
throw new Error("auth_recovery_subject_invalid");
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function pepperBytes(value) {
|
|
28
|
+
const bytes = new Uint8Array(typeof value === "string" ? new TextEncoder().encode(value) : value);
|
|
29
|
+
if (bytes.byteLength < MINIMUM_PEPPER_BYTES)
|
|
30
|
+
throw new Error("auth_recovery_pepper_too_short");
|
|
31
|
+
return bytes;
|
|
32
|
+
}
|
|
33
|
+
function requireCodeCount(value) {
|
|
34
|
+
const count = value ?? DEFAULT_CODE_COUNT;
|
|
35
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > MAX_CODE_COUNT) {
|
|
36
|
+
throw new Error("auth_recovery_code_count_invalid");
|
|
37
|
+
}
|
|
38
|
+
return count;
|
|
39
|
+
}
|
|
40
|
+
function encodeBase64Url(bytes) {
|
|
41
|
+
let binary = "";
|
|
42
|
+
for (const byte of bytes)
|
|
43
|
+
binary += String.fromCharCode(byte);
|
|
44
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
45
|
+
}
|
|
46
|
+
function formatCode(canonical) {
|
|
47
|
+
const groups = [];
|
|
48
|
+
for (let offset = 0; offset < canonical.length; offset += CODE_GROUP_SIZE) {
|
|
49
|
+
groups.push(canonical.slice(offset, offset + CODE_GROUP_SIZE));
|
|
50
|
+
}
|
|
51
|
+
return groups.join("-");
|
|
52
|
+
}
|
|
53
|
+
/** Accepts ASCII case, spaces, and hyphens; rejects ambiguous or lookalike characters. */
|
|
54
|
+
export function normalizeRecoveryCode(value) {
|
|
55
|
+
let normalized = "";
|
|
56
|
+
for (const character of value) {
|
|
57
|
+
if (NORMALIZABLE_SEPARATORS.has(character))
|
|
58
|
+
continue;
|
|
59
|
+
if (character.charCodeAt(0) > 127)
|
|
60
|
+
throw new Error("auth_recovery_code_invalid");
|
|
61
|
+
normalized += character.toUpperCase();
|
|
62
|
+
}
|
|
63
|
+
if (normalized.length !== CODE_CHARACTERS)
|
|
64
|
+
throw new Error("auth_recovery_code_invalid");
|
|
65
|
+
for (const character of normalized) {
|
|
66
|
+
if (!CODE_ALPHABET.includes(character))
|
|
67
|
+
throw new Error("auth_recovery_code_invalid");
|
|
68
|
+
}
|
|
69
|
+
return normalized;
|
|
70
|
+
}
|
|
71
|
+
/** Generates a 20-character code with approximately 99 bits of unbiased entropy. */
|
|
72
|
+
export function generateRecoveryCode(options = {}) {
|
|
73
|
+
const cryptoImplementation = resolveCrypto(options.crypto);
|
|
74
|
+
const maximumUnbiasedByte = Math.floor(256 / CODE_ALPHABET.length) * CODE_ALPHABET.length;
|
|
75
|
+
let canonical = "";
|
|
76
|
+
while (canonical.length < CODE_CHARACTERS) {
|
|
77
|
+
const random = cryptoImplementation.getRandomValues(new Uint8Array(CODE_CHARACTERS));
|
|
78
|
+
for (const byte of random) {
|
|
79
|
+
if (byte >= maximumUnbiasedByte)
|
|
80
|
+
continue;
|
|
81
|
+
canonical += CODE_ALPHABET.charAt(byte % CODE_ALPHABET.length);
|
|
82
|
+
if (canonical.length === CODE_CHARACTERS)
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return formatCode(canonical);
|
|
87
|
+
}
|
|
88
|
+
/** Returns a deterministic, versioned HMAC digest scoped to both pepper and stable subject ID. */
|
|
89
|
+
export async function digestRecoveryCode(options) {
|
|
90
|
+
const cryptoImplementation = resolveCrypto(options.crypto);
|
|
91
|
+
const subject = normalizeSubject(options.subject);
|
|
92
|
+
const code = normalizeRecoveryCode(options.code);
|
|
93
|
+
const key = await cryptoImplementation.subtle.importKey("raw", pepperBytes(options.pepper), { hash: "SHA-256", name: "HMAC" }, false, ["sign"]);
|
|
94
|
+
const message = new TextEncoder().encode(`${DIGEST_DOMAIN}\u0000${subject}\u0000${code}`);
|
|
95
|
+
const signature = await cryptoImplementation.subtle.sign("HMAC", key, message);
|
|
96
|
+
return `${DIGEST_PREFIX}${encodeBase64Url(new Uint8Array(signature))}`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Replaces the consumer-owned digest set, then returns the new plaintext codes.
|
|
100
|
+
* Plaintext is never passed to storage and cannot be retrieved through this API.
|
|
101
|
+
*/
|
|
102
|
+
export async function issueRecoveryCodes(options) {
|
|
103
|
+
const count = requireCodeCount(options.count);
|
|
104
|
+
const subject = normalizeSubject(options.subject);
|
|
105
|
+
const cryptoImplementation = resolveCrypto(options.crypto);
|
|
106
|
+
const issued = new Set();
|
|
107
|
+
while (issued.size < count)
|
|
108
|
+
issued.add(generateRecoveryCode({ crypto: cryptoImplementation }));
|
|
109
|
+
const codes = [...issued];
|
|
110
|
+
const records = await Promise.all(codes.map(async (code) => ({
|
|
111
|
+
digest: await digestRecoveryCode({ code, crypto: cryptoImplementation, pepper: options.pepper, subject }),
|
|
112
|
+
})));
|
|
113
|
+
await options.store.replaceRecoveryCodes({ records, subject });
|
|
114
|
+
return codes;
|
|
115
|
+
}
|
|
116
|
+
/** Digests a candidate and delegates its single-use decision to the store's atomic consume operation. */
|
|
117
|
+
export async function consumeRecoveryCode(options) {
|
|
118
|
+
const subject = normalizeSubject(options.subject);
|
|
119
|
+
pepperBytes(options.pepper);
|
|
120
|
+
const cryptoImplementation = resolveCrypto(options.crypto);
|
|
121
|
+
let code;
|
|
122
|
+
try {
|
|
123
|
+
code = normalizeRecoveryCode(options.code);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
const digest = await digestRecoveryCode({ code, crypto: cryptoImplementation, pepper: options.pepper, subject });
|
|
129
|
+
return options.store.consumeRecoveryCodeAtomically({ digest, subject });
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,iCAAiC,CAAC;AACxD,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,aAAa,GAAG,KAAK,CAAC;AAC5B,MAAM,aAAa,GAAG,4BAA4B,CAAC;AACnD,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAkDtE,SAAS,aAAa,CAAC,KAAyB;IAC9C,OAAO,KAAK,IAAI,UAAU,CAAC,MAAM,CAAC;AACpC,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAa;IAC7C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,QAAQ,IAAI,EA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mBAAmB,CAAC,OAAmC;IAC3E,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,oBAAoB,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3D,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,qBAAqB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACjH,OAAO,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@santi020k/auth-recovery",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Consumer-owned, one-time recovery-code primitives for Santiago-owned authentication.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Santiago Molina",
|
|
8
|
+
"url": "https://santi020k.com"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
25
|
+
"@types/node": "26.6.2",
|
|
26
|
+
"publint": "0.3.24",
|
|
27
|
+
"typescript": "5.9.3"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=22.22.3"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/santi020k/auth.git",
|
|
35
|
+
"directory": "packages/auth-recovery"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://auth.santi020k.com",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/santi020k/auth/issues"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"provenance": false
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -p tsconfig.build.json",
|
|
47
|
+
"check:package": "publint . --strict && attw --pack . --profile esm-only",
|
|
48
|
+
"clean": "rm -rf dist dist-test",
|
|
49
|
+
"lint": "eslint src tests --max-warnings=0",
|
|
50
|
+
"test": "tsc -p tsconfig.test.json --outDir dist-test && node --test dist-test/tests/*.test.js",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
52
|
+
}
|
|
53
|
+
}
|