1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-04-16 09:41:22 +00:00

remove jose

This commit is contained in:
Nebel 2025-04-08 23:19:05 +09:00 committed by GitHub
parent cdc1c7f065
commit a2d2d92e8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 0 additions and 60 deletions

View file

@ -1,5 +0,0 @@
{
"imports": {
"jose": "npm:jose@^5.9.6"
}
}

17
jose/deno.lock generated
View file

@ -1,17 +0,0 @@
{
"version": "4",
"specifiers": {
"npm:jose@*": "5.9.6",
"npm:jose@^5.9.6": "5.9.6"
},
"npm": {
"jose@5.9.6": {
"integrity": "sha512-AMlnetc9+CV9asI19zHmrgS/WYsWUwCn2R7RzlbJWD7F9eWYUTGyBmU9o6PxngtLGOiDGPRu+Uc4fhKzbpteZQ=="
}
},
"workspace": {
"dependencies": [
"npm:jose@^5.9.6"
]
}
}

View file

@ -1,38 +0,0 @@
import {
exportJWK,
flattenedDecrypt,
FlattenedEncrypt,
generateKeyPair,
importJWK,
} from "npm:jose";
/*
* JWE_SECRET=$(openssl rand -base64 32) deno run -A jwe.ts
*/
const encryptionKey = await importJWK({
kty: "oct",
k: Deno.env.get("JWE_SECRET"),
});
const keyToEncrypt = await generateKeyPair("ES256", { extractable: true });
const privateKeyJWK = await exportJWK(keyToEncrypt.privateKey);
// encrypt
const jwe = await new FlattenedEncrypt(
new TextEncoder().encode(JSON.stringify(privateKeyJWK)),
)
.setProtectedHeader({
alg: "dir",
enc: "A256GCM",
})
.encrypt(encryptionKey);
// decrypt
const res = await flattenedDecrypt(jwe, encryptionKey);
const jwk = JSON.parse(new TextDecoder().decode(res.plaintext));
console.log({
jwe,
jwk,
});