Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 update zenroom deprecated statements #56

Merged
merged 12 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ jobs:
name: 🧪 Contract unit tests
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: ⏬ Install Zenroom
run: |
wget https://github.com/dyne/zenroom/releases/latest/download/zenroom -O zenroom
@@ -41,7 +41,7 @@ jobs:
name: 🔬 API integration tests
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: ⏬ Install Zenroom
run: |
wget https://github.com/dyne/zenroom/releases/latest/download/zenroom -O zenroom
@@ -87,17 +87,17 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, latest]
node-version: [16.x, 18.x, 20.x]
env:
SANDBOX_TEST_ADMIN_KEYRING: ${{secrets.SANDBOX_TEST_ADMIN_KEYRING}}
defaults:
run:
working-directory: bindings/javascript
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: ⚙️ Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: ⏬ Install dependencies
29 changes: 16 additions & 13 deletions api/v1/common/pubkeys-accept-1-acl.zen
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Rule caller restroom-mw
Rule unknown ignore
Rule input encoding base58
Scenario 'ecdh': singature
Scenario 'eddsa': signature
Scenario 'w3c': did document

# http_request
# restroom statement
Given I read the http request

# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'

# data
Given I have a 'did document' named 'did document'
and I rename 'did_document' to 'request_did_document'
and I have a 'ecdh signature'
@@ -16,7 +19,7 @@ and I have a 'eddsa signature'
and I have a 'string' named 'id'
and I rename 'id' to 'signer_id'

# constants
# keys
Given I have a 'string dictionary' named 'request_ACL'
and I have a 'string dictionary' named 'signer_ACL'
and I have a 'string dictionary' named 'utility'
@@ -37,20 +40,20 @@ and I write string '' in 'signer_path_permission'

# signer_parts
When I create the array by splitting 'signer_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'signer_idspec'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'signer_idpk'
and I remove 'array'

# request_parts
When I pickup from path 'request_did_document.id'
and I rename the 'id' to 'request_id'
and I create the array by splitting 'request_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'request_idspec'
and I copy 'request_idspec' to 'commit message'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'request_idpk'
and I remove 'array'
# request_domain
@@ -59,12 +62,12 @@ and I rename 'array' to 'request_split_by_underscore'
and I create the size of 'request_split_by_underscore'
and I verify number 'size' is less or equal than '2'
and I rename 'size' to 'length_request_split_by_underscore'
and I create the copy of element '1' in array 'request_split_by_underscore'
and I create the copy of element '1' from array 'request_split_by_underscore'
and I rename 'copy' to 'request_domain.request_ctx'
and I create the array by splitting 'request_domain.request_ctx' at '.'
and I create the size of 'array'
and I verify number 'size' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'request_domain'
and I remove 'size'
and I remove 'array'
@@ -77,7 +80,7 @@ and I verify 'request_domain' is not equal to 'admin' in 'utility'
When I create the array by splitting 'signer_idspec' at '_'
and I create the size of 'array'
and I verify number 'size' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'signer_domain.signer_ctx'

# no underscore => has to be admin
@@ -97,7 +100,7 @@ If I verify 'size' is equal to '2' in 'utility'
When I remove 'exit_code'
and I set 'exit_code' to 'check signer permissions' as 'string'

When I create the copy of element '2' in array 'array'
When I create the copy of element '2' from array 'array'
and I verify the 'copy' is found in 'signer_ACL'

When I append the string '/' to 'signer_path_permission'
@@ -163,10 +166,10 @@ If I verify 'length_request_split_by_underscore' is equal to '2' in 'utility'
When I remove 'exit_code'
and I set 'exit_code' to 'check request permissions' as 'string'

When I create the copy of element '1' in array 'request_split_by_underscore'
When I create the copy of element '1' from array 'request_split_by_underscore'
and I remove 'request_idspec'
and I rename 'copy' to 'request_idspec'
and I create the copy of element '2' in array 'request_split_by_underscore'
and I create the copy of element '2' from array 'request_split_by_underscore'
and I verify the 'copy' is found in 'request_ACL'
and I append the string '/' to 'request_idspec'
and I append 'copy' to 'request_idspec'
46 changes: 21 additions & 25 deletions api/v1/common/pubkeys-accept-2-checks.zen
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
Rule caller restroom-mw
Rule unknown ignore
Scenario 'ecdh': verify signature
Scenario 'eddsa': verify signature
Scenario 'w3c': proof

