Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
OR13 committed Aug 11, 2024
1 parent 2b3df9f commit 9131665
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion scripts/jose.diagnostic.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# signing keys
npm run -s transmute -- jose keygen --alg ES256 > ./tests/fixtures/private.sig.jwk.json
npm run -s transmute -- jose keypub ./tests/fixtures/private.sig.jwk.json > ./tests/fixtures/public.sig.jwk.json
Expand All @@ -15,7 +16,7 @@ npm run -s transmute -- jose sign ./tests/fixtures/private.sig.jwk.json ./tests/
npm run -s transmute -- jose verify ./tests/fixtures/public.sig.jwk.json ./tests/fixtures/message.signature.detached.json ./tests/fixtures/message.json --detached> ./tests/fixtures/message.signature.detached.verified.json

# detached compact
npm run -s transmute -- jose sign ./tests/fixtures/private.sig.jwk.json ./tests/fixtures/message.json --detached --compact > ./tests/fixtures/message.signature.detached.compact.jws
npm run -s transmute -- jose sign ./tests/fixtures/private.sig.jwk.json ./tests/fixtures/message.json --detached --compact --output ./tests/fixtures/message.signature.detached.compact.jws
npm run -s transmute -- jose verify ./tests/fixtures/public.sig.jwk.json ./tests/fixtures/message.signature.detached.compact.jws ./tests/fixtures/message.json --detached --compact > ./tests/fixtures/message.signature.detached.compact.jws.verified.json

# encrypt
Expand Down
17 changes: 12 additions & 5 deletions src/jose/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ export const handler = async function ({ positionals, values }: Arguments) {
}

if (output) {
fs.writeFileSync(output, typeof jws === 'string' ? jws : JSON.stringify(jws, null, 2))
if (compact) {
fs.writeFileSync(output, `${jws.protected}.${jws.payload}.${jws.signature}`)
} else {
fs.writeFileSync(output, JSON.stringify(jws, null, 2))
}
}

if (env.github()) {
Expand All @@ -120,11 +124,14 @@ export const handler = async function ({ positionals, values }: Arguments) {
setOutput('json', jws)
}
} else {
if (compact) {
console.log(`${jws.protected}.${jws.payload}.${jws.signature}`)
} else {
console.log(JSON.stringify(jws, null, 2))
if (!output) {
if (compact) {
console.log(`${jws.protected}.${jws.payload}.${jws.signature}`)
} else {
console.log(JSON.stringify(jws, null, 2))
}
}

}
break
}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/message.ciphertext.compact.jwe
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJlbmMiOiJBMTI4R0NNIiwiYWxnIjoiRUNESC1FUytBMTI4S1ciLCJlcGsiOnsieCI6InhKTGNkMml0Ql81QnpnRjZUcFlYVXNTYlZQS2QxM3prTFczdmFqbi1xMlZVeFBmcVRzaU11eGttSEVISk9lM3IiLCJjcnYiOiJQLTM4NCIsImt0eSI6IkVDIiwieSI6Im1aNTFBLTdkQzg2Y2R5RDR4NHZfUktXY3pid01PMXNLQzZkdXJMVWlxZkM3VGJTcEtKQ2hfdHJ1d2RJM1Z1TU0ifX0.k56Wf6Z-5xklDeOJA1PjA0L7IeXxBILm.aIPb_qFL8o-SdCi6.nozJc1CoiKDyFxeUyeV6cj7WHvFauyqG6w35C1liaJdGUaK07DS62Nvy2zmYaIWwl7ja-TrOT2t-ShhSiwgyABqERDvI9wkhPzo.AxoXZWOZm1B7KcY-JU8ZjA
eyJlbmMiOiJBMTI4R0NNIiwiYWxnIjoiRUNESC1FUytBMTI4S1ciLCJlcGsiOnsieCI6Im5ycWhqakZkby1UUFJnZmRzV0l0NXB2MVhYbnhrUHBtQklEdkhnTkxxam15VG5SNnpibTJzVDEzVF83am9GZGEiLCJjcnYiOiJQLTM4NCIsImt0eSI6IkVDIiwieSI6Ik5MZzlxNzhtUTBOTFl5MU5JRGZEVlZ6SU5OLXM0M1REbThJNldxaFI5MUFJQlhjSERaSFNvT1pCRU5uNVJ3cUUifX0.bYrKTTTuxr_CmeLuFwFJdZQwM8Hspk93.9DdHRgFL8d4YpQ9z.4Xm53ts4rONlZYg060N2Sh1mrZm-RPXbvzCn7EZywbyofhF3UG_d-ojHJUciDerA5pSSryJMUrJMx8QIuVk1_AVnWMrdrIUnigk.29LTfjheh4IE5eEhSiFGDg
10 changes: 5 additions & 5 deletions tests/fixtures/message.ciphertext.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"ciphertext": "F6UDBUlpwbjinu2jEBAlOnGYRTkzgdX7PkwsgYK-mhf1O3b3H7-cziDlDfmOGb_kmgmdMMvm5ywyIm4oDRsgnJGDCwaIL74SnXc",
"iv": "b5VgLgGCNG8w5evy",
"ciphertext": "JxzQQLvPhXnsedr_V4GiKzKMy_rtNDAaIc3-VqeHIYtw7cgjjHFK17RjG_m37Lhs6lmArs6Ll21cVdQp-1E2ja9c_Fd7Xn7DLpU",
"iv": "cnVKkDmVkYld5whs",
"recipients": [
{
"encrypted_key": "wct_Lr-68duSzrq88b7G6EpS1QUDAP8r",
"encrypted_key": "IJkg7YWmrU4lGhgLXmJBc4dJZlsZQX8b",
"header": {
"alg": "ECDH-ES+A128KW"
}
}
],
"tag": "iKbNThs8T_4rftHd5CxXug",
"protected": "eyJlbmMiOiJBMTI4R0NNIiwiZXBrIjp7IngiOiJsOTJabTZPU3lpQlF6akNQcUp0cVRtZkNWNHpIUmZNdWoxUGlGeWRhc1cydmN6SnVNUmNvVGlVamo2eWdrb3h0IiwiY3J2IjoiUC0zODQiLCJrdHkiOiJFQyIsInkiOiJvaTlQcFNYeXZDOUlJZDFyaUs3bkFYUUMtTGNrVENJN0FaMEhNQmVka19hUzV5YmJPMVdUTFNzMkNGOU82VzhVIn19"
"tag": "iA5OPzdQd2rtaT3EFQlQ3Q",
"protected": "eyJlbmMiOiJBMTI4R0NNIiwiZXBrIjp7IngiOiJWSTRrQmV5ekVUNkV0V2JVWG9lWHhPemtaMzZoOEtnUjNSUUJrRXI3VXM2T2hIMVRHeDl4N3JlQkhHbFBrWjBIIiwiY3J2IjoiUC0zODQiLCJrdHkiOiJFQyIsInkiOiJvdXVIaXM0NjEtbjRmOVVMT09VcF9ocnE4UHlrbVNvV1pEWm9yTGN0V1gyQjJwOUctTG1NTEFKZ016ZDRNVkJRIn19"
}
4 changes: 2 additions & 2 deletions tests/fixtures/message.decrypted.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"enc": "A128GCM",
"alg": "ECDH-ES+A128KW",
"epk": {
"x": "xJLcd2itB_5BzgF6TpYXUsSbVPKd13zkLW3vajn-q2VUxPfqTsiMuxkmHEHJOe3r",
"x": "nrqhjjFdo-TPRgfdsWIt5pv1XXnxkPpmBIDvHgNLqjmyTnR6zbm2sT13T_7joFda",
"crv": "P-384",
"kty": "EC",
"y": "mZ51A-7dC86cdyD4x4v_RKWczbwMO1sKC6durLUiqfC7TbSpKJCh_truwdI3VuMM"
"y": "NLg9q78mQ0NLYy1NIDfDVVzINN-s43TDm8I6WqhR91AIBXcHDZHSoOZBENn5RwqE"
}
}
2 changes: 1 addition & 1 deletion tests/fixtures/message.signature.detached.compact.jws
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJFUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..js0q6d0Eyl1HOPEQfovJCN9-79G1hfWVHBi-G5NdrkE464YLIC1DL0lTHZPfEkBlrlAmFMSWf3rU_u7Q6RFALQ
eyJhbGciOiJFUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..lrgEOVGLwsxOO2DWVUg0kSD004PlGBk7AiujLLvz5IQQwcloeUsoomQZeXqChgd5pvwzUuCt6wRbSHnxilEWVw
2 changes: 1 addition & 1 deletion tests/fixtures/message.signature.detached.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"signature": "OjHqfSQsWGIWvZPr1uzJO_5J8Z_m8MixsJmJemDAsN9ZpjUGXbu9MmFdqzY-Rs7pNARIJ32OIZSiAkKNUYaldA",
"signature": "uFnhAFTBWR95E_LGNxcR-W_36OxlGUbrn8xTLBI0M6wEHdDj6h5DFrOvxDO4dk88xBqb7Fp5OeCXFadPSkcFAg",
"payload": "",
"protected": "eyJhbGciOiJFUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19"
}
2 changes: 1 addition & 1 deletion tests/fixtures/message.signature.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"signature": "siSDhMUkw36kxp8_TpRVGxIw0igXfx2-Bs2xqp2YoT-q-LKRpzYn0eAihlAZk3VdJ1nCVf0MXDUQtQK50TuTJg",
"signature": "4yBU1wHIw1QgHBLOrpQGpQnQ0hDc3m_y8UmcIyEcanj5gGej7AzWONEdHxR8LRCo1u0gf_wBL1pgXls9jumohQ",
"payload": "eyJtZXNzYWdlIjoi4oybIE15IGx1bmdzIHRhc3RlIHRoZSBhaXIgb2YgVGltZSBCbG93biBwYXN0IGZhbGxpbmcgc2FuZHMifQo",
"protected": "eyJhbGciOiJFUzI1NiJ9"
}
8 changes: 4 additions & 4 deletions tests/fixtures/private.enc.jwk.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"kid": "yCR1KQpH_Qb-icK-mp4h2a5_IOi6Bw1Vx-QjZBhIGfs",
"kid": "8gNIfOf8glOCvML5X5klWybceOyC3BhxH0ohs1tnCmI",
"kty": "EC",
"crv": "P-384",
"alg": "ECDH-ES+A128KW",
"x": "7F6KzxLLieSlncZyqq2WGtPKBJQC4nJ1FLNZDtoV4lO4m44WbeDHlWB9xOoAsR1u",
"y": "hUj3VIHAgENGZIgYxLV4-fTVd5Q2KTPEIGgxXsieAwTTL0HqqpskgGitD7jYHunb",
"d": "Ljf69uYHD3VqBwdn5Zp9dxnMYAWptKVDL6roGTIUJzqGmNDq3dZR23su3_QHV8_X"
"x": "vagYWKx7sk7R6iqhlP3Rh5s5siVF3Tzyds-DSjC-0d9J4Xb6Yi6bxFotsLUB_wRM",
"y": "qLGaP8nz6sjOWK5-0BEhdNFBr69TGdabQbBiPWG1NVr5jxKHnj6DAtdLVNr813XZ",
"d": "QfYXj6bVAzCWqWwpioOjpSEHKhmgwChoEsc7vaLRRFNaQ3XaXoKeLdGHt8NBwqnE"
}
8 changes: 4 additions & 4 deletions tests/fixtures/private.sig.jwk.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"kid": "osPbX-F0cFH2V_y7Z8qdEQ4nnTaEkoWXcdaMshdmI4A",
"kid": "CHMhpHBawFQ9CYa2p35gJbmJktO1SC93N98b7U0BbLk",
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"x": "RSAD1Jvqdhx29vQrkYGRGlcehTdHx99c5bi3ddFznV8",
"y": "Pu3COSqHuyEKqoo-84pjuxKMrkGJs6pOOzxU3RC-Klc",
"d": "7a6o08p23Dlf061buQ6gGJGTMuKqpy06ikXT8flr9lg"
"x": "yX3lHwKrl8FWj9WUbSZ6E1nN1ZMuM7jbvvgH4gEU5Xg",
"y": "1GLRQ4bARsbOGqdfY47ECe1CWECYKS3lhrdBy8aSzuw",
"d": "fHU2s6n3BCjW8gko5K5dEtvSYVzIyxeetLjafm0A8WM"
}
6 changes: 3 additions & 3 deletions tests/fixtures/public.enc.jwk.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"kid": "yCR1KQpH_Qb-icK-mp4h2a5_IOi6Bw1Vx-QjZBhIGfs",
"kid": "8gNIfOf8glOCvML5X5klWybceOyC3BhxH0ohs1tnCmI",
"kty": "EC",
"crv": "P-384",
"alg": "ECDH-ES+A128KW",
"x": "7F6KzxLLieSlncZyqq2WGtPKBJQC4nJ1FLNZDtoV4lO4m44WbeDHlWB9xOoAsR1u",
"y": "hUj3VIHAgENGZIgYxLV4-fTVd5Q2KTPEIGgxXsieAwTTL0HqqpskgGitD7jYHunb"
"x": "vagYWKx7sk7R6iqhlP3Rh5s5siVF3Tzyds-DSjC-0d9J4Xb6Yi6bxFotsLUB_wRM",
"y": "qLGaP8nz6sjOWK5-0BEhdNFBr69TGdabQbBiPWG1NVr5jxKHnj6DAtdLVNr813XZ"
}
6 changes: 3 additions & 3 deletions tests/fixtures/public.sig.jwk.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"kid": "osPbX-F0cFH2V_y7Z8qdEQ4nnTaEkoWXcdaMshdmI4A",
"kid": "CHMhpHBawFQ9CYa2p35gJbmJktO1SC93N98b7U0BbLk",
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"x": "RSAD1Jvqdhx29vQrkYGRGlcehTdHx99c5bi3ddFznV8",
"y": "Pu3COSqHuyEKqoo-84pjuxKMrkGJs6pOOzxU3RC-Klc"
"x": "yX3lHwKrl8FWj9WUbSZ6E1nN1ZMuM7jbvvgH4gEU5Xg",
"y": "1GLRQ4bARsbOGqdfY47ECe1CWECYKS3lhrdBy8aSzuw"
}

0 comments on commit 9131665

Please sign in to comment.