Skip to content

Commit 3074143

Browse files
committed
updated error message for multiple operations & compares buffers
1 parent ce8c054 commit 3074143

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/utils.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,12 @@ export namespace Utils {
193193

194194
if (operation.value === undefined) {
195195
throw new InvalidSep10ChallengeError(
196-
"The transaction's operation value should not be null",
196+
"The transaction's operation values should not be null",
197197
);
198198
}
199199

200200
// verify base64
201-
if (
202-
!operation.value ||
203-
Buffer.from(operation.value.toString(), "base64").length !== 48
204-
) {
201+
if (Buffer.from(operation.value.toString(), "base64").length !== 48) {
205202
throw new InvalidSep10ChallengeError(
206203
"The transaction's operation value should be a 64 bytes base64 random string",
207204
);
@@ -248,14 +245,17 @@ export namespace Utils {
248245
"The transaction has operations that are unrecognized",
249246
);
250247
}
248+
if (op.value === undefined) {
249+
throw new InvalidSep10ChallengeError(
250+
"The transaction's operation values should not be null",
251+
);
252+
}
251253
if (
252254
op.name === "web_auth_domain" &&
253-
(!op.value || op.value.toString() !== webAuthDomain)
255+
!op.value.compare(Buffer.from(webAuthDomain))
254256
) {
255257
throw new InvalidSep10ChallengeError(
256-
`Invalid 'web_auth_domain' value. Expected: ${webAuthDomain}; Contained: ${
257-
op.value ? op.value.toString() : op.value
258-
}`,
258+
`'web_auth_domain' operation value does not match ${webAuthDomain}`,
259259
);
260260
}
261261
}

0 commit comments

Comments
 (0)