@aporthq/aport-agent-guardrails 1.0.8

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.
Files changed (237) hide show
  1. package/LICENSE +217 -0
  2. package/README.md +481 -0
  3. package/bin/agent-guardrails +133 -0
  4. package/bin/aport-create-passport.sh +444 -0
  5. package/bin/aport-cursor-hook.sh +90 -0
  6. package/bin/aport-guardrail-api.sh +108 -0
  7. package/bin/aport-guardrail-bash.sh +394 -0
  8. package/bin/aport-guardrail-v2.sh +5 -0
  9. package/bin/aport-guardrail.sh +5 -0
  10. package/bin/aport-resolve-paths.sh +71 -0
  11. package/bin/aport-status.sh +276 -0
  12. package/bin/frameworks/crewai.sh +49 -0
  13. package/bin/frameworks/cursor.sh +95 -0
  14. package/bin/frameworks/langchain.sh +48 -0
  15. package/bin/frameworks/n8n.sh +36 -0
  16. package/bin/frameworks/openclaw.sh +19 -0
  17. package/bin/lib/allowlist.sh +18 -0
  18. package/bin/lib/common.sh +28 -0
  19. package/bin/lib/config.sh +46 -0
  20. package/bin/lib/constants.sh +232 -0
  21. package/bin/lib/detect.sh +65 -0
  22. package/bin/lib/error.sh +269 -0
  23. package/bin/lib/passport.sh +19 -0
  24. package/bin/lib/templates/.gitkeep +1 -0
  25. package/bin/lib/templates/config.yaml +6 -0
  26. package/bin/lib/validation.sh +206 -0
  27. package/bin/openclaw +660 -0
  28. package/docs/ADDING_A_FRAMEWORK.md +87 -0
  29. package/docs/AGENTS.md.example +40 -0
  30. package/docs/CODE_REVIEW.md +192 -0
  31. package/docs/DEPLOYMENT_READINESS.md +81 -0
  32. package/docs/FAQ_SECURITY_SCANNERS.md +373 -0
  33. package/docs/FRAMEWORK_ROADMAP.md +41 -0
  34. package/docs/HOSTED_PASSPORT_SETUP.md +362 -0
  35. package/docs/IMPLEMENTING_YOUR_OWN_EVALUATOR.md +433 -0
  36. package/docs/OPENCLAW_COMPATIBILITY.md +73 -0
  37. package/docs/OPENCLAW_LOCAL_INTEGRATION.md +596 -0
  38. package/docs/OPENCLAW_TOOLS_AND_POLICIES.md +54 -0
  39. package/docs/QUICKSTART.md +470 -0
  40. package/docs/QUICKSTART_OPENCLAW_PLUGIN.md +470 -0
  41. package/docs/README.md +28 -0
  42. package/docs/RELEASE.md +87 -0
  43. package/docs/REPO_LAYOUT.md +47 -0
  44. package/docs/SKILLS_ECOSYSTEM_ANALYSIS_FEB17.md +1260 -0
  45. package/docs/TOOL_POLICY_MAPPING.md +46 -0
  46. package/docs/UPGRADE.md +46 -0
  47. package/docs/VERIFICATION_METHODS.md +97 -0
  48. package/docs/assets/README.md +8 -0
  49. package/docs/assets/porter.svg +54 -0
  50. package/docs/development/ERROR_CODES.md +616 -0
  51. package/docs/frameworks/GITHUB_ISSUE_PROPOSALS.md +1105 -0
  52. package/docs/frameworks/crewai.md +114 -0
  53. package/docs/frameworks/cursor.md +159 -0
  54. package/docs/frameworks/langchain.md +72 -0
  55. package/docs/frameworks/n8n.md +40 -0
  56. package/docs/frameworks/openclaw.md +40 -0
  57. package/docs/launch/ADD_APORT_AWESOME_LISTS_INSTRUCTIONS.md +146 -0
  58. package/docs/launch/ANNOUNCEMENT_GUIDE.md +266 -0
  59. package/docs/launch/AWESOME_REPOS.md +53 -0
  60. package/docs/launch/CURSOR_VSCODE_HOOKS_RESEARCH.md +77 -0
  61. package/docs/launch/DEMO_TERMINAL_OUTPUT.txt +48 -0
  62. package/docs/launch/DRY_AND_PLAN_CHECKLIST.md +47 -0
  63. package/docs/launch/EVIDENCE_README.md +61 -0
  64. package/docs/launch/EVIDENCE_TERMINAL_CAPTURE.txt +10 -0
  65. package/docs/launch/FRAMEWORK_SUPPORT_PLAN.md +1640 -0
  66. package/docs/launch/LAUNCH_READINESS_CHECKLIST.md +237 -0
  67. package/docs/launch/LAUNCH_STRATEGY_SUMMARY.md +464 -0
  68. package/docs/launch/OPENCLAW_FEEDBACK_AND_FIXES.md +85 -0
  69. package/docs/launch/POST_1_VALENTINE_IMPROVED.md +233 -0
  70. package/docs/launch/POST_2_GUARDRAIL_IMPROVED.md +369 -0
  71. package/docs/launch/PRE_LAUNCH_FIXES.md +766 -0
  72. package/docs/launch/QUICK_LAUNCH_CHECKLIST.md +400 -0
  73. package/docs/launch/READINESS_SUMMARY.md +262 -0
  74. package/docs/launch/README.md +68 -0
  75. package/docs/launch/USER_STORIES.md +327 -0
  76. package/docs/launch/scripts/add-aport-awesome-pr.sh +69 -0
  77. package/docs/operations/MONITORING.md +588 -0
  78. package/docs/reviews/2026-02-18-staff-review.md +268 -0
  79. package/extensions/openclaw-aport/README.md +415 -0
  80. package/extensions/openclaw-aport/index.js +625 -0
  81. package/extensions/openclaw-aport/openclaw-aport.js +7 -0
  82. package/extensions/openclaw-aport/openclaw.plugin.json +46 -0
  83. package/extensions/openclaw-aport/package.json +36 -0
  84. package/extensions/openclaw-aport/test.js +307 -0
  85. package/external/aport-policies/README.md +363 -0
  86. package/external/aport-policies/agent.session.create.v1/README.md +345 -0
  87. package/external/aport-policies/agent.session.create.v1/policy.json +162 -0
  88. package/external/aport-policies/agent.tool.register.v1/README.md +361 -0
  89. package/external/aport-policies/agent.tool.register.v1/policy.json +172 -0
  90. package/external/aport-policies/code.release.publish.v1/README.md +51 -0
  91. package/external/aport-policies/code.release.publish.v1/policy.json +121 -0
  92. package/external/aport-policies/code.repository.merge.v1/README.md +287 -0
  93. package/external/aport-policies/code.repository.merge.v1/express.example.js +332 -0
  94. package/external/aport-policies/code.repository.merge.v1/fastapi.example.py +370 -0
  95. package/external/aport-policies/code.repository.merge.v1/policy.json +162 -0
  96. package/external/aport-policies/data.export.create.v1/README.md +226 -0
  97. package/external/aport-policies/data.export.create.v1/express.example.js +172 -0
  98. package/external/aport-policies/data.export.create.v1/fastapi.example.py +165 -0
  99. package/external/aport-policies/data.export.create.v1/policy.json +133 -0
  100. package/external/aport-policies/data.report.ingest.v1/README.md +134 -0
  101. package/external/aport-policies/data.report.ingest.v1/express.example.js +105 -0
  102. package/external/aport-policies/data.report.ingest.v1/minimal-example.js +68 -0
  103. package/external/aport-policies/data.report.ingest.v1/policy.json +174 -0
  104. package/external/aport-policies/finance.crypto.trade.v1/README.md +146 -0
  105. package/external/aport-policies/finance.crypto.trade.v1/express.example.js +109 -0
  106. package/external/aport-policies/finance.crypto.trade.v1/minimal-example.js +65 -0
  107. package/external/aport-policies/finance.crypto.trade.v1/policy.json +176 -0
  108. package/external/aport-policies/finance.payment.charge.v1/README.md +326 -0
  109. package/external/aport-policies/finance.payment.charge.v1/express.example.js +250 -0
  110. package/external/aport-policies/finance.payment.charge.v1/fastapi.example.py +227 -0
  111. package/external/aport-policies/finance.payment.charge.v1/minimal-example.js +64 -0
  112. package/external/aport-policies/finance.payment.charge.v1/policy.json +224 -0
  113. package/external/aport-policies/finance.payment.charge.v1/tests/contexts.jsonl +12 -0
  114. package/external/aport-policies/finance.payment.charge.v1/tests/expected.jsonl +12 -0
  115. package/external/aport-policies/finance.payment.charge.v1/tests/passport.instance.json +42 -0
  116. package/external/aport-policies/finance.payment.charge.v1/tests/passport.template.json +40 -0
  117. package/external/aport-policies/finance.payment.charge.v1/tests/payments-charge-policy.test.js +817 -0
  118. package/external/aport-policies/finance.payment.charge.v1/tests/test_payments_charge_policy.py +486 -0
  119. package/external/aport-policies/finance.payment.payout.v1/README.md +78 -0
  120. package/external/aport-policies/finance.payment.payout.v1/policy.json +181 -0
  121. package/external/aport-policies/finance.payment.refund.v1/README.md +275 -0
  122. package/external/aport-policies/finance.payment.refund.v1/express.example.js +167 -0
  123. package/external/aport-policies/finance.payment.refund.v1/fastapi.example.py +136 -0
  124. package/external/aport-policies/finance.payment.refund.v1/minimal-example.js +183 -0
  125. package/external/aport-policies/finance.payment.refund.v1/policy.json +216 -0
  126. package/external/aport-policies/finance.payment.refund.v1/tests/refunds-policy.test.js +924 -0
  127. package/external/aport-policies/finance.payment.refund.v1/tests/test_refunds_policy.py +778 -0
  128. package/external/aport-policies/finance.transaction.execute.v1/README.md +309 -0
  129. package/external/aport-policies/finance.transaction.execute.v1/express.example.js +261 -0
  130. package/external/aport-policies/finance.transaction.execute.v1/fastapi.example.py +231 -0
  131. package/external/aport-policies/finance.transaction.execute.v1/minimal-example.js +78 -0
  132. package/external/aport-policies/finance.transaction.execute.v1/policy.json +189 -0
  133. package/external/aport-policies/finance.transaction.execute.v1/tests/contexts.jsonl +12 -0
  134. package/external/aport-policies/finance.transaction.execute.v1/tests/expected.jsonl +12 -0
  135. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.instance.json +42 -0
  136. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.template.json +42 -0
  137. package/external/aport-policies/finance.transaction.execute.v1/tests/test_transactions_policy.py +214 -0
  138. package/external/aport-policies/finance.transaction.execute.v1/tests/transactions-policy.test.js +306 -0
  139. package/external/aport-policies/governance.data.access.v1/README.md +292 -0
  140. package/external/aport-policies/governance.data.access.v1/express.example.js +321 -0
  141. package/external/aport-policies/governance.data.access.v1/fastapi.example.py +279 -0
  142. package/external/aport-policies/governance.data.access.v1/minimal-example.js +65 -0
  143. package/external/aport-policies/governance.data.access.v1/policy.json +208 -0
  144. package/external/aport-policies/governance.data.access.v1/tests/contexts.jsonl +12 -0
  145. package/external/aport-policies/governance.data.access.v1/tests/data-access-policy.test.js +308 -0
  146. package/external/aport-policies/governance.data.access.v1/tests/expected.jsonl +12 -0
  147. package/external/aport-policies/governance.data.access.v1/tests/passport.instance.json +56 -0
  148. package/external/aport-policies/governance.data.access.v1/tests/passport.template.json +56 -0
  149. package/external/aport-policies/governance.data.access.v1/tests/test_data_access_policy.py +214 -0
  150. package/external/aport-policies/legal.contract.review.v1/README.md +109 -0
  151. package/external/aport-policies/legal.contract.review.v1/policy.json +378 -0
  152. package/external/aport-policies/legal.contract.review.v1/tests/legal-contract-review-policy.test.js +609 -0
  153. package/external/aport-policies/legal.contract.review.v1/tests/passport.template.json +49 -0
  154. package/external/aport-policies/mcp.tool.execute.v1/README.md +301 -0
  155. package/external/aport-policies/mcp.tool.execute.v1/policy.json +141 -0
  156. package/external/aport-policies/messaging.message.send.v1/README.md +230 -0
  157. package/external/aport-policies/messaging.message.send.v1/express.example.js +183 -0
  158. package/external/aport-policies/messaging.message.send.v1/fastapi.example.py +193 -0
  159. package/external/aport-policies/messaging.message.send.v1/policy.json +144 -0
  160. package/external/aport-policies/policy-template.json +107 -0
  161. package/external/aport-policies/system.command.execute.v1/README.md +275 -0
  162. package/external/aport-policies/system.command.execute.v1/policy.json +146 -0
  163. package/external/aport-spec/CONTRIBUTING.md +273 -0
  164. package/external/aport-spec/LICENSE +21 -0
  165. package/external/aport-spec/README.md +168 -0
  166. package/external/aport-spec/conformance/README.md +294 -0
  167. package/external/aport-spec/conformance/cases/data.export.v1/contexts/allow_users.json +6 -0
  168. package/external/aport-spec/conformance/cases/data.export.v1/contexts/deny_pii.json +6 -0
  169. package/external/aport-spec/conformance/cases/data.export.v1/expected/allow_users.decision.json +19 -0
  170. package/external/aport-spec/conformance/cases/data.export.v1/expected/deny_pii.decision.json +19 -0
  171. package/external/aport-spec/conformance/cases/data.export.v1/passports/template.json +29 -0
  172. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/allow_50usd.json +9 -0
  173. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_150usd.json +9 -0
  174. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_currency.json +9 -0
  175. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/allow_50usd.decision.json +19 -0
  176. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_150usd.decision.json +19 -0
  177. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_currency.decision.json +19 -0
  178. package/external/aport-spec/conformance/cases/payments.refunds.v1/passports/template.json +42 -0
  179. package/external/aport-spec/conformance/package.json +44 -0
  180. package/external/aport-spec/conformance/pnpm-lock.yaml +642 -0
  181. package/external/aport-spec/conformance/src/cases.ts +371 -0
  182. package/external/aport-spec/conformance/src/ed25519.ts +167 -0
  183. package/external/aport-spec/conformance/src/jcs.ts +85 -0
  184. package/external/aport-spec/conformance/src/runner.ts +533 -0
  185. package/external/aport-spec/conformance/src/validators.ts +185 -0
  186. package/external/aport-spec/conformance/test-runner.js +315 -0
  187. package/external/aport-spec/conformance/tsconfig.json +21 -0
  188. package/external/aport-spec/error-schema.json +192 -0
  189. package/external/aport-spec/index.json +12 -0
  190. package/external/aport-spec/integrations/clawmoat/README.md +12 -0
  191. package/external/aport-spec/integrations/shield/README.md +245 -0
  192. package/external/aport-spec/integrations/shield/adapters/index.js +116 -0
  193. package/external/aport-spec/integrations/shield/adapters/system-command-execute.js +133 -0
  194. package/external/aport-spec/integrations/shield/test/README.md +58 -0
  195. package/external/aport-spec/integrations/shield/test/shield.md +40 -0
  196. package/external/aport-spec/integrations/shield/test/test-shield-to-verify.js +274 -0
  197. package/external/aport-spec/metrics-schema.json +504 -0
  198. package/external/aport-spec/oap/CHANGELOG.md +54 -0
  199. package/external/aport-spec/oap/VERSION.md +40 -0
  200. package/external/aport-spec/oap/capability-registry.md +229 -0
  201. package/external/aport-spec/oap/conformance.md +257 -0
  202. package/external/aport-spec/oap/decision-schema.json +114 -0
  203. package/external/aport-spec/oap/examples/context.refund.usd.50.json +9 -0
  204. package/external/aport-spec/oap/examples/decision.allow.sample.json +20 -0
  205. package/external/aport-spec/oap/examples/decision.deny.sample.json +23 -0
  206. package/external/aport-spec/oap/examples/passport.instance.v1.json +50 -0
  207. package/external/aport-spec/oap/examples/passport.template.v1.json +71 -0
  208. package/external/aport-spec/oap/oap-spec.md +426 -0
  209. package/external/aport-spec/oap/passport-schema.json +396 -0
  210. package/external/aport-spec/oap/security.md +213 -0
  211. package/external/aport-spec/oap/vc/context-oap-v1.jsonld +137 -0
  212. package/external/aport-spec/oap/vc/examples/oap-decision-vc.json +37 -0
  213. package/external/aport-spec/oap/vc/examples/oap-passport-vc.json +68 -0
  214. package/external/aport-spec/oap/vc/tools/INTEGRATION.md +375 -0
  215. package/external/aport-spec/oap/vc/tools/README.md +278 -0
  216. package/external/aport-spec/oap/vc/tools/examples/decision-to-vc.js +66 -0
  217. package/external/aport-spec/oap/vc/tools/examples/passport-to-vc.js +83 -0
  218. package/external/aport-spec/oap/vc/tools/examples/vc-to-decision.js +77 -0
  219. package/external/aport-spec/oap/vc/tools/examples/vc-to-passport.js +94 -0
  220. package/external/aport-spec/oap/vc/tools/package.json +38 -0
  221. package/external/aport-spec/oap/vc/tools/pnpm-lock.yaml +472 -0
  222. package/external/aport-spec/oap/vc/tools/src/cli.ts +226 -0
  223. package/external/aport-spec/oap/vc/tools/src/crypto-utils.ts +427 -0
  224. package/external/aport-spec/oap/vc/tools/src/index.ts +653 -0
  225. package/external/aport-spec/oap/vc/tools/src/test.ts +148 -0
  226. package/external/aport-spec/oap/vc/tools/src/vp.ts +382 -0
  227. package/external/aport-spec/oap/vc/tools/test-simple.js +214 -0
  228. package/external/aport-spec/oap/vc/tools/tsconfig.json +19 -0
  229. package/external/aport-spec/oap/vc/vc-mapping.md +443 -0
  230. package/external/aport-spec/passport-schema.json +586 -0
  231. package/external/aport-spec/rate-limiting.md +136 -0
  232. package/external/aport-spec/transport-profile.md +325 -0
  233. package/external/aport-spec/webhook-spec.md +314 -0
  234. package/package.json +70 -0
  235. package/skills/aport-agent-guardrail/SKILL.md +314 -0
  236. package/src/evaluator.js +252 -0
  237. package/src/server/index.js +72 -0
