|
|
||
|---|---|---|
| .. | ||
| deploy | ||
| .env.example | ||
| app_test.go | ||
| app.go | ||
| assurance.go | ||
| chain.go | ||
| config_test.go | ||
| config.go | ||
| crypto.go | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| marketplace_models.go | ||
| marketplace.go | ||
| models.go | ||
| quote_cost.go | ||
| README.md | ||
| regulatory_profile.go | ||
| session_auth.go | ||
| store.go | ||
Secret API Backend (secretapi)
Deterministic backend for wallet-first designation, EDUT ID activation, and governance install authorization.
Run
cd /Users/vsg/Documents/VSG\ Codex/web/backend/secretapi
go run .
Default listen address is :8080.
Test
cd /Users/vsg/Documents/VSG\ Codex/web/backend/secretapi
go test ./...
Environment Template
Copy .env.example in this folder and set contract/runtime values before deploy.
secretapi validates config at startup and fails closed if strict chain verification is enabled without RPC.
Endpoint Surface
Membership
POST /secret/wallet/intentPOST /secret/wallet/verifyPOST /secret/wallet/session/refreshPOST /secret/wallet/session/revokePOST /secret/membership/quotePOST /secret/membership/confirmGET /secret/membership/statusPOST /secret/id/quote(alias to membership quote)POST /secret/id/confirm(alias to membership confirm)GET /secret/id/status(alias to membership status)
Marketplace
GET /marketplace/offersGET /marketplace/offers/{offer_id}POST /marketplace/checkout/quotePOST /marketplace/checkout/confirmGET /marketplace/entitlements
Governance install + availability
POST /governance/install/tokenPOST /governance/install/confirmGET /governance/install/statusPOST /governance/lease/heartbeatPOST /governance/lease/offline-renew
Member app channel
POST /member/channel/device/registerPOST /member/channel/device/unregisterGET /member/channel/eventsPOST /member/channel/events/{event_id}/ackPOST /member/channel/support/ticket
Wallet Session Hardening
POST /secret/wallet/verify now issues a wallet session token:
- Response fields:
session_token,session_expires_at - Response headers:
X-Edut-Session,X-Edut-Session-Expires-At
When SECRET_API_REQUIRE_WALLET_SESSION=true, wallet-scoped control-plane endpoints fail closed unless a valid session token is provided via:
Authorization: Bearer <session_token>X-Edut-Session: <session_token>
Covered endpoints include marketplace checkout/entitlements, governance install/lease actions, and member-channel calls.
Session lifecycle endpoints:
POST /secret/wallet/session/refresh: rotates the current session token and revokes the prior token.POST /secret/wallet/session/revoke: revokes the current token immediately.
Sponsorship Behavior
Membership quote supports ownership wallet and distinct payer wallet:
address: ownership wallet (required)payer_wallet: optional payer walletpayer_proof: required when payer differs from owner
Distinct payer proof uses owner-signed personal message:
EDUT-PAYER-AUTH:{designation_code}:{owner_wallet}:{payer_wallet}:{chain_id}
This enables company-sponsored mint flows while preserving deterministic owner authorization.
Company-first sponsor path is also supported:
- If
sponsor_org_root_idis provided and thepayer_walletis a storedorg_root_ownerprincipal for that org root with active entitlement status, quote issuance is allowed withoutpayer_proof.
Identity Assurance Model
Membership activation and identity assurance are stored as separate facts:
membership_statusidentity_assurance_level
Assurance levels:
nonecrypto_direct_unattestedsponsored_unattestedonramp_attested
onramp_attested can be set during membership confirm only on self-paid quotes and requires identity_attested_by.
Policy gates:
- Store checkout requires active membership.
- Workspace admin install/support actions require
onramp_attestedassurance.
Quote Cost Envelope
POST /secret/membership/quote and POST /marketplace/checkout/quote return a deterministic cost_envelope object.
The envelope is pre-execution pricing metadata and is authoritative for checkout presentation:
checkout_total_atomicandcheckout_totalare the user checkout totals.provider_fee_policy=edut_absorbedmeans on-ramp processing fees are absorbed by EDUT.network_fee_policy=payer_wallet_pays_chain_gasmeans chain gas remains wallet-dependent and separate from checkout total.
Key Environment Variables
Core
SECRET_API_LISTEN_ADDR(default:8080)SECRET_API_DB_PATH(default./secret.db)SECRET_API_ALLOWED_ORIGIN(defaulthttps://edut.ai)SECRET_API_DEPLOYMENT_CLASS(development|staging|production; defaultdevelopment)SECRET_API_MEMBER_POLL_INTERVAL_SECONDS(default30)SECRET_API_CHAIN_ID(default84532)SECRET_API_CHAIN_RPC_URL(optional, enables on-chain tx receipt verification)SECRET_API_REQUIRE_ONCHAIN_TX_VERIFICATION:- if explicitly set, value is honored.
- if unset, defaults to
truewhenSECRET_API_DEPLOYMENT_CLASS=production, elsefalse. - when enabled, membership confirm and marketplace checkout confirm fail closed without chain receipt verification.
SECRET_API_ENTITLEMENT_CONTRACT(optional; when set, marketplace quote emits purchase calldata for entitlement settlement contract)
Membership
SECRET_API_INTENT_TTL_SECONDS(default900)SECRET_API_QUOTE_TTL_SECONDS(default900)SECRET_API_WALLET_SESSION_TTL_SECONDS(default2592000)SECRET_API_REQUIRE_WALLET_SESSION(defaulttrue; setfalseonly for controlled local harness/debug usage)SECRET_API_REGULATORY_PROFILE_ID(us_general_2026default,eu_ai_act_2026_baselinesupported)SECRET_API_DOMAIN_NAMESECRET_API_VERIFYING_CONTRACTSECRET_API_MEMBERSHIP_CONTRACTSECRET_API_MINT_CURRENCY(USDCfor launch;ETHallowed for Sepolia/test harness)SECRET_API_MINT_AMOUNT_ATOMIC(default100000000)SECRET_API_MINT_DECIMALS(must be6forUSDC,18forETH)
Marketplace
SECRET_API_ENTITLEMENT_CONTRACTmust be configured to issue checkout quotes.- Marketplace quote fails closed with
entitlement_contract_unconfiguredwhen unset/zero.
Governance install
SECRET_API_INSTALL_TOKEN_TTL_SECONDS(default900)SECRET_API_LEASE_TTL_SECONDS(default3600)SECRET_API_OFFLINE_RENEW_TTL_SECONDS(default2592000)SECRET_API_GOV_RUNTIME_VERSIONSECRET_API_GOV_PACKAGE_URLSECRET_API_GOV_PACKAGE_HASHSECRET_API_GOV_PACKAGE_SIGNATURESECRET_API_GOV_SIGNER_KEY_IDSECRET_API_GOV_POLICY_HASHSECRET_API_GOV_ROLLOUT_CHANNEL(defaultstable)