@byok-sdk/core 0.22.0 → 0.23.0

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/errors.d.ts CHANGED
@@ -37,6 +37,10 @@ export declare const CORE_ERROR_CODES: {
37
37
  readonly proof_envelope_invalid: 'proof_envelope_invalid';
38
38
  readonly proof_canonicalization_failed: 'proof_canonicalization_failed';
39
39
  readonly assertion_envelope_invalid: 'assertion_envelope_invalid';
40
+ readonly webcrypto_unavailable: 'webcrypto_unavailable';
41
+ readonly sealed_secret_invalid: 'sealed_secret_invalid';
42
+ readonly sealed_secret_open_failed: 'sealed_secret_open_failed';
43
+ readonly provider_provisioning_request_invalid: 'provider_provisioning_request_invalid';
40
44
  readonly mailbox_message_not_found: 'mailbox_message_not_found';
41
45
  readonly mailbox_cursor_regression: 'mailbox_cursor_regression';
42
46
  readonly mailbox_cursor_ahead_of_delivery: 'mailbox_cursor_ahead_of_delivery';
package/dist/hpke.d.ts ADDED
@@ -0,0 +1,58 @@
1
+ import { type WebCryptoKey } from './webcrypto';
2
+ /** Encoded P-256 public key and encapsulation length (uncompressed SEC1). */
3
+ export declare const HPKE_P256_PUBLIC_KEY_BYTES = 65;
4
+ /** AES-GCM authentication tag length. */
5
+ export declare const HPKE_AEAD_TAG_BYTES = 16;
6
+ type Bytes = Uint8Array<ArrayBuffer>;
7
+ /**
8
+ * Import an uncompressed SEC1 P-256 public key for ECDH.
9
+ *
10
+ * The length and `0x04` prefix are checked here; the on-curve check is the
11
+ * WebCrypto import itself, which rejects a point that is not on P-256.
12
+ */
13
+ export declare function importP256PublicKey(raw: Uint8Array): Promise<WebCryptoKey>;
14
+ /** Key schedule output for base mode. Exported for the RFC 9180 conformance tests only. */
15
+ export interface HpkeBaseKeySchedule {
16
+ readonly sharedSecret: Uint8Array;
17
+ readonly key: Uint8Array;
18
+ readonly baseNonce: Uint8Array;
19
+ readonly exporterSecret: Uint8Array;
20
+ }
21
+ /** A caller-fixed ephemeral key pair. Conformance tests only; production always generates one. */
22
+ export interface HpkeEphemeralKeyPair {
23
+ readonly privateKey: WebCryptoKey;
24
+ readonly publicKey: Uint8Array;
25
+ }
26
+ /** `SetupBaseS`. Exported for the RFC 9180 conformance tests only. */
27
+ export declare function setupBaseSender(recipientPublicKey: Uint8Array, info: Uint8Array, ephemeral?: HpkeEphemeralKeyPair): Promise<{
28
+ enc: Uint8Array;
29
+ schedule: HpkeBaseKeySchedule;
30
+ }>;
31
+ /** `SetupBaseR`. Exported for the RFC 9180 conformance tests only. */
32
+ export declare function setupBaseRecipient(enc: Uint8Array, recipientPrivateKey: WebCryptoKey, recipientPublicKey: Uint8Array, info: Uint8Array): Promise<HpkeBaseKeySchedule>;
33
+ /** `ComputeNonce(seq)`. Exported for the RFC 9180 conformance tests only. */
34
+ export declare function hpkeNonce(baseNonce: Uint8Array, sequence: number): Bytes;
35
+ /** AEAD seal at an explicit sequence number. Exported for the RFC 9180 conformance tests only. */
36
+ export declare function hpkeAeadSeal(schedule: HpkeBaseKeySchedule, sequence: number, aad: Uint8Array, plaintext: Uint8Array): Promise<Bytes>;
37
+ /** AEAD open at an explicit sequence number. Exported for the RFC 9180 conformance tests only. */
38
+ export declare function hpkeAeadOpen(schedule: HpkeBaseKeySchedule, sequence: number, aad: Uint8Array, ciphertext: Uint8Array): Promise<Bytes>;
39
+ /** One-shot `SealBase`: a fresh ephemeral key, sequence 0, never reused. */
40
+ export declare function hpkeSealBase(input: {
41
+ readonly recipientPublicKey: Uint8Array;
42
+ readonly info: Uint8Array;
43
+ readonly aad: Uint8Array;
44
+ readonly plaintext: Uint8Array;
45
+ }): Promise<{
46
+ enc: Uint8Array;
47
+ ciphertext: Uint8Array;
48
+ }>;
49
+ /** One-shot `OpenBase`, sequence 0. */
50
+ export declare function hpkeOpenBase(input: {
51
+ readonly recipientPrivateKey: WebCryptoKey;
52
+ readonly recipientPublicKey: Uint8Array;
53
+ readonly enc: Uint8Array;
54
+ readonly info: Uint8Array;
55
+ readonly aad: Uint8Array;
56
+ readonly ciphertext: Uint8Array;
57
+ }): Promise<Uint8Array>;
58
+ export {};
package/dist/index.d.ts CHANGED
@@ -2,7 +2,9 @@
2
2
  * `@byok-sdk/core` — platform contracts.
3
3
  *
4
4
  * What this package exports is deliberately narrow: contracts, schemas, errors,
5
- * and one in-memory reference implementation. No HTTP, no crypto, no SQL, no
5
+ * one in-memory reference implementation, and the sealed provider-secret byte
6
+ * authority (one-shot HPKE over WebCrypto only — the browser and the device
7
+ * must run the same code). No HTTP, no node crypto, no SQL, no
6
8
  * `@byok-sdk/protocol` (that edge would make a future `keys → core` dependency drag
7
9
  * the wire protocol along with it, §12.1), and no `node:` import (a Workers
8
10
  * composition has to be able to load this).
@@ -41,6 +43,8 @@ export type { DeviceProofAlgorithm, DeviceProofEnvelopeV1, DeviceProofProtectedC
41
43
  export { authenticateDeviceAssertion, DEVICE_ASSERTION_ALGORITHMS, DEVICE_ASSERTION_AUDIENCE_MAX_BYTES, DEVICE_ASSERTION_DEFAULT_TTL_MS, DEVICE_ASSERTION_DOMAIN_PREFIX, DEVICE_ASSERTION_MAX_TTL_MS, DEVICE_ASSERTION_SCHEMA_ID, DEVICE_ASSERTION_VERSION, DeviceAssertionClaimsSchema, DeviceAssertionEnvelopeV1Schema, deviceAssertionCanonicalClaims, deviceAssertionCanonicalJson, deviceAssertionSigningInput, parseDeviceAssertionEnvelope, verifyDeviceAssertion, } from './device-assertion';
42
44
  export { authenticateTaskAssertion, TASK_ASSERTION_AGENT_REF_MAX_BYTES, TASK_ASSERTION_DOMAIN_PREFIX, TASK_ASSERTION_SCHEMA_ID, TASK_ASSERTION_TOOLSET_ID_MAX_LENGTH, TASK_ASSERTION_VERSION, TaskAssertionAgentRefSchema, TaskAssertionClaimsSchema, TaskAssertionEnvelopeV1Schema, parseTaskAssertionEnvelope, taskAssertionCanonicalClaims, taskAssertionCanonicalJson, taskAssertionSigningInput, verifyTaskAssertion, } from './device-assertion';
43
45
  export type { AuthenticateDeviceAssertionDeps, AuthenticatedAssertion, AuthenticatedDeviceAssertion, AuthenticatedTaskAssertion, DeviceAssertionAlgorithm, DeviceAssertionAuthorityRow, DeviceAssertionClaims, DeviceAssertionDeviceRow, DeviceAssertionEnvelopeV1, DeviceAssertionExpectedBinding, DeviceAssertionReplayConsumeInput, DeviceAssertionReplayAuthority, DeviceAssertionReplaySchemaId, DeviceAssertionVerifier, DeviceAssertionVerifyDeps, DeviceAssertionVerifyInput, TaskAssertionAgentRef, TaskAssertionClaims, TaskAssertionEnvelopeV1, } from './device-assertion';
46
+ export { PROVIDER_PROVISIONING_MAX_TTL_MS, PROVIDER_PROVISIONING_OPERATIONS, PROVIDER_PROVISIONING_REQUEST_VERSION, PROVIDER_PROVISIONING_SECRET_OPERATIONS, PROVIDER_SECRET_HPKE_INFO, PROVIDER_SECRET_HPKE_SUITE, PROVIDER_SECRET_MAX_BYTES, PROVIDER_SECRET_MAX_PADDED_BYTES, PROVIDER_SECRET_PAD_BLOCK_BYTES, ProviderProvisioningConfigV1Schema, ProviderProvisioningExpectedProfileSchema, ProviderProvisioningHeaderV1Schema, ProviderProvisioningIdentityRevisionSchema, ProviderProvisioningRequestV1Schema, SEALING_KEY_ID_LENGTH, SealedProviderSecretV1Schema, SealingKeyClaimV1Schema, SealingKeyIdSchema, SealingPublicJwkSchema, assertProviderProvisioningConfigDigest, deriveSealingKeyId, openProviderProvisioningSecret, parseProviderProvisioningRequest, providerProvisioningConfigDigest, providerProvisioningRequestDigest, providerSecretAadBytes, sealProviderProvisioningRequest, sealingKeyClaimCanonicalBytes, } from './sealed-provider-secret';
47
+ export type { ProviderProvisioningConfigV1, ProviderProvisioningExpectedProfile, ProviderProvisioningHeaderV1, ProviderProvisioningOperation, ProviderProvisioningRequestV1, ProviderSecretRecipient, SealProviderProvisioningRequestInput, SealedProviderSecretV1, SealingKeyClaimV1, SealingPublicJwk, WebCryptoKey, } from './sealed-provider-secret';
44
48
  export { NONCE_SIGNING_DOMAIN, nonceSigningBytes } from './pairing';
45
49
  export { IN_MEMORY_CLOCK_EPOCH, InMemoryBoardStore, InMemoryMailboxStore, InMemoryDeviceAssertionReplayAuthority, InMemoryObjectStore, InMemoryPresenceStore, InMemoryQuotaStore, InMemorySkillPackStore, InMemoryTruthStore, createInMemoryCoreStores, createInMemoryCoreCompositionWithClock, createMutableClock, } from './in-memory/index';
46
50
  export type { InMemoryCoreComposition, InMemoryCoreOptions } from './in-memory/index';