@absolutejs/auth 0.55.8 → 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 CHANGED
@@ -159,6 +159,12 @@ RFC 9728/RFC 8414 discovery, claim polling, and assertion exchange.
159
159
  See [the agent-auth interoperability and deployment guide](docs/AGENT-AUTH.md)
160
160
  for supported standards, security invariants, and the production checklist.
161
161
 
162
+ OIDC and agent-registration signing accepts either a local ES256 `privateJwk`
163
+ or a `sign(input)` adapter with the public JWK and key ID. Production adapters
164
+ can therefore keep private key material non-exportable in a KMS or HSM. The
165
+ adapter must return the 64-byte JOSE ES256 signature (`r || s`); DER conversion
166
+ belongs at the KMS boundary.
167
+
162
168
  ### Features
163
169
 
164
170
  - **Authorization**: Handles the authorization process by generating the authorization URL and redirecting the user to the authentication provider.
@@ -199,6 +199,7 @@ init_crypto();
199
199
  var ENCODER = new TextEncoder;
200
200
  var ES256 = { hash: "SHA-256", name: "ECDSA" };
201
201
  var KEY_PARAMS = { name: "ECDSA", namedCurve: "P-256" };
202
+ var ES256_JOSE_SIGNATURE_BYTES = 64;
202
203
  var toBase64Url = (bytes) => Buffer.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)).toString("base64url");
203
204
  var fromBase64Url = (value) => new Uint8Array(Buffer.from(value, "base64url"));
204
205
  var encodeSegment = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
@@ -232,9 +233,18 @@ var jwkThumbprint = async (jwk) => {
232
233
  return toBase64Url(await crypto.subtle.digest("SHA-256", ENCODER.encode(canonical)));
233
234
  };
234
235
  var signJwt = async (payload, signing, typ = "JWT") => {
235
- const key = await crypto.subtle.importKey("jwk", signing.privateJwk, KEY_PARAMS, false, ["sign"]);
236
236
  const input = `${encodeSegment({ alg: "ES256", kid: signing.kid, typ })}.${encodeSegment(payload)}`;
237
- const signature = await crypto.subtle.sign(ES256, key, ENCODER.encode(input));
237
+ const encoded = ENCODER.encode(input);
238
+ let signature;
239
+ if (signing.sign !== undefined) {
240
+ signature = await signing.sign(encoded);
241
+ } else {
242
+ const key = await crypto.subtle.importKey("jwk", signing.privateJwk, KEY_PARAMS, false, ["sign"]);
243
+ signature = await crypto.subtle.sign(ES256, key, encoded);
244
+ }
245
+ if (signature.byteLength !== ES256_JOSE_SIGNATURE_BYTES) {
246
+ throw new Error("ES256 signer must return a 64-byte JOSE signature");
247
+ }
238
248
  return `${input}.${toBase64Url(signature)}`;
239
249
  };
240
250
  var toPublicJwk = (key) => ({
@@ -12866,5 +12876,5 @@ export {
12866
12876
  AGENT_CLAIM_GRANT_TYPE
12867
12877
  };
12868
12878
 
12869
- //# debugId=0C42692E8F64E63E64756E2164756E21
12879
+ //# debugId=B167D950C52D83A964756E2164756E21
12870
12880
  //# sourceMappingURL=index.js.map