Skip to content

Commit

Permalink
chore: Update deps (#694)
Browse files Browse the repository at this point in the history
* chore: update deps

* fix: tests

* chore: deno lint

---------

Co-authored-by: Eric Crooks <[email protected]>
  • Loading branch information
drashbot and crookse authored Oct 10, 2023
1 parent 3dc1ccf commit 99176a8
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
10 changes: 5 additions & 5 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const decoder = new TextDecoder();
const encoder = new TextEncoder();
export { decoder, encoder };

import { STATUS_TEXT as StdStatusText } from "https://deno.land/std@0.175.0/http/http_status.ts";
import { STATUS_TEXT as StdStatusText } from "https://deno.land/std@0.203.0/http/http_status.ts";
export const STATUS_TEXT = new Map<string, string>(
Object.entries(StdStatusText),
);
Expand All @@ -11,11 +11,11 @@ export {
deleteCookie,
getCookies,
setCookie,
} from "https://deno.land/std@0.175.0/http/cookie.ts";
} from "https://deno.land/std@0.203.0/http/cookie.ts";

export type { Cookie } from "https://deno.land/std@0.175.0/http/cookie.ts";
export type { Cookie } from "https://deno.land/std@0.203.0/http/cookie.ts";

export {
Server as StdServer,
} from "https://deno.land/std@0.175.0/http/server.ts";
export type { ConnInfo } from "https://deno.land/std@0.175.0/http/server.ts";
} from "https://deno.land/std@0.203.0/http/server.ts";
export type { ConnInfo } from "https://deno.land/std@0.203.0/http/server.ts";
1 change: 0 additions & 1 deletion src/http/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export class DrashResponse {
// We ignore the following because this means a user can do
// `const user: IUSer = ...; response.json(user)`, which isn't possible with
// Record<string, unknown>
// deno-lint-ignore ban-types
json: object,
status?: number,
headers: Record<string, string> = {},
Expand Down
11 changes: 7 additions & 4 deletions src/services/csrf/csrf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Errors, IService, Request, Response, Service } from "../../../mod.ts";
import { createHash, v4 } from "./deps.ts";
import { toHashString } from "./deps.ts";

/**
* This allows us to pass the TS compiler, so we can add properties to a method that uses it. See `csrf` method below
Expand All @@ -9,9 +9,12 @@ interface F {
token: string;
}

const primaryToken = createHash("sha512");
primaryToken.update(v4.generate());
const primaryTokenString = primaryToken.toString();
const primaryTokenString = toHashString(
await crypto.subtle.digest(
"SHA-512",
new TextEncoder().encode(crypto.randomUUID()),
),
);

type Options = {
cookie?: boolean;
Expand Down
3 changes: 1 addition & 2 deletions src/services/csrf/deps.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { createHash } from "https://deno.land/[email protected]/hash/mod.ts";
export { v4 } from "https://deno.land/[email protected]/uuid/mod.ts";
export { toHashString } from "https://deno.land/[email protected]/crypto/mod.ts";
2 changes: 1 addition & 1 deletion src/services/etag/deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { createHash } from "https://deno.land/std@0.175.0/node/crypto.ts";
export { toHashString } from "https://deno.land/std@0.203.0/crypto/mod.ts";
8 changes: 4 additions & 4 deletions src/services/etag/etag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IService, Request, Response, Service } from "../../../mod.ts";
import { createHash } from "./deps.ts";
import { toHashString } from "./deps.ts";

export class ETagService extends Service implements IService {
#options: { weak: boolean };
Expand All @@ -11,7 +11,7 @@ export class ETagService extends Service implements IService {
this.#options = options;
}

runAfterResource(request: Request, response: Response) {
async runAfterResource(request: Request, response: Response) {
// if response body is empty, send a default etag
if (
response.body === null ||
Expand Down Expand Up @@ -39,8 +39,8 @@ export class ETagService extends Service implements IService {
const body = typeof response.body === "string"
? new TextEncoder().encode(response.body)
: response.body as Uint8Array;
const hash = createHash("sha1").update(body, "utf8").digest("base64")
.toString().substring(0, 27);
const hash = toHashString(await crypto.subtle.digest("SHA-1", body))
.substring(0, 27);
const len = body.byteLength;

// create the etag value to use
Expand Down
2 changes: 1 addition & 1 deletion src/services/graphql/deps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * as Drash from "../../../mod.ts";
export * as GraphQL from "https://cdn.skypack.dev/[email protected]?dts";
// TODO ENSURE DMM UPDATES THIS
export { renderPlaygroundPage } from "https://deno.land/x/gql@1.1.2/graphiql/render.ts";
export { renderPlaygroundPage } from "https://deno.land/x/gql@1.2.4/graphiql/render.ts";
export type {
ExecutionResult,
} from "https://cdn.skypack.dev/[email protected]?dts"; // TODO ENSURE DMM UPDATES THIS
10 changes: 5 additions & 5 deletions tests/deps.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export * as Drash from "../mod.ts";
export * as path from "https://deno.land/std@0.175.0/path/mod.ts";
export * as path from "https://deno.land/std@0.203.0/path/mod.ts";
export * as TestHelpers from "./test_helpers.ts";
export {
assert,
assertEquals,
assertNotEquals,
} from "https://deno.land/std@0.175.0/testing/asserts.ts";
} from "https://deno.land/std@0.203.0/testing/asserts.ts";

export { green, red } from "https://deno.land/std@0.175.0/fmt/colors.ts";
export { delay } from "https://deno.land/std@0.175.0/async/delay.ts";
export { green, red } from "https://deno.land/std@0.203.0/fmt/colors.ts";
export { delay } from "https://deno.land/std@0.203.0/async/delay.ts";

export { deferred } from "https://deno.land/std@0.175.0/async/deferred.ts";
export { deferred } from "https://deno.land/std@0.203.0/async/deferred.ts";

0 comments on commit 99176a8

Please sign in to comment.