Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Dec 10, 2024
1 parent b68c05f commit 964d622
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions deno/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ There are a growing number of tools that are built atop or support Zod natively!
- [`@vee-validate/zod`](https://github.com/logaretm/vee-validate/tree/main/packages/zod): Form library for Vue.js with Zod schema validation.
- [`zod-form-renderer`](https://github.com/thepeaklab/zod-form-renderer): Auto-infer form fields from zod schema and render them with react-hook-form with E2E type safety.
- [`antd-zod`](https://github.com/MrBr/antd-zod): Zod adapter for Ant Design form fields validation.
- [`frrm`](https://github.com/schalkventer/frrm): Tiny 0.5kb Zod-based, HTML form abstraction that goes brr.

#### Zod to X

Expand Down
5 changes: 2 additions & 3 deletions deno/lib/__tests__/standard-schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// @ts-ignore TS6133
import { expect } from "https://deno.land/x/expect@v0.2.6/mod.ts";
const test = Deno.test;
import { util } from "../helpers/util.ts";
import type { StandardSchemaV1 } from "@standard-schema/spec";

import { util } from "../helpers/util.ts";
import * as z from "../index.ts";

import type { StandardSchemaV1 } from "@standard-schema/spec";

test("assignability", () => {
const _s1: StandardSchemaV1 = z.string();
const _s2: StandardSchemaV1<string> = z.string();
Expand Down
12 changes: 8 additions & 4 deletions deno/lib/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ test("jwt validations", () => {
const jwtWithAlg = z.string().jwt({ alg: "HS256" });

// Valid JWTs
const validHeader = Buffer.from(JSON.stringify({ typ: "JWT", alg: "HS256" })).toString('base64url');
const validPayload = Buffer.from("{}").toString('base64url');
const validHeader = Buffer.from(
JSON.stringify({ typ: "JWT", alg: "HS256" })
).toString("base64url");
const validPayload = Buffer.from("{}").toString("base64url");
const validSignature = "signature";
const validJWT = `${validHeader}.${validPayload}.${validSignature}`;

Expand All @@ -266,12 +268,14 @@ test("jwt validations", () => {
expect(() => jwt.parse("invalid.invalid.invalid")).toThrow();

// Invalid header
const invalidHeader = Buffer.from("{}").toString('base64url');
const invalidHeader = Buffer.from("{}").toString("base64url");
const invalidHeaderJWT = `${invalidHeader}.${validPayload}.${validSignature}`;
expect(() => jwt.parse(invalidHeaderJWT)).toThrow();

// Wrong algorithm
const wrongAlgHeader = Buffer.from(JSON.stringify({ typ: "JWT", alg: "RS256" })).toString('base64url');
const wrongAlgHeader = Buffer.from(
JSON.stringify({ typ: "JWT", alg: "RS256" })
).toString("base64url");
const wrongAlgJWT = `${wrongAlgHeader}.${validPayload}.${validSignature}`;
expect(() => jwtWithAlg.parse(wrongAlgJWT)).toThrow();

Expand Down
5 changes: 2 additions & 3 deletions src/__tests__/standard-schema.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// @ts-ignore TS6133
import { expect, test } from "@jest/globals";
import { util } from "../helpers/util";
import type { StandardSchemaV1 } from "@standard-schema/spec";

import { util } from "../helpers/util";
import * as z from "../index";

import type { StandardSchemaV1 } from "@standard-schema/spec";

test("assignability", () => {
const _s1: StandardSchemaV1 = z.string();
const _s2: StandardSchemaV1<string> = z.string();
Expand Down
12 changes: 8 additions & 4 deletions src/__tests__/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ test("jwt validations", () => {
const jwtWithAlg = z.string().jwt({ alg: "HS256" });

// Valid JWTs
const validHeader = Buffer.from(JSON.stringify({ typ: "JWT", alg: "HS256" })).toString('base64url');
const validPayload = Buffer.from("{}").toString('base64url');
const validHeader = Buffer.from(
JSON.stringify({ typ: "JWT", alg: "HS256" })
).toString("base64url");
const validPayload = Buffer.from("{}").toString("base64url");
const validSignature = "signature";
const validJWT = `${validHeader}.${validPayload}.${validSignature}`;

Expand All @@ -265,12 +267,14 @@ test("jwt validations", () => {
expect(() => jwt.parse("invalid.invalid.invalid")).toThrow();

// Invalid header
const invalidHeader = Buffer.from("{}").toString('base64url');
const invalidHeader = Buffer.from("{}").toString("base64url");
const invalidHeaderJWT = `${invalidHeader}.${validPayload}.${validSignature}`;
expect(() => jwt.parse(invalidHeaderJWT)).toThrow();

// Wrong algorithm
const wrongAlgHeader = Buffer.from(JSON.stringify({ typ: "JWT", alg: "RS256" })).toString('base64url');
const wrongAlgHeader = Buffer.from(
JSON.stringify({ typ: "JWT", alg: "RS256" })
).toString("base64url");
const wrongAlgJWT = `${wrongAlgHeader}.${validPayload}.${validSignature}`;
expect(() => jwtWithAlg.parse(wrongAlgJWT)).toThrow();

Expand Down

0 comments on commit 964d622

Please sign in to comment.