Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat!: native DIDDocuments and proper DID resolution interface #799

Merged
merged 80 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
7bb8621
Add base types for the compliant DIDs
ntn-x2 Sep 29, 2023
6d1963b
Add base types for the compliant DID resolution
ntn-x2 Sep 29, 2023
8c2ddea
Add dereferencing
ntn-x2 Sep 29, 2023
9faa011
Refactor of Did.utils and Did.chain
ntn-x2 Sep 29, 2023
c8b22fc
Work on DID.signature
ntn-x2 Sep 29, 2023
a6a7734
Bit more mess here and there
ntn-x2 Sep 29, 2023
22672d5
yarn check working fine
ntn-x2 Oct 2, 2023
1332a7c
did.resolve implemented
ntn-x2 Oct 2, 2023
d135a1c
DID resolver ok
ntn-x2 Oct 2, 2023
b43cc80
AccountLinks2.chain.ts
ntn-x2 Oct 3, 2023
ed5d240
Add resolveRepresentation to resolver
ntn-x2 Oct 3, 2023
dd3148c
Better DID resolver
ntn-x2 Oct 3, 2023
812a360
Resolver improvements
ntn-x2 Oct 3, 2023
54c8022
Improve API surface to keep the same abstraction level
ntn-x2 Oct 3, 2023
9f7c71a
First DID integration test passing!
ntn-x2 Oct 4, 2023
050a043
More DID integration tests uncommented
ntn-x2 Oct 4, 2023
40361ec
More DID integration tests passing
ntn-x2 Oct 4, 2023
b88def8
More DID integration tests
ntn-x2 Oct 4, 2023
932ed2b
All DID integration tests passing
ntn-x2 Oct 5, 2023
5db94bc
Refactoring
ntn-x2 Oct 5, 2023
934715e
Add utility function to add a verification method
ntn-x2 Oct 5, 2023
6948e37
Minor refactoring
ntn-x2 Oct 5, 2023
25863f5
Merge commit 'c4ab492812d19169532a399b57dd1bd013a61570' into aa/nativ…
ntn-x2 Oct 5, 2023
f2fc475
Revert unwanted change
ntn-x2 Oct 5, 2023
9f54ea2
Remove addKeypairAsVerificationMethod function
ntn-x2 Oct 5, 2023
42378ca
Light DID unit tests passing
ntn-x2 Oct 5, 2023
417a220
Unit tests for light and full DID passing
ntn-x2 Oct 5, 2023
c721c52
Minor changes to signing interfaces
ntn-x2 Oct 5, 2023
4a0a5fa
DIDSignature unit tests passing
ntn-x2 Oct 6, 2023
5b4691c
Halfway through the refactoring
ntn-x2 Oct 6, 2023
b171108
Better error messages
ntn-x2 Oct 6, 2023
239b670
Fix imports
ntn-x2 Oct 6, 2023
c566069
Refactoring
ntn-x2 Oct 6, 2023
ccb9533
First refactor
ntn-x2 Oct 10, 2023
2f81498
Interim version
ntn-x2 Oct 10, 2023
c5caaee
Fix DID dereferencing and signature resolution
ntn-x2 Oct 10, 2023
0fb7c57
Compiling!
ntn-x2 Oct 10, 2023
66a0e5d
Compiling after applying stash
ntn-x2 Oct 10, 2023
6bedabe
Fix TestUtils
ntn-x2 Oct 10, 2023
6698cbc
verificationRelationship -> verificationRelationships
ntn-x2 Oct 10, 2023
0b2b461
Prepare ground for proper DID dereferencing
ntn-x2 Oct 10, 2023
9878f4e
Add support for query params in DID URLs
ntn-x2 Oct 11, 2023
8c592b4
Compiling again
ntn-x2 Oct 11, 2023
845e319
WIP dereferencing in tests
ntn-x2 Oct 11, 2023
7739f4e
Credential.spec.ts for legacy credential almost passing
ntn-x2 Oct 11, 2023
78bb06b
Did.signature.spec.ts working again
ntn-x2 Oct 11, 2023
2656556
Return minimal DID document when DID is deactivated or migrated
ntn-x2 Oct 12, 2023
0de4cd5
Add test for legacy signature support
ntn-x2 Oct 12, 2023
491b446
Sr25519Signature2020.spec.ts test failing
ntn-x2 Oct 12, 2023
04dcfed
Key -> verification method renaming
ntn-x2 Oct 16, 2023
87ba0be
Key/service ID to URL
ntn-x2 Oct 16, 2023
a279263
More constants
ntn-x2 Oct 16, 2023
998cdba
Fix yarn check
ntn-x2 Oct 16, 2023
fc79afe
Fix JSDocs
ntn-x2 Oct 16, 2023
6f1dd3c
Update tests
ntn-x2 Oct 16, 2023
3076a8a
Minor refinements
ntn-x2 Oct 16, 2023
82c5db9
Minor fixes
ntn-x2 Oct 16, 2023
79a75c1
Apply suggestion
ntn-x2 Oct 16, 2023
303abc9
Push different yarn.lock
ntn-x2 Oct 16, 2023
94c3bb5
Fix type import
ntn-x2 Oct 16, 2023
e015e03
Fix integration test
ntn-x2 Oct 16, 2023
a8c5f51
Fix integration test pt.2
ntn-x2 Oct 16, 2023
0f267db
Update unit tests for DidResolver.spec.ts
ntn-x2 Oct 17, 2023
28d068f
Half-way through new DidResolver unit tests
ntn-x2 Oct 17, 2023
226b086
Unit tests for DidResolver complete
ntn-x2 Oct 17, 2023
a1d6728
Replace buffer
ntn-x2 Oct 17, 2023
eb9c072
Apply suggestion
ntn-x2 Oct 20, 2023
2274c27
Apply w3n suggestion
ntn-x2 Oct 20, 2023
a98f360
export type
ntn-x2 Oct 20, 2023
447e64b
Replace Buffer with Uint8Array
ntn-x2 Oct 20, 2023
caf9e92
Add multikey context
ntn-x2 Oct 20, 2023
4e6c3df
Fix unit tests for linked signature suites
ntn-x2 Oct 23, 2023
00f2b27
Legacy support for document loader
ntn-x2 Oct 23, 2023
6e42e19
Make getStoreTxFromDidDocument only used in tests
ntn-x2 Oct 24, 2023
1cfe243
Use Object.fromEntries
ntn-x2 Oct 24, 2023
27f03a2
Refactor exportQueryParamsFromUri
ntn-x2 Oct 24, 2023
573373d
Use resolve instead of dereference
ntn-x2 Oct 24, 2023
a80347a
Fixes
ntn-x2 Oct 24, 2023
b2f12c5
Revert DidSignature renaming
ntn-x2 Oct 25, 2023
2fda0d6
Rename URI to DID and keep DID URL
ntn-x2 Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/attestation/Attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function verifyDataStructure(input: IAttestation): void {
if (!input.owner) {
throw new SDKErrors.OwnerMissingError()
}
Did.validateUri(input.owner, 'Did')
Did.validateIdentifier(input.owner, 'Uri')

if (typeof input.revoked !== 'boolean') {
throw new SDKErrors.RevokedTypeError()
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/credentialsV1/KiltAttestationProofV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type { IEventData, Signer } from '@polkadot/types/types'
import {
authorizeTx,
getFullDidUri,
validateUri,
validateIdentifier,
fromChain as didFromChain,
} from '@kiltprotocol/did'
import { JsonSchema, SDKErrors, Caip19 } from '@kiltprotocol/utils'
Expand Down Expand Up @@ -347,7 +347,7 @@ export async function verify(
validateCredentialStructure(credential)
const { nonTransferable, credentialStatus, credentialSubject, issuer } =
credential
validateUri(issuer, 'Did')
validateIdentifier(issuer, 'Uri')
await validateSubject(credential, opts)
// 4. check nonTransferable
if (nonTransferable !== true)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/credentialsV1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-disable no-use-before-define */

import type {
ConformingDidKey,
VerificationMethod,
DidUri,
Caip2ChainId,
IClaimContents,
Expand All @@ -33,7 +33,7 @@ import type {
KILT_ATTESTER_LEGITIMATION_V1_TYPE,
} from './common.js'

export type IPublicKeyRecord = ConformingDidKey
export type IPublicKeyRecord = VerificationMethod

export interface Proof {
type: string
Expand Down
22 changes: 13 additions & 9 deletions packages/core/src/delegation/DelegationNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import type {
CTypeHash,
DidDocument,
DidUri,
DidVerificationKey,
IAttestation,
IDelegationHierarchyDetails,
IDelegationNode,
SignCallback,
SubmittableExtrinsic,
DidUrl,
} from '@kiltprotocol/types'
import { Crypto, SDKErrors, UUID } from '@kiltprotocol/utils'
import { ConfigService } from '@kiltprotocol/config'
Expand Down Expand Up @@ -268,23 +268,27 @@ export class DelegationNode implements IDelegationNode {
): Promise<Did.EncodedSignature> {
const delegateSignature = await sign({
data: this.generateHash(),
did: delegateDid.uri,
keyRelationship: 'authentication',
did: delegateDid.id,
verificationRelationship: 'authentication',
})
const { fragment } = Did.parse(delegateSignature.keyUri)
const signerUrl =
`${delegateDid.id}${delegateSignature.verificationMethod.id}` as DidUrl
const { fragment } = Did.parse(signerUrl)
if (!fragment) {
throw new SDKErrors.DidError(
`DID key uri "${delegateSignature.keyUri}" couldn't be parsed`
`DID verification method URL "${signerUrl}" couldn't be parsed`
)
}
const key = Did.getKey(delegateDid, fragment)
if (!key) {
const verificationMethod = delegateDid.verificationMethod?.find(
({ id }) => id === fragment
)
if (!verificationMethod) {
throw new SDKErrors.DidError(
`Key with fragment "${fragment}" was not found on DID: "${delegateDid.uri}"`
`Verification method "${signerUrl}" was not found on DID: "${delegateDid.id}"`
)
}
return Did.didSignatureToChain(
key as DidVerificationKey,
verificationMethod,
delegateSignature.signature
)
}
Expand Down
3 changes: 2 additions & 1 deletion packages/did/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@polkadot/types": "^10.4.0",
"@polkadot/types-codec": "^10.4.0",
"@polkadot/util": "^12.0.0",
"@polkadot/util-crypto": "^12.0.0"
"@polkadot/util-crypto": "^12.0.0",
"multibase": "^4.0.6"
}
}
Loading
Loading