open-action-consent 0.2.0__tar.gz
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.
- open_action_consent-0.2.0/LICENSE +202 -0
- open_action_consent-0.2.0/NOTICE +5 -0
- open_action_consent-0.2.0/PKG-INFO +66 -0
- open_action_consent-0.2.0/README.md +24 -0
- open_action_consent-0.2.0/pyproject.toml +46 -0
- open_action_consent-0.2.0/setup.cfg +4 -0
- open_action_consent-0.2.0/src/oac/__init__.py +41 -0
- open_action_consent-0.2.0/src/oac/approver/__init__.py +146 -0
- open_action_consent-0.2.0/src/oac/approver/page.js +88 -0
- open_action_consent-0.2.0/src/oac/browser/__init__.py +279 -0
- open_action_consent-0.2.0/src/oac/browser/__main__.py +41 -0
- open_action_consent-0.2.0/src/oac/conformance.py +141 -0
- open_action_consent-0.2.0/src/oac/consent.py +151 -0
- open_action_consent-0.2.0/src/oac/discovery.py +64 -0
- open_action_consent-0.2.0/src/oac/errors.py +74 -0
- open_action_consent-0.2.0/src/oac/gate.py +174 -0
- open_action_consent-0.2.0/src/oac/jcs.py +108 -0
- open_action_consent-0.2.0/src/oac/jws.py +216 -0
- open_action_consent-0.2.0/src/oac/langgraph/__init__.py +43 -0
- open_action_consent-0.2.0/src/oac/mandate.py +157 -0
- open_action_consent-0.2.0/src/oac/mcp/__init__.py +212 -0
- open_action_consent-0.2.0/src/oac/openai_agents/__init__.py +104 -0
- open_action_consent-0.2.0/src/oac/preview.py +81 -0
- open_action_consent-0.2.0/src/oac/receipts.py +96 -0
- open_action_consent-0.2.0/src/oac/shapes.py +382 -0
- open_action_consent-0.2.0/src/oac/status.py +77 -0
- open_action_consent-0.2.0/src/oac/testing.py +13 -0
- open_action_consent-0.2.0/src/oac/tiers.py +41 -0
- open_action_consent-0.2.0/src/oac/undo.py +105 -0
- open_action_consent-0.2.0/src/open_action_consent.egg-info/PKG-INFO +66 -0
- open_action_consent-0.2.0/src/open_action_consent.egg-info/SOURCES.txt +36 -0
- open_action_consent-0.2.0/src/open_action_consent.egg-info/dependency_links.txt +1 -0
- open_action_consent-0.2.0/src/open_action_consent.egg-info/entry_points.txt +2 -0
- open_action_consent-0.2.0/src/open_action_consent.egg-info/requires.txt +30 -0
- open_action_consent-0.2.0/src/open_action_consent.egg-info/top_level.txt +1 -0
- open_action_consent-0.2.0/tests/test_conformance.py +64 -0
- open_action_consent-0.2.0/tests/test_gate.py +69 -0
- open_action_consent-0.2.0/tests/test_unit.py +133 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
https://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open-action-consent
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Open Action Consent: a verifiable yes for actions AI agents take for people. Core SDK plus MCP, browser, approval page, OpenAI Agents and LangGraph integrations.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/Ishan2036924/open-action-consent
|
|
7
|
+
Project-URL: Specification, https://github.com/Ishan2036924/open-action-consent/blob/main/spec/oac-v0.1.md
|
|
8
|
+
Keywords: ai-agents,consent,mcp,agent-payments,jws,open-standard
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Security :: Cryptography
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
License-File: NOTICE
|
|
18
|
+
Requires-Dist: cryptography>=42
|
|
19
|
+
Provides-Extra: mcp
|
|
20
|
+
Requires-Dist: mcp<3,>=2.3; extra == "mcp"
|
|
21
|
+
Provides-Extra: browser
|
|
22
|
+
Requires-Dist: mcp<3,>=2.3; extra == "browser"
|
|
23
|
+
Requires-Dist: playwright>=1.50; extra == "browser"
|
|
24
|
+
Provides-Extra: approver
|
|
25
|
+
Requires-Dist: starlette>=0.40; extra == "approver"
|
|
26
|
+
Requires-Dist: uvicorn>=0.30; extra == "approver"
|
|
27
|
+
Provides-Extra: openai-agents
|
|
28
|
+
Requires-Dist: openai-agents<0.30,>=0.24; extra == "openai-agents"
|
|
29
|
+
Provides-Extra: langgraph
|
|
30
|
+
Requires-Dist: langgraph<2,>=1.2; extra == "langgraph"
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: mcp<3,>=2.3; extra == "all"
|
|
33
|
+
Requires-Dist: playwright>=1.50; extra == "all"
|
|
34
|
+
Requires-Dist: starlette>=0.40; extra == "all"
|
|
35
|
+
Requires-Dist: uvicorn>=0.30; extra == "all"
|
|
36
|
+
Requires-Dist: openai-agents<0.30,>=0.24; extra == "all"
|
|
37
|
+
Requires-Dist: langgraph<2,>=1.2; extra == "all"
|
|
38
|
+
Provides-Extra: test
|
|
39
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
40
|
+
Requires-Dist: anyio>=4; extra == "test"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# open-action-consent (Python)
|
|
44
|
+
|
|
45
|
+
**A verifiable "yes" for things AI agents do for people.** Before an agent sends, books, pays or deletes, the tool
|
|
46
|
+
shows a Preview of exactly what will happen; the person signs a Consent over it; the action runs only if the signature
|
|
47
|
+
and the limits check out; a signed Receipt says what ran and how to undo it.
|
|
48
|
+
Spec and source: <https://github.com/Ishan2036924/open-action-consent>
|
|
49
|
+
|
|
50
|
+
## Everything in this one package
|
|
51
|
+
|
|
52
|
+
| Part | Install | Use | Guide |
|
|
53
|
+
|---|---|---|---|
|
|
54
|
+
| Core: previews, consents, mandates, receipts, undo, status lists, key discovery, `Gate` | `pip install open-action-consent` | `import oac` | [README](https://github.com/Ishan2036924/open-action-consent#readme) |
|
|
55
|
+
| MCP servers (official MCP Python SDK, protocol 2026-07-28) | `pip install "open-action-consent[mcp]"` | `from oac.mcp import OACExtension` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/mcp-python.md) |
|
|
56
|
+
| Gated Browser (stops before every final click) | `pip install "open-action-consent[browser]"` then `playwright install chromium` | `oac-gated-browser` or `from oac.browser import build_server` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/gated-browser.md) |
|
|
57
|
+
| Approval page (the person's key stays in their browser) | `pip install "open-action-consent[approver]"` | `from oac.approver import Approver` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/approver.md) |
|
|
58
|
+
| OpenAI Agents SDK | `pip install "open-action-consent[openai-agents]"` | `from oac.openai_agents import oac_tool` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/openai-agents.md) |
|
|
59
|
+
| LangGraph | `pip install "open-action-consent[langgraph]"` | `from oac.langgraph import gated` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/langgraph.md) |
|
|
60
|
+
| All of the above | `pip install "open-action-consent[all]"` | | |
|
|
61
|
+
|
|
62
|
+
The core needs only `cryptography`. Each part pulls in its framework only when you install that option; importing a
|
|
63
|
+
part without it tells you exactly what to install. JavaScript/TypeScript: `npm install open-action-consent`.
|
|
64
|
+
|
|
65
|
+
Tests: `python -m pytest -q` (from this folder); conformance: `PYTHONPATH=src python -m oac.conformance ../../vectors`.
|
|
66
|
+
License: Apache-2.0 (code), CC BY 4.0 (spec text).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# open-action-consent (Python)
|
|
2
|
+
|
|
3
|
+
**A verifiable "yes" for things AI agents do for people.** Before an agent sends, books, pays or deletes, the tool
|
|
4
|
+
shows a Preview of exactly what will happen; the person signs a Consent over it; the action runs only if the signature
|
|
5
|
+
and the limits check out; a signed Receipt says what ran and how to undo it.
|
|
6
|
+
Spec and source: <https://github.com/Ishan2036924/open-action-consent>
|
|
7
|
+
|
|
8
|
+
## Everything in this one package
|
|
9
|
+
|
|
10
|
+
| Part | Install | Use | Guide |
|
|
11
|
+
|---|---|---|---|
|
|
12
|
+
| Core: previews, consents, mandates, receipts, undo, status lists, key discovery, `Gate` | `pip install open-action-consent` | `import oac` | [README](https://github.com/Ishan2036924/open-action-consent#readme) |
|
|
13
|
+
| MCP servers (official MCP Python SDK, protocol 2026-07-28) | `pip install "open-action-consent[mcp]"` | `from oac.mcp import OACExtension` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/mcp-python.md) |
|
|
14
|
+
| Gated Browser (stops before every final click) | `pip install "open-action-consent[browser]"` then `playwright install chromium` | `oac-gated-browser` or `from oac.browser import build_server` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/gated-browser.md) |
|
|
15
|
+
| Approval page (the person's key stays in their browser) | `pip install "open-action-consent[approver]"` | `from oac.approver import Approver` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/approver.md) |
|
|
16
|
+
| OpenAI Agents SDK | `pip install "open-action-consent[openai-agents]"` | `from oac.openai_agents import oac_tool` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/openai-agents.md) |
|
|
17
|
+
| LangGraph | `pip install "open-action-consent[langgraph]"` | `from oac.langgraph import gated` | [guide](https://github.com/Ishan2036924/open-action-consent/blob/main/guides/langgraph.md) |
|
|
18
|
+
| All of the above | `pip install "open-action-consent[all]"` | | |
|
|
19
|
+
|
|
20
|
+
The core needs only `cryptography`. Each part pulls in its framework only when you install that option; importing a
|
|
21
|
+
part without it tells you exactly what to install. JavaScript/TypeScript: `npm install open-action-consent`.
|
|
22
|
+
|
|
23
|
+
Tests: `python -m pytest -q` (from this folder); conformance: `PYTHONPATH=src python -m oac.conformance ../../vectors`.
|
|
24
|
+
License: Apache-2.0 (code), CC BY 4.0 (spec text).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "open-action-consent"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Open Action Consent: a verifiable yes for actions AI agents take for people. Core SDK plus MCP, browser, approval page, OpenAI Agents and LangGraph integrations."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = ["ai-agents", "consent", "mcp", "agent-payments", "jws", "open-standard"]
|
|
13
|
+
dependencies = ["cryptography>=42"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Security :: Cryptography",
|
|
19
|
+
"Topic :: Software Development :: Libraries",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
mcp = ["mcp>=2.3,<3"]
|
|
24
|
+
browser = ["mcp>=2.3,<3", "playwright>=1.50"]
|
|
25
|
+
approver = ["starlette>=0.40", "uvicorn>=0.30"]
|
|
26
|
+
openai-agents = ["openai-agents>=0.24,<0.30"]
|
|
27
|
+
langgraph = ["langgraph>=1.2,<2"]
|
|
28
|
+
all = ["mcp>=2.3,<3", "playwright>=1.50", "starlette>=0.40", "uvicorn>=0.30", "openai-agents>=0.24,<0.30", "langgraph>=1.2,<2"]
|
|
29
|
+
test = ["pytest>=8", "anyio>=4"]
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
oac-gated-browser = "oac.browser.__main__:main"
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/Ishan2036924/open-action-consent"
|
|
36
|
+
Specification = "https://github.com/Ishan2036924/open-action-consent/blob/main/spec/oac-v0.1.md"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["src"]
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.package-data]
|
|
42
|
+
oac = ["approver/page.js"]
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
pythonpath = ["src"]
|
|
46
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""OAC (Open Action Consent) v0.1 reference SDK: previews, signed consents, mandates, receipts and undo for actions
|
|
2
|
+
agents take for people. Spec: spec/oac-v0.1.md."""
|
|
3
|
+
|
|
4
|
+
from oac.consent import MemoryNonces, make_consent, verify_consent
|
|
5
|
+
from oac.errors import CODES, OACError
|
|
6
|
+
from oac.jcs import canonical, parse
|
|
7
|
+
from oac.jws import KeySet, SigningKey, digest, generate, sign, token_digest, verify
|
|
8
|
+
from oac.mandate import check_mandate, loosens, make_mandate
|
|
9
|
+
from oac.preview import action_digest, build_preview, check_binding
|
|
10
|
+
from oac.receipts import make_receipt, verify_chain
|
|
11
|
+
from oac.tiers import tier_for
|
|
12
|
+
from oac.undo import check_undo, make_undo
|
|
13
|
+
|
|
14
|
+
__version__ = "0.2.0"
|
|
15
|
+
__all__ = [
|
|
16
|
+
"CODES",
|
|
17
|
+
"KeySet",
|
|
18
|
+
"MemoryNonces",
|
|
19
|
+
"OACError",
|
|
20
|
+
"SigningKey",
|
|
21
|
+
"action_digest",
|
|
22
|
+
"build_preview",
|
|
23
|
+
"canonical",
|
|
24
|
+
"check_binding",
|
|
25
|
+
"check_mandate",
|
|
26
|
+
"check_undo",
|
|
27
|
+
"digest",
|
|
28
|
+
"generate",
|
|
29
|
+
"loosens",
|
|
30
|
+
"make_consent",
|
|
31
|
+
"make_mandate",
|
|
32
|
+
"make_receipt",
|
|
33
|
+
"make_undo",
|
|
34
|
+
"parse",
|
|
35
|
+
"sign",
|
|
36
|
+
"tier_for",
|
|
37
|
+
"token_digest",
|
|
38
|
+
"verify",
|
|
39
|
+
"verify_chain",
|
|
40
|
+
"verify_consent",
|
|
41
|
+
]
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""OAC Approver: a small self-hostable approval page where a person approves (or declines) an agent's action.
|
|
2
|
+
|
|
3
|
+
The person's key never leaves their browser: it is a non-extractable WebCrypto P-256 key (OAC `signer.kind`
|
|
4
|
+
"device"), created at enrolment with a one-time code. The page shows the Preview (summary, every field and detail,
|
|
5
|
+
whether it can be undone, the cancellation policy), and on Approve the browser itself signs the Consent JWS and posts
|
|
6
|
+
it here; the Approver checks it and hands it to the executor through `deliver`. It also publishes the person's
|
|
7
|
+
public keys as issuer metadata (spec 3.5) so executors can find them.
|
|
8
|
+
|
|
9
|
+
from oac.approver import Approver
|
|
10
|
+
|
|
11
|
+
approver = Approver(issuer="https://approve.example", person="person:1",
|
|
12
|
+
previews=lambda preview_id: executor.preview(preview_id),
|
|
13
|
+
deliver=lambda token: executor.accept_consent(token))
|
|
14
|
+
app = approver.app() # a Starlette app; serve it with uvicorn behind HTTPS
|
|
15
|
+
|
|
16
|
+
0.1 limits: one person per Approver; in-memory state; no payment references in Consents (a pay action needs the
|
|
17
|
+
rail's reference, which this page does not collect yet).
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import hmac
|
|
23
|
+
import secrets
|
|
24
|
+
from collections.abc import Callable, Mapping
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from typing import Any
|
|
27
|
+
from urllib.parse import urlsplit
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
from starlette.applications import Starlette
|
|
31
|
+
from starlette.requests import Request
|
|
32
|
+
from starlette.responses import HTMLResponse, JSONResponse, Response
|
|
33
|
+
from starlette.routing import Route
|
|
34
|
+
except ImportError as e: # the optional dependency is not installed
|
|
35
|
+
raise ImportError('oac.approver needs Starlette: pip install "open-action-consent[approver]"') from e
|
|
36
|
+
|
|
37
|
+
from oac import KeySet, OACError, digest, shapes, verify
|
|
38
|
+
from oac.discovery import metadata_url
|
|
39
|
+
|
|
40
|
+
PAGE_JS = (Path(__file__).parent / "page.js").read_text()
|
|
41
|
+
CSP = "default-src 'none'; script-src 'self'; connect-src 'self'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'"
|
|
42
|
+
STYLE = ("body{font:16px -apple-system,Segoe UI,sans-serif;max-width:560px;margin:40px auto;padding:0 16px;color:#111}"
|
|
43
|
+
"td{padding:6px 10px;border-bottom:1px solid #eee;vertical-align:top}button{font-size:16px;padding:10px 18px;margin-right:8px}"
|
|
44
|
+
"#status{margin-top:16px;color:#374151}")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _page(title: str, body: str, start: str) -> HTMLResponse:
|
|
48
|
+
html = (f"<!doctype html><html><head><meta charset=utf-8><meta name=viewport content='width=device-width'>"
|
|
49
|
+
f"<title>{title}</title><style>{STYLE}</style></head><body>{body}<p id=status></p>"
|
|
50
|
+
f"<script src='page.js'></script><script src='start-{start}.js'></script></body></html>")
|
|
51
|
+
return HTMLResponse(html, headers={"Content-Security-Policy": CSP, "X-Frame-Options": "DENY", "Referrer-Policy": "no-referrer",
|
|
52
|
+
"Cache-Control": "no-store"})
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Approver:
|
|
56
|
+
def __init__(self, *, issuer: str, person: str, previews: Callable[[str], Mapping[str, Any] | None],
|
|
57
|
+
deliver: Callable[[str], bool], enrollment_code: str | None = None) -> None:
|
|
58
|
+
self.issuer, self.person, self._previews, self._deliver = issuer, person, previews, deliver
|
|
59
|
+
self.enrollment_code = enrollment_code or secrets.token_urlsafe(9)
|
|
60
|
+
self._code_used = False
|
|
61
|
+
self.keys: list[dict[str, Any]] = []
|
|
62
|
+
self.declined: list[str] = []
|
|
63
|
+
self.well_known_path = urlsplit(metadata_url(issuer)).path
|
|
64
|
+
|
|
65
|
+
def metadata(self) -> dict[str, Any]:
|
|
66
|
+
return {"oac": "0.1", "type": "issuer-metadata", "issuer": self.issuer, "keys": list(self.keys)}
|
|
67
|
+
|
|
68
|
+
def keyset(self) -> KeySet:
|
|
69
|
+
return KeySet({self.issuer: self.keys})
|
|
70
|
+
|
|
71
|
+
def _same_origin(self, request: Request) -> bool:
|
|
72
|
+
origin = request.headers.get("origin")
|
|
73
|
+
return origin is not None and origin == f"{request.url.scheme}://{request.url.netloc}"
|
|
74
|
+
|
|
75
|
+
def app(self) -> Starlette:
|
|
76
|
+
async def js(request: Request) -> Response:
|
|
77
|
+
return Response(PAGE_JS, media_type="text/javascript", headers={"Cache-Control": "no-store"})
|
|
78
|
+
|
|
79
|
+
async def start_enroll(request: Request) -> Response:
|
|
80
|
+
return Response("document.getElementById('go').onclick = enroll;", media_type="text/javascript")
|
|
81
|
+
|
|
82
|
+
async def start_consent(request: Request) -> Response:
|
|
83
|
+
return Response("showPreview();", media_type="text/javascript")
|
|
84
|
+
|
|
85
|
+
async def enroll_page(request: Request) -> HTMLResponse:
|
|
86
|
+
return _page("Enrol this browser", "<h1>Enrol this browser</h1><p>Enter the one-time code from the server.</p>"
|
|
87
|
+
"<input id=code autocomplete=off> <button id=go>Enrol</button>", "enroll")
|
|
88
|
+
|
|
89
|
+
async def consent_page(request: Request) -> HTMLResponse:
|
|
90
|
+
return _page("Approve an action", "<h1>An agent asks to act for you</h1><p id=summary></p><table id=fields></table>"
|
|
91
|
+
"<p id=buttons hidden><button id=approve>Approve</button><button id=decline>Decline</button></p>",
|
|
92
|
+
"consent")
|
|
93
|
+
|
|
94
|
+
async def api_enroll(request: Request) -> JSONResponse:
|
|
95
|
+
if not self._same_origin(request):
|
|
96
|
+
return JSONResponse({"error": "wrong origin"}, status_code=403)
|
|
97
|
+
body = await request.json()
|
|
98
|
+
if self._code_used or not hmac.compare_digest(str(body.get("code", "")), self.enrollment_code):
|
|
99
|
+
return JSONResponse({"error": "That code is not valid."}, status_code=403)
|
|
100
|
+
jwk = body.get("jwk", {})
|
|
101
|
+
try:
|
|
102
|
+
if not isinstance(jwk, dict) or set(jwk) != {"kty", "crv", "x", "y"} or jwk["kty"] != "EC" or jwk["crv"] != "P-256":
|
|
103
|
+
raise OACError("malformed", "a P-256 public key")
|
|
104
|
+
shapes.check(jwk, shapes.JWK_FIELDS, "jwk")
|
|
105
|
+
KeySet({self.issuer: [jwk]}) # computes the thumbprint, refuses a key already bound elsewhere
|
|
106
|
+
except OACError:
|
|
107
|
+
return JSONResponse({"error": "That is not a valid public key."}, status_code=400)
|
|
108
|
+
self._code_used = True
|
|
109
|
+
self.keys.append(dict(jwk))
|
|
110
|
+
return JSONResponse({"ok": True})
|
|
111
|
+
|
|
112
|
+
async def api_preview(request: Request) -> JSONResponse:
|
|
113
|
+
p = self._previews(request.query_params.get("r", ""))
|
|
114
|
+
if p is None or p.get("sub") != self.person:
|
|
115
|
+
return JSONResponse({"error": "unknown"}, status_code=404)
|
|
116
|
+
return JSONResponse({"preview": p, "issuer": self.issuer, "person": self.person}, headers={"Cache-Control": "no-store"})
|
|
117
|
+
|
|
118
|
+
async def api_consent(request: Request) -> JSONResponse:
|
|
119
|
+
if not self._same_origin(request):
|
|
120
|
+
return JSONResponse({"error": "wrong origin"}, status_code=403)
|
|
121
|
+
token = (await request.json()).get("token", "")
|
|
122
|
+
try:
|
|
123
|
+
p = verify(token, self.keyset(), "oac-consent+jws")
|
|
124
|
+
shapes.consent(p)
|
|
125
|
+
if p["sub"] != self.person or p["signer"]["kind"] != "device":
|
|
126
|
+
raise OACError("malformed", "not this person's device consent")
|
|
127
|
+
except OACError as e:
|
|
128
|
+
return JSONResponse({"error": f"Not accepted ({e.code})."}, status_code=400)
|
|
129
|
+
return JSONResponse({"ok": True}) if self._deliver(token) else JSONResponse({"error": "The agent did not accept it."}, status_code=409)
|
|
130
|
+
|
|
131
|
+
async def api_decline(request: Request) -> JSONResponse:
|
|
132
|
+
if not self._same_origin(request):
|
|
133
|
+
return JSONResponse({"error": "wrong origin"}, status_code=403)
|
|
134
|
+
self.declined.append(str((await request.json()).get("r", "")))
|
|
135
|
+
return JSONResponse({"ok": True})
|
|
136
|
+
|
|
137
|
+
async def well_known(request: Request) -> JSONResponse:
|
|
138
|
+
return JSONResponse(self.metadata())
|
|
139
|
+
|
|
140
|
+
return Starlette(routes=[
|
|
141
|
+
Route("/page.js", js), Route("/start-enroll.js", start_enroll), Route("/start-consent.js", start_consent),
|
|
142
|
+
Route("/enroll", enroll_page), Route("/consent", consent_page),
|
|
143
|
+
Route("/api/enroll", api_enroll, methods=["POST"]), Route("/api/preview", api_preview),
|
|
144
|
+
Route("/api/consent", api_consent, methods=["POST"]), Route("/api/decline", api_decline, methods=["POST"]),
|
|
145
|
+
Route(self.well_known_path, well_known),
|
|
146
|
+
])
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// OAC Approver page script. The person's key is a non-extractable WebCrypto P-256 key kept in this browser
|
|
2
|
+
// (IndexedDB); the server never sees it. Canonical JSON (RFC 8785, integers only) and JWS here must match the SDKs
|
|
3
|
+
// byte for byte; tests verify browser-made tokens with the Python SDK.
|
|
4
|
+
const N = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n;
|
|
5
|
+
const enc = new TextEncoder();
|
|
6
|
+
const b64u = (bytes) => btoa(String.fromCharCode(...new Uint8Array(bytes))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
7
|
+
function canonical(v) {
|
|
8
|
+
if (v === null) return "null";
|
|
9
|
+
if (v === true) return "true";
|
|
10
|
+
if (v === false) return "false";
|
|
11
|
+
if (typeof v === "number") { if (!Number.isSafeInteger(v)) throw new Error("integers only"); return String(v === 0 ? 0 : v); }
|
|
12
|
+
if (typeof v === "string") return JSON.stringify(v);
|
|
13
|
+
if (Array.isArray(v)) return "[" + v.map(canonical).join(",") + "]";
|
|
14
|
+
return "{" + Object.keys(v).sort().map((k) => JSON.stringify(k) + ":" + canonical(v[k])).join(",") + "}";
|
|
15
|
+
}
|
|
16
|
+
async function sha(text) { return new Uint8Array(await crypto.subtle.digest("SHA-256", enc.encode(text))); }
|
|
17
|
+
async function digest(value) { return "sha-256:" + b64u(await sha(canonical(value))); }
|
|
18
|
+
function db() {
|
|
19
|
+
return new Promise((ok, bad) => {
|
|
20
|
+
const r = indexedDB.open("oac-approver", 1);
|
|
21
|
+
r.onupgradeneeded = () => r.result.createObjectStore("keys");
|
|
22
|
+
r.onsuccess = () => ok(r.result); r.onerror = () => bad(r.error);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async function store(op, key, value) {
|
|
26
|
+
const d = await db();
|
|
27
|
+
return new Promise((ok, bad) => {
|
|
28
|
+
const tx = d.transaction("keys", op === "get" ? "readonly" : "readwrite"), s = tx.objectStore("keys");
|
|
29
|
+
const r = op === "get" ? s.get(key) : s.put(value, key);
|
|
30
|
+
r.onsuccess = () => ok(r.result); r.onerror = () => bad(r.error);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async function thumbprint(jwk) { return b64u(await sha(canonical({ crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }))); }
|
|
34
|
+
async function signJws(payload, typ) {
|
|
35
|
+
const k = await store("get", "device");
|
|
36
|
+
if (!k) throw new Error("This browser is not enrolled yet. Open /enroll first.");
|
|
37
|
+
const head = b64u(enc.encode(canonical({ alg: "ES256", kid: k.kid, typ })));
|
|
38
|
+
const body = b64u(enc.encode(canonical(payload)));
|
|
39
|
+
const sig = new Uint8Array(await crypto.subtle.sign({ name: "ECDSA", hash: "SHA-256" }, k.pair.privateKey, enc.encode(head + "." + body)));
|
|
40
|
+
let s = BigInt("0x" + [...sig.slice(32)].map((b) => b.toString(16).padStart(2, "0")).join(""));
|
|
41
|
+
if (s > N / 2n) s = N - s; // low-S: one payload, one signature (spec 3.3)
|
|
42
|
+
const sBytes = s.toString(16).padStart(64, "0").match(/../g).map((h) => parseInt(h, 16));
|
|
43
|
+
return head + "." + body + "." + b64u(new Uint8Array([...sig.slice(0, 32), ...sBytes]));
|
|
44
|
+
}
|
|
45
|
+
const post = (path, body) => fetch(path, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }).then(async (r) => ({ ok: r.ok, body: await r.json() }));
|
|
46
|
+
const el = (id) => document.getElementById(id);
|
|
47
|
+
function say(text) { el("status").textContent = text; }
|
|
48
|
+
|
|
49
|
+
async function enroll() {
|
|
50
|
+
const pair = await crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, false, ["sign", "verify"]);
|
|
51
|
+
const pub = await crypto.subtle.exportKey("jwk", pair.publicKey);
|
|
52
|
+
const jwk = { kty: "EC", crv: "P-256", x: pub.x, y: pub.y };
|
|
53
|
+
const r = await post("api/enroll", { code: el("code").value, jwk });
|
|
54
|
+
if (!r.ok) return say(r.body.error || "Enrolment refused.");
|
|
55
|
+
await store("put", "device", { pair, kid: await thumbprint(jwk) });
|
|
56
|
+
say("This browser can now approve actions.");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function row(table, label, value) {
|
|
60
|
+
const tr = table.insertRow(); tr.insertCell().textContent = label; tr.insertCell().textContent = typeof value === "string" ? value : JSON.stringify(value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function showPreview() {
|
|
64
|
+
const id = new URLSearchParams(location.search).get("r");
|
|
65
|
+
const r = await fetch("api/preview?r=" + encodeURIComponent(id || ""));
|
|
66
|
+
if (!r.ok) return say("This request is unknown or has expired.");
|
|
67
|
+
const { preview, issuer, person } = await r.json();
|
|
68
|
+
el("summary").textContent = preview.summary;
|
|
69
|
+
const t = el("fields");
|
|
70
|
+
for (const [k, v] of Object.entries(preview.fields)) row(t, k, v);
|
|
71
|
+
for (const [k, v] of Object.entries(preview.details || {})) row(t, k + " (detail)", v);
|
|
72
|
+
row(t, "can be undone", preview.undo.kind === "none" ? "NO: this cannot be undone" : preview.undo.kind);
|
|
73
|
+
if (preview.cancel_policy) row(t, "cancellation", preview.cancel_policy.text);
|
|
74
|
+
row(t, "who asks", preview.executor);
|
|
75
|
+
el("buttons").hidden = false;
|
|
76
|
+
el("approve").onclick = async () => {
|
|
77
|
+
const now = Math.floor(Date.now() / 1000);
|
|
78
|
+
const jti = b64u(crypto.getRandomValues(new Uint8Array(18)));
|
|
79
|
+
const consent = { oac: "0.1", type: "consent", iss: issuer, sub: person, aud: preview.executor, jti, iat: now, exp: now + 300,
|
|
80
|
+
items: [{ preview: await digest(preview), action: preview.action }], signer: { kind: "device" } };
|
|
81
|
+
try {
|
|
82
|
+
const res = await post("api/consent", { token: await signJws(consent, "oac-consent+jws") });
|
|
83
|
+
say(res.ok ? "Approved. You can close this page." : res.body.error || "Not accepted.");
|
|
84
|
+
} catch (e) { say(String(e.message || e)); }
|
|
85
|
+
el("buttons").hidden = true;
|
|
86
|
+
};
|
|
87
|
+
el("decline").onclick = async () => { await post("api/decline", { r: id }); say("Declined. Nothing will run."); el("buttons").hidden = true; };
|
|
88
|
+
}
|