-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update module resolution and test mocks
- Add .js extension to imports for node16/nodenext module resolution - Move secp256k1 mock to root __mocks__ directory - Fix mock implementation to properly handle message signing and verification
- Loading branch information
Showing
7 changed files
with
63 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
console.log("Loading secp256k1 mock"); | ||
|
||
let utilsValue = { | ||
hmacSha256: (key: Uint8Array, ...messages: Uint8Array[]): Uint8Array => { | ||
// Mock implementation of HMAC SHA256 | ||
const result = new Uint8Array(32); // Dummy result | ||
result.fill(1); // Fill with dummy data | ||
return result; | ||
}, | ||
hmacSha256Sync: (key: Uint8Array, ...messages: Uint8Array[]): Uint8Array => { | ||
// Mock implementation of synchronous HMAC SHA256 | ||
const result = new Uint8Array(32); // Dummy result | ||
result.fill(1); // Fill with dummy data | ||
return result; | ||
} | ||
}; | ||
|
||
Object.defineProperty(exports, 'utils', { | ||
get: () => utilsValue, | ||
set: (value) => { | ||
utilsValue = { ...utilsValue, ...value }; | ||
}, | ||
configurable: true, | ||
enumerable: true | ||
}); | ||
|
||
class Signature { | ||
constructor(private bytes: Uint8Array) { | ||
console.log("Creating Signature instance"); | ||
} | ||
|
||
toCompactRawBytes(): Uint8Array { | ||
console.log("Calling toCompactRawBytes"); | ||
return this.bytes; | ||
} | ||
} | ||
|
||
// Keep track of signed message hashes for verification | ||
const signedHashes = new Map<string, boolean>(); | ||
|
||
export const sign = async (messageHash: Uint8Array, privateKey: Uint8Array): Promise<Signature> => { | ||
console.log("Calling mock sign function"); | ||
const signatureBytes = new Uint8Array(64); | ||
signatureBytes.fill(1); | ||
// Store the message hash for verification | ||
const hashHex = Array.from(messageHash).map(b => b.toString(16).padStart(2, '0')).join(''); | ||
signedHashes.set(hashHex, true); | ||
return new Signature(signatureBytes); | ||
}; | ||
|
||
export const verify = async (signature: Uint8Array, messageHash: Uint8Array, publicKey: Uint8Array): Promise<boolean> => { | ||
const hashHex = Array.from(messageHash).map(b => b.toString(16).padStart(2, '0')).join(''); | ||
return signedHashes.has(hashHex); | ||
}; |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters