Pull Request: Credential Sharing Contract#120
Merged
Conversation
|
@Akatenvictor is attempting to deploy a commit to the Josie's projects Team on Vercel. A member of the Team first needs to authorize it. |
Add PermissionDenied, ShareExpired, and CannotReShare error variants to support the credential sharing feature with permission checks, time-limited access, and re-sharing authorization.
SharingPermission provides three granular access levels for credential sharing: View (read-only status), Download (full credential access), and ReShare (can share with others). CredentialShareEvent captures sharing activity for on-chain audit trail.
Defines typed storage keys for credential sharing: ShareCounter for auto-incrementing IDs, ShareRecord for per-share data, and index keys for owner/recipient lookups. Uses persistent storage for TTL management.
Emits on-chain events for all credential sharing operations (share, revoke, extend, re-share) with owner, share ID, and full event payload for off-chain indexing and audit compliance.
Defines the CredentialShare data model with permission levels, revocation tracking, and TTL-based persistent storage. Includes read/write helpers that manage entry expiration for long-lived credential shares.
Creates credential shares with granular View/Download/ReShare permissions, time-limited access, persistent storage with TTL, and emits on-chain events for audit trail. Owner authorization required.
check_credential_access verifies if a grantee has active, non-expired access to a credential. get_credential_share retrieves full share details. Owner/recipient index functions enable listing all shares for a party.
Revoke stores reason and timestamp for audit trail. Extend allows owner to add time. Re-share requires ReShare permission on original share and recipient authorization, creating a new share with independent expiry. All operations emit events.
Tests cover: share and retrieve, access check active/denied, revoke with reason, extend with expiry, time-based expiry, and re-share with permission propagation. All tests use the new credential sharing API.
Tests cover: re-share denied without ReShare permission, revoking expired shares preserves reason, owner/recipient index queries, and panics on nonexistent share IDs. Validates error handling and authorization guards.
share_credential and re_share_credential now populate ShareByOwner and ShareByRecipient persistent storage indices, enabling lookup functions and access checks to find shares by party. Remove unused symbol_short import.
Member
|
Kindly check failing ci checks @Wilfred007 |
Fix cargo fmt --check failures in CI by reformatting long function signatures, chained method calls, and import statements to match standard rustfmt rules.
Contributor
Author
Okay, I'm on it |
Remove 27 needless &env borrows where env is already &Env. Rename SharingDataKey variants (ShareCounter->Counter, ShareRecord->Record, ShareByOwner->ByOwner, ShareByRecipient->ByRecipient) to satisfy clippy::enum_variant_names lint.
Contributor
Author
|
Kindly confirm ci check pass @Josie123-Dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the existing DataSharing Soroban smart contract with a full-featured credential sharing system for health credentials. Adds granular permission levels (View, Download, Re-share), time-limited access with expiry, revocation with audit trail, and on-chain event tracking for all sharing operations.
Changes
New Types (types.rs)
New Error Variants (errors.rs)
Storage Layer (storage.rs)
Event Emission (events.rs)
Contract Functions (data_sharing.rs)
Data Model (CredentialShare struct)
owner, recipient, credential_hash, encrypted_key,
permission, access_expiry, is_active, shared_at,
revoked_at, revocation_reason
Storage Pattern
Uses persistent storage with TTL management (matching verification.rs pattern):
Testing
117 tests passing (13 new credential sharing tests):
Happy Path (7 tests)
Edge Cases (6 tests)
Auth Rules
Tradeoffs
Out of Scope
Closes #88