Skip to content

Commit

Permalink
Merge pull request #1227 from uport-project/next
Browse files Browse the repository at this point in the history
chore: new minor release
  • Loading branch information
mirceanis authored Sep 19, 2023
2 parents ccdccf2 + ce9cca9 commit cfea408
Show file tree
Hide file tree
Showing 72 changed files with 6,042 additions and 3,512 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
shard: [1, 2, 3, 4, 5]
services:
postgres:
image: postgres:15.1
image: postgres:15.4
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test123
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest
needs: [test-integration]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-test-publish-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
shard: [1, 2, 3, 4, 5]
services:
postgres:
image: postgres:15.1
image: postgres:15.4
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: test123
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
runs-on: ubuntu-latest
needs: [test-integration]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
GH_EMAIL: ${{secrets.GH_EMAIL}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{secrets.GH_TOKEN}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-next-with-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: everlytic/branch-merge@1.1.5
with:
github_token: ${{ secrets.GH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion __tests__/initial.migration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('database initial migration tests', () => {
}),
new DIDManager({
store: new DIDStore(dbConnection),
defaultProvider: 'did:ethr:goerli',
defaultProvider: 'did:key',
providers: {
// intentionally using deprecated config for backward compatibility checks
'did:ethr:goerli': new EthrDIDProvider({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDManager({
store: new DIDStore(dbConnection),
defaultProvider: 'did:ethr:goerli',
defaultProvider: 'did:ethr:ganache',
providers: {
'did:ethr': new EthrDIDProvider({
defaultKms: 'local',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/localJsonStoreAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDManager({
store: new DIDStoreJson(jsonFileStore),
defaultProvider: 'did:ethr:goerli',
defaultProvider: 'did:ethr',
providers: {
'did:ethr': new EthrDIDProvider({
defaultKms: 'local',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/localMemoryStoreAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDManager({
store: new MemoryDIDStore(),
defaultProvider: 'did:ethr:goerli',
defaultProvider: 'did:key',
providers: {
'did:ethr': new EthrDIDProvider({
defaultKms: 'local',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDManager({
store: new DIDStore(dbConnection),
defaultProvider: 'did:ethr:goerli',
defaultProvider: 'did:jwk',
providers: {
'did:ethr': new EthrDIDProvider({
defaultKms: 'local',
Expand Down
15 changes: 9 additions & 6 deletions __tests__/shared/credentialStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import { jest } from '@jest/globals'
type ConfiguredAgent = TAgent<IDIDManager & ICredentialPlugin & IDataStore & IDataStoreORM>

// Constant used to simulate exception flows
const simulateStatusVerificationFailure = 'Any unexpected failure during status verification.'
const simulateStatusVerificationFailure = 'Any_unexpected_failure_during_status_verification.'

// Constant used to simulate revoked credentials
const simulateRevokedCredential = 'A revoked credential.'
const simulateRevokedCredential = 'A_revoked_credential.'

// Constant used to simulate revoked credentials
const simulateNotRevokedCredential = 'A NOT revoked credential.'
const simulateNotRevokedCredential = 'A_NOT_revoked_credential.'

const callsCounter = jest.fn()

Expand Down Expand Up @@ -69,7 +69,11 @@ export default (testContext: {
],
})
agent = testContext.getAgent()
identifier = await agent.didManagerCreate({ kms: 'local' })
identifier = await agent.didManagerCreate({
kms: 'local',
provider: 'did:pkh',
options: { keyType: 'Secp256k1' },
})

rawCredential = buildCredential(identifier, {
type: 'ExoticStatusMethod2022',
Expand Down Expand Up @@ -208,7 +212,7 @@ export default (testContext: {
plugins: [],
})
agent = testContext.getAgent()
identifier = await agent.didManagerCreate({ kms: 'local' })
identifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:jwk' })

rawCredential = {
issuer: { id: identifier.did },
Expand All @@ -234,7 +238,6 @@ export default (testContext: {
})
expect(vc).toHaveProperty('proof.jwt')

// TODO It`s an exception flow an it'd be better to throw an exception instead of returning false
await expect(agent.verifyCredential({ credential: vc })).rejects.toThrow(
`invalid_setup: The credential status can't be verified because there is no ICredentialStatusVerifier plugin installed.`,
)
Expand Down
7 changes: 0 additions & 7 deletions __tests__/shared/didManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,6 @@ export default (testContext: {
})

expect(identifier6).toEqual(identifier5)

const identifier7 = await agent.didManagerGetByAlias({
alias: 'alice',
// default provider is 'did:ethr:goerli'
})

expect(identifier7).toEqual(identifier4)
})

it('should get identifiers', async () => {
Expand Down
22 changes: 11 additions & 11 deletions __tests__/shared/documentationExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,41 @@ export default (testContext: {
//DO NOT EDIT MANUALLY START

it('core-types-IResolver-getDIDComponentById example', async () => {
const did = 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const did = 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const didFragment = `${did}#controller`
const fragment = await agent.getDIDComponentById({
didDocument: (await agent.resolveDid({ didUrl: did }))?.didDocument,
didUrl: didFragment,
section: 'authentication',
})
expect(fragment).toEqual({
id: 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
id: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
blockchainAccountId: 'eip155:5:0xb09B66026bA5909A7CFE99b76875431D2b8D5190',
controller: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
blockchainAccountId: 'eip155:1:0xb09B66026bA5909A7CFE99b76875431D2b8D5190',
})
})

it('core-types-IResolver-resolveDid example', async () => {
const doc = await agent.resolveDid({
didUrl: 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
didUrl: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
})
expect(doc.didDocument).toEqual({
'@context': [
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/suites/secp256k1recovery-2020/v2',
],
id: 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
id: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
verificationMethod: [
{
id: 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
id: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
blockchainAccountId: 'eip155:5:0xb09B66026bA5909A7CFE99b76875431D2b8D5190',
controller: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
blockchainAccountId: 'eip155:1:0xb09B66026bA5909A7CFE99b76875431D2b8D5190',
},
],
authentication: ['did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller'],
assertionMethod: ['did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller'],
authentication: ['did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller'],
assertionMethod: ['did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller'],
})
})

Expand Down
81 changes: 80 additions & 1 deletion __tests__/shared/handleSdrMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default (testContext: {
afterAll(testContext.tearDown)

it('should create identifier', async () => {
identifier = await agent.didManagerCreate({ kms: 'local' })
identifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' })
expect(identifier).toHaveProperty('did')
})

Expand Down Expand Up @@ -82,6 +82,85 @@ export default (testContext: {
expect(message.raw).toEqual(JWT)
})

it('should create and handle an SDR message with Ed25519', async () => {
const sdrIssuer = await agent.didManagerCreate({ provider: 'did:key', options: { keyType: 'Ed25519' } })
const req = await agent.createSelectiveDisclosureRequest({
data: {
issuer: sdrIssuer.did,
tag: 'sdr-one',
claims: [
{
reason: 'We need it',
claimType: 'name',
essential: true,
},
],
},
})

const message = await agent.handleMessage({
raw: req,
save: false,
})

expect(message.raw).toEqual(req)
})

it('should create and handle an SDR message with Secp256k1', async () => {
const sdrIssuer = await agent.didManagerCreate({
provider: 'did:ethr',
})
const req = await agent.createSelectiveDisclosureRequest({
data: {
issuer: sdrIssuer.did,
tag: 'sdr-one',
claims: [
{
reason: 'We need it',
claimType: 'name',
essential: true,
},
],
},
})

const message = await agent.handleMessage({
raw: req,
save: false,
})

expect(message.raw).toEqual(req)
})

it('should create and handle an SDR message with Secp256r1', async () => {
const sdrIssuer = await agent.didManagerCreate({
provider: 'did:jwk',
options: {
keyType: 'Secp256r1',
}
})
const req = await agent.createSelectiveDisclosureRequest({
data: {
issuer: sdrIssuer.did,
tag: 'sdr-one',
claims: [
{
reason: 'We need it',
claimType: 'name',
essential: true,
},
],
},
})

const message = await agent.handleMessage({
raw: req,
save: false,
})

expect(message.raw).toEqual(req)
})

it('should be able to find the request message', async () => {
const messages = await agent.dataStoreORMGetMessages()

Expand Down
16 changes: 13 additions & 3 deletions __tests__/shared/keyManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// noinspection ES6PreferShortImport

import { IAgentOptions, IDIDManager, IKeyManager, IResolver, TAgent, TKeyType } from '../../packages/core-types/src'
import {
IAgentOptions,
IDIDManager,
IKeyManager,
IResolver,
TAgent,
TKeyType,
} from '../../packages/core-types/src'
import { computeAddress, serialize } from '@ethersproject/transactions'
import { mapIdentifierKeysToDoc } from '../../packages/utils/src'
import { recoverTypedSignature, SignTypedDataVersion } from '@metamask/eth-sig-util'
Expand Down Expand Up @@ -476,7 +483,7 @@ export default (testContext: {
},
}

const identifier = await agent.didManagerCreate({ kms: 'local' })
const identifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:pkh' })

const extendedKeys = await mapIdentifierKeysToDoc(identifier, 'verificationMethod', { agent })
const extendedKey = extendedKeys[0]
Expand Down Expand Up @@ -575,7 +582,10 @@ export default (testContext: {
},
}

const identifier = await agent.didManagerCreate({ kms: 'local' })
const identifier = await agent.didManagerCreate({
kms: 'local',
provider: 'did:pkh',
})

const extendedKeys = await mapIdentifierKeysToDoc(identifier, 'verificationMethod', { agent })
const extendedKey = extendedKeys[0]
Expand Down
2 changes: 1 addition & 1 deletion __tests__/shared/resolveDid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default (testContext: {
afterAll(testContext.tearDown)

it('should resolve didUrl', async () => {
const didUrl = 'did:ethr:goerli:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const didUrl = 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const didDoc = (await agent.resolveDid({ didUrl })).didDocument
expect(didDoc?.id).toEqual(didUrl)
})
Expand Down
Loading

0 comments on commit cfea408

Please sign in to comment.