ccp-core 0.4.0 → 0.5.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/README.md +2 -2
- package/dist/decision.d.ts +2 -1
- package/dist/decision.js +7 -2
- package/dist/requester.js +1 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The TypeScript implementation of the Capability Contacts Protocol (draft
|
|
4
4
|
v0.4), shaped by role: **Requester**, **Consumer**, **Runtime**, **Agent**.
|
|
5
|
-
It reproduces
|
|
5
|
+
It reproduces the frozen v1, v2, and v3 vectors in `../../test-vectors/`.
|
|
6
6
|
|
|
7
7
|
Runs in browsers and Node (no Node-only APIs in `src/`).
|
|
8
8
|
|
|
@@ -282,6 +282,6 @@ Runnable examples: `examples/provider-node/` (HTTP provider) and
|
|
|
282
282
|
## Tests
|
|
283
283
|
|
|
284
284
|
```sh
|
|
285
|
-
npx vitest run #
|
|
285
|
+
npx vitest run # v1/v2/v3 vectors + role unit tests
|
|
286
286
|
npx tsc --noEmit # typecheck
|
|
287
287
|
```
|
package/dist/decision.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export interface DecisionContext {
|
|
|
7
7
|
counters: Record<string, number>;
|
|
8
8
|
intentSpec: any | null;
|
|
9
9
|
paramsSchema: any | null;
|
|
10
|
-
supportedCcp?: string;
|
|
10
|
+
supportedCcp?: string | readonly string[];
|
|
11
11
|
}
|
|
12
|
+
export declare const DEFAULT_SUPPORTED_CCP: readonly ["0.5-draft", "0.4-draft"];
|
|
12
13
|
/**
|
|
13
14
|
* The pure §10.3 decision. Returns `authorized`,
|
|
14
15
|
* `confirmation_required`, or a rejection code.
|
package/dist/decision.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { isValid } from "./schema.js";
|
|
2
|
+
export const DEFAULT_SUPPORTED_CCP = ["0.5-draft", "0.4-draft"];
|
|
3
|
+
function isSupported(value, supported) {
|
|
4
|
+
const labels = typeof supported === "string" ? [supported] : supported;
|
|
5
|
+
return typeof value === "string" && labels.includes(value);
|
|
6
|
+
}
|
|
2
7
|
/**
|
|
3
8
|
* The pure §10.3 decision. Returns `authorized`,
|
|
4
9
|
* `confirmation_required`, or a rejection code.
|
|
5
10
|
*/
|
|
6
11
|
export function decide(ctx) {
|
|
7
12
|
const { grant, signal, signer, now, seen, counters } = ctx;
|
|
8
|
-
const supported = ctx.supportedCcp ??
|
|
9
|
-
if (signal.ccp
|
|
13
|
+
const supported = ctx.supportedCcp ?? DEFAULT_SUPPORTED_CCP;
|
|
14
|
+
if (!isSupported(signal.ccp, supported))
|
|
10
15
|
return "invalid_request";
|
|
11
16
|
if (grant === null || grant === undefined)
|
|
12
17
|
return "no_matching_grant";
|
package/dist/requester.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { signDocument } from "./signing.js";
|
|
2
2
|
import { keyIdFromPublic, publicFromSeed } from "./crypto.js";
|
|
3
|
-
const DEFAULT_CCP = "0.
|
|
3
|
+
const DEFAULT_CCP = "0.5-draft";
|
|
4
4
|
export function buildManifest(input) {
|
|
5
5
|
const provider = { id: input.provider.id };
|
|
6
6
|
if (input.provider.name !== undefined)
|
package/dist/runtime.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface RuntimeOptions {
|
|
|
46
46
|
hosts?: HostRegistry;
|
|
47
47
|
audit?: AuditStore;
|
|
48
48
|
clock?: () => string;
|
|
49
|
-
supportedCcp?: string;
|
|
49
|
+
supportedCcp?: string | readonly string[];
|
|
50
50
|
}
|
|
51
51
|
export declare class Runtime {
|
|
52
52
|
readonly grants: GrantStore;
|
|
@@ -55,7 +55,7 @@ export declare class Runtime {
|
|
|
55
55
|
readonly hosts: HostRegistry;
|
|
56
56
|
readonly audit: AuditStore;
|
|
57
57
|
readonly clock: () => string;
|
|
58
|
-
readonly supportedCcp: string;
|
|
58
|
+
readonly supportedCcp: string | readonly string[];
|
|
59
59
|
readonly replay: ReplayStore;
|
|
60
60
|
readonly limits: LimitStore;
|
|
61
61
|
readonly pendingStore: PendingStore;
|
package/dist/runtime.js
CHANGED
|
@@ -83,7 +83,7 @@ export class Runtime {
|
|
|
83
83
|
this.hosts = options.hosts ?? new HostRegistry();
|
|
84
84
|
this.audit = options.audit ?? new MemoryAuditLog();
|
|
85
85
|
this.clock = options.clock ?? utcnow;
|
|
86
|
-
this.supportedCcp = options.supportedCcp ?? "0.4-draft";
|
|
86
|
+
this.supportedCcp = options.supportedCcp ?? ["0.5-draft", "0.4-draft"];
|
|
87
87
|
this.replay = options.replay ?? new MemoryReplayStore();
|
|
88
88
|
this.limits = options.limits ?? new MemoryLimitStore();
|
|
89
89
|
this.pendingStore = options.pending ?? new MemoryPendingStore();
|