Skip to content

Commit

Permalink
Introduce deno workspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajiaji committed Aug 22, 2024
1 parent 1e8582d commit 02e7d05
Show file tree
Hide file tree
Showing 36 changed files with 126 additions and 91 deletions.
12 changes: 6 additions & 6 deletions core/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export type { RecipientContextParams } from "./src/interfaces/recipientContextPa
export type { CipherSuiteSealResponse } from "./src/interfaces/responses.ts";
export type { SenderContextParams } from "./src/interfaces/senderContextParams.ts";

// export {
// KEM_USAGES,
// LABEL_DKP_PRK,
// LABEL_SK,
// } from "./src/interfaces/dhkemPrimitives.ts";
// export { SUITE_ID_HEADER_KEM } from "./src/interfaces/kemInterface.ts";
export {
KEM_USAGES,
LABEL_DKP_PRK,
LABEL_SK,
} from "./src/interfaces/dhkemPrimitives.ts";
export { SUITE_ID_HEADER_KEM } from "./src/interfaces/kemInterface.ts";

export { Aes128Gcm, Aes256Gcm } from "./src/aeads/aesGcm.ts";
export { ExportOnly } from "./src/aeads/exportOnly.ts";
Expand Down
12 changes: 9 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{
"name": "@dajiaji/hpke",
"version": "1.2.9",
"workspace": [
"./core",
"./x/chacha20poly1305",
"./x/dhkem-secp256k1",
"./x/dhkem-x25519",
"./x/dhkem-x448",
"./x/hybridkem-x25519-kyber768"
],
"exports": "./mod.ts",
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@hpke/core": "jsr:@hpke/core@^1.2.9",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
},
Expand All @@ -16,8 +23,7 @@
"deno.lock",
"mod.ts",
"mod_core.ts",
"src/",
"x/chacha20poly1305/src/"
"src/"
],
"exclude": [
"core/LICENSE",
Expand Down
16 changes: 10 additions & 6 deletions deno.lock

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

8 changes: 8 additions & 0 deletions dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ await build({
package: {
name: "hpke-js",
version: Deno.args[0],
workspaces: [
"core",
"x/chacha20poly1305",
"x/dhkem-secp256k1",
"x/dhkem-x25519",
"x/dhkem-x448",
"x/hybridkem-x25519-kyber768",
],
description:
"A Hybrid Public Key Encryption (HPKE) module for various JavaScript runtimes",
repository: {
Expand Down
1 change: 0 additions & 1 deletion import_map_for_dnt.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@hpke/core": "npm:@hpke/core@^1.2.9",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
}
Expand Down
7 changes: 1 addition & 6 deletions x/chacha20poly1305/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
"name": "@hpke/chacha20poly1305",
"version": "1.2.9",
"exports": "./mod.ts",
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@hpke/core": "jsr:@hpke/core@^1.2.9",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
},
"publish": {
"exclude": [
"dnt.ts",
"import_map.json",
"samples/",
"test/",
"tsconfig.json"
Expand Down
2 changes: 1 addition & 1 deletion x/chacha20poly1305/dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ await build({
test: true,
declaration: true,
scriptModule: "umd",
importMap: "../../import_map_for_dnt.json",
importMap: "./import_map.json",
compilerOptions: {
lib: ["ES2022", "DOM"],
},
Expand Down
8 changes: 8 additions & 0 deletions x/chacha20poly1305/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@hpke/core": "../../core/mod.ts",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
}
}
5 changes: 2 additions & 3 deletions x/chacha20poly1305/test/chacha20poly1305.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { assertEquals } from "@std/assert";
import { describe, it } from "@std/testing/bdd";

import { AeadId } from "../../../core/src/identifiers.ts";
import {
AeadId,
CipherSuite,
DhkemP256HkdfSha256,
HkdfSha256,
} from "../../../mod_core.ts";
} from "@hpke/core";

import { loadCrypto } from "../../../core/test/utils.ts";

import { Chacha20Poly1305 } from "../mod.ts";

describe("Chacha20Poly1305", () => {
Expand Down
6 changes: 1 addition & 5 deletions x/dhkem-secp256k1/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
"name": "@hpke/dhkem-secp256k1",
"version": "1.2.9",
"exports": "./mod.ts",
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
},
"publish": {
"exclude": [
"dnt.ts",
"import_map.json",
"samples/",
"test/",
"tsconfig.json"
Expand Down
6 changes: 3 additions & 3 deletions x/dhkem-secp256k1/dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ await build({
test: true,
declaration: true,
scriptModule: "umd",
importMap: "./deno.json",
importMap: "./import_map.json",
compilerOptions: {
lib: ["es2022", "dom"],
lib: ["ES2022", "DOM"],
},
shims: {
deno: "dev",
Expand Down Expand Up @@ -59,5 +59,5 @@ await build({
});

// post build steps
Deno.copyFileSync("../../LICENSE", "npm/LICENSE");
Deno.copyFileSync("LICENSE", "npm/LICENSE");
Deno.copyFileSync("README.md", "npm/README.md");
9 changes: 9 additions & 0 deletions x/dhkem-secp256k1/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@hpke/core": "../../core/mod.ts",
"@hpke/dhkem-x25519": "../dhkem-x25519/mod.ts",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
}
}
4 changes: 2 additions & 2 deletions x/dhkem-secp256k1/src/dhkemSecp256k1.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dhkem, KemId } from "../../../mod_core.ts";
import { HkdfSha256 } from "../../../x/dhkem-x25519/mod.ts";
import { Dhkem, KemId } from "@hpke/core";
import { HkdfSha256 } from "@hpke/dhkem-x25519";

import { Secp256k1 } from "./secp256k1.ts";

Expand Down
4 changes: 2 additions & 2 deletions x/dhkem-secp256k1/src/secp256k1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-ignore: for "npm:"
import { secp256k1 } from "npm:@noble/[email protected]/secp256k1";

import type { DhkemPrimitives, KdfInterface } from "../../../mod_core.ts";
import type { DhkemPrimitives, KdfInterface } from "@hpke/core";

import {
DeriveKeyPairError,
Expand All @@ -12,7 +12,7 @@ import {
NotSupportedError,
SerializeError,
XCryptoKey,
} from "../../../mod_core.ts";
} from "@hpke/core";

const ALG_NAME = "ECDH";
const EMPTY = new Uint8Array();
Expand Down
6 changes: 1 addition & 5 deletions x/dhkem-x25519/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
"name": "@hpke/dhkem-x25519",
"version": "1.2.9",
"exports": "./mod.ts",
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
},
"publish": {
"exclude": [
"dnt.ts",
"import_map.json",
"samples/",
"test/",
"tsconfig.json"
Expand Down
6 changes: 3 additions & 3 deletions x/dhkem-x25519/dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ await build({
test: true,
declaration: true,
scriptModule: "umd",
importMap: "./deno.json",
importMap: "./import_map.json",
compilerOptions: {
lib: ["es2022", "dom"],
lib: ["ES2022", "DOM"],
},
shims: {
deno: "dev",
Expand Down Expand Up @@ -59,5 +59,5 @@ await build({
});

// post build steps
Deno.copyFileSync("../../LICENSE", "npm/LICENSE");
Deno.copyFileSync("LICENSE", "npm/LICENSE");
Deno.copyFileSync("README.md", "npm/README.md");
8 changes: 8 additions & 0 deletions x/dhkem-x25519/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@hpke/core": "../../core/mod.ts",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
}
}
3 changes: 2 additions & 1 deletion x/dhkem-x25519/src/dhkemX25519.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Dhkem, KemId } from "../../../mod_core.ts";
import { Dhkem, KemId } from "@hpke/core";

import { HkdfSha256 } from "./hkdfSha256.ts";
import { X25519 } from "./x25519.ts";

Expand Down
2 changes: 1 addition & 1 deletion x/dhkem-x25519/src/hkdfSha256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { hmac } from "npm:@noble/[email protected]/hmac";
// @ts-ignore: for "npm:"
import { sha256 } from "npm:@noble/[email protected]/sha256";

import { HkdfSha256Native } from "../../../mod_core.ts";
import { HkdfSha256Native } from "@hpke/core";

export class HkdfSha256 extends HkdfSha256Native {
public override async extract(
Expand Down
4 changes: 2 additions & 2 deletions x/dhkem-x25519/src/x25519.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-ignore: for "npm:"
import { x25519 } from "npm:@noble/[email protected]/ed25519";

import type { DhkemPrimitives, KdfInterface } from "../../../mod_core.ts";
import type { DhkemPrimitives, KdfInterface } from "@hpke/core";

import {
base64UrlToBytes,
Expand All @@ -13,7 +13,7 @@ import {
NotSupportedError,
SerializeError,
XCryptoKey,
} from "../../../mod_core.ts";
} from "@hpke/core";

const ALG_NAME = "X25519";
const EMPTY = new Uint8Array();
Expand Down
3 changes: 2 additions & 1 deletion x/dhkem-x25519/test/dhkem-x25519.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
HkdfSha256,
KdfId,
KemId,
} from "../../../core/mod.ts";
} from "@hpke/core";

import { loadCrypto } from "../../../core/test/utils.ts";
import { DhkemX25519HkdfSha256 } from "../mod.ts";

Expand Down
6 changes: 1 addition & 5 deletions x/dhkem-x448/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
"name": "@hpke/dhkem-x448",
"version": "1.2.9",
"exports": "./mod.ts",
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
},
"publish": {
"exclude": [
"dnt.ts",
"import_map.json",
"samples/",
"test/",
"tsconfig.json"
Expand Down
6 changes: 3 additions & 3 deletions x/dhkem-x448/dnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ await build({
test: true,
declaration: true,
scriptModule: "umd",
importMap: "./deno.json",
importMap: "./import_map.json",
compilerOptions: {
lib: ["es2022", "dom"],
lib: ["ES2022", "DOM"],
},
shims: {
deno: "dev",
Expand Down Expand Up @@ -59,5 +59,5 @@ await build({
});

// post build steps
Deno.copyFileSync("../../LICENSE", "npm/LICENSE");
Deno.copyFileSync("LICENSE", "npm/LICENSE");
Deno.copyFileSync("README.md", "npm/README.md");
8 changes: 8 additions & 0 deletions x/dhkem-x448/import_map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"imports": {
"@deno/dnt": "jsr:@deno/dnt@^0.41.2",
"@hpke/core": "../../core/mod.ts",
"@std/assert": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^1.0.0"
}
}
2 changes: 1 addition & 1 deletion x/dhkem-x448/src/dhkemX448.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dhkem, KemId } from "../../../mod_core.ts";
import { Dhkem, KemId } from "@hpke/core";
import { HkdfSha512 } from "./hkdfSha512.ts";
import { X448 } from "./x448.ts";

Expand Down
2 changes: 1 addition & 1 deletion x/dhkem-x448/src/hkdfSha512.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { hmac } from "npm:@noble/[email protected]/hmac";
// @ts-ignore: for "npm:"
import { sha512 } from "npm:@noble/[email protected]/sha512";

import { HkdfSha512Native } from "../../../mod_core.ts";
import { HkdfSha512Native } from "@hpke/core";

export class HkdfSha512 extends HkdfSha512Native {
public override async extract(
Expand Down
Loading

0 comments on commit 02e7d05

Please sign in to comment.