Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
amydevs committed Sep 2, 2024
1 parent f6048db commit ccd9bfe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 38 deletions.
4 changes: 3 additions & 1 deletion src/claims/payloads/claimNetworkAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ function assertClaimNetworkAccess(
}
if (
claimNetworkAccess['signedClaimNetworkAuthorityEncoded'] != null &&
!tokensSchema.validateSignedTokenEncoded(claimNetworkAccess['signedClaimNetworkAuthorityEncoded'])
!tokensSchema.validateSignedTokenEncoded(
claimNetworkAccess['signedClaimNetworkAuthorityEncoded'],
)
) {
throw new validationErrors.ErrorParse(
'`signedClaimNetworkAuthorityEncoded` property must be an encoded signed token',
Expand Down
37 changes: 0 additions & 37 deletions src/nodes/NodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,43 +263,6 @@ class NodeManager {
cause: new AggregateError(failedConnectionErrors),
},
);
} else {
// Wip: We should ideally take the fastest connection and use it here for node signing.
const conn = successfulConnections[0].value;
await this.sigchain.addClaim(
{
typ: 'ClaimNetworkNode',
iss: nodesUtils.encodeNodeId(conn.nodeId),
sub: nodesUtils.encodeNodeId(this.keyRing.getNodeId()),
},
undefined,
async (token) => {
const halfSignedClaim = token.toSigned();
const halfSignedClaimEncoded =
claimsUtils.generateSignedClaim(halfSignedClaim);
const receivedClaim =
await conn.rpcClient.methods.nodesClaimNetworkSign({
signedTokenEncoded: halfSignedClaimEncoded,
});
const signedClaim = claimsUtils.parseSignedClaim(
receivedClaim.signedTokenEncoded,
);
const fullySignedToken = Token.fromSigned(signedClaim);
// Check that the signatures are correct
const targetNodePublicKey = keysUtils.publicKeyFromNodeId(
conn.nodeId,
);
if (
!fullySignedToken.verifyWithPublicKey(
this.keyRing.keyPair.publicKey,
) ||
!fullySignedToken.verifyWithPublicKey(targetNodePublicKey)
) {
throw new claimsErrors.ErrorDoublySignedClaimVerificationFailed();
}
return fullySignedToken;
},
);
}
if (ctx.signal.aborted) return;

Expand Down

0 comments on commit ccd9bfe

Please sign in to comment.