Formatting
This commit is contained in:
@@ -42,7 +42,7 @@ const resourceIdsSchema = z.object({
|
||||
resourceId: z
|
||||
.array(z.string().min(1))
|
||||
.min(1, 'At least one resourceId is required')
|
||||
.transform((ids) => [...new Set(ids)]),
|
||||
.transform((ids) => [ ...new Set(ids) ]),
|
||||
});
|
||||
|
||||
type WriteResource = z.infer<typeof writeResource>;
|
||||
@@ -95,7 +95,7 @@ export class DataRoute implements RouteModule {
|
||||
const resourceIds = this.getResourceIds(stream);
|
||||
|
||||
// Remove duplicates.
|
||||
const uniqueIds = [...new Set(resourceIds)];
|
||||
const uniqueIds = [ ...new Set(resourceIds) ];
|
||||
|
||||
// If there are no resource ids, return an empty array.
|
||||
if (uniqueIds.length === 0) {
|
||||
@@ -107,7 +107,7 @@ export class DataRoute implements RouteModule {
|
||||
// Read the data from the database.
|
||||
const rows = await this.database.db
|
||||
.selectFrom('resource_data')
|
||||
.select(['resource_id', 'public_key', 'blob', 'timestamp'])
|
||||
.select([ 'resource_id', 'public_key', 'blob', 'timestamp' ])
|
||||
.where('resource_id', 'in', uniqueIds)
|
||||
.orderBy('timestamp', 'asc')
|
||||
.execute();
|
||||
@@ -155,11 +155,10 @@ export class DataRoute implements RouteModule {
|
||||
timestamp,
|
||||
})
|
||||
.onConflict((oc) =>
|
||||
oc.columns(['resource_id', 'public_key']).doUpdateSet({
|
||||
oc.columns([ 'resource_id', 'public_key' ]).doUpdateSet({
|
||||
blob,
|
||||
timestamp,
|
||||
}),
|
||||
)
|
||||
}))
|
||||
.execute();
|
||||
}
|
||||
});
|
||||
@@ -276,7 +275,8 @@ export class DataRoute implements RouteModule {
|
||||
const signature = hexToBin(signatureHex);
|
||||
|
||||
// Create a SHA-256 hash of the payload.
|
||||
const messageHash = createHash('sha256').update(payload).digest();
|
||||
const messageHash = createHash('sha256').update(payload)
|
||||
.digest();
|
||||
|
||||
// Low-S normalization rejects malleable signature encodings.
|
||||
return secp256k1.verifySignatureDERLowS(signature, publicKey, messageHash);
|
||||
|
||||
Reference in New Issue
Block a user