# http_request.base_url
# restroom statements
Given I read the http request
Given I have a 'string' named 'base_url' inside 'http_request'

# verify git repo
Given I verify the path 'data/' is a git repository
and I verify the path 'data/' is a git repository
and I read the content of 'request_path' and save the output into 'request_data'
and I fetch the local timestamp and store it into 'accept_timestamp'
and I read the content of 'signer_path' and save the output into 'signer_data'

# request_data should be = {}
Given I read the content of 'request_path' and save the output into 'request_data'
# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'
and I have a 'string dictionary' named 'request_data'

# timestamp
Given I fetch the local timestamp and store it into 'accept_timestamp'
and I have a 'integer' named 'accept_timestamp'
and I have a 'did document' named 'didDocument' in 'signer_data'
and I rename 'didDocument' to 'signer_did_document'
and I have a 'string dictionary' named 'didDocumentMetadata' in 'signer_data'
and I rename 'didDocumentMetadata' to 'signer_metadata'

# signer did document
Given I read the content of 'signer_path' and save the output into 'signer_data'
Given I have a 'did document' named 'didDocument' in 'signer_data'
Given I rename 'didDocument' to 'signer_did_document'
Given I have a 'string dictionary' named 'didDocumentMetadata' in 'signer_data'
Given I rename 'didDocumentMetadata' to 'signer_metadata'

# key
Given I have a 'string dictionary' named 'proof'
and I have a 'string' named '@context'
and I have a 'integer' named 'expiration_time'
and I have a 'string' named 'commit_message_prefix_accept'
# data
Given I have a 'did document' named 'request did document'
and I have a 'ecdh signature'
@@ -40,6 +29,12 @@ and I have a 'string' named 'signer_id'
and I have a 'string' named 'author'
and I have a 'string' named 'commit message'

# key
Given I have a 'string dictionary' named 'proof'
and I have a 'string' named '@context'
and I have a 'integer' named 'expiration_time'
and I have a 'string' named 'commit_message_prefix_accept'

# verify contract is used inside the chain
When I verify 'base_url' has suffix 'pubkeys-accept.chain'

@@ -120,6 +115,7 @@ and print the 'request_path'
and print the 'log_msg'
and print the 'commit'

# restroom statements
Then store 'result' in the file 'request_path'
Then append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
Then make a new commit to the git repository in 'data'
and append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
and make a new commit to the git repository in 'data'
28 changes: 15 additions & 13 deletions api/v1/common/pubkeys-broadcast-1-path.zen
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Rule caller restroom-mw
Rule unknown ignore
Rule input encoding base58
Scenario 'eddsa': singature
Scenario 'w3c': did document

# http_request
# restroom statements
Given I read the http request

# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'

# data
@@ -14,7 +16,7 @@ and I have a 'integer' named 'timestamp'
and I have a 'string' named 'id'
and I rename 'id' to 'signer_id'

# constants
# keys
Given I have a 'string dictionary' named 'request_ACL'
and I have a 'string dictionary' named 'signer_ACL'
and I have a 'float' named '0'
@@ -36,18 +38,18 @@ and I write string '' in 'signer_path_permission'

# signer_parts
When I create the array by splitting 'signer_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'signer_idspec'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'signer_idpk'
and I remove 'array'

# request_parts
When I create the array by splitting 'broadcast_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'request_idspec'
and I copy 'request_idspec' to 'commit message'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'request_idpk'
and I remove 'array'

@@ -57,12 +59,12 @@ and I rename 'array' to 'request_split_by_underscore'
and I create the size of 'request_split_by_underscore'
and I verify number 'size' is less or equal than '2'
and I rename 'size' to 'length_request_split_by_underscore'
and I create the copy of element '1' in array 'request_split_by_underscore'
and I create the copy of element '1' from array 'request_split_by_underscore'
and I rename 'copy' to 'request_domain.request_ctx'
and I create the array by splitting 'request_domain.request_ctx' at '.'
and I create the size of 'array'
and I verify number 'size' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'request_domain'
and I remove 'size'
and I remove 'array'
@@ -76,7 +78,7 @@ and I verify 'request_domain' is not equal to 'admin'
When I create the array by splitting 'signer_idspec' at '_'
and I create the size of 'array'
and I verify number 'size' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'signer_domain.signer_ctx'

