Skip to content

Commit

Permalink
Merge pull request #1209 from uport-project/next
Browse files Browse the repository at this point in the history
chore: new minor release
  • Loading branch information
mirceanis committed Aug 1, 2023
2 parents c604249 + 5294a81 commit 74c517a
Show file tree
Hide file tree
Showing 85 changed files with 4,678 additions and 2,994 deletions.
4 changes: 2 additions & 2 deletions __tests__/initial.migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('database initial migration tests', () => {
encoding: 'utf-8',
})
expect(signedMessage).toEqual(
'vzDocUViJh7ooOCZ-jBHKZddEsTa4yClHwhIL9SHJwjAv3bC6TZIcUnX36ZqNBWvLbnNAQvdtzqrVf3l0pv3QQ',
'vzDocUViJh7ooOCZ-jBHKZddEsTa4yClHwhIL9SHJwg_QIk9Fsm3jrYoIFmVy-pPjPUP5aNq6QEUfGCm_ZpKAA',
)
})

Expand Down Expand Up @@ -203,7 +203,7 @@ describe('database initial migration tests', () => {
encoding: 'utf-8',
})
expect(signedMessage).toEqual(
'JDaZFSC4eWQdau4G9a8l8ml0rhwmzCY4oEDIr-cjWK2nVCOGZP94HV3EfbpO_X3bZKPITLg8FJgVVSyRRPcObQ',
'JDaZFSC4eWQdau4G9a8l8ml0rhwmzCY4oEDIr-cjWK1Yq9x5mwCH4qI7gkWxAoIjVgsUmfcMi6OqfTH7iz8y1A',
)
})

Expand Down
4 changes: 2 additions & 2 deletions __tests__/shared/verifiableDataJWT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default (testContext: {
},
proofFormat: 'jwt',
})
const verifyResult = await agent.verifyCredential({credential: verifiableCredential})
const verifyResult = await agent.verifyCredential({ credential: verifiableCredential })

expect(verifyResult.verified).toBe(true)
expect(verifiableCredential).toHaveProperty('proof.jwt')
Expand Down Expand Up @@ -403,7 +403,7 @@ export default (testContext: {
hello: 'world',
},
credentialStatus: {
id: 'override me',
id: 'override:me',
type: 'ThisMethodDoesNotExist2022',
},
},
Expand Down
13 changes: 8 additions & 5 deletions __tests__/shared/verifiableDataLD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export default (testContext: {
challenge = 'TEST_CHALLENGE_STRING'
didEthrIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:ethr' })
didKeyIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' })
pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { chainId: "1"} })
pkhIdentifier = await agent.didManagerCreate({
kms: 'local',
provider: 'did:pkh',
options: { chainId: '1' },
})
})
afterAll(testContext.tearDown)

Expand Down Expand Up @@ -295,7 +299,7 @@ export default (testContext: {
issuer: { id: pkhIdentifier.did },
'@context': [
'https://www.w3.org/2018/credentials/v1',
'https://veramo.io/contexts/discord-kudos/v1'
'https://veramo.io/contexts/discord-kudos/v1',
],
type: ['VerifiableCredential', 'DiscordKudos'],
issuanceDate: new Date().toISOString(),
Expand All @@ -315,10 +319,9 @@ export default (testContext: {

const result = await agent.verifyCredential({
credential,
fetchRemoteContexts: true
fetchRemoteContexts: true,
})
expect(result.verified).toBe(true)

})

describe('credential verification policies', () => {
Expand Down Expand Up @@ -363,7 +366,7 @@ export default (testContext: {
name: 'hello',
},
credentialStatus: {
id: 'override me',
id: 'override:me',
type: 'ThisMethodDoesNotExist2022',
},
},
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,27 @@
"docs": "pnpm docs:copy && pnpm docs:build",
"docs:copy": "ts-node ./scripts/docs-copy.ts",
"docs:build": "ts-node ./scripts/docs-build.ts && pnpm docs:pretty",
"docs:pretty": "pretty-quick"
"docs:pretty": "prettier --write docs/**/*.md"
},
"devDependencies": {
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/transactions": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@jest/globals": "^29.5.0",
"@jest/globals": "29.5.0",
"@metamask/eth-sig-util": "6.0.0",
"@microsoft/api-documenter": "7.22.16",
"@microsoft/api-extractor": "7.35.2",
"@microsoft/api-extractor-model": "7.27.2",
"@microsoft/tsdoc": "0.14.2",
"@noble/hashes": "1.3.1",
"@stablelib/ed25519": "1.0.3",
"@transmute/credentials-context": "0.7.0-unstable.81",
"@types/express": "4.17.17",
"@types/fs-extra": "11.0.1",
"@types/jest": "29.5.2",
"@types/node": "20.3.0",
"@types/uuid": "9.0.1",
"blakejs": "1.2.1",
"@types/uuid": "9.0.2",
"caip": "1.1.0",
"credential-status": "2.0.5",
"cross-env": "7.0.3",
Expand All @@ -63,15 +64,14 @@
"oas-resolver": "2.5.6",
"openapi-types": "12.1.3",
"prettier": "3.0.0",
"pretty-quick": "3.1.3",
"rimraf": "5.0.1",
"semantic-release": "21.0.5",
"ts-jest": "29.1.0",
"ts-json-schema-generator": "1.2.0",
"ts-node": "10.9.1",
"typeorm": "0.3.16",
"typescript": "5.1.3",
"uint8arrays": "4.0.3",
"uint8arrays": "4.0.4",
"uuid": "9.0.0",
"web-did-resolver": "2.0.27"
},
Expand Down
48 changes: 24 additions & 24 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"update-veramo-latest": "pnpm add @veramo/core@latest @veramo/discovery@latest @veramo/remote-client@latest @veramo/remote-server@latest @veramo/did-provider-key@latest @veramo/did-resolver@latest @veramo/did-jwt@latest @veramo/credential-w3c@latest @veramo/did-provider-ethr@latest @veramo/did-provider-web@latest @veramo/did-comm@latest @veramo/kms-local@latest @veramo/selective-disclosure@latest @veramo/data-store@latest @veramo/key-manager@latest @veramo/message-handler@latest @veramo/did-manager@latest @veramo/url-handler@latest @veramo/credential-eip712@latest @veramo/utils@latest"
},
"dependencies": {
"@microsoft/api-extractor": "^7.35.1",
"@microsoft/api-extractor-model": "^7.27.1",
"@transmute/credentials-context": "^0.7.0-unstable.79",
"@types/blessed": "^0.1.19",
"@microsoft/api-extractor": "^7.35.2",
"@microsoft/api-extractor-model": "^7.27.2",
"@transmute/credentials-context": "^0.7.0-unstable.81",
"@types/blessed": "^0.1.22",
"@types/swagger-ui-express": "^4.1.3",
"@veramo/core": "workspace:^",
"@veramo/core-types": "workspace:^",
Expand Down Expand Up @@ -64,37 +64,37 @@
"@veramo/utils": "workspace:^",
"blessed": "^0.1.81",
"commander": "^11.0.0",
"console-table-printer": "^2.10.0",
"console-table-printer": "^2.11.1",
"cors": "^2.8.5",
"cross-fetch": "^3.1.6",
"date-fns": "^2.28.0",
"debug": "^4.3.3",
"did-resolver": "^4.0.1",
"dotenv": "^16.0.0",
"date-fns": "^2.30.0",
"debug": "^4.3.4",
"did-resolver": "^4.1.0",
"dotenv": "^16.1.4",
"ethr-did-resolver": "^8.0.0",
"express": "^4.18.2",
"express-handlebars": "^7.0.0",
"express-handlebars": "^7.0.7",
"fuzzy": "^0.1.3",
"handlebars": "^4.7.6",
"inquirer": "^9.1.4",
"handlebars": "^4.7.7",
"inquirer": "^9.2.7",
"inquirer-autocomplete-prompt": "^3.0.0",
"json-schema": "^0.4.0",
"json5": "^2.2.0",
"jsonpointer": "^5.0.0",
"oas-resolver": "^2.5.3",
"openapi-types": "^12.0.2",
"json5": "^2.2.3",
"jsonpointer": "^5.0.1",
"oas-resolver": "^2.5.6",
"openapi-types": "^12.1.3",
"passport": "^0.6.0",
"passport-http-bearer": "^1.0.1",
"pg": "^8.7.1",
"pg": "^8.11.0",
"qrcode-terminal": "^0.12.0",
"sqlite3": "^5.0.8",
"swagger-ui-express": "^4.6.0",
"sqlite3": "^5.1.6",
"swagger-ui-express": "^4.6.3",
"ts-json-schema-generator": "^1.2.0",
"typeorm": "^0.3.10",
"url-parse": "^1.5.4",
"web-did-resolver": "^2.0.21",
"ws": "^8.11.0",
"yaml": "^2.1.3"
"url-parse": "^1.5.10",
"web-did-resolver": "^2.0.24",
"ws": "^8.13.0",
"yaml": "^2.3.1"
},
"devDependencies": {
"@types/debug": "4.1.8",
Expand All @@ -105,7 +105,7 @@
"@types/passport-http-bearer": "1.0.37",
"@types/qrcode-terminal": "0.12.0",
"@types/url-parse": "1.4.8",
"@types/ws": "8.5.4",
"@types/ws": "8.5.5",
"typescript": "5.1.3"
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/explore/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import os from 'os'

export function shortDid(did?: string): string {
if (!did) return ''
did = did.replace(/\?.*$/, '')
if (did.slice(0, 7) === 'did:web') {
return did
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"dependencies": {
"credential-status": "^2.0.5",
"debug": "^4.3.3",
"did-jwt-vc": "^3.1.0",
"did-resolver": "^4.0.1"
"did-jwt-vc": "^3.2.3",
"did-resolver": "^4.1.0"
},
"devDependencies": {
"@types/debug": "4.1.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@veramo/core-types": "workspace:^",
"debug": "^4.3.4",
"events": "^3.2.0",
"z-schema": "^6.0.0"
"z-schema": "^6.0.1"
},
"devDependencies": {
"@types/debug": "4.1.8",
Expand Down
7 changes: 5 additions & 2 deletions packages/credential-eip712/src/agent/CredentialEIP712.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
MANDATORY_CREDENTIAL_CONTEXT,
mapIdentifierKeysToDoc,
processEntryToArray,
removeDIDParameters,
resolveDidOrThrow,
} from '@veramo/utils'
import schema from "../plugin.schema.json" assert { type: 'json' }
Expand Down Expand Up @@ -63,7 +64,7 @@ export class CredentialIssuerEIP712 implements IAgentPlugin {
issuanceDate = issuanceDate.toISOString()
}

const issuer = extractIssuer(args.credential)
const issuer = extractIssuer(args.credential, { removeParameters: true })
if (!issuer || typeof issuer === 'undefined') {
throw new Error('invalid_argument: credential.issuer must not be empty')
}
Expand Down Expand Up @@ -226,9 +227,11 @@ export class CredentialIssuerEIP712 implements IAgentPlugin {
presentation.verifiableCredential = credentials
}

const holder = removeDIDParameters(presentation.holder)

let identifier: IIdentifier
try {
identifier = await context.agent.didManagerGet({ did: presentation.holder })
identifier = await context.agent.didManagerGet({ did: holder })
} catch (e) {
throw new Error('invalid_argument: presentation.holder must be a DID managed by this agent')
}
Expand Down
9 changes: 4 additions & 5 deletions packages/credential-ld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
"@digitalcredentials/jsonld": "^5.2.1",
"@digitalcredentials/jsonld-signatures": "^9.3.1",
"@digitalcredentials/vc": "^5.0.0",
"@transmute/credentials-context": "^0.7.0-unstable.79",
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.79",
"@transmute/json-web-signature": "^0.7.0-unstable.79",
"@transmute/credentials-context": "^0.7.0-unstable.81",
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.81",
"@transmute/json-web-signature": "^0.7.0-unstable.81",
"@veramo-community/lds-ecdsa-secp256k1-recovery2020": "uport-project/EcdsaSecp256k1RecoverySignature2020",
"@veramo/core-types": "workspace:^",
"@veramo/utils": "workspace:^",
"cross-fetch": "^3.1.6",
"debug": "^4.3.3",
"did-resolver": "^4.0.1",
"uint8arrays": "^4.0.3"
"did-resolver": "^4.1.0"
},
"resolutions": {
"@types/react": "18.0.26",
Expand Down
9 changes: 6 additions & 3 deletions packages/credential-ld/src/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
OrPromise,
processEntryToArray,
RecordLike,
removeDIDParameters,
} from '@veramo/utils'

import { LdCredentialModule } from './ld-credential-module.js'
Expand Down Expand Up @@ -98,9 +99,11 @@ export class CredentialIssuerLD implements IAgentPlugin {
//issuanceDate must not be present for presentations because it is not defined in a @context
delete presentation.issuanceDate

const holder = removeDIDParameters(presentation.holder)

let identifier: IIdentifier
try {
identifier = await context.agent.didManagerGet({ did: presentation.holder })
identifier = await context.agent.didManagerGet({ did: holder })
} catch (e) {
throw new Error('invalid_argument: args.presentation.holder must be a DID managed by this agent')
}
Expand Down Expand Up @@ -148,7 +151,7 @@ export class CredentialIssuerLD implements IAgentPlugin {
type: credentialType,
}

const issuer = extractIssuer(credential)
const issuer = extractIssuer(credential, { removeParameters: true })
if (!issuer || typeof issuer === 'undefined') {
throw new Error('invalid_argument: args.credential.issuer must not be empty')
}
Expand Down Expand Up @@ -252,7 +255,7 @@ export class CredentialIssuerLD implements IAgentPlugin {
signingKey = extendedKeys.find((k) => supportedTypes.includes(k.meta.verificationMethod.type))
}


if (!signingKey) throw Error(`key_not_found: No suitable signing key found for ${identifier.did}`)
verificationMethodId = signingKey.meta.verificationMethod.id
return { signingKey, verificationMethodId }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { RequiredAgentMethods, VeramoLdSignature } from '../ld-suites.js'
import { CredentialPayload, DIDDocument, IAgentContext, IKey, TKeyType } from '@veramo/core-types'
import ldsEcdsa from '@veramo-community/lds-ecdsa-secp256k1-recovery2020'
import * as u8a from 'uint8arrays'
import { asArray, encodeJoseBlob } from '@veramo/utils'
import { asArray, bytesToBase64, concat, encodeJoseBlob, stringToUtf8Bytes } from '@veramo/utils'

const { EcdsaSecp256k1RecoveryMethod2020, EcdsaSecp256k1RecoverySignature2020 } = ldsEcdsa

Expand Down Expand Up @@ -36,8 +35,8 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
crit: ['b64'],
}
const headerString = encodeJoseBlob(header)
const messageBuffer = u8a.concat([u8a.fromString(`${headerString}.`, 'utf-8'), args.data])
const messageString = u8a.toString(messageBuffer, 'base64')
const messageBuffer = concat([stringToUtf8Bytes(`${headerString}.`), args.data])
const messageString = bytesToBase64(messageBuffer)
const signature = await context.agent.keyManagerSign({
keyRef: key.kid,
algorithm: 'ES256K-R',
Expand All @@ -59,7 +58,7 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
}),
})

suite.ensureSuiteContext = ({ document }: { document: any, addSuiteContext: boolean }) => {
suite.ensureSuiteContext = ({ document }: { document: any; addSuiteContext: boolean }) => {
document['@context'] = [...asArray(document['@context'] || []), this.getContext()]
}

Expand All @@ -70,12 +69,14 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
return new EcdsaSecp256k1RecoverySignature2020()
}

preSigningCredModification(credential: CredentialPayload): void {
}
preSigningCredModification(credential: CredentialPayload): void {}

async preDidResolutionModification(didUrl: string, didDoc: DIDDocument): Promise<DIDDocument> {
// did:ethr
const idx = didDoc['@context']?.indexOf('https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld') || -1
// did:ethr
const idx =
didDoc['@context']?.indexOf(
'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
) || -1
if (Array.isArray(didDoc['@context']) && idx !== -1) {
didDoc['@context'][idx] = this.getContext()
}
Expand All @@ -85,7 +86,7 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
didDoc.verificationMethod?.forEach((x) => {
if (x.blockchainAccountId) {
if (x.blockchainAccountId.lastIndexOf('@eip155:') !== -1) {
const [ address, chain ] = x.blockchainAccountId.split("@eip155:")
const [address, chain] = x.blockchainAccountId.split('@eip155:')
x.blockchainAccountId = `eip155:${chain}:${address}`
}
}
Expand Down
Loading

0 comments on commit 74c517a

Please sign in to comment.