@korajs/auth 0.1.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korajs/auth",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Offline-first authentication for Kora.js",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -42,7 +42,7 @@
42
42
  "dist"
43
43
  ],
44
44
  "dependencies": {
45
- "@korajs/core": "0.1.3"
45
+ "@korajs/core": "0.3.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^22.0.0",
@@ -50,9 +50,9 @@
50
50
  "tsup": "^8.0.0",
51
51
  "typescript": "^5.7.0",
52
52
  "vitest": "^3.0.0",
53
- "@korajs/store": "0.1.2",
54
- "@korajs/sync": "0.1.5",
55
- "@korajs/server": "0.1.7"
53
+ "@korajs/store": "0.3.0",
54
+ "@korajs/server": "0.3.0",
55
+ "@korajs/sync": "0.3.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "react": "^18.0.0 || ^19.0.0"
@@ -1,174 +0,0 @@
1
- // src/device/device-identity.ts
2
- import { KoraError } from "@korajs/core";
3
- var CryptoUnavailableError = class extends KoraError {
4
- constructor() {
5
- super(
6
- "Web Crypto API (crypto.subtle) is not available in this environment. Device identity requires crypto.subtle, which is available in modern browsers and Node.js 20+. If running in SSR, ensure your runtime provides the Web Crypto API.",
7
- "CRYPTO_UNAVAILABLE"
8
- );
9
- this.name = "CryptoUnavailableError";
10
- }
11
- };
12
- var DeviceIdentityError = class extends KoraError {
13
- constructor(message, context) {
14
- super(message, "DEVICE_IDENTITY_ERROR", context);
15
- this.name = "DeviceIdentityError";
16
- }
17
- };
18
- function toBase64Url(buffer) {
19
- const bytes = new Uint8Array(buffer);
20
- let binary = "";
21
- for (let i = 0; i < bytes.length; i++) {
22
- binary += String.fromCharCode(bytes[i]);
23
- }
24
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
25
- }
26
- function fromBase64Url(str) {
27
- let base64 = str.replace(/-/g, "+").replace(/_/g, "/");
28
- const paddingNeeded = (4 - base64.length % 4) % 4;
29
- base64 += "=".repeat(paddingNeeded);
30
- const binary = atob(base64);
31
- const bytes = new Uint8Array(binary.length);
32
- for (let i = 0; i < binary.length; i++) {
33
- bytes[i] = binary.charCodeAt(i);
34
- }
35
- return bytes;
36
- }
37
- function assertCryptoAvailable() {
38
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle === "undefined") {
39
- throw new CryptoUnavailableError();
40
- }
41
- }
42
- var ECDSA_ALGORITHM = {
43
- name: "ECDSA",
44
- namedCurve: "P-256"
45
- };
46
- var ECDSA_SIGN_ALGORITHM = {
47
- name: "ECDSA",
48
- hash: { name: "SHA-256" }
49
- };
50
- async function generateDeviceKeyPair() {
51
- assertCryptoAvailable();
52
- try {
53
- const keyPair = await globalThis.crypto.subtle.generateKey(
54
- ECDSA_ALGORITHM,
55
- // extractable: false makes the private key non-extractable.
56
- // The public key is always extractable regardless of this flag.
57
- false,
58
- ["sign", "verify"]
59
- );
60
- return keyPair;
61
- } catch (cause) {
62
- throw new DeviceIdentityError(
63
- "Failed to generate ECDSA P-256 device key pair. Ensure the runtime supports the ECDSA algorithm with the P-256 curve.",
64
- { cause: cause instanceof Error ? cause.message : String(cause) }
65
- );
66
- }
67
- }
68
- async function exportPublicKeyJwk(keyPair) {
69
- assertCryptoAvailable();
70
- try {
71
- const jwk = await globalThis.crypto.subtle.exportKey("jwk", keyPair.publicKey);
72
- return jwk;
73
- } catch (cause) {
74
- throw new DeviceIdentityError(
75
- "Failed to export public key as JWK. The key pair may be invalid or the public key may not support JWK export.",
76
- { cause: cause instanceof Error ? cause.message : String(cause) }
77
- );
78
- }
79
- }
80
- async function signChallenge(privateKey, challenge) {
81
- assertCryptoAvailable();
82
- try {
83
- const encoded = new TextEncoder().encode(challenge);
84
- const signatureBuffer = await globalThis.crypto.subtle.sign(
85
- ECDSA_SIGN_ALGORITHM,
86
- privateKey,
87
- encoded
88
- );
89
- return toBase64Url(signatureBuffer);
90
- } catch (cause) {
91
- throw new DeviceIdentityError(
92
- 'Failed to sign challenge. Ensure the key is a valid ECDSA P-256 private key with "sign" usage.',
93
- { cause: cause instanceof Error ? cause.message : String(cause) }
94
- );
95
- }
96
- }
97
- async function verifyChallenge(publicKeyJwk, challenge, signature) {
98
- assertCryptoAvailable();
99
- try {
100
- const publicKey = await globalThis.crypto.subtle.importKey(
101
- "jwk",
102
- publicKeyJwk,
103
- ECDSA_ALGORITHM,
104
- true,
105
- ["verify"]
106
- );
107
- const encoded = new TextEncoder().encode(challenge);
108
- const signatureBytes = fromBase64Url(signature);
109
- const isValid = await globalThis.crypto.subtle.verify(
110
- ECDSA_SIGN_ALGORITHM,
111
- publicKey,
112
- signatureBytes,
113
- encoded
114
- );
115
- return isValid;
116
- } catch (cause) {
117
- throw new DeviceIdentityError(
118
- "Failed to verify challenge signature. The public key JWK or signature format may be invalid.",
119
- {
120
- cause: cause instanceof Error ? cause.message : String(cause),
121
- publicKeyKty: publicKeyJwk.kty,
122
- publicKeyCrv: publicKeyJwk.crv
123
- }
124
- );
125
- }
126
- }
127
- async function computePublicKeyThumbprint(publicKeyJwk) {
128
- assertCryptoAvailable();
129
- if (publicKeyJwk.kty !== "EC") {
130
- throw new DeviceIdentityError(
131
- `Expected JWK key type "EC" but received "${publicKeyJwk.kty ?? "undefined"}". Only ECDSA public keys are supported for device identity.`,
132
- { kty: publicKeyJwk.kty }
133
- );
134
- }
135
- if (!publicKeyJwk.crv || !publicKeyJwk.x || !publicKeyJwk.y) {
136
- throw new DeviceIdentityError(
137
- 'JWK is missing required EC fields. An EC public key JWK must include "crv", "x", and "y" members.',
138
- {
139
- hasCrv: Boolean(publicKeyJwk.crv),
140
- hasX: Boolean(publicKeyJwk.x),
141
- hasY: Boolean(publicKeyJwk.y)
142
- }
143
- );
144
- }
145
- const canonicalJson = JSON.stringify({
146
- crv: publicKeyJwk.crv,
147
- kty: publicKeyJwk.kty,
148
- x: publicKeyJwk.x,
149
- y: publicKeyJwk.y
150
- });
151
- try {
152
- const encoded = new TextEncoder().encode(canonicalJson);
153
- const hashBuffer = await globalThis.crypto.subtle.digest("SHA-256", encoded);
154
- return toBase64Url(hashBuffer);
155
- } catch (cause) {
156
- throw new DeviceIdentityError(
157
- "Failed to compute SHA-256 thumbprint of the public key JWK.",
158
- { cause: cause instanceof Error ? cause.message : String(cause) }
159
- );
160
- }
161
- }
162
-
163
- export {
164
- CryptoUnavailableError,
165
- DeviceIdentityError,
166
- toBase64Url,
167
- fromBase64Url,
168
- generateDeviceKeyPair,
169
- exportPublicKeyJwk,
170
- signChallenge,
171
- verifyChallenge,
172
- computePublicKeyThumbprint
173
- };
174
- //# sourceMappingURL=chunk-L554ZDPY.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/device/device-identity.ts"],"sourcesContent":["import { KoraError } from '@korajs/core'\n\n// --- Auth-specific errors ---\n\n/**\n * Thrown when the Web Crypto API is not available in the current environment.\n * This can happen in older Node.js versions or SSR environments without crypto support.\n */\nexport class CryptoUnavailableError extends KoraError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'Web Crypto API (crypto.subtle) is not available in this environment. ' +\n\t\t\t\t'Device identity requires crypto.subtle, which is available in modern browsers and Node.js 20+. ' +\n\t\t\t\t'If running in SSR, ensure your runtime provides the Web Crypto API.',\n\t\t\t'CRYPTO_UNAVAILABLE',\n\t\t)\n\t\tthis.name = 'CryptoUnavailableError'\n\t}\n}\n\n/**\n * Thrown when a device identity operation fails (key generation, signing, verification).\n */\nexport class DeviceIdentityError extends KoraError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'DEVICE_IDENTITY_ERROR', context)\n\t\tthis.name = 'DeviceIdentityError'\n\t}\n}\n\n// --- Encoding helpers ---\n\n/**\n * Encodes an ArrayBuffer as a base64url string (no padding).\n *\n * @param buffer - The binary data to encode\n * @returns A base64url-encoded string without padding characters\n */\nexport function toBase64Url(buffer: ArrayBuffer): string {\n\tconst bytes = new Uint8Array(buffer)\n\tlet binary = ''\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tbinary += String.fromCharCode(bytes[i] as number)\n\t}\n\t// Standard base64, then convert to base64url (no padding)\n\treturn btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '')\n}\n\n/**\n * Decodes a base64url string (no padding) into a Uint8Array.\n *\n * @param str - A base64url-encoded string (with or without padding)\n * @returns The decoded binary data as a Uint8Array\n */\nexport function fromBase64Url(str: string): Uint8Array {\n\t// Convert base64url back to standard base64\n\tlet base64 = str.replace(/-/g, '+').replace(/_/g, '/')\n\t// Add padding if necessary\n\tconst paddingNeeded = (4 - (base64.length % 4)) % 4\n\tbase64 += '='.repeat(paddingNeeded)\n\n\tconst binary = atob(base64)\n\tconst bytes = new Uint8Array(binary.length)\n\tfor (let i = 0; i < binary.length; i++) {\n\t\tbytes[i] = binary.charCodeAt(i)\n\t}\n\treturn bytes\n}\n\n// --- Internal helpers ---\n\n/**\n * Asserts that `crypto.subtle` is available, throwing a clear error if not.\n */\nfunction assertCryptoAvailable(): void {\n\tif (\n\t\ttypeof globalThis.crypto === 'undefined' ||\n\t\ttypeof globalThis.crypto.subtle === 'undefined'\n\t) {\n\t\tthrow new CryptoUnavailableError()\n\t}\n}\n\n/** ECDSA algorithm parameters used throughout the module. */\nconst ECDSA_ALGORITHM: EcKeyGenParams = {\n\tname: 'ECDSA',\n\tnamedCurve: 'P-256',\n}\n\n/** Signing algorithm parameters: ECDSA with SHA-256. */\nconst ECDSA_SIGN_ALGORITHM: EcdsaParams = {\n\tname: 'ECDSA',\n\thash: { name: 'SHA-256' },\n}\n\n// --- Public API ---\n\n/**\n * Generates an ECDSA P-256 key pair for device identity.\n *\n * The private key is marked as non-extractable, ensuring it cannot be\n * exported from the browser's crypto subsystem. This provides\n * proof-of-possession: only code running on this device can sign with the key.\n *\n * @returns A CryptoKeyPair containing the public and private ECDSA P-256 keys\n * @throws {CryptoUnavailableError} If `crypto.subtle` is not available\n * @throws {DeviceIdentityError} If key generation fails\n *\n * @example\n * ```typescript\n * const keyPair = await generateDeviceKeyPair()\n * // keyPair.publicKey can be exported; keyPair.privateKey stays on device\n * ```\n */\nexport async function generateDeviceKeyPair(): Promise<CryptoKeyPair> {\n\tassertCryptoAvailable()\n\n\ttry {\n\t\tconst keyPair = await globalThis.crypto.subtle.generateKey(\n\t\t\tECDSA_ALGORITHM,\n\t\t\t// extractable: false makes the private key non-extractable.\n\t\t\t// The public key is always extractable regardless of this flag.\n\t\t\tfalse,\n\t\t\t['sign', 'verify'],\n\t\t)\n\t\treturn keyPair\n\t} catch (cause) {\n\t\tthrow new DeviceIdentityError(\n\t\t\t'Failed to generate ECDSA P-256 device key pair. ' +\n\t\t\t\t'Ensure the runtime supports the ECDSA algorithm with the P-256 curve.',\n\t\t\t{ cause: cause instanceof Error ? cause.message : String(cause) },\n\t\t)\n\t}\n}\n\n/**\n * Exports the public key from a key pair as a JSON Web Key (JWK).\n *\n * The JWK can be safely transmitted to a server or other devices to identify\n * this device. It contains only the public component of the key pair.\n *\n * @param keyPair - The CryptoKeyPair whose public key should be exported\n * @returns The public key in JWK format\n * @throws {CryptoUnavailableError} If `crypto.subtle` is not available\n * @throws {DeviceIdentityError} If the export operation fails\n *\n * @example\n * ```typescript\n * const keyPair = await generateDeviceKeyPair()\n * const jwk = await exportPublicKeyJwk(keyPair)\n * // jwk contains { kty: 'EC', crv: 'P-256', x: '...', y: '...' }\n * ```\n */\nexport async function exportPublicKeyJwk(keyPair: CryptoKeyPair): Promise<JsonWebKey> {\n\tassertCryptoAvailable()\n\n\ttry {\n\t\tconst jwk = await globalThis.crypto.subtle.exportKey('jwk', keyPair.publicKey)\n\t\treturn jwk\n\t} catch (cause) {\n\t\tthrow new DeviceIdentityError(\n\t\t\t'Failed to export public key as JWK. ' +\n\t\t\t\t'The key pair may be invalid or the public key may not support JWK export.',\n\t\t\t{ cause: cause instanceof Error ? cause.message : String(cause) },\n\t\t)\n\t}\n}\n\n/**\n * Signs a challenge string with the device's private key.\n *\n * Used for proof-of-possession during authentication: the server sends a\n * random challenge, and the device proves it holds the private key by signing it.\n *\n * @param privateKey - The device's private CryptoKey (ECDSA P-256)\n * @param challenge - The challenge string to sign (typically a random nonce from the server)\n * @returns A base64url-encoded ECDSA signature (no padding)\n * @throws {CryptoUnavailableError} If `crypto.subtle` is not available\n * @throws {DeviceIdentityError} If the signing operation fails\n *\n * @example\n * ```typescript\n * const keyPair = await generateDeviceKeyPair()\n * const signature = await signChallenge(keyPair.privateKey, 'server-nonce-abc123')\n * // signature is a base64url string like 'MEUCIQDx...'\n * ```\n */\nexport async function signChallenge(privateKey: CryptoKey, challenge: string): Promise<string> {\n\tassertCryptoAvailable()\n\n\ttry {\n\t\tconst encoded = new TextEncoder().encode(challenge)\n\t\tconst signatureBuffer = await globalThis.crypto.subtle.sign(\n\t\t\tECDSA_SIGN_ALGORITHM,\n\t\t\tprivateKey,\n\t\t\tencoded,\n\t\t)\n\t\treturn toBase64Url(signatureBuffer)\n\t} catch (cause) {\n\t\tthrow new DeviceIdentityError(\n\t\t\t'Failed to sign challenge. ' +\n\t\t\t\t'Ensure the key is a valid ECDSA P-256 private key with \"sign\" usage.',\n\t\t\t{ cause: cause instanceof Error ? cause.message : String(cause) },\n\t\t)\n\t}\n}\n\n/**\n * Verifies a challenge signature against a public key.\n *\n * Used server-side (or on any verifying party) to confirm that a device\n * holds the private key corresponding to the given public key.\n *\n * @param publicKeyJwk - The device's public key in JWK format\n * @param challenge - The original challenge string that was signed\n * @param signature - The base64url-encoded signature to verify\n * @returns `true` if the signature is valid, `false` otherwise\n * @throws {CryptoUnavailableError} If `crypto.subtle` is not available\n * @throws {DeviceIdentityError} If the verification operation fails due to an invalid key or format\n *\n * @example\n * ```typescript\n * const isValid = await verifyChallenge(publicKeyJwk, 'server-nonce-abc123', signature)\n * if (isValid) {\n * // Device proved possession of the private key\n * }\n * ```\n */\nexport async function verifyChallenge(\n\tpublicKeyJwk: JsonWebKey,\n\tchallenge: string,\n\tsignature: string,\n): Promise<boolean> {\n\tassertCryptoAvailable()\n\n\ttry {\n\t\tconst publicKey = await globalThis.crypto.subtle.importKey(\n\t\t\t'jwk',\n\t\t\tpublicKeyJwk,\n\t\t\tECDSA_ALGORITHM,\n\t\t\ttrue,\n\t\t\t['verify'],\n\t\t)\n\n\t\tconst encoded = new TextEncoder().encode(challenge)\n\t\tconst signatureBytes = fromBase64Url(signature)\n\n\t\tconst isValid = await globalThis.crypto.subtle.verify(\n\t\t\tECDSA_SIGN_ALGORITHM,\n\t\t\tpublicKey,\n\t\t\tsignatureBytes as unknown as ArrayBuffer,\n\t\t\tencoded,\n\t\t)\n\t\treturn isValid\n\t} catch (cause) {\n\t\tthrow new DeviceIdentityError(\n\t\t\t'Failed to verify challenge signature. ' +\n\t\t\t\t'The public key JWK or signature format may be invalid.',\n\t\t\t{\n\t\t\t\tcause: cause instanceof Error ? cause.message : String(cause),\n\t\t\t\tpublicKeyKty: publicKeyJwk.kty,\n\t\t\t\tpublicKeyCrv: publicKeyJwk.crv,\n\t\t\t},\n\t\t)\n\t}\n}\n\n/**\n * Computes a SHA-256 thumbprint of a JWK public key.\n *\n * The thumbprint is computed per RFC 7638: the JWK members required for the key\n * type are serialized in lexicographic order, then hashed with SHA-256. For EC keys\n * (kty: \"EC\"), the required members are `crv`, `kty`, `x`, and `y`.\n *\n * This thumbprint serves as a compact, stable identifier for the device's public key\n * (used as the `dpk` claim in device credentials).\n *\n * @param publicKeyJwk - The public key in JWK format (must be an EC P-256 key)\n * @returns A base64url-encoded SHA-256 thumbprint (no padding)\n * @throws {CryptoUnavailableError} If `crypto.subtle` is not available\n * @throws {DeviceIdentityError} If the thumbprint computation fails or the JWK is missing required fields\n *\n * @example\n * ```typescript\n * const keyPair = await generateDeviceKeyPair()\n * const jwk = await exportPublicKeyJwk(keyPair)\n * const thumbprint = await computePublicKeyThumbprint(jwk)\n * // thumbprint is a base64url string, e.g., 'NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs'\n * ```\n */\nexport async function computePublicKeyThumbprint(publicKeyJwk: JsonWebKey): Promise<string> {\n\tassertCryptoAvailable()\n\n\t// RFC 7638 requires specific members in lexicographic order for each key type.\n\t// For EC (kty: \"EC\"), the required members are: crv, kty, x, y.\n\tif (publicKeyJwk.kty !== 'EC') {\n\t\tthrow new DeviceIdentityError(\n\t\t\t`Expected JWK key type \"EC\" but received \"${publicKeyJwk.kty ?? 'undefined'}\". ` +\n\t\t\t\t'Only ECDSA public keys are supported for device identity.',\n\t\t\t{ kty: publicKeyJwk.kty },\n\t\t)\n\t}\n\n\tif (!publicKeyJwk.crv || !publicKeyJwk.x || !publicKeyJwk.y) {\n\t\tthrow new DeviceIdentityError(\n\t\t\t'JWK is missing required EC fields. ' +\n\t\t\t\t'An EC public key JWK must include \"crv\", \"x\", and \"y\" members.',\n\t\t\t{\n\t\t\t\thasCrv: Boolean(publicKeyJwk.crv),\n\t\t\t\thasX: Boolean(publicKeyJwk.x),\n\t\t\t\thasY: Boolean(publicKeyJwk.y),\n\t\t\t},\n\t\t)\n\t}\n\n\t// Build the canonical JSON with only the required members in lexicographic order.\n\t// Per RFC 7638, no whitespace, keys in sorted order.\n\tconst canonicalJson = JSON.stringify({\n\t\tcrv: publicKeyJwk.crv,\n\t\tkty: publicKeyJwk.kty,\n\t\tx: publicKeyJwk.x,\n\t\ty: publicKeyJwk.y,\n\t})\n\n\ttry {\n\t\tconst encoded = new TextEncoder().encode(canonicalJson)\n\t\tconst hashBuffer = await globalThis.crypto.subtle.digest('SHA-256', encoded)\n\t\treturn toBase64Url(hashBuffer)\n\t} catch (cause) {\n\t\tthrow new DeviceIdentityError(\n\t\t\t'Failed to compute SHA-256 thumbprint of the public key JWK.',\n\t\t\t{ cause: cause instanceof Error ? cause.message : String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