### Scala-CLI on Docker Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/01-setup-environment.md Start an isolated environment to experiment with some code samples (3/5 mins) ```shell docker run --rm -it --entrypoint /bin/sh virtuslab/scala-cli scala-cli repl \ --dependency app.fmgp::did::@VERSION@ \ --dependency app.fmgp::did-imp::@VERSION@ \ --dependency app.fmgp::did-method-peer::@VERSION@ \ --repo https://oss.sonatype.org/content/repositories/releases # For snapshots use # --repo https://oss.sonatype.org/content/repositories/snapshots # For releases use # --repo https://oss.sonatype.org/content/repositories/releases ``` -------------------------------- ### SBT setup for JVMPlatform Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/01-setup-environment.md To install the library on sbt, you can use the following lines to your build.sbt: ```sbt libraryDependencies += "app.fmgp" %% "did" % @VERSION@ libraryDependencies += "app.fmgp" %% "did-imp" % @VERSION@ // for the DIDComm implementation libraryDependencies += "app.fmgp" %% "did-resolver-peer" % @VERSION@ // for hash utils ``` -------------------------------- ### SBT setup for JSPlatform Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/01-setup-environment.md In a crossProject for the JSPlatform and JVMPlatform this shoud use this instead: ```sbt libraryDependencies += "app.fmgp" %%% "did" % @VERSION@ libraryDependencies += "app.fmgp" %%% "did-imp" % @VERSION@ // for the DIDComm implementation libraryDependencies += "app.fmgp" %%% "did-resolver-peer" % @VERSION@ // for hash utils ``` -------------------------------- ### Coursier Download for Releases Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/01-setup-environment.md Fetch releases using coursier. ```shell coursier fetch app.fmgp:did_3:@VERSION@ -r sonatype:public # -r https://oss.sonatype.org/content/repositories/releases ``` -------------------------------- ### Coursier Download for Snapshots Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/01-setup-environment.md Fetch snapshots using coursier. ```shell coursier fetch app.fmgp:did_3:@VERSION@ -r sonatype:snapshots # -r https://oss.sonatype.org/content/repositories/snapshots ``` -------------------------------- ### Trust Ping example Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/04-basic-examples.md Illustrates creating a `TrustPingWithRequestedResponse` message for the Trust Ping protocol. ```scala import fmgp.did.comm.protocol.trustping2.* // For the protocol ``` ```scala val ping = TrustPingWithRequestedResponse( from = alice.id, to = TO("did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9hbGljZS5kaWQuZm1ncC5hcHAvIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfQ") ) ``` ```scala ping.toPlaintextMessage.toJsonPretty ``` -------------------------------- ### Key Derivation Path Example Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Example of deriving a key using a specific path and label. ```bash cardano-prism key derivation-path --derivation-path "m/29'/29'/0'/1'/0'" --label my-key ``` -------------------------------- ### End-to-End Example: Set up keys and a DID Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Steps to set up keys and create a deterministic DID with a DIDComm service endpoint. ```bash # Create the config file (one-time) cardano-prism config-file --create # Generate and save an SSI wallet mnemonic cardano-prism mnemonic new -s cardano-prism mnemonic new -s uniform uniform index inner limb joy weapon business slim truck seed order call monster mad tattoo any hospital finger tourist jar video east earn # Master key — must be secp256k1 cardano-prism key sepc256k1 2 Master 0 # => saves as "key-2-Master-0" cardano-prism key random-Ed25519 --label iss cardano-prism key random-Ed25519 --label auth cardano-prism key random-X25519 --label comm # the keys Ex: # "ssiPrivateKeys" : { # "key-2-Master-0" : { # "KeySecp256k1" : { # "derivationPath" : "m/29'/29'/2'/1'/0'", # "key" : "8f60bf555957fbbf612186aa39d0d0eac6f44db51133dbfd43bb8bab9de91a55" # } # } # "iss" : { # "kty" : "OKP", # "crv" : "Ed25519", # "d" : "eEkeNXtrON4FnDjboznLl1kP4QJx9KMVxZ19mUnc3eY", # "x" : "lHFqJEvTZ39HA3cS1T_tKO2jQ4-bNKJlLQl5MmJf8bw" # }, # "auth" : { # "kty" : "OKP", # "crv" : "Ed25519", # "d" : "jcRFhJLb37C7qAGEIOoVI5TJ7BmCbTjG4ss-J4YuqHk", # "x" : "PvkqmJr98yeivaf9nJb8sQJSao0wJNKyg1ksI0llpbg" # }, # "comm" : { # "kty" : "OKP", # "crv" : "X25519", # "d" : "_6FVXdgJ-4LQYaQZzYITJbRIhgtOy2cMNKq3_CWWno0", # "x" : "RBY7U6cbUzdQmXM6VymSwFzEeGpG6ZRMhzWP115hpCo" # } # } # Build the deterministic DID (with a DIDComm service endpoint) cardano-prism did create-deterministic -S e1=https://kyc.fabiopinheiro.com/ key-2-Master-0:Master iss:Issuing auth:Authentication comm:Keyagreement ``` -------------------------------- ### Encrypt Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/04-basic-examples.md Demonstrates encrypting a Trust Ping message using `authEncrypt` and running the ZIO program. ```scala import Operations.* val program2 = for { msg <- authEncrypt(ping.toPlaintextMessage).provideSomeLayer(ZLayer.succeed(alice)) _ <- Console.printLine(msg.toJsonPretty) } yield () ``` ```scala Unsafe.unsafe { implicit unsafe => // Run side effect Runtime.default.unsafe .run(program2.provide(Operations.layerOperations ++ DidPeerResolver.layer)) .getOrThrowFiberFailure() } ``` -------------------------------- ### Install with Homebrew (deprecated) Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Installs the cardano-prism CLI using a Homebrew tap. This method is marked as deprecated. ```bash brew install FabioPinheiro/fmgp/cardano-prism cardano-prism --help ``` -------------------------------- ### Resolve did:peer identities Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/04-basic-examples.md Example of resolving a DID Peer identity document using `DidPeerResolver.didDocument`. ```scala import fmgp.did.method.peer.* ``` ```scala val program1 = DidPeerResolver.didDocument(DIDPeer(alice.id.asDIDSubject)) ``` ```scala Unsafe.unsafe { implicit unsafe => // Run side effect Runtime.default.unsafe .run(program1) .getOrThrowFiberFailure() } ``` -------------------------------- ### Make DID Peer identities Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/04-basic-examples.md Shows how to create a DID Peer identity for Alice, including specifying key agreement and authentication keys, and service endpoints. ```scala import fmgp.crypto.* import fmgp.did.method.peer.* ``` ```scala val alice = DIDPeer2.makeAgent( Seq( OKPPrivateKey( // keyAgreement kty = KTY.OKP, crv = Curve.X25519, d = "Z6D8LduZgZ6LnrOHPrMTS6uU2u5Btsrk1SGs4fn8M7c", x = "Sr4SkIskjN_VdKTn0zkjYbhGTWArdUNE4j_DmUpnQGw", ), OKPPrivateKey( // keyAuthentication kty = KTY.OKP, crv = Curve.Ed25519, d = "INXCnxFEl0atLIIQYruHzGd5sUivMRyQOzu87qVerug", x = "MBjnXZxkMcoQVVL21hahWAw43RuAG-i64ipbeKKqwoA", ) ), Seq(DIDPeerServiceEncoded.fromEndpoint("https://alice.did.fmgp.app/")) ) ``` ```scala alice.id.asDIDSubject ``` ```scala alice.id.document.toJsonPretty ``` -------------------------------- ### Minimal example Source: https://github.com/fabiopinheiro/scala-did/blob/master/README.md Add scala-did to your project. ```scala libraryDependencies += "app.fmgp" %% "did" % "" libraryDependencies += "app.fmgp" %% "did-imp" % "" ``` -------------------------------- ### Flow Examples Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-comm-protocols/shared/src/main/scala/fmgp/did/comm/protocol/chatriqube/registry/registry-protocol.md Illustrates the flow of interactions for 'enroll' and 'set_id' operations. ```mermaid 'enroll' -> 'account|ProblemReport' 'set_id' -> 'account|ProblemReport' ``` ```mermaid flowchart TD A[User A] R[Registry] A -->|enroll| R R -->|account/ProblemReport| A ``` ```mermaid flowchart TD A[User A] R[Registry] A -->|set_id| R R -->|account| A ``` ```mermaid sequenceDiagram participant UserA participant Registry rect rgb(0, 100, 0) UserA ->>+ Registry: enroll Registry-->>-UserA: account | ProblemReport end rect rgb(0, 100, 0) Note over UserA,Registry: Assume now the UserA is enrolled UserA ->>+ Registry: set_id Registry-->>-UserA: account | ProblemReport end ``` -------------------------------- ### BasicMessage to Alice from Bob Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-example/README.md Example of sending a BasicMessage to Alice from Bob using wscat with a complex encrypted payload. ```bash wscat -c ws://localhost:8080 --host "alice.did.fmgp.app" -H 'content-type: application/didcomm-encrypted+json' -x '{"ciphertext":"2kZG7zupxREzVJPJPjqLljvR6Ylyw0VIMwv7i33HQx-cMbLp_zo9hueQQtw1TbZHa_UYfArB-sgSZW0WA-rWBQNKrztvAZJcdZ3_CoyTs2D5H-fYjDEGsdG_FzHgUvVQTM4ZVR39buoWUewBU-ri30dfxpWMj6Sb2sjIOtQ6OT-sA-8rs8CQG4cctFPo2JtyfkUsfQm5UWHzlrawKrLbFyqcOwgjzJfy0-T-hS93_p0S6Ask-iMsw3yP1dDU4EJGH09F5IGiX6UojFD9q60JHAXMbk4b1ggMTdbsqA9AZP-J_58T1gbolrd6yakunZSSeW1td0ADO3RFm3j_NbPn9kxhcx2U666K9PXBoYPU4E2OH2hNGTdIfQmwaEmZyql4KqtGD55UXEPl5nqB8exLm5TWCQVnCoGQHE0WLteWl6fIzWRlLLGAAlugaTuL9T0DCn0ZEOXBi-E_Wa7S9r2vtyBFilyNg1hEd9jVERzw-O09G1XBkcxP-wcX90klBP-CryrHzb-l_axLVu8_e9FGVYws_8jM5683n5FPItXaycgM3lurG7ZaRt8JZ_00rYjLWq2r0wkYXT2OSXCDp0Q8og14c7EvtTYJ3-hp4MJM3SnAj1OD5Qv25p4WSOIImYp76IyCqwWV4UbAZJzdU2H9-zdgZdT0WB_1OcJ8RvEXMenSGEnhEUvnIHJbNKtG_1Hk6ff_x11cSav6WqOEtBWsInqqxIHKy7sSiS-wwfhfkS0WTbYt7sXVPho8qUSs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IsImVuYyI6IkEyNTZDQkMtSFM1MTIiLCJhbGciOiJFQ0RILTFQVStBMjU2S1cifQ","recipients":[{"encrypted_key":"txOTbxUzITsOKF8blLw4LyK4ZVKIzfqi-cCRzPg9beLv2A4chxr_qx2HdLDYI_5FAMi5lyiKLYy5IL70fRIXZPmd2V0HpZuj","header":{"kid":"did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9hbGljZS5kaWQuZm1ncC5hcHAvIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfQ#6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y"}}],"tag":"72k9sVAjD0Kf5xQpwv5nq3qt5Uhzluyf98LUR2oh4DM","iv":"dWCTA0n15wUkT34ePgZCGw"}' ``` -------------------------------- ### Sending a Basic DIDComm Message Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/05-did-comm-examples.md Example of initializing and sending a basic DIDComm message. ```scala import zio.* import zio.json.* import fmgp.did.* import fmgp.did.comm.* import fmgp.did.comm.protocol.basicmessage2.* // Initialize a new message val message = new BasicMessage( to = Set(TO("did:example:123")), content = "Hello, World!", from = Some(FROM("did:example:456")), ) message.toPlaintextMessage.toJsonPretty ``` -------------------------------- ### Install jsdom Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/08-others/troubleshooting.md If you encounter a 'Cannot find module 'jsdom'' error, you need to install jsdom as a development dependency. ```shell yarn add jsdom --dev ``` -------------------------------- ### Install with Coursier Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Installs the cardano-prism CLI using Coursier, a Scala artifact fetching tool. It sets up an alias for the command and provides an option to reduce JVM warnings. ```bash alias cardano-prism='cs launch app.fmgp::cardano-prism-cli:0.1.0-M46 -M fmgp.did.method.prism.cli.PrismCli --' # Or with fewer JVM warnings alias cardano-prism='cs launch --java-opt --sun-misc-unsafe-memory-access=allow app.fmgp::cardano-prism-cli:0.1.0-M46 -M fmgp.did.method.prism.cli.PrismCli --' cardano-prism --help ``` -------------------------------- ### Resolve a DID Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Examples of resolving DIDs using different methods and endpoints. ```bash # Resolve from the PRISM VDR (GitHub-hosted) cardano-prism did resolve-prism did:prism: cardano-prism did resolve-prism --network preprod did:prism: # Resolve from a custom endpoint cardano-prism did resolve did:prism: https://my-resolver.example.com/ # Resolve using the Universal Resolver (https://dev.uniresolver.io/) cardano-prism did resolve-universal did:prism: cardano-prism did resolve-universal --endpoint https://my-uniresolver.example.com/ did:prism: # Resolve using NeoPrism cardano-prism did resolve-neoprism did:prism: cardano-prism did resolve-neoprism --network preprod did:prism: ``` -------------------------------- ### ScalaJS WASM instantiation Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-imp/README.md Example of how to instantiate and run a WASM module in ScalaJS. ```Scala import org.scalajs.dom._ val importObject = js.Dynamic.literal(imports = js.Dynamic.literal(imported_func = (p1) => println(p1))) js.Dynamic.global.WebAssembly .instantiateStreaming(fetch("simple.wasm"), importObject) .`then`((obj: js.Dynamic) => obj.instance.exports.exported_func()) ``` -------------------------------- ### Build (driven by sbt) Source: https://github.com/fabiopinheiro/scala-did/blob/master/cardano-prism-cip30-webapp/README.md This command runs the `fullLinkJS` (production-optimized Scala.js), `npm install`, and `node build.js` tasks. The same task is chained into `cardano-prism-cli`'s resource generators. ```sh sbt cardanoPrismCip30Webapp/cip30Bundle ``` -------------------------------- ### Parse a DID Document Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/04-basic-examples.md Demonstrates parsing a DID document from a JSON string using `fromJson[DIDDocument]`. It shows both successful parsing and how invalid JSON or non-DID Document JSON would result in a `Left` value. ```scala import zio.* import zio.json.* import fmgp.did.* import fmgp.did.comm.* ``` ```scala val documentString = """{ "@context": "https://www.w3.org/ns/did/v1", "id": "did:example:123456789abcdefghi", "keyAgreement": [ "did:example:123456789abcdefghi#keys-1", { "id": "did:example:123#zC9ByQ8aJs8vrNXyDhPHHNNMSHPcaSgNpjjsBYpMMjsTdS", "type": "X25519KeyAgreementKey2019", "controller": "did:example:123", "publicKeyMultibase": "z9hFgmPVfmBZwRvFEyniQDBkz9LmV7gDEqytWyGZLmDXE" } ] }""" ``` ```scala documentString.fromJson[DIDDocument] ``` ```scala "not a json".fromJson[DIDDocument] ``` ```scala "{}\".fromJson[DIDDocument] ``` -------------------------------- ### Submit Events via a browser wallet (CIP-30) Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Submits PRISM events through a CIP-30 browser wallet. The CLI starts a local server, opens the browser, and the wallet handles signing and submission. No Blockfrost token or wallet mnemonic is needed by the CLI. ```bash # cardano-prism website submit-cip30 [--port ] ... cardano-prism website submit-cip30 # Custom port (default is 8088) cardano-prism website submit-cip30 --port 9090 ``` -------------------------------- ### Indexer MongoDB mode Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Starts the indexer in database mode, storing state in a MongoDB database. Suitable for production deployments. ```bash # cardano-prism indexer mongodb --token cardano-prism indexer mongodb \ --token preprod \ 'mongodb+srv://user:password@cluster0.example.mongodb.net/indexer' ``` -------------------------------- ### Indexer in-memory mode Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Starts the indexer in file system mode, reading and writing state to the local file system. Suitable for lightweight deployments and CI/CD. ```bash # cardano-prism indexer in-memory [--token ] cardano-prism indexer in-memory --token preprod ./prism-vdr/preprod ``` -------------------------------- ### Run Server Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Commands to build the frontend and run the server with live reload. ```shell # Build Frontend sbt 'serviceworker/fullLinkJS'; npm run build ``` ```shell sbt '~ demoJVM/reStart' ``` -------------------------------- ### Docker Build and Run Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Commands to build a Docker image and run the container. ```shell sbt assemblyAll # java -jar jvm/target/scala-3.3.7/scala-did-demo-server.jar docker build --tag scala_did_demo ./demo/ #docker buildx build --platform linux/amd64,linux/arm64 --tag scala_did_demo ./demo/ docker run --rm -p 8080:8080 --memory="100m" --cpus="1.0" scala_did_demo ``` -------------------------------- ### Deploy by Pushing Docker Image to Fly.io Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Commands to build a Docker image, push it to Fly.io registry, and deploy. ```shell sbt assemblyAll #docker build --tag scala_did_demo ./demo/ docker buildx build --platform linux/amd64,linux/arm64 --tag scala_did_demo ./demo/ docker tag scala_did_demo registry.fly.io/scala-did-demo # fly auth docker docker push registry.fly.io/scala-did-demo fly image update -a scala-did-demo fly deploy -a scala-did-demo --image registry.fly.io/scala-did-demo:latest --ha=false ``` -------------------------------- ### Run Frontend Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Commands for live reloading the frontend. ```shell # Live reload sbt '~serviceworker/fastLinkJS'; sbt '~webapp/fastLinkJS' # run on another console npm run dev ``` -------------------------------- ### Deploy with Fly.io Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Commands to deploy the application using Fly.io. ```shell sbt assemblyAll fly deploy ./demo/ ``` -------------------------------- ### Build (driven by sbt) - packageBin Source: https://github.com/fabiopinheiro/scala-did/blob/master/cardano-prism-cip30-webapp/README.md This command produces a jar that contains `cip30/bundle.js` ready to serve. ```sh sbt cardanoPrismCli/Compile/packageBin ``` -------------------------------- ### Receiving DIDComm Messages Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/05-did-comm-examples.md Placeholder for code to receive DIDComm messages. ```scala // TODO // didcomm.onMessage { message => // println(s"Received message from ${message.from}: ${message.body}") // } ``` -------------------------------- ### Show JAR Size Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Command to display the disk usage of the JAR file. ```shell du -h demo/jvm/target/scala-3.3.7/scala-did-demo-server.jar ``` -------------------------------- ### ScalaJS WASM module interaction Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-imp/README.md Example of interacting with a WASM module after it has been generated by ScalablyTyped. ```Scala import typings.myproject.mod mod .default() // "myproject_bg.wasm" .`then` { mod.greet() } ``` -------------------------------- ### Inspect the jar - Fat jar Source: https://github.com/fabiopinheiro/scala-did/blob/master/cardano-prism-cip30-webapp/README.md Packages the CLI as a fat jar, merging all dependencies into one runnable jar. This is optional and only needed for a single-file distribution. ```sh sbt cardanoPrismCli/assembly # Run: java -jar cardano-prism-cli/target/scala-3.3.7/cardano-prism.jar cardano submit-cip30 0a066d617374657212473045022100b32b3dfc1fb47dc102038c1cbc1571b955f0ee7bab27e8b9626f8da62c50a4d6022050dfa98afdfe7503dbe58ed9ae20addb6d52a182521cd67e9d4bb6b79629b0f41a400a3e0a3c123a0a066d617374657210014a2e0a09736563703235366b31122103ebe0934672da51ca01da94d278376a204e0e73a8d235c290bc2d5f1a629f8aec ``` -------------------------------- ### ScalaDID Dependencies Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/02-quickstart/02-install-dependency.md Dependencies to add to your Scala project for using ScalaDID, DID Comm, and related modules. ```scala libraryDependencies += "app.fmgp" %% "did" % @VERSION@ // for DID and DID Comm libraryDependencies += "app.fmgp" %% "did-imp" % @VERSION@ // for crypto implementation libraryDependencies += "app.fmgp" %% "did-framework" % @VERSION@ //for utils libraryDependencies += "app.fmgp" %% "did-method-peer" % @VERSION@ // for resolver of the did method `peer` libraryDependencies += "app.fmgp" %% "did-method-web" % @VERSION@ // for resolver the did method `web` libraryDependencies += "app.fmgp" %% "did-uniresolver" % @VERSION@ // for calling the resolver uniresolver ``` -------------------------------- ### Manual build Source: https://github.com/fabiopinheiro/scala-did/blob/master/cardano-prism-cip30-webapp/README.md Steps to manually build the webapp bundle. ```sh sbt cardanoPrismCip30Webapp/fullLinkJS npm install CIP30_SCALAJS_DIR=target/scala-3.3.7/cardano-prism-cip30-webapp-opt npm run build ``` -------------------------------- ### Show Assets in JAR Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Command to filter and show assets within the JAR file. ```shell jar tvf demo/jvm/target/scala-3.3.7/scala-did-demo-server.jar | sort -k1nr | grep "assets/" ``` -------------------------------- ### Inspect JAR Contents Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Commands to list and sort the contents of the JAR file. ```shell jar tf /home/fabio/workspace/ScalaDID/demo/jvm/target/scala-3.3.7/scala-did-demo-server.jar | less jar tvf /home/fabio/workspace/ScalaDID/demo/jvm/target/scala-3.3.7/scala-did-demo-server.jar | sort -rnk 1 | less java -jar /home/fabio/workspace/ScalaDID/demo/jvm/target/scala-3.3.7/scala-did-demo-server.jar ``` -------------------------------- ### Open the cardano-prism website directly to the Simulate page Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Opens the cardano-prism website directly on the Simulate page, allowing users to paste hex data and simulate events. ```bash # cardano-prism website simulate [--port ] cardano-prism website simulate ``` -------------------------------- ### test wscat Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-example/README.md This command tests wscat by sending a POST request to localhost:8080 with specific headers and a DIDComm encrypted JSON payload. ```shell curl -X POST localhost:8080 -H "host: alice.did.fmgp.app" -H 'content-type: application/didcomm-encrypted+json' -d '{"ciphertext":"AKA9bmJKoEVP2xTC72Nt2SVp_fAOlgrXRWYKHzmi3z9VbODwzFY3ZgVbUt_9aa87Ckko_RDx2LRnwaIl4_y2Nadj5T0xnfqUIqJ-XOV_MfxOJeGQAEIrDhPFrrJvsNCsg16dJ9_pKOQerZcdwWoOygBQjqMgpFNcW-YUY27Dsaz7nAw00sSjanwmehTzqDpdQ2abHBtaNsi1NlR8Paxz24UDM1nfELpmWrLr6GdKRmL2XCbO7e_iFILyh5SZxaNqY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TJ0SGVUTmxNbm8xTkhWUU5GVTVTSGxZU2xoU2NHRkdNbmwwYzI1VWRWWm5hRFpUVGs1dFEzbEhXbEZhTGxaNk5rMXJhbVIzZG1ZNWFGZGpObWxpV201a1Z6bENPVGR6YVRreVJGTnJPV2hYUVdoSFdVSm5VRGxyVlVack9Gb3VVMlY1U2pCSmFtOXBXa2N3YVV4RFNucEphbTlwWVVoU01HTklUVFpNZVRscFlqSkpkVnBIYkd0TWJWcDBXak5CZFZsWVFuZE1lVWx6U1c1SmFVOXNkR1JNUTBwb1NXcHdZa2x0VW5CYVIwNTJZbGN3ZG1ScVNXbFlXREFqTmt4VGEwZDVNMlV5ZWpVMGRWQTBWVGxJZVZoS1dGSndZVVl5ZVhSemJsUjFWbWRvTmxOT1RtMURlVWRhVVZvIiwidHlwIjoiYXBwbGljYXRpb24vZGlkY29tbS1lbmNyeXB0ZWQranNvbiIsImVuYyI6IkEyNTZDQkMtSFM1MTIiLCJhbGciOiJFQ0RILTFQVStBMjU2S1cifQ","recipients":[{"encrypted_key":"RPtaGUPv22qIBA14BpkrD620HgOFAzXeZOIiVzeUag00-RHZs3XNC68XCqCgON5x4uQho8HkJ5MWFaTZNbkIizfm-zymOZ62","header":{"kid":"did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y#6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y"}}],"tag":"nExhi83YT0n7B9q-OtfktTkdHO_UWk4a-KP0j_Oddwk","iv":"kXtzZmq3y8NAEBEC4NtDrg"}' ``` -------------------------------- ### TrustPingWithRequestedResponse to Alice from Bob Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-example/README.md Command to send a TrustPing message with a requested response to Alice from Bob using wscat. ```bash wscat -c ws://localhost:8080 --host "alice.did.fmgp.app" -H 'content-type: application/didcomm-encrypted+json' -x ``` -------------------------------- ### Open the cardano-prism website Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Opens the cardano-prism website in a browser, optionally on a custom port. The server stays up until Ctrl-C. ```bash # cardano-prism website open [--port ] cardano-prism website open cardano-prism website open --port 9090 ``` -------------------------------- ### Inspect the jar - List contents Source: https://github.com/fabiopinheiro/scala-did/blob/master/cardano-prism-cip30-webapp/README.md Lists the contents of a jar to verify that `cip30/bundle.js` is packaged. ```sh jar tf cardano-prism-cli/target/scala-3.3.7/cardano-prism-cli_3-0.1.0-SNAPSHOT.jar | grep cip30 # cip30/bundle.js # cip30/bundle.js.map ``` -------------------------------- ### Inspect the jar - Library jar Source: https://github.com/fabiopinheiro/scala-did/blob/master/cardano-prism-cip30-webapp/README.md Packages the CLI as a library jar, containing only this project's classes/resources. This is useful for publishing to a Maven repo. ```sh sbt cardanoPrismCli/Compile/packageBin # -> cardano-prism-cli/target/scala-3.3.7/cardano-prism-cli_3-0.1.0-SNAPSHOT.jar ``` -------------------------------- ### Website Subcommands Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md CLI commands to interact with the local website playground. ```bash cardano-prism website open cardano-prism website simulate cardano-prism website submit-cip30 ``` -------------------------------- ### Send Message with wscat Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-example/README.md Command to send a message to a WebSocket endpoint using wscat, specifying host and content type. ```bash wscat -c ws://localhost:8080 --host "alice.did.fmgp.app" -H 'content-type: application/didcomm-encrypted+json' ``` -------------------------------- ### Run ci-release Local Source: https://github.com/fabiopinheiro/scala-did/blob/master/PUBLISH.md Command to run the CI release process locally, including setting necessary environment variables. ```zsh SONATYPE_USERNAME=??? SONATYPE_PASSWORD=??? PGP_SECRET=??? sbt ``` -------------------------------- ### Sort JAR by File Size Source: https://github.com/fabiopinheiro/scala-did/blob/master/demo/README.md Command to sort the JAR contents by file size in descending order. ```shell jar tvf demo/jvm/target/scala-3.3.7/scala-did-demo-server.jar | sort -k1nr | less ``` -------------------------------- ### Publish Local Source: https://github.com/fabiopinheiro/scala-did/blob/master/PUBLISH.md Command to publish the project locally. ```sbt publishLocal ``` -------------------------------- ### Send Message with curl Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-example/README.md Command to send a POST request to a local endpoint using curl, with specified headers and an empty JSON body. ```bash curl -X POST localhost:8080 -H "host: alice.did.fmgp.app" -H 'content-type: application/didcomm-encrypted+json' -d '{}' ``` -------------------------------- ### Export from MongoDB to per-`ref` files Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Dumps events from a MongoDB-backed indexer into one file per `ref` on disk. Supports incremental updates using a `.cursor` file and can force a full rebuild with `--from-scratch`. ```bash # cardano-prism indexer export [--from-scratch] # First run (or any run with no .cursor) — full rebuild # Subsequent runs — incremental, appends only new events since the last .cursor cardano-prism indexer export \ 'mongodb+srv://readonly:readonly@cluster0.example.mongodb.net/indexer' \ ./prism-vdr/preprod/events # Force a full rebuild cardano-prism indexer export --from-scratch \ 'mongodb+srv://readonly:readonly@cluster0.example.mongodb.net/indexer' \ ./prism-vdr/preprod/events ``` -------------------------------- ### SBT Release Commands Source: https://github.com/fabiopinheiro/scala-did/blob/master/PUBLISH.md SBT commands to perform the release process. ```sbt +publish +publishSigned +sonatypeBundleRelease ``` -------------------------------- ### Project Versions Source: https://github.com/fabiopinheiro/scala-did/blob/master/PUBLISH.md List of version identifiers for different DID specifications. ```text did_3 did_sjs1_3 did-imp_3 did-imp_sjs1_3 did-method-peer_3 did-method-peer_sjs1_3 did-method-web_3 did-method-web_sjs1_3 multiformats_3 multiformats_sjs1_3 ``` -------------------------------- ### Project Structure and Dependencies Graph Source: https://github.com/fabiopinheiro/scala-did/blob/master/README.md Mermaid diagram illustrating the project's structure and dependencies. ```mermaid flowchart BT zhttp --> zio did --> zio zio-json --> zio did --> zio-json did-method-web ----> zhttp:::JVM subgraph fmgp libraries did-method-peer --> multiformats subgraph platform specific did-imp did-imp-hw:::Others -.-> did-imp did-imp_js:::JS ==>|compiles together| did-imp did-imp_jvm:::JVM ==>|compiles together| did-imp end did-method-web --> did did-method-peer --> did did-method-prism ---> did did-comm-protocols --> did did-framework --> did did-framework --> did-comm-protocols did-imp --> did end prism-node:::JVM -----> did-method-prism did-example ----> did did-example --> did-imp demo --> did-imp did-imp_jvm:::JVM ----> nimbus-jose-jwt:::JVM --> google-tink:::JVM did-imp_jvm:::JVM ---> google-tink did-imp_js ----> jose:::JS %% subgraph demo/docs webapp:::JS --> did-framework demo --> did-framework demo --> did-method-web demo --> did-method-peer webapp:::JS --> did-imp_js webapp:::JS --> did-method-web webapp:::JS --> did-method-peer webapp:::JS --> did-example demo --> did-example demo -.->|uses\serves| webapp demo_jvm(demo_jvm\nA server):::JVM ==>|compiles together| demo did-example --> did-method-peer did-example --> did-method-web %% end classDef JVM fill:#141,stroke:#444,stroke-width:2px; classDef JS fill:#05a,stroke:#444,stroke-width:2px; classDef Others fill:#222,stroke:#444,stroke-width:2px,stroke-dasharray: 5 5; ``` -------------------------------- ### Check Messages with curl Source: https://github.com/fabiopinheiro/scala-did/blob/master/did-example/README.md Command to check messages from a database endpoint using curl, specifying the host. ```bash curl 'http://localhost:8080/db' -H "host: alice.did.fmgp.app" ``` -------------------------------- ### Create a DID for VDR Source: https://github.com/fabiopinheiro/scala-did/blob/master/docs/src/09-cardano-prism-cli/01-cardano-prism-cli.md Command to create a DID with a master key and an optional VDR key. ```bash cardano-prism did create-for-vdr --master key-0-Master-0 --vdr key-0-Vdr-0 ```