Skip to content

Commit

Permalink
update prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Oct 4, 2023
1 parent a5c593c commit 7e10b2f
Show file tree
Hide file tree
Showing 47 changed files with 36,304 additions and 28,028 deletions.
21 changes: 12 additions & 9 deletions bulletin_board/js-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bulletin_board/js-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"jest": "^26.6.3",
"jest-fetch-mock": "^3.0.3",
"jest-transform-graphql": "^2.1.0",
"prettier": "2.1.2",
"prettier": "3.0.3",
"webpack-dev-server": "^3.11.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ export class GraphQLClient {
logEntriesByElection[electionUniqueId].data.election.logEntries.find(
(logEntry) => {
return logEntry.contentHash === contentHash;
}
)
},
),
);
}

getElectionLogEntries({ electionUniqueId }) {
return Promise.resolve(
logEntriesByElection[electionUniqueId].data.election.logEntries
logEntriesByElection[electionUniqueId].data.election.logEntries,
);
}

getPendingMessageByMessageId({ messageId }) {
return Promise.resolve(
pendingMessageByMessageId[messageId].data.pendingMessage
pendingMessageByMessageId[messageId].data.pendingMessage,
);
}

Expand Down
7 changes: 3 additions & 4 deletions bulletin_board/js-client/src/client/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Client", () => {

it("initialise the api client with the given params", () => {
expect(client.apiClient.apiEndpointUrl).toEqual(
defaultParams.apiEndpointUrl
defaultParams.apiEndpointUrl,
);
expect(client.apiClient.wsEndpointUrl).toEqual(defaultParams.wsEndpointUrl);
});
Expand Down Expand Up @@ -49,9 +49,8 @@ describe("Client", () => {

describe("waitForPendingMessageToBeProcessed", () => {
it("returns the pending message for the given messageId", async () => {
const pendingMessage = await client.waitForPendingMessageToBeProcessed(
"dummy.1"
);
const pendingMessage =
await client.waitForPendingMessageToBeProcessed("dummy.1");
expect(pendingMessage).toEqual({
status: "accepted",
});
Expand Down
22 changes: 12 additions & 10 deletions bulletin_board/js-client/src/client/graphql-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("GraphQLClient", () => {
const logEntryResult = { messageId: "dummy.1", signedData: "1234" };

fetch.mockResponseOnce(
JSON.stringify({ data: { logEntry: logEntryResult } })
JSON.stringify({ data: { logEntry: logEntryResult } }),
);

const logEntry = await client.getLogEntry({
Expand All @@ -40,7 +40,7 @@ describe("GraphQLClient", () => {
client.getLogEntry({
electionUniqueId: "example.1",
contentHash: "1234",
})
}),
).rejects.toThrow("something went wrong");
});
});
Expand All @@ -53,7 +53,9 @@ describe("GraphQLClient", () => {
];

fetch.mockResponseOnce(
JSON.stringify({ data: { election: { logEntries: logEntriesResult } } })
JSON.stringify({
data: { election: { logEntries: logEntriesResult } },
}),
);

const logEntries = await client.getElectionLogEntries({
Expand All @@ -69,7 +71,7 @@ describe("GraphQLClient", () => {
await expect(
client.getElectionLogEntries({
electionUniqueId: "example.1",
})
}),
).rejects.toThrow("something went wrong");
});
});
Expand All @@ -79,7 +81,7 @@ describe("GraphQLClient", () => {
const pendingMessageResult = { status: "accepted" };

fetch.mockResponseOnce(
JSON.stringify({ data: { pendingMessage: pendingMessageResult } })
JSON.stringify({ data: { pendingMessage: pendingMessageResult } }),
);

const pendingMessage = await client.getPendingMessageByMessageId({
Expand All @@ -95,7 +97,7 @@ describe("GraphQLClient", () => {
await expect(
client.getPendingMessageByMessageId({
messageId: "dummy.1",
})
}),
).rejects.toThrow("something went wrong");
});
});
Expand All @@ -109,7 +111,7 @@ describe("GraphQLClient", () => {
data: {
processKeyCeremonyStep: { pendingMessage: pendingMessageResult },
},
})
}),
);

const pendingMessage = await client.processKeyCeremonyStep({
Expand All @@ -127,13 +129,13 @@ describe("GraphQLClient", () => {
data: {
processKeyCeremonyStep: { error: errorMessage },
},
})
}),
);

await expect(
client.processKeyCeremonyStep({
electionUniqueId: "example.1",
})
}),
).rejects.toThrow(errorMessage);
});

Expand All @@ -143,7 +145,7 @@ describe("GraphQLClient", () => {
await expect(
client.processKeyCeremonyStep({
electionUniqueId: "example.1",
})
}),
).rejects.toThrow("something went wrong");
});
});
Expand Down
8 changes: 4 additions & 4 deletions bulletin_board/js-client/src/client/message-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class MessageParser {
});

const decodedData = JSON.parse(
new TextDecoder("utf-8").decode(result.payload)
new TextDecoder("utf-8").decode(result.payload),
);

