@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.
- package/LICENSE +217 -0
- package/README.md +481 -0
- package/bin/agent-guardrails +133 -0
- package/bin/aport-create-passport.sh +444 -0
- package/bin/aport-cursor-hook.sh +90 -0
- package/bin/aport-guardrail-api.sh +108 -0
- package/bin/aport-guardrail-bash.sh +394 -0
- package/bin/aport-guardrail-v2.sh +5 -0
- package/bin/aport-guardrail.sh +5 -0
- package/bin/aport-resolve-paths.sh +71 -0
- package/bin/aport-status.sh +276 -0
- package/bin/frameworks/crewai.sh +49 -0
- package/bin/frameworks/cursor.sh +95 -0
- package/bin/frameworks/langchain.sh +48 -0
- package/bin/frameworks/n8n.sh +36 -0
- package/bin/frameworks/openclaw.sh +19 -0
- package/bin/lib/allowlist.sh +18 -0
- package/bin/lib/common.sh +28 -0
- package/bin/lib/config.sh +46 -0
- package/bin/lib/constants.sh +232 -0
- package/bin/lib/detect.sh +65 -0
- package/bin/lib/error.sh +269 -0
- package/bin/lib/passport.sh +19 -0
- package/bin/lib/templates/.gitkeep +1 -0
- package/bin/lib/templates/config.yaml +6 -0
- package/bin/lib/validation.sh +206 -0
- package/bin/openclaw +660 -0
- package/docs/ADDING_A_FRAMEWORK.md +87 -0
- package/docs/AGENTS.md.example +40 -0
- package/docs/CODE_REVIEW.md +192 -0
- package/docs/DEPLOYMENT_READINESS.md +81 -0
- package/docs/FAQ_SECURITY_SCANNERS.md +373 -0
- package/docs/FRAMEWORK_ROADMAP.md +41 -0
- package/docs/HOSTED_PASSPORT_SETUP.md +362 -0
- package/docs/IMPLEMENTING_YOUR_OWN_EVALUATOR.md +433 -0
- package/docs/OPENCLAW_COMPATIBILITY.md +73 -0
- package/docs/OPENCLAW_LOCAL_INTEGRATION.md +596 -0
- package/docs/OPENCLAW_TOOLS_AND_POLICIES.md +54 -0
- package/docs/QUICKSTART.md +470 -0
- package/docs/QUICKSTART_OPENCLAW_PLUGIN.md +470 -0
- package/docs/README.md +28 -0
- package/docs/RELEASE.md +87 -0
- package/docs/REPO_LAYOUT.md +47 -0
- package/docs/SKILLS_ECOSYSTEM_ANALYSIS_FEB17.md +1260 -0
- package/docs/TOOL_POLICY_MAPPING.md +46 -0
- package/docs/UPGRADE.md +46 -0
- package/docs/VERIFICATION_METHODS.md +97 -0
- package/docs/assets/README.md +8 -0
- package/docs/assets/porter.svg +54 -0
- package/docs/development/ERROR_CODES.md +616 -0
- package/docs/frameworks/GITHUB_ISSUE_PROPOSALS.md +1105 -0
- package/docs/frameworks/crewai.md +114 -0
- package/docs/frameworks/cursor.md +159 -0
- package/docs/frameworks/langchain.md +72 -0
- package/docs/frameworks/n8n.md +40 -0
- package/docs/frameworks/openclaw.md +40 -0
- package/docs/launch/ADD_APORT_AWESOME_LISTS_INSTRUCTIONS.md +146 -0
- package/docs/launch/ANNOUNCEMENT_GUIDE.md +266 -0
- package/docs/launch/AWESOME_REPOS.md +53 -0
- package/docs/launch/CURSOR_VSCODE_HOOKS_RESEARCH.md +77 -0
- package/docs/launch/DEMO_TERMINAL_OUTPUT.txt +48 -0
- package/docs/launch/DRY_AND_PLAN_CHECKLIST.md +47 -0
- package/docs/launch/EVIDENCE_README.md +61 -0
- package/docs/launch/EVIDENCE_TERMINAL_CAPTURE.txt +10 -0
- package/docs/launch/FRAMEWORK_SUPPORT_PLAN.md +1640 -0
- package/docs/launch/LAUNCH_READINESS_CHECKLIST.md +237 -0
- package/docs/launch/LAUNCH_STRATEGY_SUMMARY.md +464 -0
- package/docs/launch/OPENCLAW_FEEDBACK_AND_FIXES.md +85 -0
- package/docs/launch/POST_1_VALENTINE_IMPROVED.md +233 -0
- package/docs/launch/POST_2_GUARDRAIL_IMPROVED.md +369 -0
- package/docs/launch/PRE_LAUNCH_FIXES.md +766 -0
- package/docs/launch/QUICK_LAUNCH_CHECKLIST.md +400 -0
- package/docs/launch/READINESS_SUMMARY.md +262 -0
- package/docs/launch/README.md +68 -0
- package/docs/launch/USER_STORIES.md +327 -0
- package/docs/launch/scripts/add-aport-awesome-pr.sh +69 -0
- package/docs/operations/MONITORING.md +588 -0
- package/docs/reviews/2026-02-18-staff-review.md +268 -0
- package/extensions/openclaw-aport/README.md +415 -0
- package/extensions/openclaw-aport/index.js +625 -0
- package/extensions/openclaw-aport/openclaw-aport.js +7 -0
- package/extensions/openclaw-aport/openclaw.plugin.json +46 -0
- package/extensions/openclaw-aport/package.json +36 -0
- package/extensions/openclaw-aport/test.js +307 -0
- package/external/aport-policies/README.md +363 -0
- package/external/aport-policies/agent.session.create.v1/README.md +345 -0
- package/external/aport-policies/agent.session.create.v1/policy.json +162 -0
- package/external/aport-policies/agent.tool.register.v1/README.md +361 -0
- package/external/aport-policies/agent.tool.register.v1/policy.json +172 -0
- package/external/aport-policies/code.release.publish.v1/README.md +51 -0
- package/external/aport-policies/code.release.publish.v1/policy.json +121 -0
- package/external/aport-policies/code.repository.merge.v1/README.md +287 -0
- package/external/aport-policies/code.repository.merge.v1/express.example.js +332 -0
- package/external/aport-policies/code.repository.merge.v1/fastapi.example.py +370 -0
- package/external/aport-policies/code.repository.merge.v1/policy.json +162 -0
- package/external/aport-policies/data.export.create.v1/README.md +226 -0
- package/external/aport-policies/data.export.create.v1/express.example.js +172 -0
- package/external/aport-policies/data.export.create.v1/fastapi.example.py +165 -0
- package/external/aport-policies/data.export.create.v1/policy.json +133 -0
- package/external/aport-policies/data.report.ingest.v1/README.md +134 -0
- package/external/aport-policies/data.report.ingest.v1/express.example.js +105 -0
- package/external/aport-policies/data.report.ingest.v1/minimal-example.js +68 -0
- package/external/aport-policies/data.report.ingest.v1/policy.json +174 -0
- package/external/aport-policies/finance.crypto.trade.v1/README.md +146 -0
- package/external/aport-policies/finance.crypto.trade.v1/express.example.js +109 -0
- package/external/aport-policies/finance.crypto.trade.v1/minimal-example.js +65 -0
- package/external/aport-policies/finance.crypto.trade.v1/policy.json +176 -0
- package/external/aport-policies/finance.payment.charge.v1/README.md +326 -0
- package/external/aport-policies/finance.payment.charge.v1/express.example.js +250 -0
- package/external/aport-policies/finance.payment.charge.v1/fastapi.example.py +227 -0
- package/external/aport-policies/finance.payment.charge.v1/minimal-example.js +64 -0
- package/external/aport-policies/finance.payment.charge.v1/policy.json +224 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/contexts.jsonl +12 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/expected.jsonl +12 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/passport.instance.json +42 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/passport.template.json +40 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/payments-charge-policy.test.js +817 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/test_payments_charge_policy.py +486 -0
- package/external/aport-policies/finance.payment.payout.v1/README.md +78 -0
- package/external/aport-policies/finance.payment.payout.v1/policy.json +181 -0
- package/external/aport-policies/finance.payment.refund.v1/README.md +275 -0
- package/external/aport-policies/finance.payment.refund.v1/express.example.js +167 -0
- package/external/aport-policies/finance.payment.refund.v1/fastapi.example.py +136 -0
- package/external/aport-policies/finance.payment.refund.v1/minimal-example.js +183 -0
- package/external/aport-policies/finance.payment.refund.v1/policy.json +216 -0
- package/external/aport-policies/finance.payment.refund.v1/tests/refunds-policy.test.js +924 -0
- package/external/aport-policies/finance.payment.refund.v1/tests/test_refunds_policy.py +778 -0
- package/external/aport-policies/finance.transaction.execute.v1/README.md +309 -0
- package/external/aport-policies/finance.transaction.execute.v1/express.example.js +261 -0
- package/external/aport-policies/finance.transaction.execute.v1/fastapi.example.py +231 -0
- package/external/aport-policies/finance.transaction.execute.v1/minimal-example.js +78 -0
- package/external/aport-policies/finance.transaction.execute.v1/policy.json +189 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/contexts.jsonl +12 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/expected.jsonl +12 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/passport.instance.json +42 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/passport.template.json +42 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/test_transactions_policy.py +214 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/transactions-policy.test.js +306 -0
- package/external/aport-policies/governance.data.access.v1/README.md +292 -0
- package/external/aport-policies/governance.data.access.v1/express.example.js +321 -0
- package/external/aport-policies/governance.data.access.v1/fastapi.example.py +279 -0
- package/external/aport-policies/governance.data.access.v1/minimal-example.js +65 -0
- package/external/aport-policies/governance.data.access.v1/policy.json +208 -0
- package/external/aport-policies/governance.data.access.v1/tests/contexts.jsonl +12 -0
- package/external/aport-policies/governance.data.access.v1/tests/data-access-policy.test.js +308 -0
- package/external/aport-policies/governance.data.access.v1/tests/expected.jsonl +12 -0
- package/external/aport-policies/governance.data.access.v1/tests/passport.instance.json +56 -0
- package/external/aport-policies/governance.data.access.v1/tests/passport.template.json +56 -0
- package/external/aport-policies/governance.data.access.v1/tests/test_data_access_policy.py +214 -0
- package/external/aport-policies/legal.contract.review.v1/README.md +109 -0
- package/external/aport-policies/legal.contract.review.v1/policy.json +378 -0
- package/external/aport-policies/legal.contract.review.v1/tests/legal-contract-review-policy.test.js +609 -0
- package/external/aport-policies/legal.contract.review.v1/tests/passport.template.json +49 -0
- package/external/aport-policies/mcp.tool.execute.v1/README.md +301 -0
- package/external/aport-policies/mcp.tool.execute.v1/policy.json +141 -0
- package/external/aport-policies/messaging.message.send.v1/README.md +230 -0
- package/external/aport-policies/messaging.message.send.v1/express.example.js +183 -0
- package/external/aport-policies/messaging.message.send.v1/fastapi.example.py +193 -0
- package/external/aport-policies/messaging.message.send.v1/policy.json +144 -0
- package/external/aport-policies/policy-template.json +107 -0
- package/external/aport-policies/system.command.execute.v1/README.md +275 -0
- package/external/aport-policies/system.command.execute.v1/policy.json +146 -0
- package/external/aport-spec/CONTRIBUTING.md +273 -0
- package/external/aport-spec/LICENSE +21 -0
- package/external/aport-spec/README.md +168 -0
- package/external/aport-spec/conformance/README.md +294 -0
- package/external/aport-spec/conformance/cases/data.export.v1/contexts/allow_users.json +6 -0
- package/external/aport-spec/conformance/cases/data.export.v1/contexts/deny_pii.json +6 -0
- package/external/aport-spec/conformance/cases/data.export.v1/expected/allow_users.decision.json +19 -0
- package/external/aport-spec/conformance/cases/data.export.v1/expected/deny_pii.decision.json +19 -0
- package/external/aport-spec/conformance/cases/data.export.v1/passports/template.json +29 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/allow_50usd.json +9 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_150usd.json +9 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_currency.json +9 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/allow_50usd.decision.json +19 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_150usd.decision.json +19 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_currency.decision.json +19 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/passports/template.json +42 -0
- package/external/aport-spec/conformance/package.json +44 -0
- package/external/aport-spec/conformance/pnpm-lock.yaml +642 -0
- package/external/aport-spec/conformance/src/cases.ts +371 -0
- package/external/aport-spec/conformance/src/ed25519.ts +167 -0
- package/external/aport-spec/conformance/src/jcs.ts +85 -0
- package/external/aport-spec/conformance/src/runner.ts +533 -0
- package/external/aport-spec/conformance/src/validators.ts +185 -0
- package/external/aport-spec/conformance/test-runner.js +315 -0
- package/external/aport-spec/conformance/tsconfig.json +21 -0
- package/external/aport-spec/error-schema.json +192 -0
- package/external/aport-spec/index.json +12 -0
- package/external/aport-spec/integrations/clawmoat/README.md +12 -0
- package/external/aport-spec/integrations/shield/README.md +245 -0
- package/external/aport-spec/integrations/shield/adapters/index.js +116 -0
- package/external/aport-spec/integrations/shield/adapters/system-command-execute.js +133 -0
- package/external/aport-spec/integrations/shield/test/README.md +58 -0
- package/external/aport-spec/integrations/shield/test/shield.md +40 -0
- package/external/aport-spec/integrations/shield/test/test-shield-to-verify.js +274 -0
- package/external/aport-spec/metrics-schema.json +504 -0
- package/external/aport-spec/oap/CHANGELOG.md +54 -0
- package/external/aport-spec/oap/VERSION.md +40 -0
- package/external/aport-spec/oap/capability-registry.md +229 -0
- package/external/aport-spec/oap/conformance.md +257 -0
- package/external/aport-spec/oap/decision-schema.json +114 -0
- package/external/aport-spec/oap/examples/context.refund.usd.50.json +9 -0
- package/external/aport-spec/oap/examples/decision.allow.sample.json +20 -0
- package/external/aport-spec/oap/examples/decision.deny.sample.json +23 -0
- package/external/aport-spec/oap/examples/passport.instance.v1.json +50 -0
- package/external/aport-spec/oap/examples/passport.template.v1.json +71 -0
- package/external/aport-spec/oap/oap-spec.md +426 -0
- package/external/aport-spec/oap/passport-schema.json +396 -0
- package/external/aport-spec/oap/security.md +213 -0
- package/external/aport-spec/oap/vc/context-oap-v1.jsonld +137 -0
- package/external/aport-spec/oap/vc/examples/oap-decision-vc.json +37 -0
- package/external/aport-spec/oap/vc/examples/oap-passport-vc.json +68 -0
- package/external/aport-spec/oap/vc/tools/INTEGRATION.md +375 -0
- package/external/aport-spec/oap/vc/tools/README.md +278 -0
- package/external/aport-spec/oap/vc/tools/examples/decision-to-vc.js +66 -0
- package/external/aport-spec/oap/vc/tools/examples/passport-to-vc.js +83 -0
- package/external/aport-spec/oap/vc/tools/examples/vc-to-decision.js +77 -0
- package/external/aport-spec/oap/vc/tools/examples/vc-to-passport.js +94 -0
- package/external/aport-spec/oap/vc/tools/package.json +38 -0
- package/external/aport-spec/oap/vc/tools/pnpm-lock.yaml +472 -0
- package/external/aport-spec/oap/vc/tools/src/cli.ts +226 -0
- package/external/aport-spec/oap/vc/tools/src/crypto-utils.ts +427 -0
- package/external/aport-spec/oap/vc/tools/src/index.ts +653 -0
- package/external/aport-spec/oap/vc/tools/src/test.ts +148 -0
- package/external/aport-spec/oap/vc/tools/src/vp.ts +382 -0
- package/external/aport-spec/oap/vc/tools/test-simple.js +214 -0
- package/external/aport-spec/oap/vc/tools/tsconfig.json +19 -0
- package/external/aport-spec/oap/vc/vc-mapping.md +443 -0
- package/external/aport-spec/passport-schema.json +586 -0
- package/external/aport-spec/rate-limiting.md +136 -0
- package/external/aport-spec/transport-profile.md +325 -0
- package/external/aport-spec/webhook-spec.md +314 -0
- package/package.json +70 -0
- package/skills/aport-agent-guardrail/SKILL.md +314 -0
- package/src/evaluator.js +252 -0
- package/src/server/index.js +72 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": {
|
|
3
|
+
"oap": "https://github.com/aporthq/aport-spec/oap/v1#",
|
|
4
|
+
"vc": "https://www.w3.org/2018/credentials/v1",
|
|
5
|
+
"passport": {
|
|
6
|
+
"@id": "oap:passport",
|
|
7
|
+
"@type": "@id"
|
|
8
|
+
},
|
|
9
|
+
"decision": {
|
|
10
|
+
"@id": "oap:decision",
|
|
11
|
+
"@type": "@id"
|
|
12
|
+
},
|
|
13
|
+
"passport_id": {
|
|
14
|
+
"@id": "oap:passportId",
|
|
15
|
+
"@type": "xsd:string"
|
|
16
|
+
},
|
|
17
|
+
"kind": {
|
|
18
|
+
"@id": "oap:kind",
|
|
19
|
+
"@type": "xsd:string"
|
|
20
|
+
},
|
|
21
|
+
"spec_version": {
|
|
22
|
+
"@id": "oap:specVersion",
|
|
23
|
+
"@type": "xsd:string"
|
|
24
|
+
},
|
|
25
|
+
"parent_agent_id": {
|
|
26
|
+
"@id": "oap:parentAgentId",
|
|
27
|
+
"@type": "xsd:string"
|
|
28
|
+
},
|
|
29
|
+
"owner_id": {
|
|
30
|
+
"@id": "oap:ownerId",
|
|
31
|
+
"@type": "xsd:string"
|
|
32
|
+
},
|
|
33
|
+
"owner_type": {
|
|
34
|
+
"@id": "oap:ownerType",
|
|
35
|
+
"@type": "xsd:string"
|
|
36
|
+
},
|
|
37
|
+
"assurance_level": {
|
|
38
|
+
"@id": "oap:assuranceLevel",
|
|
39
|
+
"@type": "xsd:string"
|
|
40
|
+
},
|
|
41
|
+
"status": {
|
|
42
|
+
"@id": "oap:status",
|
|
43
|
+
"@type": "xsd:string"
|
|
44
|
+
},
|
|
45
|
+
"capabilities": {
|
|
46
|
+
"@id": "oap:capabilities",
|
|
47
|
+
"@type": "xsd:string",
|
|
48
|
+
"@container": "@list"
|
|
49
|
+
},
|
|
50
|
+
"limits": {
|
|
51
|
+
"@id": "oap:limits",
|
|
52
|
+
"@type": "oap:Limits"
|
|
53
|
+
},
|
|
54
|
+
"regions": {
|
|
55
|
+
"@id": "oap:regions",
|
|
56
|
+
"@type": "xsd:string",
|
|
57
|
+
"@container": "@list"
|
|
58
|
+
},
|
|
59
|
+
"metadata": {
|
|
60
|
+
"@id": "oap:metadata",
|
|
61
|
+
"@type": "oap:Metadata"
|
|
62
|
+
},
|
|
63
|
+
"created_at": {
|
|
64
|
+
"@id": "oap:createdAt",
|
|
65
|
+
"@type": "xsd:dateTime"
|
|
66
|
+
},
|
|
67
|
+
"updated_at": {
|
|
68
|
+
"@id": "oap:updatedAt",
|
|
69
|
+
"@type": "xsd:dateTime"
|
|
70
|
+
},
|
|
71
|
+
"version": {
|
|
72
|
+
"@id": "oap:version",
|
|
73
|
+
"@type": "xsd:string"
|
|
74
|
+
},
|
|
75
|
+
"decision_id": {
|
|
76
|
+
"@id": "oap:decisionId",
|
|
77
|
+
"@type": "xsd:string"
|
|
78
|
+
},
|
|
79
|
+
"policy_id": {
|
|
80
|
+
"@id": "oap:policyId",
|
|
81
|
+
"@type": "xsd:string"
|
|
82
|
+
},
|
|
83
|
+
"allow": {
|
|
84
|
+
"@id": "oap:allow",
|
|
85
|
+
"@type": "xsd:boolean"
|
|
86
|
+
},
|
|
87
|
+
"reasons": {
|
|
88
|
+
"@id": "oap:reasons",
|
|
89
|
+
"@type": "oap:Reason",
|
|
90
|
+
"@container": "@list"
|
|
91
|
+
},
|
|
92
|
+
"expires_in": {
|
|
93
|
+
"@id": "oap:expiresIn",
|
|
94
|
+
"@type": "xsd:integer"
|
|
95
|
+
},
|
|
96
|
+
"passport_digest": {
|
|
97
|
+
"@id": "oap:passportDigest",
|
|
98
|
+
"@type": "xsd:string"
|
|
99
|
+
},
|
|
100
|
+
"signature": {
|
|
101
|
+
"@id": "oap:signature",
|
|
102
|
+
"@type": "xsd:string"
|
|
103
|
+
},
|
|
104
|
+
"kid": {
|
|
105
|
+
"@id": "oap:kid",
|
|
106
|
+
"@type": "xsd:string"
|
|
107
|
+
},
|
|
108
|
+
"decision_token": {
|
|
109
|
+
"@id": "oap:decisionToken",
|
|
110
|
+
"@type": "xsd:string"
|
|
111
|
+
},
|
|
112
|
+
"agent_id": {
|
|
113
|
+
"@id": "oap:agentId",
|
|
114
|
+
"@type": "xsd:string"
|
|
115
|
+
},
|
|
116
|
+
"remaining_daily_cap": {
|
|
117
|
+
"@id": "oap:remainingDailyCap",
|
|
118
|
+
"@type": "oap:DailyCap"
|
|
119
|
+
},
|
|
120
|
+
"code": {
|
|
121
|
+
"@id": "oap:code",
|
|
122
|
+
"@type": "xsd:string"
|
|
123
|
+
},
|
|
124
|
+
"message": {
|
|
125
|
+
"@id": "oap:message",
|
|
126
|
+
"@type": "xsd:string"
|
|
127
|
+
},
|
|
128
|
+
"expires_at": {
|
|
129
|
+
"@id": "oap:expiresAt",
|
|
130
|
+
"@type": "xsd:dateTime"
|
|
131
|
+
},
|
|
132
|
+
"never_expires": {
|
|
133
|
+
"@id": "oap:neverExpires",
|
|
134
|
+
"@type": "xsd:boolean"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://www.w3.org/2018/credentials/v1",
|
|
4
|
+
"https://raw.githubusercontent.com/aporthq/aport-spec/refs/heads/main/oap/vc/context-oap-v1.jsonld"
|
|
5
|
+
],
|
|
6
|
+
"type": ["VerifiableCredential", "OAPDecisionReceipt"],
|
|
7
|
+
"credentialSubject": {
|
|
8
|
+
"decision_id": "550e8400-e29b-41d4-a716-446655440002",
|
|
9
|
+
"policy_id": "finance.payment.refund.v1",
|
|
10
|
+
"agent_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
11
|
+
"owner_id": "org_12345678",
|
|
12
|
+
"assurance_level": "L2",
|
|
13
|
+
"allow": true,
|
|
14
|
+
"reasons": [
|
|
15
|
+
{
|
|
16
|
+
"code": "oap.allowed",
|
|
17
|
+
"message": "Transaction within limits and policy requirements"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"created_at": "2024-01-15T10:30:00Z",
|
|
21
|
+
"expires_in": 3600,
|
|
22
|
+
"passport_digest": "sha256:abcd1234efgh5678ijkl9012mnop3456qrst7890uvwx1234yzab5678cdef",
|
|
23
|
+
"signature": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
24
|
+
"kid": "oap:registry:key-2025-01",
|
|
25
|
+
"decision_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
26
|
+
},
|
|
27
|
+
"issuer": "https://aport.io",
|
|
28
|
+
"issuanceDate": "2024-01-15T10:30:00Z",
|
|
29
|
+
"expirationDate": "2024-01-15T11:30:00Z",
|
|
30
|
+
"proof": {
|
|
31
|
+
"type": "Ed25519Signature2020",
|
|
32
|
+
"created": "2024-01-15T10:30:00Z",
|
|
33
|
+
"verificationMethod": "https://aport.io/.well-known/oap/keys.json#ap_registry_ed25519_2024",
|
|
34
|
+
"proofPurpose": "assertionMethod",
|
|
35
|
+
"jws": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVkZW50aWFsU3ViamVjdCI6eyJkZWNpc2lvbl9pZCI6IjU1MGU4NDAwLWUyOWItNDFkNC1hNzE2LTQ0NjY1NTQ0MDAwMiIsInBvbGljeV9pZCI6InBheW1lbnRzLnJlZnVuZC52MSIsInBhc3Nwb3J0X2lkIjoiNTUwZTg0MDAtZTI5Yi00MWQ0LWE3MTYtNDQ2NjU1NDQwMDAwIiwib3duZXJfaWQiOiJvcmdfMTIzNDU2NzgiLCJhc3N1cmFuY2VfbGV2ZWwiOiJMMiIsImFsbG93Ijp0cnVlLCJyZWFzb25zIjpbeyJjb2RlIjoib2FwLmFsbG93ZWQiLCJtZXNzYWdlIjoiVHJhbnNhY3Rpb24gd2l0aGluIGxpbWl0cyBhbmQgcG9saWN5IHJlcXVpcmVtZW50cyJ9XSwiaXNzdWVkX2F0IjoiMjAyNC0wMS0xNVQxMDozMDowMFoiLCJleHBpcmVzX2F0IjoiMjAyNC0wMS0xNVQxMTozMDowMFoiLCJwYXNzcG9ydF9kaWdlc3QiOiJzaGEyNTY6YWJjZDEyMzRlZmdoNTY3OGlqa2w5MDEybW5vcDM0NTZxcnN0Nzg5MHV2d3gxMjM0eXphYjU2NzhjZGVmIn0sImlzc3VlciI6Imh0dHBzOi8vYXBpLmFwb3J0LmRldiIsImlzc3VhbmNlRGF0ZSI6IjIwMjQtMDEtMTVUMTA6MzA6MDBaIiwiZXhwaXJhdGlvbkRhdGUiOiIyMDI0LTAxLTE1VDExOjMwOjAwWiJ9.signature"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://www.w3.org/2018/credentials/v1",
|
|
4
|
+
"https://raw.githubusercontent.com/aporthq/aport-spec/refs/heads/main/oap/vc/context-oap-v1.jsonld"
|
|
5
|
+
],
|
|
6
|
+
"type": ["VerifiableCredential", "OAPPassportCredential"],
|
|
7
|
+
"credentialSubject": {
|
|
8
|
+
"agent_id": "550e8400-e29b-41d4-a716-446655440000",
|
|
9
|
+
"kind": "template",
|
|
10
|
+
"spec_version": "oap/1.0",
|
|
11
|
+
"owner_id": "org_12345678",
|
|
12
|
+
"owner_type": "org",
|
|
13
|
+
"assurance_level": "L2",
|
|
14
|
+
"status": "active",
|
|
15
|
+
"capabilities": [
|
|
16
|
+
"finance.payment.refund",
|
|
17
|
+
"data.export",
|
|
18
|
+
"repo.release.publish"
|
|
19
|
+
],
|
|
20
|
+
"limits": {
|
|
21
|
+
"finance.payment.refund": {
|
|
22
|
+
"currency_limits": {
|
|
23
|
+
"USD": {
|
|
24
|
+
"max_per_tx": 5000,
|
|
25
|
+
"daily_cap": 50000
|
|
26
|
+
},
|
|
27
|
+
"EUR": {
|
|
28
|
+
"max_per_tx": 4500,
|
|
29
|
+
"daily_cap": 45000
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"reason_codes": ["customer_request", "defective_product", "fraud"],
|
|
33
|
+
"idempotency_required": true
|
|
34
|
+
},
|
|
35
|
+
"data.export": {
|
|
36
|
+
"max_rows": 100000,
|
|
37
|
+
"allow_pii": false,
|
|
38
|
+
"allowed_collections": ["users", "orders", "products"]
|
|
39
|
+
},
|
|
40
|
+
"repo.release.publish": {
|
|
41
|
+
"allowed_branches": ["main", "develop"],
|
|
42
|
+
"max_releases_per_day": 10,
|
|
43
|
+
"require_signed_artifacts": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"regions": ["US", "CA", "EU"],
|
|
47
|
+
"metadata": {
|
|
48
|
+
"name": "Customer Support AI",
|
|
49
|
+
"description": "AI agent for customer support operations",
|
|
50
|
+
"version": "1.0.0",
|
|
51
|
+
"contact": "support@example.com",
|
|
52
|
+
"homepage": "https://example.com/ai/support"
|
|
53
|
+
},
|
|
54
|
+
"created_at": "2024-01-01T00:00:00Z",
|
|
55
|
+
"updated_at": "2024-01-15T10:30:00Z",
|
|
56
|
+
"version": "1.0.0"
|
|
57
|
+
},
|
|
58
|
+
"issuer": "https://aport.io",
|
|
59
|
+
"issuanceDate": "2024-01-01T00:00:00Z",
|
|
60
|
+
"expirationDate": "2025-01-01T00:00:00Z",
|
|
61
|
+
"proof": {
|
|
62
|
+
"type": "Ed25519Signature2020",
|
|
63
|
+
"created": "2024-01-01T00:00:00Z",
|
|
64
|
+
"verificationMethod": "https://aport.io/.well-known/oap/keys.json#ap_registry_ed25519_2024",
|
|
65
|
+
"proofPurpose": "assertionMethod",
|
|
66
|
+
"jws": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVkZW50aWFsU3ViamVjdCI6eyJwYXNzcG9ydF9pZCI6IjU1MGU4NDAwLWUyOWItNDFkNC1hNzE2LTQ0NjY1NTQ0MDAwMCIsImtpbmQiOiJ0ZW1wbGF0ZSIsInNwZWNfdmVyc2lvbiI6Im9hcC8xLjAiLCJvd25lcl9pZCI6Im9yZ18xMjM0NTY3OCIsIm93bmVyX3R5cGUiOiJvcmciLCJhc3N1cmFuY2VfbGV2ZWwiOiJMMiIsInN0YXR1cyI6ImFjdGl2ZSIsImNhcGFiaWxpdGllcyI6WyJwYXltZW50cy5yZWZ1bmQiLCJkYXRhLmV4cG9ydCIsInJlcG8ucmVsZWFzZS5wdWJsaXNoIl0sImxpbWl0cyI6eyJwYXltZW50cy5yZWZ1bmQiOnsiY3VycmVuY3lfbGltaXRzIjp7IlVTRCI6eyJtYXhfcGVyX3R4Ijo1MDAwLCJkYWlseV9jYXAiOjUwMDAwfSwiRVVSIjp7Im1heF9wZXJfdHgiOjQ1MDAsImRhaWx5X2NhcCI6NDUwMDB9fSwicmVhc29uX2NvZGVzIjpbImN1c3RvbWVyX3JlcXVlc3QiLCJkZWZlY3RpdmVfcHJvZHVjdCIsImZyYXVkIl0sImlkZW1wb3RlbmN5X3JlcXVpcmVkIjp0cnVlfSwiZGF0YS5leHBvcnQiOnsibWF4X3Jvd3MiOjEwMDAwMCwiYWxsb3dfcGlpIjpmYWxzZSwiYWxsb3dlZF9jb2xsZWN0aW9ucyI6WyJ1c2VycyIsIm9yZGVycyIsInByb2R1Y3RzIl19LCJyZXBvLnJlbGVhc2UucHVibGlzaCI6eyJhbGxvd2VkX2JyYW5jaGVzIjpbIm1haW4iLCJkZXZlbG9wIl0sIm1heF9yZWxlYXNlc19wZXJfZGF5IjoxMCwicmVxdWlyZV9zaWduZWRfYXJ0aWZhY3RzIjp0cnVlfX0sInJlZ2lvbnMiOlsiVVMiLCJDQSIsIkVVIl0sIm1ldGFkYXRhIjp7Im5hbWUiOiJDdXN0b21lciBTdXBwb3J0IEFJIiwiZGVzY3JpcHRpb24iOiJBSSBhZ2VudCBmb3IgY3VzdG9tZXIgc3VwcG9ydCBvcGVyYXRpb25zIiwidmVyc2lvbiI6IjEuMC4wIiwiY29udGFjdCI6InN1cHBvcnRAZXhhbXBsZS5jb20iLCJob21lcGFnZSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vYWkvc3VwcG9ydCJ9LCJjcmVhdGVkX2F0IjoiMjAyNC0wMS0wMVQwMDowMDowMFoiLCJ1cGRhdGVkX2F0IjoiMjAyNC0wMS0xNVQxMDozMDowMFoiLCJ2ZXJzaW9uIjoxfX0sImlzc3VlciI6Imh0dHBzOi8vYXBpLmFwb3J0LmRldiIsImlzc3VhbmNlRGF0ZSI6IjIwMjQtMDEtMDFUMDA6MDA6MDBaIiwiZXhwaXJhdGlvbkRhdGUiOiIyMDI1LTAxLTAxVDAwOjAwOjAwWiJ9.signature"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# OAP VC Integration Guide
|
|
2
|
+
|
|
3
|
+
This guide shows how to integrate OAP VC conversion tools into your application using the tools directly from the repository.
|
|
4
|
+
|
|
5
|
+
## โก Quick Start (5 minutes)
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Get the tools
|
|
9
|
+
git clone https://github.com/aporthq/oap-spec.git
|
|
10
|
+
cd oap-spec/spec/oap/vc/tools
|
|
11
|
+
|
|
12
|
+
# 2. Install and build
|
|
13
|
+
npm install
|
|
14
|
+
npm run build
|
|
15
|
+
|
|
16
|
+
# 3. Generate a registry key
|
|
17
|
+
node dist/cli.js generate-key --output registry-key.json
|
|
18
|
+
|
|
19
|
+
# 4. Convert your OAP passport to VC
|
|
20
|
+
node dist/cli.js export --type passport --input your-passport.json --output your-passport.vc.json --key registry-key.json
|
|
21
|
+
|
|
22
|
+
# 5. Convert VC back to OAP
|
|
23
|
+
node dist/cli.js import --type passport --input your-passport.vc.json --output your-passport-back.json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
That's it! You now have working OAP โ VC conversion tools.
|
|
27
|
+
|
|
28
|
+
## ๐ Try the Examples
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Run the working examples
|
|
32
|
+
node examples/passport-to-vc.js
|
|
33
|
+
node examples/decision-to-vc.js
|
|
34
|
+
node examples/vc-to-passport.js
|
|
35
|
+
node examples/vc-to-decision.js
|
|
36
|
+
|
|
37
|
+
# Or run the test suite
|
|
38
|
+
node test-simple.js
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## ๐ Full Integration Guide
|
|
42
|
+
|
|
43
|
+
### 1. Get the Tools
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Clone or download the OAP specification repository
|
|
47
|
+
git clone https://github.com/aporthq/oap-spec.git
|
|
48
|
+
cd oap-spec/spec/oap/vc/tools
|
|
49
|
+
|
|
50
|
+
# Install dependencies
|
|
51
|
+
npm install
|
|
52
|
+
|
|
53
|
+
# Build the TypeScript code
|
|
54
|
+
npm run build
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 2. Basic Usage
|
|
58
|
+
|
|
59
|
+
#### Option A: Use as CLI Tool
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Export OAP Passport to VC
|
|
63
|
+
node dist/cli.js export --type passport --input passport.json --output passport.vc.json --key registry-key.json
|
|
64
|
+
|
|
65
|
+
# Export with verbose output (shows converted data)
|
|
66
|
+
node dist/cli.js export --type passport --input passport.json --output passport.vc.json --key registry-key.json --verbose
|
|
67
|
+
|
|
68
|
+
# Import VC to OAP Passport
|
|
69
|
+
node dist/cli.js import --type passport --input passport.vc.json --output passport.json
|
|
70
|
+
|
|
71
|
+
# Import with verbose output (shows converted data)
|
|
72
|
+
node dist/cli.js import --type passport --input passport.vc.json --output passport.json --verbose
|
|
73
|
+
|
|
74
|
+
# Validate OAP objects or VCs
|
|
75
|
+
node dist/cli.js validate --type passport --input passport.json
|
|
76
|
+
node dist/cli.js validate --type vc --input passport.vc.json
|
|
77
|
+
|
|
78
|
+
# Generate a registry key
|
|
79
|
+
node dist/cli.js generate-key --output my-registry-key.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Option B: Use as SDK
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
// Import the conversion functions directly
|
|
86
|
+
import {
|
|
87
|
+
exportPassportToVC,
|
|
88
|
+
exportDecisionToVC,
|
|
89
|
+
importVCToPassport,
|
|
90
|
+
importVCToDecision
|
|
91
|
+
} from './dist/index.js';
|
|
92
|
+
|
|
93
|
+
// Your OAP passport
|
|
94
|
+
const passport = {
|
|
95
|
+
agent_id: '550e8400-e29b-41d4-a716-446655440000',
|
|
96
|
+
kind: 'template',
|
|
97
|
+
spec_version: 'oap/1.0',
|
|
98
|
+
// ... other fields
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Your registry key
|
|
102
|
+
const registryKey = {
|
|
103
|
+
issuer: 'https://aport.io',
|
|
104
|
+
kid: 'key-2025-01',
|
|
105
|
+
publicKey: 'your-ed25519-public-key',
|
|
106
|
+
privateKey: 'your-ed25519-private-key'
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Convert to VC
|
|
110
|
+
const vc = exportPassportToVC(passport, registryKey);
|
|
111
|
+
|
|
112
|
+
// Convert back to OAP
|
|
113
|
+
const importedPassport = importVCToPassport(vc);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## ๐ง Integration Patterns
|
|
117
|
+
|
|
118
|
+
### Pattern 1: OAP โ VC โ Storage
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
// Import the tools
|
|
122
|
+
import { exportPassportToVC, importVCToPassport } from './dist/index.js';
|
|
123
|
+
|
|
124
|
+
// Convert OAP passport to VC for storage in VC wallet
|
|
125
|
+
const vc = exportPassportToVC(passport, registryKey);
|
|
126
|
+
|
|
127
|
+
// Store in VC wallet
|
|
128
|
+
await vcWallet.store(vc);
|
|
129
|
+
|
|
130
|
+
// Later: retrieve and convert back
|
|
131
|
+
const storedVC = await vcWallet.retrieve(vcId);
|
|
132
|
+
const passport = importVCToPassport(storedVC);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Pattern 2: VC โ OAP โ Processing
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
// Import the tools
|
|
139
|
+
import { importVCToPassport, exportDecisionToVC } from './dist/index.js';
|
|
140
|
+
|
|
141
|
+
// Receive VC from external system
|
|
142
|
+
const vc = await receiveVCFromExternalSystem();
|
|
143
|
+
|
|
144
|
+
// Convert to OAP for processing
|
|
145
|
+
const passport = importVCToPassport(vc);
|
|
146
|
+
|
|
147
|
+
// Process using OAP logic
|
|
148
|
+
const decision = await processOAPPassport(passport);
|
|
149
|
+
|
|
150
|
+
// Convert decision back to VC
|
|
151
|
+
const decisionVC = exportDecisionToVC(decision, registryKey);
|
|
152
|
+
|
|
153
|
+
// Send back to external system
|
|
154
|
+
await sendVCToExternalSystem(decisionVC);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Pattern 3: Hybrid OAP/VC System
|
|
158
|
+
|
|
159
|
+
```javascript
|
|
160
|
+
// Import the tools
|
|
161
|
+
import { exportPassportToVC } from './dist/index.js';
|
|
162
|
+
|
|
163
|
+
// Store both formats for maximum compatibility
|
|
164
|
+
const passport = await createOAPPassport(data);
|
|
165
|
+
const vc = exportPassportToVC(passport, registryKey);
|
|
166
|
+
|
|
167
|
+
// Store in both systems
|
|
168
|
+
await oapDatabase.store(passport);
|
|
169
|
+
await vcWallet.store(vc);
|
|
170
|
+
|
|
171
|
+
// Use appropriate format based on context
|
|
172
|
+
if (needsVCCapabilities) {
|
|
173
|
+
return vc;
|
|
174
|
+
} else {
|
|
175
|
+
return passport;
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## ๐ ๏ธ CLI Integration
|
|
180
|
+
|
|
181
|
+
### Batch Conversion
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
#!/bin/bash
|
|
185
|
+
# Convert all OAP passports to VCs
|
|
186
|
+
|
|
187
|
+
# Make sure you're in the tools directory
|
|
188
|
+
cd spec/oap/vc/tools
|
|
189
|
+
|
|
190
|
+
# Build the tools first
|
|
191
|
+
npm run build
|
|
192
|
+
|
|
193
|
+
# Convert all passports
|
|
194
|
+
for passport in passports/*.json; do
|
|
195
|
+
filename=$(basename "$passport" .json)
|
|
196
|
+
node dist/cli.js export --type passport --input "$passport" --output "vcs/${filename}.vc.json" --key registry-key.json
|
|
197
|
+
done
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Validation Pipeline
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
#!/bin/bash
|
|
204
|
+
# Validate all VCs before processing
|
|
205
|
+
|
|
206
|
+
# Make sure you're in the tools directory
|
|
207
|
+
cd spec/oap/vc/tools
|
|
208
|
+
|
|
209
|
+
# Build the tools first
|
|
210
|
+
npm run build
|
|
211
|
+
|
|
212
|
+
# Validate all VCs
|
|
213
|
+
for vc in vcs/*.vc.json; do
|
|
214
|
+
if ! node dist/cli.js validate --type vc --input "$vc"; then
|
|
215
|
+
echo "Invalid VC: $vc"
|
|
216
|
+
exit 1
|
|
217
|
+
fi
|
|
218
|
+
done
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## ๐ Security Integration
|
|
222
|
+
|
|
223
|
+
### Key Management
|
|
224
|
+
|
|
225
|
+
```javascript
|
|
226
|
+
// Import the tools
|
|
227
|
+
import { exportPassportToVC, importVCToPassport } from './dist/index.js';
|
|
228
|
+
|
|
229
|
+
// Load registry key securely
|
|
230
|
+
const registryKey = await loadRegistryKeyFromSecureStore();
|
|
231
|
+
|
|
232
|
+
// Rotate keys periodically
|
|
233
|
+
const newKey = await generateNewRegistryKey();
|
|
234
|
+
await updateRegistryKey(newKey);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Signature Verification
|
|
238
|
+
|
|
239
|
+
```javascript
|
|
240
|
+
// Import the tools
|
|
241
|
+
import { importVCToPassport } from './dist/index.js';
|
|
242
|
+
|
|
243
|
+
// Always verify signatures when importing
|
|
244
|
+
const vc = await receiveVCFromExternalSystem();
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
const passport = importVCToPassport(vc);
|
|
248
|
+
// Signature verified automatically
|
|
249
|
+
console.log('VC signature is valid');
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.error('Invalid VC signature:', error.message);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## ๐ VC Ecosystem Integration
|
|
256
|
+
|
|
257
|
+
### VC Wallet Integration
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
// Import the tools
|
|
261
|
+
import { exportPassportToVC } from './dist/index.js';
|
|
262
|
+
|
|
263
|
+
// Store OAP as VC in wallet
|
|
264
|
+
const vc = exportPassportToVC(passport, registryKey);
|
|
265
|
+
await wallet.store(vc);
|
|
266
|
+
|
|
267
|
+
// Present VC to verifier
|
|
268
|
+
const presentation = await wallet.createPresentation([vc]);
|
|
269
|
+
await verifier.verify(presentation);
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### DID Integration
|
|
273
|
+
|
|
274
|
+
```javascript
|
|
275
|
+
// Import the tools
|
|
276
|
+
import { exportPassportToVC } from './dist/index.js';
|
|
277
|
+
|
|
278
|
+
// Use with DID documents
|
|
279
|
+
const did = 'did:example:123456789';
|
|
280
|
+
const vc = exportPassportToVC(passport, { ...registryKey, issuer: did });
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## ๐ Monitoring and Logging
|
|
284
|
+
|
|
285
|
+
```javascript
|
|
286
|
+
// Import the tools
|
|
287
|
+
import { exportPassportToVC } from './dist/index.js';
|
|
288
|
+
|
|
289
|
+
// Log conversion events
|
|
290
|
+
function convertWithLogging(passport, registryKey) {
|
|
291
|
+
console.log('Converting passport to VC:', passport.agent_id);
|
|
292
|
+
|
|
293
|
+
try {
|
|
294
|
+
const vc = exportPassportToVC(passport, registryKey);
|
|
295
|
+
console.log('Conversion successful:', vc.id);
|
|
296
|
+
return vc;
|
|
297
|
+
} catch (error) {
|
|
298
|
+
console.error('Conversion failed:', error.message);
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## ๐งช Testing Integration
|
|
305
|
+
|
|
306
|
+
```javascript
|
|
307
|
+
// Import the tools
|
|
308
|
+
import { exportPassportToVC, importVCToPassport } from './dist/index.js';
|
|
309
|
+
|
|
310
|
+
// Test conversion functions
|
|
311
|
+
describe('OAP VC Conversion', () => {
|
|
312
|
+
test('should convert passport to VC and back', () => {
|
|
313
|
+
const vc = exportPassportToVC(samplePassport, sampleRegistryKey);
|
|
314
|
+
const importedPassport = importVCToPassport(vc);
|
|
315
|
+
|
|
316
|
+
expect(importedPassport.agent_id).toBe(samplePassport.agent_id);
|
|
317
|
+
expect(importedPassport.kind).toBe(samplePassport.kind);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## ๐ Deployment
|
|
323
|
+
|
|
324
|
+
### Docker Integration
|
|
325
|
+
|
|
326
|
+
```dockerfile
|
|
327
|
+
FROM node:18-alpine
|
|
328
|
+
|
|
329
|
+
WORKDIR /app
|
|
330
|
+
|
|
331
|
+
# Copy the OAP VC tools
|
|
332
|
+
COPY spec/oap/vc/tools/package*.json ./
|
|
333
|
+
RUN npm install
|
|
334
|
+
|
|
335
|
+
COPY spec/oap/vc/tools/ ./
|
|
336
|
+
RUN npm run build
|
|
337
|
+
|
|
338
|
+
# Use the CLI tool
|
|
339
|
+
CMD ["node", "dist/cli.js", "--help"]
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### CI/CD Pipeline
|
|
343
|
+
|
|
344
|
+
```yaml
|
|
345
|
+
name: OAP VC Conversion
|
|
346
|
+
on: [push, pull_request]
|
|
347
|
+
|
|
348
|
+
jobs:
|
|
349
|
+
test:
|
|
350
|
+
runs-on: ubuntu-latest
|
|
351
|
+
steps:
|
|
352
|
+
- uses: actions/checkout@v3
|
|
353
|
+
- uses: actions/setup-node@v3
|
|
354
|
+
with:
|
|
355
|
+
node-version: '18'
|
|
356
|
+
- name: Install dependencies
|
|
357
|
+
run: |
|
|
358
|
+
cd spec/oap/vc/tools
|
|
359
|
+
npm install
|
|
360
|
+
- name: Build tools
|
|
361
|
+
run: |
|
|
362
|
+
cd spec/oap/vc/tools
|
|
363
|
+
npm run build
|
|
364
|
+
- name: Test tools
|
|
365
|
+
run: |
|
|
366
|
+
cd spec/oap/vc/tools
|
|
367
|
+
npm test
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## ๐ Additional Resources
|
|
371
|
+
|
|
372
|
+
- [W3C Verifiable Credentials Data Model v2.0](https://www.w3.org/TR/vc-data-model-2.0/)
|
|
373
|
+
- [OAP Specification](../oap-spec.md)
|
|
374
|
+
- [VC Mapping Documentation](../vc-mapping.md)
|
|
375
|
+
- [Examples Directory](./examples/)
|