Skip to content

Commit

Permalink
Merge pull request #114 from sicpa-dlab/main
Browse files Browse the repository at this point in the history
release-0.4.0
  • Loading branch information
dkulic committed Mar 2, 2023
2 parents cb33da4 + 3adf844 commit 9f3e9f9
Show file tree
Hide file tree
Showing 58 changed files with 2,223 additions and 2,323 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,42 @@ jobs:
already_in_npm_nodejs: ${{ steps.check_in_npm.outputs.already_in_npm_nodejs != '' }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Get current version
id: current_version
run: |
version="$(cargo -q metadata --no-deps \
| jq -r '.packages[] | select(.name == "${{ env.PKG_NAME }}") | .version')"
echo "$version"
echo "::set-output name=current_version::$version"
echo "current_version=$version" >> $GITHUB_OUTPUT
shell: bash

- name: Get release info
id: release_info
run: |
release_info="$(curl -s https://api.github.com/repos/${{ github.repository }}/releases \
| jq '.[] | select(.name == "v${{ steps.current_version.outputs.current_version }}")')"
echo "::set-output name=release_info::$release_info"
echo "release_info=$release_info" >> $GITHUB_OUTPUT
echo "$release_info"
asset_crate_url="$(echo "$release_info" \
| jq -r '.assets[] | select(.name | match("^${{ env.PKG_NAME }}.*\\.crate$")) | .browser_download_url')"
echo "::set-output name=asset_crate_url::$asset_crate_url"
echo "asset_crate_url=$asset_crate_url" >> $GITHUB_OUTPUT
echo "$asset_crate_url"
asset_npm_pkg_bundler_url="$(echo "$release_info" \
| jq -r '.assets[] | select(.name | match("^${{ env.PKG_NAME }}-${{ steps.current_version.outputs.current_version }}\\.tgz$")) | .browser_download_url')"
echo "::set-output name=asset_npm_pkg_bundler_url::$asset_npm_pkg_bundler_url"
echo "asset_npm_pkg_bundler_url=$asset_npm_pkg_bundler_url" >> $GITHUB_OUTPUT
echo "$asset_npm_pkg_bundler_url"
asset_npm_pkg_nodejs_url="$(echo "$release_info" \
| jq -r '.assets[] | select(.name | match("^${{ env.PKG_NAME_NODEJS }}-${{ steps.current_version.outputs.current_version }}\\.tgz$")) | .browser_download_url')"
echo "::set-output name=asset_npm_pkg_nodejs_url::$asset_npm_pkg_nodejs_url"
echo "asset_npm_pkg_nodejs_url=$asset_npm_pkg_nodejs_url" >> $GITHUB_OUTPUT
echo "$asset_npm_pkg_nodejs_url"
upload_url="$(echo "$release_info" | jq -r '.upload_url')"
echo "::set-output name=upload_url::$upload_url"
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
echo "$upload_url"
shell: bash

Expand All @@ -79,7 +79,7 @@ jobs:
out="$(curl -s https://crates.io/api/v1/crates/${{ env.PKG_NAME }} | jq -r '.versions[] | .num' \
| grep '^${{ steps.current_version.outputs.current_version }}$')"
echo "in crates.io check: $out"
echo "::set-output name=already_in_crates_io::$out"
echo "already_in_crates_io=$out" >> $GITHUB_OUTPUT
shell: bash {0} # to opt-out of default fail-fast behavior

- name: check if already deployed to npm
Expand All @@ -88,12 +88,12 @@ jobs:
out="$(npm view ${{ env.PKG_NAME }}@${{ steps.current_version.outputs.current_version }} --json 2>/dev/null \
| jq -r '.versions | select (.!=null)')"
echo "in npm check for ${{ env.PKG_NAME }} : $out"
echo "::set-output name=already_in_npm_bundler::$out"
echo "already_in_npm_bundler=$out" >> $GITHUB_OUTPUT
out="$(npm view ${{ env.PKG_NAME_NODEJS }}@${{ steps.current_version.outputs.current_version }} --json 2>/dev/null \
| jq -r '.versions | select (.!=null)')"
echo "in npm check for ${{ env.PKG_NAME_NODEJS }}: $out"
echo "::set-output name=already_in_npm_nodejs::$out"
echo "already_in_npm_nodejs=$out" >> $GITHUB_OUTPUT
shell: bash {0} # to opt-out of default fail-fast behavior


Expand All @@ -103,7 +103,7 @@ jobs:
runs-on: ubuntu-latest
needs: checks
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set rustup profile & toolchain
run: |
Expand All @@ -130,9 +130,9 @@ jobs:
if: ${{ !(needs.checks.outputs.asset_crate_url && needs.checks.outputs.asset_npm_pkg_bundler_url && needs.checks.outputs.asset_npm_pkg_nodejs_url) }}
run: |
if [[ -n "${{ needs.checks.outputs.upload_url }}" ]]; then
echo "::set-output name=value::${{ needs.checks.outputs.upload_url }}"
echo "value=${{ needs.checks.outputs.upload_url }}" >> $GITHUB_OUTPUT
else
echo "::set-output name=value::${{ steps.create_release.outputs.upload_url }}"
echo "value=${{ steps.create_release.outputs.upload_url }}" >> $GITHUB_OUTPUT
fi
- name: package and verify (crate)
Expand All @@ -148,7 +148,7 @@ jobs:
cargo package --list
asset_name="$(find target/package -name '*.crate' -printf '%f')"
echo "::set-output name=asset_name::$asset_name"
echo "asset_name=$asset_name" >> $GITHUB_OUTPUT
shell: bash

- name: upload to GitHub (crate)
Expand All @@ -169,7 +169,7 @@ jobs:
# build, install (verify) and pack
make -C wasm build install pack
asset_name="$(find wasm/pkg -name '*.tgz' -printf '%f')"
echo "::set-output name=asset_name::$asset_name"
echo "asset_name=$asset_name" >> $GITHUB_OUTPUT
shell: bash

- name: upload to GitHub (npm bundler)
Expand All @@ -190,7 +190,7 @@ jobs:
# build, install (verify) and pack
WASM_TARGET=nodejs PKG_NAME=${{ env.PKG_NAME_NODEJS }} make -C wasm build install pack
asset_name="$(find wasm/pkg -name '*.tgz' -printf '%f')"
echo "::set-output name=asset_name::$asset_name"
echo "asset_name=$asset_name" >> $GITHUB_OUTPUT
shell: bash

- name: upload to GitHub (npm nodejs)
Expand Down Expand Up @@ -238,7 +238,7 @@ jobs:
if: github.ref != 'refs/heads/stable' && github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set rustup profile & toolchain
run: |
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Get current version
id: current_version
run: |
version="$(cargo -q metadata --no-deps \
| jq -r '.packages[] | select(.name == "${{ env.PKG_NAME }}") | .version')"
echo "$version"
echo "::set-output name=current_version::$version"
echo "current_version=$version" >> $GITHUB_OUTPUT
cd wasm
version="$(cargo -q metadata --no-deps \
| jq -r '.packages[] | select(.name == "${{ env.PKG_NAME_JS_TMP }}") | .version')"
echo "$version"
echo "::set-output name=current_wasm_version::$version"
echo "current_wasm_version=$version" >> $GITHUB_OUTPUT
- name: Check version format
run: |
Expand All @@ -47,7 +47,7 @@ jobs:
run: |
release_info="$(curl -s https://api.github.com/repos/${{ github.repository }}/releases \
| jq '.[] | select(.name == "v${{ steps.current_version.outputs.current_version }}")')"
echo "::set-output name=release_info::$release_info"
echo "release_info=$release_info" >> $GITHUB_OUTPUT
echo "$release_info"
- name: check version bumped
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set rustup profile & toolchain
run: |
Expand All @@ -92,8 +92,8 @@ jobs:
- name: Get timestamp for cache
id: date
run: echo ::set-output name=yearmo::$(date +%Y%m)
- uses: actions/cache@v2
run: echo "yearmo=$(date +%Y%m)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set rustup profile & toolchain
run: |
Expand All @@ -138,8 +138,8 @@ jobs:
- name: Get timestamp for cache
id: date
run: echo ::set-output name=yearmo::$(date +%Y%m)
- uses: actions/cache@v2
run: echo "yearmo=$(date +%Y%m)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand All @@ -160,7 +160,7 @@ jobs:

# TODO caching, makes sense for demo and tests-js where lock files are presented
- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand Down Expand Up @@ -229,7 +229,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set rustup profile & toolchain
run: |
Expand All @@ -238,8 +238,8 @@ jobs:
- name: Get timestamp for cache
id: date
run: echo ::set-output name=yearmo::$(date +%Y%m)
- uses: actions/cache@v2
run: echo "yearmo=$(date +%Y%m)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name = 'routing'

[package]
name = 'didcomm'
version = '0.3.4'
version = '0.4.0'
authors = ['Vyacheslav Gudkov <vyacheslav.gudkov@dsr-corporation.com>']
edition = '2018'
description = 'DIDComm for Rust'
Expand Down Expand Up @@ -77,4 +77,4 @@ features = ['async_futures']

[features]
uniffi = []
testvectors = ["lazy_static"]
testvectors = ["lazy_static"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To use `didcomm`, add this to your `Cargo.toml`:

```toml
[dependencies]
didcomm = "0.3"
didcomm = "0.4"
```

## Run examples
Expand Down
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"config:base"
]
}
37 changes: 24 additions & 13 deletions src/did/did_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@ use serde_json::Value;