# no underscore => has to be admin
@@ -97,7 +99,7 @@ If I verify 'size' is equal to '2'
When I remove 'exit_code'
and I set 'exit_code' to 'check signer permissions' as 'string'

When I create the copy of element '2' in array 'array'
When I create the copy of element '2' from array 'array'
and I verify the 'copy' is found in 'signer_ACL'

When I append the string '/' to 'signer_path_permission'
@@ -169,10 +171,10 @@ If I verify 'length_request_split_by_underscore' is equal to '2'
When I remove 'exit_code'
and I set 'exit_code' to 'check request permissions' as 'string'

When I create the copy of element '1' in array 'request_split_by_underscore'
When I create the copy of element '1' from array 'request_split_by_underscore'
and I remove 'request_idspec'
and I rename 'copy' to 'request_idspec'
and I create the copy of element '2' in array 'request_split_by_underscore'
and I create the copy of element '2' from array 'request_split_by_underscore'
and I verify the 'copy' is found in 'request_ACL'
and I append the string '/' to 'request_idspec'
and I append 'copy' to 'request_idspec'
44 changes: 20 additions & 24 deletions api/v1/common/pubkeys-broadcast-2-checks.zen
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
Rule caller restroom-mw
Rule unknown ignore
Scenario 'eddsa': verify signature
Scenario 'w3c': proof

# http_request.base_url (restroom)
# restroom statements
Given I read the http request
Given I have a 'string' named 'base_url' inside 'http_request'
and I fetch the local timestamp and store it into 'broadcast_timestamp'
and I read the content of 'signer_path' and save the output into 'signer_data'
and I read the content of 'request_path' and save the output into 'request_data'

# timestamp (restroom)
Given I fetch the local timestamp and store it into 'broadcast_timestamp'
# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'
and I have a 'integer' named 'broadcast_timestamp'

# signer did document
Given I read the content of 'signer_path' and save the output into 'signer_data'
and I have a 'did document' named 'didDocument' in 'signer_data'
and I rename 'didDocument' to 'signer_did_document'
and I have a 'string dictionary' named 'didDocumentMetadata' in 'signer_data'
and I rename 'didDocumentMetadata' to 'signer_metadata'

# request did document
Given I read the content of 'request_path' and save the output into 'request_data'
and I have a 'string dictionary' named 'request_data'

# keys
Given I have a 'string array' named 'api_blockchains'
and I have a 'string' named '-'
and I have a 'string' named '.'
and I have a 'integer' named 'expiration_time'
and I have a 'string' named 'commit_message_prefix_broadcast'
and I have a 'string' named 'on'

# data
Given I have a 'string' named 'broadcast_id'
and I have a 'eddsa signature'
@@ -38,6 +26,14 @@ and I have a 'integer' named 'timestamp'
and I have a 'string' named 'author'
and I have a 'string' named 'commit message'

# keys
Given I have a 'string array' named 'api_blockchains'
and I have a 'string' named '-'
and I have a 'string' named '.'
and I have a 'integer' named 'expiration_time'
and I have a 'string' named 'commit_message_prefix_broadcast'
and I have a 'string' named 'on'

# verify timestamp
When I create the result of 'broadcast_timestamp' - 'timestamp'
and I verify number 'result' is less or equal than 'expiration_time'
@@ -59,11 +55,11 @@ and I verify the 'json escaped string' has a eddsa signature in 'eddsa signature