if (!this.keys) {
Expand All @@ -61,7 +61,7 @@ export class MessageParser {
async parseCreateElection({ authority, bulletin_board, trustees }) {
if (!samePublicKeys(authority.public_key, this.authorityPublicKeyJSON)) {
throw new Error(
"The authority public key doesn't match the election's authority public key."
"The authority public key doesn't match the election's authority public key.",
);
}

Expand All @@ -75,13 +75,13 @@ export class MessageParser {
promises.push(
this.loadKey(bulletin_board).then((key) => {
result[BULLETIN_BOARD_TYPE][bulletin_board.slug] = key;
})
}),
);
for (const trustee of trustees) {
promises.push(
this.loadKey(trustee).then((key) => {
result[TRUSTEE_TYPE][trustee.slug] = key;
})
}),
);
}

Expand Down
8 changes: 4 additions & 4 deletions bulletin_board/js-client/src/election/election.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Election", () => {

it("initializes the election with the correct params", () => {
expect(election.bulletinBoardClient).toEqual(
defaultParams.bulletinBoardClient
defaultParams.bulletinBoardClient,
);
expect(election.uniqueId).toEqual(defaultParams.uniqueId);
expect(election.logEntries).toEqual([]);
Expand Down Expand Up @@ -97,7 +97,7 @@ describe("Election", () => {
election.uniqueId,
"some-subtype",
TRUSTEE_TYPE,
"some-other-trustee"
"some-other-trustee",
),
signedData: "5678",
},
Expand All @@ -117,7 +117,7 @@ describe("Election", () => {
election.uniqueId,
"some-subtype",
TRUSTEE_TYPE,
trusteeId
trusteeId,
),
signedData: "1234",
},
Expand All @@ -126,7 +126,7 @@ describe("Election", () => {
election.uniqueId,
"some-subtype",
TRUSTEE_TYPE,
trusteeId
trusteeId,
),
signedData: "5678",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class KeyCeremonyComponent extends TrusteeComponent {
await keyCeremonySetup.next();
await this.trustee.runKeyCeremony();
onComplete();
}
},
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion bulletin_board/js-client/src/trustee/event_manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("EventManager", () => {
expect(message).toEqual("foo");
expect(result).toEqual("bar");
done();
}
},
);
eventManager.broadcastMessageProcessed("foo", "bar");
subscription.unsubscribe();
Expand Down
12 changes: 6 additions & 6 deletions bulletin_board/js-client/src/trustee/identification_keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class IdentificationKeys {
this.usages = ["sign"];
this.publicKeyAttrs = ["alg", "e", "kty", "n"];
this.jwtHeader = this._encode64(
JSON.stringify({ alg: "RS256", typ: "JWT" })
JSON.stringify({ alg: "RS256", typ: "JWT" }),
);

this.trusteeUniqueId = trusteeUniqueId;
Expand Down Expand Up @@ -60,8 +60,8 @@ export class IdentificationKeys {
element.setAttribute(
"href",
`data:text/plain;charset=utf-8,${encodeURIComponent(
JSON.stringify(jwk)
)}`
JSON.stringify(jwk),
)}`,
);
element.setAttribute("download", `${this.keyIdentifier}.jwk`);
element.style.display = "none";
Expand Down Expand Up @@ -149,10 +149,10 @@ export class IdentificationKeys {
const signature = await this.crypto.subtle.sign(
this.algorithm,
this.privateKey,
this.textEncoder.encode(data)
this.textEncoder.encode(data),
);
return `${data}.${btoa(
Reflect.apply(String.fromCharCode, null, new Uint8Array(signature))
Reflect.apply(String.fromCharCode, null, new Uint8Array(signature)),
)
.replace(/[=]/g, "")
.replace(/\+/g, "-")
Expand Down Expand Up @@ -211,7 +211,7 @@ export class IdentificationKeys {
privateKey: this.privateKey,
publicKey: this.publicKey,
},
this.keyIdentifier
this.keyIdentifier,
);
});
}
Expand Down
8 changes: 4 additions & 4 deletions bulletin_board/js-client/src/trustee/trustee.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class Trustee {
*/
async needsToBeRestored() {
const lastMessageFromTrustee = this.election.getLastMessageFromTrustee(
this.uniqueId
this.uniqueId,
);

return lastMessageFromTrustee && (await this.wrapperAdapter.isFresh());
Expand All @@ -156,7 +156,7 @@ export class Trustee {
*/
async restore(wrapperState) {
const lastMessageFromTrustee = this.election.getLastMessageFromTrustee(
this.uniqueId
this.uniqueId,
);

this.hasSetupKeyCeremony =
Expand Down Expand Up @@ -206,7 +206,7 @@ export class Trustee {

const result = await this.wrapperAdapter.processMessage(
messageIdentifier.typeSubtype,
decodedData
decodedData,
);

this.events.broadcastMessageProcessed(message, result);
Expand All @@ -220,7 +220,7 @@ export class Trustee {
this.election.uniqueId,
messageType,
TRUSTEE_TYPE,
this.uniqueId
this.uniqueId,
),
content,
};
Expand Down
Loading

0 comments on commit 7e10b2f

Please sign in to comment.