Skip to content

Commit

Permalink
chore(message): rename externalKeyId to signingDeviceKeyId
Browse files Browse the repository at this point in the history
  • Loading branch information
Ofir Dagan committed Jan 11, 2024
1 parent 0d5be5b commit 2cbe57c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api/customer-server.api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ components:
- version
- fbKeyId
- requestId
- externalKeyId
- signingDeviceKeyId
- algorithm
- data
properties:
Expand All @@ -160,7 +160,7 @@ components:
type: string
format: uuid
example: b015f35e-5d44-4d68-a0df-a1c625255abc
externalKeyId:
signingDeviceKeyId:
type: string
example: 70721651-a7f3-42f6-a984-6e058269495f
algorithm:
Expand Down
2 changes: 1 addition & 1 deletion api/customer-server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface components {
*/
requestId: string;
/** @example 70721651-a7f3-42f6-a984-6e058269495f */
externalKeyId: string;
signingDeviceKeyId: string;
algorithm: components["schemas"]["Algorithm"];
/**
* @description The string to sign
Expand Down
2 changes: 1 addition & 1 deletion examples/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:api": "openapi-typescript ../../api/customer-server.api.yml -o ./src/customer-server.d.ts",
"build": "tsc",
"build": "npm run build:api && tsc",
"start": "NODE_ENV=dev node ./dist/server.js",
"dev": "NODE_ENV=dev ts-node ./src/server.ts",
"build:docker": "npm run build:api && docker build -t softhsm2:2.6.1 .",
Expand Down
2 changes: 1 addition & 1 deletion examples/server/src/customer-server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface components {
*/
requestId: string;
/** @example 70721651-a7f3-42f6-a984-6e058269495f */
externalKeyId: string;
signingDeviceKeyId: string;
algorithm: components["schemas"]["Algorithm"];
/**
* @description The string to sign
Expand Down
8 changes: 4 additions & 4 deletions examples/server/src/services/hsm-sign-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export async function randomlySignOrFailMessagesAsync(msgIds: number[]) {
msg.errorMessage = `Simulate error while signing this message ${msg.msgId}`;
}
const algorithm = msg.message.algorithm === 'EDDSA_ED25519' ? 'EDDSA' : 'ECDSA';
const { externalKeyId, data } = msg.message;
const { signingDeviceKeyId, data } = msg.message;
if (msg.status === 'SIGNED') {
msg.signedPayload = await hsmFacade.sign(externalKeyId, data, algorithm);
msg.signedPayload = await hsmFacade.sign(signingDeviceKeyId, data, algorithm);
}
await messagesDao.updateMessageStatus(msg);
console.log(`Set ${msg.msgId} from status ${previousStatus} to ${msg.status}`);
Expand All @@ -29,8 +29,8 @@ export async function signMessages(msgIds: number[]) {
const messages = await getMessages(msgIds);
messages.forEach(async (msg) => {
const algorithm = msg.message.algorithm === 'EDDSA_ED25519' ? 'EDDSA' : 'ECDSA';
const { externalKeyId, data } = msg.message;
msg.signedPayload = await hsmFacade.sign(externalKeyId, data, algorithm);
const { signingDeviceKeyId, data } = msg.message;
msg.signedPayload = await hsmFacade.sign(signingDeviceKeyId, data, algorithm);
msg.status = 'SIGNED';
logger.info(`signed message ${msg.msgId}. signature: ${msg.signedPayload}`);
await messagesDao.updateMessageStatus(msg);
Expand Down
2 changes: 1 addition & 1 deletion src/services/server.api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const messageBuilder = {
version: 1,
fbKeyId: c.guid(),
requestId: c.guid(),
externalKeyId: c.guid(),
signingDeviceKeyId: c.guid(),
algorithm: 'ECDSA_SECP256K1',
data: c.string(),
...message,
Expand Down

0 comments on commit 2cbe57c

Please sign in to comment.