Skip to content

Commit

Permalink
Cleanup package.json (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel authored Jun 28, 2024
1 parent b0fff10 commit adac416
Show file tree
Hide file tree
Showing 13 changed files with 19,510 additions and 13,662 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import {
AuthorizationRequestStatus,
FIXTURE
} from '@narval/policy-engine-shared'
import { Alg, generateJwk, getPublicKey } from '@narval/signature'
import { Alg, JwtError, generateJwk, getPublicKey } from '@narval/signature'
import { HttpModule } from '@nestjs/axios'
import { BullModule, getQueueToken } from '@nestjs/bull'
import { Test, TestingModule } from '@nestjs/testing'
import { Client, Prisma } from '@prisma/client/armory'
import { Job, Queue } from 'bull'
import { mock } from 'jest-mock-extended'
import { JwtError } from 'packages/signature/src/lib/error'
import { load } from '../../../../../armory.config'
import {
AUTHORIZATION_REQUEST_PROCESSING_QUEUE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PublicKey } from '@narval/signature'
import { JwtError, PublicKey } from '@narval/signature'
import { HttpStatus } from '@nestjs/common'
import { JwtError } from 'packages/signature/src/lib/error'
import { PolicyEngineException } from './policy-engine.exception'

export class InvalidAttestationSignatureException extends PolicyEngineException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import {
PolicyStore,
Source
} from '@narval/policy-engine-shared'
import { Jwk, decodeJwt, hash, verifyJwt } from '@narval/signature'
import { Jwk, JwtError, decodeJwt, hash, verifyJwt } from '@narval/signature'
import { HttpStatus, Injectable } from '@nestjs/common'
import { JwtError } from 'packages/signature/src/lib/error'
import { ZodObject, z } from 'zod'
import { DataStoreException } from '../exception/data-store.exception'
import { DataStoreRepositoryFactory } from '../factory/data-store-repository.factory'
Expand Down
7 changes: 3 additions & 4 deletions apps/policy-engine/src/shared/testing/evaluation.testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Permission, Resource } from '@narval/armory-sdk'
import { Action, EvaluationRequest, FIXTURE, Request, TransactionRequest } from '@narval/policy-engine-shared'
import { Alg, Payload, hash, privateKeyToJwk, signJwt } from '@narval/signature'
import { randomBytes } from 'crypto'
import { UNSAFE_PRIVATE_KEY } from 'packages/policy-engine-shared/src/lib/dev.fixture'
import { v4 as uuid } from 'uuid'
import { toHex } from 'viem'

Expand All @@ -14,9 +13,9 @@ const sign = async (request: Request) => {
requestHash: message
}

const aliceSignature = await signJwt(payload, privateKeyToJwk(UNSAFE_PRIVATE_KEY.Alice, Alg.ES256K))
const bobSignature = await signJwt(payload, privateKeyToJwk(UNSAFE_PRIVATE_KEY.Bob, Alg.ES256K))
const carolSignature = await signJwt(payload, privateKeyToJwk(UNSAFE_PRIVATE_KEY.Carol, Alg.ES256K))
const aliceSignature = await signJwt(payload, privateKeyToJwk(FIXTURE.UNSAFE_PRIVATE_KEY.Alice, Alg.ES256K))
const bobSignature = await signJwt(payload, privateKeyToJwk(FIXTURE.UNSAFE_PRIVATE_KEY.Bob, Alg.ES256K))
const carolSignature = await signJwt(payload, privateKeyToJwk(FIXTURE.UNSAFE_PRIVATE_KEY.Carol, Alg.ES256K))