# extract data to be broadcast
When I create the 'string dictionary' named 'broadcast_data'
When I create the copy of '@context' in 'request_data'
When I create the copy of '@context' from 'request_data'
and I move the 'copy' to '@context' in 'broadcast_data'
When I create the copy of 'didDocument' in 'request_data'
When I create the copy of 'didDocument' from 'request_data'
and I move the 'copy' to 'didDocument' in 'broadcast_data'
When I create the copy of 'didDocumentMetadata' in 'request_data'
When I create the copy of 'didDocumentMetadata' from 'request_data'
and I rename 'copy' to 'didDocumentMetadata_copy'
and I create the 'string dictionary' named 'didDocumentMetadata'
and I pickup from path 'didDocumentMetadata_copy.created'
@@ -78,11 +74,11 @@ EndIf
# blockchains txids
## compose the blockchain api endpoint (dash is used in its name)
When I create the array by splitting 'base_url' at '-'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I remove 'array'
and I rename 'copy' to 'blockchain.chain'
and I create the array by splitting 'blockchain.chain' at '.'
and I create the copy of element '1' in array 'array'
and I create the copy of element '1' from array 'array'
and I remove 'array'
and I rename 'copy' to 'blockchain'
## match the blockchain is supported by api
49 changes: 22 additions & 27 deletions api/v1/common/pubkeys-broadcast-3-evm.zen
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
Rule caller restroom-mw
Rule unknown ignore
Scenario 'ethereum': keys

# keyring and pks
# restroom statements
Given I read the content of 'secrets/blockchains_client.json'
Given my name is in a 'string' named 'identity'
Given I have my 'keyring'
Given I have the 'ethereum address'

# http_request.base_url
Given I read the http request
Given I have a 'string' named 'base_url' inside 'http_request'

# evm endpoint
Given I have a ethereum endpoint named 'evm_endpoint'
and I read the http request
and I have a ethereum endpoint named 'evm_endpoint'
and I read the ethereum nonce for 'ethereum_address'
and I read the ethereum suggested gas price

# nonce
Given I read the ethereum nonce for 'ethereum_address'
Given I have a 'ethereum nonce'
# restroom data
Given my name is in a 'string' named 'identity'
and I have my 'keyring'
and I have the 'ethereum address'
and I have a 'string' named 'base_url' inside 'http_request'
and I have a 'ethereum nonce'
and I have a 'gas_price'

# gas price
Given I read the ethereum suggested gas price
Given I have a 'gas_price'
# data
Given I have a 'string dictionary' named 'request_data'
and I have a 'string dictionary' named 'broadcast_data'
and I have a 'string dictionary' named 'commit'
and I have a 'string' named 'request_path'
and I have a 'string' named 'log_msg'
and I have a 'gas_limit'
and I have a 'string' named 'blockchain'

# keys
Given I have a 'ethereum address' named 'storage contract'
Given I have a 'string' named 'chainid'

# data
Given I have a 'string dictionary' named 'request_data'
Given I have a 'string dictionary' named 'broadcast_data'
Given I have a 'string dictionary' named 'commit'
Given I have a 'string' named 'request_path'
Given I have a 'string' named 'log_msg'
Given I have a 'gas_limit'
Given I have a 'string' named 'blockchain'

# store the hash to point
When I create the hash to point 'ecp' of 'broadcast_data'

@@ -53,4 +47,5 @@ Then print the 'commit'
Then print the 'request_data'
Then print the 'blockchain'

# restroom statements
Then I ask ethereum to broadcast the 'signed_ethereum_transaction' and save the transaction id in 'txid'
23 changes: 12 additions & 11 deletions api/v1/common/pubkeys-broadcast-4-store.zen
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Rule caller restroom-mw
Rule unknown ignore

# verify git
# restroom statements
Given I verify the path 'data/' is a git repository
and I read the http request

# http_request.base_url
Given I read the http request
# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'

# data
Given I have a 'string dictionary' named 'request_data'
Given I have a 'string dictionary' named 'commit'
Given I have a 'string' named 'request path'
Given I have a 'string' named 'log_msg'
Given I have a 'string' named 'txid'
Given I have a 'string' named 'blockchain'
and I have a 'string dictionary' named 'commit'
and I have a 'string' named 'request path'
and I have a 'string' named 'log_msg'
and I have a 'string' named 'txid'
and I have a 'string' named 'blockchain'

