@goodtiming/baton-sdk 0.5.1 → 0.5.2
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/README.md +2 -2
- package/dist/index.cjs +53 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -86
- package/dist/index.d.ts +39 -86
- package/dist/index.js +51 -116
- 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.5.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.5.2";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -1407,24 +1407,15 @@ declare class HttpSink implements Sink {
|
|
|
1407
1407
|
private sendWithRetry;
|
|
1408
1408
|
}
|
|
1409
1409
|
|
|
1410
|
-
/** Principal identity —
|
|
1410
|
+
/** Principal identity — what a vendor's resolver hands back, and how it goes
|
|
1411
|
+
* on the wire.
|
|
1411
1412
|
*
|
|
1412
1413
|
* The TypeScript half of Python's `baton/identity.py`. Baton attaches the
|
|
1413
1414
|
* resolved principal to every event so the Console can group by
|
|
1414
1415
|
* `(tenant_id, vendor_id, principal.id)`, at whatever grain the vendor
|
|
1415
|
-
* resolved (SPEC §11.4).
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1418
|
-
* the HASH — raw identity must never leave the capture edge. So hashing
|
|
1419
|
-
* happens HERE, before an event reaches any console-bound sink.
|
|
1420
|
-
*
|
|
1421
|
-
* ⚠ **This file and Python's must produce byte-identical digests**, and that
|
|
1422
|
-
* is asserted rather than believed: `test/identity.test.ts` runs a corpus
|
|
1423
|
-
* GENERATED from Python (`test/identityVectors.json`, regenerated by
|
|
1424
|
-
* `scripts/gen_identity_vectors.py`) and compares strings. Same discipline as
|
|
1425
|
-
* `scrub.ts` — though NOT its method, which was a hand-mirrored matrix, not a
|
|
1426
|
-
* generated corpus — for the same reason: one person reaching two SDKs must be one
|
|
1427
|
-
* actor downstream, and nothing but a differential corpus can prove it.
|
|
1416
|
+
* resolved (SPEC §11.4). The resolver decides everything about the value: who
|
|
1417
|
+
* it names, whether it is hashed, what a page shows for it. The SDK sends it
|
|
1418
|
+
* on as stated.
|
|
1428
1419
|
*/
|
|
1429
1420
|
/** Where a principal came from. `"asserted"` is a vendor's own resolver,
|
|
1430
1421
|
* which nothing in the protocol checks, and is the only value this SDK
|
|
@@ -1435,44 +1426,25 @@ declare const PRINCIPAL_SOURCE_ASSERTED = "asserted";
|
|
|
1435
1426
|
* SPEC §11.4 lets a consumer classify on. */
|
|
1436
1427
|
declare const PRINCIPAL_FORM_HASHED = "hashed";
|
|
1437
1428
|
declare const PRINCIPAL_FORM_RAW = "raw";
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
1441
|
-
/** A raw, UNHASHED principal, as a resolver produced it. */
|
|
1429
|
+
type PrincipalForm = typeof PRINCIPAL_FORM_HASHED | typeof PRINCIPAL_FORM_RAW;
|
|
1430
|
+
/** A principal as a vendor's resolver produced it. */
|
|
1442
1431
|
interface Principal {
|
|
1443
|
-
/**
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1432
|
+
/** A stable identifier from the vendor's own system. Never an application
|
|
1433
|
+
* id: that names the app and is identical for every one of its users, which
|
|
1434
|
+
* merges them into one actor. */
|
|
1446
1435
|
principalId: string;
|
|
1447
|
-
/**
|
|
1448
|
-
* the
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1451
|
-
|
|
1436
|
+
/** What `principalId` is: `"raw"`, a real identity, or `"hashed"`, a
|
|
1437
|
+
* pseudonym the resolver derived itself. A consumer treats anything not
|
|
1438
|
+
* `"hashed"` as personal data, so leave it unset unless the resolver hashed
|
|
1439
|
+
* the value. */
|
|
1440
|
+
form?: PrincipalForm | undefined;
|
|
1452
1441
|
/** What a page shows for this principal — `principalFromOAuthEmail` puts
|
|
1453
|
-
* the part of the address before the last `@` here.
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1442
|
+
* the part of the address before the last `@` here. Sent verbatim and never
|
|
1443
|
+
* through the scrubber (SPEC §11.4): the vendor chooses what is safe to
|
|
1444
|
+
* show, and it is personal data whatever `form` says. An unusable value is
|
|
1456
1445
|
* dropped alone — see `wireDisplayName`. */
|
|
1457
1446
|
displayName?: string | null | undefined;
|
|
1458
1447
|
}
|
|
1459
|
-
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal.id`.
|
|
1460
|
-
*
|
|
1461
|
-
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
1462
|
-
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
1463
|
-
* Returns the BARE lowercase hex digest — no tag, no prefix, no scheme. It
|
|
1464
|
-
* returned `"h1:<hex>"` until 0.4.1; the tag was never part of the HMAC
|
|
1465
|
-
* message, so taking it off moved no digit of the digest.
|
|
1466
|
-
*
|
|
1467
|
-
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
1468
|
-
* form** — the append-only message layout is what guarantees it, and every
|
|
1469
|
-
* hash baton-proxy and baton-extmcp have produced since 0.5.0 was issuer-less.
|
|
1470
|
-
*/
|
|
1471
|
-
declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
1472
|
-
tenantId: string;
|
|
1473
|
-
key: Uint8Array | string;
|
|
1474
|
-
issuer?: string | null | undefined;
|
|
1475
|
-
}): string;
|
|
1476
1448
|
|
|
1477
1449
|
/** A validated access token, as both majors declare it
|
|
1478
1450
|
* (`@modelcontextprotocol/sdk` 1.x `server/auth/types.d.ts`,
|
|
@@ -1493,15 +1465,13 @@ interface AuthInfo {
|
|
|
1493
1465
|
|
|
1494
1466
|
/** `BatonConfig.resolvePrincipal` — the ONLY identity provenance (SPEC §11.4).
|
|
1495
1467
|
*
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
1498
|
-
* SDK emits is `source: "asserted"`. The hook's context carries
|
|
1499
|
-
* `authInfo`, and `oauthHooks.ts` ships the two ready-made
|
|
1468
|
+
* The producer never reads the token itself and never derives the value: who
|
|
1469
|
+
* the person is, and whether the id is hashed, are the hook's to state. Every
|
|
1470
|
+
* principal this SDK emits is `source: "asserted"`. The hook's context carries
|
|
1471
|
+
* the validated `authInfo`, and `oauthHooks.ts` ships the two ready-made
|
|
1472
|
+
* OAuth hooks.
|
|
1500
1473
|
*
|
|
1501
|
-
* The TypeScript half of Python's `integrations/identity_adapter.py
|
|
1502
|
-
* close register D6: the field (`user_id` until 0.3.5) had been on this SDK's
|
|
1503
|
-
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
1504
|
-
* works on one of two SDKs is not a partition.
|
|
1474
|
+
* The TypeScript half of Python's `integrations/identity_adapter.py`.
|
|
1505
1475
|
*/
|
|
1506
1476
|
|
|
1507
1477
|
/** What a vendor's `resolvePrincipal` hook is handed.
|
|
@@ -1548,10 +1518,8 @@ type ResolvePrincipalHook = (context: PrincipalResolutionContext) => Principal |
|
|
|
1548
1518
|
/** The registered values of `resultCaptureMode` (SPEC §11.4), and the single
|
|
1549
1519
|
* source of truth for them.
|
|
1550
1520
|
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
* happen to agree", which is the prose-shaped binding that pattern exists to
|
|
1554
|
-
* replace. `config.ts` builds its validator set from THIS array rather than
|
|
1521
|
+
* A second hand-written list would make the guarantee "two lists happen to
|
|
1522
|
+
* agree". `config.ts` builds its validator set from THIS array rather than
|
|
1555
1523
|
* restating the literals, so a mode cannot be accepted at the door without
|
|
1556
1524
|
* someone having given it a payload shape below. */
|
|
1557
1525
|
declare const RESULT_CAPTURE_MODES: readonly ["full", "off"];
|
|
@@ -1710,23 +1678,13 @@ interface BatonConfig {
|
|
|
1710
1678
|
*
|
|
1711
1679
|
* Never fails a tool call: a hook that throws or returns junk yields an
|
|
1712
1680
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
1713
|
-
* stalls its own request.
|
|
1714
|
-
resolvePrincipal?: ResolvePrincipalHook;
|
|
1715
|
-
/** `"hashed"` (default) emits a per-tenant HMAC pseudonym and
|
|
1716
|
-
* `form: "hashed"`; `"raw"` emits the subject VERBATIM and `form: "raw"`.
|
|
1717
|
-
*
|
|
1718
|
-
* `"raw"` puts real identity in the collector's database and is the vendor's
|
|
1719
|
-
* deliberate choice. ⚠ A consumer classifies on `form`, never on this
|
|
1720
|
-
* setting — `PrincipalWireSchema` carries the rule and why it is stated that
|
|
1721
|
-
* way round. */
|
|
1722
|
-
principalIdMode?: PrincipalIdMode;
|
|
1723
|
-
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
1724
|
-
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
1681
|
+
* stalls its own request.
|
|
1725
1682
|
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
|
|
1683
|
+
* The SDK sends what the hook returns and does nothing else to it: the id
|
|
1684
|
+
* as given, `form` to say whether the hook hashed it, and `displayName` for
|
|
1685
|
+
* what a page shows. A vendor who must not send real identities hashes
|
|
1686
|
+
* inside the hook and returns `form: "hashed"`. */
|
|
1687
|
+
resolvePrincipal?: ResolvePrincipalHook;
|
|
1730
1688
|
}
|
|
1731
1689
|
|
|
1732
1690
|
/**
|
|
@@ -1887,20 +1845,15 @@ declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig):
|
|
|
1887
1845
|
* hooks return `null` there.
|
|
1888
1846
|
*/
|
|
1889
1847
|
|
|
1890
|
-
/** The token's `sub
|
|
1891
|
-
*
|
|
1848
|
+
/** The token's `sub`. A subject is unique only per issuer: a vendor running
|
|
1849
|
+
* two identity providers writes a hook that combines it with `iss`. */
|
|
1892
1850
|
declare function principalFromOAuthSub(context: PrincipalResolutionContext): Principal | null;
|
|
1893
|
-
/** The token's `email`, as the WHOLE address
|
|
1851
|
+
/** The token's `email`, as the WHOLE address.
|
|
1894
1852
|
*
|
|
1895
1853
|
* `principalId` is the whole address and `displayName` the part before the
|
|
1896
1854
|
* last `@`. The local part alone is not an id — `alice@acme.com` and
|
|
1897
|
-
* `alice@contoso.com` are two people.
|
|
1898
|
-
*
|
|
1899
|
-
* own hook.
|
|
1900
|
-
*
|
|
1901
|
-
* No issuer, unlike the `sub` hook: a subject is unique only per issuer, an
|
|
1902
|
-
* address on its own, and folding `iss` in would give one person a new
|
|
1903
|
-
* pseudonym the day their identity provider changes its issuer URL.
|
|
1855
|
+
* `alice@contoso.com` are two people. A vendor who does not want `alice` on
|
|
1856
|
+
* the wire writes their own hook.
|
|
1904
1857
|
*
|
|
1905
1858
|
* ⚠ `email` is not a standard ACCESS-token claim (OIDC puts it in the ID
|
|
1906
1859
|
* token), so it is here only if the identity provider adds it and the verifier
|
|
@@ -1908,4 +1861,4 @@ declare function principalFromOAuthSub(context: PrincipalResolutionContext): Pri
|
|
|
1908
1861
|
* good enough is the vendor's call. */
|
|
1909
1862
|
declare function principalFromOAuthEmail(context: PrincipalResolutionContext): Principal | null;
|
|
1910
1863
|
|
|
1911
|
-
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type AuthInfo, 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
|
|
1864
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type AuthInfo, 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 PrincipalForm, type PrincipalResolutionContext, PrincipalWireSchema, type PromptGetEndEvent, PromptGetEndEventSchema, type PromptGetEndPayload, PromptGetEndPayloadSchema, type PromptGetErrorEvent, PromptGetErrorEventSchema, type PromptGetErrorPayload, PromptGetErrorPayloadSchema, type PromptGetStartEvent, PromptGetStartEventSchema, type PromptGetStartPayload, PromptGetStartPayloadSchema, type PromptListEndEvent, PromptListEndEventSchema, type PromptListEndPayload, PromptListEndPayloadSchema, type PromptListErrorEvent, PromptListErrorEventSchema, type PromptListErrorPayload, PromptListErrorPayloadSchema, type PromptListStartEvent, PromptListStartEventSchema, type PromptListStartPayload, PromptListStartPayloadSchema, type ResolvePrincipalHook, type ResourceListEndEvent, ResourceListEndEventSchema, type ResourceListEndPayload, ResourceListEndPayloadSchema, type ResourceListErrorEvent, ResourceListErrorEventSchema, type ResourceListErrorPayload, ResourceListErrorPayloadSchema, type ResourceListStartEvent, ResourceListStartEventSchema, type ResourceListStartPayload, ResourceListStartPayloadSchema, type ResourceReadEndEvent, ResourceReadEndEventSchema, type ResourceReadEndPayload, ResourceReadEndPayloadSchema, type ResourceReadErrorEvent, ResourceReadErrorEventSchema, type ResourceReadErrorPayload, ResourceReadErrorPayloadSchema, type ResourceReadStartEvent, ResourceReadStartEventSchema, type ResourceReadStartPayload, ResourceReadStartPayloadSchema, type ResultCaptureMode, 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, identityScrub, principalFromOAuthEmail, principalFromOAuthSub, 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.5.
|
|
3
|
+
declare const SDK_VERSION = "ts-0.5.2";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Zod schemas + TS types for the Baton event stream per SPEC §11.4.
|
|
@@ -1407,24 +1407,15 @@ declare class HttpSink implements Sink {
|
|
|
1407
1407
|
private sendWithRetry;
|
|
1408
1408
|
}
|
|
1409
1409
|
|
|
1410
|
-
/** Principal identity —
|
|
1410
|
+
/** Principal identity — what a vendor's resolver hands back, and how it goes
|
|
1411
|
+
* on the wire.
|
|
1411
1412
|
*
|
|
1412
1413
|
* The TypeScript half of Python's `baton/identity.py`. Baton attaches the
|
|
1413
1414
|
* resolved principal to every event so the Console can group by
|
|
1414
1415
|
* `(tenant_id, vendor_id, principal.id)`, at whatever grain the vendor
|
|
1415
|
-
* resolved (SPEC §11.4).
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1418
|
-
* the HASH — raw identity must never leave the capture edge. So hashing
|
|
1419
|
-
* happens HERE, before an event reaches any console-bound sink.
|
|
1420
|
-
*
|
|
1421
|
-
* ⚠ **This file and Python's must produce byte-identical digests**, and that
|
|
1422
|
-
* is asserted rather than believed: `test/identity.test.ts` runs a corpus
|
|
1423
|
-
* GENERATED from Python (`test/identityVectors.json`, regenerated by
|
|
1424
|
-
* `scripts/gen_identity_vectors.py`) and compares strings. Same discipline as
|
|
1425
|
-
* `scrub.ts` — though NOT its method, which was a hand-mirrored matrix, not a
|
|
1426
|
-
* generated corpus — for the same reason: one person reaching two SDKs must be one
|
|
1427
|
-
* actor downstream, and nothing but a differential corpus can prove it.
|
|
1416
|
+
* resolved (SPEC §11.4). The resolver decides everything about the value: who
|
|
1417
|
+
* it names, whether it is hashed, what a page shows for it. The SDK sends it
|
|
1418
|
+
* on as stated.
|
|
1428
1419
|
*/
|
|
1429
1420
|
/** Where a principal came from. `"asserted"` is a vendor's own resolver,
|
|
1430
1421
|
* which nothing in the protocol checks, and is the only value this SDK
|
|
@@ -1435,44 +1426,25 @@ declare const PRINCIPAL_SOURCE_ASSERTED = "asserted";
|
|
|
1435
1426
|
* SPEC §11.4 lets a consumer classify on. */
|
|
1436
1427
|
declare const PRINCIPAL_FORM_HASHED = "hashed";
|
|
1437
1428
|
declare const PRINCIPAL_FORM_RAW = "raw";
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
type PrincipalIdMode = typeof PRINCIPAL_ID_MODE_HASHED | typeof PRINCIPAL_ID_MODE_RAW;
|
|
1441
|
-
/** A raw, UNHASHED principal, as a resolver produced it. */
|
|
1429
|
+
type PrincipalForm = typeof PRINCIPAL_FORM_HASHED | typeof PRINCIPAL_FORM_RAW;
|
|
1430
|
+
/** A principal as a vendor's resolver produced it. */
|
|
1442
1431
|
interface Principal {
|
|
1443
|
-
/**
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1432
|
+
/** A stable identifier from the vendor's own system. Never an application
|
|
1433
|
+
* id: that names the app and is identical for every one of its users, which
|
|
1434
|
+
* merges them into one actor. */
|
|
1446
1435
|
principalId: string;
|
|
1447
|
-
/**
|
|
1448
|
-
* the
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1451
|
-
|
|
1436
|
+
/** What `principalId` is: `"raw"`, a real identity, or `"hashed"`, a
|
|
1437
|
+
* pseudonym the resolver derived itself. A consumer treats anything not
|
|
1438
|
+
* `"hashed"` as personal data, so leave it unset unless the resolver hashed
|
|
1439
|
+
* the value. */
|
|
1440
|
+
form?: PrincipalForm | undefined;
|
|
1452
1441
|
/** What a page shows for this principal — `principalFromOAuthEmail` puts
|
|
1453
|
-
* the part of the address before the last `@` here.
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1442
|
+
* the part of the address before the last `@` here. Sent verbatim and never
|
|
1443
|
+
* through the scrubber (SPEC §11.4): the vendor chooses what is safe to
|
|
1444
|
+
* show, and it is personal data whatever `form` says. An unusable value is
|
|
1456
1445
|
* dropped alone — see `wireDisplayName`. */
|
|
1457
1446
|
displayName?: string | null | undefined;
|
|
1458
1447
|
}
|
|
1459
|
-
/** HMAC-SHA256 a raw principal into a console-safe, per-tenant `principal.id`.
|
|
1460
|
-
*
|
|
1461
|
-
* `tenantId` is folded into the HMAC MESSAGE (not just the key) so the same
|
|
1462
|
-
* principal under two tenants can never collide or be cross-tenant-correlated.
|
|
1463
|
-
* Returns the BARE lowercase hex digest — no tag, no prefix, no scheme. It
|
|
1464
|
-
* returned `"h1:<hex>"` until 0.4.1; the tag was never part of the HMAC
|
|
1465
|
-
* message, so taking it off moved no digit of the digest.
|
|
1466
|
-
*
|
|
1467
|
-
* ⚠ **`issuer` null/undefined MUST hash byte-identically to the pre-issuer
|
|
1468
|
-
* form** — the append-only message layout is what guarantees it, and every
|
|
1469
|
-
* hash baton-proxy and baton-extmcp have produced since 0.5.0 was issuer-less.
|
|
1470
|
-
*/
|
|
1471
|
-
declare function hashPrincipalId(rawPrincipal: string, options: {
|
|
1472
|
-
tenantId: string;
|
|
1473
|
-
key: Uint8Array | string;
|
|
1474
|
-
issuer?: string | null | undefined;
|
|
1475
|
-
}): string;
|
|
1476
1448
|
|
|
1477
1449
|
/** A validated access token, as both majors declare it
|
|
1478
1450
|
* (`@modelcontextprotocol/sdk` 1.x `server/auth/types.d.ts`,
|
|
@@ -1493,15 +1465,13 @@ interface AuthInfo {
|
|
|
1493
1465
|
|
|
1494
1466
|
/** `BatonConfig.resolvePrincipal` — the ONLY identity provenance (SPEC §11.4).
|
|
1495
1467
|
*
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
1498
|
-
* SDK emits is `source: "asserted"`. The hook's context carries
|
|
1499
|
-
* `authInfo`, and `oauthHooks.ts` ships the two ready-made
|
|
1468
|
+
* The producer never reads the token itself and never derives the value: who
|
|
1469
|
+
* the person is, and whether the id is hashed, are the hook's to state. Every
|
|
1470
|
+
* principal this SDK emits is `source: "asserted"`. The hook's context carries
|
|
1471
|
+
* the validated `authInfo`, and `oauthHooks.ts` ships the two ready-made
|
|
1472
|
+
* OAuth hooks.
|
|
1500
1473
|
*
|
|
1501
|
-
* The TypeScript half of Python's `integrations/identity_adapter.py
|
|
1502
|
-
* close register D6: the field (`user_id` until 0.3.5) had been on this SDK's
|
|
1503
|
-
* envelope since 0.3.0 and NOTHING could populate it, so a partition that
|
|
1504
|
-
* works on one of two SDKs is not a partition.
|
|
1474
|
+
* The TypeScript half of Python's `integrations/identity_adapter.py`.
|
|
1505
1475
|
*/
|
|
1506
1476
|
|
|
1507
1477
|
/** What a vendor's `resolvePrincipal` hook is handed.
|
|
@@ -1548,10 +1518,8 @@ type ResolvePrincipalHook = (context: PrincipalResolutionContext) => Principal |
|
|
|
1548
1518
|
/** The registered values of `resultCaptureMode` (SPEC §11.4), and the single
|
|
1549
1519
|
* source of truth for them.
|
|
1550
1520
|
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
* happen to agree", which is the prose-shaped binding that pattern exists to
|
|
1554
|
-
* replace. `config.ts` builds its validator set from THIS array rather than
|
|
1521
|
+
* A second hand-written list would make the guarantee "two lists happen to
|
|
1522
|
+
* agree". `config.ts` builds its validator set from THIS array rather than
|
|
1555
1523
|
* restating the literals, so a mode cannot be accepted at the door without
|
|
1556
1524
|
* someone having given it a payload shape below. */
|
|
1557
1525
|
declare const RESULT_CAPTURE_MODES: readonly ["full", "off"];
|
|
@@ -1710,23 +1678,13 @@ interface BatonConfig {
|
|
|
1710
1678
|
*
|
|
1711
1679
|
* Never fails a tool call: a hook that throws or returns junk yields an
|
|
1712
1680
|
* anonymous call. ⚠ It is awaited INLINE with no timeout — a blocking hook
|
|
1713
|
-
* stalls its own request.
|
|
1714
|
-
resolvePrincipal?: ResolvePrincipalHook;
|
|
1715
|
-
/** `"hashed"` (default) emits a per-tenant HMAC pseudonym and
|
|
1716
|
-
* `form: "hashed"`; `"raw"` emits the subject VERBATIM and `form: "raw"`.
|
|
1717
|
-
*
|
|
1718
|
-
* `"raw"` puts real identity in the collector's database and is the vendor's
|
|
1719
|
-
* deliberate choice. ⚠ A consumer classifies on `form`, never on this
|
|
1720
|
-
* setting — `PrincipalWireSchema` carries the rule and why it is stated that
|
|
1721
|
-
* way round. */
|
|
1722
|
-
principalIdMode?: PrincipalIdMode;
|
|
1723
|
-
/** The HMAC secret for hashed mode. Resolved explicit →
|
|
1724
|
-
* `BATON_PRINCIPAL_ID_HMAC_KEY` → unset.
|
|
1681
|
+
* stalls its own request.
|
|
1725
1682
|
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
|
|
1683
|
+
* The SDK sends what the hook returns and does nothing else to it: the id
|
|
1684
|
+
* as given, `form` to say whether the hook hashed it, and `displayName` for
|
|
1685
|
+
* what a page shows. A vendor who must not send real identities hashes
|
|
1686
|
+
* inside the hook and returns `form: "hashed"`. */
|
|
1687
|
+
resolvePrincipal?: ResolvePrincipalHook;
|
|
1730
1688
|
}
|
|
1731
1689
|
|
|
1732
1690
|
/**
|
|
@@ -1887,20 +1845,15 @@ declare function withBaton(server: SupportedMcpServer, supplied?: BatonConfig):
|
|
|
1887
1845
|
* hooks return `null` there.
|
|
1888
1846
|
*/
|
|
1889
1847
|
|
|
1890
|
-
/** The token's `sub
|
|
1891
|
-
*
|
|
1848
|
+
/** The token's `sub`. A subject is unique only per issuer: a vendor running
|
|
1849
|
+
* two identity providers writes a hook that combines it with `iss`. */
|
|
1892
1850
|
declare function principalFromOAuthSub(context: PrincipalResolutionContext): Principal | null;
|
|
1893
|
-
/** The token's `email`, as the WHOLE address
|
|
1851
|
+
/** The token's `email`, as the WHOLE address.
|
|
1894
1852
|
*
|
|
1895
1853
|
* `principalId` is the whole address and `displayName` the part before the
|
|
1896
1854
|
* last `@`. The local part alone is not an id — `alice@acme.com` and
|
|
1897
|
-
* `alice@contoso.com` are two people.
|
|
1898
|
-
*
|
|
1899
|
-
* own hook.
|
|
1900
|
-
*
|
|
1901
|
-
* No issuer, unlike the `sub` hook: a subject is unique only per issuer, an
|
|
1902
|
-
* address on its own, and folding `iss` in would give one person a new
|
|
1903
|
-
* pseudonym the day their identity provider changes its issuer URL.
|
|
1855
|
+
* `alice@contoso.com` are two people. A vendor who does not want `alice` on
|
|
1856
|
+
* the wire writes their own hook.
|
|
1904
1857
|
*
|
|
1905
1858
|
* ⚠ `email` is not a standard ACCESS-token claim (OIDC puts it in the ID
|
|
1906
1859
|
* token), so it is here only if the identity provider adds it and the verifier
|
|
@@ -1908,4 +1861,4 @@ declare function principalFromOAuthSub(context: PrincipalResolutionContext): Pri
|
|
|
1908
1861
|
* good enough is the vendor's call. */
|
|
1909
1862
|
declare function principalFromOAuthEmail(context: PrincipalResolutionContext): Principal | null;
|
|
1910
1863
|
|
|
1911
|
-
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type AuthInfo, 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
|
|
1864
|
+
export { type AnnotationEvent, AnnotationEventSchema, type AnnotationPayload, AnnotationPayloadSchema, type AuthInfo, 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 PrincipalForm, type PrincipalResolutionContext, PrincipalWireSchema, type PromptGetEndEvent, PromptGetEndEventSchema, type PromptGetEndPayload, PromptGetEndPayloadSchema, type PromptGetErrorEvent, PromptGetErrorEventSchema, type PromptGetErrorPayload, PromptGetErrorPayloadSchema, type PromptGetStartEvent, PromptGetStartEventSchema, type PromptGetStartPayload, PromptGetStartPayloadSchema, type PromptListEndEvent, PromptListEndEventSchema, type PromptListEndPayload, PromptListEndPayloadSchema, type PromptListErrorEvent, PromptListErrorEventSchema, type PromptListErrorPayload, PromptListErrorPayloadSchema, type PromptListStartEvent, PromptListStartEventSchema, type PromptListStartPayload, PromptListStartPayloadSchema, type ResolvePrincipalHook, type ResourceListEndEvent, ResourceListEndEventSchema, type ResourceListEndPayload, ResourceListEndPayloadSchema, type ResourceListErrorEvent, ResourceListErrorEventSchema, type ResourceListErrorPayload, ResourceListErrorPayloadSchema, type ResourceListStartEvent, ResourceListStartEventSchema, type ResourceListStartPayload, ResourceListStartPayloadSchema, type ResourceReadEndEvent, ResourceReadEndEventSchema, type ResourceReadEndPayload, ResourceReadEndPayloadSchema, type ResourceReadErrorEvent, ResourceReadErrorEventSchema, type ResourceReadErrorPayload, ResourceReadErrorPayloadSchema, type ResourceReadStartEvent, ResourceReadStartEventSchema, type ResourceReadStartPayload, ResourceReadStartPayloadSchema, type ResultCaptureMode, 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, identityScrub, principalFromOAuthEmail, principalFromOAuthSub, safeWrite, withBaton };
|