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: cbor keys should be pascal case #128

Merged
merged 1 commit into from
Aug 11, 2021
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
28 changes: 14 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ const _create = async (privateKey, value, seq, validityType, expirationDate, ttl
*/
const createCborData = (value, validity, validityType, sequence, ttl) => {
const data = {
value,
validity,
validityType,
sequence,
ttl
Value: value,
Validity: validity,
ValidityType: validityType,
Sequence: sequence,
TTL: ttl
}

return cborg.encode(data)
Expand Down Expand Up @@ -195,33 +195,33 @@ const validateCborDataMatchesPbData = (entry) => {

const data = cborg.decode(entry.data)

if (Number.isInteger(data.sequence)) {
if (Number.isInteger(data.Sequence)) {
// sequence must be a BigInt, but DAG-CBOR doesn't preserve this for Numbers within the safe-integer range
data.sequence = BigInt(data.sequence)
data.Sequence = BigInt(data.Sequence)
}

if (Number.isInteger(data.ttl)) {
if (Number.isInteger(data.TTL)) {
// ttl must be a BigInt, but DAG-CBOR doesn't preserve this for Numbers within the safe-integer range
data.ttl = BigInt(data.ttl)
data.TTL = BigInt(data.TTL)
}

if (!uint8ArrayEquals(data.value, entry.value)) {
if (!uint8ArrayEquals(data.Value, entry.value)) {
throw errCode(new Error('Field "value" did not match between protobuf and CBOR'), ERRORS.ERR_SIGNATURE_VERIFICATION)
}

if (!uint8ArrayEquals(data.validity, entry.validity)) {
if (!uint8ArrayEquals(data.Validity, entry.validity)) {
throw errCode(new Error('Field "validity" did not match between protobuf and CBOR'), ERRORS.ERR_SIGNATURE_VERIFICATION)
}

if (data.validityType !== entry.validityType) {
if (data.ValidityType !== entry.validityType) {
throw errCode(new Error('Field "validityType" did not match between protobuf and CBOR'), ERRORS.ERR_SIGNATURE_VERIFICATION)
}

if (data.sequence !== entry.sequence) {
if (data.Sequence !== entry.sequence) {
throw errCode(new Error('Field "sequence" did not match between protobuf and CBOR'), ERRORS.ERR_SIGNATURE_VERIFICATION)
}

if (data.ttl !== entry.ttl) {
if (data.TTL !== entry.ttl) {
throw errCode(new Error('Field "ttl" did not match between protobuf and CBOR'), ERRORS.ERR_SIGNATURE_VERIFICATION)
}
}
Expand Down