TinyCloud uses two distinct types of Decentralized Identifiers (DIDs) for different purposes. Understanding when to use each is critical for successful delegations and correct identity handling.Documentation Index
Fetch the complete documentation index at: https://docs.tinycloud.xyz/llms.txt
Use this file to discover all available pages before exploring further.
The Two DID Types
Session Key DID
The Session Key DID is an ephemeral identifier generated fresh for each session. It uses thedid:key method:
.sessionDid:
Primary DID (User Identity)
The Primary DID represents the user’s persistent identity, derived from the authentication method they used. For Ethereum wallets, this is adid:pkh (Public Key Hash) DID:
The .did Property
The tc.did property returns different values depending on the authentication state:
- After signIn()
- Before signIn()
After calling In this mode,
signIn(), tc.did returns the primary DID (persistent identity):tc.did and tc.sessionDid return different values. Use tc.did for delegations and identity, and tc.sessionDid for debugging session internals.When to Use Which
| Use Case | What to Use | Returns |
|---|---|---|
| User-to-user delegations | tc.did | Primary DID (after signIn) |
| Identifying a user persistently | tc.did | Primary DID (after signIn) |
| Debugging session key issues | tc.sessionDid | Session Key DID |
| Logging internal session state | tc.sessionDid | Session Key DID |
The Common Mistake
When Alice wants to delegate capabilities to Bob, developers sometimes use the session DID directly instead of the primary identity:Why This Matters
The TinyCloud server performs strict validation on delegation chains:- Delegatee matching: When Bob uses a delegation from Alice, the server checks that the
delegateefield in Alice’s delegation matches Bob’s identity - Primary DID expected: The server expects the delegatee to be the primary DID (e.g.,
did:pkh:eip155:...for Ethereum wallets) - Session DIDs are ephemeral: Bob’s session DID changes with each authentication, so a delegation to
bob.sessionDidwould be invalid after Bob re-authenticates
Quick Reference
If you see the error “Delegation failed: invalid delegatee”, verify that you are using
tc.did (after signIn()) rather than tc.sessionDid when specifying the delegate.