Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/triple-ratchet/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.mts",
"bundledPackages": [
"@bcts/*"
],
"compiler": {
"tsconfigFilePath": "<projectFolder>/tsconfig.json"
},
"apiReport": {
"enabled": false
},
"docModel": {
"enabled": false
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/bundle.d.mts"
},
"tsdocMetadata": {
"enabled": false
},
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
},
"ae-forgotten-export": {
"logLevel": "error",
"addToApiReportFile": false
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
}
}
}
}
17 changes: 11 additions & 6 deletions packages/triple-ratchet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
},
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.mts",
"types": "dist/bundle.d.mts",
"exports": {
".": {
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.mjs"
"import": {
"types": "./dist/bundle.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"files": [
Expand All @@ -31,7 +35,7 @@
"LICENSE"
],
"scripts": {
"build": "tsdown",
"build": "tsc --noEmit -p tsconfig.build.json && tsdown && api-extractor run --local",
"test": "vitest run",
"test:watch": "vitest",
"lint": "eslint 'src/**/*.ts' 'tests/**/*.ts'",
Expand Down Expand Up @@ -64,6 +68,7 @@
"@bcts/eslint": "workspace:*",
"@bcts/tsconfig": "workspace:*",
"@eslint/js": "^10.0.1",
"@microsoft/api-extractor": "^7.52.1",
"@types/node": "^25.3.2",
"eslint": "^10.0.2",
"prettier": "^3.8.1",
Expand Down
14 changes: 2 additions & 12 deletions packages/triple-ratchet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@ export { KyberPreKeyRecord, InMemoryKyberPreKeyStore } from "./stores.js";
export type { KyberPreKeyStore, PQXDHPreKeyBundle } from "./stores.js";

// Types
export type {
AlicePQXDHParameters,
BobPQXDHParameters,
KyberKeyPair,
KyberCiphertext,
PQXDHDerivedKeys,
PQRatchetState,
PQRatchetMessage,
InitialPQRKey,
PreKeysUsed,
TripleRatchetChainParams,
} from "./types.js";
export type * from "./types.js";
export * from "@bcts/double-ratchet";

// Session cipher (encrypt/decrypt)
export { tripleRatchetEncrypt, tripleRatchetDecrypt } from "./session-cipher.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/triple-ratchet/src/session-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from "@bcts/double-ratchet";
import type { RandomNumberGenerator } from "@bcts/rand";
import * as spqr from "@bcts/spqr";
import type { ChainParams } from "@bcts/spqr";
import type { ChainParams } from "./types.js";
import { ml_kem1024 } from "@noble/post-quantum/ml-kem.js";

import {
Expand Down
4 changes: 2 additions & 2 deletions packages/triple-ratchet/src/session-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
} from "@bcts/double-ratchet";
import * as spqr from "@bcts/spqr";
import { TripleRatchetError, TripleRatchetErrorCode } from "./error.js";
import type { PQRatchetState, PQRatchetMessage } from "./types.js";
import type { PQRatchetState, PQRatchetMessage, RandomBytes } from "./types.js";

export class TripleRatchetSessionState {
private readonly inner: SessionState;
Expand All @@ -42,7 +42,7 @@ export class TripleRatchetSessionState {
* Returns the serialized SPQR message to include in the wire envelope
* and an optional 32-byte key that should be mixed into the root key.
*/
pqRatchetSend(rng: spqr.RandomBytes): { msg: PQRatchetMessage; key: Uint8Array | null } {
pqRatchetSend(rng: RandomBytes): { msg: PQRatchetMessage; key: Uint8Array | null } {
try {
const result = spqr.send(this._pqRatchetState, rng);
this._pqRatchetState = result.state;
Expand Down
6 changes: 4 additions & 2 deletions packages/triple-ratchet/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import type { KeyPair, IdentityKeyPair, IdentityKey } from "@bcts/double-ratchet";
import type { ChainParams } from "@bcts/spqr";

// Re-export SPQR types used in our public API
export type { ChainParams } from "@bcts/spqr";
export type * from "@bcts/double-ratchet";

export type { RandomBytes, ChainParams } from "@bcts/spqr";
export type { RandomNumberGenerator } from "@bcts/rand";

/** Opaque serialized SPQR state (protobuf bytes). */
export type PQRatchetState = Uint8Array;
Expand Down
10 changes: 10 additions & 0 deletions packages/triple-ratchet/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts"
],
"exclude": [
"dist",
"node_modules"
]
}