# verify contract is used inside the chain
When I verify 'base_url' has suffix '.chain'
@@ -41,6 +41,7 @@ Then print the 'request_path'
Then print the 'log_msg'
Then print the 'commit'

# restroom statements
Then store 'request_data' in the file 'request_path'
Then append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
Then make a new commit to the git repository in 'data'
and append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
and make a new commit to the git repository in 'data'
33 changes: 18 additions & 15 deletions api/v1/common/pubkeys-deactivate-1-acl.zen
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
Rule caller restroom-mw
Rule unknown ignore
Rule input encoding base58
Scenario 'ecdh': singature
Scenario 'w3c': did document

# http_request
# restroom statements
Given I read the http request

# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'

# data
Given I have a 'string' named 'deactivate_id'
and I have a 'ecdh signature'
and I have a 'string' named 'id'
and I rename 'id' to 'signer_id'

# constants
# keys
Given I have a 'string dictionary' named 'request_ACL'
and I have a 'string dictionary' named 'signer_ACL'
and I have a 'string dictionary' named 'utility'
@@ -32,9 +35,9 @@ and I set 'request_path' to 'data/dyne/' as 'string'

# signer_parts
When I create the array by splitting 'signer_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'signer_idspec'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'signer_idpk'
and I remove 'array'
and I create the array by splitting 'signer_idspec' at '_'
@@ -47,9 +50,9 @@ and I remove 'array'

# request_parts
When I create the array by splitting 'deactivate_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'request_idspec'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'request_idpk'
and I copy 'request_idspec' to 'commit message'
and I remove 'array'
@@ -62,12 +65,12 @@ EndForeach
When I append 'request_idpk' to 'request_path'
# request domain
When I rename 'array' to 'request_split_by_underscore'
and I verify the length of 'request_split_by_underscore' is less or equal than '2'
and I create the copy of element '1' in array 'request_split_by_underscore'
and I verify the size of 'request_split_by_underscore' is less or equal than '2'
and I create the copy of element '1' from array 'request_split_by_underscore'
and I rename 'copy' to 'request_domain.request_ctx'
and I create the array by splitting 'request_domain.request_ctx' at '.'
and I verify the length of 'array' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I verify the size of 'array' is less or equal than '2'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'request_domain'
and I remove 'array'
# check request_domain is allowed
@@ -84,7 +87,7 @@ EndIf
When I create the array by splitting 'signer_idspec' at '_'
and I create the size of 'array'
and I verify number 'size' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'signer_domain.signer_ctx'

# no underscore => has to be admin
@@ -106,7 +109,7 @@ and I verify 'self_allowed' is not equal to 'true' in 'utility'
When I remove 'exit_code'
and I set 'exit_code' to 'check signer permissions' as 'string'

When I create the copy of element '2' in array 'array'
When I create the copy of element '2' from array 'array'
and I verify the 'copy' is found in 'signer_ACL'
and I remove 'copy'

@@ -160,11 +163,11 @@ and I remove 'size'

## request ACL
# TODO: replace with equal (not yet implemented)
If I verify the length of 'request_split_by_underscore' is more or equal than '2'
If I verify the size of 'request_split_by_underscore' is more or equal than '2'
When I remove 'exit_code'
and I set 'exit_code' to 'check request permissions' as 'string'

When I create the copy of element '2' in array 'request_split_by_underscore'
When I create the copy of element '2' from array 'request_split_by_underscore'
and I verify the 'copy' is found in 'request_ACL'

When I remove 'exit_code'
32 changes: 14 additions & 18 deletions api/v1/common/pubkeys-deactivate-2-checks.zen
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
Rule caller restroom-mw
Rule unknown ignore
Scenario 'ecdh': verify signature
Scenario 'w3c': proof

# http_request.base_url
# restroom statements
Given I read the http request
Given I have a 'string' named 'base_url' inside 'http_request'

# verify git repo
Given I verify the path 'data/' is a git repository
and I verify the path 'data/' is a git repository
and I fetch the local timestamp and store it into 'deactivate_timestamp'
and I read the content of 'signer_path' and save the output into 'signer_data'
and I read the content of 'request_path' and save the output into 'request_data'