return { aliceSignature, bobSignature, carolSignature }
}
Expand Down
2 changes: 1 addition & 1 deletion apps/vault/src/shared/module/key-value/key-value.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ConfigService } from '@narval/config-module'
import { EncryptionModule } from '@narval/encryption-module'
import { Module, forwardRef } from '@nestjs/common'
import { ConfigService } from 'packages/config-module/src/lib/config.service'
import { AppService } from '../../../vault/core/service/app.service'
import { VaultModule } from '../../../vault/vault.module'
import { EncryptionModuleOptionFactory } from '../../factory/encryption-module-option.factory'
Expand Down
15 changes: 7 additions & 8 deletions apps/vault/src/vault/__test__/e2e/sign.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ConfigModule } from '@narval/config-module'
import { EncryptionModuleOptionProvider } from '@narval/encryption-module'
import { Action } from '@narval/policy-engine-shared'
import { Action, FIXTURE } from '@narval/policy-engine-shared'
import {
SigningAlg,
buildSignerEip191,
Expand All @@ -16,7 +16,6 @@ import {
} from '@narval/signature'
import { HttpStatus, INestApplication } from '@nestjs/common'
import { Test, TestingModule } from '@nestjs/testing'
import { UNSAFE_PRIVATE_KEY, VIEM_ACCOUNT } from 'packages/policy-engine-shared/src/lib/dev.fixture'
import request from 'supertest'
import { v4 as uuid } from 'uuid'
import { verifyMessage } from 'viem'
Expand Down Expand Up @@ -294,7 +293,7 @@ describe('Sign', () => {
it('returns error when auth is client-bound but no jwsd header', async () => {
const payload = { request: getSignTransactionRequest() }

const clientJwk = secp256k1PublicKeyToJwk(VIEM_ACCOUNT.Alice.publicKey)
const clientJwk = secp256k1PublicKeyToJwk(FIXTURE.VIEM_ACCOUNT.Alice.publicKey)
const accessToken = await getAccessToken(payload.request, { cnf: clientJwk })

const { status, body } = await request(app.getHttpServer())
Expand All @@ -312,10 +311,10 @@ describe('Sign', () => {
const now = Math.floor(Date.now() / 1000)
const payload = { request: getSignTransactionRequest() }

const clientJwk = secp256k1PublicKeyToJwk(VIEM_ACCOUNT.Alice.publicKey)
const clientJwk = secp256k1PublicKeyToJwk(FIXTURE.VIEM_ACCOUNT.Alice.publicKey)
const accessToken = await getAccessToken(payload.request, { cnf: clientJwk })

const jwsdSigner = buildSignerEip191(UNSAFE_PRIVATE_KEY.Alice)
const jwsdSigner = buildSignerEip191(FIXTURE.UNSAFE_PRIVATE_KEY.Alice)
const jwsdHeader: JwsdHeader = {
alg: SigningAlg.EIP191,
kid: clientJwk.kid,
Expand Down Expand Up @@ -349,13 +348,13 @@ describe('Sign', () => {
const now = Math.floor(Date.now() / 1000)
const payload = { request: getSignTransactionRequest() }

const clientJwk = secp256k1PublicKeyToJwk(VIEM_ACCOUNT.Alice.publicKey)
const boundClientJwk = secp256k1PublicKeyToJwk(VIEM_ACCOUNT.Bob.publicKey)
const clientJwk = secp256k1PublicKeyToJwk(FIXTURE.VIEM_ACCOUNT.Alice.publicKey)
const boundClientJwk = secp256k1PublicKeyToJwk(FIXTURE.VIEM_ACCOUNT.Bob.publicKey)
// We bind BOB to the access token, but ALICe is the one signing the request, so she has
// a valid access token but it's not bound to her.
const accessToken = await getAccessToken(payload.request, { cnf: boundClientJwk })

const jwsdSigner = buildSignerEip191(UNSAFE_PRIVATE_KEY.Alice)
const jwsdSigner = buildSignerEip191(FIXTURE.UNSAFE_PRIVATE_KEY.Alice)
const jwsdHeader: JwsdHeader = {
alg: SigningAlg.EIP191,
kid: clientJwk.kid,
Expand Down
2 changes: 1 addition & 1 deletion apps/vault/src/vault/http/rest/dto/encryption-key.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rsaPublicKeySchema } from '@narval/signature'
import { createZodDto } from 'nestjs-zod'
import { rsaPublicKeySchema } from 'packages/signature/src/lib/schemas'
import { z } from 'zod'

export class EncryptionKeyDto extends createZodDto(
Expand Down
2 changes: 1 addition & 1 deletion apps/vault/src/vault/http/rest/dto/sign-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SerializedSignableRequest } from '@narval/policy-engine-shared'
import { createZodDto } from 'nestjs-zod'
import { SerializedSignableRequest } from 'packages/policy-engine-shared/src/lib/type/action.type'
import { z } from 'zod'

export class SignRequestDto extends createZodDto(
Expand Down
10 changes: 5 additions & 5 deletions examples/armory-sdk-nodejs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-console */

import { createArmoryConfig, importPrivateKey, sendTransaction, setPolicies } from '@narval/armory-sdk'
import { Action, Policy } from '@narval/policy-engine-shared'
import { Action, FIXTURE, Policy } from '@narval/policy-engine-shared'
import { privateKeyToJwk } from '@narval/signature'
import { UNSAFE_PRIVATE_KEY } from 'packages/policy-engine-shared/src/lib/dev.fixture'
import { v4 } from 'uuid'
import { Hex, toHex } from 'viem'
import { privateKeyToAddress } from 'viem/accounts'

Expand Down Expand Up @@ -105,9 +105,9 @@ const policy = [

const main = async () => {
const anotherAddress = '0x3f843E606C79312718477F9bC020F3fC5b7264C2'.toLowerCase() as Hex
const signerAddr = privateKeyToAddress(UNSAFE_PRIVATE_KEY.Root)
const signerAddr = privateKeyToAddress(FIXTURE.UNSAFE_PRIVATE_KEY.Root)
const signer = {
...privateKeyToJwk(UNSAFE_PRIVATE_KEY.Root),
...privateKeyToJwk(FIXTURE.UNSAFE_PRIVATE_KEY.Root),
addr: signerAddr,
kid: signerAddr
}
Expand All @@ -118,7 +118,7 @@ const main = async () => {
authSecret: '4d975e601bd61cb7163025bdec0b77ce6fcfc30d2513eab7b1187e13a5ecfe409fb40850b9e917a51a02',
vaultClientId: '5f16ff6a-a9ca-42d5-9a6e-d605e58e3359',
vaultHost: 'http://localhost:3011',
signer: privateKeyToJwk(UNSAFE_PRIVATE_KEY.Alice)
signer: privateKeyToJwk(FIXTURE.UNSAFE_PRIVATE_KEY.Alice)
})

try {
Expand Down
Loading

0 comments on commit adac416

Please sign in to comment.