@uglyunicorn/pie 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/body.txt CHANGED
@@ -1,3 +1,5 @@
1
- * Refactor CipherContext type in hpke.ts for clarity and consistency; update exports in index.ts
1
+ * Refactor EnvelopeContext type in index.ts and clean up hpke.ts exports
2
2
 
3
- * Update package version to 0.1.4 in package.json
3
+ * Update package version to 0.1.5 in package.json
4
+
5
+ * Refactor envelopeContext return type in hpke.ts to use generic CipherContext<Envelope> for improved type safety
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uglyunicorn/pie",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Schema-validated envelopes using HPKE",
5
5
  "keywords": [
6
6
  "schema",
@@ -9,7 +9,7 @@ import {
9
9
  } from "hpke";
10
10
 
11
11
  import { decodeBuffer, deserialize, encodeBuffer, serialize } from "../lib/utils";
12
- import type { CipherContext as CipherContextType, DecipherContext, RetranslateContext } from "..";
12
+ import type { CipherContext, DecipherContext, RetranslateContext } from "..";
13
13
 
14
14
  export class HpkeEnvelopeError extends Error {}
15
15
 
@@ -18,8 +18,6 @@ export interface Envelope {
18
18
  enc: string;
19
19
  }
20
20
 
21
- export type CipherContext = CipherContextType<Envelope>;
22
-
23
21
  export function createCipherSuite(): CipherSuite {
24
22
  return new CipherSuite(KEM_DHKEM_P256_HKDF_SHA256, KDF_HKDF_SHA256, AEAD_AES_128_GCM);
25
23
  }
@@ -91,7 +89,7 @@ export async function openEnvelope<T>(
91
89
  return validated.value;
92
90
  }
93
91
 
94
- export function envelopeContext(opts: { out: Pick<KeyPair, "publicKey"> }): CipherContext;
92
+ export function envelopeContext(opts: { out: Pick<KeyPair, "publicKey"> }): CipherContext<Envelope>;
95
93
 
96
94
  export function envelopeContext(opts: {
97
95
  in: Pick<KeyPair, "privateKey">;
@@ -121,7 +119,7 @@ export function envelopeContext(opts?: any) {
121
119
  if (opts?.out) {
122
120
  return {
123
121
  seal: (schema, data) => sealEnvelope(schema, data, opts.out.publicKey),
124
- } as CipherContext;
122
+ } as CipherContext<Envelope>;
125
123
  }
126
124
 
127
125
  return undefined;
@@ -1 +1,6 @@
1
- export { createCipherSuite, envelopeContext, type CipherContext, type Envelope } from "./hpke";
1
+ import type { EnvelopeContext as EnvelopeContextType } from "..";
2
+ import type { Envelope } from "./hpke";
3
+
4
+ export { createCipherSuite, envelopeContext, type Envelope } from "./hpke";
5
+
6
+ export type EnvelopeContext = EnvelopeContextType<Envelope>;