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

Array.prototype methods cause validation error in the expected transp… #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 14 additions & 8 deletions dist/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1980,22 +1980,22 @@ async function validateExpectations() {
if (!Array.isArray(allowCredentials)) {
throw new Error("expected allowCredentials to be null or array");
} else {
for (const index in allowCredentials) {
if (typeof allowCredentials[index].id === "string") {
allowCredentials[index].id = coerceToArrayBuffer$1(allowCredentials[index].id, "allowCredentials[" + index + "].id");
allowCredentials.forEach((allowCredential, index) => {
if (typeof allowCredential.id === "string") {
allowCredential.id = coerceToArrayBuffer$1(allowCredential.id, "allowCredentials[" + index + "].id");
}
if (allowCredentials[index].id == null || !(allowCredentials[index].id instanceof ArrayBuffer)) {
if (allowCredential.id == null || !(allowCredential.id instanceof ArrayBuffer)) {
throw new Error("expected id of allowCredentials[" + index + "] to be ArrayBuffer");
}
if (allowCredentials[index].type == null || allowCredentials[index].type !== "public-key") {
if (allowCredential.type == null || allowCredential.type !== "public-key") {
throw new Error("expected type of allowCredentials[" + index + "] to be string with value 'public-key'");
}
if (allowCredentials[index].transports != null && !Array.isArray(allowCredentials[index].transports)) {
if (allowCredential.transports != null && !Array.isArray(allowCredential.transports)) {
throw new Error("expected transports of allowCredentials[" + index + "] to be array or null");
} else if (allowCredentials[index].transports != null && !allowCredentials[index].transports.every(el => ["usb", "nfc", "ble", "cable", "internal"].includes(el))) {
} else if (allowCredential.transports != null && !allowCredential.transports.every(el => ["usb", "nfc", "ble", "cable", "internal"].includes(el))) {
throw new Error("expected transports of allowCredentials[" + index + "] to be string with value 'usb', 'nfc', 'ble', 'cable', 'internal' or null");
}
}
});
}
}

Expand Down Expand Up @@ -2100,6 +2100,9 @@ async function validateTransports() {
}

for (const index in transports) {
if (typeof transports[index] == "function") {
continue; //expected transports[<Array.Prototype.Methods>] are skipped;
}
if (typeof transports[index] !== "string") {
throw new Error("expected transports[" + index + "] to be 'string'");
}
Expand Down Expand Up @@ -2704,6 +2707,9 @@ function parseExpectations(exp) {
}

for (const index in allowCredentials) {
if (typeof allowCredentials[index] == "function") {
continue; //expected allowCredentials[<Array.Prototype.Methods>] are skipped;
}
if (allowCredentials[index].id != null) {
allowCredentials[index].id = coerceToArrayBuffer$1(
allowCredentials[index].id,
Expand Down
10 changes: 10 additions & 0 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42933,6 +42933,10 @@ async function validateExpectations() {
throw new Error("expected allowCredentials to be null or array");
} else {
for(const index in allowCredentials){
if (typeof allowCredentials[index] == "function")
{
continue; //expected allowCredentials[<Array.Prototype.Methods>] are skipped;
}
if (typeof allowCredentials[index].id === "string") {
allowCredentials[index].id = coerceToArrayBuffer(allowCredentials[index].id, "allowCredentials[" + index + "].id");
}
Expand Down Expand Up @@ -43020,6 +43024,9 @@ function parseExpectations(exp) {
throw new TypeError("expected 'allowCredentials' to be null or array, got " + typeof allowCredentials);
}
for(const index in allowCredentials){
if (typeof allowCredentials[index] == "function") {
continue; //expected allowCredentials[<Array.Prototype.Methods>] are skipped;
}
if (allowCredentials[index].id != null) {
allowCredentials[index].id = coerceToArrayBuffer(allowCredentials[index].id, "allowCredentials[" + index + "].id");
}
Expand Down Expand Up @@ -43763,6 +43770,9 @@ async function validateTransports() {
throw new Error("expected transports to be 'null' or 'array<string>'");
}
for(const index in transports){
if (typeof transports[index] == "function") {
continue; //expected transports[<Array.Prototype.Methods>] are skipped;
}
if (typeof transports[index] !== "string") {
throw new Error("expected transports[" + index + "] to be 'string'");
}
Expand Down
3 changes: 3 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function parseExpectations(exp) {
}

for (const index in allowCredentials) {
if (typeof allowCredentials[index] == "function") {
continue; //expected allowCredentials[<Array.Prototype.Methods>] are skipped;
}
if (allowCredentials[index].id != null) {
allowCredentials[index].id = coerceToArrayBuffer(
allowCredentials[index].id,
Expand Down
3 changes: 3 additions & 0 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ async function validateTransports() {
}

for (const index in transports) {
if (typeof transports[index] == "function") {
continue; //expected transports[<Array.Prototype.Methods>] are skipped;
}
if (typeof transports[index] !== "string") {
throw new Error("expected transports[" + index + "] to be 'string'");
}
Expand Down