# timestamp
Given I fetch the local timestamp and store it into 'deactivate_timestamp'
# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'
and I have a 'integer' named 'deactivate_timestamp'

# signer did document
Given I read the content of 'signer_path' and save the output into 'signer_data'
and I have a 'did document' named 'didDocument' in 'signer_data'
and I rename 'didDocument' to 'signer_did_document'
and I have a 'string dictionary' named 'didDocumentMetadata' in 'signer_data'
and I rename 'didDocumentMetadata' to 'signer_metadata'

# request did document
Given I read the content of 'request_path' and save the output into 'request_data'
and I have a 'string dictionary' named 'request_data'
and I have a 'string dictionary' named 'didDocumentMetadata' in 'request_data'
and I rename 'didDocumentMetadata' to 'request_metadata'

# keys
Given I have a 'string' named 'commit_message_prefix_deactivate'
# data
Given I have a 'string' named 'deactivate_id'
and I have a 'ecdh signature'
@@ -36,6 +28,9 @@ and I have a 'string' named 'signer_id'
and I have a 'string' named 'author'
and I have a 'string' named 'commit message'

# keys
Given I have a 'string' named 'commit_message_prefix_deactivate'

# verify contract is used inside the chain
When I verify 'base_url' has suffix 'pubkeys-deactivate.chain'

@@ -81,6 +76,7 @@ and print the 'request_path'
and print the 'log_msg'
and print the 'commit'

# restroom statements
Then store 'result' in the file 'request_path'
Then append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
Then make a new commit to the git repository in 'data'
and append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
and make a new commit to the git repository in 'data'
31 changes: 17 additions & 14 deletions api/v1/common/pubkeys-update-1-acl.zen
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Rule caller restroom-mw
Rule unknown ignore
Rule input encoding base58
Scenario 'ecdh': singature
Scenario 'eddsa': signature
Scenario 'w3c': did document

# http_request
# restroom statements
Given I read the http request

# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'

# data
Given I have a 'did document' named 'did document'
and I rename 'did_document' to 'request_did_document'
and I have a 'ecdh signature'
@@ -16,7 +19,7 @@ and I have a 'eddsa signature'
and I have a 'string' named 'id'
and I rename 'id' to 'signer_id'

# constants
# keys
Given I have a 'string dictionary' named 'request_ACL'
and I have a 'string dictionary' named 'signer_ACL'
and I have a 'string dictionary' named 'utility'
@@ -36,9 +39,9 @@ and I set 'request_path' to 'data/dyne/' as 'string'

# signer_parts
When I create the array by splitting 'signer_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'signer_idspec'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'signer_idpk'
and I remove 'array'
and I create the array by splitting 'signer_idspec' at '_'
@@ -53,10 +56,10 @@ and I remove 'array'
When I pickup from path 'request_did_document.id'
and I rename the 'id' to 'request_id'
and I create the array by splitting 'request_id' at ':'
and I create the copy of element '3' in array 'array'
and I create the copy of element '3' from array 'array'
and I rename the 'copy' to 'request_idspec'
and I copy 'request_idspec' to 'commit message'
and I create the copy of element '4' in array 'array'
and I create the copy of element '4' from array 'array'
and I rename the 'copy' to 'request_idpk'
and I remove 'array'
When I create the array by splitting 'request_idspec' at '_'
@@ -69,11 +72,11 @@ When I append 'request_idpk' to 'request_path'
# request domain
When I rename 'array' to 'request_split_by_underscore'
and I verify the size of 'request_split_by_underscore' is less or equal than '2'
and I create the copy of element '1' in array 'request_split_by_underscore'
and I create the copy of element '1' from array 'request_split_by_underscore'
and I rename 'copy' to 'request_domain.request_ctx'
and I create the array by splitting 'request_domain.request_ctx' at '.'
and I verify the length of 'array' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I verify the size of 'array' is less or equal than '2'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'request_domain'
and I remove 'array'
# check request_domain is allowed
@@ -90,7 +93,7 @@ EndIf
When I create the array by splitting 'signer_idspec' at '_'
and I create the size of 'array'
and I verify number 'size' is less or equal than '2'
and I create the copy of element '1' in array 'array'
and I create the copy of element '1' from array 'array'
and I rename 'copy' to 'signer_domain.signer_ctx'

