diff --git a/affinidi-messaging-mediator/README.md b/affinidi-messaging-mediator/README.md index 81ac08d..ea09c02 100644 --- a/affinidi-messaging-mediator/README.md +++ b/affinidi-messaging-mediator/README.md @@ -50,7 +50,8 @@ To build and run this project, you need to set up the following: cargo run --example generate_secrets ``` - This will generate `affinidi-messaging-mediator/conf/secrets.json-generated` file containing a did:peer together with the pair of keys for verification and encryption. Use the generated did:peer as a value for `` placeholder in following commands as well as in [affinidi-messaging-sdk - Examples](../affinidi-messaging-sdk#examples). + This will generate `affinidi-messaging-mediator/conf/secrets.json-generated` file containing a did:peer together with the pair of keys for verification and encryption and `jwt_authorization_secret` you shall use for `jwt_authorization_secret` value in `mediator.toml`. + Use the generated did:peer as a value for `` placeholder in following commands as well as in [affinidi-messaging-sdk - Examples](../affinidi-messaging-sdk#examples). 4. Save the generated `secrets.json-generated` file as `affinidi-messaging-mediator/conf/secrets.json`. diff --git a/affinidi-messaging-mediator/examples/generate_secrets.rs b/affinidi-messaging-mediator/examples/generate_secrets.rs index ed25ca0..9a2acb7 100644 --- a/affinidi-messaging-mediator/examples/generate_secrets.rs +++ b/affinidi-messaging-mediator/examples/generate_secrets.rs @@ -1,10 +1,13 @@ use std::fs::File; use std::io::Write; +use base64::prelude::{Engine as _, BASE64_URL_SAFE_NO_PAD}; + use did_peer::{ DIDPeer, DIDPeerCreateKeys, DIDPeerKeys, DIDPeerService, PeerServiceEndPoint, PeerServiceEndPointLong, }; +use ring::signature::Ed25519KeyPair; use serde_json::json; use ssi::{ dids::DIDKey, @@ -110,7 +113,7 @@ async fn main() -> std::io::Result<()> { let (did_peer, _) = DIDPeer::create_peer_did(&keys, Some(&services)).expect("Failed to create did:peer"); - println!("{}", did_peer); + println!("did = {}", did_peer); let secrets_json = json!([ { @@ -141,5 +144,12 @@ async fn main() -> std::io::Result<()> { let mut file = File::create("./conf/secrets.json-generated")?; file.write_all(json_string.as_bytes())?; + // Create jwt_authorization_secret + let doc = Ed25519KeyPair::generate_pkcs8(&ring::rand::SystemRandom::new()).unwrap(); + println!( + "jwt_authorization_secret = {}", + &BASE64_URL_SAFE_NO_PAD.encode(doc.as_ref()) + ); + Ok(()) }