File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import type {
77 SignatureData ,
88 ClaimIntermediary ,
99} from './types' ;
10- import type { NodeIdEncoded } from '../nodes/types' ;
10+ import type { NodeId , NodeIdEncoded } from '../nodes/types' ;
1111import type { PublicKeyPem , PrivateKeyPem } from '../keys/types' ;
1212import type { POJO } from '../types' ;
1313import type { GeneralJWSInput } from 'jose' ;
@@ -492,10 +492,14 @@ function decodeClaimId(claimIdEncoded: string): ClaimId | undefined {
492492 return claimId ;
493493}
494494
495- function createClaimIdGenerator ( nodeId : NodeIdEncoded , lastClaimId ?: ClaimId ) {
495+ /**
496+ * Generator for `ClaimId`
497+ * Make sure the `nodeId` is set to this node's own `NodeId`
498+ */
499+ function createClaimIdGenerator ( nodeId : NodeId , lastClaimId ?: ClaimId ) {
496500 const generator = new IdSortable < ClaimId > ( {
497501 lastId : lastClaimId ,
498- nodeId : IdInternal . fromString ( nodeId ) . toBuffer ( ) ,
502+ nodeId,
499503 } ) ;
500504 return ( ) => generator . get ( ) ;
501505}
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ import {
1919} from '@matrixai/async-init/dist/CreateDestroyStartStop' ;
2020import * as sigchainErrors from './errors' ;
2121import * as claimsUtils from '../claims/utils' ;
22- import { utils as nodesUtils } from '../nodes' ;
2322
2423interface Sigchain extends CreateDestroyStartStop { }
2524@CreateDestroyStartStop (
@@ -138,7 +137,7 @@ class Sigchain {
138137 // Creating the ID generator
139138 const latestId = await this . getLatestClaimId ( ) ;
140139 this . generateClaimId = claimsUtils . createClaimIdGenerator (
141- nodesUtils . encodeNodeId ( this . keyManager . getNodeId ( ) ) ,
140+ this . keyManager . getNodeId ( ) ,
142141 latestId ,
143142 ) ;
144143 this . logger . info ( `Started ${ this . constructor . name } ` ) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import * as identitiesPB from '@/proto/js/polykey/v1/identities/identities_pb';
2323import * as clientUtils from '@/client/utils/utils' ;
2424import * as keysUtils from '@/keys/utils' ;
2525import * as claimsUtils from '@/claims/utils' ;
26+ import * as nodesUtils from '@/nodes/utils' ;
2627import * as validationErrors from '@/validation/errors' ;
2728import * as testUtils from '../../utils' ;
2829import TestProvider from '../../identities/TestProvider' ;
@@ -47,7 +48,9 @@ describe('identitiesClaim', () => {
4748 provider : testToken . providerId ,
4849 identity : testToken . identityId ,
4950 } ;
50- const claimId = claimsUtils . createClaimIdGenerator ( claimData . node ) ( ) ;
51+ const claimId = claimsUtils . createClaimIdGenerator (
52+ nodesUtils . decodeNodeId ( claimData . node ) ! ,
53+ ) ( ) ;
5154 let mockedGenerateKeyPair : jest . SpyInstance ;
5255 let mockedGenerateDeterministicKeyPair : jest . SpyInstance ;
5356 let mockedAddClaim : jest . SpyInstance ;
You can’t perform that action at this time.
0 commit comments