# no underscore => has to be admin
@@ -112,7 +115,7 @@ and I verify 'self_allowed' is not equal to 'true' in 'utility'
When I remove 'exit_code'
and I set 'exit_code' to 'check signer permissions' as 'string'

When I create the copy of element '2' in array 'array'
When I create the copy of element '2' from array 'array'
and I verify the 'copy' is found in 'signer_ACL'
and I remove 'copy'

@@ -166,11 +169,11 @@ and I remove 'size'

## request ACL
# TODO: replace with equal (not yet implemented)
If I verify the length of 'request_split_by_underscore' is more or equal than '2'
If I verify the size of 'request_split_by_underscore' is more or equal than '2'
When I remove 'exit_code'
and I set 'exit_code' to 'check request permissions' as 'string'

When I create the copy of element '2' in array 'request_split_by_underscore'
When I create the copy of element '2' from array 'request_split_by_underscore'
and I verify the 'copy' is found in 'request_ACL'

When I remove 'exit_code'
50 changes: 23 additions & 27 deletions api/v1/common/pubkeys-update-2-checks.zen
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
Rule caller restroom-mw
Rule unknown ignore
Scenario 'ecdh': verify signature
Scenario 'eddsa': verify signature
Scenario 'w3c': proof

# http_request.base_url
# restroom statements
Given I read the http request
Given I have a 'string' named 'base_url' inside 'http_request'

# verify git repo
Given I verify the path 'data/' is a git repository
and I verify the path 'data/' is a git repository
and I fetch the local timestamp and store it into 'update_timestamp'
and I read the content of 'signer_path' and save the output into 'signer_data'
and I read the content of 'request_path' and save the output into 'request_data'

# timestamp
Given I fetch the local timestamp and store it into 'update_timestamp'
# restroom data
Given I have a 'string' named 'base_url' inside 'http_request'
and I have a 'integer' named 'update_timestamp'
and I have a 'did document' named 'didDocument' in 'signer_data'
and I rename 'didDocument' to 'signer_did_document'
and I have a 'string dictionary' named 'didDocumentMetadata' in 'signer_data'
and I rename 'didDocumentMetadata' to 'signer_metadata'
and I have a 'string dictionary' named 'didDocumentMetadata' in 'request_data'
and I rename 'didDocumentMetadata' to 'request_metadata'

# signer did document
Given I read the content of 'signer_path' and save the output into 'signer_data'
Given I have a 'did document' named 'didDocument' in 'signer_data'
Given I rename 'didDocument' to 'signer_did_document'
Given I have a 'string dictionary' named 'didDocumentMetadata' in 'signer_data'
Given I rename 'didDocumentMetadata' to 'signer_metadata'

# request did document
Given I read the content of 'request_path' and save the output into 'request_data'
Given I have a 'string dictionary' named 'didDocumentMetadata' in 'request_data'
Given I rename 'didDocumentMetadata' to 'request_metadata'

# key
Given I have a 'string dictionary' named 'proof'
and I have a 'string' named '@context'
and I have a 'integer' named 'expiration_time'
and I have a 'string' named 'commit_message_prefix_update'
# data
Given I have a 'did document' named 'request did document'
and I have a 'ecdh signature'
@@ -41,6 +30,12 @@ and I have a 'string' named 'signer_id'
and I have a 'string' named 'author'
and I have a 'string' named 'commit message'

# key
Given I have a 'string dictionary' named 'proof'
and I have a 'string' named '@context'
and I have a 'integer' named 'expiration_time'
and I have a 'string' named 'commit_message_prefix_update'

# verify contract is used inside the chain
When I verify 'base_url' has suffix 'pubkeys-update.chain'

@@ -119,6 +114,7 @@ and print the 'request_path'
and print the 'log_msg'
and print the 'commit'

# restroom statements
Then store 'result' in the file 'request_path'
Then append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
Then make a new commit to the git repository in 'data'
and append the string 'log_msg' to the logfile in 'api_dyne_v1.log'
and make a new commit to the git repository in 'data'
6 changes: 3 additions & 3 deletions bindings/javascript/package-lock.json
2 changes: 1 addition & 1 deletion client/v1/admin/didgen.zen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Rule caller restroom-mw
Rule unknown ignore
rule input encoding base58
rule output encoding base58

