@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,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
|
+
}
|