Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 sha with whole data #391

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/src/statements/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const validKey = (input) =>
input.search(/^[a-z]+:(\/?\/?)[^\s]+$/g) === 0;

const sha = (input) => Promise.resolve(createHash('sha256').update(JSON.stringify(input)).digest('hex'));

//
// JS implentation of NCDA
// see http://search.cpan.org/~jak/Noid/noid#NOID_CHECK_DIGIT_ALGORITHM
Expand Down Expand Up @@ -54,7 +55,7 @@ export default async function identify(data, feed) {
if (scheme === 'uid') {
identifier = await generate(nolookalikes, 8);
} else if (scheme === 'sha') {
identifier = await sha(uri);
identifier = await sha(JSON.stringify(data));
}
if (identifier) {
const checksum = ncda(identifier, nolookalikes);
Expand Down