Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
OR13 committed Aug 10, 2024
1 parent d2ec170 commit eae5cff
Show file tree
Hide file tree
Showing 22 changed files with 933 additions and 652 deletions.
1,004 changes: 762 additions & 242 deletions dist/925.index.js

Large diffs are not rendered by default.

79 changes: 29 additions & 50 deletions dist/index.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/api/jose/detached.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as jose from 'jose'
import { detachedHeaderParams } from '../controller/utils'


const detachedHeaderParams = { b64: false, crit: ['b64'] }

// TODO Remote KMS.
const signer = async (privateKeyJwk) => {
Expand Down
9 changes: 4 additions & 5 deletions src/cli/cose/diagnostic/diagnose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ const diagnose = async (argv: RequestDiagnose) => {
const { input, output } = argv

const payload = fs.readFileSync(path.resolve(process.cwd(), input))
const items = await cose.rfc.diag(payload)
const markdown = await cose.rfc.blocks(items)
// TODO: use @transmute/edn
const edn = await cose.cbor.diagnose(payload)
if (output) {
fs.writeFileSync(
path.resolve(process.cwd(), output),
markdown
edn
)
} else {

console.info(markdown)
console.info(edn)
}

}
Expand Down
6 changes: 0 additions & 6 deletions src/cli/cose/key/index.ts

This file was deleted.

54 changes: 0 additions & 54 deletions src/cli/cose/key/sign.ts

This file was deleted.

64 changes: 0 additions & 64 deletions src/cli/cose/key/verify.ts

This file was deleted.

24 changes: 12 additions & 12 deletions src/cli/cose/module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@

import key from "./key"

import diagnostic from "./diagnostic"

export const command = 'cose <resource> <action>'

export const describe = 'cose operations'

const resources = {
diagnostic
}

export const handler = async function (argv) {
const { resource, action } = argv
if (resources[resource][action]) {
resources[resource][action](argv)
}
}

export const builder = (yargs) => {
return yargs
.positional('resource', {
Expand Down Expand Up @@ -44,14 +55,3 @@ export const builder = (yargs) => {
})
}

const resources = {
key,
diagnostic
}

export const handler = async function (argv) {
const { resource, action } = argv
if (resources[resource][action]) {
resources[resource][action](argv)
}
}
2 changes: 1 addition & 1 deletion src/cli/graph/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'
import jsongraph from '../../api/rdf/jsongraph'
import * as contants from '../../constants'

import cypher from '../../api/cypher'

import operationSwitch from '../../action/operationSwitch'
Expand Down
15 changes: 9 additions & 6 deletions src/cli/scitt/certificate/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ const createLeafCertificate = async (argv: RequestCertificate) => {
const userKeys = await crypto.subtle.generateKey(alg, extractable, ["sign", "verify"]);

const issuerPrivateKeyCose = fs.readFileSync(path.resolve(process.cwd(), argv.issuerPrivateKey))
const issuerPrivateKey = cose.key.exportJWK(cose.cbor.decode(issuerPrivateKeyCose))
const coseKey = cose.cbor.decode(issuerPrivateKeyCose)
const issuerPrivateKeyJwk = await cose.key.convertCoseKeyToJsonWebKey<any>(coseKey)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const extensions: any = []
if (argv.subjectGuid) {
Expand All @@ -144,7 +145,7 @@ const createLeafCertificate = async (argv: RequestCertificate) => {
publicKey: userKeys.publicKey, // leaf public key
signingKey: await crypto.subtle.importKey(
"jwk",
issuerPrivateKey,
issuerPrivateKeyJwk,
alg,
true,
["sign"],
Expand Down Expand Up @@ -189,7 +190,9 @@ const create = async (argv: RequestCertificate) => {
if (!argv.issuerCertificate) {
// root cert
cert = await createRootCertificate(argv)
const subjectPrivateKey = cose.cbor.encode(cose.key.importJWK(JSON.parse(cert.subjectPrivateKey)))
const subjectPrivateKeyJwk = JSON.parse(cert.subjectPrivateKey)
const subjectPrivateKeyCose = await cose.key.convertJsonWebKeyToCoseKey<any>(subjectPrivateKeyJwk)
const subjectPrivateKey = cose.cbor.encode(subjectPrivateKeyCose)
fs.writeFileSync(
path.resolve(process.cwd(), argv.subjectPrivateKey),
Buffer.from(subjectPrivateKey)
Expand All @@ -203,10 +206,10 @@ const create = async (argv: RequestCertificate) => {
// leaf cert
cert = await createLeafCertificate(argv)

const subjectPublicCoseKeyMap = cose.key.importJWK(JSON.parse(cert.subjectPublicKey))
const subjectPublicCoseKeyMap = await cose.key.convertCoseKeyToJsonWebKey<any>(JSON.parse(cert.subjectPublicKey))
const subjectPublicKey = cose.cbor.encode(subjectPublicCoseKeyMap)
const subjectPrivateCoseKeyMap = cose.key.importJWK(JSON.parse(cert.subjectPrivateKey))
subjectPrivateCoseKeyMap.set(-66666, subjectPublicCoseKeyMap.get(-66666) as any)
const subjectPrivateCoseKeyMap = await cose.key.convertCoseKeyToJsonWebKey<any>(JSON.parse(cert.subjectPrivateKey))

const subjectPrivateKey = cose.cbor.encode(subjectPrivateCoseKeyMap)

fs.writeFileSync(
Expand Down
26 changes: 0 additions & 26 deletions src/cli/scitt/key/diagnose.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/cli/scitt/key/export.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/cli/scitt/key/generate.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/cli/scitt/key/index.ts

This file was deleted.

Loading

0 comments on commit eae5cff

Please sign in to comment.