@poppykit/server 0.3.0 → 0.4.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 -0
- package/AUTH.md +36 -7
- package/CHANGELOG.md +11 -0
- package/CONTRIBUTING.md +6 -4
- package/DELIVERY.md +19 -1
- package/INTEGRATIONS.md +21 -11
- package/README.md +12 -4
- package/RELEASING.md +1 -1
- package/STORAGE.md +19 -3
- package/dist/adapter-contract.js +11 -11
- package/dist/browser.d.ts +9 -6
- package/dist/browser.js +32 -30
- package/dist/conversation/service.d.ts +7 -7
- package/dist/conversation/service.js +26 -24
- package/dist/index.d.ts +1 -0
- package/dist/network/discovery.d.ts +20 -9
- package/dist/network/discovery.js +74 -21
- package/dist/network/redirect.d.ts +3 -0
- package/dist/network/redirect.js +38 -0
- package/dist/network/tasks.d.ts +23 -0
- package/dist/network/tasks.js +45 -0
- package/dist/postgres.js +22 -4
- package/dist/protocol/wire.d.ts +12 -11
- package/dist/protocol/wire.js +33 -7
- package/dist/reference-auth/index.d.ts +16 -5
- package/dist/reference-auth/index.js +130 -59
- package/dist/reference-auth/store.d.ts +2 -1
- package/dist/sqlite.js +22 -4
- package/examples/quickstart.mjs +2 -1
- package/package.json +2 -2
package/dist/sqlite.js
CHANGED
|
@@ -3,7 +3,7 @@ import { initializeSqlite } from './sqlite-init.js';
|
|
|
3
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
4
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
5
5
|
import { initialConversationState } from './conversation/service.js';
|
|
6
|
-
import { initialIssuerState } from './reference-auth/index.js';
|
|
6
|
+
import { initialIssuerState, upgradeIssuerState } from './reference-auth/index.js';
|
|
7
7
|
import { clientRevisionKey, accountRevisionKey } from './reference-auth/store.js';
|
|
8
8
|
function json(value) {
|
|
9
9
|
return JSON.stringify(value, (_key, item) => {
|
|
@@ -120,6 +120,8 @@ export class SqliteCompanyDatabase {
|
|
|
120
120
|
conversations(namespace) {
|
|
121
121
|
const load = (selection) => {
|
|
122
122
|
const state = { ...this.meta(namespace, 'conversation_meta', () => { const { version, generation } = initialConversationState(); return { version, generation }; }), conversations: {}, bindings: {}, messages: {}, work: [] };
|
|
123
|
+
if (state.version !== 2)
|
|
124
|
+
throw new Error('conversation reset required for draft 0.3');
|
|
123
125
|
let id = selection.conversationId;
|
|
124
126
|
if (selection.messageKey) {
|
|
125
127
|
const message = this.one(namespace, 'messages', selection.messageKey);
|
|
@@ -254,9 +256,9 @@ export class SqliteCompanyDatabase {
|
|
|
254
256
|
};
|
|
255
257
|
}
|
|
256
258
|
issuer(namespace) {
|
|
257
|
-
const kinds = ['sessions', 'grants', 'refreshTokens', 'authorizations', 'codes', 'signIns', 'accessTokens', 'replay'];
|
|
259
|
+
const kinds = ['sessions', 'sessionKeys', 'grants', 'refreshTokens', 'authorizations', 'codes', 'signIns', 'accessTokens', 'replay'];
|
|
258
260
|
const load = (selection) => {
|
|
259
|
-
const state = { ...this.meta(namespace, 'issuer_meta', () => { const { version, generation, nonces } = initialIssuerState(); return { version, generation, nonces }; }), sessions: {}, grants: {}, refreshTokens: {}, authorizations: {}, codes: {}, signIns: {}, accessTokens: {}, replay: {} };
|
|
261
|
+
const state = { ...this.meta(namespace, 'issuer_meta', () => { const { version, generation, nonces } = initialIssuerState(); return { version, generation, nonces }; }), sessions: {}, sessionKeys: {}, grants: {}, refreshTokens: {}, authorizations: {}, codes: {}, signIns: {}, accessTokens: {}, replay: {} };
|
|
260
262
|
const get = (kind, id) => {
|
|
261
263
|
if (!id)
|
|
262
264
|
return;
|
|
@@ -268,6 +270,23 @@ export class SqliteCompanyDatabase {
|
|
|
268
270
|
for (const row of this.rows(namespace, kind, where, params))
|
|
269
271
|
state[kind][row.id] = JSON.parse(row.body);
|
|
270
272
|
};
|
|
273
|
+
if (state.version === 3) {
|
|
274
|
+
for (const kind of kinds)
|
|
275
|
+
find(kind, '');
|
|
276
|
+
const before = structuredClone(state);
|
|
277
|
+
upgradeIssuerState(state);
|
|
278
|
+
for (const kind of kinds)
|
|
279
|
+
this.save(namespace, kind, before[kind], state[kind]);
|
|
280
|
+
this.put(namespace, 'issuer_meta', 'meta', { version: state.version, generation: state.generation, nonces: state.nonces });
|
|
281
|
+
for (const kind of kinds)
|
|
282
|
+
state[kind] = {};
|
|
283
|
+
}
|
|
284
|
+
if (state.version !== 4)
|
|
285
|
+
throw new Error('unsupported issuer state version');
|
|
286
|
+
if ((selection.kind === 'token' || selection.kind === 'sign_in') && selection.sessionKey) {
|
|
287
|
+
get('sessionKeys', selection.sessionKey);
|
|
288
|
+
get('sessions', state.sessionKeys[selection.sessionKey]);
|
|
289
|
+
}
|
|
271
290
|
if (selection.kind === 'access')
|
|
272
291
|
get('accessTokens', selection.hash);
|
|
273
292
|
if (selection.kind === 'sign_in') {
|
|
@@ -293,7 +312,6 @@ export class SqliteCompanyDatabase {
|
|
|
293
312
|
get('signIns', selection.revocationKey);
|
|
294
313
|
}
|
|
295
314
|
if (selection.kind === 'token') {
|
|
296
|
-
get('sessions', selection.sessionId);
|
|
297
315
|
get('codes', selection.codeHash);
|
|
298
316
|
get('refreshTokens', selection.refreshHash);
|
|
299
317
|
for (const key of selection.replayKeys)
|
package/examples/quickstart.mjs
CHANGED
|
@@ -10,11 +10,12 @@ try {
|
|
|
10
10
|
const endpoint = 'https://company.example/conversations';
|
|
11
11
|
const auth = createReferenceIssuer({
|
|
12
12
|
issuer, tokenEndpoint: issuer + '/token', revocationEndpoint: issuer + '/revoke',
|
|
13
|
-
|
|
13
|
+
protectedResources: ['https://company.example'], supportedScopes: [], resources: [endpoint],
|
|
14
14
|
metadata: createMetadataResolver(transport), store: database.issuer(issuer),
|
|
15
15
|
coordinator: database, now: Date.now,
|
|
16
16
|
});
|
|
17
17
|
const conversations = createConversationService({
|
|
18
|
+
historyScopes: ['orders:read'],
|
|
18
19
|
endpoint, store: database.conversations(issuer), policy: auth.authority.policy,
|
|
19
20
|
authenticator: createRequestAuthenticator({ authority: auth.authority,
|
|
20
21
|
endpoints: [{ origin: 'https://company.example', pathPrefix: '/conversations', resource: endpoint }],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppykit/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Personal Agent Protocol company SDK",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=24.
|
|
12
|
+
"node": ">=24.21.0 <25"
|
|
13
13
|
},
|
|
14
14
|
"packageManager": "pnpm@11.25.0",
|
|
15
15
|
"scripts": {
|