Skip to content

Commit

Permalink
Use isDenoV1.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajiaji committed Oct 13, 2024
1 parent 2f750df commit 5c49d88
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/core/test/kemContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ describe("generateKeyPair", () => {
});

it("should return a proper instance with DhkemX448HkdfSha512", async () => {
if (isDenoV1()) {
return;
}
// assert
const kemContext = new DhkemX448HkdfSha512();
const kp = await kemContext.generateKeyPair();
Expand Down Expand Up @@ -363,6 +366,9 @@ describe("serialize/deserializePublicKey", () => {
});

it("should return a proper instance with DhkemX448HkdfSha512", async () => {
if (isDenoV1()) {
return;
}
// assert
const kemContext = new DhkemX448HkdfSha512();
const kp = await kemContext.generateKeyPair();
Expand Down Expand Up @@ -848,6 +854,9 @@ describe("importKey", () => {
});

it("should return a valid private key for DhkemX448HkdfSha512 from JWK", async () => {
if (isDenoV1()) {
return;
}
const kemContext = new DhkemX448HkdfSha512();

const jwk = {
Expand All @@ -866,6 +875,9 @@ describe("importKey", () => {
});

it("should return a valid public key for DhkemX448HkdfSha512 from JWK", async () => {
if (isDenoV1()) {
return;
}
const kemContext = new DhkemX448HkdfSha512();

const jwk = {
Expand Down
23 changes: 22 additions & 1 deletion packages/core/test/sample.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertEquals, assertRejects } from "@std/assert";
import { describe, it } from "@std/testing/bdd";

import { isDeno } from "@hpke/common";
import { isDeno, isDenoV1 } from "@hpke/common";
import {
Aes128Gcm,
Aes256Gcm,
Expand Down Expand Up @@ -283,6 +283,9 @@ describe("README examples", () => {

describe("Base mode with DhkemX25519HkdfSha256/HkdfSha256/Aes128Gcm", () => {
it("should work normally", async () => {
if (isDenoV1()) {
return;
}
// setup
const suite = new CipherSuite({
kem: new DhkemX25519HkdfSha256(),
Expand Down Expand Up @@ -366,6 +369,9 @@ describe("README examples", () => {
});

it("should work normally with importKey('jwk') and using CryptoKeyPair", async () => {
if (isDenoV1()) {
return;
}
// setup
const suite = new CipherSuite({
kem: new DhkemX25519HkdfSha256(),
Expand Down Expand Up @@ -416,6 +422,9 @@ describe("README examples", () => {
});
describe("Base mode with DhkemX448HkdfSha256/HkdfSha512/Aes256Gcm)", () => {
it("should work normally", async () => {
if (isDenoV1()) {
return;
}
// setup
const suite = new CipherSuite({
kem: new DhkemX448HkdfSha512(),
Expand Down Expand Up @@ -499,6 +508,9 @@ describe("README examples", () => {
});

it("should work normally with importKey('jwk') and using CryptoKeyPair", async () => {
if (isDenoV1()) {
return;
}
// setup
const suite = new CipherSuite({
kem: new DhkemX448HkdfSha512(),
Expand Down Expand Up @@ -589,6 +601,9 @@ describe("README examples", () => {

describe("Base mode with DhkemX25519HkdfSha256/HkdfSha256/ExportOnly", () => {
it("should work normally", async () => {
if (isDenoV1()) {
return;
}
// setup
const suite = new CipherSuite({
kem: new DhkemX25519HkdfSha256(),
Expand Down Expand Up @@ -749,6 +764,9 @@ describe("README examples", () => {

describe("AuthPSK mode with DhkemX25519HkdfSha256", () => {
it("should work normally", async () => {
if (isDenoV1()) {
return;
}
// setup
const suite = new CipherSuite({
kem: new DhkemX25519HkdfSha256(),
Expand Down Expand Up @@ -793,6 +811,9 @@ describe("README examples", () => {

describe("AuthPSK mode with DhkemX448HkdfSha512", () => {
it("should work normally", async () => {
if (isDenoV1()) {
return;
}
// setup
const suite = new CipherSuite({
kem: new DhkemX448HkdfSha512(),
Expand Down

0 comments on commit 5c49d88

Please sign in to comment.