/// Represents DID Document (https://www.w3.org/TR/did-core/)
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DIDDoc {
/// DID for the given DID Doc
pub did: String,
pub id: String,

/// DID URLs of verification methods used for key agreement.
/// See https://www.w3.org/TR/did-core/#verification-methods.
pub key_agreements: Vec<String>,
pub key_agreement: Vec<String>,

/// Returns DID URLs of verification methods used for authentication.
/// See https://www.w3.org/TR/did-core/#authentication
pub authentications: Vec<String>,
pub authentication: Vec<String>,

/// All local verification methods including embedded to
/// key agreement and authentication sections.
/// See https://www.w3.org/TR/did-core/#verification-methods.
pub verification_methods: Vec<VerificationMethod>,
pub verification_method: Vec<VerificationMethod>,

/// All services (https://www.w3.org/TR/did-core/#services)
pub services: Vec<Service>,
pub service: Vec<Service>,
}

/// Represents verification method record in DID Document
Expand All @@ -34,6 +35,7 @@ pub struct VerificationMethod {
#[serde(rename = "type")]
pub type_: VerificationMethodType,
pub controller: String,
#[serde(flatten)]
pub verification_material: VerificationMaterial,
}

Expand All @@ -50,24 +52,30 @@ pub enum VerificationMethodType {

/// Represents verification material (https://www.w3.org/TR/did-core/#verification-material)
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(tag = "format")]
#[serde(untagged)]
pub enum VerificationMaterial {
JWK { value: Value },
Multibase { value: String },
Base58 { value: String },
Hex { value: String },
Other { value: Value },
#[serde(rename_all = "camelCase")]
JWK { public_key_jwk: Value },

#[serde(rename_all = "camelCase")]
Multibase { public_key_multibase: String },

#[serde(rename_all = "camelCase")]
Base58 { public_key_base58: String },
}