6 changes: 3 additions & 3 deletions client/v1/broadcast-request.zen
Original file line number Diff line number Diff line change
@@ -33,10 +33,10 @@ and I append the 'base58' of 'eddsa public key' to 'id'
When I create the 'string dictionary' named 'signed_by_eddsa'
and I copy 'broadcast_id' in 'signed_by_eddsa'
and I copy 'timestamp' in 'signed_by_eddsa'
and I create the json of 'signed_by_eddsa'
and I create the eddsa signature of 'json'
and I create the json escaped string of 'signed_by_eddsa'
and I create the eddsa signature of 'json_escaped_string'

Then print the 'broadcast_id'
Then print the 'id'
Then print the 'timestamp'
Then print the 'eddsa signature'
Then print the 'eddsa signature'
2 changes: 1 addition & 1 deletion client/v1/ifacer/pubkeys-request-signed.zen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Rule caller restroom-mw
#Rule unknown ignore
rule input encoding base58
rule output encoding base58

2 changes: 1 addition & 1 deletion client/v1/ifacer/pubkeys-request-unsigned.zen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Rule caller restroom-mw
#Rule unknown ignore
rule input encoding base58
rule output encoding base58

2 changes: 1 addition & 1 deletion client/v1/pubkeys-request-signed.zen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Rule caller restroom-mw
#Rule unknown ignore
rule input encoding base58
rule output encoding base58

2 changes: 1 addition & 1 deletion client/v1/pubkeys-request-unsigned.zen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Rule caller restroom-mw
#Rule unknown ignore
rule input encoding base58
rule output encoding base58

2 changes: 1 addition & 1 deletion client/v1/pubkeys-sign.zen
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ and print the 'eddsa signature'
EndIf

If I verify 'deactivate_id' is found in 'request'
When I copy the 'deactivate_id' in 'request' to 'json escaped string'
When I copy the 'deactivate_id' from 'request' to 'json escaped string'
Then print the 'deactivate_id' from 'request'
EndIf

24 changes: 20 additions & 4 deletions restroom/package-lock.json
2 changes: 1 addition & 1 deletion restroom/package.json
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
"sqlite3": "^5.0.0",
"swagger-ui-express": "^4.1.5",
"web3": "1.7.0",
"zenroom": "^3.0.0"
"zenroom": "^4.0.0"
},
"devDependencies": {
"ava": "^5.1.0",
15 changes: 11 additions & 4 deletions restroom/yarn.lock
Original file line number Diff line number Diff line change
@@ -5295,6 +5295,11 @@ yargs@^17.6.2:
y18n "^5.0.5"
yargs-parser "^21.1.1"

yarn@^1.22.19:
version "1.22.19"
resolved "https://registry.npmjs.org/yarn/-/yarn-1.22.19.tgz"
integrity sha512-/0V5q0WbslqnwP91tirOvldvYISzaqhClxzyUKXYxs07yUILIs5jx/k6CFe8bvKSkds5w+eiOqta39Wk3WxdcQ==

yauzl@^2.10.0:
version "2.10.0"
resolved "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz"
@@ -5308,7 +5313,9 @@ yocto-queue@^1.0.0:
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz"
integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==

zenroom@^3.0.0:
version "3.3.1"
resolved "https://registry.npmjs.org/zenroom/-/zenroom-3.3.1.tgz"
integrity sha512-zIT8rLpt9cifAVt0OIxNYxE0RCgdSv5dt1yxpjmPHpH1ftYHOjZ0p3QuwOWv5gvDuL2/cw3YKvr5a2iQeQvxoQ==
zenroom@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/zenroom/-/zenroom-4.0.0.tgz"
integrity sha512-RRRwdJ7k4QKTB7XCLpmHpU9fPBwxjIX69SUiJVvwq1AX3xSUCFQLHOArMZu8PN7lYM5B4dwiihkiE9ZCR3YfNA==
dependencies:
yarn "^1.22.19"