@oxdeai/sdk 1.3.3 → 2.0.1

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/CHANGELOG.md CHANGED
@@ -7,6 +7,85 @@ This project follows Semantic Versioning.
7
7
 
8
8
  ---
9
9
 
10
+ ## [2.0.1] - 2026-10-04
11
+
12
+ Dependency release of `@oxdeai/sdk`. It packs against `@oxdeai/core@2.0.1`
13
+ (exact dependency). No SDK source, public API or type declaration change.
14
+
15
+ ### Security
16
+
17
+ - Pins `@oxdeai/core@2.0.1` (GHSA-48xw-c298-546r). Because the SDK re-exports
18
+ `@oxdeai/core`, a `PolicyEngine` imported from `@oxdeai/sdk@2.0.0` is the
19
+ affected `core@2.0.0` engine; upgrade to this release.
20
+
21
+ ## [2.0.0] - 2026-09-25
22
+
23
+ **Baseline for this entry:** the published `@oxdeai/sdk@1.3.3` npm artifact
24
+ (2026-04-23), compared file-by-file against the current candidate.
25
+
26
+ > ⚠️ `1.3.3` was published and then further modified on `main` without a version
27
+ > bump: the published `dist/guard.js` and `dist/client.js` differ from the current
28
+ > source at the same version number. `2.0.0` restores the guarantee that a version
29
+ > identifies an artifact.
30
+
31
+ The SDK's own module list is unchanged. The major is not cosmetic dependency
32
+ tracking — it reflects two real consumer-visible changes plus the re-exported core
33
+ surface.
34
+
35
+ ### Breaking
36
+
37
+ - **`export * from "@oxdeai/core"` re-exports core's 2.0 surface.** Every core
38
+ breaking change is therefore an SDK breaking change for consumers importing
39
+ `PolicyEngine` and friends from `@oxdeai/sdk`. See the `@oxdeai/core` 2.0.0 entry
40
+ — in particular the required `evaluationTime` argument and the now-required
41
+ `maxClockSkewSeconds` / `maxIntentAgeSeconds` engine options.
42
+ - **`Authorization` is replaced by `AuthorizationV1`** in the public type surface of
43
+ `client.d.ts`, `guard.d.ts` and `types.d.ts`. Code that annotated these values with
44
+ the internal `Authorization` type no longer compiles.
45
+
46
+ ### Security hardening
47
+
48
+ - **Verifier time is taken from the trusted clock, never from `intent.timestamp`.**
49
+ Previously `OxDeAIClient.verifyAuthorization` and the SDK guard passed
50
+ `intent.timestamp` as "now". Because that value is proposer-supplied and
51
+ hash-bound into the authorization at issuance, the expiry comparison was pinned to
52
+ issuance time and **the authorization never expired**. Both paths now sample the
53
+ clock boundary once per evaluation and reuse that single sample for the timestamp
54
+ fallback, for `evaluationTime`, and for verification.
55
+
56
+ This changes runtime behaviour for existing callers: artifacts that previously
57
+ verified indefinitely will now correctly be rejected once expired.
58
+
59
+ Note that the SDK clock defaults to `Date.now() / 1000` unless the caller supplies
60
+ an independent `ClockAdapter`. A supplied value is not automatically independently
61
+ trusted time.
62
+
63
+ ### Added
64
+
65
+ - `OxDeAIClient.verifyAuthorization` accepts an optional third argument
66
+ `{ verificationTime?: number }` for callers that already hold a verification time
67
+ from their trusted execution boundary. Additive; existing two-argument calls
68
+ continue to work.
69
+
70
+ ### Changed
71
+
72
+ - `OxDeAIClient.verifyAuthorization` documents that it inherits the **limited scope**
73
+ of `PolicyEngine.verifyAuthorization`: it authenticates only the engine-HMAC field
74
+ subset. Relying parties enforcing an authorization issued by an external party must
75
+ use the strict standalone verifier with explicit `trustedKeySets`.
76
+
77
+ ### Packaging
78
+
79
+ - `license`, `repository` (with `directory`), `homepage` and `bugs` are now declared;
80
+ the published `1.3.3` artifact carried none of them, which blocks npm provenance.
81
+ - `prepack` now rebuilds before packing.
82
+
83
+ ---
84
+
85
+ ## 1.3.3
86
+
87
+ - Fix package publish contents: exclude src and test artifacts from the published tarball.
88
+
10
89
  ## [1.3.2] - 2026-03-30
11
90
 
12
91
  ### Security
package/LICENSE CHANGED
@@ -1,17 +1,213 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
4
5
 
5
- Copyright 2026 OxDeAI
6
-
7
- Licensed under the Apache License, Version 2.0 (the "License");
8
- you may not use this file except in compliance with the License.
9
- You may obtain a copy of the License at
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
10
8
 
9
+ 1. Definitions.
10
+
11
11
  http://www.apache.org/licenses/LICENSE-2.0
12
+ "License" shall mean the terms and conditions for use, reproduction,
13
+ and distribution as defined by Sections 1 through 9 of this document.
14
+
15
+ "Licensor" shall mean the copyright owner or entity authorized by
16
+ the copyright owner that is granting the License.
17
+
18
+ "Legal Entity" shall mean the union of the acting entity and all
19
+ other entities that control, are controlled by, or are under common
20
+ control with that entity. For the purposes of this definition,
21
+ "control" means (i) the power, direct or indirect, to cause the
22
+ direction or management of such entity, whether by contract or
23
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
24
+ outstanding shares, or (iii) beneficial ownership of such entity.
25
+
26
+ "You" (or "Your") shall mean an individual or Legal Entity
27
+ exercising permissions granted by this License.
28
+
29
+ "Source" form shall mean the preferred form for making modifications,
30
+ including but not limited to software source code, documentation
31
+ source, and configuration files.
32
+
33
+ "Object" form shall mean any form resulting from mechanical
34
+ transformation or translation of a Source form, including but
35
+ not limited to compiled object code, generated documentation,
36
+ and conversions to other media types.
37
+
38
+ "Work" shall mean the work of authorship, whether in Source or
39
+ Object form, made available under the License, as indicated by a
40
+ copyright notice that is included in or attached to the work
41
+ (an example is provided in the Appendix below).
42
+
43
+ "Derivative Works" shall mean any work, whether in Source or Object
44
+ form, that is based on (or derived from) the Work and for which the
45
+ editorial revisions, annotations, elaborations, or other modifications
46
+ represent, as a whole, an original work of authorship. For the purposes
47
+ of this License, Derivative Works shall not include works that remain
48
+ separable from, or merely link (or bind by name) to the interfaces of,
49
+ the Work and Derivative Works thereof.
50
+
51
+ "Contribution" shall mean any work of authorship, including
52
+ the original version of the Work and any modifications or additions
53
+ to that Work or Derivative Works thereof, that is intentionally
54
+ submitted to Licensor for inclusion in the Work by the copyright owner
55
+ or by an individual or Legal Entity authorized to submit on behalf of
56
+ the copyright owner. For the purposes of this definition, "submitted"
57
+ means any form of electronic, verbal, or written communication sent
58
+ to the Licensor or its representatives, including but not limited to
59
+ communication on electronic mailing lists, source code control systems,
60
+ and issue tracking systems that are managed by, or on behalf of, the
61
+ Licensor for the purpose of discussing and improving the Work, but
62
+ excluding communication that is conspicuously marked or otherwise
63
+ designated in writing by the copyright owner as "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity
66
+ on behalf of whom a Contribution has been received by Licensor and
67
+ subsequently incorporated within the Work.
68
+
69
+ 2. Grant of Copyright License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ copyright license to reproduce, prepare Derivative Works of,
73
+ publicly display, publicly perform, sublicense, and distribute the
74
+ Work and such Derivative Works in Source or Object form.
75
+
76
+ 3. Grant of Patent License. Subject to the terms and conditions of
77
+ this License, each Contributor hereby grants to You a perpetual,
78
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79
+ (except as stated in this section) patent license to make, have made,
80
+ use, offer to sell, sell, import, and otherwise transfer the Work,
81
+ where such license applies only to those patent claims licensable
82
+ by such Contributor that are necessarily infringed by their
83
+ Contribution(s) alone or by combination of their Contribution(s)
84
+ with the Work to which such Contribution(s) was submitted. If You
85
+ institute patent litigation against any entity (including a
86
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
87
+ or a Contribution incorporated within the Work constitutes direct
88
+ or contributory patent infringement, then any patent licenses
89
+ granted to You under this License for that Work shall terminate
90
+ as of the date such litigation is filed.
91
+
92
+ 4. Redistribution. You may reproduce and distribute copies of the
93
+ Work or Derivative Works thereof in any medium, with or without
94
+ modifications, and in Source or Object form, provided that You
95
+ meet the following conditions:
96
+
97
+ (a) You must give any other recipients of the Work or
98
+ Derivative Works a copy of this License; and
99
+
100
+ (b) You must cause any modified files to carry prominent notices
101
+ stating that You changed the files; and
102
+
103
+ (c) You must retain, in the Source form of any Derivative Works
104
+ that You distribute, all copyright, patent, trademark, and
105
+ attribution notices from the Source form of the Work,
106
+ excluding those notices that do not pertain to any part of
107
+ the Derivative Works; and
108
+
109
+ (d) If the Work includes a "NOTICE" text file as part of its
110
+ distribution, then any Derivative Works that You distribute must
111
+ include a readable copy of the attribution notices contained
112
+ within such NOTICE file, excluding those notices that do not
113
+ pertain to any part of the Derivative Works, in at least one
114
+ of the following places: within a NOTICE text file distributed
115
+ as part of the Derivative Works; within the Source form or
116
+ documentation, if provided along with the Derivative Works; or,
117
+ within a display generated by the Derivative Works, if and
118
+ wherever such third-party notices normally appear. The contents
119
+ of the NOTICE file are for informational purposes only and
120
+ do not modify the License. You may add Your own attribution
121
+ notices within Derivative Works that You distribute, alongside
122
+ or as an addendum to the NOTICE text from the Work, provided
123
+ that such additional attribution notices cannot be construed
124
+ as modifying the License.
125
+
126
+ You may add Your own copyright statement to Your modifications and
127
+ may provide additional or different license terms and conditions
128
+ for use, reproduction, or distribution of Your modifications, or
129
+ for any such Derivative Works as a whole, provided Your use,
130
+ reproduction, and distribution of the Work otherwise complies with
131
+ the conditions stated in this License.
132
+
133
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
134
+ any Contribution intentionally submitted for inclusion in the Work
135
+ by You to the Licensor shall be under the terms and conditions of
136
+ this License, without any additional terms or conditions.
137
+ Notwithstanding the above, nothing herein shall supersede or modify
138
+ the terms of any separate license agreement you may have executed
139
+ with Licensor regarding such Contributions.
140
+
141
+ 6. Trademarks. This License does not grant permission to use the trade
142
+ names, trademarks, service marks, or product names of the Licensor,
143
+ except as required for reasonable and customary use in describing the
144
+ origin of the Work and reproducing the content of the NOTICE file.
145
+
146
+ 7. Disclaimer of Warranty. Unless required by applicable law or
147
+ agreed to in writing, Licensor provides the Work (and each
148
+ Contributor provides its Contributions) on an "AS IS" BASIS,
149
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150
+ implied, including, without limitation, any warranties or conditions
151
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152
+ PARTICULAR PURPOSE. You are solely responsible for determining the
153
+ appropriateness of using or redistributing the Work and assume any
154
+ risks associated with Your exercise of permissions under this License.
155
+
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor be
160
+ liable to You for damages, including any direct, indirect, special,
161
+ incidental, or consequential damages of any character arising as a
162
+ result of this License or out of the use or inability to use the
163
+ Work (including but not limited to damages for loss of goodwill,
164
+ work stoppage, computer failure or malfunction, or any and all
165
+ other commercial damages or losses), even if such Contributor
166
+ has been advised of the possibility of such damages.
167
+
168
+ 9. Accepting Warranty or Additional Liability. While redistributing
169
+ the Work or Derivative Works thereof, You may choose to offer,
170
+ and charge a fee for, acceptance of support, warranty, indemnity,
171
+ or other liability obligations and/or rights consistent with this
172
+ License. However, in accepting such obligations, You may act only
173
+ on Your own behalf and on Your sole responsibility, not on behalf
174
+ of any other Contributor, and only if You agree to indemnify,
175
+ defend, and hold each Contributor harmless for any liability
176
+ incurred by, or claims asserted against, such Contributor by reason
177
+ of your accepting any such warranty or additional liability.
178
+
179
+ END OF TERMS AND CONDITIONS
180
+
181
+ APPENDIX: How to apply the Apache License to your work.
182
+
183
+ To apply the Apache License to your work, attach the following
184
+ boilerplate notice, with the fields enclosed by brackets "[]"
185
+ replaced with your own identifying information. (Don't include
186
+ the brackets!) The text should be enclosed in the appropriate
187
+ comment syntax for the file format. We also recommend that a
188
+ file or class name and description of purpose be included on the
189
+ same "printed page" as the copyright notice for easier
190
+ identification within third-party archives.
191
+
192
+ Copyright [yyyy] [name of copyright owner]
193
+
194
+ Licensed under the Apache License, Version 2.0 (the "License");
195
+ you may not use this file except in compliance with the License.
196
+ You may obtain a copy of the License at
197
+
198
+ http://www.apache.org/licenses/LICENSE-2.0
199
+
200
+ Unless required by applicable law or agreed to in writing, software
201
+ distributed under the License is distributed on an "AS IS" BASIS,
202
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
203
+ See the License for the specific language governing permissions and
204
+ limitations under the License.
205
+
206
+
207
+ OxDeAI
208
+ Copyright 2026 OxDeAI contributors
209
+
210
+ This product includes software developed by the OxDeAI project
211
+ (https://github.com/oxdeai/oxdeai).
212
+
12
213
 
13
- Unless required by applicable law or agreed to in writing, software
14
- distributed under the License is distributed on an "AS IS" BASIS,
15
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- See the License for the specific language governing permissions and
17
- limitations under the License.
package/README.md CHANGED
@@ -1,12 +1,16 @@
1
1
  # @oxdeai/sdk
2
2
  Developer toolkit for the OxDeAI execution-time authorization protocol (ETA).
3
- Builds intents/states and guard boundaries that remain non-bypassable and fail-closed at execution.
3
+ Builds intents/states and guard boundaries that fail closed at execution.
4
4
 
5
5
  ## Status
6
6
 
7
7
  Release policy note: OxDeAI uses package-scoped versions and package-scoped tags. `@oxdeai/sdk` has its own package version line; coordinated release commits do not imply shared package versions across `core`, `sdk`, or `conformance`. See [`docs/release/RELEASE.md`](../../docs/release/RELEASE.md).
8
8
 
9
- Current `@oxdeai/sdk` package line: `1.3.x`.
9
+ Current `@oxdeai/sdk` package line: **2.0.1**. `export * from "@oxdeai/core"`
10
+ re-exports core's 2.0 surface, so every core 2.0 breaking change (in particular
11
+ the required `evaluationTime` argument and the now-required
12
+ `maxClockSkewSeconds` / `maxIntentAgeSeconds` engine options) is a consumer-visible
13
+ change here too. See [`CHANGELOG.md`](./CHANGELOG.md) for the full list.
10
14
 
11
15
  The SDK is an integration surface and does not redefine protocol semantics.
12
16
 
@@ -30,9 +34,10 @@ OxDeAI SDK sits at the runtime integration boundary:
30
34
  Diagram source/editing policy:
31
35
  - [`docs/diagrams/README.md`](../../docs/diagrams/README.md)
32
36
 
33
- ## Guard API (v1.3 adoption layer)
37
+ ## Guard API
34
38
 
35
- The SDK exposes a framework-agnostic guard boundary:
39
+ The SDK exposes its own framework-agnostic guard boundary, built directly on
40
+ `OxDeAIClient`'s in-process `stateAdapter`/`auditAdapter`/`clock`:
36
41
 
37
42
  ```ts
38
43
  const guard = createGuard({ engine, stateAdapter, auditAdapter, clock });
@@ -49,12 +54,27 @@ This keeps PDP/PEP separation explicit:
49
54
  - PDP: `PolicyEngine.evaluatePure(...)` decides
50
55
  - PEP: guard callback boundary enforces execute-or-refuse
51
56
 
57
+ **`createGuard` is not the canonical universal PEP.** It is a convenience
58
+ boundary scoped to the SDK's own in-process adapters, useful for prototypes,
59
+ scripts, and simple single-process integrations. It does not implement
60
+ versioned/CAS state commits, a pluggable replay store, delegation, or trusted
61
+ execution-context provenance reconciliation.
62
+
63
+ **[`@oxdeai/guard`](../guard/README.md) is the dedicated enforcement-boundary
64
+ package for the 2.0 architecture.** `OxDeAIGuard` and the Tier 1
65
+ `createSecureGuard` path are what production deployments should use. It is a
66
+ separate package specifically so that every runtime adapter (LangGraph,
67
+ CrewAI, OpenAI Agents SDK, OpenClaw, custom agents) shares one PEP
68
+ implementation instead of each re-implementing this boundary. Prefer
69
+ `@oxdeai/guard` for anything beyond a single-process prototype; treat the
70
+ SDK's `createGuard` as the lower-level/legacy-compatible path it is.
71
+
52
72
  OxDeAI sits below agent frameworks (OpenAI tools, LangGraph, others) as the deterministic authorization boundary.
53
73
 
54
74
  ## Quick Example
55
75
 
56
76
  ```ts
57
- import { PolicyEngine } from "@oxdeai/core";
77
+ import { PolicyEngine, RECOMMENDED_TRUSTED_TIME_PROFILE } from "@oxdeai/core";
58
78
  import {
59
79
  OxDeAIClient,
60
80
  createGuard,
@@ -67,7 +87,8 @@ import {
67
87
  const engine = new PolicyEngine({
68
88
  policy_version: "v1",
69
89
  engine_secret: "example-secret-must-be-32-chars!",
70
- authorization_ttl_seconds: 120
90
+ authorization_ttl_seconds: 120,
91
+ ...RECOMMENDED_TRUSTED_TIME_PROFILE // maxClockSkewSeconds / maxIntentAgeSeconds: required, no default
71
92
  });
72
93
 
73
94
  const stateAdapter = new InMemoryStateAdapter(
@@ -112,6 +133,29 @@ await guard(intent, async () => {
112
133
  });
113
134
  ```
114
135
 
136
+ ## Verification Time
137
+
138
+ Authorization verification has two clock domains, and they are not interchangeable:
139
+
140
+ | Value | Trust |
141
+ | --- | --- |
142
+ | `intent.timestamp` | Untrusted. Supplied by the agent. |
143
+ | verifier time | Trusted. Supplied by the execution boundary. |
144
+
145
+ The SDK takes verifier time from the trusted `clock` passed to `OxDeAIClient` and `createGuard`,
146
+ never from the intent. A caller that already holds a trusted time from the execution boundary can
147
+ pass it explicitly:
148
+
149
+ ```ts
150
+ await client.verifyAuthorization(intent, authorization, {
151
+ verificationTime: trustedClock.now()
152
+ });
153
+ ```
154
+
155
+ Deriving verifier time from `intent.timestamp` compares an authorization against a deadline the
156
+ same untrusted value produced, so expiry can never be enforced. `clock` defaults to
157
+ `Date.now() / 1000`; supply a `ClockAdapter` when the host has an independently trusted time source.
158
+
115
159
  ## Main Exports
116
160
 
117
161
  - `buildIntent`, `buildState`
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PolicyEngine } from "@oxdeai/core";
2
- import type { Authorization, Intent } from "@oxdeai/core";
2
+ import type { AuthorizationV1, Intent } from "@oxdeai/core";
3
3
  import type { AuditAdapter, ClockAdapter, EvaluateAndCommitResult, StateAdapter, VerifyBundleResult } from "./types.js";
4
4
  type ClientOptions = {
5
5
  engine: PolicyEngine;
@@ -18,7 +18,24 @@ export declare class OxDeAIClient {
18
18
  private auditCursor;
19
19
  constructor(opts: ClientOptions);
20
20
  evaluateAndCommit(input: EvaluateInput): Promise<EvaluateAndCommitResult>;
21
- verifyAuthorization(intent: Intent, authorization: Authorization): Promise<{
21
+ /**
22
+ * Verifies an authorization against a trusted verification time.
23
+ *
24
+ * Verifier time is taken from the client's trusted clock boundary, or from an
25
+ * explicit `verificationTime` when the caller already holds one from the trusted
26
+ * execution boundary. It is never derived from `intent.timestamp`: that value is
27
+ * attacker-supplied and is hash-bound into the authorization at issuance, so using
28
+ * it as "now" pins the expiry comparison to issuance time and the authorization
29
+ * never expires.
30
+ *
31
+ * ⚠️ Inherits the LIMITED SCOPE of `PolicyEngine.verifyAuthorization` — it
32
+ * authenticates only the engine-HMAC field subset. Relying parties enforcing an
33
+ * authorization issued by an external party must use the strict standalone
34
+ * verifier with explicit `trustedKeySets` instead.
35
+ */
36
+ verifyAuthorization(intent: Intent, authorization: AuthorizationV1, opts?: {
37
+ verificationTime?: number;
38
+ }): Promise<{
22
39
  valid: boolean;
23
40
  reason?: string;
24
41
  }>;
package/dist/client.js CHANGED
@@ -19,14 +19,24 @@ export class OxDeAIClient {
19
19
  }
20
20
  async evaluateAndCommit(input) {
21
21
  const state = await this.stateAdapter.load();
22
+ // Single clock sample, reused for both the timestamp fallback below and
23
+ // evaluationTime — the trusted-time freshness gate requires evaluationTime
24
+ // to be sampled exactly once per evaluation (spec §2.1), and this.clock is
25
+ // the same trusted-context boundary already responsible for the timestamp
26
+ // fallback. Never derived from intent.timestamp itself (which may be
27
+ // attacker-supplied via `input.timestamp`). Note: this.clock defaults to
28
+ // Date.now()/1000 unless the caller supplies an independent ClockAdapter;
29
+ // an explicitly supplied value here is not necessarily independently
30
+ // trusted time.
31
+ const evaluationTime = this.clock.now();
22
32
  const resolvedTimestamp = input.timestamp === undefined || input.timestamp === 0
23
- ? this.clock.now()
33
+ ? evaluationTime
24
34
  : input.timestamp;
25
35
  const intent = {
26
36
  ...input,
27
37
  timestamp: resolvedTimestamp
28
38
  };
29
- const out = this.engine.evaluatePure(intent, state, { mode: "fail-fast" });
39
+ const out = this.engine.evaluatePure(intent, state, evaluationTime, { mode: "fail-fast" });
30
40
  const emitted = collectNewEvents(this.engine, this.auditCursor);
31
41
  this.auditCursor = emitted.nextCursor;
32
42
  if (this.auditAdapter)
@@ -46,9 +56,28 @@ export class OxDeAIClient {
46
56
  };
47
57
  return { output, state, auditEvents: emitted.events };
48
58
  }
49
- async verifyAuthorization(intent, authorization) {
59
+ /**
60
+ * Verifies an authorization against a trusted verification time.
61
+ *
62
+ * Verifier time is taken from the client's trusted clock boundary, or from an
63
+ * explicit `verificationTime` when the caller already holds one from the trusted
64
+ * execution boundary. It is never derived from `intent.timestamp`: that value is
65
+ * attacker-supplied and is hash-bound into the authorization at issuance, so using
66
+ * it as "now" pins the expiry comparison to issuance time and the authorization
67
+ * never expires.
68
+ *
69
+ * ⚠️ Inherits the LIMITED SCOPE of `PolicyEngine.verifyAuthorization` — it
70
+ * authenticates only the engine-HMAC field subset. Relying parties enforcing an
71
+ * authorization issued by an external party must use the strict standalone
72
+ * verifier with explicit `trustedKeySets` instead.
73
+ */
74
+ async verifyAuthorization(intent, authorization, opts) {
50
75
  const state = await this.stateAdapter.load();
51
- const result = this.engine.verifyAuthorization(intent, authorization, state, intent.timestamp);
76
+ const verificationTime = opts?.verificationTime ?? this.clock.now();
77
+ // Cast as Authorization: internal engine.verifyAuthorization() uses legacy fields
78
+ // (engine_signature, state_snapshot_hash) for HMAC binding verification.
79
+ // Authorization objects returned by evaluatePure() retain these at runtime.
80
+ const result = this.engine.verifyAuthorization(intent, authorization, state, verificationTime);
52
81
  return result.valid ? { valid: true } : { valid: false, reason: result.reason };
53
82
  }
54
83
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,cAAc,EACf,MAAM,cAAc,CAAC;AAqBtB,SAAS,gBAAgB,CAAC,MAAoB,EAAE,MAAc;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAe,CAAC;IACjD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,OAAO,YAAY;IACN,MAAM,CAAe;IACrB,YAAY,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rE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3E,MAAM,QAAQ,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;QAE/C,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAoD,EAAE;YACpF,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,aAAa;SAClC,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,cAAc,CAAC;YACnC,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,aAAa;YACvB,MAAM,EAAE,SAAgB;SACzB,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,cAAc,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC;QACtF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IACvC,CAAC;CACF"}
package/dist/guard.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { Intent, PolicyEngine, State, Authorization } from "@oxdeai/core";
1
+ import type { Intent, PolicyEngine, State, AuthorizationV1 } from "@oxdeai/core";
2
2
  import type { AuditAdapter, ClockAdapter, MaybePromise, StateAdapter, IntentBuilderInput } from "./types.js";
3
3
  export type GuardDecision = {
4
4
  decision: "ALLOW";
5
5
  reasons: [];
6
- authorization: Authorization;
6
+ authorization: AuthorizationV1;
7
7
  } | {
8
8
  decision: "DENY";
9
9
  reasons: string[];
@@ -12,7 +12,7 @@ export type GuardAllowResult<T> = {
12
12
  output: GuardDecision & {
13
13
  decision: "ALLOW";
14
14
  reasons: [];
15
- authorization: Authorization;
15
+ authorization: AuthorizationV1;
16
16
  };
17
17
  intent: Intent;
18
18
  state: State;
@@ -48,7 +48,7 @@ export type GuardOptions = {
48
48
  };
49
49
  type GuardExecuteContext = {
50
50
  intent: Intent;
51
- authorization: Authorization;
51
+ authorization: AuthorizationV1;
52
52
  state: State;
53
53
  };
54
54
  export type GuardFn = <T>(input: GuardInputIntent, execute: (ctx: GuardExecuteContext) => MaybePromise<T>) => Promise<GuardResult<T>>;
package/dist/guard.js CHANGED
@@ -22,16 +22,25 @@ export function createGuard(opts) {
22
22
  let auditCursor = 0;
23
23
  return async function guard(input, execute) {
24
24
  const state = await opts.stateAdapter.load();
25
+ // Single clock sample, reused for both the timestamp fallback below and
26
+ // evaluationTime — the trusted-time freshness gate requires evaluationTime
27
+ // to be sampled exactly once per evaluation (spec §2.1), and clock is the
28
+ // same trusted-context boundary already responsible for the timestamp
29
+ // fallback. Never derived from intent.timestamp itself (which may be
30
+ // attacker-supplied). Note: clock defaults to Date.now()/1000 unless the
31
+ // caller supplies an independent ClockAdapter; an explicitly supplied
32
+ // value here is not necessarily independently trusted time.
33
+ const evaluationTime = clock.now();
25
34
  const intent = isIntent(input)
26
35
  ? {
27
36
  ...input,
28
- timestamp: input.timestamp === 0 ? clock.now() : input.timestamp,
37
+ timestamp: input.timestamp === 0 ? evaluationTime : input.timestamp,
29
38
  }
30
39
  : buildIntent({
31
40
  ...input,
32
- timestamp: input.timestamp ?? clock.now(),
41
+ timestamp: input.timestamp ?? evaluationTime,
33
42
  });
34
- const out = opts.engine.evaluatePure(intent, state, { mode: opts.mode ?? "fail-fast" });
43
+ const out = opts.engine.evaluatePure(intent, state, evaluationTime, { mode: opts.mode ?? "fail-fast" });
35
44
  const emitted = collectNewEvents(opts.engine, auditCursor);
36
45
  auditCursor = emitted.nextCursor;
37
46
  if (opts.auditAdapter)
@@ -55,7 +64,12 @@ export function createGuard(opts) {
55
64
  };
56
65
  }
57
66
  if (opts.verifyAuthorization !== false) {
58
- const authCheck = opts.engine.verifyAuthorization(intent, out.authorization, out.nextState, intent.timestamp);
67
+ // Cast as Authorization: runtime object retains internal engine fields even
68
+ // though the TypeScript type was narrowed to AuthorizationV1 at the evaluatePure boundary.
69
+ // Verifier time is the single trusted `evaluationTime` sample taken above, never
70
+ // intent.timestamp — that value is attacker-supplied, so reading it as "now" would
71
+ // let the intent decide whether its own authorization has expired.
72
+ const authCheck = opts.engine.verifyAuthorization(intent, out.authorization, out.nextState, evaluationTime);
59
73
  if (!authCheck.valid) {
60
74
  return {
61
75
  output: { decision: "DENY", reasons: [`AUTH_INVALID:${authCheck.reason ?? "unknown"}`] },
package/dist/guard.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgD5C,SAAS,gBAAgB,CAAC,MAAoB,EAAE,MAAc;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAe,CAAC;IACjD,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAuB;IACvC,OAAO,CACL,OAAQ,KAAgB,CAAC,SAAS,KAAK,QAAQ;QAC/C,OAAQ,KAAgB,CAAC,QAAQ,KAAK,QAAQ;QAC9C,OAAQ,KAAgB,CAAC,WAAW,KAAK,QAAQ;QACjD,OAAQ,KAAgB,CAAC,SAAS,KAAK,QAAQ,CAChD,CAAC;AACJ,CAAC;AAOD;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,IAAkB;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACzE,IAAI,WAAW,GAAG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AmB,KAAK,KAAK,EAAE,CAAC;YACvC,4EAA4E;YAC5E,2FAA2F;YAC3F,iFAAiF;YACjF,mFAAmF;YACnF,mEAAmE;YACnE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,aAA8B,EAAE,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;YAC7H,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;gBACrB,OAAO;oBACL,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,gBAAgB,SAAS,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,EAAE;oBACxF,MAAM;oBACN,KAAK;oBACL,WAAW,EAAE,OAAO,CAAC,MAAM;oBAC3B,QAAQ,EAAE,KAAK;iBAChB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC;YACpC,MAAM;YACN,aAAa,EAAE,GAAG,CAAC,aAAa;YAChC,KAAK,EAAE,GAAG,CAAC,SAAS;SACrB,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE5C,OAAO;YACL,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE;YAC5E,MAAM;YACN,KAAK,EAAE,GAAG,CAAC,SAAS;YACpB,WAAW,EAAE,OAAO,CAAC,MAAM;YAC3B,QAAQ,EAAE,IAAI;YACd,eAAe;SAChB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { Authorization, Intent, State, VerificationResult } from "@oxdeai/core";
1
+ import type { AuthorizationV1, Intent, State, VerificationResult } from "@oxdeai/core";
2
2
  export type MaybePromise<T> = T | Promise<T>;
3
3
  export type EvaluateDecision = {
4
4
  decision: "ALLOW";
5
5
  reasons: [];
6
- authorization: Authorization;
6
+ authorization: AuthorizationV1;
7
7
  } | {
8
8
  decision: "DENY";
9
9
  reasons: string[];
package/package.json CHANGED
@@ -1,21 +1,33 @@
1
1
  {
2
2
  "name": "@oxdeai/sdk",
3
- "version": "1.3.3",
3
+ "version": "2.0.1",
4
+ "license": "Apache-2.0",
4
5
  "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
- "dependencies": {
8
- "@oxdeai/core": "1.7.0"
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/oxdeai/oxdeai.git",
11
+ "directory": "packages/sdk"
12
+ },
13
+ "homepage": "https://github.com/oxdeai/oxdeai",
14
+ "bugs": {
15
+ "url": "https://github.com/oxdeai/oxdeai/issues"
9
16
  },
10
17
  "files": [
11
18
  "dist",
19
+ "!dist/**/*.test.*",
12
20
  "README.md",
13
21
  "CHANGELOG.md",
14
22
  "LICENSE"
15
23
  ],
24
+ "dependencies": {
25
+ "@oxdeai/core": "2.0.1"
26
+ },
16
27
  "scripts": {
17
28
  "typecheck": "tsc -p tsconfig.json --noEmit",
18
29
  "build": "rm -rf dist && tsc -p tsconfig.json",
19
- "test": "pnpm build && node --test \"dist/**/*.test.js\""
30
+ "build:test": "rm -rf dist && tsc -p tsconfig.test.json",
31
+ "test": "pnpm build:test && node --test \"dist/**/*.test.js\""
20
32
  }
21
33
  }