/// Represents service record in DID Document (https://www.w3.org/TR/did-core/#services).
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Service {
pub id: String,
pub kind: ServiceKind,

#[serde(flatten)]
pub service_endpoint: ServiceKind,
}

/// Represents additional service properties defined for specific Service type.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(tag = "type", content = "serviceEndpoint")]
pub enum ServiceKind {
DIDCommMessaging {
#[serde(flatten)]
Expand All @@ -82,10 +90,13 @@ pub enum ServiceKind {
/// Properties for DIDCommMessagingService
/// (https://identity.foundation/didcomm-messaging/spec/#did-document-service-endpoint).
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DIDCommMessagingService {
pub service_endpoint: String,
pub uri: String,

#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub accept: Option<Vec<String>>,

pub routing_keys: Vec<String>,
}
2 changes: 1 addition & 1 deletion src/did/resolvers/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl DIDResolver for ExampleDIDResolver {
Ok(self
.known_dids
.iter()
.find(|ddoc| ddoc.did == did)
.find(|ddoc| ddoc.id == did)
.map(|ddoc| ddoc.clone()))
}
}
4 changes: 2 additions & 2 deletions src/message/from_prior/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl FromPrior {
}

let kid = did_doc
.authentications
.authentication
.iter()
.find(|a| *a == kid)
.ok_or_else(|| {
Expand All @@ -83,7 +83,7 @@ impl FromPrior {

vec![kid]
} else {
did_doc.authentications.iter().map(|s| s.as_str()).collect()
did_doc.authentication.iter().map(|s| s.as_str()).collect()
};

let kid = *secrets_resolver
Expand Down
Loading

0 comments on commit 9f3e9f9

Please sign in to comment.