@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,472 @@
1
+ lockfileVersion: '9.0'
2
+
3
+ settings:
4
+ autoInstallPeers: true
5
+ excludeLinksFromLockfile: false
6
+
7
+ importers:
8
+
9
+ .:
10
+ dependencies:
11
+ '@noble/ed25519':
12
+ specifier: ^3.0.0
13
+ version: 3.0.0
14
+ ajv:
15
+ specifier: ^8.12.0
16
+ version: 8.17.1
17
+ ajv-formats:
18
+ specifier: ^2.1.1
19
+ version: 2.1.1(ajv@8.17.1)
20
+ chalk:
21
+ specifier: ^5.3.0
22
+ version: 5.6.2
23
+ commander:
24
+ specifier: ^11.1.0
25
+ version: 11.1.0
26
+ crypto:
27
+ specifier: ^1.0.1
28
+ version: 1.0.1
29
+ jsonld:
30
+ specifier: ^8.3.3
31
+ version: 8.3.3(web-streams-polyfill@3.3.3)
32
+ ora:
33
+ specifier: ^7.0.1
34
+ version: 7.0.1
35
+ devDependencies:
36
+ '@types/jsonld':
37
+ specifier: ^1.5.15
38
+ version: 1.5.15
39
+ '@types/node':
40
+ specifier: ^20.10.0
41
+ version: 20.19.19
42
+ typescript:
43
+ specifier: ^5.3.0
44
+ version: 5.9.3
45
+
46
+ packages:
47
+
48
+ '@digitalbazaar/http-client@3.4.1':
49
+ resolution: {integrity: sha512-Ahk1N+s7urkgj7WvvUND5f8GiWEPfUw0D41hdElaqLgu8wZScI8gdI0q+qWw5N1d35x7GCRH2uk9mi+Uzo9M3g==}
50
+ engines: {node: '>=14.0'}
51
+
52
+ '@fastify/busboy@2.1.1':
53
+ resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==}
54
+ engines: {node: '>=14'}
55
+
56
+ '@noble/ed25519@3.0.0':
57
+ resolution: {integrity: sha512-QyteqMNm0GLqfa5SoYbSC3+Pvykwpn95Zgth4MFVSMKBB75ELl9tX1LAVsN4c3HXOrakHsF2gL4zWDAYCcsnzg==}
58
+
59
+ '@types/jsonld@1.5.15':
60
+ resolution: {integrity: sha512-PlAFPZjL+AuGYmwlqwKEL0IMP8M8RexH0NIPGfCVWSQ041H2rR/8OlyZSD7KsCVoN8vCfWdtWDBxX8yBVP+xow==}
61
+
62
+ '@types/node@20.19.19':
63
+ resolution: {integrity: sha512-pb1Uqj5WJP7wrcbLU7Ru4QtA0+3kAXrkutGiD26wUKzSMgNNaPARTUDQmElUXp64kh3cWdou3Q0C7qwwxqSFmg==}
64
+
65
+ abort-controller@3.0.0:
66
+ resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
67
+ engines: {node: '>=6.5'}
68
+
69
+ ajv-formats@2.1.1:
70
+ resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==}
71
+ peerDependencies:
72
+ ajv: ^8.0.0
73
+ peerDependenciesMeta:
74
+ ajv:
75
+ optional: true
76
+
77
+ ajv@8.17.1:
78
+ resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==}
79
+
80
+ ansi-regex@6.2.2:
81
+ resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==}
82
+ engines: {node: '>=12'}
83
+
84
+ base64-js@1.5.1:
85
+ resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
86
+
87
+ bl@5.1.0:
88
+ resolution: {integrity: sha512-tv1ZJHLfTDnXE6tMHv73YgSJaWR2AFuPwMntBe7XL/GBFHnT0CLnsHMogfk5+GzCDC5ZWarSCYaIGATZt9dNsQ==}
89
+
90
+ buffer@6.0.3:
91
+ resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
92
+
93
+ canonicalize@1.0.8:
94
+ resolution: {integrity: sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==}
95
+
96
+ chalk@5.6.2:
97
+ resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==}
98
+ engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
99
+
100
+ cli-cursor@4.0.0:
101
+ resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==}
102
+ engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
103
+
104
+ cli-spinners@2.9.2:
105
+ resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==}
106
+ engines: {node: '>=6'}
107
+
108
+ commander@11.1.0:
109
+ resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==}
110
+ engines: {node: '>=16'}
111
+
112
+ crypto@1.0.1:
113
+ resolution: {integrity: sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==}
114
+ deprecated: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
115
+
116
+ data-uri-to-buffer@4.0.1:
117
+ resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
118
+ engines: {node: '>= 12'}
119
+
120
+ eastasianwidth@0.2.0:
121
+ resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
122
+
123
+ emoji-regex@10.5.0:
124
+ resolution: {integrity: sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==}
125
+
126
+ event-target-shim@5.0.1:
127
+ resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
128
+ engines: {node: '>=6'}
129
+
130
+ fast-deep-equal@3.1.3:
131
+ resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
132
+
133
+ fast-uri@3.1.0:
134
+ resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==}
135
+
136
+ fetch-blob@3.2.0:
137
+ resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
138
+ engines: {node: ^12.20 || >= 14.13}
139
+
140
+ formdata-polyfill@4.0.10:
141
+ resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
142
+ engines: {node: '>=12.20.0'}
143
+
144
+ ieee754@1.2.1:
145
+ resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
146
+
147
+ inherits@2.0.4:
148
+ resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
149
+
150
+ is-interactive@2.0.0:
151
+ resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==}
152
+ engines: {node: '>=12'}
153
+
154
+ is-unicode-supported@1.3.0:
155
+ resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==}
156
+ engines: {node: '>=12'}
157
+
158
+ json-schema-traverse@1.0.0:
159
+ resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==}
160
+
161
+ jsonld@8.3.3:
162
+ resolution: {integrity: sha512-9YcilrF+dLfg9NTEof/mJLMtbdX1RJ8dbWtJgE00cMOIohb1lIyJl710vFiTaiHTl6ZYODJuBd32xFvUhmv3kg==}
163
+ engines: {node: '>=14'}
164
+
165
+ ky-universal@0.11.0:
166
+ resolution: {integrity: sha512-65KyweaWvk+uKKkCrfAf+xqN2/epw1IJDtlyCPxYffFCMR8u1sp2U65NtWpnozYfZxQ6IUzIlvUcw+hQ82U2Xw==}
167
+ engines: {node: '>=14.16'}
168
+ peerDependencies:
169
+ ky: '>=0.31.4'
170
+ web-streams-polyfill: '>=3.2.1'
171
+ peerDependenciesMeta:
172
+ web-streams-polyfill:
173
+ optional: true
174
+
175
+ ky@0.33.3:
176
+ resolution: {integrity: sha512-CasD9OCEQSFIam2U8efFK81Yeg8vNMTBUqtMOHlrcWQHqUX3HeCl9Dr31u4toV7emlH8Mymk5+9p0lL6mKb/Xw==}
177
+ engines: {node: '>=14.16'}
178
+
179
+ log-symbols@5.1.0:
180
+ resolution: {integrity: sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==}
181
+ engines: {node: '>=12'}
182
+
183
+ lru-cache@6.0.0:
184
+ resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
185
+ engines: {node: '>=10'}
186
+
187
+ mimic-fn@2.1.0:
188
+ resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
189
+ engines: {node: '>=6'}
190
+
191
+ node-domexception@1.0.0:
192
+ resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
193
+ engines: {node: '>=10.5.0'}
194
+ deprecated: Use your platform's native DOMException instead
195
+
196
+ node-fetch@3.3.2:
197
+ resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
198
+ engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
199
+
200
+ onetime@5.1.2:
201
+ resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==}
202
+ engines: {node: '>=6'}
203
+
204
+ ora@7.0.1:
205
+ resolution: {integrity: sha512-0TUxTiFJWv+JnjWm4o9yvuskpEJLXTcng8MJuKd+SzAzp2o+OP3HWqNhB4OdJRt1Vsd9/mR0oyaEYlOnL7XIRw==}
206
+ engines: {node: '>=16'}
207
+
208
+ rdf-canonize@3.4.0:
209
+ resolution: {integrity: sha512-fUeWjrkOO0t1rg7B2fdyDTvngj+9RlUyL92vOdiB7c0FPguWVsniIMjEtHH+meLBO9rzkUlUzBVXgWrjI8P9LA==}
210
+ engines: {node: '>=12'}
211
+
212
+ readable-stream@3.6.2:
213
+ resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
214
+ engines: {node: '>= 6'}
215
+
216
+ require-from-string@2.0.2:
217
+ resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
218
+ engines: {node: '>=0.10.0'}
219
+
220
+ restore-cursor@4.0.0:
221
+ resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==}
222
+ engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
223
+
224
+ safe-buffer@5.2.1:
225
+ resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
226
+
227
+ setimmediate@1.0.5:
228
+ resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==}
229
+
230
+ signal-exit@3.0.7:
231
+ resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==}
232
+
233
+ stdin-discarder@0.1.0:
234
+ resolution: {integrity: sha512-xhV7w8S+bUwlPTb4bAOUQhv8/cSS5offJuX8GQGq32ONF0ZtDWKfkdomM3HMRA+LhX6um/FZ0COqlwsjD53LeQ==}
235
+ engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
236
+
237
+ string-width@6.1.0:
238
+ resolution: {integrity: sha512-k01swCJAgQmuADB0YIc+7TuatfNvTBVOoaUWJjTB9R4VJzR5vNWzf5t42ESVZFPS8xTySF7CAdV4t/aaIm3UnQ==}
239
+ engines: {node: '>=16'}
240
+
241
+ string_decoder@1.3.0:
242
+ resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
243
+
244
+ strip-ansi@7.1.2:
245
+ resolution: {integrity: sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==}
246
+ engines: {node: '>=12'}
247
+
248
+ typescript@5.9.3:
249
+ resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
250
+ engines: {node: '>=14.17'}
251
+ hasBin: true
252
+
253
+ undici-types@6.21.0:
254
+ resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
255
+
256
+ undici@5.29.0:
257
+ resolution: {integrity: sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==}
258
+ engines: {node: '>=14.0'}
259
+
260
+ util-deprecate@1.0.2:
261
+ resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
262
+
263
+ web-streams-polyfill@3.3.3:
264
+ resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==}
265
+ engines: {node: '>= 8'}
266
+
267
+ yallist@4.0.0:
268
+ resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
269
+
270
+ snapshots:
271
+
272
+ '@digitalbazaar/http-client@3.4.1(web-streams-polyfill@3.3.3)':
273
+ dependencies:
274
+ ky: 0.33.3
275
+ ky-universal: 0.11.0(ky@0.33.3)(web-streams-polyfill@3.3.3)
276
+ undici: 5.29.0
277
+ transitivePeerDependencies:
278
+ - web-streams-polyfill
279
+
280
+ '@fastify/busboy@2.1.1': {}
281
+
282
+ '@noble/ed25519@3.0.0': {}
283
+
284
+ '@types/jsonld@1.5.15': {}
285
+
286
+ '@types/node@20.19.19':
287
+ dependencies:
288
+ undici-types: 6.21.0
289
+
290
+ abort-controller@3.0.0:
291
+ dependencies:
292
+ event-target-shim: 5.0.1
293
+
294
+ ajv-formats@2.1.1(ajv@8.17.1):
295
+ optionalDependencies:
296
+ ajv: 8.17.1
297
+
298
+ ajv@8.17.1:
299
+ dependencies:
300
+ fast-deep-equal: 3.1.3
301
+ fast-uri: 3.1.0
302
+ json-schema-traverse: 1.0.0
303
+ require-from-string: 2.0.2
304
+
305
+ ansi-regex@6.2.2: {}
306
+
307
+ base64-js@1.5.1: {}
308
+
309
+ bl@5.1.0:
310
+ dependencies:
311
+ buffer: 6.0.3
312
+ inherits: 2.0.4
313
+ readable-stream: 3.6.2
314
+
315
+ buffer@6.0.3:
316
+ dependencies:
317
+ base64-js: 1.5.1
318
+ ieee754: 1.2.1
319
+
320
+ canonicalize@1.0.8: {}
321
+
322
+ chalk@5.6.2: {}
323
+
324
+ cli-cursor@4.0.0:
325
+ dependencies:
326
+ restore-cursor: 4.0.0
327
+
328
+ cli-spinners@2.9.2: {}
329
+
330
+ commander@11.1.0: {}
331
+
332
+ crypto@1.0.1: {}
333
+
334
+ data-uri-to-buffer@4.0.1: {}
335
+
336
+ eastasianwidth@0.2.0: {}
337
+
338
+ emoji-regex@10.5.0: {}
339
+
340
+ event-target-shim@5.0.1: {}
341
+
342
+ fast-deep-equal@3.1.3: {}
343
+
344
+ fast-uri@3.1.0: {}
345
+
346
+ fetch-blob@3.2.0:
347
+ dependencies:
348
+ node-domexception: 1.0.0
349
+ web-streams-polyfill: 3.3.3
350
+
351
+ formdata-polyfill@4.0.10:
352
+ dependencies:
353
+ fetch-blob: 3.2.0
354
+
355
+ ieee754@1.2.1: {}
356
+
357
+ inherits@2.0.4: {}
358
+
359
+ is-interactive@2.0.0: {}
360
+
361
+ is-unicode-supported@1.3.0: {}
362
+
363
+ json-schema-traverse@1.0.0: {}
364
+
365
+ jsonld@8.3.3(web-streams-polyfill@3.3.3):
366
+ dependencies:
367
+ '@digitalbazaar/http-client': 3.4.1(web-streams-polyfill@3.3.3)
368
+ canonicalize: 1.0.8
369
+ lru-cache: 6.0.0
370
+ rdf-canonize: 3.4.0
371
+ transitivePeerDependencies:
372
+ - web-streams-polyfill
373
+
374
+ ky-universal@0.11.0(ky@0.33.3)(web-streams-polyfill@3.3.3):
375
+ dependencies:
376
+ abort-controller: 3.0.0
377
+ ky: 0.33.3
378
+ node-fetch: 3.3.2
379
+ optionalDependencies:
380
+ web-streams-polyfill: 3.3.3
381
+
382
+ ky@0.33.3: {}
383
+
384
+ log-symbols@5.1.0:
385
+ dependencies:
386
+ chalk: 5.6.2
387
+ is-unicode-supported: 1.3.0
388
+
389
+ lru-cache@6.0.0:
390
+ dependencies:
391
+ yallist: 4.0.0
392
+
393
+ mimic-fn@2.1.0: {}
394
+
395
+ node-domexception@1.0.0: {}
396
+
397
+ node-fetch@3.3.2:
398
+ dependencies:
399
+ data-uri-to-buffer: 4.0.1
400
+ fetch-blob: 3.2.0
401
+ formdata-polyfill: 4.0.10
402
+
403
+ onetime@5.1.2:
404
+ dependencies:
405
+ mimic-fn: 2.1.0
406
+
407
+ ora@7.0.1:
408
+ dependencies:
409
+ chalk: 5.6.2
410
+ cli-cursor: 4.0.0
411
+ cli-spinners: 2.9.2
412
+ is-interactive: 2.0.0
413
+ is-unicode-supported: 1.3.0
414
+ log-symbols: 5.1.0
415
+ stdin-discarder: 0.1.0
416
+ string-width: 6.1.0
417
+ strip-ansi: 7.1.2
418
+
419
+ rdf-canonize@3.4.0:
420
+ dependencies:
421
+ setimmediate: 1.0.5
422
+
423
+ readable-stream@3.6.2:
424
+ dependencies:
425
+ inherits: 2.0.4
426
+ string_decoder: 1.3.0
427
+ util-deprecate: 1.0.2
428
+
429
+ require-from-string@2.0.2: {}
430
+
431
+ restore-cursor@4.0.0:
432
+ dependencies:
433
+ onetime: 5.1.2
434
+ signal-exit: 3.0.7
435
+
436
+ safe-buffer@5.2.1: {}
437
+
438
+ setimmediate@1.0.5: {}
439
+
440
+ signal-exit@3.0.7: {}
441
+
442
+ stdin-discarder@0.1.0:
443
+ dependencies:
444
+ bl: 5.1.0
445
+
446
+ string-width@6.1.0:
447
+ dependencies:
448
+ eastasianwidth: 0.2.0
449
+ emoji-regex: 10.5.0
450
+ strip-ansi: 7.1.2
451
+
452
+ string_decoder@1.3.0:
453
+ dependencies:
454
+ safe-buffer: 5.2.1
455
+
456
+ strip-ansi@7.1.2:
457
+ dependencies:
458
+ ansi-regex: 6.2.2
459
+
460
+ typescript@5.9.3: {}
461
+
462
+ undici-types@6.21.0: {}
463
+
464
+ undici@5.29.0:
465
+ dependencies:
466
+ '@fastify/busboy': 2.1.1
467
+
468
+ util-deprecate@1.0.2: {}
469
+
470
+ web-streams-polyfill@3.3.3: {}
471
+
472
+ yallist@4.0.0: {}
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * OAP VC Conversion CLI Tool
5
+ *
6
+ * Command-line interface for converting between OAP objects and Verifiable Credentials
7
+ */
8
+
9
+ import { Command } from "commander";
10
+ import { readFileSync, writeFileSync } from "fs";
11
+ import chalk from "chalk";
12
+ import ora from "ora";
13
+ import {
14
+ exportPassportToVC,
15
+ exportDecisionToVC,
16
+ importVCToPassport,
17
+ importVCToDecision,
18
+ OAPPassport,
19
+ OAPDecision,
20
+ VerifiableCredential,
21
+ RegistryKey,
22
+ } from "./index.js";
23
+
24
+ const program = new Command();
25
+
26
+ program
27
+ .name("oap-vc")
28
+ .description("Open Agent Passport VC conversion tools")
29
+ .version("1.0.0");
30
+
31
+ // Export commands
32
+ program
33
+ .command("export")
34
+ .description("Export OAP objects to Verifiable Credentials")
35
+ .option("-t, --type <type>", "Object type: passport or decision", "passport")
36
+ .option("-i, --input <file>", "Input OAP JSON file")
37
+ .option("-o, --output <file>", "Output VC JSON file")
38
+ .option("-k, --key <file>", "Registry key JSON file")
39
+ .option("-v, --verbose", "Show converted data in output", false)
40
+ .action(async (options) => {
41
+ const spinner = ora("Converting OAP to VC...").start();
42
+
43
+ try {
44
+ // Load input file
45
+ const inputData = JSON.parse(readFileSync(options.input, "utf8"));
46
+
47
+ // Load registry key
48
+ const registryKey: RegistryKey = JSON.parse(
49
+ readFileSync(options.key, "utf8")
50
+ );
51
+
52
+ let vc: VerifiableCredential;
53
+
54
+ if (options.type === "passport") {
55
+ vc = await exportPassportToVC(inputData as OAPPassport, registryKey);
56
+ } else if (options.type === "decision") {
57
+ vc = await exportDecisionToVC(inputData as OAPDecision, registryKey);
58
+ } else {
59
+ throw new Error('Invalid type. Must be "passport" or "decision"');
60
+ }
61
+
62
+ // Write output file
63
+ writeFileSync(options.output, JSON.stringify(vc, null, 2));
64
+
65
+ spinner.succeed(
66
+ chalk.green(`Successfully exported ${options.type} to VC`)
67
+ );
68
+ console.log(chalk.blue(`Output written to: ${options.output}`));
69
+
70
+ // Log the converted data if verbose flag is set
71
+ if (options.verbose) {
72
+ console.log(chalk.cyan("\nšŸ“„ Converted VC Data:"));
73
+ console.log(chalk.gray("─".repeat(50)));
74
+ console.log(JSON.stringify(vc, null, 2));
75
+ console.log(chalk.gray("─".repeat(50)));
76
+ }
77
+ } catch (error) {
78
+ spinner.fail(chalk.red("Export failed"));
79
+ console.error(
80
+ chalk.red(
81
+ `Error: ${error instanceof Error ? error.message : "Unknown error"}`
82
+ )
83
+ );
84
+ process.exit(1);
85
+ }
86
+ });
87
+
88
+ // Import commands
89
+ program
90
+ .command("import")
91
+ .description("Import Verifiable Credentials to OAP objects")
92
+ .option("-t, --type <type>", "Object type: passport or decision", "passport")
93
+ .option("-i, --input <file>", "Input VC JSON file")
94
+ .option("-o, --output <file>", "Output OAP JSON file")
95
+ .option("-v, --verbose", "Show converted data in output", false)
96
+ .action(async (options) => {
97
+ const spinner = ora("Converting VC to OAP...").start();
98
+
99
+ try {
100
+ // Load input file
101
+ const vc: VerifiableCredential = JSON.parse(
102
+ readFileSync(options.input, "utf8")
103
+ );
104
+
105
+ let oapObject: OAPPassport | OAPDecision;
106
+
107
+ if (options.type === "passport") {
108
+ oapObject = await importVCToPassport(vc);
109
+ } else if (options.type === "decision") {
110
+ oapObject = await importVCToDecision(vc);
111
+ } else {
112
+ throw new Error('Invalid type. Must be "passport" or "decision"');
113
+ }
114
+
115
+ // Write output file
116
+ writeFileSync(options.output, JSON.stringify(oapObject, null, 2));
117
+
118
+ spinner.succeed(
119
+ chalk.green(`Successfully imported VC to ${options.type}`)
120
+ );
121
+ console.log(chalk.blue(`Output written to: ${options.output}`));
122
+
123
+ // Log the converted data if verbose flag is set
124
+ if (options.verbose) {
125
+ console.log(chalk.cyan(`\nšŸ“„ Converted ${options.type} Data:`));
126
+ console.log(chalk.gray("─".repeat(50)));
127
+ console.log(JSON.stringify(oapObject, null, 2));
128
+ console.log(chalk.gray("─".repeat(50)));
129
+ }
130
+ } catch (error) {
131
+ spinner.fail(chalk.red("Import failed"));
132
+ console.error(
133
+ chalk.red(
134
+ `Error: ${error instanceof Error ? error.message : "Unknown error"}`
135
+ )
136
+ );
137
+ process.exit(1);
138
+ }
139
+ });
140
+
141
+ // Validate commands
142
+ program
143
+ .command("validate")
144
+ .description("Validate OAP objects or VCs")
145
+ .option(
146
+ "-t, --type <type>",
147
+ "Object type: passport, decision, or vc",
148
+ "passport"
149
+ )
150
+ .option("-i, --input <file>", "Input JSON file")
151
+ .action(async (options) => {
152
+ const spinner = ora("Validating...").start();
153
+
154
+ try {
155
+ const data = JSON.parse(readFileSync(options.input, "utf8"));
156
+
157
+ let isValid = false;
158
+
159
+ if (options.type === "passport") {
160
+ isValid = data.agent_id && data.kind && data.spec_version;
161
+ } else if (options.type === "decision") {
162
+ isValid = data.decision_id && data.policy_id && data.agent_id;
163
+ } else if (options.type === "vc") {
164
+ isValid = data["@context"] && data.type && data.credentialSubject;
165
+ } else {
166
+ throw new Error(
167
+ 'Invalid type. Must be "passport", "decision", or "vc"'
168
+ );
169
+ }
170
+
171
+ if (isValid) {
172
+ spinner.succeed(chalk.green("Validation passed"));
173
+ } else {
174
+ spinner.fail(chalk.red("Validation failed"));
175
+ process.exit(1);
176
+ }
177
+ } catch (error) {
178
+ spinner.fail(chalk.red("Validation failed"));
179
+ console.error(
180
+ chalk.red(
181
+ `Error: ${error instanceof Error ? error.message : "Unknown error"}`
182
+ )
183
+ );
184
+ process.exit(1);
185
+ }
186
+ });
187
+
188
+ // Generate registry key
189
+ program
190
+ .command("generate-key")
191
+ .description("Generate a new registry key")
192
+ .option("-o, --output <file>", "Output key JSON file", "registry-key.json")
193
+ .action(async (options) => {
194
+ const spinner = ora("Generating registry key...").start();
195
+
196
+ try {
197
+ // Generate a sample registry key
198
+ const registryKey: RegistryKey = {
199
+ issuer: "https://aport.io",
200
+ kid: "key-" + Date.now(),
201
+ publicKey: "placeholder-public-key",
202
+ privateKey: "placeholder-private-key",
203
+ };
204
+
205
+ writeFileSync(options.output, JSON.stringify(registryKey, null, 2));
206
+
207
+ spinner.succeed(chalk.green("Registry key generated"));
208
+ console.log(chalk.blue(`Key written to: ${options.output}`));
209
+ console.log(
210
+ chalk.yellow(
211
+ "Note: This is a placeholder key. In production, use proper Ed25519 key generation."
212
+ )
213
+ );
214
+ } catch (error) {
215
+ spinner.fail(chalk.red("Key generation failed"));
216
+ console.error(
217
+ chalk.red(
218
+ `Error: ${error instanceof Error ? error.message : "Unknown error"}`
219
+ )
220
+ );
221
+ process.exit(1);
222
+ }
223
+ });
224
+
225
+ // Parse command line arguments
226
+ program.parse();