@@ -0,0 +1,278 @@
1
+ # OAP VC Conversion Tools
2
+
3
+ Practical tools for converting between Open Agent Passport (OAP) objects and Verifiable Credentials (VCs) for interoperability with VC/DID ecosystems.
4
+
5
+ ## šŸš€ Quick Start
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ # Clone the OAP specification repository
11
+ git clone https://github.com/aporthq/oap-spec.git
12
+ cd oap-spec/spec/oap/vc/tools
13
+
14
+ # Install dependencies
15
+ npm install
16
+
17
+ # Build the TypeScript code
18
+ npm run build
19
+ ```
20
+
21
+ ### CLI Usage
22
+
23
+ ```bash
24
+ # Export OAP Passport to VC
25
+ node dist/cli.js export --type passport --input passport.json --output passport.vc.json --key registry-key.json
26
+
27
+ # Export with verbose output (shows converted data)
28
+ node dist/cli.js export --type passport --input passport.json --output passport.vc.json --key registry-key.json --verbose
29
+
30
+ # Export OAP Decision to VC
31
+ node dist/cli.js export --type decision --input decision.json --output decision.vc.json --key registry-key.json
32
+
33
+ # Import VC to OAP Passport
34
+ node dist/cli.js import --type passport --input passport.vc.json --output passport.json
35
+
36
+ # Import with verbose output (shows converted data)
37
+ node dist/cli.js import --type passport --input passport.vc.json --output passport.json --verbose
38
+
39
+ # Import VC to OAP Decision
40
+ node dist/cli.js import --type decision --input decision.vc.json --output decision.json
41
+
42
+ # Validate OAP objects or VCs
43
+ node dist/cli.js validate --type passport --input passport.json
44
+ node dist/cli.js validate --type decision --input decision.json
45
+ node dist/cli.js validate --type vc --input passport.vc.json
46
+
47
+ # Generate a registry key
48
+ node dist/cli.js generate-key --output my-registry-key.json
49
+ ```
50
+
51
+ ### SDK Usage
52
+
53
+ ```javascript
54
+ import {
55
+ exportPassportToVC,
56
+ exportDecisionToVC,
57
+ importVCToPassport,
58
+ importVCToDecision
59
+ } from './dist/index.js';
60
+
61
+ // Export OAP Passport to VC
62
+ const passportVC = exportPassportToVC(passport, registryKey);
63
+
64
+ // Export OAP Decision to VC
65
+ const decisionVC = exportDecisionToVC(decision, registryKey);
66
+
67
+ // Import VC to OAP Passport
68
+ const passport = importVCToPassport(vc);
69
+
70
+ // Import VC to OAP Decision
71
+ const decision = importVCToDecision(vc);
72
+ ```
73
+
74
+ ## šŸ“‹ Requirements
75
+
76
+ - Node.js 18+
77
+ - TypeScript 5.3+
78
+ - Registry key for signing VCs
79
+
80
+ ## šŸ”§ Configuration
81
+
82
+ ### Registry Key Format
83
+
84
+ ```json
85
+ {
86
+ "issuer": "https://aport.io",
87
+ "kid": "key-2025-01",
88
+ "publicKey": "your-ed25519-public-key",
89
+ "privateKey": "your-ed25519-private-key"
90
+ }
91
+ ```
92
+
93
+ ### OAP Passport Format
94
+
95
+ ```json
96
+ {
97
+ "agent_id": "550e8400-e29b-41d4-a716-446655440000",
98
+ "kind": "template",
99
+ "spec_version": "oap/1.0",
100
+ "owner_id": "org_12345678",
101
+ "owner_type": "org",
102
+ "assurance_level": "L2",
103
+ "status": "active",
104
+ "capabilities": [
105
+ { "id": "finance.payment.refund", "params": { "currency_limits": { "USD": { "max_per_tx": 5000 } } } }
106
+ ],
107
+ "limits": { /* policy limits */ },
108
+ "regions": ["US", "CA"],
109
+ "metadata": { /* additional metadata */ },
110
+ "created_at": "2024-01-01T00:00:00Z",
111
+ "updated_at": "2024-01-15T10:30:00Z",
112
+ "version": "1.0.0"
113
+ }
114
+ ```
115
+
116
+ ### OAP Decision Format
117
+
118
+ ```json
119
+ {
120
+ "decision_id": "550e8400-e29b-41d4-a716-446655440002",
121
+ "policy_id": "finance.payment.refund.v1",
122
+ "agent_id": "550e8400-e29b-41d4-a716-446655440000",
123
+ "owner_id": "org_12345678",
124
+ "assurance_level": "L2",
125
+ "allow": true,
126
+ "reasons": [
127
+ { "code": "oap.allowed", "message": "Transaction within limits" }
128
+ ],
129
+ "created_at": "2024-01-15T10:30:00Z",
130
+ "expires_in": 3600,
131
+ "passport_digest": "sha256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx1234yzab5678cdef",
132
+ "signature": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
133
+ "kid": "oap:registry:key-2025-01",
134
+ "decision_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9..."
135
+ }
136
+ ```
137
+
138
+ ## 🧪 Testing
139
+
140
+ ```bash
141
+ # Run the simple test (no build required)
142
+ node test-simple.js
143
+
144
+ # Build and run full test suite
145
+ npm run build
146
+ npm test
147
+
148
+ # Run specific test
149
+ npm run test -- --grep "passport"
150
+ ```
151
+
152
+ ## šŸ“š API Reference
153
+
154
+ ### `exportPassportToVC(passport, registryKey)`
155
+
156
+ Converts an OAP Passport to a Verifiable Credential.
157
+
158
+ **Parameters:**
159
+
160
+ - `passport` (OAPPassport): The OAP passport object
161
+ - `registryKey` (RegistryKey): Registry key for signing
162
+
163
+ **Returns:** `VerifiableCredential`
164
+
165
+ ### `exportDecisionToVC(decision, registryKey)`
166
+
167
+ Converts an OAP Decision to a Verifiable Credential.
168
+
169
+ **Parameters:**
170
+
171
+ - `decision` (OAPDecision): The OAP decision object
172
+ - `registryKey` (RegistryKey): Registry key for signing
173
+
174
+ **Returns:** `VerifiableCredential`
175
+
176
+ ### `importVCToPassport(vc)`
177
+
178
+ Converts a Verifiable Credential to an OAP Passport.
179
+
180
+ **Parameters:**
181
+
182
+ - `vc` (VerifiableCredential): The Verifiable Credential
183
+
184
+ **Returns:** `OAPPassport`
185
+
186
+ ### `importVCToDecision(vc)`
187
+
188
+ Converts a Verifiable Credential to an OAP Decision.
189
+
190
+ **Parameters:**
191
+
192
+ - `vc` (VerifiableCredential): The Verifiable Credential
193
+
194
+ **Returns:** `OAPDecision`
195
+
196
+ ## šŸ“Š Logging and Debugging
197
+
198
+ The tools provide detailed logging to help you understand what's being converted:
199
+
200
+ ### Verbose Output
201
+
202
+ Use the `--verbose` flag to see the full converted data:
203
+
204
+ ```bash
205
+ # Show converted VC data
206
+ node dist/cli.js export --type passport --input passport.json --output passport.vc.json --key registry-key.json --verbose
207
+
208
+ # Show converted OAP data
209
+ node dist/cli.js import --type passport --input passport.vc.json --output passport.json --verbose
210
+ ```
211
+
212
+ ### Example Output
213
+
214
+ ```text
215
+ āœ… Successfully exported passport to VC
216
+ šŸ“ Output written to: passport.vc.json
217
+
218
+ šŸ“„ Converted VC Data:
219
+ ──────────────────────────────────────────────────
220
+ {
221
+ "@context": [
222
+ "https://www.w3.org/2018/credentials/v1",
223
+ "https://raw.githubusercontent.com/aporthq/aport-spec/refs/heads/main/oap/vc/context-oap-v1.jsonld"
224
+ ],
225
+ "type": ["VerifiableCredential", "OAPPassportCredential"],
226
+ "credentialSubject": {
227
+ "agent_id": "550e8400-e29b-41d4-a716-446655440000",
228
+ "kind": "template",
229
+ "spec_version": "oap/1.0",
230
+ ...
231
+ },
232
+ "issuer": "https://aport.io",
233
+ "issuanceDate": "2024-01-01T00:00:00Z",
234
+ "expirationDate": "2025-01-01T00:00:00Z",
235
+ "proof": {
236
+ "type": "Ed25519Signature2020",
237
+ ...
238
+ }
239
+ }
240
+ ──────────────────────────────────────────────────
241
+ ```
242
+
243
+ ## šŸ”’ Security Considerations
244
+
245
+ - **Signing**: VCs are signed using Ed25519Signature2020
246
+ - **Verification**: Always verify VC signatures before importing
247
+ - **Key Management**: Store registry keys securely
248
+ - **Expiration**: VCs include expiration dates for security
249
+
250
+ ## 🌐 Interoperability
251
+
252
+ These tools enable OAP objects to work with:
253
+
254
+ - **VC Wallets**: Store OAP objects in standard VC wallets
255
+ - **VC Presentations**: Present OAP objects using VC presentation protocols
256
+ - **VC Verification**: Verify OAP objects using standard VC libraries
257
+ - **DID Ecosystems**: Integrate with Decentralized Identifier systems
258
+
259
+ ## šŸ“– Examples
260
+
261
+ See the `examples/` directory for complete working examples:
262
+
263
+ - `examples/passport-to-vc.js` - Convert passport to VC
264
+ - `examples/decision-to-vc.js` - Convert decision to VC
265
+ - `examples/vc-to-passport.js` - Convert VC to passport
266
+ - `examples/vc-to-decision.js` - Convert VC to decision
267
+
268
+ ## šŸ¤ Contributing
269
+
270
+ 1. Fork the repository
271
+ 2. Create a feature branch
272
+ 3. Make your changes
273
+ 4. Add tests
274
+ 5. Submit a pull request
275
+
276
+ ## šŸ“„ License
277
+
278
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Example: Convert OAP Decision to Verifiable Credential
5
+ */
6
+
7
+ import { readFileSync, writeFileSync } from "fs";
8
+ import { join, dirname } from "path";
9
+ import { fileURLToPath } from "url";
10
+ import { exportDecisionToVC } from "../dist/index.js";
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ // Sample OAP Decision
16
+ const decision = {
17
+ decision_id: "550e8400-e29b-41d4-a716-446655440002",
18
+ policy_id: "finance.payment.refund.v1",
19
+ agent_id: "550e8400-e29b-41d4-a716-446655440000",
20
+ owner_id: "org_12345678",
21
+ assurance_level: "L2",
22
+ allow: true,
23
+ reasons: [{ code: "oap.allowed", message: "Transaction within limits" }],
24
+ created_at: "2024-01-15T10:30:00Z",
25
+ expires_in: 3600,
26
+ passport_digest:
27
+ "sha256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx1234yzab5678cdef",
28
+ signature: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
29
+ kid: "oap:registry:key-2025-01",
30
+ decision_token: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
31
+ };
32
+
33
+ // Sample Registry Key
34
+ const registryKey = {
35
+ issuer: "https://aport.io",
36
+ kid: "key-2025-01",
37
+ publicKey: "placeholder-public-key",
38
+ privateKey: "placeholder-private-key",
39
+ };
40
+
41
+ try {
42
+ console.log("šŸ”„ Converting OAP Decision to Verifiable Credential...\n");
43
+
44
+ // Convert decision to VC
45
+ const vc = exportDecisionToVC(decision, registryKey);
46
+
47
+ // Save to file
48
+ const outputFile = join(__dirname, "decision.vc.json");
49
+ writeFileSync(outputFile, JSON.stringify(vc, null, 2));
50
+
51
+ console.log("āœ… Conversion successful!");
52
+ console.log(`šŸ“„ VC Type: ${vc.type.join(", ")}`);
53
+ console.log(`šŸ¢ Issuer: ${vc.issuer}`);
54
+ console.log(`šŸ“… Issuance Date: ${vc.issuanceDate}`);
55
+ console.log(`ā° Expiration Date: ${vc.expirationDate}`);
56
+ console.log(`šŸ“ Output saved to: ${outputFile}`);
57
+
58
+ // Log the converted data
59
+ console.log("\nšŸ“„ Converted VC Data:");
60
+ console.log("─".repeat(50));
61
+ console.log(JSON.stringify(vc, null, 2));
62
+ console.log("─".repeat(50));
63
+ } catch (error) {
64
+ console.error("āŒ Conversion failed:", error.message);
65
+ process.exit(1);
66
+ }
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Example: Convert OAP Passport to Verifiable Credential
5
+ */
6
+
7
+ import { readFileSync, writeFileSync } from "fs";
8
+ import { join, dirname } from "path";
9
+ import { fileURLToPath } from "url";
10
+ import { exportPassportToVC } from "../dist/index.js";
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ // Sample OAP Passport
16
+ const passport = {
17
+ agent_id: "550e8400-e29b-41d4-a716-446655440000",
18
+ kind: "template",
19
+ spec_version: "oap/1.0",
20
+ owner_id: "org_12345678",
21
+ owner_type: "org",
22
+ assurance_level: "L2",
23
+ status: "active",
24
+ capabilities: [
25
+ {
26
+ id: "finance.payment.refund",
27
+ params: { currency_limits: { USD: { max_per_tx: 5000 } } },
28
+ },
29
+ { id: "data.export", params: { max_rows: 100000 } },
30
+ ],
31
+ limits: {
32
+ "finance.payment.refund": {
33
+ currency_limits: {
34
+ USD: { max_per_tx: 5000, daily_cap: 50000 },
35
+ },
36
+ reason_codes: ["customer_request", "defective_product"],
37
+ idempotency_required: true,
38
+ },
39
+ },
40
+ regions: ["US", "CA"],
41
+ metadata: {
42
+ name: "Customer Support AI",
43
+ description: "AI agent for customer support operations",
44
+ },
45
+ created_at: "2024-01-01T00:00:00Z",
46
+ updated_at: "2024-01-15T10:30:00Z",
47
+ version: "1.0.0",
48
+ };
49
+
50
+ // Sample Registry Key
51
+ const registryKey = {
52
+ issuer: "https://aport.io",
53
+ kid: "key-2025-01",
54
+ publicKey: "placeholder-public-key",
55
+ privateKey: "placeholder-private-key",
56
+ };
57
+
58
+ try {
59
+ console.log("šŸ”„ Converting OAP Passport to Verifiable Credential...\n");
60
+
61
+ // Convert passport to VC
62
+ const vc = exportPassportToVC(passport, registryKey);
63
+
64
+ // Save to file
65
+ const outputFile = join(__dirname, "passport.vc.json");
66
+ writeFileSync(outputFile, JSON.stringify(vc, null, 2));
67
+
68
+ console.log("āœ… Conversion successful!");
69
+ console.log(`šŸ“„ VC Type: ${vc.type.join(", ")}`);
70
+ console.log(`šŸ¢ Issuer: ${vc.issuer}`);
71
+ console.log(`šŸ“… Issuance Date: ${vc.issuanceDate}`);
72
+ console.log(`ā° Expiration Date: ${vc.expirationDate}`);
73
+ console.log(`šŸ“ Output saved to: ${outputFile}`);
74
+
75
+ // Log the converted data
76
+ console.log("\nšŸ“„ Converted VC Data:");
77
+ console.log("─".repeat(50));
78
+ console.log(JSON.stringify(vc, null, 2));
79
+ console.log("─".repeat(50));
80
+ } catch (error) {
81
+ console.error("āŒ Conversion failed:", error.message);
82
+ process.exit(1);
83
+ }
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Example: Convert Verifiable Credential to OAP Decision
5
+ */
6
+
7
+ import { readFileSync, writeFileSync } from "fs";
8
+ import { join, dirname } from "path";
9
+ import { fileURLToPath } from "url";
10
+ import { importVCToDecision } from "../dist/index.js";
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ // Sample Verifiable Credential (OAP Decision)
16
+ const vc = {
17
+ "@context": [
18
+ "https://www.w3.org/2018/credentials/v1",
19
+ "https://raw.githubusercontent.com/aporthq/aport-spec/refs/heads/main/oap/vc/context-oap-v1.jsonld",
20
+ ],
21
+ type: ["VerifiableCredential", "OAPDecisionReceipt"],
22
+ credentialSubject: {
23
+ decision_id: "550e8400-e29b-41d4-a716-446655440002",
24
+ policy_id: "finance.payment.refund.v1",
25
+ agent_id: "550e8400-e29b-41d4-a716-446655440000",
26
+ owner_id: "org_12345678",
27
+ assurance_level: "L2",
28
+ allow: true,
29
+ reasons: [{ code: "oap.allowed", message: "Transaction within limits" }],
30
+ created_at: "2024-01-15T10:30:00Z",
31
+ expires_in: 3600,
32
+ passport_digest:
33
+ "sha256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx1234yzab5678cdef",
34
+ signature: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
35
+ kid: "oap:registry:key-2025-01",
36
+ decision_token: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
37
+ },
38
+ issuer: "https://aport.io",
39
+ issuanceDate: "2024-01-15T10:30:00Z",
40
+ expirationDate: "2024-01-15T11:30:00Z",
41
+ proof: {
42
+ type: "Ed25519Signature2020",
43
+ created: "2024-01-15T10:30:00Z",
44
+ verificationMethod:
45
+ "https://aport.io/.well-known/oap/keys.json#ap_registry_ed25519_2024",
46
+ proofPurpose: "assertionMethod",
47
+ jws: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVkZW50aWFsU3ViamVjdCI6eyJkZWNpc2lvbl9pZCI6IjU1MGU4NDAwLWUyOWItNDFkNC1hNzE2LTQ0NjY1NTQ0MDAwMiIsInBvbGljeV9pZCI6InBheW1lbnRzLnJlZnVuZC52MSIsImFnZW50X2lkIjoiNTUwZTg0MDAtZTI5Yi00MWQ0LWE3MTYtNDQ2NjU1NDQwMDAwIiwib3duZXJfaWQiOiJvcmdfMTIzNDU2NzgiLCJhc3N1cmFuY2VfbGV2ZWwiOiJMMiIsImFsbG93Ijp0cnVlLCJyZWFzb25zIjpbeyJjb2RlIjoib2FwLmFsbG93ZWQiLCJtZXNzYWdlIjoiVHJhbnNhY3Rpb24gd2l0aGluIGxpbWl0cyJ9XSwicGFzc3BvcnRfZGlnZXN0Ijoic2hhMjU2OmFiY2QxMjM0ZWZnaDU2NzhpamtsOTAxMm1ub3AzNDU2cXJzdDc4OTB1dnd4MTIzNHl6YWI1Njc4Y2RlZiIsInNpZ25hdHVyZSI6ImV5SmhiR2NpT2lKU1V6STFOaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpoYkdjaU9pSlNVekkxTmlJc0luUjVjQ0k2SWtwWFZDSjkucGxhY2Vob2xkZXIifQ.signature",
48
+ },
49
+ };
50
+
51
+ try {
52
+ console.log("šŸ”„ Converting Verifiable Credential to OAP Decision...\n");
53
+
54
+ // Convert VC to decision
55
+ const decision = importVCToDecision(vc);
56
+
57
+ // Save to file
58
+ const outputFile = join(__dirname, "decision.json");
59
+ writeFileSync(outputFile, JSON.stringify(decision, null, 2));
60
+
61
+ console.log("āœ… Conversion successful!");
62
+ console.log(`šŸ†” Decision ID: ${decision.decision_id}`);
63
+ console.log(`šŸ“‹ Policy ID: ${decision.policy_id}`);
64
+ console.log(`āœ… Allow: ${decision.allow}`);
65
+ console.log(`šŸ“ Reasons: ${decision.reasons.length} reasons`);
66
+ console.log(`ā° Expires In: ${decision.expires_in} seconds`);
67
+ console.log(`šŸ“ Output saved to: ${outputFile}`);
68
+
69
+ // Log the converted data
70
+ console.log("\nšŸ“„ Converted Decision Data:");
71
+ console.log("─".repeat(50));
72
+ console.log(JSON.stringify(decision, null, 2));
73
+ console.log("─".repeat(50));
74
+ } catch (error) {
75
+ console.error("āŒ Conversion failed:", error.message);
76
+ process.exit(1);
77
+ }
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Example: Convert Verifiable Credential to OAP Passport
5
+ */
6
+
7
+ import { readFileSync, writeFileSync } from "fs";
8
+ import { join, dirname } from "path";
9
+ import { fileURLToPath } from "url";
10
+ import { importVCToPassport } from "../dist/index.js";
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ // Sample Verifiable Credential (OAP Passport)
16
+ const vc = {
17
+ "@context": [
18
+ "https://www.w3.org/2018/credentials/v1",
19
+ "https://raw.githubusercontent.com/aporthq/aport-spec/refs/heads/main/oap/vc/context-oap-v1.jsonld",
20
+ ],
21
+ type: ["VerifiableCredential", "OAPPassportCredential"],
22
+ credentialSubject: {
23
+ agent_id: "550e8400-e29b-41d4-a716-446655440000",
24
+ kind: "template",
25
+ spec_version: "oap/1.0",
26
+ owner_id: "org_12345678",
27
+ owner_type: "org",
28
+ assurance_level: "L2",
29
+ status: "active",
30
+ capabilities: [
31
+ {
32
+ id: "finance.payment.refund",
33
+ params: { currency_limits: { USD: { max_per_tx: 5000 } } },
34
+ },
35
+ { id: "data.export", params: { max_rows: 100000 } },
36
+ ],
37
+ limits: {
38
+ "finance.payment.refund": {
39
+ currency_limits: {
40
+ USD: { max_per_tx: 5000, daily_cap: 50000 },
41
+ },
42
+ reason_codes: ["customer_request", "defective_product"],
43
+ idempotency_required: true,
44
+ },
45
+ },
46
+ regions: ["US", "CA"],
47
+ metadata: {
48
+ name: "Customer Support AI",
49
+ description: "AI agent for customer support operations",
50
+ },
51
+ created_at: "2024-01-01T00:00:00Z",
52
+ updated_at: "2024-01-15T10:30:00Z",
53
+ version: "1.0.0",
54
+ },
55
+ issuer: "https://aport.io",
56
+ issuanceDate: "2024-01-01T00:00:00Z",
57
+ expirationDate: "2025-01-01T00:00:00Z",
58
+ proof: {
59
+ type: "Ed25519Signature2020",
60
+ created: "2024-01-01T00:00:00Z",
61
+ verificationMethod:
62
+ "https://aport.io/.well-known/oap/keys.json#ap_registry_ed25519_2024",
63
+ proofPurpose: "assertionMethod",
64
+ jws: "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVkZW50aWFsU3ViamVjdCI6eyJhZ2VudF9pZCI6IjU1MGU4NDAwLWUyOWItNDFkNC1hNzE2LTQ0NjY1NTQ0MDAwMCIsImtpbmQiOiJ0ZW1wbGF0ZSIsInNwZWNfdmVyc2lvbiI6Im9hcC8xLjAiLCJvd25lcl9pZCI6Im9yZ18xMjM0NTY3OCIsIm93bmVyX3R5cGUiOiJvcmciLCJhc3N1cmFuY2VfbGV2ZWwiOiJMMiIsInN0YXR1cyI6ImFjdGl2ZSIsImNhcGFiaWxpdGllcyI6W3siaWQiOiJwYXltZW50cy5yZWZ1bmQiLCJwYXJhbXMiOnsiY3VycmVuY3lfbGltaXRzIjp7IlVTRCI6eyJtYXhfcGVyX3R4Ijo1MDAwfX19fSx7ImlkIjoiZGF0YS5leHBvcnQiLCJwYXJhbXMiOnsibWF4X3Jvd3MiOjEwMDAwMH19XSwibGltaXRzIjp7InBheW1lbnRzLnJlZnVuZCI6eyJjdXJyZW5jeV9saW1pdHMiOnsiVVNEIjp7Im1heF9wZXJfdHgiOjUwMDAsImRhaWx5X2NhcCI6NTAwMDB9fSwicmVhc29uX2NvZGVzIjpbImN1c3RvbWVyX3JlcXVlc3QiLCJkZWZlY3RpdmVfcHJvZHVjdCJdLCJpZGVtcG90ZW5jeV9yZXF1aXJlZCI6dHJ1ZX19LCJyZWdpb25zIjpbIlVTIiwiQ0EiXSwibWV0YWRhdGEiOnsibmFtZSI6IkN1c3RvbWVyIFN1cHBvcnQgQUkiLCJkZXNjcmlwdGlvbiI6IkFJIGFnZW50IGZvciBjdXN0b21lciBzdXBwb3J0IG9wZXJhdGlvbnMifSwiY3JlYXRlZF9hdCI6IjIwMjQtMDEtMDFUMDA6MDA6MDBaIiwidXBkYXRlZF9hdCI6IjIwMjQtMDEtMTVUMTA6MzA6MDBaIiwidmVyc2lvbiI6IjEuMC4wIn0sImlzc3VlciI6Imh0dHBzOi8vYXBpLmFwb3J0LmRldiIsImlzc3VhbmNlRGF0ZSI6IjIwMjQtMDEtMDFUMDA6MDA6MDBaIiwiZXhwaXJhdGlvbkRhdGUiOiIyMDI1LTAxLTAxVDAwOjAwOjAwWiJ9.signature",
65
+ },
66
+ };
67
+
68
+ try {
69
+ console.log("šŸ”„ Converting Verifiable Credential to OAP Passport...\n");
70
+
71
+ // Convert VC to passport
72
+ const passport = importVCToPassport(vc);
73
+
74
+ // Save to file
75
+ const outputFile = join(__dirname, "passport.json");
76
+ writeFileSync(outputFile, JSON.stringify(passport, null, 2));
77
+
78
+ console.log("āœ… Conversion successful!");
79
+ console.log(`šŸ†” Agent ID: ${passport.agent_id}`);
80
+ console.log(`šŸ“‹ Kind: ${passport.kind}`);
81
+ console.log(`šŸ” Assurance Level: ${passport.assurance_level}`);
82
+ console.log(`šŸ“Š Capabilities: ${passport.capabilities.length} capabilities`);
83
+ console.log(`šŸŒ Regions: ${passport.regions.join(", ")}`);
84
+ console.log(`šŸ“ Output saved to: ${outputFile}`);
85
+
86
+ // Log the converted data
87
+ console.log("\nšŸ“„ Converted Passport Data:");
88
+ console.log("─".repeat(50));
89
+ console.log(JSON.stringify(passport, null, 2));
90
+ console.log("─".repeat(50));
91
+ } catch (error) {
92
+ console.error("āŒ Conversion failed:", error.message);
93
+ process.exit(1);
94
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@oap/vc-tools",
3
+ "version": "1.0.0",
4
+ "description": "Open Agent Passport VC conversion tools",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "oap-vc": "./dist/cli.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "test": "node dist/test.js",
14
+ "convert": "node dist/cli.js"
15
+ },
16
+ "dependencies": {
17
+ "@noble/ed25519": "^3.0.0",
18
+ "ajv": "^8.12.0",
19
+ "ajv-formats": "^2.1.1",
20
+ "chalk": "^5.3.0",
21
+ "commander": "^11.1.0",
22
+ "crypto": "^1.0.1",
23
+ "ora": "^7.0.1"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.10.0",
27
+ "typescript": "^5.3.0"
28
+ },
29
+ "keywords": [
30
+ "oap",
31
+ "verifiable-credentials",
32
+ "vc",
33
+ "conversion",
34
+ "interoperability"
35
+ ],
36
+ "author": "Aport",
37
+ "license": "MIT"
38
+ }