mirror of
https://github.com/kou029w/jwk.pages.dev.git
synced 2025-01-31 06:18:06 +00:00
auto selection of public key use
This commit is contained in:
parent
ae1cc7af53
commit
f192341f66
2 changed files with 21 additions and 14 deletions
|
@ -37,14 +37,6 @@
|
||||||
<option>RSA-OAEP-512</option>
|
<option>RSA-OAEP-512</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label style="display: block">
|
|
||||||
Public Key Use
|
|
||||||
<select name="use">
|
|
||||||
<option value="sig">Signature</option>
|
|
||||||
<option value="enc">Encryption</option>
|
|
||||||
<option value="">-</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<label style="display: block">
|
<label style="display: block">
|
||||||
Key ID
|
Key ID
|
||||||
<select name="kid-method">
|
<select name="kid-method">
|
||||||
|
|
27
src/main.ts
27
src/main.ts
|
@ -14,7 +14,25 @@ async function onSubmit(e: SubmitEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const data = new FormData(form);
|
const data = new FormData(form);
|
||||||
const alg = data.get("alg") as string;
|
const alg = data.get("alg") as string;
|
||||||
const use = (data.get("use") as string) || undefined;
|
const use = {
|
||||||
|
ES256: "sig",
|
||||||
|
ES384: "sig",
|
||||||
|
ES512: "sig",
|
||||||
|
RS256: "sig",
|
||||||
|
RS384: "sig",
|
||||||
|
RS512: "sig",
|
||||||
|
PS256: "sig",
|
||||||
|
PS384: "sig",
|
||||||
|
PS512: "sig",
|
||||||
|
"ECDH-ES": "enc",
|
||||||
|
"ECDH-ES+A128KW": "enc",
|
||||||
|
"ECDH-ES+A192KW": "enc",
|
||||||
|
"ECDH-ES+A256KW": "enc",
|
||||||
|
"RSA-OAEP": "enc",
|
||||||
|
"RSA-OAEP-256": "enc",
|
||||||
|
"RSA-OAEP-384": "enc",
|
||||||
|
"RSA-OAEP-512": "enc",
|
||||||
|
}[alg];
|
||||||
const { privateKey, publicKey } = await generateKeyPair(alg, {
|
const { privateKey, publicKey } = await generateKeyPair(alg, {
|
||||||
extractable: true,
|
extractable: true,
|
||||||
});
|
});
|
||||||
|
@ -34,15 +52,12 @@ async function onSubmit(e: SubmitEvent) {
|
||||||
}[data.get("kid-method") as string];
|
}[data.get("kid-method") as string];
|
||||||
const kid = await createKid?.();
|
const kid = await createKid?.();
|
||||||
privateKeyOutput.textContent = JSON.stringify(
|
privateKeyOutput.textContent = JSON.stringify(
|
||||||
{ ...{ alg, use, kid }, ...jwk },
|
{ alg, use, kid, ...jwk },
|
||||||
null,
|
null,
|
||||||
" ",
|
" ",
|
||||||
);
|
);
|
||||||
publicKeyOutput.textContent = JSON.stringify(
|
publicKeyOutput.textContent = JSON.stringify(
|
||||||
{
|
{ alg, use, kid, ...(await exportJWK(publicKey)) },
|
||||||
...{ alg, use, kid },
|
|
||||||
...(await exportJWK(publicKey)),
|
|
||||||
},
|
|
||||||
null,
|
null,
|
||||||
" ",
|
" ",
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue