├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── config.yml │ └── feature-request.yaml ├── dependabot.yml ├── linters │ ├── .commitlint.rules.js │ ├── .eslintrc.json │ ├── .golangci.yaml │ ├── .hadolint.yaml │ ├── .markdown-lint.yml │ ├── .openapirc.yaml │ └── mlc_config.json └── workflows │ ├── build.yml │ ├── cleanup-actions.yml │ ├── cleanup-cache.yml │ ├── codeql.yml │ ├── dispatch.yml │ ├── lint.yml │ ├── pull-request.yml │ ├── release.yml │ ├── staging.yml │ └── test.yml ├── .gitignore ├── .goreleaser.yml ├── .releaserc.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── Makefile ├── NOTICE.md ├── README.md ├── SECURITY.md ├── docker ├── Dockerfile └── docker-compose.yml ├── docs ├── docs.go ├── swagger.json └── swagger.yaml ├── go.mod ├── go.sum ├── main.go ├── migrations ├── did.go ├── indy_style.go └── uuid.go ├── package-lock.json ├── package.json ├── services ├── context.go ├── diddoc │ ├── diddoc_all_version_metadata.go │ ├── diddoc_fragment.go │ ├── diddoc_full.go │ ├── diddoc_metadata.go │ ├── diddoc_only.go │ ├── diddoc_query.go │ ├── diddoc_resource_dereferencing.go │ ├── diddoc_version.go │ ├── diddoc_version_metadata.go │ ├── echo_handlers.go │ ├── queries │ │ ├── base_handler.go │ │ ├── diddoc │ │ │ ├── did_doc_helpers.go │ │ │ ├── did_doc_metadata_handler.go │ │ │ ├── did_doc_resolve_handler.go │ │ │ ├── did_query_all_versions_handler.go │ │ │ ├── did_query_relative_ref_handler.go │ │ │ ├── did_query_service_handler.go │ │ │ ├── did_query_transform_key_handler.go │ │ │ ├── did_query_version_id_handler.go │ │ │ ├── did_query_version_time_handler.go │ │ │ └── utils.go │ │ ├── resources │ │ │ ├── resource_checksum_handler.go │ │ │ ├── resource_helper_handler.go │ │ │ ├── resource_query_collection_id_handler.go │ │ │ ├── resource_query_handler.go │ │ │ ├── resource_query_id_handler.go │ │ │ ├── resource_query_metadata_handler.go │ │ │ ├── resource_query_name_handler.go │ │ │ ├── resource_query_type_handler.go │ │ │ ├── resource_query_version_handler.go │ │ │ ├── resource_query_version_time_handler.go │ │ │ └── resource_validation_handler.go │ │ └── stop_handler.go │ └── routes.go ├── diddoc_service.go ├── error_handler.go ├── helpers.go ├── ledger_service.go ├── request_service_base.go ├── request_service_interface.go ├── resource │ ├── echo_handlers.go │ ├── resource_data_dereferencing.go │ ├── resource_data_with_metadata_dereferencing.go │ ├── resource_metadata_dereferencing.go │ └── routes.go └── resource_dereference_service.go ├── tests ├── constants │ ├── common.go │ └── constants.go ├── docker-compose-testing.yml ├── integration │ └── rest │ │ ├── did_redirect_test.go │ │ ├── diddoc │ │ ├── diddoc │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ ├── fragment │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ ├── metadata │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ ├── query │ │ │ ├── common_negative_test.go │ │ │ ├── common_positive_test.go │ │ │ ├── metadata │ │ │ │ ├── negative_test.go │ │ │ │ ├── positive_test.go │ │ │ │ └── suite_test.go │ │ │ ├── service │ │ │ │ ├── negative_test.go │ │ │ │ ├── positive_test.go │ │ │ │ └── suite_test.go │ │ │ ├── suite_test.go │ │ │ ├── transform_key │ │ │ │ ├── negative_test.go │ │ │ │ ├── positive_test.go │ │ │ │ └── suite_test.go │ │ │ ├── version_id │ │ │ │ ├── negative_test.go │ │ │ │ ├── positive_test.go │ │ │ │ └── suite_test.go │ │ │ └── version_time │ │ │ │ ├── negative_test.go │ │ │ │ ├── positive_test.go │ │ │ │ └── suite_test.go │ │ ├── version │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ └── versions │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ ├── resource │ │ ├── collection │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ ├── data │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ ├── data_with_metadata │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ ├── metadata │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ └── query │ │ │ ├── common_positive_test.go │ │ │ ├── resource_checksum │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ ├── resource_collection_id │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ ├── resource_id │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ ├── resource_metadata │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ ├── resource_name │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ ├── resource_type │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ ├── resource_version │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ ├── resource_version_time │ │ │ ├── negative_test.go │ │ │ ├── positive_test.go │ │ │ └── suite_test.go │ │ │ └── suite_test.go │ │ ├── support_query_negative_test.go │ │ ├── test_suite_test.go │ │ ├── test_utils.go │ │ └── testdata │ │ ├── collection_of_resources │ │ ├── metadata.json │ │ ├── metadata_32_indy_did.json │ │ ├── metadata_did_json.json │ │ └── metadata_did_ld.json │ │ ├── diddoc │ │ ├── diddoc_did_json.json │ │ ├── diddoc_escaped_am.json │ │ ├── diddoc_indy_mainnet_did.json │ │ ├── diddoc_indy_mainnet_did_ld.json │ │ ├── diddoc_indy_testnet_did.json │ │ ├── diddoc_multiservice_testnet_did.json │ │ ├── diddoc_old_16_indy_testnet_did.json │ │ ├── diddoc_old_32_indy_testnet_did.json │ │ ├── diddoc_uuid_mainnet_did.json │ │ ├── diddoc_uuid_testnet_did.json │ │ ├── diddoc_uuid_testnet_several_versions.json │ │ ├── diddoc_uuid_testnet_several_versions_between.json │ │ └── diddoc_version_did_ld.json │ │ ├── diddoc_fragment │ │ ├── service_endpoint_did_fragment.json │ │ ├── service_endpoint_did_fragment_did_json.json │ │ ├── verification_method_did_fragment.json │ │ ├── verification_method_did_fragment_did_json.json │ │ ├── verification_method_did_fragment_json_ld.json │ │ ├── verification_method_old_16_did_fragment.json │ │ └── verification_method_old_32_did_fragment.json │ │ ├── diddoc_version │ │ ├── diddoc_version_did_json.json │ │ ├── diddoc_version_indy_mainnet_did.json │ │ ├── diddoc_version_indy_testnet_did.json │ │ ├── diddoc_version_old_16_indy_testnet_did.json │ │ ├── diddoc_version_old_32_indy_testnet_did.json │ │ ├── diddoc_version_uuid_mainnet_did.json │ │ ├── diddoc_version_uuid_testnet_did.json │ │ └── diddoc_version_uuid_testnet_did_ld.json │ │ ├── diddoc_version_metadata │ │ ├── diddoc_did_json.json │ │ ├── diddoc_indy_mainnet_did.json │ │ ├── diddoc_indy_testnet_did.json │ │ ├── diddoc_old_16_indy_testnet_did.json │ │ ├── diddoc_old_32_indy_testnet_did.json │ │ ├── diddoc_uuid_mainnet_did.json │ │ └── diddoc_uuid_testnet_did.json │ │ ├── diddoc_versions │ │ ├── diddoc_versions.json │ │ ├── diddoc_versions_did_json.json │ │ ├── diddoc_versions_old_16_indy_did.json │ │ └── diddoc_versions_old_32_indy_did.json │ │ ├── query │ │ ├── checksum │ │ │ ├── resource_32_indy_did_checksum.json │ │ │ └── resource_checksum.json │ │ ├── collection_id │ │ │ ├── metadata_32_indy_did.json │ │ │ └── metadata_did.json │ │ ├── diddoc │ │ │ ├── diddoc_version_16_old_indy_did.json │ │ │ ├── diddoc_version_32_old_indy_did.json │ │ │ └── diddoc_version_did.json │ │ ├── diddoc_common │ │ │ ├── metadata │ │ │ │ ├── version_id.json │ │ │ │ ├── version_id_&_version_time.json │ │ │ │ └── version_time.json │ │ │ └── version_id │ │ │ │ ├── transform_key.json │ │ │ │ ├── version_time.json │ │ │ │ └── version_time_&_transform_key.json │ │ ├── metadata │ │ │ ├── diddoc_16_old_indy_did.json │ │ │ ├── diddoc_32_old_indy_did.json │ │ │ ├── diddoc_did.json │ │ │ └── diddoc_metadata_did.json │ │ ├── resource_common │ │ │ ├── resource_combination_of_queries_1.json │ │ │ └── resource_combination_of_queries_2.json │ │ ├── resource_id │ │ │ ├── resource.json │ │ │ └── resource_32_indy_did.json │ │ ├── resource_metadata │ │ │ ├── metadata.json │ │ │ ├── metadata_32_indy_did.json │ │ │ ├── metadata_did_res.json │ │ │ ├── metadata_false.json │ │ │ ├── metadata_false_ld.json │ │ │ └── metadata_ld.json │ │ ├── resource_name │ │ │ ├── resource.json │ │ │ └── resource_32_indy_did.json │ │ ├── resource_type │ │ │ ├── resource.json │ │ │ └── resource_32_indy_did.json │ │ ├── resource_version │ │ │ └── resource.json │ │ ├── resource_version_time │ │ │ ├── resource.json │ │ │ ├── resource_32_indy_did.json │ │ │ └── resource_sorted_desc.json │ │ ├── transform_key │ │ │ ├── diddoc_ed25519_2018_to_ed25519_2018.json │ │ │ ├── diddoc_ed25519_2018_to_ed25519_2020.json │ │ │ ├── diddoc_ed25519_2018_to_jwk_2020.json │ │ │ ├── diddoc_ed25519_2020_to_ed25519_2018.json │ │ │ ├── diddoc_ed25519_2020_to_ed25519_2020.json │ │ │ ├── diddoc_ed25519_2020_to_jwk_2020.json │ │ │ ├── diddoc_jwk_2020_to_ed25519_2018.json │ │ │ ├── diddoc_jwk_2020_to_ed25519_2020.json │ │ │ ├── diddoc_jwk_2020_to_jwk_2020.json │ │ │ ├── diddoc_old_16_indy_jwk_2020_to_ed25519_2018.json │ │ │ ├── diddoc_old_16_indy_jwk_2020_to_ed25519_2020.json │ │ │ ├── diddoc_old_16_indy_jwk_2020_to_jwk_2020.json │ │ │ ├── diddoc_old_32_indy_ed255519_2020_to_ed25519_2018.json │ │ │ ├── diddoc_old_32_indy_ed255519_2020_to_ed25519_2020.json │ │ │ ├── diddoc_old_32_indy_ed255519_2020_to_jwk_2020.json │ │ │ ├── diddoc_transform_key_and_version_id.json │ │ │ └── diddoc_transform_key_version_time.json │ │ └── version_time │ │ │ ├── diddoc_version_time_16_old_indy_did.json │ │ │ ├── diddoc_version_time_32_old_indy_did.json │ │ │ ├── diddoc_version_time_date_did.json │ │ │ └── diddoc_version_time_did.json │ │ ├── resource_data │ │ ├── resource.json │ │ ├── resource_32_indy_did.json │ │ └── resource_hello_world.txt │ │ ├── resource_data_with_metadata │ │ ├── resource.json │ │ └── resource_image.json │ │ └── resource_metadata │ │ ├── metadata.json │ │ ├── metadata_32_indy_did.json │ │ ├── metadata_did_json.json │ │ └── metadata_did_ld.json └── unit │ ├── diddoc │ ├── common │ │ ├── dereferencing_content_stream_test.go │ │ ├── dereferencing_metadata_test.go │ │ ├── did_doc_metadata_list_test.go │ │ ├── did_doc_metadata_test.go │ │ ├── did_doc_resolve_service_test.go │ │ ├── diddoc_dereference_service_test.go │ │ ├── diddoc_fragment_service_test.go │ │ ├── serve_test.go │ │ ├── suite_test.go │ │ └── supported_queries_test.go │ ├── ledger │ │ ├── query_all_did_doc_versions_ledger_service_test.go │ │ ├── query_did_doc_ledger_service_test.go │ │ └── suite_test.go │ └── request │ │ ├── common_negative_metadata_test.go │ │ ├── common_positive_metadata_test.go │ │ ├── diddoc_negative_cases_test.go │ │ ├── diddoc_positive_cases_test.go │ │ ├── diddoc_resolution_query_positive_test.go │ │ ├── diddoc_service_params_test.go │ │ ├── diddoc_transform_key_test.go │ │ ├── request_service_dereference_collection_resources_test.go │ │ ├── request_service_resolve_did_doc_test.go │ │ ├── resource_negative_data_test.go │ │ ├── resource_negative_metadata_test.go │ │ ├── resources_positive_cases_metadata_test.go │ │ ├── resources_positive_cases_test.go │ │ ├── suite_test.go │ │ └── types_test.go │ ├── resource │ ├── common │ │ ├── resource_dereference_metadata_service_test.go │ │ ├── resource_dereference_resource_data__with_metadata_test.go │ │ ├── resource_dereference_resource_data_test.go │ │ └── suite_test.go │ ├── ledger │ │ ├── query_collection_resource_ledger_service_test.go │ │ ├── query_resource_ledger_service_test.go │ │ └── suite_test.go │ └── request │ │ ├── request_service_dereference_resource_data_test.go │ │ ├── request_service_dereference_resource_metadata_test.go │ │ └── suite_test.go │ └── test_utils.go ├── types ├── config.go ├── constants.go ├── dereferecing_metadata.go ├── dereferenced_did_versions_list.go ├── dereferencing_content_stream.go ├── did_dereferencing.go ├── did_doc.go ├── did_doc_metadata_list.go ├── did_service.go ├── errors.go ├── helper.go ├── interfaces.go ├── resolution_diddoc_metadata.go ├── resolution_metadata.go ├── resource_data.go ├── resource_dereferencing.go ├── resource_metadata.go └── supported_queries.go └── utils ├── did.go ├── did_url.go ├── encoding.go ├── id.go ├── parse_time.go ├── skipper_gzip.go ├── str.go ├── uuid.go ├── verification_key_generator.go └── verification_key_parser.go /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .github 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | 3 | contact_links: 4 | - name: System Status 5 | url: https://status.cheqd.net 6 | about: System status reporting tool for cheqd services 7 | 8 | - name: Technical Documentation 9 | url: https://docs.cheqd.io 10 | about: Technical Documentation for cheqd projects 11 | 12 | - name: Community Slack 13 | url: http://cheqd.link/join-cheqd-slack 14 | about: Community Slack for Q&A and discussions 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yaml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Request a new feature 3 | title: "[feature]: " 4 | labels: ["feature-request"] 5 | body: 6 | - type: textarea 7 | id: feature-info 8 | attributes: 9 | label: What is the feature you'd like to see? 10 | description: Also tell what prompted this idea? 11 | placeholder: I would like to see... 12 | validations: 13 | required: true 14 | - type: textarea 15 | id: examples 16 | attributes: 17 | label: Are there any examples of where similar features are available? 18 | description: Feel free to provide any links, screenshots, mockups etc that would help illustrate this idea better. 19 | placeholder: An example of this feature is... 20 | - type: checkboxes 21 | id: terms 22 | attributes: 23 | label: Code of Conduct 24 | description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/cheqd/.github/blob/main/CODE_OF_CONDUCT.md) 25 | options: 26 | - label: I agree to follow this project's Code of Conduct 27 | required: true 28 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | ################################# 2 | # GitHub Dependabot Config info # 3 | ################################# 4 | 5 | version: 2 6 | updates: 7 | 8 | # Maintain dependencies for GitHub Actions 9 | - package-ecosystem: "github-actions" 10 | target-branch: "develop" 11 | directory: "/" 12 | schedule: 13 | interval: "weekly" 14 | ignore: 15 | - dependency-name: "*" 16 | update-types: 17 | - version-update:semver-patch 18 | 19 | # Maintain dependencies for NPM 20 | - package-ecosystem: "npm" 21 | target-branch: "develop" 22 | directory: "/" 23 | schedule: 24 | interval: "weekly" 25 | ignore: 26 | - dependency-name: "*" 27 | update-types: 28 | - version-update:semver-patch 29 | 30 | # Maintain dependencies for Docker 31 | - package-ecosystem: "docker" 32 | target-branch: "develop" 33 | directory: "/" 34 | schedule: 35 | interval: "weekly" 36 | ignore: 37 | - dependency-name: "*" 38 | update-types: 39 | - version-update:semver-patch 40 | 41 | # Maintain dependencies for Golang 42 | - package-ecosystem: "gomod" 43 | target-branch: "develop" 44 | directory: "/" 45 | schedule: 46 | interval: "weekly" 47 | 48 | # Maintain dependencies for Terraform 49 | - package-ecosystem: "terraform" 50 | directory: "/" 51 | schedule: 52 | interval: "weekly" 53 | 54 | # Maintain dependencies for Python 55 | - package-ecosystem: "pip" 56 | directory: "/" 57 | schedule: 58 | interval: "weekly" 59 | 60 | # Maintain dependencies for Kotlin 61 | - package-ecosystem: "gradle" 62 | target-branch: "develop" 63 | directory: "/" 64 | schedule: 65 | interval: "weekly" 66 | -------------------------------------------------------------------------------- /.github/linters/.commitlint.rules.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | 'type-case': [2, 'always', 'lower-case'], 4 | 'type-empty': [2, 'never'], 5 | 'type-enum': [ 6 | 2, 7 | 'always', 8 | [ 9 | 'build', 10 | 'chore', 11 | 'ci', 12 | 'docs', 13 | 'feat', 14 | 'fix', 15 | 'perf', 16 | 'refactor', 17 | 'revert', 18 | 'style', 19 | 'test', 20 | ], 21 | ], 22 | 'scope-case': [2, 'always', 'lower-case'], 23 | 'scope-empty': [1, 'never'], 24 | 'subject-case': [ 25 | 2, 26 | 'always', 27 | ['sentence-case'], 28 | ], 29 | 'subject-empty': [1, 'never'], 30 | 'subject-full-stop': [1, 'never', '.'], 31 | 'header-max-length': [2, 'always', 100], 32 | 'body-leading-blank': [1, 'always'], 33 | 'body-max-line-length': [2, 'always', 1000], 34 | 'footer-leading-blank': [1, 'always'], 35 | 'footer-max-line-length': [2, 'always', 100], 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /.github/linters/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true, 4 | "jest/globals": true 5 | }, 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/recommended", 9 | "plugin:prettier/recommended" 10 | ], 11 | "parser": "@typescript-eslint/parser", 12 | "parserOptions": { 13 | "ecmaVersion": 2018, 14 | "sourceType": "module" 15 | }, 16 | "plugins": ["@typescript-eslint", "jest"], 17 | "rules": {} 18 | } 19 | -------------------------------------------------------------------------------- /.github/linters/.golangci.yaml: -------------------------------------------------------------------------------- 1 | run: 2 | timeout: 10m 3 | 4 | 5 | linters: 6 | enable: 7 | - bodyclose 8 | - copyloopvar 9 | - depguard 10 | - dogsled 11 | - errcheck 12 | - goconst 13 | - gocritic 14 | - gofumpt 15 | - goimports 16 | - gosimple 17 | - govet 18 | - ineffassign 19 | - misspell 20 | - nakedret 21 | - nestif 22 | - nolintlint 23 | - staticcheck 24 | # - stylecheck # Disable stylecheck until refactor 25 | - typecheck 26 | - unconvert 27 | - unused 28 | 29 | 30 | linters-settings: 31 | dogsled: 32 | # Checks assignments with too many blank identifiers. 33 | # Default: 2 34 | max-blank-identifiers: 3 35 | 36 | gocritic: 37 | # Which checks should be disabled; can't be combined with 'enabled-checks'. 38 | # See https://go-critic.github.io/overview#checks-overview. 39 | # Default: [] 40 | disabled-checks: 41 | - regexpMust 42 | - badCall # Remove this after CI workflow PR 43 | 44 | gofumpt: 45 | lang-version: "1.24" 46 | 47 | misspell: 48 | ignore-words: 49 | - cheqd 50 | - cheq 51 | - ncheq 52 | 53 | stylecheck: 54 | # Select the Go version to target. 55 | go: "1.23" 56 | # STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks 57 | # Default: ["*"] 58 | checks: ["all"] 59 | # https://staticcheck.io/docs/configuration/options/#dot_import_whitelist 60 | dot-import-whitelist: 61 | - "github.com/cheqd/cheqd-node/x/did/utils" 62 | - "github.com/onsi/gomega" 63 | # https://staticcheck.io/docs/configuration/options/#initialisms 64 | initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] 65 | 66 | depguard: 67 | rules: 68 | main: 69 | files: 70 | - $all 71 | list-mode: lax 72 | allow: "*" 73 | 74 | goconst: 75 | min-occurrences: 5 76 | ignore-tests: true 77 | ignore-strings: "echo '" -------------------------------------------------------------------------------- /.github/linters/.hadolint.yaml: -------------------------------------------------------------------------------- 1 | # Set threshold level (error | warning | info | style | ignore | none) 2 | failure-threshold: warning 3 | 4 | # List of ignored rules 5 | # See list for reference: https://github.com/hadolint/hadolint#rules 6 | ignored: 7 | 8 | # Override default levels for specific rules 9 | override: 10 | error: 11 | warning: 12 | info: 13 | - DL3008 14 | - DL3018 15 | - DL3027 16 | style: 17 | -------------------------------------------------------------------------------- /.github/linters/.openapirc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | ########################## 4 | ########################## 5 | ## OpenAPI Linter rules ## 6 | ########################## 7 | ########################## 8 | 9 | extends: spectral:oas 10 | 11 | rules: 12 | oas2-schema: warn 13 | -------------------------------------------------------------------------------- /.github/linters/mlc_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "aliveStatusCodes": [ 3 | 0, 4 | 200, 5 | 206, 6 | 403, 7 | 501, 8 | 999 9 | ], 10 | "replacementPatterns": [ 11 | { 12 | "pattern": "\" %}", 13 | "replacement": "" 14 | }, 15 | { 16 | "pattern": "" %}", 17 | "replacement": "" 18 | } 19 | ], 20 | "ignorePatterns": [ 21 | { 22 | "pattern": "^https://resolver.cheqd.net/" 23 | }, 24 | { 25 | "pattern": "^https://twitter.com/" 26 | }, 27 | { 28 | "pattern": "^https://dev.uniresolver.io" 29 | } 30 | ], 31 | "retryOn429": true 32 | } 33 | -------------------------------------------------------------------------------- /.github/workflows/cleanup-actions.yml: -------------------------------------------------------------------------------- 1 | name: "Cleanup - Actions" 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | days: 6 | description: 'Retain days' 7 | required: true 8 | type: string 9 | default: "30" 10 | minimum_runs: 11 | description: 'Minimum runs to keep for each workflow' 12 | required: true 13 | type: string 14 | default: "0" 15 | delete_workflow_pattern: 16 | description: 'Name/filename of workflow. Default is all.' 17 | required: false 18 | type: string 19 | delete_workflow_by_state_pattern: 20 | description: 'Remove workflow by state: active, deleted, disabled_fork, disabled_inactivity, disabled_manually' 21 | required: true 22 | default: All 23 | type: choice 24 | options: 25 | - All 26 | - active 27 | - deleted 28 | - disabled_inactivity 29 | - disabled_manually 30 | 31 | jobs: 32 | 33 | delete-runs: 34 | name: "Delete old workflow runs" 35 | runs-on: ubuntu-latest 36 | 37 | steps: 38 | - uses: Mattraks/delete-workflow-runs@v2 39 | with: 40 | token: ${{ github.token }} 41 | repository: ${{ github.repository }} 42 | retain_days: ${{ github.event.inputs.days }} 43 | keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} 44 | delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }} 45 | delete_workflow_by_state_pattern: ${{ github.event.inputs.delete_workflow_by_state_pattern }} 46 | -------------------------------------------------------------------------------- /.github/workflows/cleanup-cache.yml: -------------------------------------------------------------------------------- 1 | name: "Cleanup - Cache" 2 | on: 3 | schedule: 4 | - cron: "0 0 * * 0" 5 | workflow_dispatch: 6 | 7 | jobs: 8 | 9 | delete-caches: 10 | name: "Delete Actions caches" 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: "Wipe Github Actions cache" 15 | uses: easimon/wipe-cache@v2 16 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | on: 3 | push: 4 | branches: 5 | - main 6 | - develop 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.ref }} 9 | cancel-in-progress: true 10 | defaults: 11 | run: 12 | shell: bash 13 | 14 | 15 | jobs: 16 | 17 | codeql-analysis: 18 | name: "CodeQL Analysis" 19 | runs-on: ubuntu-latest 20 | permissions: 21 | actions: read 22 | contents: read 23 | security-events: write 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | with: 28 | fetch-depth: 0 29 | 30 | - uses: actions/setup-go@v5 31 | with: 32 | go-version-file: ./go.mod 33 | cache: true 34 | 35 | - name: Setup CodeQL 36 | uses: github/codeql-action/init@v3 37 | with: 38 | languages: 'go' 39 | queries: security-and-quality 40 | 41 | - name: Build 42 | run: make build 43 | 44 | - name: Perform CodeQL Analysis 45 | uses: github/codeql-action/analyze@v3 46 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.yml: -------------------------------------------------------------------------------- 1 | name: "Workflow Dispatch" 2 | on: push 3 | concurrency: 4 | group: ${{ github.workflow }}-${{ github.ref }} 5 | cancel-in-progress: true 6 | 7 | 8 | jobs: 9 | 10 | call-lint: 11 | name: "Lint" 12 | uses: ./.github/workflows/lint.yml 13 | secrets: inherit 14 | 15 | call-build: 16 | name: "Build" 17 | uses: ./.github/workflows/build.yml 18 | secrets: inherit 19 | 20 | call-test: 21 | name: "Test" 22 | needs: [ call-lint, call-build ] 23 | uses: ./.github/workflows/test.yml 24 | secrets: inherit 25 | 26 | call-staging: 27 | name: "Staging" 28 | needs: call-test 29 | uses: ./.github/workflows/staging.yml 30 | secrets: inherit 31 | 32 | call-release: 33 | name: "Release" 34 | needs: call-test 35 | if: ${{ github.ref_protected == true }} 36 | uses: ./.github/workflows/release.yml 37 | secrets: inherit 38 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: "Lint" 2 | on: 3 | workflow_call: 4 | defaults: 5 | run: 6 | shell: bash 7 | 8 | 9 | jobs: 10 | 11 | md-link-check: 12 | name: "Broken Markdown links" 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Run Markdown link check 19 | uses: tcort/github-action-markdown-link-check@v1 20 | with: 21 | config-file: '.github/linters/mlc_config.json' 22 | use-quiet-mode: 'yes' 23 | 24 | go-lint: 25 | # We can't use VALIDATE_GO from super linter because of this issue: 26 | # https://github.com/github/super-linter/issues/143 27 | name: "Golang Lint" 28 | runs-on: ubuntu-latest 29 | 30 | steps: 31 | - uses: actions/checkout@v4 32 | 33 | - uses: actions/setup-go@v5 34 | with: 35 | go-version-file: ./go.mod 36 | # cache = false cause there is an open issue related to "File exists" error. 37 | # https://github.com/golangci/golangci-lint-action/issues/807 38 | cache: false 39 | 40 | - name: Run golangci-lint 41 | uses: golangci/golangci-lint-action@v6 42 | with: 43 | version: v1.64.6 44 | args: --config .github/linters/.golangci.yaml 45 | 46 | super-lint: 47 | name: "Super Linter" 48 | runs-on: ubuntu-latest 49 | 50 | steps: 51 | - uses: actions/checkout@v4 52 | with: 53 | fetch-depth: 0 # Required to fetch version 54 | 55 | - name: Run Super Linter 56 | uses: super-linter/super-linter/slim@v7 57 | env: 58 | IGNORE_GITIGNORED_FILES: true 59 | DEFAULT_BRANCH: main 60 | LINTER_RULES_PATH: '.github/linters' 61 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 62 | LOG_LEVEL: WARN 63 | VALIDATE_ALL_CODEBASE: true 64 | MULTI_STATUS: true 65 | 66 | VALIDATE_BASH: true 67 | VALIDATE_DOCKERFILE_HADOLINT: true 68 | VALIDATE_ENV: true 69 | VALIDATE_GITHUB_ACTIONS: true 70 | VALIDATE_JSONC: true 71 | VALIDATE_MARKDOWN: true 72 | VALIDATE_OPENAPI: true 73 | VALIDATE_PYTHON_PYLINT: true 74 | VALIDATE_YAML: true 75 | -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: "PR Title Check" 2 | on: 3 | pull_request_target: 4 | branches: 5 | - main 6 | - develop 7 | types: 8 | - opened 9 | - reopened 10 | - edited 11 | - synchronize 12 | - ready_for_review 13 | - review_requested 14 | concurrency: 15 | group: ${{ github.workflow }}-${{ github.ref }} 16 | cancel-in-progress: true 17 | 18 | jobs: 19 | lint-pr: 20 | name: "PR format check" 21 | runs-on: ubuntu-latest 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | 26 | - uses: amannn/action-semantic-pull-request@v5 27 | env: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | with: 30 | # Configure which types are allowed (newline delimited). 31 | # Default: https://github.com/commitizen/conventional-commit-types 32 | types: | 33 | feat 34 | fix 35 | build 36 | chore 37 | ci 38 | docs 39 | feat 40 | fix 41 | perf 42 | refactor 43 | revert 44 | style 45 | test 46 | security 47 | # Configure that a scope must always be provided. 48 | requireScope: false 49 | -------------------------------------------------------------------------------- /.github/workflows/staging.yml: -------------------------------------------------------------------------------- 1 | name: "Deploy" 2 | on: 3 | workflow_call: 4 | defaults: 5 | run: 6 | shell: bash 7 | 8 | jobs: 9 | 10 | deploy-staging: 11 | name: "Staging Deploy" 12 | runs-on: ubuntu-latest 13 | env: 14 | IMAGE_NAME: ${{ github.repository }} 15 | environment: 16 | name: staging 17 | url: https://resolver-staging.cheqd.net 18 | 19 | steps: 20 | - name: Install DigitalOcean CLI 21 | uses: digitalocean/action-doctl@v2 22 | with: 23 | token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} 24 | 25 | - name: Login to DOCR 26 | run: doctl registry login --expiry-seconds 600 27 | 28 | - name: Download Docker image 29 | uses: actions/download-artifact@v4 30 | with: 31 | name: did-resolver-staging 32 | 33 | - name: Load Docker image 34 | run: docker image load --input did-resolver-staging.tar 35 | 36 | - name: Push staging image to DOCR 37 | run: docker image push --all-tags registry.digitalocean.com/${{ env.IMAGE_NAME }} 38 | 39 | release-staging: 40 | name: "Release Staging Docker image" 41 | runs-on: ubuntu-latest 42 | if: ${{ github.ref_name == 'develop' }} 43 | env: 44 | IMAGE_NAME: ${{ github.repository }} 45 | 46 | steps: 47 | - name: Login to GitHub Container Registry 48 | uses: docker/login-action@v3 49 | with: 50 | registry: ghcr.io 51 | username: ${{ github.actor }} 52 | password: ${{ secrets.GITHUB_TOKEN }} 53 | 54 | - name: Download Docker image 55 | uses: actions/download-artifact@v4 56 | with: 57 | name: did-resolver-staging 58 | 59 | - name: Load Docker image 60 | run: docker image load --input did-resolver-staging.tar 61 | 62 | - name: Push image to GitHub Container Registry 63 | run: docker image push --all-tags ghcr.io/${{ env.IMAGE_NAME }} 64 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # Goreleaser configuration file 2 | version: 2 3 | 4 | project_name: did-resolver 5 | 6 | env: 7 | - GO111MODULE=on 8 | 9 | before: 10 | hooks: 11 | - make clean 12 | - make tidy 13 | - make swagger 14 | 15 | builds: 16 | - 17 | env: 18 | - CGO_ENABLED=0 19 | main: ./ 20 | binary: did-resolver 21 | goos: 22 | - linux 23 | - darwin 24 | goarch: 25 | - amd64 26 | - arm64 27 | flags: 28 | - -mod=readonly 29 | - -trimpath 30 | ldflags: 31 | - -s -w 32 | - -X github.com/cheqd/did-resolver.version={{ .Version }} 33 | - -X github.com/cheqd/did-resolver.Commit={{ .Commit }} 34 | 35 | archives: 36 | - id: release-archives 37 | format: tar.gz 38 | wrap_in_directory: false 39 | name_template: "{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}" 40 | files: 41 | - LICENSE 42 | - README.md 43 | 44 | checksum: 45 | algorithm: sha256 46 | 47 | changelog: 48 | use: github-native 49 | sort: asc 50 | groups: 51 | - title: Features 52 | regexp: "^.*feat[(\\w)]*:+.*$" 53 | order: 0 54 | - title: 'Fixes' 55 | regexp: "^.*fix[(\\w)]*:+.*$" 56 | order: 1 57 | - title: 'Performance Improvements' 58 | regexp: "^.*perf[(\\w)]*:+.*$" 59 | order: 2 60 | - title: 'Build Improvements' 61 | regexp: "^.*build[(\\w)]*:+.*$" 62 | order: 3 63 | - title: 'Security' 64 | regexp: "^.*build[(\\w)]*:+.*$" 65 | order: 4 66 | - title: 'Other changes' 67 | order: 999 68 | 69 | 70 | release: 71 | github: 72 | owner: cheqd 73 | name: did-resolver 74 | 75 | draft: false 76 | prerelease: auto 77 | mode: keep-existing 78 | header: | 79 | # Release Notes for {{.ProjectName}} v{{.Version}} 80 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "branches": [ 3 | "main", 4 | { 5 | "name": "develop", 6 | "channel": "beta", 7 | "prerelease": true 8 | } 9 | ], 10 | "tagFormat": "v${version}", 11 | "ci": true, 12 | "preset": "conventionalcommits", 13 | "plugins": [ 14 | [ "@semantic-release/commit-analyzer", 15 | { 16 | "parserOpts": "./.github/linters/.commitlint.rules.js", 17 | "releaseRules": [ 18 | { "breaking": true, "release": "major" }, 19 | { "type": "feat", "release": "minor" }, 20 | { "type": "fix", "release": "patch" }, 21 | { "type": "perf", "release": "patch" }, 22 | { "type": "build", "release": "patch" }, 23 | { "scope": "security", "release": "patch" }, 24 | { "type": "chore", "release": false }, 25 | { "type": "ci", "release": false }, 26 | { "type": "docs", "release": false }, 27 | { "type": "refactor", "release": false }, 28 | { "type": "revert", "release": false }, 29 | { "type": "style", "release": false }, 30 | { "type": "test", "release": false }, 31 | { "scope": "no-release", "release": false }, 32 | { "scope": "release", "release": "patch" } 33 | ], 34 | "presetConfig": true 35 | } 36 | ], 37 | [ "@semantic-release/git", 38 | { 39 | "assets": [ "package.json" ], 40 | "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" 41 | } 42 | ] 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /NOTICE.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | This is the NOTICE file as described under the Apache License 2.0 terms for inclusion in downstream software projects that use this code. 4 | --- 5 | 6 | # Notice 7 | 8 | Copyright 2021-2022 Cheqd Foundation Limited 9 | 10 | This product includes software developed at Cheqd Foundation Limited, doing business as "cheqd" 11 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | If you think you have discovered a security issue in any of cheqd projects, we'd love to hear from you. 6 | 7 | We take all security bugs seriously. If confirmed upon investigation, we will patch it within a reasonable amount of time and release a public security bulletin discussing the impact and credit the discoverer. 8 | 9 | There are two ways to report a security bug: 10 | 11 | * Email us at [security-github@cheqd.io](mailto:security-github@cheqd.io) 12 | * Join [our cheqd Community Slack](http://cheqd.link/join-cheqd-slack) and post a message on the #security channel 13 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ##################################################################### 2 | ### STAGE 1: Build cheqd did-resolver binary pre-requisites ### 3 | ##################################################################### 4 | 5 | FROM golang:1.23-alpine AS builder 6 | 7 | # Install minimum necessary dependencies 8 | ENV PACKAGES="make git bash linux-headers findutils" 9 | RUN apk update && apk add --no-cache $PACKAGES 10 | 11 | # Set working directory for the build 12 | WORKDIR /builder 13 | 14 | # Add source files 15 | COPY . . 16 | 17 | # Build did-resolver binary 18 | RUN make tidy && make build 19 | 20 | ##################################################################### 21 | ### STAGE 2: Build cheqd did-resolver container image ### 22 | ##################################################################### 23 | 24 | FROM alpine:3 AS resolver 25 | 26 | # Install pre-requisites 27 | RUN apk update && apk add --no-cache bash ca-certificates 28 | 29 | # Copy did-resolver binary from Stage 1 30 | COPY --from=builder /builder/build/did-resolver /usr/bin/did-resolver 31 | 32 | # Set user directory and details 33 | ARG HOME_DIR="/resolver" 34 | ARG USER="resolver" 35 | SHELL ["/bin/bash", "-euo", "pipefail", "-c"] 36 | 37 | # Add non-root user to use in the container 38 | RUN addgroup --system $USER \ 39 | && adduser $USER --system --home $HOME_DIR --shell /bin/bash 40 | 41 | # Set environment variables with default values 42 | ENV MAINNET_ENDPOINT="grpc.cheqd.net:443,true,5s" 43 | ENV TESTNET_ENDPOINT="grpc.cheqd.network:443,true,5s" 44 | ENV LOG_LEVEL="warn" 45 | ENV RESOLVER_LISTENER="0.0.0.0:8080" 46 | 47 | # Set working directory & bash defaults 48 | WORKDIR $HOME_DIR 49 | USER $USER 50 | 51 | EXPOSE 8080 52 | 53 | ENTRYPOINT ["did-resolver"] 54 | -------------------------------------------------------------------------------- /docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | # CAUTION: Please ensure you edit necessary values in docker-compose.env before using this Docker Compose file. 4 | 5 | # SYNTAX: docker compose -f docker/docker-compose.yml up --detach 6 | 7 | services: 8 | did_resolver: 9 | # OPTIONAL: Rebuild cheqd did-resolver Docker image, if you want build your own 10 | # Default is to pull in the pre-published image on GitHub Container Registry 11 | # SYNTAX: docker compose -f docker/docker-compose.yml build 12 | # build: 13 | # context: ../ 14 | # dockerfile: docker/Dockerfile 15 | # target: resolver 16 | # CAUTION: Change IMAGE_VERSION to local in docker-compose.env if building your own image in section below 17 | image: ghcr.io/cheqd/did-resolver:latest 18 | ports: 19 | - target: 8080 20 | published: 8080 21 | mode: host 22 | restart: on-failure 23 | environment: 24 | # Syntax: ,boolean,time 25 | # 1st parameter is gRPC endpoint 26 | # 2nd (Boolean) parameter is whether to use TLS or not 27 | # 3nd connection timeout 28 | MAINNET_ENDPOINT: "grpc.cheqd.net:443,true,5s" 29 | TESTNET_ENDPOINT: "grpc.cheqd.network:443,true,5s" 30 | 31 | # Logging level 32 | LOG_LEVEL: "warn" 33 | 34 | # Interface and port to listen on in the container 35 | RESOLVER_LISTENER: "0.0.0.0:8080" 36 | -------------------------------------------------------------------------------- /migrations/did.go: -------------------------------------------------------------------------------- 1 | package migrations 2 | 3 | func MigrateDID(did string) string { 4 | did = MigrateIndyStyleDid(did) 5 | did = MigrateUUIDDid(did) 6 | 7 | return did 8 | } 9 | -------------------------------------------------------------------------------- /migrations/indy_style.go: -------------------------------------------------------------------------------- 1 | package migrations 2 | 3 | import ( 4 | "crypto/sha256" 5 | 6 | "github.com/cheqd/did-resolver/utils" 7 | "github.com/mr-tron/base58" 8 | ) 9 | 10 | func MigrateIndyStyleDid(did string) string { 11 | method, namespace, id := utils.MustSplitDID(did) 12 | return utils.JoinDID(method, namespace, MigrateIndyStyleID(id)) 13 | } 14 | 15 | func MigrateIndyStyleID(id string) string { 16 | // If id is UUID it should not be changed 17 | if utils.IsValidUUID(id) { 18 | return id 19 | } 20 | 21 | // Get Hash from current id to make a 32-symbol string 22 | hash := sha256.Sum256([]byte(id)) 23 | 24 | // Indy-style identifier is 16-byte base58 string 25 | return base58.Encode(hash[:16]) 26 | } 27 | -------------------------------------------------------------------------------- /migrations/uuid.go: -------------------------------------------------------------------------------- 1 | package migrations 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/utils" 5 | "github.com/google/uuid" 6 | ) 7 | 8 | func MigrateUUIDDid(did string) string { 9 | method, namespace, id := utils.MustSplitDID(did) 10 | return utils.JoinDID(method, namespace, MigrateUUIDId(id)) 11 | } 12 | 13 | func MigrateUUIDId(id string) string { 14 | // If id is not UUID it should not be changed 15 | if !utils.IsValidUUID(id) { 16 | return id 17 | } 18 | 19 | // If uuid is already normalized, it should not be changed 20 | if utils.NormalizeUUID(id) == id { 21 | return id 22 | } 23 | 24 | newID := uuid.NewSHA1(uuid.Nil, []byte(id)) 25 | 26 | return utils.NormalizeUUID(newID.String()) 27 | } 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "did-resolver", 3 | "version": "3.3.3", 4 | "description": "DID Resolver for did:cheqd method", 5 | "license": "Apache-2.0", 6 | "author": "Cheqd Foundation Limited (https://github.com/cheqd)", 7 | "homepage": "https://github.com/cheqd/did-resolver#readme", 8 | "bugs": { 9 | "url": "https://github.com/cheqd/did-resolver/issues" 10 | }, 11 | "main": "main.go", 12 | "scripts": { 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/cheqd/did-resolver.git" 18 | }, 19 | "devDependencies": { 20 | "@semantic-release/commit-analyzer": "^13.0.1", 21 | "@semantic-release/git": "^10.0.1", 22 | "conventional-changelog-conventionalcommits": "^9.0.0", 23 | "semantic-release": "^24.2.5" 24 | }, 25 | "engines": { 26 | "node": ">=22.0.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /services/context.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "github.com/labstack/echo/v4" 5 | ) 6 | 7 | type ResolverContext struct { 8 | echo.Context 9 | LedgerService LedgerServiceI 10 | DidDocService DIDDocService 11 | ResourceService ResourceService 12 | } 13 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_all_version_metadata.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | ) 10 | 11 | type DIDDocAllVersionMetadataRequestService struct { 12 | services.BaseRequestService 13 | } 14 | 15 | func (dd *DIDDocAllVersionMetadataRequestService) Setup(c services.ResolverContext) error { 16 | dd.IsDereferencing = true // /versions path is dereferencing 17 | return nil 18 | } 19 | 20 | func (dd *DIDDocAllVersionMetadataRequestService) SpecificPrepare(c services.ResolverContext) error { 21 | return nil 22 | } 23 | 24 | func (dd DIDDocAllVersionMetadataRequestService) Redirect(c services.ResolverContext) error { 25 | migratedDid := migrations.MigrateDID(dd.GetDid()) 26 | 27 | path := types.RESOLVER_PATH + migratedDid + types.DID_VERSIONS_PATH 28 | return c.Redirect(http.StatusMovedPermanently, path) 29 | } 30 | 31 | func (dd *DIDDocAllVersionMetadataRequestService) SpecificValidation(c services.ResolverContext) error { 32 | // We not allow query here 33 | if len(dd.Queries) != 0 { 34 | return types.NewInvalidDidUrlError(dd.GetDid(), dd.RequestedContentType, nil, dd.IsDereferencing) 35 | } 36 | return nil 37 | } 38 | 39 | func (dd *DIDDocAllVersionMetadataRequestService) Query(c services.ResolverContext) error { 40 | result, err := c.DidDocService.GetAllDidDocVersionsMetadata(dd.GetDid(), dd.GetContentType()) 41 | if err != nil { 42 | err.IsDereferencing = dd.IsDereferencing 43 | return err 44 | } 45 | return dd.SetResponse(result) 46 | } 47 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_fragment.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/cheqd/did-resolver/services" 7 | "github.com/cheqd/did-resolver/types" 8 | ) 9 | 10 | type FragmentDIDDocRequestService struct { 11 | services.BaseRequestService 12 | } 13 | 14 | func (dd *FragmentDIDDocRequestService) Setup(c services.ResolverContext) error { 15 | dd.IsDereferencing = true 16 | split := strings.Split(c.Param("did"), "#") 17 | if len(split) == 2 { 18 | dd.Fragment = split[1] 19 | } 20 | return nil 21 | } 22 | 23 | func (dd *FragmentDIDDocRequestService) SpecificValidation(c services.ResolverContext) error { 24 | // We not allow query here 25 | if len(dd.Queries) != 0 { 26 | return types.NewInvalidDidUrlError(dd.GetDid(), dd.RequestedContentType, nil, dd.IsDereferencing) 27 | } 28 | return nil 29 | } 30 | 31 | func (dd *FragmentDIDDocRequestService) SpecificPrepare(c services.ResolverContext) error { 32 | return nil 33 | } 34 | 35 | func (dd *FragmentDIDDocRequestService) Query(c services.ResolverContext) error { 36 | result, err := c.DidDocService.DereferenceSecondary(dd.GetDid(), dd.Version, dd.Fragment, dd.GetContentType()) 37 | if err != nil { 38 | err.IsDereferencing = dd.IsDereferencing 39 | return err 40 | } 41 | return dd.SetResponse(result) 42 | } 43 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_full.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | ) 6 | 7 | type FullDIDDocRequestService struct { 8 | services.BaseRequestService 9 | } 10 | 11 | func (dd *FullDIDDocRequestService) Setup(c services.ResolverContext) error { 12 | dd.IsDereferencing = false 13 | return nil 14 | } 15 | 16 | func (dd *FullDIDDocRequestService) SpecificValidation(c services.ResolverContext) error { 17 | return nil 18 | } 19 | 20 | func (dd *FullDIDDocRequestService) SpecificPrepare(c services.ResolverContext) error { 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_metadata.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | ) 10 | 11 | type DIDDocMetadataService struct { 12 | services.BaseRequestService 13 | Profile string 14 | } 15 | 16 | func (dr *DIDDocMetadataService) Setup(c services.ResolverContext) error { 17 | dr.IsDereferencing = false 18 | return nil 19 | } 20 | 21 | func (dr *DIDDocMetadataService) SpecificPrepare(c services.ResolverContext) error { 22 | return nil 23 | } 24 | 25 | func (dr DIDDocMetadataService) Redirect(c services.ResolverContext) error { 26 | migratedDid := migrations.MigrateDID(dr.GetDid()) 27 | 28 | path := types.RESOLVER_PATH + migratedDid + types.DID_METADATA 29 | return c.Redirect(http.StatusMovedPermanently, path) 30 | } 31 | 32 | func (dr *DIDDocMetadataService) SpecificValidation(c services.ResolverContext) error { 33 | // We only allow one query parameter 34 | if len(dr.Queries) > 1 { 35 | return types.NewInvalidDidUrlError(dr.GetDid(), dr.RequestedContentType, nil, dr.IsDereferencing) 36 | } 37 | return nil 38 | } 39 | 40 | func (dr *DIDDocMetadataService) Query(c services.ResolverContext) error { 41 | resolution, err := c.ResourceService.ResolveMetadataResources(dr.GetDid(), dr.GetContentType()) 42 | if err != nil { 43 | err.IsDereferencing = dr.GetDereferencing() 44 | return err 45 | } 46 | return dr.SetResponse(resolution) 47 | } 48 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_only.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/services" 7 | "github.com/cheqd/did-resolver/types" 8 | ) 9 | 10 | type OnlyDIDDocRequestService struct { 11 | services.BaseRequestService 12 | ResourceQuery string 13 | } 14 | 15 | func (dd *OnlyDIDDocRequestService) Setup(c services.ResolverContext) error { 16 | dd.IsDereferencing = false 17 | return nil 18 | } 19 | 20 | func (dd *OnlyDIDDocRequestService) SpecificValidation(c services.ResolverContext) error { 21 | return nil 22 | } 23 | 24 | func (dd *OnlyDIDDocRequestService) SpecificPrepare(c services.ResolverContext) error { 25 | return nil 26 | } 27 | 28 | func (dd OnlyDIDDocRequestService) Respond(c services.ResolverContext) error { 29 | _result := dd.Result.(*types.DidResolution) 30 | // Return only the DidDocument 31 | return c.JSONPretty(http.StatusOK, _result.Did, " ") 32 | } 33 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_resource_dereferencing.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | ) 10 | 11 | type DIDDocResourceDereferencingService struct { 12 | services.BaseRequestService 13 | Profile string 14 | } 15 | 16 | func (dr *DIDDocResourceDereferencingService) Setup(c services.ResolverContext) error { 17 | dr.IsDereferencing = false 18 | return nil 19 | } 20 | 21 | func (dr *DIDDocResourceDereferencingService) SpecificPrepare(c services.ResolverContext) error { 22 | return nil 23 | } 24 | 25 | func (dr DIDDocResourceDereferencingService) Redirect(c services.ResolverContext) error { 26 | migratedDid := migrations.MigrateDID(dr.GetDid()) 27 | 28 | path := types.RESOLVER_PATH + migratedDid + types.DID_METADATA 29 | return c.Redirect(http.StatusMovedPermanently, path) 30 | } 31 | 32 | func (dr *DIDDocResourceDereferencingService) SpecificValidation(c services.ResolverContext) error { 33 | // We only allow one query parameter 34 | if len(dr.Queries) > 1 { 35 | return types.NewInvalidDidUrlError(dr.GetDid(), dr.RequestedContentType, nil, dr.IsDereferencing) 36 | } 37 | return nil 38 | } 39 | 40 | func (dr *DIDDocResourceDereferencingService) Query(c services.ResolverContext) error { 41 | resolution, err := c.ResourceService.ResolveCollectionResources(dr.GetDid(), dr.GetContentType()) 42 | if err != nil { 43 | err.IsDereferencing = dr.GetDereferencing() 44 | return err 45 | } 46 | return dr.SetResponse(resolution) 47 | } 48 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_version.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | "github.com/cheqd/did-resolver/utils" 10 | ) 11 | 12 | type DIDDocVersionRequestService struct { 13 | services.BaseRequestService 14 | } 15 | 16 | func (dd *DIDDocVersionRequestService) Setup(c services.ResolverContext) error { 17 | dd.IsDereferencing = false 18 | return nil 19 | } 20 | 21 | func (dd *DIDDocVersionRequestService) SpecificPrepare(c services.ResolverContext) error { 22 | // Get Version 23 | dd.Version = c.Param("version") 24 | return nil 25 | } 26 | 27 | func (dd DIDDocVersionRequestService) Redirect(c services.ResolverContext) error { 28 | migratedDid := migrations.MigrateDID(dd.GetDid()) 29 | 30 | path := types.RESOLVER_PATH + migratedDid + types.DID_VERSION_PATH + dd.Version 31 | return c.Redirect(http.StatusMovedPermanently, path) 32 | } 33 | 34 | func (dd *DIDDocVersionRequestService) SpecificValidation(c services.ResolverContext) error { 35 | if !utils.IsValidUUID(dd.Version) { 36 | return types.NewInvalidDidUrlError(dd.Version, dd.RequestedContentType, nil, dd.IsDereferencing) 37 | } 38 | // We not allow query here 39 | if len(dd.Queries) != 0 { 40 | return types.NewInvalidDidUrlError(dd.GetDid(), dd.RequestedContentType, nil, dd.IsDereferencing) 41 | } 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /services/diddoc/diddoc_version_metadata.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | "github.com/cheqd/did-resolver/utils" 10 | ) 11 | 12 | type DIDDocVersionMetadataRequestService struct { 13 | services.BaseRequestService 14 | } 15 | 16 | func (dd *DIDDocVersionMetadataRequestService) Setup(c services.ResolverContext) error { 17 | dd.IsDereferencing = false 18 | return nil 19 | } 20 | 21 | func (dd *DIDDocVersionMetadataRequestService) SpecificPrepare(c services.ResolverContext) error { 22 | // Get Version 23 | dd.Version = c.Param("version") 24 | return nil 25 | } 26 | 27 | func (dd DIDDocVersionMetadataRequestService) Redirect(c services.ResolverContext) error { 28 | migratedDid := migrations.MigrateDID(dd.GetDid()) 29 | 30 | path := types.RESOLVER_PATH + migratedDid + types.DID_VERSION_PATH + dd.Version + types.DID_METADATA 31 | return c.Redirect(http.StatusMovedPermanently, path) 32 | } 33 | 34 | func (dd *DIDDocVersionMetadataRequestService) SpecificValidation(c services.ResolverContext) error { 35 | if !utils.IsValidUUID(dd.Version) { 36 | return types.NewInvalidDidUrlError(dd.Version, dd.RequestedContentType, nil, dd.IsDereferencing) 37 | } 38 | 39 | // We not allow query here 40 | if len(dd.Queries) != 0 { 41 | return types.NewInvalidDidUrlError(dd.GetDid(), dd.RequestedContentType, nil, dd.IsDereferencing) 42 | } 43 | return nil 44 | } 45 | 46 | func (dd *DIDDocVersionMetadataRequestService) Query(c services.ResolverContext) error { 47 | result, err := c.DidDocService.GetDIDDocVersionsMetadata(dd.GetDid(), dd.Version, dd.GetContentType()) 48 | if err != nil { 49 | err.IsDereferencing = dd.IsDereferencing 50 | return err 51 | } 52 | return dd.SetResponse(result) 53 | } 54 | -------------------------------------------------------------------------------- /services/diddoc/queries/base_handler.go: -------------------------------------------------------------------------------- 1 | package queries 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/types" 6 | ) 7 | 8 | type BaseQueryHandlerI interface { 9 | SetNext(c services.ResolverContext, next BaseQueryHandlerI, isDereferencing bool) error 10 | // ToDo too many parameters, need to increase 11 | Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) 12 | Continue(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) 13 | } 14 | 15 | type BaseQueryHandler struct { 16 | IsDereferencing bool 17 | next BaseQueryHandlerI 18 | } 19 | 20 | func (b *BaseQueryHandler) SetNext(c services.ResolverContext, next BaseQueryHandlerI, isDereferencing bool) error { 21 | // All the query handlers are dereferencing by default 22 | b.IsDereferencing = isDereferencing 23 | if next == nil { 24 | return types.NewInternalError("next handler is nil", types.DIDJSONLD, nil, b.IsDereferencing) 25 | } 26 | b.next = next 27 | return nil 28 | } 29 | 30 | func (b *BaseQueryHandler) Continue(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 31 | if b.next == nil { 32 | return nil, types.NewInternalError("next handler is nil", types.DIDJSONLD, nil, b.IsDereferencing) 33 | } 34 | return b.next.Handle(c, service, response) 35 | } 36 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_doc_helpers.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/types" 6 | ) 7 | 8 | type DidDocHelperHandler struct{} 9 | 10 | func (d *DidDocHelperHandler) CastToContent(service services.RequestServiceI, response types.ResolutionResultI) (types.DidDocMetadataList, error) { 11 | // Cast to DidDocMetadataList for getting the list of metadata 12 | rc, ok := response.(types.DidDocMetadataList) 13 | if !ok { 14 | return nil, types.NewInternalError(service.GetDid(), service.GetContentType(), nil, service.GetDereferencing()) 15 | } 16 | return rc, nil 17 | } 18 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_doc_metadata_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "sort" 5 | 6 | "github.com/cheqd/did-resolver/services" 7 | "github.com/cheqd/did-resolver/services/diddoc/queries" 8 | "github.com/cheqd/did-resolver/types" 9 | ) 10 | 11 | type DidDocMetadataHandler struct { 12 | queries.BaseQueryHandler 13 | DidDocHelperHandler 14 | } 15 | 16 | func (dd *DidDocMetadataHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 17 | metadata := c.QueryParams().Get(types.Metadata) 18 | // If metadata is set we don't need to resolve the DidDoc 19 | if metadata != "true" { 20 | return dd.Continue(c, service, response) 21 | } 22 | 23 | allVersions, err := dd.CastToContent(service, response) 24 | if err != nil { 25 | return nil, err 26 | } 27 | if len(allVersions) == 0 { 28 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, dd.IsDereferencing) 29 | } 30 | 31 | // Get the latest version. If versionId and versionTime handlers were called, should be only 1 element. 32 | // If versionId or versionTime was not called, we will return the latest version 33 | // Cause allVersions are sorted in reverse order the latest version is the first element 34 | versionId := allVersions[0].VersionId 35 | filteredResources := allVersions[0].Resources 36 | 37 | // Filter in descending order 38 | sort.Sort(filteredResources) 39 | result, _err := c.DidDocService.GetDIDDocVersionsMetadata(service.GetDid(), versionId, service.GetContentType()) 40 | if _err != nil { 41 | _err.IsDereferencing = dd.IsDereferencing 42 | return nil, _err 43 | } 44 | 45 | // Fill the resources 46 | resultMetadata := result.Metadata 47 | resultMetadata.Resources = filteredResources 48 | result.Metadata = resultMetadata 49 | 50 | return dd.Continue(c, service, result) 51 | } 52 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_doc_resolve_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "sort" 5 | 6 | "github.com/cheqd/did-resolver/services" 7 | "github.com/cheqd/did-resolver/services/diddoc/queries" 8 | "github.com/cheqd/did-resolver/types" 9 | ) 10 | 11 | type DidDocResolveHandler struct { 12 | queries.BaseQueryHandler 13 | DidDocHelperHandler 14 | } 15 | 16 | func (dd *DidDocResolveHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 17 | metadata := c.QueryParams().Get(types.Metadata) 18 | // If metadata is set we don't need to resolve the DidDoc 19 | if metadata == "true" { 20 | return dd.Continue(c, service, response) 21 | } 22 | 23 | allVersions, err := dd.CastToContent(service, response) 24 | if err != nil { 25 | return nil, err 26 | } 27 | if len(allVersions) == 0 { 28 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, dd.IsDereferencing) 29 | } 30 | 31 | // Get the latest version. If versionId and versionTime handlers were called here, should be only 1 element. 32 | // If versionId or versionTime was not called, we will return the latest version 33 | versionId := allVersions[0].VersionId 34 | filteredResources := allVersions[0].Resources 35 | 36 | // Filter in descending order 37 | sort.Sort(filteredResources) 38 | 39 | result, _err := c.DidDocService.Resolve(service.GetDid(), versionId, service.GetContentType()) 40 | if _err != nil { 41 | _err.IsDereferencing = dd.IsDereferencing 42 | return nil, _err 43 | } 44 | 45 | if metadata == "false" { 46 | result.Metadata = nil 47 | } else { 48 | result.Metadata.Resources = filteredResources 49 | } 50 | // Call the next handler 51 | return dd.Continue(c, service, result) 52 | } 53 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_query_all_versions_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type DidQueryAllVersionsHandler struct { 10 | queries.BaseQueryHandler 11 | } 12 | 13 | func (d *DidQueryAllVersionsHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 14 | // Get Params 15 | did := service.GetDid() 16 | contentType := service.GetContentType() 17 | 18 | result, err := c.DidDocService.GetAllDidDocVersionsMetadata(did, contentType) 19 | if err != nil { 20 | err.IsDereferencing = d.IsDereferencing 21 | return nil, err 22 | } 23 | content, ok := result.ContentStream.(*types.DereferencedDidVersionsList) 24 | if !ok { 25 | return nil, types.NewInternalError(service.GetDid(), service.GetContentType(), nil, service.GetDereferencing()) 26 | } 27 | // Call the next handler 28 | return d.Continue(c, service, content.Versions) 29 | } 30 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_query_relative_ref_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type RelativeRefHandler struct { 10 | queries.BaseQueryHandler 11 | } 12 | 13 | func (r *RelativeRefHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 14 | // Get Params 15 | relativeRef := service.GetQueryParam(types.RelativeRef) 16 | 17 | // If relativeRef is empty, call the next handler. We don't need to handle it here 18 | if relativeRef == "" { 19 | return r.Continue(c, service, response) 20 | } 21 | 22 | // We expect here only DidResolution 23 | serviceResult, ok := response.(*types.ServiceResult) 24 | if !ok { 25 | return r.Continue(c, service, response) 26 | } 27 | 28 | // Call the next handler 29 | return r.Continue(c, service, types.NewServiceResult(serviceResult.GetServiceEndpoint()+relativeRef)) 30 | } 31 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_query_service_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ServiceHandler struct { 10 | queries.BaseQueryHandler 11 | } 12 | 13 | func (s *ServiceHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 14 | // Get Params 15 | serviceValue := service.GetQueryParam(types.ServiceQ) 16 | 17 | // If serviceValue is empty, call the next handler. We don't need to handle it here 18 | if serviceValue == "" { 19 | return s.Continue(c, service, response) 20 | } 21 | // We expect here only DidResolution 22 | didResolution, ok := response.(*types.DidResolution) 23 | if !ok { 24 | return nil, types.NewInternalError(service.GetDid(), types.DIDJSONLD, nil, service.GetDereferencing()) 25 | } 26 | 27 | result, err := didResolution.GetServiceByName(serviceValue) 28 | if err != nil { 29 | return nil, types.NewInternalError(service.GetDid(), types.JSONLD, nil, service.GetDereferencing()) 30 | } 31 | 32 | if result == "" { 33 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, service.GetDereferencing()) 34 | } 35 | // Call the next handler 36 | return s.Continue(c, service, types.NewServiceResult(result)) 37 | } 38 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_query_transform_key_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type TransformKeysHandler struct { 10 | queries.BaseQueryHandler 11 | } 12 | 13 | func (t *TransformKeysHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 14 | // Get Params 15 | transformKeys := types.TransformKeysType(service.GetQueryParam(types.TransformKeys)) 16 | 17 | // If transformKeys is empty, call the next handler. We don't need to handle it here 18 | if transformKeys == "" { 19 | return t.Continue(c, service, response) 20 | } 21 | 22 | if !transformKeys.IsSupported() { 23 | return nil, types.NewRepresentationNotSupportedError(service.GetDid(), service.GetContentType(), nil, t.IsDereferencing) 24 | } 25 | 26 | // We expect here only DidResolution 27 | didResolution, ok := response.(*types.DidResolution) 28 | if !ok { 29 | return nil, types.NewInternalError(service.GetDid(), types.DIDJSONLD, nil, t.IsDereferencing) 30 | } 31 | 32 | for i, vMethod := range didResolution.Did.VerificationMethod { 33 | result, err := transformVerificationMethodKey(vMethod, transformKeys) 34 | if err != nil { 35 | return nil, err 36 | } 37 | didResolution.Did.VerificationMethod[i] = result 38 | } 39 | 40 | // Call the next handler 41 | return t.Continue(c, service, didResolution) 42 | } 43 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_query_version_id_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type VersionIdHandler struct { 10 | queries.BaseQueryHandler 11 | DidDocHelperHandler 12 | } 13 | 14 | func (v *VersionIdHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | versionId := service.GetQueryParam(types.VersionId) 16 | // If versionId is empty, call the next handler. We don't need to handle it here 17 | if versionId == "" { 18 | return v.Continue(c, service, response) 19 | } 20 | 21 | // Get Params 22 | contentType := service.GetContentType() 23 | allVersions, err := v.CastToContent(service, response) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | versionFiltered := allVersions.GetByVersionId(versionId) 29 | if len(versionFiltered) == 0 { 30 | return nil, types.NewNotFoundError(service.GetDid(), contentType, nil, service.GetDereferencing()) 31 | } 32 | 33 | versionFiltered[0].Resources = allVersions.GetResourcesBeforeNextVersion(versionId) 34 | 35 | // Call the next handler 36 | return v.Continue(c, service, versionFiltered) 37 | } 38 | -------------------------------------------------------------------------------- /services/diddoc/queries/diddoc/did_query_version_time_handler.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type VersionTimeHandler struct { 10 | queries.BaseQueryHandler 11 | DidDocHelperHandler 12 | } 13 | 14 | func (v *VersionTimeHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | versionTime := service.GetQueryParam(types.VersionTime) 16 | 17 | // Here we are handling only query DID without versionId and versionTime 18 | if versionTime == "" { 19 | return v.Continue(c, service, response) 20 | } 21 | // Get Param 22 | contentType := service.GetContentType() 23 | 24 | allVersions, err := v.CastToContent(service, response) 25 | if err != nil { 26 | return nil, err 27 | } 28 | 29 | versionId, _err := allVersions.FindActiveForTime(versionTime) 30 | if _err != nil { 31 | return nil, types.NewInternalError(service.GetDid(), contentType, _err, service.GetDereferencing()) 32 | } 33 | 34 | if versionId == "" { 35 | return nil, types.NewNotFoundError(service.GetDid(), contentType, nil, service.GetDereferencing()) 36 | } 37 | 38 | versionsFiltered := allVersions.GetByVersionId(versionId) 39 | if len(versionsFiltered) == 0 { 40 | return nil, types.NewInternalError(service.GetDid(), contentType, nil, service.GetDereferencing()) 41 | } 42 | 43 | // Call the next handler 44 | return v.Continue(c, service, versionsFiltered) 45 | } 46 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_checksum_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceChecksumHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceChecksumHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceChecksum := service.GetQueryParam(types.ResourceChecksum) 16 | if resourceChecksum == "" { 17 | return d.Continue(c, service, response) 18 | } 19 | 20 | // Cast to just list of resources 21 | didResolution, err := d.CastToContent(service, response) 22 | if err != nil { 23 | return nil, err 24 | } 25 | 26 | // Filter the list of metadatas by the resourceCollectionId 27 | resourceCollectionFiltered := didResolution.Metadata.Resources.FilterByChecksum(resourceChecksum) 28 | if len(resourceCollectionFiltered) == 0 { 29 | // Notfound error if no resource found 30 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 31 | } 32 | if len(resourceCollectionFiltered) > 1 { 33 | // InvalidDidUrl error if multiple resources found with same checksum 34 | return nil, types.NewInvalidDidUrlError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 35 | } 36 | 37 | didResolution.Metadata.Resources = resourceCollectionFiltered 38 | 39 | // Call the next handler 40 | return d.Continue(c, service, didResolution) 41 | } 42 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_helper_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/types" 6 | ) 7 | 8 | type ResourceHelperHandler struct{} 9 | 10 | func (d *ResourceHelperHandler) CastToContent(service services.RequestServiceI, response types.ResolutionResultI) (*types.DidResolution, error) { 11 | // Cast to DidDocMetadataList for getting the list of metadata 12 | rc, ok := response.(*types.DidResolution) 13 | if !ok { 14 | return nil, types.NewInternalError(service.GetDid(), service.GetContentType(), nil, service.GetDereferencing()) 15 | } 16 | return rc, nil 17 | } 18 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_query_collection_id_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceCollectionIdHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceCollectionIdHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceCollectionId := service.GetQueryParam(types.ResourceCollectionId) 16 | if resourceCollectionId == "" { 17 | return d.Continue(c, service, response) 18 | } 19 | 20 | // Cast to just list of resources 21 | didResolution, err := d.CastToContent(service, response) 22 | if err != nil { 23 | return nil, err 24 | } 25 | 26 | // Filter the list of metadata by the resourceCollectionId 27 | resourceCollectionFiltered := didResolution.Metadata.Resources.FilterByCollectionId(resourceCollectionId) 28 | if len(resourceCollectionFiltered) == 0 { 29 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 30 | } 31 | 32 | didResolution.Metadata.Resources = resourceCollectionFiltered 33 | 34 | // Call the next handler 35 | return d.Continue(c, service, didResolution) 36 | } 37 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_query_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceQueryHandler struct { 10 | queries.BaseQueryHandler 11 | } 12 | 13 | func (d *ResourceQueryHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 14 | // If response is nil, then we need to dereference the resource from the beginning 15 | if response == nil { 16 | resolutionResult, err := c.ResourceService.ResolveMetadataResources(service.GetDid(), service.GetContentType()) 17 | if err != nil { 18 | return nil, err 19 | } 20 | // Call the next handler 21 | return d.Continue(c, service, resolutionResult) 22 | } 23 | // Otherwise just use the result from previous handlers 24 | // But here we need to cast ContentStream to ResolutionDidDocMetadata 25 | // in case of ResourceDereferencing response 26 | casted_did_resolution, ok := response.(*types.DidResolution) 27 | if !ok { 28 | return nil, types.NewInternalError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 29 | } 30 | // Call the next handler 31 | return d.Continue(c, service, casted_did_resolution) 32 | } 33 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_query_id_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceIdHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceIdHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceId := service.GetQueryParam(types.ResourceId) 16 | if resourceId == "" { 17 | return d.Continue(c, service, response) 18 | } 19 | 20 | // Cast to just list of resources 21 | didResolution, err := d.CastToContent(service, response) 22 | if err != nil { 23 | return nil, err 24 | } 25 | resourceCollectionFiltered := didResolution.Metadata.Resources.GetByResourceId(resourceId) 26 | if len(resourceCollectionFiltered) == 0 { 27 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 28 | } 29 | 30 | didResolution.Metadata.Resources = resourceCollectionFiltered 31 | 32 | // Call the next handler 33 | return d.Continue(c, service, didResolution) 34 | } 35 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_query_name_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceNameHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceNameHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceName := service.GetQueryParam(types.ResourceName) 16 | 17 | if resourceName == "" { 18 | return d.Continue(c, service, response) 19 | } 20 | 21 | // Cast to just list of resources 22 | didResolution, err := d.CastToContent(service, response) 23 | if err != nil { 24 | return nil, err 25 | } 26 | 27 | // Filter the list of metadata by the resourceCollectionId 28 | resourceCollectionFiltered := didResolution.Metadata.Resources.FilterByResourceName(resourceName) 29 | if len(resourceCollectionFiltered) == 0 { 30 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 31 | } 32 | 33 | didResolution.Metadata.Resources = resourceCollectionFiltered 34 | 35 | // Call the next handler 36 | return d.Continue(c, service, didResolution) 37 | } 38 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_query_type_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceTypeHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceTypeHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceType := service.GetQueryParam(types.ResourceType) 16 | if resourceType == "" { 17 | return d.Continue(c, service, response) 18 | } 19 | 20 | didResolution, err := d.CastToContent(service, response) 21 | if err != nil { 22 | return nil, err 23 | } 24 | // Filter the list of metadata by the resourceCollectionId 25 | resourceCollectionFiltered := didResolution.Metadata.Resources.FilterByResourceType(resourceType) 26 | if len(resourceCollectionFiltered) == 0 { 27 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 28 | } 29 | 30 | didResolution.Metadata.Resources = resourceCollectionFiltered 31 | 32 | // Call the next handler 33 | return d.Continue(c, service, didResolution) 34 | } 35 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_query_version_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceVersionHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceVersionHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceVersion := service.GetQueryParam(types.ResourceVersion) 16 | if resourceVersion == "" { 17 | return d.Continue(c, service, response) 18 | } 19 | 20 | // Cast to just list of resources 21 | didResolution, err := d.CastToContent(service, response) 22 | if err != nil { 23 | return nil, err 24 | } 25 | 26 | // Filter the list of metadata by the resourceCollectionId 27 | resourceCollectionFiltered := didResolution.Metadata.Resources.FilterByResourceVersion(resourceVersion) 28 | if len(resourceCollectionFiltered) == 0 { 29 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 30 | } 31 | 32 | didResolution.Metadata.Resources = resourceCollectionFiltered 33 | // Call the next handler 34 | return d.Continue(c, service, didResolution) 35 | } 36 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_query_version_time_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceVersionTimeHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceVersionTimeHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceVersionTime := service.GetQueryParam(types.ResourceVersionTime) 16 | if resourceVersionTime == "" { 17 | return d.Continue(c, service, response) 18 | } 19 | 20 | // Cast to just list of resources 21 | didResolution, err := d.CastToContent(service, response) 22 | if err != nil { 23 | return nil, err 24 | } 25 | // Get resourceId of the resource with the closest time to the requested time 26 | resourceList, err := didResolution.Metadata.Resources.FindAllBeforeTime(resourceVersionTime) 27 | if err != nil { 28 | return nil, types.NewRepresentationNotSupportedError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 29 | } 30 | if len(resourceList) == 0 { 31 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 32 | } 33 | 34 | didResolution.Metadata.Resources = resourceList 35 | 36 | // Call the next handler 37 | return d.Continue(c, service, didResolution) 38 | } 39 | -------------------------------------------------------------------------------- /services/diddoc/queries/resources/resource_validation_handler.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/services/diddoc/queries" 6 | "github.com/cheqd/did-resolver/types" 7 | ) 8 | 9 | type ResourceValidationHandler struct { 10 | queries.BaseQueryHandler 11 | ResourceHelperHandler 12 | } 13 | 14 | func (d *ResourceValidationHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 15 | resourceName := service.GetQueryParam(types.ResourceName) 16 | resourceMetadata := service.GetQueryParam(types.ResourceMetadata) 17 | 18 | // Cast to just list of resources 19 | didResolution, err := d.CastToContent(service, response) 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | if resourceMetadata == "true" { 25 | return d.Continue(c, service, didResolution) 26 | } 27 | 28 | if resourceName != "" { 29 | // If we have 2 or more resources we need to check resource types. 30 | // If resource types are the same we need to return the latest. 31 | // If resource types are different we need to return an error. 32 | if !didResolution.Metadata.Resources.AreResourceTypesTheSame() { 33 | return nil, types.NewNotFoundError(service.GetDid(), service.GetContentType(), nil, d.IsDereferencing) 34 | } 35 | // They are sorted in descending order by default 36 | didResolution.Metadata.Resources = types.DereferencedResourceList{didResolution.Metadata.Resources[0]} 37 | } 38 | 39 | // Call the next handler 40 | return d.Continue(c, service, didResolution) 41 | } 42 | -------------------------------------------------------------------------------- /services/diddoc/queries/stop_handler.go: -------------------------------------------------------------------------------- 1 | package queries 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/services" 5 | "github.com/cheqd/did-resolver/types" 6 | ) 7 | 8 | type StopHandler struct { 9 | BaseQueryHandler 10 | } 11 | 12 | func (s *StopHandler) Handle(c services.ResolverContext, service services.RequestServiceI, response types.ResolutionResultI) (types.ResolutionResultI, error) { 13 | return response, nil 14 | } 15 | -------------------------------------------------------------------------------- /services/diddoc/routes.go: -------------------------------------------------------------------------------- 1 | package diddoc 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/types" 5 | "github.com/labstack/echo/v4" 6 | ) 7 | 8 | func SetRoutes(e *echo.Echo) { 9 | // Routes 10 | // Did docs 11 | e.GET(types.RESOLVER_PATH+":did", DidDocEchoHandler) 12 | e.GET(types.RESOLVER_PATH+":did"+types.DID_METADATA, DidDocMetadataEchoHandler) 13 | e.GET(types.RESOLVER_PATH+":did"+types.DID_VERSION_PATH+":version", DidDocVersionEchoHandler) 14 | e.GET(types.RESOLVER_PATH+":did"+types.DID_VERSION_PATH+":version/metadata", DidDocVersionMetadataEchoHandler) 15 | e.GET(types.RESOLVER_PATH+":did"+types.DID_VERSIONS_PATH, DidDocAllVersionMetadataEchoHandler) 16 | } 17 | -------------------------------------------------------------------------------- /services/error_handler.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/types" 7 | "github.com/labstack/echo/v4" 8 | "github.com/rs/zerolog/log" 9 | ) 10 | 11 | func CustomHTTPErrorHandler(err error, c echo.Context) { 12 | if err == nil { 13 | return 14 | } 15 | identityError := generateIdentityError(err) 16 | if identityError.Code == http.StatusInternalServerError { 17 | log.Error().Err(identityError.Internal) 18 | } else { 19 | log.Warn().Err(identityError.Internal) 20 | } 21 | c.Response().Header().Set(echo.HeaderContentType, string(identityError.ContentType)) 22 | err = c.JSONPretty(identityError.Code, identityError.DisplayMessage(), " ") 23 | if err != nil { 24 | log.Error().Err(err) 25 | } 26 | } 27 | 28 | func generateIdentityError(err error) *types.IdentityError { 29 | identityError, ok := err.(*types.IdentityError) 30 | if ok { 31 | return identityError 32 | } 33 | he, ok := err.(*echo.HTTPError) 34 | if !ok || he.Code != http.StatusNotFound { 35 | return types.NewInternalError("", types.JSON, err, false) 36 | } 37 | return types.NewInvalidDidUrlError("", types.JSON, err, true) 38 | } 39 | -------------------------------------------------------------------------------- /services/request_service_interface.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/types" 5 | echo "github.com/labstack/echo/v4" 6 | ) 7 | 8 | type RequestServiceI interface { 9 | // Getters 10 | GetDid() string 11 | GetContentType() types.ContentType 12 | GetQueryParam(name string) string 13 | GetDereferencing() bool 14 | 15 | // Setters 16 | SetResponse(r types.ResolutionResultI) error 17 | 18 | // Checks 19 | IsRedirectNeeded(c ResolverContext) bool 20 | 21 | // Methods 22 | // Setup 23 | Setup(c ResolverContext) error 24 | // Preparations 25 | BasicPrepare(c ResolverContext) error 26 | SpecificPrepare(c ResolverContext) error 27 | 28 | // Validation 29 | BasicValidation(c ResolverContext) error 30 | SpecificValidation(c ResolverContext) error 31 | 32 | // Redirect if needed 33 | Redirect(c ResolverContext) error 34 | 35 | // Ask ledger for data 36 | Query(c ResolverContext) error 37 | 38 | // Some kind of postprocessing for response 39 | SetupResponse(c ResolverContext) error 40 | 41 | Respond(c ResolverContext) error 42 | } 43 | 44 | // The main flow for all the requests 45 | func EchoWrapHandler(controller RequestServiceI) echo.HandlerFunc { 46 | return func(c echo.Context) error { 47 | rc := c.(ResolverContext) 48 | // Setup 49 | if err := controller.Setup(rc); err != nil { 50 | return err 51 | } 52 | // Preparations, like get parameters from context and others 53 | if err := controller.BasicPrepare(rc); err != nil { 54 | return err 55 | } 56 | if err := controller.SpecificPrepare(rc); err != nil { 57 | return err 58 | } 59 | // Redirect if needed 60 | if controller.IsRedirectNeeded(rc) { 61 | return controller.Redirect(rc) 62 | } 63 | // Validation 64 | if err := controller.BasicValidation(rc); err != nil { 65 | return err 66 | } 67 | if err := controller.SpecificValidation(rc); err != nil { 68 | return err 69 | } 70 | // Query 71 | if err := controller.Query(rc); err != nil { 72 | return err 73 | } 74 | // Make response. Set specific headers, etc. 75 | if err := controller.SetupResponse(rc); err != nil { 76 | return err 77 | } 78 | return controller.Respond(rc) 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /services/resource/resource_data_dereferencing.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | "github.com/cheqd/did-resolver/utils" 10 | ) 11 | 12 | type ResourceDataDereferencingService struct { 13 | services.BaseRequestService 14 | ResourceId string 15 | } 16 | 17 | func (dr *ResourceDataDereferencingService) Setup(c services.ResolverContext) error { 18 | dr.IsDereferencing = true 19 | return nil 20 | } 21 | 22 | func (dr *ResourceDataDereferencingService) SpecificPrepare(c services.ResolverContext) error { 23 | dr.ResourceId = c.Param("resource") 24 | return nil 25 | } 26 | 27 | func (dr ResourceDataDereferencingService) Redirect(c services.ResolverContext) error { 28 | migratedDid := migrations.MigrateDID(dr.GetDid()) 29 | 30 | path := types.RESOLVER_PATH + migratedDid + types.RESOURCE_PATH + dr.ResourceId 31 | return c.Redirect(http.StatusMovedPermanently, path) 32 | } 33 | 34 | func (dr *ResourceDataDereferencingService) SpecificValidation(c services.ResolverContext) error { 35 | if !utils.IsValidUUID(dr.ResourceId) { 36 | return types.NewInvalidDidUrlError(dr.ResourceId, dr.RequestedContentType, nil, dr.IsDereferencing) 37 | } 38 | 39 | // We not allow query here 40 | if len(dr.Queries) != 0 { 41 | return types.NewInvalidDidUrlError(dr.GetDid(), dr.RequestedContentType, nil, dr.IsDereferencing) 42 | } 43 | return nil 44 | } 45 | 46 | func (dr *ResourceDataDereferencingService) Query(c services.ResolverContext) error { 47 | result, err := c.ResourceService.DereferenceResourceData(dr.GetDid(), dr.ResourceId, dr.GetContentType()) 48 | if err != nil { 49 | err.IsDereferencing = dr.IsDereferencing 50 | return err 51 | } 52 | return dr.SetResponse(result) 53 | } 54 | 55 | func (dr ResourceDataDereferencingService) Respond(c services.ResolverContext) error { 56 | return dr.RespondWithResourceData(c) 57 | } 58 | -------------------------------------------------------------------------------- /services/resource/resource_data_with_metadata_dereferencing.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | "github.com/cheqd/did-resolver/utils" 10 | ) 11 | 12 | type ResourceDataWithMetadataDereferencingService struct { 13 | services.BaseRequestService 14 | ResourceId string 15 | } 16 | 17 | func (dr *ResourceDataWithMetadataDereferencingService) Setup(c services.ResolverContext) error { 18 | dr.IsDereferencing = true 19 | return nil 20 | } 21 | 22 | func (dr *ResourceDataWithMetadataDereferencingService) SpecificPrepare(c services.ResolverContext) error { 23 | dr.ResourceId = c.Param("resource") 24 | return nil 25 | } 26 | 27 | func (dr ResourceDataWithMetadataDereferencingService) Redirect(c services.ResolverContext) error { 28 | migratedDid := migrations.MigrateDID(dr.GetDid()) 29 | 30 | path := types.RESOLVER_PATH + migratedDid + types.RESOURCE_PATH + dr.ResourceId 31 | return c.Redirect(http.StatusMovedPermanently, path) 32 | } 33 | 34 | func (dr *ResourceDataWithMetadataDereferencingService) SpecificValidation(c services.ResolverContext) error { 35 | if !utils.IsValidUUID(dr.ResourceId) { 36 | return types.NewInvalidDidUrlError(dr.ResourceId, dr.RequestedContentType, nil, dr.IsDereferencing) 37 | } 38 | 39 | // We not allow query here 40 | if len(dr.Queries) != 0 { 41 | return types.NewInvalidDidUrlError(dr.GetDid(), dr.RequestedContentType, nil, dr.IsDereferencing) 42 | } 43 | return nil 44 | } 45 | 46 | func (dr *ResourceDataWithMetadataDereferencingService) Query(c services.ResolverContext) error { 47 | result, err := c.ResourceService.DereferenceResourceDataWithMetadata(dr.GetDid(), dr.ResourceId, dr.GetContentType()) 48 | if err != nil { 49 | err.IsDereferencing = dr.IsDereferencing 50 | return err 51 | } 52 | 53 | return dr.SetResponse(result) 54 | } 55 | -------------------------------------------------------------------------------- /services/resource/resource_metadata_dereferencing.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/cheqd/did-resolver/migrations" 7 | "github.com/cheqd/did-resolver/services" 8 | "github.com/cheqd/did-resolver/types" 9 | "github.com/cheqd/did-resolver/utils" 10 | ) 11 | 12 | type ResourceMetadataDereferencingService struct { 13 | services.BaseRequestService 14 | ResourceId string 15 | } 16 | 17 | func (dr *ResourceMetadataDereferencingService) Setup(c services.ResolverContext) error { 18 | dr.IsDereferencing = true 19 | return nil 20 | } 21 | 22 | func (dr *ResourceMetadataDereferencingService) SpecificPrepare(c services.ResolverContext) error { 23 | dr.ResourceId = c.Param("resource") 24 | return nil 25 | } 26 | 27 | func (dr ResourceMetadataDereferencingService) Redirect(c services.ResolverContext) error { 28 | migratedDid := migrations.MigrateDID(dr.GetDid()) 29 | 30 | path := types.RESOLVER_PATH + migratedDid + types.RESOURCE_PATH + dr.ResourceId + "/metadata" 31 | return c.Redirect(http.StatusMovedPermanently, path) 32 | } 33 | 34 | func (dr *ResourceMetadataDereferencingService) SpecificValidation(c services.ResolverContext) error { 35 | // Metadata endpoint should be one of the supported types. 36 | if !dr.RequestedContentType.IsSupported() { 37 | return types.NewRepresentationNotSupportedError(dr.GetDid(), types.JSON, nil, dr.IsDereferencing) 38 | } 39 | 40 | if !utils.IsValidUUID(dr.ResourceId) { 41 | return types.NewInvalidDidUrlError(dr.ResourceId, dr.RequestedContentType, nil, dr.IsDereferencing) 42 | } 43 | 44 | // We not allow query here 45 | if len(dr.Queries) != 0 { 46 | return types.NewInvalidDidUrlError(dr.GetDid(), dr.RequestedContentType, nil, dr.IsDereferencing) 47 | } 48 | return nil 49 | } 50 | 51 | func (dr *ResourceMetadataDereferencingService) Query(c services.ResolverContext) error { 52 | result, err := c.ResourceService.DereferenceResourceMetadata(dr.GetDid(), dr.ResourceId, dr.GetContentType()) 53 | if err != nil { 54 | err.IsDereferencing = dr.IsDereferencing 55 | return err 56 | } 57 | return dr.SetResponse(result) 58 | } 59 | -------------------------------------------------------------------------------- /services/resource/routes.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/cheqd/did-resolver/types" 5 | "github.com/labstack/echo/v4" 6 | ) 7 | 8 | func SetRoutes(e *echo.Echo) { 9 | e.GET(types.RESOLVER_PATH+":did"+types.RESOURCE_PATH+":resource", ResourceDataEchoHandler) 10 | e.GET(types.RESOLVER_PATH+":did"+types.RESOURCE_PATH+":resource/metadata", ResourceMetadataEchoHandler) 11 | } 12 | -------------------------------------------------------------------------------- /tests/docker-compose-testing.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | # CAUTION: Please ensure you edit necessary values in docker-compose.env before using this Docker Compose file. 4 | 5 | # SYNTAX: docker compose -f docker/docker-compose.yml up --detach 6 | 7 | services: 8 | did_resolver: 9 | # OPTIONAL: Rebuild cheqd did-resolver Docker image, if you want build your own 10 | # Default is to pull in the pre-published image on GitHub Container Registry 11 | # SYNTAX: docker compose -f docker/docker-compose.yml build 12 | # build: 13 | # context: ../ 14 | # dockerfile: docker/Dockerfile 15 | # target: resolver 16 | # CAUTION: Change IMAGE_VERSION to local in docker-compose.env if building your own image in section below 17 | image: ${IMAGE_NAME:-cheqd/did-resolver}:staging-latest 18 | ports: 19 | - target: 8080 20 | published: 8080 21 | mode: host 22 | restart: on-failure 23 | environment: 24 | # Syntax: ,boolean,time 25 | # 1st parameter is gRPC endpoint 26 | # 2nd (Boolean) parameter is whether to use TLS or not 27 | # 3nd connection timeout 28 | MAINNET_ENDPOINT: "grpc.cheqd.net:443,true,5s" 29 | TESTNET_ENDPOINT: "grpc.cheqd.network:443,true,5s" 30 | 31 | # Logging level 32 | LOG_LEVEL: "warn" 33 | 34 | # Interface and port to listen on in the container 35 | RESOLVER_LISTENER: "0.0.0.0:8080" 36 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/diddoc/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package diddoc_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestDiddoc(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: DIDDoc") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/fragment/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package fragment_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestFragment(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: DIDDoc Fragment") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/metadata/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package metadata_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestMetadata(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: DIDDoc Version Metadata") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/query/metadata/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package metadata 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestMetadata(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: DIDDoc Metadata query parameter") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/query/service/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package service 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestMetadata(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Service and Relative Ref query parameters") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/query/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package query_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestQuery(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Combination of DIDDoc query parameters") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/query/transform_key/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package transformKeys 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestTransformKey(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Transform Keys Query") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/query/version_id/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package versionId 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestMetadata(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: VersionId query parameter") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/query/version_time/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package versionTime 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestMetadata(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: VersionTime query parameter") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/version/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package version_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestVersion(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: DIDDoc Version") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/diddoc/versions/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package versions_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestVersions(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: DIDDoc Versions") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/collection/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package collection_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestCollection(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Collection of Resources") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/data/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package data_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestData(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Resource Data") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/data_with_metadata/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package data_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestData(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Resource Data with Metadata") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/metadata/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package metadata_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestMetadata(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Resource Metadata") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_checksum/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_checksum_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceChecksum(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: Resource checksum query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_collection_id/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_collection_id_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceCollectionId(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: Resource collectionId query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_id/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_id_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceId(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: ResourceId query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_metadata/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_metadata_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceMetadata(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: Resource metadata query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_name/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_name_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceName(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: Resource name query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_type/negative_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package resource_type_test 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | 9 | testconstants "github.com/cheqd/did-resolver/tests/constants" 10 | utils "github.com/cheqd/did-resolver/tests/integration/rest" 11 | "github.com/cheqd/did-resolver/types" 12 | errors "github.com/cheqd/did-resolver/types" 13 | 14 | "github.com/go-resty/resty/v2" 15 | . "github.com/onsi/ginkgo/v2" 16 | . "github.com/onsi/gomega" 17 | ) 18 | 19 | var _ = DescribeTable("Negative: Get Resource with resourceType query", func(testCase utils.NegativeTestCase) { 20 | client := resty.New() 21 | 22 | resp, err := client.R(). 23 | SetHeader("Accept", testCase.ResolutionType). 24 | Get(testCase.DidURL) 25 | Expect(err).To(BeNil()) 26 | 27 | var receivedDidDereferencing utils.DereferencingResult 28 | Expect(json.Unmarshal(resp.Body(), &receivedDidDereferencing)).To(BeNil()) 29 | Expect(testCase.ExpectedStatusCode).To(Equal(resp.StatusCode())) 30 | 31 | expectedDidDereferencing := testCase.ExpectedResult.(utils.DereferencingResult) 32 | utils.AssertDidDereferencing(expectedDidDereferencing, receivedDidDereferencing) 33 | }, 34 | 35 | Entry( 36 | "cannot get resource with not existent resourceType query parameter", 37 | utils.NegativeTestCase{ 38 | DidURL: fmt.Sprintf( 39 | "http://%s/1.0/identifiers/%s?resourceType=xyz", 40 | testconstants.TestHostAddress, 41 | testconstants.UUIDStyleTestnetDid, 42 | ), 43 | ResolutionType: string(types.DIDJSONLD), 44 | ExpectedResult: utils.DereferencingResult{ 45 | Context: "", 46 | DereferencingMetadata: types.DereferencingMetadata{ 47 | ContentType: types.DIDJSONLD, 48 | ResolutionError: "notFound", 49 | DidProperties: types.DidProperties{ 50 | DidString: testconstants.UUIDStyleTestnetDid, 51 | MethodSpecificId: testconstants.UUIDStyleTestnetId, 52 | Method: testconstants.ValidMethod, 53 | }, 54 | }, 55 | ContentStream: nil, 56 | Metadata: types.ResolutionDidDocMetadata{}, 57 | }, 58 | ExpectedStatusCode: errors.NotFoundHttpCode, 59 | }, 60 | ), 61 | ) 62 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_type/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_type_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceType(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: Resource type query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_version/positive_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package resource_version_test 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | "net/http" 9 | 10 | testconstants "github.com/cheqd/did-resolver/tests/constants" 11 | utils "github.com/cheqd/did-resolver/tests/integration/rest" 12 | 13 | "github.com/go-resty/resty/v2" 14 | . "github.com/onsi/ginkgo/v2" 15 | . "github.com/onsi/gomega" 16 | ) 17 | 18 | var severalResourcesDID = "did:cheqd:testnet:0a5b94d0-a417-48ed-a6f5-4abc9e95888d" 19 | 20 | var _ = DescribeTable("Positive: Get Resource with resourceVersion query", func(testCase utils.PositiveTestCase) { 21 | client := resty.New() 22 | 23 | resp, err := client.R(). 24 | SetHeader("Accept", testCase.ResolutionType). 25 | Get(testCase.DidURL) 26 | Expect(err).To(BeNil()) 27 | 28 | var receivedResourceData any 29 | Expect(json.Unmarshal(resp.Body(), &receivedResourceData)).To(BeNil()) 30 | Expect(testCase.ExpectedStatusCode).To(Equal(resp.StatusCode())) 31 | 32 | var expectedResourceData any 33 | Expect(utils.ConvertJsonFileToType(testCase.ExpectedJSONPath, &expectedResourceData)).To(BeNil()) 34 | 35 | Expect(expectedResourceData).To(Equal(receivedResourceData)) 36 | }, 37 | 38 | Entry( 39 | "can get resource with an existent resourceVersion query parameter", 40 | utils.PositiveTestCase{ 41 | DidURL: fmt.Sprintf( 42 | "http://%s/1.0/identifiers/%s?resourceVersion=1.0&resourceType=%s", 43 | testconstants.TestHostAddress, 44 | severalResourcesDID, 45 | "JsonSchemaValidator2018", 46 | ), 47 | ResolutionType: testconstants.DefaultResolutionType, 48 | ExpectedJSONPath: "../../../testdata/query/resource_version/resource.json", 49 | ExpectedStatusCode: http.StatusOK, 50 | }, 51 | ), 52 | 53 | // TODO: add unit test for testing get resource with: 54 | // - an old 16 characters INDY style DID and resourceVersion query parameter 55 | // - an old 32 characters INDY style DID and resourceVersion query parameter 56 | ) 57 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_version/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_version_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceVersion(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: Resource version query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/resource_version_time/suite_test.go: -------------------------------------------------------------------------------- 1 | package resource_version_time_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | ) 9 | 10 | func TestResourceVersionTime(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "[Integration Test]: Resource version time query parameter") 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/rest/resource/query/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package query_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestQuery(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: Combination of Resource query parameters") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/support_query_negative_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package rest 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | 9 | testconstants "github.com/cheqd/did-resolver/tests/constants" 10 | "github.com/cheqd/did-resolver/types" 11 | "github.com/go-resty/resty/v2" 12 | . "github.com/onsi/ginkgo/v2" 13 | . "github.com/onsi/gomega" 14 | ) 15 | 16 | var _ = DescribeTable("", func(testCase NegativeTestCase) { 17 | client := resty.New() 18 | 19 | resp, err := client.R(). 20 | SetHeader("Accept", testCase.ResolutionType). 21 | Get(testCase.DidURL) 22 | Expect(err).To(BeNil()) 23 | Expect(testCase.ExpectedStatusCode).To(Equal(resp.StatusCode())) 24 | 25 | var receivedDidDereferencing types.DidResolution 26 | Expect(json.Unmarshal(resp.Body(), &receivedDidDereferencing)).To(BeNil()) 27 | 28 | expectedDidDereferencing := testCase.ExpectedResult.(types.DidResolution) 29 | AssertDidResolution(expectedDidDereferencing, receivedDidDereferencing) 30 | }, 31 | 32 | Entry( 33 | "cannot get resolution result with an invalid query", 34 | NegativeTestCase{ 35 | DidURL: fmt.Sprintf( 36 | "http://%s/1.0/identifiers/%s?invalid_parameter=invalid_value", 37 | testconstants.TestHostAddress, 38 | testconstants.UUIDStyleTestnetDid, 39 | ), 40 | ResolutionType: testconstants.DefaultResolutionType, 41 | ExpectedResult: types.DidResolution{ 42 | Context: "", 43 | ResolutionMetadata: types.ResolutionMetadata{ 44 | ContentType: types.JSONLD, 45 | ResolutionError: "invalidDidUrl", 46 | DidProperties: types.DidProperties{ 47 | DidString: testconstants.UUIDStyleTestnetDid, 48 | MethodSpecificId: "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 49 | Method: testconstants.ValidMethod, 50 | }, 51 | }, 52 | Did: nil, 53 | Metadata: nil, 54 | }, 55 | ExpectedStatusCode: types.InvalidDidUrlHttpCode, 56 | }, 57 | ), 58 | ) 59 | -------------------------------------------------------------------------------- /tests/integration/rest/test_suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build integration 2 | 3 | package rest 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestTestsGeneral(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Integration Test]: REST API") 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/collection_of_resources/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-27T04:52:38Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2023-01-25T11:58:10Z", 14 | "versionId": "e5615fc2-6f13-42b1-989c-49576a574cef", 15 | "linkedResourceMetadata": [ 16 | { 17 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 18 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 19 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 20 | "resourceName": "Demo Resource", 21 | "resourceType": "String", 22 | "resourceVersion" : "", 23 | "mediaType": "application/json", 24 | "created": "2023-01-25T12:08:39Z", 25 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 26 | "previousVersionId": null, 27 | "nextVersionId": null 28 | }, 29 | { 30 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/e733ebb7-c8dd-41ed-9d42-33bceea70952", 31 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 32 | "resourceId": "e733ebb7-c8dd-41ed-9d42-33bceea70952", 33 | "resourceName": "ResourceName", 34 | "resourceType": "String", 35 | "resourceVersion" : "", 36 | "mediaType": "text/plain; charset=utf-8", 37 | "created": "2023-01-25T12:04:52Z", 38 | "checksum": "cffd829b06797f85407be9353056db722ca3eca0c05ab0462a42d30f19cdef09", 39 | "previousVersionId": null, 40 | "nextVersionId": null 41 | } 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/collection_of_resources/metadata_did_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "didResolutionMetadata": { 3 | "contentType": "application/did+json", 4 | "retrieved": "2023-04-05T16:48:19Z", 5 | "did": { 6 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 7 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "method": "cheqd" 9 | } 10 | }, 11 | "didDocumentMetadata": { 12 | "created": "2023-01-25T11:58:10Z", 13 | "versionId": "e5615fc2-6f13-42b1-989c-49576a574cef", 14 | "linkedResourceMetadata": [ 15 | { 16 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 17 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 18 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 19 | "resourceName": "Demo Resource", 20 | "resourceType": "String", 21 | "resourceVersion" : "", 22 | "mediaType": "application/json", 23 | "created": "2023-01-25T12:08:39Z", 24 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 25 | "previousVersionId": null, 26 | "nextVersionId": null 27 | }, 28 | { 29 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/e733ebb7-c8dd-41ed-9d42-33bceea70952", 30 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 31 | "resourceId": "e733ebb7-c8dd-41ed-9d42-33bceea70952", 32 | "resourceName": "ResourceName", 33 | "resourceType": "String", 34 | "resourceVersion" : "", 35 | "mediaType": "text/plain; charset=utf-8", 36 | "created": "2023-01-25T12:04:52Z", 37 | "checksum": "cffd829b06797f85407be9353056db722ca3eca0c05ab0462a42d30f19cdef09", 38 | "previousVersionId": null, 39 | "nextVersionId": null 40 | } 41 | ] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/collection_of_resources/metadata_did_ld.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did+ld+json", 5 | "retrieved": "2023-03-27T04:52:38Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2023-01-25T11:58:10Z", 14 | "versionId": "e5615fc2-6f13-42b1-989c-49576a574cef", 15 | "linkedResourceMetadata": [ 16 | { 17 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 18 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 19 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 20 | "resourceName": "Demo Resource", 21 | "resourceType": "String", 22 | "resourceVersion" : "", 23 | "mediaType": "application/json", 24 | "created": "2023-01-25T12:08:39Z", 25 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 26 | "previousVersionId": null, 27 | "nextVersionId": null 28 | }, 29 | { 30 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/e733ebb7-c8dd-41ed-9d42-33bceea70952", 31 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 32 | "resourceId": "e733ebb7-c8dd-41ed-9d42-33bceea70952", 33 | "resourceName": "ResourceName", 34 | "resourceType": "String", 35 | "resourceVersion" : "", 36 | "mediaType": "text/plain; charset=utf-8", 37 | "created": "2023-01-25T12:04:52Z", 38 | "checksum": "cffd829b06797f85407be9353056db722ca3eca0c05ab0462a42d30f19cdef09", 39 | "previousVersionId": null, 40 | "nextVersionId": null 41 | } 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_did_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 3 | "verificationMethod": [ 4 | { 5 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 6 | "type": "Ed25519VerificationKey2020", 7 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 9 | } 10 | ], 11 | "authentication": [ 12 | "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1" 13 | ], 14 | "service": [ 15 | { 16 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", 17 | "type": "LinkedDomains", 18 | "serviceEndpoint": "https://www.cheqd.io" 19 | }, 20 | { 21 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#non-fungible-image", 22 | "type": "LinkedDomains", 23 | "serviceEndpoint": "https://gateway.ipfs.io/ipfs/bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe" 24 | }, 25 | { 26 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#twitter", 27 | "type": "LinkedDomains", 28 | "serviceEndpoint": [ 29 | "https://twitter.com/cheqd_io" 30 | ] 31 | }, 32 | { 33 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#linkedin", 34 | "type": "LinkedDomains", 35 | "serviceEndpoint": [ 36 | "https://www.linkedin.com/company/cheqd-identity/" 37 | ] 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_escaped_am.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didDocument": { 4 | "@context": [ 5 | "https://www.w3.org/ns/did/v1", 6 | "https://w3id.org/security/suites/ed25519-2018/v1" 7 | ], 8 | "id": "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9", 9 | "controller": [ 10 | "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9" 11 | ], 12 | "verificationMethod": [ 13 | { 14 | "id": "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9#auth", 15 | "type": "Ed25519VerificationKey2018", 16 | "controller": "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9", 17 | "publicKeyBase58": "AyBW3mFr5uHNkxrwW191nNBySWRTY1e6vDnzrQ3JfbpY" 18 | } 19 | ], 20 | "authentication": [ 21 | "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9#auth" 22 | ], 23 | "assertionMethod": [ 24 | { 25 | "id": "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9#key-1", 26 | "type": "Bls12381G2Key2020", 27 | "controller": "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9", 28 | "publicKeyBase58": "248ZvAYDLDjwSVkRZ562R7FBcwZYJj8noBHk5Ny3Vs3SyoY48YgVZYY3KLhyUpD6BLE57eRmFzesVZ5kaDXdEG7HzZsCA5PWkDgZj39ExoZPLDnDr2UstJ6PhZmXocQUaTZr" 29 | } 30 | ] 31 | }, 32 | "didResolutionMetadata": { 33 | "contentType": "application/did", 34 | "retrieved": "2025-03-24T07:07:43Z", 35 | "did": { 36 | "didString": "did:cheqd:testnet:8667d3ad-427d-4061-b547-6a1cd2f781b9", 37 | "methodSpecificId": "8667d3ad-427d-4061-b547-6a1cd2f781b9", 38 | "method": "cheqd" 39 | } 40 | }, 41 | "didDocumentMetadata": { 42 | "created": "2025-03-16T23:20:04Z", 43 | "versionId": "a5c52420-b606-47f9-9cd9-3c6b6c0d572a" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_indy_mainnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-22T11:16:34Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://identity.foundation/.well-known/did-configuration/v1", 16 | "https://w3id.org/security/suites/ed25519-2020/v1" 17 | ], 18 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 19 | "verificationMethod": [ 20 | { 21 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 22 | "type": "Ed25519VerificationKey2020", 23 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 24 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 25 | } 26 | ], 27 | "authentication": ["did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1"], 28 | "service": [ 29 | { 30 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", 31 | "type": "LinkedDomains", 32 | "serviceEndpoint": "https://www.cheqd.io" 33 | }, 34 | { 35 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#non-fungible-image", 36 | "type": "LinkedDomains", 37 | "serviceEndpoint": [ 38 | "https://gateway.ipfs.io/ipfs/bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe" 39 | ] 40 | }, 41 | { 42 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#twitter", 43 | "type": "LinkedDomains", 44 | "serviceEndpoint": "https://twitter.com/cheqd_io" 45 | }, 46 | { 47 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#linkedin", 48 | "type": "LinkedDomains", 49 | "serviceEndpoint": "https://www.linkedin.com/company/cheqd-identity/" 50 | } 51 | ] 52 | }, 53 | "didDocumentMetadata": { 54 | "created": "2022-04-05T11:49:19Z", 55 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_indy_mainnet_did_ld.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": [ 3 | "https://www.w3.org/ns/did/v1", 4 | "https://identity.foundation/.well-known/did-configuration/v1", 5 | "https://w3id.org/security/suites/ed25519-2020/v1" 6 | ], 7 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "verificationMethod": [ 9 | { 10 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 11 | "type": "Ed25519VerificationKey2020", 12 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 13 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 14 | } 15 | ], 16 | "authentication": ["did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1"], 17 | "service": [ 18 | { 19 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", 20 | "type": "LinkedDomains", 21 | "serviceEndpoint": "https://www.cheqd.io" 22 | }, 23 | { 24 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#non-fungible-image", 25 | "type": "LinkedDomains", 26 | "serviceEndpoint": [ 27 | "https://gateway.ipfs.io/ipfs/bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe" 28 | ] 29 | }, 30 | { 31 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#twitter", 32 | "type": "LinkedDomains", 33 | "serviceEndpoint": "https://twitter.com/cheqd_io" 34 | }, 35 | { 36 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#linkedin", 37 | "type": "LinkedDomains", 38 | "serviceEndpoint": ["https://www.linkedin.com/company/cheqd-identity/"] 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_indy_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-22T11:39:31Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 8 | "methodSpecificId": "73wnEyHhkhXiH1Nq7w5Kgq", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/ed25519-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 18 | "controller": [ 19 | "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq#key-1", 24 | "type": "Ed25519VerificationKey2020", 25 | "controller": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 26 | "publicKeyMultibase": "z6Mkfx6xXBoMp73M5AhR4coRMFDUG3RLxV8hb6p2fZtgEimA" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq#key-1" 31 | ] 32 | }, 33 | "didDocumentMetadata": { 34 | "created": "2022-08-18T14:12:51Z", 35 | "versionId": "60bb3b62-e0f0-545b-a552-63aab5cd1aef" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_multiservice_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-22T11:44:52Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:fbe4fe88-69e2-44f1-8f97-3f7634eccfae", 8 | "methodSpecificId": "fbe4fe88-69e2-44f1-8f97-3f7634eccfae", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/ed25519-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:fbe4fe88-69e2-44f1-8f97-3f7634eccfae", 18 | "controller": [ 19 | "did:cheqd:testnet:fbe4fe88-69e2-44f1-8f97-3f7634eccfae" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:fbe4fe88-69e2-44f1-8f97-3f7634eccfae#key-1", 24 | "type": "Ed25519VerificationKey2020", 25 | "controller": "did:cheqd:testnet:fbe4fe88-69e2-44f1-8f97-3f7634eccfae", 26 | "publicKeyMultibase": "z6MkeowWakpyqF7WSDs5Mn18LBqoPumEVAr4km9ZahAEkL2i" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:fbe4fe88-69e2-44f1-8f97-3f7634eccfae#key-1" 31 | ], 32 | "service": [ 33 | { 34 | "id": "did:cheqd:testnet:fbe4fe88-69e2-44f1-8f97-3f7634eccfae#service-1", 35 | "type": "EndpointArray", 36 | "serviceEndpoint": [ 37 | "http://endpoint1.com:3002", 38 | "http://endpoint2.com:3002" 39 | ] 40 | } 41 | ] 42 | }, 43 | "didDocumentMetadata": { 44 | "created": "2025-05-19T14:42:12Z", 45 | "updated": "2025-05-19T14:43:58Z", 46 | "versionId": "fe031842-b1a3-4021-a47f-cdaad5c1ff91", 47 | "previousVersionId": "3bec0fcf-5fa7-4c59-b044-6b787ab2f4c6" 48 | } 49 | } -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_old_16_indy_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-03T10:45:46Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 18 | "controller": [ 19 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 24 | "type": "JsonWebKey2020", 25 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 26 | "publicKeyJwk": { 27 | "crv": "Ed25519", 28 | "kty": "OKP", 29 | "x": "-i4BlSGbjoUqmqRePrQhBvHbvqrrQjVIDL_lAoceRGw" 30 | } 31 | } 32 | ], 33 | "authentication": [ 34 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 35 | ], 36 | "assertionMethod": [ 37 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 38 | ] 39 | }, 40 | "didDocumentMetadata": { 41 | "created": "2022-10-13T06:09:04Z", 42 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc/diddoc_version_did_ld.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": [ 3 | "https://www.w3.org/ns/did/v1", 4 | "https://w3id.org/security/suites/ed25519-2018/v1" 5 | ], 6 | "id": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 7 | "verificationMethod": [ 8 | { 9 | "id": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c#key-1", 10 | "type": "Ed25519VerificationKey2018", 11 | "controller": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 12 | "publicKeyBase58": "BpVGbTeT26LipAdk26DBZrmJx2939i9gZS5VxGt1zZQ6" 13 | } 14 | ], 15 | "authentication": [ 16 | "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c#key-1" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_fragment/service_endpoint_did_fragment.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-03-27T07:01:21Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1" 15 | ], 16 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", 17 | "type": "LinkedDomains", 18 | "serviceEndpoint": "https://www.cheqd.io" 19 | }, 20 | "contentMetadata": { 21 | "created": "2022-04-05T11:49:19Z", 22 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_fragment/service_endpoint_did_fragment_did_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "dereferencingMetadata": { 3 | "contentType": "application/did+json", 4 | "retrieved": "2023-04-06T08:38:18Z", 5 | "did": { 6 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 7 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "method": "cheqd" 9 | } 10 | }, 11 | "contentStream": { 12 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", 13 | "type": "LinkedDomains", 14 | "serviceEndpoint": "https://www.cheqd.io" 15 | }, 16 | "contentMetadata": { 17 | "created": "2022-04-05T11:49:19Z", 18 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_fragment/verification_method_did_fragment.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-03-23T12:26:03Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1" 15 | ], 16 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 17 | "type": "Ed25519VerificationKey2020", 18 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 19 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 20 | }, 21 | "contentMetadata": { 22 | "created": "2022-04-05T11:49:19Z", 23 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_fragment/verification_method_did_fragment_did_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "dereferencingMetadata": { 3 | "contentType": "application/did+json", 4 | "retrieved": "2023-04-04T07:09:52Z", 5 | "did": { 6 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 7 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "method": "cheqd" 9 | } 10 | }, 11 | "contentStream": { 12 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 13 | "type": "Ed25519VerificationKey2020", 14 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 15 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 16 | }, 17 | "contentMetadata": { 18 | "created": "2022-04-05T11:49:19Z", 19 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_fragment/verification_method_did_fragment_json_ld.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-04T07:13:07Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1" 15 | ], 16 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 17 | "type": "Ed25519VerificationKey2020", 18 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 19 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 20 | }, 21 | "contentMetadata": { 22 | "created": "2022-04-05T11:49:19Z", 23 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_fragment/verification_method_old_16_did_fragment.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-03T10:54:17Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1" 15 | ], 16 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 17 | "type": "JsonWebKey2020", 18 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 19 | "publicKeyJwk": { 20 | "crv": "Ed25519", 21 | "kty": "OKP", 22 | "x": "-i4BlSGbjoUqmqRePrQhBvHbvqrrQjVIDL_lAoceRGw" 23 | } 24 | }, 25 | "contentMetadata": { 26 | "created": "2022-10-13T06:09:04Z", 27 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_fragment/verification_method_old_32_did_fragment.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-03T11:17:14Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:3KpiDD6Hxs4i2G7FtpiGhu", 8 | "methodSpecificId": "3KpiDD6Hxs4i2G7FtpiGhu", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1" 15 | ], 16 | "id": "did:cheqd:testnet:3KpiDD6Hxs4i2G7FtpiGhu#key-1", 17 | "type": "Ed25519VerificationKey2020", 18 | "controller": "did:cheqd:testnet:3KpiDD6Hxs4i2G7FtpiGhu", 19 | "publicKeyMultibase": "z6MktNQJ7YCFUBk7Q6VAD9jnUfgYcxwXstGdoALbME9QSTL3" 20 | }, 21 | "contentMetadata": { 22 | "created": "2022-10-12T08:57:25Z", 23 | "versionId": "1dc202d4-26ee-54a9-b091-8d2e1f609722" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version/diddoc_version_indy_mainnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-24T12:50:08Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://identity.foundation/.well-known/did-configuration/v1", 16 | "https://w3id.org/security/suites/ed25519-2020/v1" 17 | ], 18 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 19 | "verificationMethod": [ 20 | { 21 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 22 | "type": "Ed25519VerificationKey2020", 23 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 24 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 25 | } 26 | ], 27 | "authentication": ["did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1"], 28 | "service": [ 29 | { 30 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", 31 | "type": "LinkedDomains", 32 | "serviceEndpoint": "https://www.cheqd.io" 33 | }, 34 | { 35 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#non-fungible-image", 36 | "type": "LinkedDomains", 37 | "serviceEndpoint": [ 38 | "https://gateway.ipfs.io/ipfs/bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe" 39 | ] 40 | }, 41 | { 42 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#twitter", 43 | "type": "LinkedDomains", 44 | "serviceEndpoint": "https://twitter.com/cheqd_io" 45 | }, 46 | { 47 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#linkedin", 48 | "type": "LinkedDomains", 49 | "serviceEndpoint": ["https://www.linkedin.com/company/cheqd-identity/"] 50 | } 51 | ] 52 | }, 53 | "didDocumentMetadata": { 54 | "created": "2022-04-05T11:49:19Z", 55 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version/diddoc_version_indy_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-24T12:53:42Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 8 | "methodSpecificId": "73wnEyHhkhXiH1Nq7w5Kgq", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/ed25519-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 18 | "controller": [ 19 | "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq#key-1", 24 | "type": "Ed25519VerificationKey2020", 25 | "controller": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 26 | "publicKeyMultibase": "z6Mkfx6xXBoMp73M5AhR4coRMFDUG3RLxV8hb6p2fZtgEimA" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq#key-1" 31 | ] 32 | }, 33 | "didDocumentMetadata": { 34 | "created": "2022-08-18T14:12:51Z", 35 | "versionId": "60bb3b62-e0f0-545b-a552-63aab5cd1aef" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version/diddoc_version_old_16_indy_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-03T16:59:25Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 18 | "controller": [ 19 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 24 | "type": "JsonWebKey2020", 25 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 26 | "publicKeyJwk": { 27 | "crv": "Ed25519", 28 | "kty": "OKP", 29 | "x": "-i4BlSGbjoUqmqRePrQhBvHbvqrrQjVIDL_lAoceRGw" 30 | } 31 | } 32 | ], 33 | "authentication": [ 34 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 35 | ], 36 | "assertionMethod": [ 37 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 38 | ] 39 | }, 40 | "didDocumentMetadata": { 41 | "created": "2022-10-13T06:09:04Z", 42 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version_metadata/diddoc_did_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "didResolutionMetadata": { 3 | "contentType": "application/did+json", 4 | "retrieved": "2023-04-05T16:00:45Z", 5 | "did": { 6 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 7 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "method": "cheqd" 9 | } 10 | }, 11 | "didDocumentMetadata": { 12 | "created": "2023-01-25T11:58:10Z", 13 | "versionId": "e5615fc2-6f13-42b1-989c-49576a574cef", 14 | "linkedResourceMetadata": [ 15 | { 16 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 17 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 18 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 19 | "resourceName": "Demo Resource", 20 | "resourceType": "String", 21 | "resourceVersion": "", 22 | "mediaType": "application/json", 23 | "created": "2023-01-25T12:08:39Z", 24 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 25 | "previousVersionId": null, 26 | "nextVersionId": null 27 | }, 28 | { 29 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/e733ebb7-c8dd-41ed-9d42-33bceea70952", 30 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 31 | "resourceId": "e733ebb7-c8dd-41ed-9d42-33bceea70952", 32 | "resourceName": "ResourceName", 33 | "resourceType": "String", 34 | "resourceVersion": "", 35 | "mediaType": "text/plain; charset=utf-8", 36 | "created": "2023-01-25T12:04:52Z", 37 | "checksum": "cffd829b06797f85407be9353056db722ca3eca0c05ab0462a42d30f19cdef09", 38 | "previousVersionId": null, 39 | "nextVersionId": null 40 | } 41 | ] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version_metadata/diddoc_indy_mainnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-26T13:33:59Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2022-04-05T11:49:19Z", 14 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version_metadata/diddoc_indy_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-26T13:35:22Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 8 | "methodSpecificId": "73wnEyHhkhXiH1Nq7w5Kgq", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2022-08-18T14:12:51Z", 14 | "versionId": "60bb3b62-e0f0-545b-a552-63aab5cd1aef" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version_metadata/diddoc_old_16_indy_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-03T11:22:58Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2022-10-13T06:09:04Z", 14 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_version_metadata/diddoc_uuid_testnet_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-03-27T02:58:18Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2023-01-25T11:58:10Z", 14 | "versionId": "e5615fc2-6f13-42b1-989c-49576a574cef", 15 | "linkedResourceMetadata": [ 16 | { 17 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 18 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 19 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 20 | "resourceName": "Demo Resource", 21 | "resourceType": "String", 22 | "resourceVersion": "", 23 | "mediaType": "application/json", 24 | "created": "2023-01-25T12:08:39Z", 25 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 26 | "previousVersionId": null, 27 | "nextVersionId": null 28 | }, 29 | { 30 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/e733ebb7-c8dd-41ed-9d42-33bceea70952", 31 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 32 | "resourceId": "e733ebb7-c8dd-41ed-9d42-33bceea70952", 33 | "resourceName": "ResourceName", 34 | "resourceType": "String", 35 | "resourceVersion": "", 36 | "mediaType": "text/plain; charset=utf-8", 37 | "created": "2023-01-25T12:04:52Z", 38 | "checksum": "cffd829b06797f85407be9353056db722ca3eca0c05ab0462a42d30f19cdef09", 39 | "previousVersionId": null, 40 | "nextVersionId": null 41 | } 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_versions/diddoc_versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-03T08:00:19Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:73wnEyHhkhXiH1Nq7w5Kgq", 8 | "methodSpecificId": "73wnEyHhkhXiH1Nq7w5Kgq", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "versions": [ 14 | { 15 | "created": "2022-08-18T14:12:51Z", 16 | "versionId": "60bb3b62-e0f0-545b-a552-63aab5cd1aef" 17 | } 18 | ] 19 | }, 20 | "contentMetadata": {} 21 | } 22 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/diddoc_versions/diddoc_versions_old_16_indy_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-03T11:30:45Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "versions": [ 14 | { 15 | "created": "2022-10-13T06:09:04Z", 16 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 17 | } 18 | ] 19 | }, 20 | "contentMetadata": {} 21 | } 22 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/checksum/resource_32_indy_did_checksum.json: -------------------------------------------------------------------------------- 1 | {"AnonCredsSchema":{"attr_names":["name","age","degree"],"name":"FaberCollege301071f2-314d-49e4-8e65-393586e5e05a","version":"1.0"},"AnonCredsObjectMetadata":{"objectFamily":"anoncreds","objectFamilyVersion":"v2","objectType":"2","objectURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/f31c68e6-61b5-4926-a932-40a13b4c4507","publisherDid":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12","legacyObjectId":"3iYPVcRcz1oJE8EmSTkwpX:2:FaberCollege301071f2-314d-49e4-8e65-393586e5e05a:1.0"}} 2 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/checksum/resource_checksum.json: -------------------------------------------------------------------------------- 1 | "{ \"content\": \"test data\" }" 2 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/collection_id/metadata_32_indy_did.json: -------------------------------------------------------------------------------- 1 | {"AnonCredsRevRegEntry":{"ver":"1.0","value":{"accum":"21 131A01666B8FB55DAC5EA8FC195BBF4A88902D3E349FEC3E0601F33D21A10063D 21 11C2B4E311432AC2EDAFD2940496E915237B5A112558C8F32DC747FA266EDE150 6 70642801694BBD5A30C98B2772213BFD966895735CBB367D224D2D27A201B4B2 4 1A781D7DDA945F1541023C7647170189BB8A30463FB0547E84B75522DF841437 6 5660118E9DA72C04F44F39180D966F00D4C8603CCEC4BB273D1E2A8B2A0CAA6A 4 1C54B5AE99FDE1C8711135BD92DBC68206AE7149EC0D2EAC22C5031DE81AA78A","revoked":[10,1,12]}},"AnonCredsObjectMetadata":{"objectFamily":"anoncreds","objectFamilyVersion":"v2","objectType":"5","objectURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/7c20c558-9b0b-46c3-a095-79861828b35a","publisherDid":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12","legacyObjectId":"3iYPVcRcz1oJE8EmSTkwpX:4:3iYPVcRcz1oJE8EmSTkwpX:3:CL:8:Degree301071f2-314d-49e4-8e65-393586e5e05a:CL_ACCUM:43773793-9304-4677-8444-389468710263","objectDefinitionURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/83205e1a-f474-448d-bf4b-816fe2aabd84"}} 2 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/collection_id/metadata_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "test data" 3 | } 4 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/diddoc/diddoc_version_16_old_indy_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-20T15:03:41Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 18 | "controller": [ 19 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 24 | "type": "JsonWebKey2020", 25 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 26 | "publicKeyJwk": { 27 | "crv": "Ed25519", 28 | "kty": "OKP", 29 | "x": "-i4BlSGbjoUqmqRePrQhBvHbvqrrQjVIDL_lAoceRGw" 30 | } 31 | } 32 | ], 33 | "authentication": [ 34 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 35 | ], 36 | "assertionMethod": [ 37 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 38 | ] 39 | }, 40 | "didDocumentMetadata": { 41 | "created": "2022-10-13T06:09:04Z", 42 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/diddoc/diddoc_version_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-21T08:19:44Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 8 | "methodSpecificId": "b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/ed25519-2018/v1" 16 | ], 17 | "id": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 18 | "verificationMethod": [ 19 | { 20 | "id": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c#key-1", 21 | "type": "Ed25519VerificationKey2018", 22 | "controller": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 23 | "publicKeyBase58": "BpVGbTeT26LipAdk26DBZrmJx2939i9gZS5VxGt1zZQ6" 24 | } 25 | ], 26 | "authentication": [ 27 | "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c#key-1" 28 | ] 29 | }, 30 | "didDocumentMetadata": { 31 | "created": "2023-03-06T09:36:55Z", 32 | "deactivated": true, 33 | "versionId": "0ce23d04-5b67-4ea6-a315-788588e53f4e", 34 | "nextVersionId": "ce298b6f-594b-426e-b431-370d6bc5d3ad" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/diddoc_common/metadata/version_id.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-25T10:04:17Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 8 | "methodSpecificId": "b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2023-03-06T09:36:55Z", 14 | "deactivated": true, 15 | "versionId": "0ce23d04-5b67-4ea6-a315-788588e53f4e", 16 | "nextVersionId": "ce298b6f-594b-426e-b431-370d6bc5d3ad" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/diddoc_common/metadata/version_id_&_version_time.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-25T10:08:48Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 8 | "methodSpecificId": "b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2023-03-06T09:36:55Z", 14 | "deactivated": true, 15 | "versionId": "0ce23d04-5b67-4ea6-a315-788588e53f4e", 16 | "nextVersionId": "ce298b6f-594b-426e-b431-370d6bc5d3ad" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/diddoc_common/metadata/version_time.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-25T10:05:13Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 8 | "methodSpecificId": "b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2023-03-06T09:36:55Z", 14 | "updated": "2023-03-06T09:39:48Z", 15 | "deactivated": true, 16 | "versionId": "ce298b6f-594b-426e-b431-370d6bc5d3ad", 17 | "nextVersionId": "f790c9b9-4817-4b31-be43-b198e6e18071", 18 | "previousVersionId": "0ce23d04-5b67-4ea6-a315-788588e53f4e", 19 | "linkedResourceMetadata": [ 20 | { 21 | "resourceURI": "did:cheqd:testnet:b5d70adf-31ca-4662-aa10-d3a54cd8f06c/resources/5e16a3f9-7c6e-4b6b-8e28-20f56780ee25", 22 | "resourceCollectionId": "b5d70adf-31ca-4662-aa10-d3a54cd8f06c", 23 | "resourceId": "5e16a3f9-7c6e-4b6b-8e28-20f56780ee25", 24 | "resourceName": "TestResource", 25 | "resourceType": "TestType", 26 | "mediaType": "text/plain; charset=utf-8", 27 | "resourceVersion": "1.0", 28 | "created": "2023-03-06T09:53:44Z", 29 | "checksum": "64ec88ca00b268e5ba1a35678a1b5316d212f4f366b2477232534a8aeca37f3c", 30 | "previousVersionId": null, 31 | "nextVersionId": null 32 | } 33 | ] 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/metadata/diddoc_16_old_indy_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-24T11:03:24Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2022-10-13T06:09:04Z", 14 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/metadata/diddoc_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-06-15T08:10:37Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://identity.foundation/.well-known/did-configuration/v1", 16 | "https://w3id.org/security/suites/ed25519-2020/v1" 17 | ], 18 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 19 | "verificationMethod": [ 20 | { 21 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1", 22 | "type": "Ed25519VerificationKey2020", 23 | "controller": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 24 | "publicKeyMultibase": "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA" 25 | } 26 | ], 27 | "authentication": ["did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#key1"], 28 | "service": [ 29 | { 30 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#website", 31 | "type": "LinkedDomains", 32 | "serviceEndpoint": "https://www.cheqd.io" 33 | }, 34 | { 35 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#non-fungible-image", 36 | "type": "LinkedDomains", 37 | "serviceEndpoint": [ 38 | "https://gateway.ipfs.io/ipfs/bafybeihetj2ng3d74k7t754atv2s5dk76pcqtvxls6dntef3xa6rax25xe" 39 | ] 40 | }, 41 | { 42 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#twitter", 43 | "type": "LinkedDomains", 44 | "serviceEndpoint": "https://twitter.com/cheqd_io" 45 | }, 46 | { 47 | "id": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN#linkedin", 48 | "type": "LinkedDomains", 49 | "serviceEndpoint": ["https://www.linkedin.com/company/cheqd-identity/"] 50 | } 51 | ] 52 | }, 53 | "didDocumentMetadata": { 54 | "created": "2022-04-05T11:49:19Z", 55 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/metadata/diddoc_metadata_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-24T10:59:35Z", 6 | "did": { 7 | "didString": "did:cheqd:mainnet:Ps1ysXP2Ae6GBfxNhNQNKN", 8 | "methodSpecificId": "Ps1ysXP2Ae6GBfxNhNQNKN", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocumentMetadata": { 13 | "created": "2022-04-05T11:49:19Z", 14 | "versionId": "4fa8e367-c70e-533e-babf-3732d9761061" 15 | } 16 | } -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_common/resource_combination_of_queries_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "test data" 3 | } 4 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_id/resource.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "test data" 3 | } 4 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_id/resource_32_indy_did.json: -------------------------------------------------------------------------------- 1 | {"AnonCredsRevRegEntry":{"ver":"1.0","value":{"accum":"21 108D8E1B28C2561E2A81B18332CDB52731257BDD08803DE3FB11C120C97F1D7E7 21 13917841F0317F61D7D0D1432B995D865AD73DBF00359F46AF5B0D370A4C98601 6 692A9339175646D8D6A6663011DEB16C4651D4BB16F0F78F24D3ED0D34B85652 4 40A8B043F710B12154CF3DDCFDF2342B1E76844FBADB229D879A52C45C84A075 6 811DB35E4CAC0A656CB5BDDD615478EEED19F59F6CA626A0A3386D8562EE0AFA 4 1ED0E0C69D5F7BB3C48B53A4689FAC82869C5BE95FC288685178A71537F6EB94","revoked":[10]}},"AnonCredsObjectMetadata":{"objectFamily":"anoncreds","objectFamilyVersion":"v2","objectType":"5","objectURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/214b8b61-a861-416b-a7e4-45533af40ada","publisherDid":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12","legacyObjectId":"3iYPVcRcz1oJE8EmSTkwpX:4:3iYPVcRcz1oJE8EmSTkwpX:3:CL:8:Degree301071f2-314d-49e4-8e65-393586e5e05a:CL_ACCUM:43773793-9304-4677-8444-389468710263","objectDefinitionURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/83205e1a-f474-448d-bf4b-816fe2aabd84"}} 2 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_metadata/metadata_did_res.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2025-02-21T14:48:05Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentMetadata": { 13 | "linkedResourceMetadata": [ 14 | { 15 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 16 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 17 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 18 | "resourceName": "Demo Resource", 19 | "resourceType": "String", 20 | "mediaType": "application/json", 21 | "resourceVersion": "", 22 | "created": "2023-01-25T12:08:39Z", 23 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 24 | "previousVersionId": null, 25 | "nextVersionId": null 26 | }, 27 | { 28 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/e733ebb7-c8dd-41ed-9d42-33bceea70952", 29 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 30 | "resourceId": "e733ebb7-c8dd-41ed-9d42-33bceea70952", 31 | "resourceName": "ResourceName", 32 | "resourceType": "String", 33 | "mediaType": "text/plain; charset=utf-8", 34 | "resourceVersion": "", 35 | "created": "2023-01-25T12:04:52Z", 36 | "checksum": "cffd829b06797f85407be9353056db722ca3eca0c05ab0462a42d30f19cdef09", 37 | "previousVersionId": null, 38 | "nextVersionId": null 39 | } 40 | ] 41 | }, 42 | "contentStream": null 43 | } 44 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_metadata/metadata_false.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2025-02-20T09:59:41Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/ed25519-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 18 | "controller": [ 19 | "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0#key-1", 24 | "type": "Ed25519VerificationKey2020", 25 | "controller": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 26 | "publicKeyMultibase": "z6Mkjhidm3FJxUo4FekqyhXGMqrDLnrw9NtuzfmGQ61UXW1e" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0#key-1" 31 | ] 32 | }, 33 | "didDocumentMetadata": { 34 | "created": "2023-01-25T11:58:10Z", 35 | "versionId": "e5615fc2-6f13-42b1-989c-49576a574cef" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_metadata/metadata_false_ld.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2025-02-20T09:59:41Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/ed25519-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 18 | "controller": [ 19 | "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0#key-1", 24 | "type": "Ed25519VerificationKey2020", 25 | "controller": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 26 | "publicKeyMultibase": "z6Mkjhidm3FJxUo4FekqyhXGMqrDLnrw9NtuzfmGQ61UXW1e" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0#key-1" 31 | ] 32 | }, 33 | "didDocumentMetadata": { 34 | "created": "2023-01-25T11:58:10Z", 35 | "versionId": "e5615fc2-6f13-42b1-989c-49576a574cef" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_name/resource.json: -------------------------------------------------------------------------------- 1 | "{ \"content\": \"test data\" }" 2 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_name/resource_32_indy_did.json: -------------------------------------------------------------------------------- 1 | {"AnonCredsSchema":{"attr_names":["name","age","degree"],"name":"FaberCollege301071f2-314d-49e4-8e65-393586e5e05a","version":"1.0"},"AnonCredsObjectMetadata":{"objectFamily":"anoncreds","objectFamilyVersion":"v2","objectType":"2","objectURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/f31c68e6-61b5-4926-a932-40a13b4c4507","publisherDid":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12","legacyObjectId":"3iYPVcRcz1oJE8EmSTkwpX:2:FaberCollege301071f2-314d-49e4-8e65-393586e5e05a:1.0"}} 2 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_type/resource.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "did:cheqd:testnet:0a5b94d0-a417-48ed-a6f5-4abc9e95888d", 3 | "entries": { 4 | "https://resolver.cheqd.net/1.0/identifiers/did:cheqd:testnet:0a5b94d0-a417-48ed-a6f5-4abc9e95888d/resources/ef344b53-f2db-44bd-9df3-01259c178704": { 5 | "did:cheqd:testnet:181cd85c-ad4e-490c-bdd9-f3349545fbbd": { 6 | "name": "Natural History Museum", 7 | "credentials": [ 8 | "https://resolver.cheqd.net/1.0/identifiers/did:cheqd:testnet:0a5b94d0-a417-48ed-a6f5-4abc9e95888d/resources/ef344b53-f2db-44bd-9df3-01259c178704" 9 | ] 10 | }, 11 | "did:cheqd:testnet:37d23667-265a-4119-b844-ad2d745f5eb3": { 12 | "name": "Science Museum", 13 | "credentials": [ 14 | "https://resolver.cheqd.net/1.0/identifiers/did:cheqd:testnet:0a5b94d0-a417-48ed-a6f5-4abc9e95888d/resources/ef344b53-f2db-44bd-9df3-01259c178704" 15 | ] 16 | }, 17 | "did:cheqd:testnet:cf61fcfa-fa7d-4670-905b-c6a7f1579c9d": { 18 | "name": "Victoria and Albert Museum", 19 | "credentials": [ 20 | "https://resolver.cheqd.net/1.0/identifiers/did:cheqd:testnet:0a5b94d0-a417-48ed-a6f5-4abc9e95888d/resources/ef344b53-f2db-44bd-9df3-01259c178704" 21 | ] 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_type/resource_32_indy_did.json: -------------------------------------------------------------------------------- 1 | {"AnonCredsSchema":{"attr_names":["name","age","degree"],"name":"FaberCollege301071f2-314d-49e4-8e65-393586e5e05a","version":"1.0"},"AnonCredsObjectMetadata":{"objectFamily":"anoncreds","objectFamilyVersion":"v2","objectType":"2","objectURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/f31c68e6-61b5-4926-a932-40a13b4c4507","publisherDid":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12","legacyObjectId":"3iYPVcRcz1oJE8EmSTkwpX:2:FaberCollege301071f2-314d-49e4-8e65-393586e5e05a:1.0"}} 2 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_version_time/resource.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-28T08:30:17Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentMetadata": { 13 | "linkedResourceMetadata": [ 14 | { 15 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 16 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 17 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 18 | "resourceName": "Demo Resource", 19 | "resourceType": "String", 20 | "mediaType": "application/json", 21 | "resourceVersion": "", 22 | "created": "2023-01-25T12:08:39Z", 23 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 24 | "previousVersionId": null, 25 | "nextVersionId": null 26 | }, 27 | { 28 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/e733ebb7-c8dd-41ed-9d42-33bceea70952", 29 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 30 | "resourceId": "e733ebb7-c8dd-41ed-9d42-33bceea70952", 31 | "resourceName": "ResourceName", 32 | "resourceType": "String", 33 | "mediaType": "text/plain; charset=utf-8", 34 | "resourceVersion": "", 35 | "created": "2023-01-25T12:04:52Z", 36 | "checksum": "cffd829b06797f85407be9353056db722ca3eca0c05ab0462a42d30f19cdef09", 37 | "previousVersionId": null, 38 | "nextVersionId": null 39 | } 40 | ] 41 | }, 42 | "contentStream": null 43 | } 44 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/resource_version_time/resource_32_indy_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-28T08:31:32Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:3KpiDD6Hxs4i2G7FtpiGhu", 8 | "methodSpecificId": "3KpiDD6Hxs4i2G7FtpiGhu", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentMetadata": { 13 | "linkedResourceMetadata": [ 14 | { 15 | "resourceURI": "did:cheqd:testnet:3KpiDD6Hxs4i2G7FtpiGhu/resources/f31c68e6-61b5-4926-a932-40a13b4c4507", 16 | "resourceCollectionId": "3KpiDD6Hxs4i2G7FtpiGhu", 17 | "resourceId": "f31c68e6-61b5-4926-a932-40a13b4c4507", 18 | "resourceName": "FaberCollege301071f2-314d-49e4-8e65-393586e5e05a", 19 | "resourceType": "CL-Schema", 20 | "mediaType": "application/json", 21 | "resourceVersion": "", 22 | "created": "2022-10-12T08:57:31Z", 23 | "checksum": "657e37a833f139fc8f58b115174b2297223a2d98316a78ce8d49d60467d8913d", 24 | "previousVersionId": null, 25 | "nextVersionId": null 26 | } 27 | ] 28 | }, 29 | "contentStream": null 30 | } 31 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/transform_key/diddoc_jwk_2020_to_ed25519_2018.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-17T11:12:27Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 8 | "methodSpecificId": "54c96733-32ad-4878-b7ce-f62f4fdf3291", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 18 | "controller": [ 19 | "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291#key-1", 24 | "type": "Ed25519VerificationKey2018", 25 | "controller": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 26 | "publicKeyBase58": "GagrZ3tmrK6uHkqiP5UxCcdXVAVRHRwcEedcJTwNrgmz" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291#key-1" 31 | ] 32 | }, 33 | "didDocumentMetadata": { 34 | "created": "2022-10-26T10:13:46Z", 35 | "versionId": "6e52097d-8257-51af-9862-8a31140b6c2c" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/transform_key/diddoc_jwk_2020_to_ed25519_2020.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-17T11:18:18Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 8 | "methodSpecificId": "54c96733-32ad-4878-b7ce-f62f4fdf3291", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 18 | "controller": [ 19 | "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291#key-1", 24 | "type": "Ed25519VerificationKey2020", 25 | "controller": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 26 | "publicKeyMultibase": "z6Mkv2wu9J9DBrbNQFgR4eSo3iBXJjmGhKBxvfYY8juPmuZN" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291#key-1" 31 | ] 32 | }, 33 | "didDocumentMetadata": { 34 | "created": "2022-10-26T10:13:46Z", 35 | "versionId": "6e52097d-8257-51af-9862-8a31140b6c2c" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/transform_key/diddoc_jwk_2020_to_jwk_2020.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-17T06:42:38Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 8 | "methodSpecificId": "54c96733-32ad-4878-b7ce-f62f4fdf3291", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 18 | "controller": [ 19 | "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291#key-1", 24 | "type": "JsonWebKey2020", 25 | "controller": "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291", 26 | "publicKeyJwk": { 27 | "crv": "Ed25519", 28 | "kty": "OKP", 29 | "x": "54CIt_4th9Hux9RAT618MWzmCpohV8zps-w3sdEcemU" 30 | } 31 | } 32 | ], 33 | "authentication": [ 34 | "did:cheqd:testnet:54c96733-32ad-4878-b7ce-f62f4fdf3291#key-1" 35 | ] 36 | }, 37 | "didDocumentMetadata": { 38 | "created": "2022-10-26T10:13:46Z", 39 | "versionId": "6e52097d-8257-51af-9862-8a31140b6c2c" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/transform_key/diddoc_old_16_indy_jwk_2020_to_ed25519_2018.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-19T14:15:59Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 18 | "controller": [ 19 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 24 | "type": "Ed25519VerificationKey2018", 25 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 26 | "publicKeyBase58": "HqbcXb3irKRCMstm5nav1dG1qksdDkKjDK41gR5qz64b" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 31 | ], 32 | "assertionMethod": [ 33 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 34 | ] 35 | }, 36 | "didDocumentMetadata": { 37 | "created": "2022-10-13T06:09:04Z", 38 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/transform_key/diddoc_old_16_indy_jwk_2020_to_ed25519_2020.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-19T14:12:22Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 18 | "controller": [ 19 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 24 | "type": "Ed25519VerificationKey2020", 25 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 26 | "publicKeyMultibase": "z6MkwHrf7qJABrufUNjTmMYkrip1fL9Udda5uKxwWh3ruJqy" 27 | } 28 | ], 29 | "authentication": [ 30 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 31 | ], 32 | "assertionMethod": [ 33 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 34 | ] 35 | }, 36 | "didDocumentMetadata": { 37 | "created": "2022-10-13T06:09:04Z", 38 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/transform_key/diddoc_old_16_indy_jwk_2020_to_jwk_2020.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-19T14:16:42Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 18 | "controller": [ 19 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 24 | "type": "JsonWebKey2020", 25 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 26 | "publicKeyJwk": { 27 | "crv": "Ed25519", 28 | "kty": "OKP", 29 | "x": "-i4BlSGbjoUqmqRePrQhBvHbvqrrQjVIDL_lAoceRGw" 30 | } 31 | } 32 | ], 33 | "authentication": [ 34 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 35 | ], 36 | "assertionMethod": [ 37 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 38 | ] 39 | }, 40 | "didDocumentMetadata": { 41 | "created": "2022-10-13T06:09:04Z", 42 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/query/version_time/diddoc_version_time_16_old_indy_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "didResolutionMetadata": { 4 | "contentType": "application/did", 5 | "retrieved": "2023-04-24T10:50:04Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 8 | "methodSpecificId": "CpeMubv5yw63jXyrgRRsxR", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "didDocument": { 13 | "@context": [ 14 | "https://www.w3.org/ns/did/v1", 15 | "https://w3id.org/security/suites/jws-2020/v1" 16 | ], 17 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 18 | "controller": [ 19 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR" 20 | ], 21 | "verificationMethod": [ 22 | { 23 | "id": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1", 24 | "type": "JsonWebKey2020", 25 | "controller": "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR", 26 | "publicKeyJwk": { 27 | "crv": "Ed25519", 28 | "kty": "OKP", 29 | "x": "-i4BlSGbjoUqmqRePrQhBvHbvqrrQjVIDL_lAoceRGw" 30 | } 31 | } 32 | ], 33 | "authentication": [ 34 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 35 | ], 36 | "assertionMethod": [ 37 | "did:cheqd:testnet:CpeMubv5yw63jXyrgRRsxR#key-1" 38 | ] 39 | }, 40 | "didDocumentMetadata": { 41 | "created": "2022-10-13T06:09:04Z", 42 | "versionId": "674e6cb5-8d7c-5c50-b0ff-d91bcbcbd5d6" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_data/resource.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "test data" 3 | } 4 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_data/resource_32_indy_did.json: -------------------------------------------------------------------------------- 1 | {"AnonCredsRevRegEntry":{"ver":"1.0","value":{"accum":"21 108D8E1B28C2561E2A81B18332CDB52731257BDD08803DE3FB11C120C97F1D7E7 21 13917841F0317F61D7D0D1432B995D865AD73DBF00359F46AF5B0D370A4C98601 6 692A9339175646D8D6A6663011DEB16C4651D4BB16F0F78F24D3ED0D34B85652 4 40A8B043F710B12154CF3DDCFDF2342B1E76844FBADB229D879A52C45C84A075 6 811DB35E4CAC0A656CB5BDDD615478EEED19F59F6CA626A0A3386D8562EE0AFA 4 1ED0E0C69D5F7BB3C48B53A4689FAC82869C5BE95FC288685178A71537F6EB94","revoked":[10]}},"AnonCredsObjectMetadata":{"objectFamily":"anoncreds","objectFamilyVersion":"v2","objectType":"5","objectURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/214b8b61-a861-416b-a7e4-45533af40ada","publisherDid":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12","legacyObjectId":"3iYPVcRcz1oJE8EmSTkwpX:4:3iYPVcRcz1oJE8EmSTkwpX:3:CL:8:Degree301071f2-314d-49e4-8e65-393586e5e05a:CL_ACCUM:43773793-9304-4677-8444-389468710263","objectDefinitionURI":"did:cheqd:testnet:zEv9FXHwp8eFeHbeTXamwda8YoPfgU12/resources/83205e1a-f474-448d-bf4b-816fe2aabd84"}} -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_data/resource_hello_world.txt: -------------------------------------------------------------------------------- 1 | Hello world -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_data_with_metadata/resource.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-03-27T03:52:40Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": { 13 | "content": "test data" 14 | }, 15 | "contentMetadata": { 16 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 17 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 18 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 19 | "resourceName": "Demo Resource", 20 | "resourceType": "String", 21 | "resourceVersion" : "", 22 | "mediaType": "application/json", 23 | "created": "2023-01-25T12:08:39Z", 24 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 25 | "previousVersionId": null, 26 | "nextVersionId": null 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_metadata/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-03-27T03:52:40Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": null, 13 | "contentMetadata": { 14 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 15 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 16 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 17 | "resourceName": "Demo Resource", 18 | "resourceType": "String", 19 | "resourceVersion" : "", 20 | "mediaType": "application/json", 21 | "created": "2023-01-25T12:08:39Z", 22 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 23 | "previousVersionId": null, 24 | "nextVersionId": null 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_metadata/metadata_32_indy_did.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/ld+json", 5 | "retrieved": "2023-04-03T11:41:04Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:3KpiDD6Hxs4i2G7FtpiGhu", 8 | "methodSpecificId": "3KpiDD6Hxs4i2G7FtpiGhu", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": null, 13 | "contentMetadata": { 14 | "resourceURI": "did:cheqd:testnet:3KpiDD6Hxs4i2G7FtpiGhu/resources/214b8b61-a861-416b-a7e4-45533af40ada", 15 | "resourceCollectionId": "3KpiDD6Hxs4i2G7FtpiGhu", 16 | "resourceId": "214b8b61-a861-416b-a7e4-45533af40ada", 17 | "resourceName": "RevRegEntry301071f2-314d-49e4-8e65-393586e5e05a", 18 | "resourceType": "CL-RevRegEntry", 19 | "resourceVersion" : "", 20 | "mediaType": "application/json", 21 | "created": "2022-10-12T09:00:02Z", 22 | "checksum": "4bf7d5855a05955f84195f01ef7e8d91353a8895dc5d9022aebbcecc9f2c3dc6", 23 | "previousVersionId": "616be02a-0838-42ee-b906-065fff3799ea", 24 | "nextVersionId": "9f5b2985-990d-4160-94ed-06706043af7e" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_metadata/metadata_did_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "dereferencingMetadata": { 3 | "contentType": "application/did+json", 4 | "retrieved": "2023-04-05T17:09:59Z", 5 | "did": { 6 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 7 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "method": "cheqd" 9 | } 10 | }, 11 | "contentStream": null, 12 | "contentMetadata": { 13 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 14 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 15 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 16 | "resourceName": "Demo Resource", 17 | "resourceType": "String", 18 | "resourceVersion" : "", 19 | "mediaType": "application/json", 20 | "created": "2023-01-25T12:08:39Z", 21 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 22 | "previousVersionId": null, 23 | "nextVersionId": null 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/integration/rest/testdata/resource_metadata/metadata_did_ld.json: -------------------------------------------------------------------------------- 1 | { 2 | "@context": "https://w3id.org/did-resolution/v1", 3 | "dereferencingMetadata": { 4 | "contentType": "application/did+ld+json", 5 | "retrieved": "2023-03-27T03:52:40Z", 6 | "did": { 7 | "didString": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 8 | "methodSpecificId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 9 | "method": "cheqd" 10 | } 11 | }, 12 | "contentStream": null, 13 | "contentMetadata": { 14 | "resourceURI": "did:cheqd:testnet:c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0/resources/9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 15 | "resourceCollectionId": "c1685ca0-1f5b-439c-8eb8-5c0e85ab7cd0", 16 | "resourceId": "9ba3922e-d5f5-4f53-b265-fc0d4e988c77", 17 | "resourceName": "Demo Resource", 18 | "resourceType": "String", 19 | "resourceVersion" : "", 20 | "mediaType": "application/json", 21 | "created": "2023-01-25T12:08:39Z", 22 | "checksum": "e1dbc03b50bdb995961dc8843df6539b79d03bf49787ed6462189ee97d27eaf3", 23 | "previousVersionId": null, 24 | "nextVersionId": null 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/unit/diddoc/common/dereferencing_metadata_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package common 4 | 5 | import ( 6 | "time" 7 | 8 | utils "github.com/cheqd/did-resolver/tests/unit" 9 | "github.com/cheqd/did-resolver/types" 10 | . "github.com/onsi/ginkgo/v2" 11 | . "github.com/onsi/gomega" 12 | ) 13 | 14 | var _ = Describe("DereferencingMetadata", func() { 15 | var versionList types.DidDocMetadataList 16 | 17 | BeforeEach(func() { 18 | _tcreated := utils.MustParseDate("2021-08-23T09:00:00Z") 19 | _t1 := utils.MustParseDate("2021-08-23T09:30:00Z") 20 | _t2 := utils.MustParseDate("2021-08-23T09:40:00Z") 21 | versionList = types.DidDocMetadataList{ 22 | { 23 | VersionId: "1", 24 | Deactivated: false, 25 | Created: &_tcreated, 26 | Updated: nil, 27 | }, 28 | { 29 | VersionId: "2", 30 | Deactivated: false, 31 | Created: &_tcreated, 32 | Updated: &_t1, 33 | }, 34 | { 35 | VersionId: "3", 36 | Deactivated: false, 37 | Created: &_tcreated, 38 | Updated: &_t2, 39 | }, 40 | } 41 | }, 42 | ) 43 | 44 | Context("FindBeforeTime", func() { 45 | // Time right after creation but before first update 46 | It("should return versionId of metadata with created", func() { 47 | Expect(versionList.FindActiveForTime(utils.MustParseDate("2021-08-23T09:00:01Z").Format(time.RFC3339))).To(Equal("1")) 48 | }) 49 | // Time after first update but the the latest 50 | It("should return versionId of metadata with the first updated", func() { 51 | Expect(versionList.FindActiveForTime(utils.MustParseDate("2021-08-23T09:30:01Z").Format(time.RFC3339))).To(Equal("2")) 52 | }) 53 | 54 | It("should return versionId of metadata with the latest updated", func() { 55 | Expect(versionList.FindActiveForTime(utils.MustParseDate("2021-08-23T09:40:01Z").Format(time.RFC3339))).To(Equal("3")) 56 | }) 57 | // Time before the creation 58 | It("should return empty string if no metadata found", func() { 59 | Expect(versionList.FindActiveForTime(utils.MustParseDate("2021-08-23T08:59:59Z").Format(time.RFC3339))).To(Equal("")) 60 | }) 61 | }) 62 | }) 63 | -------------------------------------------------------------------------------- /tests/unit/diddoc/common/diddoc_fragment_service_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package common 4 | 5 | import ( 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | 9 | "github.com/cheqd/did-resolver/services" 10 | testconstants "github.com/cheqd/did-resolver/tests/constants" 11 | ) 12 | 13 | var _ = Describe("Test GetDIDFragment method", func() { 14 | It("can find a existent fragment in VerificationMethod", func() { 15 | fragmentId := testconstants.ValidDIDDocResolution.VerificationMethod[0].Id 16 | expectedFragment := &testconstants.ValidDIDDocResolution.VerificationMethod[0] 17 | 18 | didDocService := services.DIDDocService{} 19 | 20 | fragment := didDocService.GetDIDFragment(fragmentId, testconstants.ValidDIDDocResolution) 21 | Expect(fragment).To(Equal(expectedFragment)) 22 | }) 23 | 24 | It("can find a existent fragment in Service", func() { 25 | fragmentId := testconstants.ValidDIDDocResolution.Service[0].Id 26 | expectedFragment := &testconstants.ValidDIDDocResolution.Service[0] 27 | 28 | didDocService := services.DIDDocService{} 29 | 30 | fragment := didDocService.GetDIDFragment(fragmentId, testconstants.ValidDIDDocResolution) 31 | Expect(fragment).To(Equal(expectedFragment)) 32 | }) 33 | 34 | It("cannot find a not-existent fragment", func() { 35 | didDocService := services.DIDDocService{} 36 | 37 | fragment := didDocService.GetDIDFragment(testconstants.NotExistentFragment, testconstants.ValidDIDDocResolution) 38 | Expect(fragment).To(BeNil()) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /tests/unit/diddoc/common/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package common_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestCommon(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Unit Test]: DIDDoc common methods and functions") 15 | } 16 | -------------------------------------------------------------------------------- /tests/unit/diddoc/common/supported_queries_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package common 4 | 5 | import ( 6 | "github.com/cheqd/did-resolver/types" 7 | . "github.com/onsi/ginkgo/v2" 8 | . "github.com/onsi/gomega" 9 | ) 10 | 11 | var _ = Describe("Diff with values tests", func() { 12 | It("returns empty list if all values are supported", func() { 13 | supportedQueries := types.SupportedQueriesT{"a", "b", "c"} 14 | values := map[string][]string{ 15 | "a": {"1"}, 16 | "b": {"2"}, 17 | "c": {"3"}, 18 | } 19 | 20 | result := supportedQueries.DiffWithUrlValues(values) 21 | Expect(result).To(BeEmpty()) 22 | }) 23 | 24 | It("returns list with unsupported values", func() { 25 | supportedQueries := types.SupportedQueriesT{"a", "b", "c"} 26 | values := map[string][]string{ 27 | "a": {"1"}, 28 | "b": {"2"}, 29 | "c": {"3"}, 30 | "d": {"4"}, 31 | } 32 | 33 | result := supportedQueries.DiffWithUrlValues(values) 34 | Expect(result).To(Equal([]string{"d"})) 35 | }) 36 | }) 37 | -------------------------------------------------------------------------------- /tests/unit/diddoc/ledger/query_all_did_doc_versions_ledger_service_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package ledger 4 | 5 | import ( 6 | testconstants "github.com/cheqd/did-resolver/tests/constants" 7 | utils "github.com/cheqd/did-resolver/tests/unit" 8 | "github.com/cheqd/did-resolver/types" 9 | . "github.com/onsi/ginkgo/v2" 10 | . "github.com/onsi/gomega" 11 | ) 12 | 13 | type queryDIDDocVersionsTestCase struct { 14 | did string 15 | expectedDidDocVersions *types.DereferencedDidVersionsList 16 | expectedError *types.IdentityError 17 | } 18 | 19 | var _ = DescribeTable("Test QueryAllDidDocVersionsMetadata method", func(testCase queryDIDDocVersionsTestCase) { 20 | didDocMetadata, err := utils.MockLedger.QueryAllDidDocVersionsMetadata(testCase.did) 21 | didDocVersions := types.NewDereferencedDidVersionsList(testCase.did, didDocMetadata, nil) 22 | if err != nil { 23 | Expect(testCase.expectedError.Code).To(Equal(err.Code)) 24 | Expect(testCase.expectedError.Message).To(Equal(err.Message)) 25 | } else { 26 | Expect(testCase.expectedError).To(BeNil()) 27 | Expect(testCase.expectedDidDocVersions).To(Equal(didDocVersions)) 28 | } 29 | }, 30 | 31 | Entry( 32 | "can get DIDDoc versions with an existent DID", 33 | queryDIDDocVersionsTestCase{ 34 | did: testconstants.ExistentDid, 35 | expectedDidDocVersions: &types.DereferencedDidVersionsList{ 36 | Versions: []types.ResolutionDidDocMetadata{ 37 | { 38 | Created: &testconstants.ValidCreated, 39 | VersionId: testconstants.ValidMetadata.VersionId, 40 | NextVersionId: "", 41 | PreviousVersionId: "", 42 | }, 43 | }, 44 | }, 45 | expectedError: nil, 46 | }, 47 | ), 48 | 49 | Entry( 50 | "cannot get DIDDoc versions with not existent DID", 51 | queryDIDDocVersionsTestCase{ 52 | did: testconstants.NotExistentTestnetDid, 53 | expectedDidDocVersions: nil, 54 | expectedError: types.NewNotFoundError(testconstants.NotExistentTestnetDid, types.JSON, nil, true), 55 | }, 56 | ), 57 | ) 58 | -------------------------------------------------------------------------------- /tests/unit/diddoc/ledger/query_did_doc_ledger_service_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package ledger 4 | 5 | import ( 6 | . "github.com/onsi/ginkgo/v2" 7 | . "github.com/onsi/gomega" 8 | 9 | didTypes "github.com/cheqd/cheqd-node/api/v2/cheqd/did/v2" 10 | testconstants "github.com/cheqd/did-resolver/tests/constants" 11 | utils "github.com/cheqd/did-resolver/tests/unit" 12 | "github.com/cheqd/did-resolver/types" 13 | ) 14 | 15 | type queryDIDDocTestCase struct { 16 | did string 17 | expectedDidDocWithMetadata *didTypes.DidDocWithMetadata 18 | expectedError *types.IdentityError 19 | } 20 | 21 | var _ = DescribeTable("Test QueryDIDDoc method", func(testCase queryDIDDocTestCase) { 22 | didDocWithMetadata, err := utils.MockLedger.QueryDIDDoc(testCase.did, "") 23 | if err != nil { 24 | Expect(testCase.expectedError.Code).To(Equal(err.Code)) 25 | Expect(testCase.expectedError.Message).To(Equal(err.Message)) 26 | } else { 27 | Expect(testCase.expectedError).To(BeNil()) 28 | Expect(testCase.expectedDidDocWithMetadata).To(Equal(didDocWithMetadata)) 29 | } 30 | }, 31 | 32 | Entry( 33 | "can get DIDDoc with an existent DID", 34 | queryDIDDocTestCase{ 35 | did: testconstants.ExistentDid, 36 | expectedDidDocWithMetadata: &didTypes.DidDocWithMetadata{ 37 | DidDoc: &testconstants.ValidDIDDoc, 38 | Metadata: &testconstants.ValidMetadata, 39 | }, 40 | expectedError: nil, 41 | }, 42 | ), 43 | 44 | Entry( 45 | "cannot get DIDDoc with not existent DID", 46 | queryDIDDocTestCase{ 47 | did: testconstants.NotExistentTestnetDid, 48 | expectedDidDocWithMetadata: nil, 49 | expectedError: types.NewNotFoundError(testconstants.NotExistentTestnetDid, types.JSON, nil, true), 50 | }, 51 | ), 52 | ) 53 | -------------------------------------------------------------------------------- /tests/unit/diddoc/ledger/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package ledger_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestLedger(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Unit Test]: DIDDoc Ledger Service") 15 | } 16 | -------------------------------------------------------------------------------- /tests/unit/diddoc/request/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package request_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestRequest(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Unit Test]: DIDDoc Request Service") 15 | } 16 | -------------------------------------------------------------------------------- /tests/unit/resource/common/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package common_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestCommon(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Unit Test]: Resource common methods and functions") 15 | } 16 | -------------------------------------------------------------------------------- /tests/unit/resource/ledger/query_collection_resource_ledger_service_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package ledger 4 | 5 | import ( 6 | resourceTypes "github.com/cheqd/cheqd-node/api/v2/cheqd/resource/v2" 7 | testconstants "github.com/cheqd/did-resolver/tests/constants" 8 | utils "github.com/cheqd/did-resolver/tests/unit" 9 | "github.com/cheqd/did-resolver/types" 10 | . "github.com/onsi/ginkgo/v2" 11 | . "github.com/onsi/gomega" 12 | ) 13 | 14 | type queryCollectionResourcesTestCase struct { 15 | did string 16 | expectedCollection []*resourceTypes.Metadata 17 | expectedError *types.IdentityError 18 | } 19 | 20 | var _ = DescribeTable("Test QueryCollectionResources method", func(testCase queryCollectionResourcesTestCase) { 21 | collection, err := utils.MockLedger.QueryCollectionResources(testCase.did) 22 | if err != nil { 23 | Expect(testCase.expectedError.Code).To(Equal(err.Code)) 24 | Expect(testCase.expectedError.Message).To(Equal(err.Message)) 25 | } else { 26 | Expect(testCase.expectedError).To(BeNil()) 27 | Expect(testCase.expectedCollection).To(Equal(collection)) 28 | } 29 | }, 30 | 31 | Entry( 32 | "can get collection of resources an existent DID", 33 | queryCollectionResourcesTestCase{ 34 | did: testconstants.ExistentDid, 35 | expectedCollection: []*resourceTypes.Metadata{ 36 | testconstants.ValidResource[0].Metadata, 37 | }, 38 | expectedError: nil, 39 | }, 40 | ), 41 | 42 | Entry( 43 | "can get collection of resources not existent DID", 44 | queryCollectionResourcesTestCase{ 45 | did: testconstants.NotExistentTestnetDid, 46 | expectedCollection: nil, 47 | expectedError: types.NewNotFoundError(testconstants.NotExistentTestnetDid, types.JSON, nil, true), 48 | }, 49 | ), 50 | ) 51 | -------------------------------------------------------------------------------- /tests/unit/resource/ledger/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package ledger_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestLedger(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Unit Test]: Resource Ledger Service") 15 | } 16 | -------------------------------------------------------------------------------- /tests/unit/resource/request/suite_test.go: -------------------------------------------------------------------------------- 1 | //go:build unit 2 | 3 | package request_test 4 | 5 | import ( 6 | "testing" 7 | 8 | . "github.com/onsi/ginkgo/v2" 9 | . "github.com/onsi/gomega" 10 | ) 11 | 12 | func TestRequest(t *testing.T) { 13 | RegisterFailHandler(Fail) 14 | RunSpecs(t, "[Unit Test]: Resource Request Service") 15 | } 16 | -------------------------------------------------------------------------------- /types/config.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/json" 5 | "time" 6 | ) 7 | 8 | type RawConfig struct { 9 | MainnetEndpoint string `mapstructure:"MAINNET_ENDPOINT"` 10 | TestnetEndpoint string `mapstructure:"TESTNET_ENDPOINT"` 11 | ResolverListener string `mapstructure:"RESOLVER_LISTENER"` 12 | LogLevel string `mapstructure:"LOG_LEVEL"` 13 | } 14 | 15 | type Config struct { 16 | Networks []Network 17 | ResolverListener string 18 | LogLevel string 19 | } 20 | 21 | type Network struct { 22 | Namespace string 23 | Endpoint string 24 | UseTls bool 25 | Timeout time.Duration 26 | } 27 | 28 | func (c *Config) MarshalJson() (string, error) { 29 | bytes, err := json.MarshalIndent(c, "", " ") 30 | return string(bytes), err 31 | } 32 | 33 | func (c *Config) MustMarshalJson() string { 34 | res, err := c.MarshalJson() 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | return res 40 | } 41 | -------------------------------------------------------------------------------- /types/dereferecing_metadata.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | type ( 4 | DereferencingMetadata ResolutionMetadata 5 | ) 6 | 7 | func NewDereferencingMetadata(did string, contentType ContentType, resolutionError string) DereferencingMetadata { 8 | return DereferencingMetadata(NewResolutionMetadata(did, contentType, resolutionError)) 9 | } 10 | -------------------------------------------------------------------------------- /types/dereferenced_did_versions_list.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "sort" 5 | 6 | didTypes "github.com/cheqd/cheqd-node/api/v2/cheqd/did/v2" 7 | resourceTypes "github.com/cheqd/cheqd-node/api/v2/cheqd/resource/v2" 8 | ) 9 | 10 | type DereferencedDidVersionsList struct { 11 | Versions DidDocMetadataList `json:"versions,omitempty"` 12 | } 13 | 14 | func NewDereferencedDidVersionsList(did string, versions []*didTypes.Metadata, resources []*resourceTypes.Metadata) *DereferencedDidVersionsList { 15 | didVersionList := DidDocMetadataList{} 16 | for _, version := range versions { 17 | didVersionList = append(didVersionList, *NewResolutionDidDocMetadata(did, version, resources)) 18 | } 19 | 20 | // Sort by updated date or created in reverse order 21 | sort.Sort(didVersionList) 22 | 23 | return &DereferencedDidVersionsList{ 24 | Versions: didVersionList, 25 | } 26 | } 27 | 28 | func (e *DereferencedDidVersionsList) AddContext(newProtocol string) {} 29 | func (e *DereferencedDidVersionsList) RemoveContext() {} 30 | func (e *DereferencedDidVersionsList) GetBytes() []byte { return []byte{} } 31 | -------------------------------------------------------------------------------- /types/did_dereferencing.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | type ( 4 | DidDereferencing struct { 5 | Context string `json:"@context,omitempty" example:"https://w3id.org/did-resolution/v1"` 6 | DereferencingMetadata DereferencingMetadata `json:"dereferencingMetadata"` 7 | ContentStream ContentStreamI `json:"contentStream"` 8 | Metadata ResolutionDidDocMetadata `json:"contentMetadata"` 9 | } 10 | ) 11 | 12 | // Interface implementation 13 | 14 | func (d DidDereferencing) GetContentType() string { 15 | return string(d.DereferencingMetadata.ContentType) 16 | } 17 | 18 | func (d DidDereferencing) GetBytes() []byte { 19 | if d.ContentStream == nil { 20 | return []byte{} 21 | } 22 | return d.ContentStream.GetBytes() 23 | } 24 | 25 | func (r DidDereferencing) IsRedirect() bool { 26 | return false 27 | } 28 | -------------------------------------------------------------------------------- /types/did_service.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Implements ResolutionResult interface 4 | type ServiceResult struct { 5 | endpoint string 6 | } 7 | 8 | // Interface implementation 9 | func (s ServiceResult) GetContentType() string { 10 | return "" 11 | } 12 | 13 | func (s ServiceResult) GetBytes() []byte { 14 | return []byte(s.endpoint) 15 | } 16 | 17 | func (s ServiceResult) GetServiceEndpoint() string { 18 | return s.endpoint 19 | } 20 | 21 | func (r ServiceResult) IsRedirect() bool { 22 | return true 23 | } 24 | 25 | // end of Interface implementation 26 | 27 | func NewServiceResult(endpoint string) *ServiceResult { 28 | return &ServiceResult{endpoint: endpoint} 29 | } 30 | -------------------------------------------------------------------------------- /types/interfaces.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | type ContentStreamI interface { 4 | AddContext(newProtocol string) 5 | RemoveContext() 6 | GetBytes() []byte 7 | } 8 | 9 | type ResolutionResultI interface { 10 | GetContentType() string 11 | GetBytes() []byte 12 | IsRedirect() bool 13 | } 14 | -------------------------------------------------------------------------------- /types/resource_data.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/rs/zerolog/log" 7 | ) 8 | 9 | type ResourceData struct { 10 | Content map[string]interface{} 11 | } 12 | 13 | func NewResourceData(data []byte) (*ResourceData, error) { 14 | var parsedData map[string]interface{} 15 | 16 | err := json.Unmarshal(data, &parsedData) 17 | if err != nil { 18 | return nil, err 19 | } 20 | return &ResourceData{Content: parsedData}, nil 21 | } 22 | 23 | func (e *ResourceData) AddContext(newProtocol string) {} 24 | func (e *ResourceData) RemoveContext() {} 25 | func (e *ResourceData) GetBytes() []byte { 26 | bytes, err := json.Marshal(e.Content) 27 | if err != nil { 28 | log.Info().Msg("Failed to marshal resource") 29 | return []byte{} 30 | } 31 | return bytes 32 | } 33 | 34 | func (e *ResourceData) MarshalJSON() ([]byte, error) { 35 | return json.Marshal(e.Content) 36 | } 37 | 38 | func (e *ResourceData) GetContentType() string { return "" } 39 | func (e *ResourceData) IsRedirect() bool { return false } 40 | -------------------------------------------------------------------------------- /types/resource_dereferencing.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | type ResourceDereferencing struct { 4 | Context string `json:"@context,omitempty" example:"https://w3id.org/did-resolution/v1"` 5 | DereferencingMetadata DereferencingMetadata `json:"dereferencingMetadata"` 6 | ContentStream ContentStreamI `json:"contentStream"` 7 | Metadata *ResolutionResourceMetadata `json:"contentMetadata"` 8 | } 9 | 10 | func NewResourceDereferencingFromContent(did string, contentType ContentType, contentStream ContentStreamI) *ResourceDereferencing { 11 | dereferenceMetadata := NewDereferencingMetadata(did, contentType, "") 12 | 13 | var context string 14 | if contentType == DIDJSONLD || contentType == JSONLD { 15 | context = ResolutionSchemaJSONLD 16 | } 17 | 18 | return &ResourceDereferencing{Context: context, ContentStream: contentStream, DereferencingMetadata: dereferenceMetadata} 19 | } 20 | 21 | func NewResourceDereferencingFromResources(did string, contentType ContentType, resources *DereferencedResourceList) *ResourceDereferencing { 22 | dereferenceMetadata := NewDereferencingMetadata(did, contentType, "") 23 | 24 | var context string 25 | if contentType == DIDJSONLD || contentType == JSONLD { 26 | context = ResolutionSchemaJSONLD 27 | } 28 | 29 | return &ResourceDereferencing{Context: context, Metadata: &ResolutionResourceMetadata{Resources: resources}, DereferencingMetadata: dereferenceMetadata} 30 | } 31 | 32 | // Interface implementation 33 | 34 | func (d ResourceDereferencing) GetContentType() string { 35 | return string(d.DereferencingMetadata.ContentType) 36 | } 37 | 38 | func (d ResourceDereferencing) GetBytes() []byte { 39 | if d.ContentStream == nil { 40 | return []byte{} 41 | } 42 | return d.ContentStream.GetBytes() 43 | } 44 | 45 | func (r ResourceDereferencing) IsRedirect() bool { 46 | return false 47 | } 48 | -------------------------------------------------------------------------------- /types/resource_metadata.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/json" 5 | ) 6 | 7 | type ResolutionResourceMetadata struct { 8 | ContentMetadata *DereferencedResource `json:"metadata,omitempty"` 9 | Resources *DereferencedResourceList `json:"linkedResourceMetadata,omitempty"` 10 | } 11 | 12 | func (e *ResolutionResourceMetadata) MarshalJSON() ([]byte, error) { 13 | // If Metadata is present, use custom marshaller 14 | if e.ContentMetadata != nil { 15 | return json.Marshal(e.ContentMetadata) 16 | } 17 | 18 | // Otherwise, marshal Resources normally 19 | return json.Marshal(struct { 20 | Resources *DereferencedResourceList `json:"linkedResourceMetadata,omitempty"` 21 | }{ 22 | Resources: e.Resources, 23 | }) 24 | } 25 | 26 | func (e *ResolutionResourceMetadata) UnmarshalJSON(data []byte) error { 27 | // Define a temporary structure to assist with unmarshalling 28 | var aux struct { 29 | Resources *DereferencedResourceList `json:"linkedResourceMetadata,omitempty"` 30 | } 31 | 32 | // First, try to unmarshal into ContentMetadata 33 | if err := json.Unmarshal(data, &e.ContentMetadata); err == nil && e.ContentMetadata.CollectionId != "" { 34 | return nil // Successfully unmarshalled into ContentMetadata, return early 35 | } 36 | 37 | // If ContentMetadata is nil, try to unmarshal into Resources 38 | if err := json.Unmarshal(data, &aux); err != nil { 39 | return err 40 | } 41 | 42 | // Assign the extracted Resources 43 | e.Resources = aux.Resources 44 | e.ContentMetadata = nil 45 | return nil 46 | } 47 | -------------------------------------------------------------------------------- /types/supported_queries.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/cheqd/did-resolver/utils" 7 | ) 8 | 9 | type SupportedQueriesT []string 10 | 11 | // DiffWithUrlValues returns values which are in url.Values but not in SupportedQueriesT 12 | func (s *SupportedQueriesT) DiffWithUrlValues(values url.Values) []string { 13 | var result []string 14 | for k := range values { 15 | if !utils.Contains(*s, k) { 16 | result = append(result, k) 17 | } 18 | } 19 | return result 20 | } 21 | 22 | func (s *SupportedQueriesT) IntersectWithUrlValues(values url.Values) []string { 23 | var result []string 24 | for k := range values { 25 | if utils.Contains(*s, k) { 26 | result = append(result, k) 27 | } 28 | } 29 | return result 30 | } 31 | 32 | func (s *SupportedQueriesT) Plus(s2 SupportedQueriesT) SupportedQueriesT { 33 | var result SupportedQueriesT 34 | result = append(result, *s...) 35 | result = append(result, s2...) 36 | return result 37 | } 38 | 39 | var DidSupportedQueries = SupportedQueriesT{ 40 | VersionId, 41 | VersionTime, 42 | TransformKeys, 43 | ResourceMetadata, 44 | ServiceQ, 45 | RelativeRef, 46 | Metadata, 47 | } 48 | 49 | var DidResolutionQueries = SupportedQueriesT{ 50 | VersionId, 51 | VersionTime, 52 | TransformKeys, 53 | ServiceQ, 54 | RelativeRef, 55 | } 56 | 57 | var ResourceSupportedQueries = SupportedQueriesT{ 58 | ResourceId, 59 | ResourceCollectionId, 60 | ResourceName, 61 | ResourceMetadata, 62 | ResourceType, 63 | ResourceVersion, 64 | ResourceVersionTime, 65 | ResourceChecksum, 66 | } 67 | 68 | var ResourceAmbiguousQueries = SupportedQueriesT{ 69 | ResourceCollectionId, 70 | ResourceVersion, 71 | ResourceVersionTime, 72 | } 73 | 74 | var AllSupportedQueries = DidSupportedQueries.Plus(ResourceSupportedQueries) 75 | 76 | var SupportedQueriesWithTransformKeys = []string{ 77 | VersionId, 78 | VersionTime, 79 | ServiceQ, 80 | RelativeRef, 81 | } 82 | 83 | func IsSupportedWithCombinationTransformKeysQuery(values url.Values) bool { 84 | for query := range values { 85 | if query == TransformKeys { 86 | continue 87 | } 88 | 89 | if !utils.Contains(SupportedQueriesWithTransformKeys, query) { 90 | return false 91 | } 92 | } 93 | 94 | return true 95 | } 96 | -------------------------------------------------------------------------------- /utils/did.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strings" 7 | ) 8 | 9 | func MustSplitDID(did string) (method string, namespace string, id string) { 10 | method, namespace, id, err := TrySplitDID(did) 11 | if err != nil { 12 | panic(err.Error()) 13 | } 14 | return 15 | } 16 | 17 | func JoinDID(method, namespace, id string) string { 18 | res := "did:" + method 19 | 20 | if namespace != "" { 21 | res = res + ":" + namespace 22 | } 23 | 24 | return res + ":" + id 25 | } 26 | 27 | // ValidateDID checks method and allowed namespaces only when the corresponding parameters are specified. 28 | func ValidateDID(did string, method string, allowedNamespaces []string) error { 29 | sMethod, sNamespace, sUniqueID, err := TrySplitDID(did) 30 | if err != nil { 31 | return err 32 | } 33 | 34 | // check method 35 | if method != "" && method != sMethod { 36 | return fmt.Errorf("did method must be: %s", method) 37 | } 38 | 39 | // check namespaces 40 | if !DidNamespaceRegexp.MatchString(sNamespace) { 41 | return errors.New("invalid did namespace") 42 | } 43 | 44 | if len(allowedNamespaces) > 0 && !Contains(allowedNamespaces, sNamespace) { 45 | return fmt.Errorf("did namespace must be one of: %s", strings.Join(allowedNamespaces, ", ")) 46 | } 47 | 48 | // check unique-id 49 | err = ValidateID(sUniqueID) 50 | if err != nil { 51 | return err 52 | } 53 | 54 | return err 55 | } 56 | 57 | func IsValidDID(did string, method string, allowedNamespaces []string) bool { 58 | err := ValidateDID(did, method, allowedNamespaces) 59 | return err == nil 60 | } 61 | -------------------------------------------------------------------------------- /utils/encoding.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | 7 | "github.com/labstack/echo/v4" 8 | "github.com/multiformats/go-multibase" 9 | ) 10 | 11 | func ValidateMultibaseEncoding(data string, expectedEncoding multibase.Encoding) error { 12 | actualEncoding, _, err := multibase.Decode(data) 13 | if err != nil { 14 | return err 15 | } 16 | 17 | if actualEncoding != expectedEncoding { 18 | return fmt.Errorf("invalid actualEncoding. expected: %s actual: %s", 19 | multibase.EncodingToStr[expectedEncoding], multibase.EncodingToStr[actualEncoding]) 20 | } 21 | 22 | return nil 23 | } 24 | 25 | func ValidateBase58(data string) error { 26 | return ValidateMultibaseEncoding(string(multibase.Base58BTC)+data, multibase.Base58BTC) 27 | } 28 | 29 | func IsValidBase58(data string) bool { 30 | return ValidateBase58(data) == nil 31 | } 32 | 33 | // Headers Encoding 34 | func IsGzipAccepted(c echo.Context) bool { 35 | acceptEncoding := c.Request().Header.Get(echo.HeaderAcceptEncoding) 36 | return strings.Contains(acceptEncoding, "gzip") || strings.Contains(acceptEncoding, "*") 37 | } 38 | -------------------------------------------------------------------------------- /utils/id.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/mr-tron/base58" 7 | ) 8 | 9 | const ( 10 | IndyIDLength = 16 11 | ) 12 | 13 | func IsValidIndyID(data string) bool { 14 | bytes, err := base58.Decode(data) 15 | if err != nil { 16 | return false 17 | } 18 | return len(bytes) == IndyIDLength 19 | } 20 | 21 | func ValidateID(id string) error { 22 | isValidID := IsValidIndyID(id) || IsValidUUID(id) 23 | 24 | if !isValidID { 25 | return errors.New("unique id should be one of: 16 bytes of decoded base58 string or UUID") 26 | } 27 | 28 | return nil 29 | } 30 | 31 | func IsValidID(id string) bool { 32 | err := ValidateID(id) 33 | return err == nil 34 | } 35 | -------------------------------------------------------------------------------- /utils/parse_time.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func ParseFromStringTimeToGoTime(timeString string) (time.Time, error) { 9 | // If timeString is empty return default nullable time value (0001-01-01 00:00:00 +0000 UTC) 10 | if timeString == "" { 11 | return time.Time{}, nil 12 | } 13 | 14 | t, err := parseTimeString(timeString) 15 | if err == nil { 16 | return t, nil 17 | } 18 | 19 | return time.Time{}, err 20 | } 21 | 22 | func parseTimeString(timeString string) (time.Time, error) { 23 | formats := []string{ 24 | time.Layout, 25 | time.ANSIC, 26 | time.UnixDate, 27 | time.RubyDate, 28 | time.RFC822, 29 | time.RFC822Z, 30 | time.RFC850, 31 | time.RFC1123, 32 | time.RFC1123Z, 33 | time.RFC3339, 34 | time.RFC3339Nano, 35 | time.DateTime, 36 | time.DateOnly, 37 | } 38 | 39 | // Try parsing the date using different formats 40 | for _, format := range formats { 41 | parsedTime, err := time.Parse(format, timeString) 42 | if err == nil { 43 | return parsedTime.UTC(), nil 44 | } 45 | } 46 | 47 | return time.Time{}, fmt.Errorf("unable to parse date string") 48 | } 49 | -------------------------------------------------------------------------------- /utils/skipper_gzip.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "github.com/labstack/echo/v4" 5 | ) 6 | 7 | // If gzip is not accepted by the client, skip the middleware 8 | func GzipSkipper(c echo.Context) bool { 9 | return !IsGzipAccepted(c) 10 | } 11 | -------------------------------------------------------------------------------- /utils/str.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | func IndexOf(array []string, searchElement string, fromIndex int) int { 4 | for i, v := range array[fromIndex:] { 5 | if v == searchElement { 6 | return fromIndex + i 7 | } 8 | } 9 | 10 | return -1 11 | } 12 | 13 | func Contains(vs []string, t string) bool { 14 | return IndexOf(vs, t, 0) >= 0 15 | } 16 | -------------------------------------------------------------------------------- /utils/uuid.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/google/uuid" 9 | ) 10 | 11 | const StandardUUIDLength = 36 12 | 13 | func ValidateUUID(u string) error { 14 | if len(u) != StandardUUIDLength { 15 | return errors.New("uuid must be of length " + strconv.Itoa(StandardUUIDLength) + " (in form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)") 16 | } 17 | 18 | _, err := uuid.Parse(u) 19 | return err 20 | } 21 | 22 | func IsValidUUID(u string) bool { 23 | return ValidateUUID(u) == nil 24 | } 25 | 26 | // Normalization 27 | 28 | func NormalizeUUID(uuid string) string { 29 | return strings.ToLower(uuid) 30 | } 31 | -------------------------------------------------------------------------------- /utils/verification_key_generator.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "crypto/ed25519" 5 | 6 | "github.com/lestrrat-go/jwx/jwk" 7 | "github.com/mr-tron/base58" 8 | "github.com/multiformats/go-multibase" 9 | ) 10 | 11 | func GenerateEd25519VerificationKey2018(publicKey ed25519.PublicKey) string { 12 | return base58.Encode(publicKey) 13 | } 14 | 15 | func GenerateEd25519VerificationKey2020(publicKey ed25519.PublicKey) (string, error) { 16 | publicKeyMultibaseBytes := []byte{0xed, 0x01} 17 | publicKeyMultibaseBytes = append(publicKeyMultibaseBytes, publicKey...) 18 | 19 | return multibase.Encode(multibase.Base58BTC, publicKeyMultibaseBytes) 20 | } 21 | 22 | func GenerateJSONWebKey2020(publicKey ed25519.PublicKey) (jwk.Key, error) { 23 | return jwk.New(publicKey) 24 | } 25 | --------------------------------------------------------------------------------