Skip to content

Commit

Permalink
wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed Nov 18, 2024
1 parent f1f3645 commit c8f79ea
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/eudi/eudi.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defmodule CA.EUDI do
@moduledoc "CA/EUDI/OID4VC HTTPS/HTTP library."

end
42 changes: 42 additions & 0 deletions lib/eudi/issuer.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
defmodule CA.EUDI.Issuer do
@moduledoc "EUDI/OID4VC Issuer server."
@profiles [ "secp256k1", "secp384r1", "secp521r1" ]

Check warning on line 3 in lib/eudi/issuer.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @profiles was set but never used
@templates [ "ocsp", "ipsec", "bgp", "eap", "cap", "sip", "cmc", "scvp", "ssh", "tls" ]

Check warning on line 4 in lib/eudi/issuer.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @templates was set but never used
@classes [ "ca", "ra", "server", "client", "human", "program" ]

Check warning on line 5 in lib/eudi/issuer.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @classes was set but never used

use Plug.Router
plug :match
plug :dispatch
plug Plug.Parsers, parsers: [:json], json_decoder: Jason

def start_link(opt) do
Bandit.start_link(opt)
end

def child_spec(opt) do
%{
id: EUDI.Issuer,
start: {CA.EUDI.Issuer, :start_link, [opt]},
type: :supervisor,
restart: :permanent
}
end

get "/jwks" do CA.EST.Get.get(conn, "EUDI", [], [], "JWKS") end
get "/.well-known/openid-configuration" do CA.EST.Get.get(conn, "EUDI", [], [], "CONFIG") end
get "/.well-known/openid-credential-issuer" do CA.EST.Get.get(conn, "EUDI", [], [], "ISSUE") end
get "/.well-known/oauth-authorization-server" do CA.EST.Get.get(conn, "EUDI", [], [], "OAUTH") end
get "/.well-known/jwt-vc-issuer" do CA.EST.Get.get(conn, "EUDI", [], [], "JWT") end
get "/openid4vc/credentialOffer" do CA.EST.Get.get(conn, "EUDI", [], [], "OFFER") end
post "/openid4vc/jwt/issue" do CA.EST.Get.get(conn, "EUDI", [], [], "JWT") end
post "/openid4vc/sdjwt/issue" do CA.EST.Get.get(conn, "EUDI", [], [], "SDJWT") end
post "/openid4vc/mdoc/issue" do CA.EST.Get.get(conn, "EUDI", [], [], "MDOC") end

match _ do send_resp(conn, 404, "Please refer to https://authority.erp.uno for more information.\n") end
def encode(x) do
case Jason.encode(x) do
{:ok, bin} -> bin
{:error, _} -> ""
end |> Jason.Formatter.pretty_print
end
end
38 changes: 38 additions & 0 deletions lib/eudi/verifier.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
defmodule CA.EUDI.Verifier do
@moduledoc "EUDI/OID4VC Verifier."
@profiles [ "secp256k1", "secp384r1", "secp521r1" ]

Check warning on line 3 in lib/eudi/verifier.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @profiles was set but never used
@templates [ "ocsp", "ipsec", "bgp", "eap", "cap", "sip", "cmc", "scvp", "ssh", "tls" ]

Check warning on line 4 in lib/eudi/verifier.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @templates was set but never used
@classes [ "ca", "ra", "server", "client", "human", "program" ]

Check warning on line 5 in lib/eudi/verifier.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @classes was set but never used

use Plug.Router
plug :match
plug :dispatch
plug Plug.Parsers, parsers: [:json], json_decoder: Jason

def start_link(opt) do
Bandit.start_link(opt)
end

def child_spec(opt) do
%{
id: EUDI.Verifier,
start: {CA.EUDI.Verifier, :start_link, [opt]},
type: :supervisor,
restart: :permanent
}
end

get "/openid4vc/session/:id" do CA.EST.Get.get(conn, "EUDI", [], id, "SESSION") end
get "/openid4vc/policy-list" do CA.EST.Get.get(conn, "EUDI", [], [], "POLICIES") end
get "/openid4vc/pd/:id" do CA.EST.Get.get(conn, "EUDI", [], id, "PD") end
get "/openid4vc/verify/:state" do CA.EST.Get.get(conn, "EUDI", [], state, "VERIFY") end
get "/openid4vc/request/:id" do CA.EST.Get.get(conn, "EUDI", [], id, "REQ") end

match _ do send_resp(conn, 404, "Please refer to https://authority.erp.uno for more information.\n") end
def encode(x) do
case Jason.encode(x) do
{:ok, bin} -> bin
{:error, _} -> ""
end |> Jason.Formatter.pretty_print
end
end
40 changes: 40 additions & 0 deletions lib/eudi/wallet.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
defmodule CA.EUDI.Wallet do
@moduledoc "EUDI/OID4VC Wallet web application server."
@profiles [ "secp256k1", "secp384r1", "secp521r1" ]

Check warning on line 3 in lib/eudi/wallet.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @profiles was set but never used
@templates [ "ocsp", "ipsec", "bgp", "eap", "cap", "sip", "cmc", "scvp", "ssh", "tls" ]

Check warning on line 4 in lib/eudi/wallet.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @templates was set but never used
@classes [ "ca", "ra", "server", "client", "human", "program" ]

Check warning on line 5 in lib/eudi/wallet.ex

View workflow job for this annotation

GitHub Actions / build

module attribute @classes was set but never used

use Plug.Router
plug :match
plug :dispatch
plug Plug.Parsers, parsers: [:json], json_decoder: Jason

def start_link(opt) do
Bandit.start_link(opt)
end

def child_spec(opt) do
%{
id: EUDI.Wallet,
start: {CA.EUDI.Wallet, :start_link, [opt]},
type: :supervisor,
restart: :permanent
}
end

get "/wallets" do CA.EST.Get.get(conn, "EUDI", [], [], "WALLETS") end
get "/wallets/:id/dids" do CA.EST.Get.get(conn, "EUDI", [], [], "DIDS") end
get "/wallets/:id/keys" do CA.EST.Get.get(conn, "EUDI", [], [], "KEYS") end
get "/wallets/:id/credentials" do CA.EST.Get.get(conn, "EUDI", [], [], "CREDS") end
get "/wallets/:id/issuers" do CA.EST.Get.get(conn, "EUDI", [], [], "ISSUERS") end
get "/wallets/:id/exchange" do CA.EST.Get.get(conn, "EUDI", [], [], "EXCHANGES") end
get "/wallets/parseMDoc" do CA.EST.Get.get(conn, "EUDI", [], [], "MDOC") end

match _ do send_resp(conn, 404, "Please refer to https://authority.erp.uno for more information.\n") end
def encode(x) do
case Jason.encode(x) do
{:ok, bin} -> bin
{:error, _} -> ""
end |> Jason.Formatter.pretty_print
end
end

0 comments on commit c8f79ea

Please sign in to comment.