@absolutejs/auth 0.55.9 → 0.56.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/README.md +6 -0
- package/dist/agents/index.js +13 -3
- package/dist/agents/index.js.map +3 -3
- package/dist/index.js +13 -3
- package/dist/index.js.map +3 -3
- package/dist/oidc/keys.d.ts +12 -2
- package/dist/server.js +13 -3
- package/dist/server.js.map +3 -3
- package/package.json +1 -1
package/dist/oidc/keys.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
type SigningKeyIdentity = {
|
|
2
2
|
kid: string;
|
|
3
|
-
privateJwk: JsonWebKey;
|
|
4
3
|
publicJwk: JsonWebKey;
|
|
5
4
|
};
|
|
5
|
+
/** ES256 signing material can remain local for development or be delegated to
|
|
6
|
+
* a non-exportable KMS/HSM adapter. External signers return the 64-byte JOSE
|
|
7
|
+
* ECDSA signature (r || s), not an ASN.1 DER envelope. */
|
|
8
|
+
export type SigningKey = SigningKeyIdentity & ({
|
|
9
|
+
privateJwk: JsonWebKey;
|
|
10
|
+
sign?: never;
|
|
11
|
+
} | {
|
|
12
|
+
privateJwk?: never;
|
|
13
|
+
sign: (input: Uint8Array) => Promise<Uint8Array>;
|
|
14
|
+
});
|
|
6
15
|
export declare const generateSigningKey: () => Promise<SigningKey>;
|
|
7
16
|
export declare const jwkThumbprint: (jwk: JsonWebKey) => Promise<string>;
|
|
8
17
|
export declare const signJwt: (payload: Record<string, unknown>, signing: SigningKey, typ?: string) => Promise<string>;
|
|
@@ -23,3 +32,4 @@ export declare const verifyJwt: (token: string, publicJwk: JsonWebKey) => Promis
|
|
|
23
32
|
[k: string]: any;
|
|
24
33
|
};
|
|
25
34
|
} | undefined>;
|
|
35
|
+
export {};
|
package/dist/server.js
CHANGED
|
@@ -3214,6 +3214,7 @@ init_crypto();
|
|
|
3214
3214
|
var ENCODER = new TextEncoder;
|
|
3215
3215
|
var ES256 = { hash: "SHA-256", name: "ECDSA" };
|
|
3216
3216
|
var KEY_PARAMS = { name: "ECDSA", namedCurve: "P-256" };
|
|
3217
|
+
var ES256_JOSE_SIGNATURE_BYTES = 64;
|
|
3217
3218
|
var toBase64Url = (bytes) => Buffer.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)).toString("base64url");
|
|
3218
3219
|
var fromBase64Url = (value) => new Uint8Array(Buffer.from(value, "base64url"));
|
|
3219
3220
|
var encodeSegment = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
@@ -3247,9 +3248,18 @@ var jwkThumbprint = async (jwk) => {
|
|
|
3247
3248
|
return toBase64Url(await crypto.subtle.digest("SHA-256", ENCODER.encode(canonical)));
|
|
3248
3249
|
};
|
|
3249
3250
|
var signJwt = async (payload, signing, typ = "JWT") => {
|
|
3250
|
-
const key = await crypto.subtle.importKey("jwk", signing.privateJwk, KEY_PARAMS, false, ["sign"]);
|
|
3251
3251
|
const input = `${encodeSegment({ alg: "ES256", kid: signing.kid, typ })}.${encodeSegment(payload)}`;
|
|
3252
|
-
const
|
|
3252
|
+
const encoded = ENCODER.encode(input);
|
|
3253
|
+
let signature;
|
|
3254
|
+
if (signing.sign !== undefined) {
|
|
3255
|
+
signature = await signing.sign(encoded);
|
|
3256
|
+
} else {
|
|
3257
|
+
const key = await crypto.subtle.importKey("jwk", signing.privateJwk, KEY_PARAMS, false, ["sign"]);
|
|
3258
|
+
signature = await crypto.subtle.sign(ES256, key, encoded);
|
|
3259
|
+
}
|
|
3260
|
+
if (signature.byteLength !== ES256_JOSE_SIGNATURE_BYTES) {
|
|
3261
|
+
throw new Error("ES256 signer must return a 64-byte JOSE signature");
|
|
3262
|
+
}
|
|
3253
3263
|
return `${input}.${toBase64Url(signature)}`;
|
|
3254
3264
|
};
|
|
3255
3265
|
var toPublicJwk = (key) => ({
|
|
@@ -29661,5 +29671,5 @@ export {
|
|
|
29661
29671
|
auth2 as auth
|
|
29662
29672
|
};
|
|
29663
29673
|
|
|
29664
|
-
//# debugId=
|
|
29674
|
+
//# debugId=15A591E91DD3DB9A64756E2164756E21
|
|
29665
29675
|
//# sourceMappingURL=server.js.map
|