@coffre/core 0.14.2 → 0.14.4

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/dist/kek.d.ts CHANGED
@@ -84,5 +84,11 @@ export declare const KEY_CHECK_CONTEXT: SecretContext;
84
84
  export declare function opensKeyCheck(key: Buffer, check: WrappedDek): Promise<boolean>;
85
85
  /** The id the log records for entries the app signs with `key`, its APP_KEY. */
86
86
  export declare function appLogKeyId(key: Uint8Array): string;
87
+ /**
88
+ * The signing key a local vault key stands for, when the vault is given
89
+ * none: HKDF-SHA-256 of the key. The vault MACs its log entries and member
90
+ * rows with what it derives from this one (`vaultLogKey` in @coffre/vault).
91
+ */
92
+ export declare function derivedSigningKey(kek: Uint8Array): Buffer;
87
93
  //#endregion
88
94
  export { type AwsCredentials, type AwsKmsOptions, DEK_BYTES, KekBadClaimError, KekCancelledError, type KekProvider, KekRegistry, KekUnavailableError, type KeyOperation, type WrappedDek };
package/dist/kek.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { deriveLogKey } from "./audit.js";
2
2
  import { i as KekUnavailableError, n as KekBadClaimError, o as checkContext, r as KekCancelledError, s as encodeAad, t as DEK_BYTES } from "./types-Cp3lB_-W.js";
3
- import { createCipheriv, createDecipheriv, createHash, createHmac, createSecretKey, randomBytes, timingSafeEqual } from "node:crypto";
3
+ import { createCipheriv, createDecipheriv, createHash, createHmac, createSecretKey, hkdfSync, randomBytes, timingSafeEqual } from "node:crypto";
4
4
  //#region src/kek/cancellation.ts
5
5
  function checkOperation(operation, uncertain = false) {
6
6
  if (operation !== void 0 && (operation.signal.aborted || Date.now() >= operation.deadline)) throw new KekCancelledError(uncertain);
@@ -520,5 +520,15 @@ async function opensKeyCheck(key, check) {
520
520
  function appLogKeyId(key) {
521
521
  return deriveLogKey("app", key).keyId;
522
522
  }
523
+ /** The label no other use of a vault key shares: a local vault key is otherwise only ever an AES-256-GCM key. */
524
+ const SIGNING_KEY_LABEL = "coffre.vault.signing-key.v1";
525
+ /**
526
+ * The signing key a local vault key stands for, when the vault is given
527
+ * none: HKDF-SHA-256 of the key. The vault MACs its log entries and member
528
+ * rows with what it derives from this one (`vaultLogKey` in @coffre/vault).
529
+ */
530
+ function derivedSigningKey(kek) {
531
+ return Buffer.from(hkdfSync("sha256", kek, /* @__PURE__ */ new Uint8Array(0), SIGNING_KEY_LABEL, 32));
532
+ }
523
533
  //#endregion
524
- export { AwsKmsKekProvider, DEK_BYTES, KEY_CHECK, KEY_CHECK_CONTEXT, KEY_CHECK_VALUE, KekBadClaimError, KekCancelledError, KekRegistry, KekUnavailableError, LocalKekProvider, appLogKeyId, awsKms, equalBytes, opensKeyCheck };
534
+ export { AwsKmsKekProvider, DEK_BYTES, KEY_CHECK, KEY_CHECK_CONTEXT, KEY_CHECK_VALUE, KekBadClaimError, KekCancelledError, KekRegistry, KekUnavailableError, LocalKekProvider, appLogKeyId, awsKms, derivedSigningKey, equalBytes, opensKeyCheck };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/core",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "What coffre's packages share: roles, envelopes, identity, the audit chain and the vault's contract.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -83,14 +83,14 @@
83
83
  "jose": "6.2.3",
84
84
  "oauth4webapi": "3.8.8",
85
85
  "zod": "4.4.3",
86
- "@coffre/client": "0.14.2"
86
+ "@coffre/client": "0.14.4"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@hegeldev/hegel": "0.4.7",
90
90
  "@types/node": "26.1.1",
91
91
  "tsdown": "0.23.0",
92
92
  "typescript": "5.9.3",
93
- "@coffre/conformance": "0.14.2"
93
+ "@coffre/conformance": "0.14.4"
94
94
  },
95
95
  "scripts": {
96
96
  "build": "tsdown",
package/src/kek/check.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // a fingerprint of the key they are signed with. The vault writes the
5
5
  // checks; `coffre verify keys` holds an escrowed key to them, on the
6
6
  // operator's machine, the key never sent anywhere.
7
- import { createHash } from 'node:crypto';
7
+ import { createHash, hkdfSync } from 'node:crypto';
8
8
 
9
9
  import { deriveLogKey } from '../audit/chain.ts';
10
10
  import type { SecretContext } from '../context.ts';
@@ -44,3 +44,15 @@ export async function opensKeyCheck(key: Buffer, check: WrappedDek): Promise<boo
44
44
  export function appLogKeyId(key: Uint8Array): string {
45
45
  return deriveLogKey('app', key).keyId;
46
46
  }
47
+
48
+ /** The label no other use of a vault key shares: a local vault key is otherwise only ever an AES-256-GCM key. */
49
+ const SIGNING_KEY_LABEL = 'coffre.vault.signing-key.v1';
50
+
51
+ /**
52
+ * The signing key a local vault key stands for, when the vault is given
53
+ * none: HKDF-SHA-256 of the key. The vault MACs its log entries and member
54
+ * rows with what it derives from this one (`vaultLogKey` in @coffre/vault).
55
+ */
56
+ export function derivedSigningKey(kek: Uint8Array): Buffer {
57
+ return Buffer.from(hkdfSync('sha256', kek, new Uint8Array(0), SIGNING_KEY_LABEL, 32));
58
+ }
package/src/kek/index.ts CHANGED
@@ -3,5 +3,5 @@ export { DEK_BYTES, KekUnavailableError, KekCancelledError, KekBadClaimError } f
3
3
  export { LocalKekProvider, equalBytes } from './local.ts';
4
4
  export { KekRegistry } from './registry.ts';
5
5
  export { AwsKmsKekProvider, awsKms, type AwsKmsOptions } from './aws-kms.ts';
6
- export { appLogKeyId, KEY_CHECK, KEY_CHECK_CONTEXT, KEY_CHECK_VALUE, opensKeyCheck } from './check.ts';
6
+ export { appLogKeyId, derivedSigningKey, KEY_CHECK, KEY_CHECK_CONTEXT, KEY_CHECK_VALUE, opensKeyCheck } from './check.ts';
7
7
  export type { AwsCredentials } from './sigv4.ts';