@agenticprimitives/connect-client 1.0.0-alpha.1 → 1.0.0-alpha.11
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/deployment-epoch.d.ts +18 -0
- package/dist/deployment-epoch.d.ts.map +1 -0
- package/dist/deployment-epoch.js +39 -0
- package/dist/deployment-epoch.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/oidc.d.ts +17 -2
- package/dist/oidc.d.ts.map +1 -1
- package/dist/oidc.js +5 -2
- package/dist/oidc.js.map +1 -1
- package/dist/quick-connect.d.ts +58 -0
- package/dist/quick-connect.d.ts.map +1 -0
- package/dist/quick-connect.js +79 -0
- package/dist/quick-connect.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DeploymentEpochVerdict = 'ok' | 'stale' | 'unstamped' | 'unknown';
|
|
2
|
+
/**
|
|
3
|
+
* Compare a stored session's epoch to the current deployment epoch.
|
|
4
|
+
*
|
|
5
|
+
* - `current` undefined ⇒ `'unknown'`: the running build carries no epoch
|
|
6
|
+
* (e.g. an older deployments artifact), so we CANNOT know staleness and must
|
|
7
|
+
* NOT gate — fail-open only when knowledge is absent (never a silent
|
|
8
|
+
* fallback to a weaker check; there simply is no check to run).
|
|
9
|
+
* - `stored` undefined ⇒ `'unstamped'`: a session written before the guard
|
|
10
|
+
* existed. Since the guard's whole purpose is post-reset recovery, callers
|
|
11
|
+
* SHOULD treat this like `'stale'` and force a reconnect.
|
|
12
|
+
* - otherwise: string equality → `'ok'` | `'stale'`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkDeploymentEpoch(current: string | undefined, stored: string | undefined): DeploymentEpochVerdict;
|
|
15
|
+
/** Convenience: does this verdict require dropping the session + reconnecting?
|
|
16
|
+
* `unstamped` and `stale` both do; `ok` and `unknown` do not. */
|
|
17
|
+
export declare function requiresReconnect(verdict: DeploymentEpochVerdict): boolean;
|
|
18
|
+
//# sourceMappingURL=deployment-epoch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment-epoch.d.ts","sourceRoot":"","sources":["../src/deployment-epoch.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,sBAAsB,GAC9B,IAAI,GACJ,OAAO,GACP,WAAW,GACX,SAAS,CAAC;AAEd;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,sBAAsB,CAIxB;AAED;kEACkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAE1E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Spec 311 — the deployment-epoch guard for relying-app sessions.
|
|
2
|
+
//
|
|
3
|
+
// A relying app stamps each stored session with the authority deployment epoch
|
|
4
|
+
// it was minted against (`CONTRACTS.deploymentEpoch`, emitted by the contracts
|
|
5
|
+
// deployments artifact). On load, it compares the stored epoch to the CURRENT
|
|
6
|
+
// one; a mismatch means a full-reset redeploy happened (new factory / new
|
|
7
|
+
// DelegationManager / new signature validator), so the stored grant + session
|
|
8
|
+
// delegation are signed against a now-dead EIP-712 domain and will fail
|
|
9
|
+
// on-chain verification — the confusing "Signed in, but every vault call
|
|
10
|
+
// 401s" state. Detecting it lets the app force a reconnect instead.
|
|
11
|
+
//
|
|
12
|
+
// Pure + storage-agnostic: the app owns where the epoch is stored (its session
|
|
13
|
+
// blob) and what it does with the verdict (clear + route to reconnect). This
|
|
14
|
+
// module only decides.
|
|
15
|
+
/**
|
|
16
|
+
* Compare a stored session's epoch to the current deployment epoch.
|
|
17
|
+
*
|
|
18
|
+
* - `current` undefined ⇒ `'unknown'`: the running build carries no epoch
|
|
19
|
+
* (e.g. an older deployments artifact), so we CANNOT know staleness and must
|
|
20
|
+
* NOT gate — fail-open only when knowledge is absent (never a silent
|
|
21
|
+
* fallback to a weaker check; there simply is no check to run).
|
|
22
|
+
* - `stored` undefined ⇒ `'unstamped'`: a session written before the guard
|
|
23
|
+
* existed. Since the guard's whole purpose is post-reset recovery, callers
|
|
24
|
+
* SHOULD treat this like `'stale'` and force a reconnect.
|
|
25
|
+
* - otherwise: string equality → `'ok'` | `'stale'`.
|
|
26
|
+
*/
|
|
27
|
+
export function checkDeploymentEpoch(current, stored) {
|
|
28
|
+
if (!current)
|
|
29
|
+
return 'unknown';
|
|
30
|
+
if (!stored)
|
|
31
|
+
return 'unstamped';
|
|
32
|
+
return stored === current ? 'ok' : 'stale';
|
|
33
|
+
}
|
|
34
|
+
/** Convenience: does this verdict require dropping the session + reconnecting?
|
|
35
|
+
* `unstamped` and `stale` both do; `ok` and `unknown` do not. */
|
|
36
|
+
export function requiresReconnect(verdict) {
|
|
37
|
+
return verdict === 'stale' || verdict === 'unstamped';
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=deployment-epoch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment-epoch.js","sourceRoot":"","sources":["../src/deployment-epoch.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,0EAA0E;AAC1E,8EAA8E;AAC9E,wEAAwE;AACxE,yEAAyE;AACzE,oEAAoE;AACpE,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,uBAAuB;AAQvB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAA2B,EAC3B,MAA0B;IAE1B,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,CAAC;IAChC,OAAO,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;AAC7C,CAAC;AAED;kEACkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,OAA+B;IAC/D,OAAO,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,WAAW,CAAC;AACxD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export declare const SPEC_REF = "specs/295-relying-connect-client.md";
|
|
|
3
3
|
export { createConnectClient, generatePkce, randomB64url, type ConnectClient, type ConnectClientConfig, type AuthorizeTemplate, type IdTokenClaims, type TokenResult, type EnrollmentStart, type WireDelegation, } from './oidc.js';
|
|
4
4
|
export { openCentralAuthPopup, preferRedirect, relayCodeIfPopupReturn, type PopupResult, } from './popup.js';
|
|
5
5
|
export { connectViaRedirect, connectViaPopup, connectViaFedcm, type ConnectStash, type PopupConnectResult, type FedcmConnectResult, } from './launch.js';
|
|
6
|
+
export { checkDeploymentEpoch, requiresReconnect, type DeploymentEpochVerdict, } from './deployment-epoch.js';
|
|
7
|
+
export { listQuickConnect, connectAsQuickConnect, type QuickConnectIdentity, type QuickConnectSession, type QuickConnectConfig, } from './quick-connect.js';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,sCAAsC,CAAC;AAChE,eAAO,MAAM,QAAQ,wCAAwC,CAAC;AAE9D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,sCAAsC,CAAC;AAChE,eAAO,MAAM,QAAQ,wCAAwC,CAAC;AAE9D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,4 +10,9 @@ export const SPEC_REF = 'specs/295-relying-connect-client.md';
|
|
|
10
10
|
export { createConnectClient, generatePkce, randomB64url, } from './oidc.js';
|
|
11
11
|
export { openCentralAuthPopup, preferRedirect, relayCodeIfPopupReturn, } from './popup.js';
|
|
12
12
|
export { connectViaRedirect, connectViaPopup, connectViaFedcm, } from './launch.js';
|
|
13
|
+
export { checkDeploymentEpoch, requiresReconnect, } from './deployment-epoch.js';
|
|
14
|
+
// Quick-connect identities a Home may offer (the client half of its persona registry). Gated by the
|
|
15
|
+
// HOME: `listQuickConnect` returns [] when none are offered, so the affordance disappears everywhere at
|
|
16
|
+
// once without any app shipping a flag.
|
|
17
|
+
export { listQuickConnect, connectAsQuickConnect, } from './quick-connect.js';
|
|
13
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,uGAAuG;AACvG,uGAAuG;AACvG,iGAAiG;AACjG,wGAAwG;AACxG,8FAA8F;AAE9F,MAAM,CAAC,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAChE,MAAM,CAAC,MAAM,QAAQ,GAAG,qCAAqC,CAAC;AAE9D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,GAQb,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GAEvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,GAIhB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,uGAAuG;AACvG,uGAAuG;AACvG,iGAAiG;AACjG,wGAAwG;AACxG,8FAA8F;AAE9F,MAAM,CAAC,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAChE,MAAM,CAAC,MAAM,QAAQ,GAAG,qCAAqC,CAAC;AAE9D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,GAQb,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GAEvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,GAIhB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAE/B,oGAAoG;AACpG,wGAAwG;AACxG,wCAAwC;AACxC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,GAItB,MAAM,oBAAoB,CAAC"}
|
package/dist/oidc.d.ts
CHANGED
|
@@ -37,6 +37,11 @@ export interface TokenResult {
|
|
|
37
37
|
delegation?: WireDelegation;
|
|
38
38
|
/** Present for `org-create`: the created org's identity + its broker delegation. */
|
|
39
39
|
org?: Record<string, unknown>;
|
|
40
|
+
/** spec 345 — a `delegator = delegate = person` grant scoped to the person's OWN vault record
|
|
41
|
+
* family, present when the requesting client's Home-side registry declared `self_vault_grant`.
|
|
42
|
+
* Rides the SAME plain sign-in as `delegation` — no separate ceremony. Generic: any relying app
|
|
43
|
+
* may use this, not tied to one app's domain. Opaque here; the app casts to its `DelegationWire`. */
|
|
44
|
+
selfVaultGrant?: WireDelegation;
|
|
40
45
|
}
|
|
41
46
|
/** The PKCE + state + nonce a started enrollment must round-trip back to `exchangeCode`/`verifyIdToken`. */
|
|
42
47
|
export interface EnrollmentStart {
|
|
@@ -64,6 +69,8 @@ interface AuthorizeParams {
|
|
|
64
69
|
orgBase?: string;
|
|
65
70
|
purpose?: string;
|
|
66
71
|
grantOrg?: Address;
|
|
72
|
+
/** org-create: reuse an EXISTING org the person stewards — the Home grants from it instead of deploying. */
|
|
73
|
+
existingOrg?: Address;
|
|
67
74
|
/** Appended when launching in a popup (the Home posts the result back instead of redirecting). */
|
|
68
75
|
mode?: 'popup';
|
|
69
76
|
}
|
|
@@ -75,10 +82,18 @@ export interface ConnectClient {
|
|
|
75
82
|
startEnrollment(name: string, opts?: {
|
|
76
83
|
mode?: 'popup';
|
|
77
84
|
}): Promise<EnrollmentStart>;
|
|
78
|
-
/** Build an `org-create` authorize request (deploy + custody an org SA at the Home).
|
|
79
|
-
|
|
85
|
+
/** Build an `org-create` authorize request (deploy + custody an org SA at the Home). Omit `orgBase`
|
|
86
|
+
* (and `existingOrg`) to run CHOOSER MODE: the Home asks the member to pick an org they already
|
|
87
|
+
* steward — granting from it, no deploy — or to name a new one there. */
|
|
88
|
+
startOrgCreation(personName: string, orgBase?: string, opts?: {
|
|
80
89
|
purpose?: string;
|
|
81
90
|
grantOrg?: Address;
|
|
91
|
+
existingOrg?: Address;
|
|
92
|
+
mode?: 'popup';
|
|
93
|
+
}): Promise<EnrollmentStart>;
|
|
94
|
+
/** Deploy a workspace-kind Smart Agent (at:WorkspaceAgent). Name is required. */
|
|
95
|
+
startWorkspaceCreation(personName: string, workspaceName: string, opts?: {
|
|
96
|
+
purpose?: string;
|
|
82
97
|
mode?: 'popup';
|
|
83
98
|
}): Promise<EnrollmentStart>;
|
|
84
99
|
/** Exchange the authorization `code` at the Home's `/token` (PKCE) → `{ idToken, delegation, org? }`. */
|
package/dist/oidc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc.d.ts","sourceRoot":"","sources":["../src/oidc.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD;0GAC0G;AAC1G,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD;6EAC6E;AAC7E,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,CAAC;AAErE,0GAA0G;AAC1G,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,6FAA6F;IAC7F,QAAQ,EAAE,OAAO,CAAC;IAClB,qGAAqG;IACrG,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B;0FACsF;IACtF,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC/D,6FAA6F;IAC7F,qBAAqB,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G,oFAAoF;IACpF,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC;IAC9C,mGAAmG;IACnG,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACnD;;wFAEoF;IACpF,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAChD;AAED;4GAC4G;AAC5G,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,aAAa,CA4F9E"}
|
package/dist/oidc.js
CHANGED
|
@@ -57,6 +57,8 @@ export function createConnectClient(config) {
|
|
|
57
57
|
u.searchParams.set('org_purpose', p.purpose);
|
|
58
58
|
if (p.grantOrg)
|
|
59
59
|
u.searchParams.set('grant_org', p.grantOrg);
|
|
60
|
+
if (p.existingOrg)
|
|
61
|
+
u.searchParams.set('existing_org', p.existingOrg);
|
|
60
62
|
if (p.mode)
|
|
61
63
|
u.searchParams.set('mode', p.mode);
|
|
62
64
|
return u.toString();
|
|
@@ -73,7 +75,8 @@ export function createConnectClient(config) {
|
|
|
73
75
|
return {
|
|
74
76
|
buildAuthorizeUrl,
|
|
75
77
|
startEnrollment: (name, opts) => begin(name, 'site-login', { mode: opts?.mode }),
|
|
76
|
-
startOrgCreation: (personName, orgBase, opts) => begin(personName, 'org-create', { orgBase, purpose: opts?.purpose, grantOrg: opts?.grantOrg, mode: opts?.mode }),
|
|
78
|
+
startOrgCreation: (personName, orgBase, opts) => begin(personName, 'org-create', { orgBase, purpose: opts?.purpose, grantOrg: opts?.grantOrg, existingOrg: opts?.existingOrg, mode: opts?.mode }),
|
|
79
|
+
startWorkspaceCreation: (personName, workspaceName, opts) => begin(personName, 'workspace-create', { orgBase: workspaceName, purpose: opts?.purpose, mode: opts?.mode }),
|
|
77
80
|
async exchangeCode(authOrigin, code, codeVerifier) {
|
|
78
81
|
const r = await fetch(new URL('/token', authOrigin).toString(), {
|
|
79
82
|
method: 'POST',
|
|
@@ -83,7 +86,7 @@ export function createConnectClient(config) {
|
|
|
83
86
|
const b = (await r.json().catch(() => ({})));
|
|
84
87
|
if (!r.ok || !b.id_token)
|
|
85
88
|
throw new Error(b.error ?? `token exchange failed (HTTP ${r.status})`);
|
|
86
|
-
return { idToken: b.id_token, delegation: b.delegation, org: b.org };
|
|
89
|
+
return { idToken: b.id_token, delegation: b.delegation, org: b.org, selfVaultGrant: b.selfVaultGrant };
|
|
87
90
|
},
|
|
88
91
|
async verifyIdToken(authOrigin, idToken, expectedNonce) {
|
|
89
92
|
if (!config.isAllowedIssuerOrigin(authOrigin)) {
|
package/dist/oidc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc.js","sourceRoot":"","sources":["../src/oidc.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,4GAA4G;AAC5G,4GAA4G;AAC5G,4GAA4G;AAC5G,6CAA6C;AAC7C,EAAE;AACF,0GAA0G;AAC1G,8GAA8G;AAC9G,0FAA0F;
|
|
1
|
+
{"version":3,"file":"oidc.js","sourceRoot":"","sources":["../src/oidc.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,4GAA4G;AAC5G,4GAA4G;AAC5G,4GAA4G;AAC5G,6CAA6C;AAC7C,EAAE;AACF,0GAA0G;AAC1G,8GAA8G;AAC9G,0FAA0F;AA+D1F,0EAA0E;AAC1E,SAAS,MAAM,CAAC,KAAiB;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC;AACD,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,GAAG,GAAG,IAAI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AAC,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAC3G,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,aAAa;QACb,wBAAwB,CAAC,OAAO;YAC9B,MAAM,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;YACjC,MAAM,GAAG,GAAG,CAAC,CAAC,kBAAkB,IAAI,CAAC,CAAC,GAAG,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG,CAAC,CAAC,CAAC,GAAG,CAAY,CAAC;QACtE,CAAC;QACD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;KACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** One identity a Home offers for quick connect. */
|
|
2
|
+
export interface QuickConnectIdentity {
|
|
3
|
+
/** Short stable id used to request a session. */
|
|
4
|
+
handle: string;
|
|
5
|
+
/** The canonical Smart Agent address — the identity itself (ADR-0010). */
|
|
6
|
+
sa: string;
|
|
7
|
+
/** Display name. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** One-line description of who they are in the demo world. */
|
|
10
|
+
blurb: string;
|
|
11
|
+
/** The custodian address holding their key at the Home, when disclosed. */
|
|
12
|
+
custodian?: string;
|
|
13
|
+
/** Agents this identity custodies (orgs, services) — what makes them useful for testing. */
|
|
14
|
+
custodies?: {
|
|
15
|
+
sa: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
kind?: string;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
/** What a Home returns when an app connects as one of them — an ordinary sign-in result. */
|
|
21
|
+
export interface QuickConnectSession {
|
|
22
|
+
/** Canonical subject (CAIP-10 or SA address, per the Home). */
|
|
23
|
+
sub: string;
|
|
24
|
+
agentName: string | null;
|
|
25
|
+
/** OIDC id_token — what Home-run surfaces (inbox, invites) authenticate with. */
|
|
26
|
+
idToken: string;
|
|
27
|
+
/** The site-login delegation — the AUTHORITY half. A token authenticates; this authorizes. */
|
|
28
|
+
delegation: unknown;
|
|
29
|
+
/** The same person's Home session, so an app can hand off into their portal already signed in. */
|
|
30
|
+
homeSession?: string;
|
|
31
|
+
homeSessionExpiresIn?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface QuickConnectConfig {
|
|
34
|
+
/** The Home origin, injected by the app's own domain module. */
|
|
35
|
+
homeOrigin: string;
|
|
36
|
+
/** This app's registered OIDC client id — the Home resolves the delegate from its OWN registry, so a
|
|
37
|
+
* wrong value yields no session rather than a session scoped to somebody else. */
|
|
38
|
+
clientId: string;
|
|
39
|
+
fetchImpl?: typeof fetch;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* List the identities this Home offers.
|
|
43
|
+
*
|
|
44
|
+
* Returns `[]` for every non-success — a Home that does not offer the feature, an origin that is not a
|
|
45
|
+
* Home, a network failure. That is deliberate: the ONLY use of this list is deciding whether to show an
|
|
46
|
+
* affordance, and "show nothing" is the correct outcome in all of those cases. It never throws, so a
|
|
47
|
+
* Home being unreachable cannot break an app's header.
|
|
48
|
+
*/
|
|
49
|
+
export declare function listQuickConnect(config: QuickConnectConfig): Promise<QuickConnectIdentity[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Connect as one of them.
|
|
52
|
+
*
|
|
53
|
+
* THROWS on failure, unlike the list above, and the asymmetry is intentional: listing decides whether to
|
|
54
|
+
* offer a choice, where silence is a fine answer; connecting is a user action, where silence would leave
|
|
55
|
+
* someone looking at a button that did nothing. A failed connect must say so.
|
|
56
|
+
*/
|
|
57
|
+
export declare function connectAsQuickConnect(config: QuickConnectConfig, handleOrSa: string): Promise<QuickConnectSession>;
|
|
58
|
+
//# sourceMappingURL=quick-connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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 +1,79 @@
|
|
|
1
|
+
// Quick-connect identities offered by a Home (spec 295; the client half of the Home's persona registry).
|
|
2
|
+
//
|
|
3
|
+
// WHAT THIS IS FOR. A Home MAY offer a small set of pre-custodied identities a relying app can connect
|
|
4
|
+
// as without running a credential ceremony — the same person, same Smart Agent, same vault and org
|
|
5
|
+
// memberships, in every app that asks. It exists so a demo or a test can exercise a real authority
|
|
6
|
+
// chain instead of a mock: the identity is an actual on-chain SA whose custodian the Home holds, so
|
|
7
|
+
// every downstream signature, delegation and vault read is genuine.
|
|
8
|
+
//
|
|
9
|
+
// GATED BY THE HOME, NOT BY THE APP. `listQuickConnect` returns `[]` when the Home offers none, and an
|
|
10
|
+
// app is expected to render nothing in that case. That is the whole configuration story: a Home without
|
|
11
|
+
// the feature enabled reports an empty list, so the affordance disappears everywhere at once without
|
|
12
|
+
// any app shipping a flag. An app that hard-coded its own list would defeat that.
|
|
13
|
+
//
|
|
14
|
+
// THIS IS NOT A CREDENTIAL PATH. The app never holds a key. It asks the Home for a session and receives
|
|
15
|
+
// exactly what an ordinary OIDC sign-in returns — an `id_token` and the site delegation. Anyone who can
|
|
16
|
+
// reach an enabled Home can connect as these identities; that is what "connect as this account" means,
|
|
17
|
+
// and it is why a Home only enables it for accounts that exist to be shared.
|
|
18
|
+
//
|
|
19
|
+
// NO HOSTNAMES (ADR-0021): the caller supplies its Home origin, as with everything else in this package.
|
|
20
|
+
const trimOrigin = (o) => o.replace(/\/$/, '');
|
|
21
|
+
/**
|
|
22
|
+
* List the identities this Home offers.
|
|
23
|
+
*
|
|
24
|
+
* Returns `[]` for every non-success — a Home that does not offer the feature, an origin that is not a
|
|
25
|
+
* Home, a network failure. That is deliberate: the ONLY use of this list is deciding whether to show an
|
|
26
|
+
* affordance, and "show nothing" is the correct outcome in all of those cases. It never throws, so a
|
|
27
|
+
* Home being unreachable cannot break an app's header.
|
|
28
|
+
*/
|
|
29
|
+
export async function listQuickConnect(config) {
|
|
30
|
+
const doFetch = config.fetchImpl ?? fetch;
|
|
31
|
+
try {
|
|
32
|
+
const res = await doFetch(`${trimOrigin(config.homeOrigin)}/connect/demo-personas`, {
|
|
33
|
+
method: 'GET',
|
|
34
|
+
headers: { accept: 'application/json' },
|
|
35
|
+
});
|
|
36
|
+
if (!res.ok)
|
|
37
|
+
return [];
|
|
38
|
+
const body = (await res.json());
|
|
39
|
+
return Array.isArray(body.personas) ? body.personas : [];
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Connect as one of them.
|
|
47
|
+
*
|
|
48
|
+
* THROWS on failure, unlike the list above, and the asymmetry is intentional: listing decides whether to
|
|
49
|
+
* offer a choice, where silence is a fine answer; connecting is a user action, where silence would leave
|
|
50
|
+
* someone looking at a button that did nothing. A failed connect must say so.
|
|
51
|
+
*/
|
|
52
|
+
export async function connectAsQuickConnect(config, handleOrSa) {
|
|
53
|
+
const doFetch = config.fetchImpl ?? fetch;
|
|
54
|
+
const isSa = /^0x[0-9a-fA-F]{40}$/.test(handleOrSa);
|
|
55
|
+
const res = await doFetch(`${trimOrigin(config.homeOrigin)}/connect/demo-signin`, {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
headers: { 'content-type': 'application/json' },
|
|
58
|
+
body: JSON.stringify({ ...(isSa ? { sa: handleOrSa } : { handle: handleOrSa }), client_id: config.clientId }),
|
|
59
|
+
});
|
|
60
|
+
const body = (await res.json().catch(() => ({})));
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
throw new Error(body.error ?? `quick connect failed (${res.status})`);
|
|
63
|
+
}
|
|
64
|
+
if (typeof body.id_token !== 'string' || !body.delegation) {
|
|
65
|
+
// A session without BOTH halves is not a session. The token authenticates and the delegation
|
|
66
|
+
// authorizes; an app that accepted one without the other would be authenticated and unable to act,
|
|
67
|
+
// or acting without having authenticated — and would discover it much later (ADR-0041).
|
|
68
|
+
throw new Error('quick connect returned an incomplete session (missing id_token or delegation)');
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
sub: String(body.sub ?? ''),
|
|
72
|
+
agentName: body.agent_name ?? null,
|
|
73
|
+
idToken: body.id_token,
|
|
74
|
+
delegation: body.delegation,
|
|
75
|
+
homeSession: typeof body.homeSession === 'string' ? body.homeSession : undefined,
|
|
76
|
+
homeSessionExpiresIn: typeof body.homeSessionExpiresIn === 'number' ? body.homeSessionExpiresIn : undefined,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=quick-connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quick-connect.js","sourceRoot":"","sources":["../src/quick-connect.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,EAAE;AACF,uGAAuG;AACvG,mGAAmG;AACnG,mGAAmG;AACnG,oGAAoG;AACpG,oEAAoE;AACpE,EAAE;AACF,uGAAuG;AACvG,wGAAwG;AACxG,qGAAqG;AACrG,kFAAkF;AAClF,EAAE;AACF,wGAAwG;AACxG,wGAAwG;AACxG,uGAAuG;AACvG,6EAA6E;AAC7E,EAAE;AACF,yGAAyG;AAyCzG,MAAM,UAAU,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAA0B;IAC/D,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC;IAC1C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,wBAAwB,EAAE;YAClF,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;SACxC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,EAAE,CAAC;QACvB,MA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,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;QAC1D,6FAA6F;QAC7F,mGAAmG;QACnG,wFAAwF;QACxF,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IACnG,CAAC;IACD,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;QAC3B,SAAS,EAAG,IAAI,CAAC,UAA4B,IAAI,IAAI;QACrD,OAAO,EAAE,IAAI,CAAC,QAAQ;QACtB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;QAChF,oBAAoB,EAClB,OAAO,IAAI,CAAC,oBAAoB,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;KACxF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticprimitives/connect-client",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
4
4
|
"description": "Generic relying-party connect client: hand off to the central-auth Home (FedCM-first → OIDC redirect/popup), exchange the code for an SA-signed scoped delegation. The relying half of spec 230/259; no credential ever originates in the relying app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@agenticprimitives/fedcm-rp": "1.0.0-alpha.6",
|
|
35
|
-
"@agenticprimitives/types": "1.0.0-alpha.
|
|
35
|
+
"@agenticprimitives/types": "1.0.0-alpha.21"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.7.0",
|