Skip to content

Conversation

@chihunmanse
Copy link
Contributor

Pull Request

Thank you for raising a Pull Request. Please follow the instruction.

  • I’ve read CONTRIBUTING.md and followed the guidelines.

Summary

Links (Issue References, etc, if there's any)

* Defines which API names are allowed for each operation type.
* Each operation type has a specific set of APIs that can be called.
*/
export const ALLOWED_APIS: Record<OperationType, string[]> = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a generic Record of the type described as such. This is a very specific object instance.


await pool.query(
`INSERT INTO "commit_reveal_sessions"
(session_id, operation_type, client_ephemeral_pubkey, id_token_hash, state, expires_at)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so you know, you are assuming the whitespace in the left side since you used backtick operators

hasCommitRevealApiBeenCalled,
} from "@oko-wallet/oko-pg-interface/commit_reveal";

import { ErrorCodeMap } from "@oko-wallet/oko-api-error-codes";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

external deps

app.use("/keyshare/v2", keyshareV2Router);

const commitRevealRouter = makeCommitRevealRouter();
app.use("/commit-reveal/v2", commitRevealRouter);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore valid

@chihunmanse
Copy link
Contributor Author

@eldenpark Ready for review. I’ve addressed the comments


// Verify signature: message = node_pubkey + session_id + auth_type + id_token + operation_type + api_name
const nodePubkeyHex = state.server_keypair.publicKey.toHex();
const message = `${nodePubkeyHex}${cr_session_id}${authType}${idToken}${session.operation_type}${apiName}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should become a function. I'll modify.

| "register_ed25519";

export const ALLOWED_APIS = {
export const ALLOWED_APIS: Record<OperationType, ApiName[]> = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Record<OperationType, ApiName[]> implies any of the matches between K and V, such that
sign_in => register" is a valid interface. This is not the case. I'll modify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Record<OperationType, ApiName[]> implies any of the matches between K and V, such that sign_in => register" is a valid interface. This is not the case. I'll modify.

I applied the same changes to the oko api middleware as well.

@eldenpark
Copy link
Collaborator

@chihunmanse Why does "commit-reveal" operation need to happen between user <> oko?

@chihunmanse
Copy link
Contributor Author

@chihunmanse Why does "commit-reveal" operation need to happen between user <> oko?

Because the oko server also uses the user’s OAuth token for sign-up and sign-in, it can theoretically front-run just like a ks node.

}

// message = node_pubkey + session_id + auth_type + id_token + operation_type + api_name
function makeSigMessage({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chihunmanse Please review the change I made here. We may want to use this function in other places as well.

const state = params.state ?? "COMMITTED";

await pool.query(
`INSERT INTO "commit_reveal_sessions" (session_id, operation_type, client_ephemeral_pubkey, id_token_hash, state, expires_at) VALUES ($1, $2, $3, $4, $5, $6)`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too long and I'd like to set a coding practice where we write 4 items in a line. I'll make a change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, never mind. It's a test case and I'll leave it as it is!

@eldenpark eldenpark merged commit 9c2c819 into develop Jan 30, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants