@poppykit/client 0.2.0 → 0.3.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/API.md +1 -1
- package/CHANGELOG.md +6 -0
- package/PROVIDER.md +10 -0
- package/README.md +2 -2
- package/dist/provider.d.ts +26 -0
- package/dist/provider.js +39 -0
- package/package.json +1 -1
package/API.md
CHANGED
|
@@ -11,7 +11,7 @@ for complete option/result types. This map describes the supported integration s
|
|
|
11
11
|
| `@poppykit/client` | `ApiTarget`, `AgentBrowserController`, `FeedbackReport` types | [integrations](INTEGRATIONS.md) |
|
|
12
12
|
| `@poppykit/client/sqlite` | `SqliteAuthStore`, `SqliteConversationStore` | [storage](STORAGE.md) |
|
|
13
13
|
| `@poppykit/client/memory` | `MemoryConversationStore` (non-durable) | [storage](STORAGE.md) |
|
|
14
|
-
| `@poppykit/client/provider` | `createProvider`, `createProviderClient`, `createResultCipher` | [provider](PROVIDER.md) |
|
|
14
|
+
| `@poppykit/client/provider` | `createProvider`, `createProviderClient`, `createResultCipher`, `createBrowserEnrollmentClient` | [provider](PROVIDER.md) |
|
|
15
15
|
| `@poppykit/client/provider/sqlite` | `SqliteProviderStore` | [provider](PROVIDER.md) |
|
|
16
16
|
|
|
17
17
|
ClientAuth methods include `start/get/list/target`, `authorization`,
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 (release candidate)
|
|
4
|
+
|
|
5
|
+
Add the optional challenge-bound browser enrollment client under `/provider`.
|
|
6
|
+
Existing provider APIs, storage adapters and all protocol authentication methods
|
|
7
|
+
retain their contracts. Enrollment secrets remain caller-controlled.
|
|
8
|
+
|
|
3
9
|
## 0.2.0 (release candidate)
|
|
4
10
|
|
|
5
11
|
Add bundled Postgres auth/conversation/provider stores and explicit migrations. Provider APIs and targeted storage transactions are asynchronous; await callback/result/revocation operations. SQLite and explicit legacy local-store migration remain supported.
|
package/PROVIDER.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Optional identity provider
|
|
2
2
|
|
|
3
|
+
`createBrowserEnrollmentClient` from this subpath is an optional hosting-service
|
|
4
|
+
client. It is independent of company consent and leaves all secret custody with
|
|
5
|
+
the caller. Configure an HTTPS enrollment URL on the provider origin; call
|
|
6
|
+
`start(SHA256(verifier))`, show only its public `browserUrl`, then call
|
|
7
|
+
`status(requestId, verifier)` from trusted code. A ready response contains the
|
|
8
|
+
credential for immediate secure staging, never for model output. `cancel` revokes
|
|
9
|
+
failed/uncertain delivery; hosts must consume results once, retain replay
|
|
10
|
+
tombstones and revoke on failed/lost retrieval. The CLI implements that workflow.
|
|
11
|
+
This optional service uses version1 JSON requests and is not a Poppy extension.
|
|
12
|
+
|
|
3
13
|
Import `createProvider`, `createProviderClient`, and `createResultCipher` from
|
|
4
14
|
`@poppykit/client/provider`; durable `SqliteProviderStore` is separately exported
|
|
5
15
|
from `@poppykit/client/provider/sqlite`. Neither is loaded by the core import.
|
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ application supplies the agent and trusted infrastructure. [MIT](LICENSE).
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
Version 0.
|
|
9
|
+
Version 0.3.0 is a release candidate until its publishing workflow completes.
|
|
10
10
|
|
|
11
11
|
Requires Node **24.12.0+**, ESM and HTTPS. CI tests Node 24.12.0 on Linux, macOS and
|
|
12
12
|
Windows; later majors are not separately certified.
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
npm install @poppykit/client@0.
|
|
15
|
+
npm install @poppykit/client@0.3.0
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Discover a company
|
package/dist/provider.d.ts
CHANGED
|
@@ -148,4 +148,30 @@ export declare function createProviderClient(options: {
|
|
|
148
148
|
cancel: (operationId: string) => Promise<Row>;
|
|
149
149
|
revokeEnrollment: () => Promise<Row>;
|
|
150
150
|
};
|
|
151
|
+
/** Browser enrollment is an optional host service, separate from company consent. Keep verifier/results in trusted custody. */
|
|
152
|
+
export declare function createBrowserEnrollmentClient(options: {
|
|
153
|
+
url: string;
|
|
154
|
+
provider: string;
|
|
155
|
+
company: string;
|
|
156
|
+
installationId: string;
|
|
157
|
+
transport: HttpTransport;
|
|
158
|
+
}): {
|
|
159
|
+
start(challenge: string): Promise<{
|
|
160
|
+
requestId: string;
|
|
161
|
+
browserUrl: string;
|
|
162
|
+
expiresAt: number;
|
|
163
|
+
}>;
|
|
164
|
+
status(requestId: string, verifier: string): Promise<{
|
|
165
|
+
status: "pending" | "denied";
|
|
166
|
+
credential?: undefined;
|
|
167
|
+
clientId?: undefined;
|
|
168
|
+
callbackUrl?: undefined;
|
|
169
|
+
} | {
|
|
170
|
+
status: "ready";
|
|
171
|
+
credential: string;
|
|
172
|
+
clientId: string;
|
|
173
|
+
callbackUrl: string;
|
|
174
|
+
}>;
|
|
175
|
+
cancel: (requestId: string, verifier: string) => Promise<Row>;
|
|
176
|
+
};
|
|
151
177
|
export {};
|
package/dist/provider.js
CHANGED
|
@@ -355,3 +355,42 @@ export function createProviderClient(options) {
|
|
|
355
355
|
takeResult: (input) => call('takeResult', input),
|
|
356
356
|
cancel: (operationId) => call('cancel', { operationId }), revokeEnrollment: () => call('revokeEnrollment', {}) };
|
|
357
357
|
}
|
|
358
|
+
/** Browser enrollment is an optional host service, separate from company consent. Keep verifier/results in trusted custody. */
|
|
359
|
+
export function createBrowserEnrollmentClient(options) {
|
|
360
|
+
const base = https(options.url), provider = https(options.provider);
|
|
361
|
+
if (base.search || base.hash || provider.origin !== base.origin)
|
|
362
|
+
throw new TypeError('enrollment and provider must share origin');
|
|
363
|
+
async function call(action, input) {
|
|
364
|
+
const response = await options.transport.fetch(new Request(`${base.href.replace(/\/$/, '')}/${action}`, {
|
|
365
|
+
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
366
|
+
body: JSON.stringify({ version: 1, installationId: options.installationId, provider: options.provider, company: options.company, ...input }),
|
|
367
|
+
}));
|
|
368
|
+
const body = object(await response.json());
|
|
369
|
+
if (!response.ok)
|
|
370
|
+
throw new ProviderError(['unauthorized', 'binding_conflict', 'expired', 'consumed', 'canceled', 'rate_limited'].includes(body.error) ? body.error : 'unavailable');
|
|
371
|
+
return body;
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
async start(challenge) {
|
|
375
|
+
if (!/^[\w-]{43}$/.test(challenge))
|
|
376
|
+
throw new TypeError('enrollment challenge');
|
|
377
|
+
const body = await call('start', { challenge });
|
|
378
|
+
const browser = https(text(body.browserUrl));
|
|
379
|
+
if (browser.origin !== base.origin || typeof body.expiresAt !== 'number' || !/^[\w-]{43}$/.test(body.requestId))
|
|
380
|
+
fail('binding_conflict');
|
|
381
|
+
return { requestId: body.requestId, browserUrl: browser.href, expiresAt: body.expiresAt };
|
|
382
|
+
},
|
|
383
|
+
async status(requestId, verifier) {
|
|
384
|
+
const body = await call('status', { requestId, verifier });
|
|
385
|
+
if (!['pending', 'denied', 'ready'].includes(body.status))
|
|
386
|
+
fail('binding_conflict');
|
|
387
|
+
if (body.status !== 'ready')
|
|
388
|
+
return { status: body.status };
|
|
389
|
+
const clientId = https(text(body.clientId)).href, callbackUrl = https(text(body.callbackUrl)).href;
|
|
390
|
+
if (new URL(clientId).origin !== provider.origin || new URL(callbackUrl).origin !== provider.origin)
|
|
391
|
+
fail('binding_conflict');
|
|
392
|
+
return { status: 'ready', credential: text(body.credential), clientId, callbackUrl };
|
|
393
|
+
},
|
|
394
|
+
cancel: (requestId, verifier) => call('cancel', { requestId, verifier }),
|
|
395
|
+
};
|
|
396
|
+
}
|