@goodtiming/baton-sdk 0.4.0 → 0.4.1
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/index.cjs +3 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -38
- package/dist/index.d.ts +13 -38
- package/dist/index.js +3 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const SDK_VERSION = "ts-0.4.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.4.1";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -666,19 +666,6 @@ declare class HttpSink implements Sink {
|
|
|
666
666
|
* generated corpus — for the same reason: one person reaching two SDKs must be one
|
|
667
667
|
* actor downstream, and nothing but a differential corpus can prove it.
|
|
668
668
|
*/
|
|
669
|
-
/** The HMAC KEY GENERATION, and nothing else.
|
|
670
|
-
*
|
|
671
|
-
* It is not a provenance marker and not a privacy classifier. Provenance is
|
|
672
|
-
* `PrincipalWire.source` and the classification is `PrincipalWire.form`, and
|
|
673
|
-
* both ride every mode — including `"raw"`, where no tag exists at all, which
|
|
674
|
-
* is the gap a tag can structurally never close. `h2:` is reserved for a key
|
|
675
|
-
* rotation. SPEC §11.4 and the §13 entry carry the full derivation.
|
|
676
|
-
*
|
|
677
|
-
* ⚠ **This value is a WIRE CONSTANT.** `test/identity.test.ts` pins it against
|
|
678
|
-
* Python's generated corpus by literal, not through this name — an assertion
|
|
679
|
-
* written as ``startsWith(`${HASH_SCHEME}:`)`` is self-referential and cannot
|
|
680
|
-
* see this constant change. */
|
|
681
|
-
declare const HASH_SCHEME = "h1";
|
|
682
669
|
/** Where a principal came from. `"asserted"` is a vendor's own resolver,
|
|
683
670
|
* which nothing in the protocol checks, and is the only value this SDK
|
|
684
671
|
* emits — `integrations/mcp/principalResolution.ts` has the why, and the
|
|
@@ -707,11 +694,9 @@ interface Principal {
|
|
|
707
694
|
*
|
|
708
695
|
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
709
696
|
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
710
|
-
* Returns
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
* `(tenantId, principal, issuer)` is identical under every scheme and only the
|
|
714
|
-
* prefix moves. What that buys is in `HASH_SCHEME`.
|
|
697
|
+
* Returns the BARE lowercase hex digest — no tag, no prefix, no scheme. It
|
|
698
|
+
* returned `"h1:<hex>"` until 0.4.1; the tag was never part of the HMAC
|
|
699
|
+
* message, so taking it off moved no digit of the digest.
|
|
715
700
|
*
|
|
716
701
|
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
717
702
|
* form** — the append-only message layout is what guarantees it, and every
|
|
@@ -721,18 +706,6 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
721
706
|
tenantId: string;
|
|
722
707
|
key: Uint8Array | string;
|
|
723
708
|
issuer?: string | null | undefined;
|
|
724
|
-
/** The key generation, defaulting to the current one exactly as Python's
|
|
725
|
-
* does. A caller passes this only to reproduce a digest under a
|
|
726
|
-
* superseded key.
|
|
727
|
-
*
|
|
728
|
-
* `| undefined` explicitly, for the same `exactOptionalPropertyTypes`
|
|
729
|
-
* reason `issuer` carries above — and it bites HARDER here, because this
|
|
730
|
-
* option exists precisely to be omittable. Without it the natural vendor
|
|
731
|
-
* shape, forwarding an optional off their own config
|
|
732
|
-
* (`scheme: cfg.scheme` where `cfg.scheme: string | undefined`), is a
|
|
733
|
-
* compile error on the published types. No in-repo caller can see that:
|
|
734
|
-
* they either omit it or pass a concrete string from the corpus. */
|
|
735
|
-
scheme?: string | undefined;
|
|
736
709
|
}): string;
|
|
737
710
|
|
|
738
711
|
/** `BatonConfig.resolvePrincipal` — the ASSERTED identity provenance.
|
|
@@ -745,12 +718,14 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
745
718
|
* **Hook only — there is deliberately no ATTESTED rung here yet**, so every
|
|
746
719
|
* principal this SDK emits carries `source: "asserted"`.
|
|
747
720
|
*
|
|
748
|
-
* ⚠ **The missing rung
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
721
|
+
* ⚠ **The missing rung has no shape on the value, and never will again.** This
|
|
722
|
+
* note said "saying `no h1: rung` would be false, because this SDK does emit
|
|
723
|
+
* `h1:`" — true until 0.4.1, when the tag came off the value entirely (SPEC
|
|
724
|
+
* §11.4, §13 entry 0.8.11). A hashed principal is now the bare digest, so there
|
|
725
|
+
* is no prefix to be right or wrong about: the missing thing is the
|
|
726
|
+
* `source: "attested"` VALUE, and a consumer reads `source` to learn it. SPEC
|
|
727
|
+
* §11.4 forbids presenting an asserted principal as verified, and this arm has
|
|
728
|
+
* only asserted to present.
|
|
754
729
|
*
|
|
755
730
|
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
756
731
|
* `AuthInfo` has no `claims` field at all (it is
|
|
@@ -1064,4 +1039,4 @@ interface SupportedMcpServer {
|
|
|
1064
1039
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
1065
1040
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
1066
1041
|
|
|
1067
|
-
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema,
|
|
1042
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, PRINCIPAL_FORM_HASHED, PRINCIPAL_FORM_RAW, PRINCIPAL_SOURCE_ASSERTED, type Principal, type PrincipalIdMode, type PrincipalResolutionContext, PrincipalWireSchema, type ResolvePrincipalHook, SDK_VERSION, Scrubber, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema, hashPrincipalId, identityScrub, safeWrite, withBaton };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
declare const SDK_VERSION = "ts-0.4.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.4.1";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -666,19 +666,6 @@ declare class HttpSink implements Sink {
|
|
|
666
666
|
* generated corpus — for the same reason: one person reaching two SDKs must be one
|
|
667
667
|
* actor downstream, and nothing but a differential corpus can prove it.
|
|
668
668
|
*/
|
|
669
|
-
/** The HMAC KEY GENERATION, and nothing else.
|
|
670
|
-
*
|
|
671
|
-
* It is not a provenance marker and not a privacy classifier. Provenance is
|
|
672
|
-
* `PrincipalWire.source` and the classification is `PrincipalWire.form`, and
|
|
673
|
-
* both ride every mode — including `"raw"`, where no tag exists at all, which
|
|
674
|
-
* is the gap a tag can structurally never close. `h2:` is reserved for a key
|
|
675
|
-
* rotation. SPEC §11.4 and the §13 entry carry the full derivation.
|
|
676
|
-
*
|
|
677
|
-
* ⚠ **This value is a WIRE CONSTANT.** `test/identity.test.ts` pins it against
|
|
678
|
-
* Python's generated corpus by literal, not through this name — an assertion
|
|
679
|
-
* written as ``startsWith(`${HASH_SCHEME}:`)`` is self-referential and cannot
|
|
680
|
-
* see this constant change. */
|
|
681
|
-
declare const HASH_SCHEME = "h1";
|
|
682
669
|
/** Where a principal came from. `"asserted"` is a vendor's own resolver,
|
|
683
670
|
* which nothing in the protocol checks, and is the only value this SDK
|
|
684
671
|
* emits — `integrations/mcp/principalResolution.ts` has the why, and the
|
|
@@ -707,11 +694,9 @@ interface Principal {
|
|
|
707
694
|
*
|
|
708
695
|
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
709
696
|
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
710
|
-
* Returns
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
* `(tenantId, principal, issuer)` is identical under every scheme and only the
|
|
714
|
-
* prefix moves. What that buys is in `HASH_SCHEME`.
|
|
697
|
+
* Returns the BARE lowercase hex digest — no tag, no prefix, no scheme. It
|
|
698
|
+
* returned `"h1:<hex>"` until 0.4.1; the tag was never part of the HMAC
|
|
699
|
+
* message, so taking it off moved no digit of the digest.
|
|
715
700
|
*
|
|
716
701
|
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
717
702
|
* form** — the append-only message layout is what guarantees it, and every
|
|
@@ -721,18 +706,6 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
721
706
|
tenantId: string;
|
|
722
707
|
key: Uint8Array | string;
|
|
723
708
|
issuer?: string | null | undefined;
|
|
724
|
-
/** The key generation, defaulting to the current one exactly as Python's
|
|
725
|
-
* does. A caller passes this only to reproduce a digest under a
|
|
726
|
-
* superseded key.
|
|
727
|
-
*
|
|
728
|
-
* `| undefined` explicitly, for the same `exactOptionalPropertyTypes`
|
|
729
|
-
* reason `issuer` carries above — and it bites HARDER here, because this
|
|
730
|
-
* option exists precisely to be omittable. Without it the natural vendor
|
|
731
|
-
* shape, forwarding an optional off their own config
|
|
732
|
-
* (`scheme: cfg.scheme` where `cfg.scheme: string | undefined`), is a
|
|
733
|
-
* compile error on the published types. No in-repo caller can see that:
|
|
734
|
-
* they either omit it or pass a concrete string from the corpus. */
|
|
735
|
-
scheme?: string | undefined;
|
|
736
709
|
}): string;
|
|
737
710
|
|
|
738
711
|
/** `BatonConfig.resolvePrincipal` — the ASSERTED identity provenance.
|
|
@@ -745,12 +718,14 @@ declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
|
745
718
|
* **Hook only — there is deliberately no ATTESTED rung here yet**, so every
|
|
746
719
|
* principal this SDK emits carries `source: "asserted"`.
|
|
747
720
|
*
|
|
748
|
-
* ⚠ **The missing rung
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
721
|
+
* ⚠ **The missing rung has no shape on the value, and never will again.** This
|
|
722
|
+
* note said "saying `no h1: rung` would be false, because this SDK does emit
|
|
723
|
+
* `h1:`" — true until 0.4.1, when the tag came off the value entirely (SPEC
|
|
724
|
+
* §11.4, §13 entry 0.8.11). A hashed principal is now the bare digest, so there
|
|
725
|
+
* is no prefix to be right or wrong about: the missing thing is the
|
|
726
|
+
* `source: "attested"` VALUE, and a consumer reads `source` to learn it. SPEC
|
|
727
|
+
* §11.4 forbids presenting an asserted principal as verified, and this arm has
|
|
728
|
+
* only asserted to present.
|
|
754
729
|
*
|
|
755
730
|
* Python reads `claims["sub"]` off a verified access token; TypeScript's
|
|
756
731
|
* `AuthInfo` has no `claims` field at all (it is
|
|
@@ -1064,4 +1039,4 @@ interface SupportedMcpServer {
|
|
|
1064
1039
|
/** Install Baton into an `McpServer`. See module docstring for usage. */
|
|
1065
1040
|
declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig): BatonHandle;
|
|
1066
1041
|
|
|
1067
|
-
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema,
|
|
1042
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type BatonConfig, BatonHandle, DEFAULT_CONSENT_TOKEN, DEPTH_LIMIT, type Event, EventSchema, type EventType, EventTypeSchema, HttpSink, type HttpSinkOptions, PRINCIPAL_FORM_HASHED, PRINCIPAL_FORM_RAW, PRINCIPAL_SOURCE_ASSERTED, type Principal, type PrincipalIdMode, type PrincipalResolutionContext, PrincipalWireSchema, type ResolvePrincipalHook, SDK_VERSION, Scrubber, type Sink, StdoutSink, type StdoutSinkOptions, type SupportedMcpServer, type SurfaceSnapshotEvent, SurfaceSnapshotEventSchema, type SurfaceSnapshotPayload, SurfaceSnapshotPayloadSchema, type ToolCallEndEvent, ToolCallEndEventSchema, type ToolCallEndPayload, ToolCallEndPayloadSchema, type ToolCallErrorEvent, ToolCallErrorEventSchema, type ToolCallErrorPayload, ToolCallErrorPayloadSchema, type ToolCallStartEvent, ToolCallStartEventSchema, type ToolCallStartPayload, ToolCallStartPayloadSchema, hashPrincipalId, identityScrub, safeWrite, withBaton };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "ts-0.4.
|
|
2
|
+
var SDK_VERSION = "ts-0.4.1";
|
|
3
3
|
|
|
4
4
|
// src/events.ts
|
|
5
5
|
import { z } from "zod";
|
|
@@ -470,7 +470,6 @@ function capCodePoints(value, max) {
|
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
// src/identity.ts
|
|
473
|
-
var HASH_SCHEME = "h1";
|
|
474
473
|
var PRINCIPAL_SOURCE_ASSERTED = "asserted";
|
|
475
474
|
var PRINCIPAL_FORM_HASHED = "hashed";
|
|
476
475
|
var PRINCIPAL_FORM_RAW = "raw";
|
|
@@ -494,14 +493,13 @@ function pythonStrip(value) {
|
|
|
494
493
|
return value.replace(PYTHON_STRIP, "");
|
|
495
494
|
}
|
|
496
495
|
function hashPrincipalId(rawPrincipal, options) {
|
|
497
|
-
const { tenantId, key, issuer = null
|
|
496
|
+
const { tenantId, key, issuer = null } = options;
|
|
498
497
|
let message = `${tenantId}\0${canonicalize(rawPrincipal)}`;
|
|
499
498
|
if (issuer !== null) {
|
|
500
499
|
message += `\0${canonicalize(issuer)}`;
|
|
501
500
|
}
|
|
502
501
|
const keyBytes = typeof key === "string" ? Buffer.from(key, "utf8") : key;
|
|
503
|
-
|
|
504
|
-
return `${scheme}:${digest}`;
|
|
502
|
+
return createHmac("sha256", keyBytes).update(message, "utf8").digest("hex");
|
|
505
503
|
}
|
|
506
504
|
function normalizePrincipal(result) {
|
|
507
505
|
if (result === null || typeof result !== "object") return null;
|
|
@@ -2114,7 +2112,6 @@ export {
|
|
|
2114
2112
|
DEPTH_LIMIT,
|
|
2115
2113
|
EventSchema,
|
|
2116
2114
|
EventTypeSchema,
|
|
2117
|
-
HASH_SCHEME,
|
|
2118
2115
|
HttpSink,
|
|
2119
2116
|
PRINCIPAL_FORM_HASHED,
|
|
2120
2117
|
PRINCIPAL_FORM_RAW,
|