Skip to content

Commit 1f8bcd3

Browse files
authored
fix: cbor keys should be pascal case (#128)
go-ipfs expects keys to be in PascalCase not camelCase.
1 parent 1f16e92 commit 1f8bcd3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/index.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ const _create = async (privateKey, value, seq, validityType, expirationDate, ttl
116116
*/
117117
const createCborData = (value, validity, validityType, sequence, ttl) => {
118118
const data = {
119-
value,
120-
validity,
121-
validityType,
122-
sequence,
123-
ttl
119+
Value: value,
120+
Validity: validity,
121+
ValidityType: validityType,
122+
Sequence: sequence,
123+
TTL: ttl
124124
}
125125

126126
return cborg.encode(data)
@@ -195,33 +195,33 @@ const validateCborDataMatchesPbData = (entry) => {
195195

196196
const data = cborg.decode(entry.data)
197197

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

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

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

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

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

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

224-
if (data.ttl !== entry.ttl) {
224+
if (data.TTL !== entry.ttl) {
225225
throw errCode(new Error('Field "ttl" did not match between protobuf and CBOR'), ERRORS.ERR_SIGNATURE_VERIFICATION)
226226
}
227227
}

0 commit comments

Comments
 (0)