docs: update entity example to latest api
@@ -25,10 +25,6 @@ maintaining a secure channel behind two simple functions:
An `Entity` is an abstraction that provides an API for managing identities. The `Entity` API requires a Vault to store and manage secrets.
In this example, a Vault is created automatically by the Entity.
-Establishing a secure channel requires a **trust policy**. The simplest trust policy is the `IdentifierTrustPolicy` which
-determines trust based on a static access control list of authorized parties. In this example, the two parties will
-mutually trust one another by constructing `IdentifierTrustPolicy`s which contain each other's identifiers.
-
## App worker
For demonstration, we'll create a secure channel within a single node. Like our
@@ -46,7 +42,7 @@ Add the following code to this file:
```rust
// This node creates a secure channel and routes a message through it.
-use ockam::{Address, Context, Entity, IdentifierTrustPolicy, ProfileIdentity, Result, Route};
+use ockam::{Address, Context, Entity, Result, Route, SecureChannels};
use ockam_get_started::Echoer;
#[ockam::node]
@@ -54,24 +50,15 @@ async fn main(mut ctx: Context) -> Result<()> {
// Start an Echoer worker at address "echoer"
ctx.start_worker("echoer", Echoer).await?;
- let mut bob = Entity::create(&ctx).await?;
+ let mut bob = Entity::create(&ctx)?;
// Connect to a secure channel listener and perform a handshake.
- let mut alice = Entity::create(&ctx).await?;
-
- // Bob defines a trust policy that only trusts Alice
- let bob_trust_policy = IdentifierTrustPolicy::new(alice.identifier()?);
-
- // Alice defines a trust policy that only trusts Bob
- let alice_trust_policy = IdentifierTrustPolicy::new(bob.identifier()?);
+ let mut alice = Entity::create(&ctx)?;
// Create a secure channel listener.
- bob.create_secure_channel_listener("bob_secure_channel_listener", bob_trust_policy)
- .await?;
+ bob.create_secure_channel_listener("bob_secure_channel_listener")?;
- let channel_to_bob = alice
- .create_secure_channel("bob_secure_channel_listener", alice_trust_policy)
- .await?;
+ let channel_to_bob = alice.create_secure_channel("bob_secure_channel_listener")?;
let echoer: Address = "echoer".into();
let route: Route = vec![channel_to_bob, echoer].into();
@@ -86,7 +73,6 @@ async fn main(mut ctx: Context) -> Result<()> {
// Stop all workers, stop the node, cleanup and return.
ctx.stop().await
}
-
```
To run this new node program:
