Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into oid4vci-draft-13
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoGlastra committed Jul 17, 2024
2 parents 09a5907 + 7d5ebba commit bdc50c3
Show file tree
Hide file tree
Showing 88 changed files with 2,783 additions and 2,080 deletions.
5 changes: 0 additions & 5 deletions .changeset/big-baboons-poke.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/eighty-radios-grin.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/lemon-kangaroos-walk.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/nice-meals-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@credo-ts/core": patch
"@credo-ts/openid4vc": patch
---

Adds support for issuance and verification of SD-JWT VCs using x509 certificates over OpenID4VC, as well as adds support for the `x509_san_uri` and `x509_san_dns` values for `client_id_scheme`. It also adds support for OpenID4VP Draft 20
5 changes: 5 additions & 0 deletions .changeset/pink-icons-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@credo-ts/core': patch
---

Treat an empty received handshake_protocols array as undefined
5 changes: 5 additions & 0 deletions .changeset/pretty-spies-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@credo-ts/core': patch
---

Allow to pass in a key instance when registering a DID jwk, key or peer with num algo 0
2 changes: 1 addition & 1 deletion demo-openid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@hyperledger/anoncreds-nodejs": "^0.2.2",
"@hyperledger/aries-askar-nodejs": "^0.2.1",
"@hyperledger/aries-askar-nodejs": "^0.2.3",
"@hyperledger/indy-vdr-nodejs": "^0.2.2",
"express": "^4.18.1",
"inquirer": "^8.2.5"
Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@hyperledger/indy-vdr-nodejs": "^0.2.2",
"@hyperledger/anoncreds-nodejs": "^0.2.2",
"@hyperledger/aries-askar-nodejs": "^0.2.1",
"@hyperledger/aries-askar-nodejs": "^0.2.3",
"inquirer": "^8.2.5"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"demo-openid",
"samples/*"
],
"packageManager": "pnpm@9.1.0",
"repository": {
"url": "https://github.com/openwallet-foundation/credo-ts",
"type": "git"
Expand All @@ -31,7 +32,7 @@
},
"devDependencies": {
"@changesets/cli": "^2.27.5",
"@hyperledger/aries-askar-nodejs": "^0.2.1",
"@hyperledger/aries-askar-nodejs": "^0.2.3",
"@jest/types": "^29.6.3",
"@types/bn.js": "^5.1.5",
"@types/cors": "^2.8.10",
Expand Down
8 changes: 8 additions & 0 deletions packages/action-menu/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.5.7

### Patch Changes

- Updated dependencies [352383f]
- Updated dependencies [1044c9d]
- @credo-ts/core@0.5.7

## 0.5.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/action-menu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@credo-ts/action-menu",
"main": "src/index",
"types": "src/index",
"version": "0.5.6",
"version": "0.5.7",
"files": [
"build"
],
Expand Down
9 changes: 9 additions & 0 deletions packages/anoncreds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.5.7

### Patch Changes

- 1044c9d: make credential_preview optional on V2CredentialOfferMessage
- Updated dependencies [352383f]
- Updated dependencies [1044c9d]
- @credo-ts/core@0.5.7

## 0.5.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/anoncreds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@credo-ts/anoncreds",
"main": "src/index",
"types": "src/index",
"version": "0.5.6",
"version": "0.5.7",
"files": [
"build"
],
Expand Down
8 changes: 8 additions & 0 deletions packages/askar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.5.7

### Patch Changes

- Updated dependencies [352383f]
- Updated dependencies [1044c9d]
- @credo-ts/core@0.5.7

## 0.5.6

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/askar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@credo-ts/askar",
"main": "src/index",
"types": "src/index",
"version": "0.5.6",
"version": "0.5.7",
"files": [
"build"
],
Expand Down Expand Up @@ -34,8 +34,8 @@
"tsyringe": "^4.8.0"
},
"devDependencies": {
"@hyperledger/aries-askar-nodejs": "^0.2.1",
"@hyperledger/aries-askar-shared": "^0.2.1",
"@hyperledger/aries-askar-nodejs": "^0.2.3",
"@hyperledger/aries-askar-shared": "^0.2.3",
"@types/bn.js": "^5.1.0",
"@types/ref-array-di": "^1.2.6",
"@types/ref-struct-di": "^1.1.10",
Expand All @@ -44,6 +44,6 @@
"typescript": "~5.5.2"
},
"peerDependencies": {
"@hyperledger/aries-askar-shared": "^0.2.1"
"@hyperledger/aries-askar-shared": "^0.2.3"
}
}
11 changes: 11 additions & 0 deletions packages/askar/src/utils/askarKeyBackend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { KeyBackend as CredoKeyBackend } from '@credo-ts/core'
import { KeyBackend as AskarKeyBackend } from '@hyperledger/aries-askar-shared'

export const convertToAskarKeyBackend = (credoKeyBackend: CredoKeyBackend) => {
switch (credoKeyBackend) {
case CredoKeyBackend.Software:
return AskarKeyBackend.Software
case CredoKeyBackend.SecureElement:
return AskarKeyBackend.SecureElement
}
}
11 changes: 9 additions & 2 deletions packages/askar/src/wallet/AskarBaseWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
WalletError,
Key,
TypedArrayEncoder,
KeyBackend,
} from '@credo-ts/core'
import { CryptoBox, Store, Key as AskarKey, keyAlgFromString } from '@hyperledger/aries-askar-shared'
import BigNumber from 'bn.js'
Expand All @@ -35,6 +36,7 @@ import {
isKeyTypeSupportedByAskarForPurpose,
keyTypesSupportedByAskar,
} from '../utils'
import { convertToAskarKeyBackend } from '../utils/askarKeyBackend'

import { didcommV1Pack, didcommV1Unpack } from './didcommV1'

Expand Down Expand Up @@ -125,7 +127,12 @@ export abstract class AskarBaseWallet implements Wallet {
* Create a key with an optional seed and keyType.
* The keypair is also automatically stored in the wallet afterwards
*/
public async createKey({ seed, privateKey, keyType }: WalletCreateKeyOptions): Promise<Key> {
public async createKey({
seed,
privateKey,
keyType,
keyBackend = KeyBackend.Software,
}: WalletCreateKeyOptions): Promise<Key> {
try {
if (seed && privateKey) {
throw new WalletError('Only one of seed and privateKey can be set')
Expand All @@ -149,7 +156,7 @@ export abstract class AskarBaseWallet implements Wallet {
? AskarKey.fromSecretBytes({ secretKey: privateKey, algorithm })
: seed
? AskarKey.fromSeed({ seed, algorithm })
: AskarKey.generate(algorithm)
: AskarKey.generate(algorithm, convertToAskarKeyBackend(keyBackend))

// FIXME: we need to create a separate const '_key' so TS definitely knows _key is defined in the session callback.
// This will be fixed once we use the new 'using' syntax
Expand Down
27 changes: 16 additions & 11 deletions packages/askar/src/wallet/__tests__/AskarWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from '@credo-ts/core'
import { Store } from '@hyperledger/aries-askar-shared'

import { KeyBackend } from '../../../../core/src/crypto/KeyBackend'
import { encodeToBase58 } from '../../../../core/src/utils/base58'
import { agentDependencies } from '../../../../core/tests/helpers'
import testLogger from '../../../../core/tests/logger'
Expand Down Expand Up @@ -102,7 +103,7 @@ describe('AskarWallet basic operations', () => {
seed,
keyType: KeyType.Ed25519,
})
).rejects.toThrowError()
).rejects.toThrow()
})

test('Create x25519 keypair', async () => {
Expand All @@ -122,13 +123,17 @@ describe('AskarWallet basic operations', () => {
test('throws WalletKeyExistsError when a key already exists', async () => {
const privateKey = TypedArrayEncoder.fromString('2103de41b4ae37e8e28586d84a342b68')
await expect(askarWallet.createKey({ privateKey, keyType: KeyType.Ed25519 })).resolves.toEqual(expect.any(Key))
await expect(askarWallet.createKey({ privateKey, keyType: KeyType.Ed25519 })).rejects.toThrowError(
WalletKeyExistsError
)
await expect(askarWallet.createKey({ privateKey, keyType: KeyType.Ed25519 })).rejects.toThrow(WalletKeyExistsError)
})

test('Fail to create a P384 keypair', async () => {
await expect(askarWallet.createKey({ seed, keyType: KeyType.P384 })).rejects.toThrowError(WalletError)
await expect(askarWallet.createKey({ seed, keyType: KeyType.P384 })).rejects.toThrow(WalletError)
})

test('Fail to create a P256 keypair in hardware', async () => {
await expect(
askarWallet.createKey({ keyType: KeyType.P256, keyBackend: KeyBackend.SecureElement })
).rejects.toThrow(WalletError)
})

test('Create a signature with a ed25519 keypair', async () => {
Expand Down Expand Up @@ -186,12 +191,12 @@ describe.skip('Currently, all KeyTypes are supported by Askar natively', () => {
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public async sign(options: SignOptions): Promise<Buffer> {
public async sign(_options: SignOptions): Promise<Buffer> {
return new Buffer('signed')
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public async verify(options: VerifyOptions): Promise<boolean> {
public async verify(_options: VerifyOptions): Promise<boolean> {
return true
}
}
Expand Down Expand Up @@ -268,7 +273,7 @@ describe('AskarWallet management', () => {
await askarWallet.close()
await expect(
askarWallet.createAndOpen({ ...walletConfig, id: 'AskarWallet Create', key: anotherKey })
).rejects.toThrowError(WalletDuplicateError)
).rejects.toThrow(WalletDuplicateError)
})

test('Open', async () => {
Expand All @@ -282,14 +287,14 @@ describe('AskarWallet management', () => {

// Close and try to re-opening it with a wrong key
await askarWallet.close()
await expect(askarWallet.open({ ...walletConfig, id: 'AskarWallet Open', key: wrongKey })).rejects.toThrowError(
await expect(askarWallet.open({ ...walletConfig, id: 'AskarWallet Open', key: wrongKey })).rejects.toThrow(
WalletInvalidKeyError
)

// Try to open a non existent wallet
await expect(
askarWallet.open({ ...walletConfig, id: 'AskarWallet Open - Non existent', key: initialKey })
).rejects.toThrowError(WalletNotFoundError)
).rejects.toThrow(WalletNotFoundError)
})

test('Rotate key', async () => {
Expand All @@ -313,7 +318,7 @@ describe('AskarWallet management', () => {

await expect(
askarWallet.open({ ...walletConfig, id: 'AskarWallet Key Rotation', key: initialKey })
).rejects.toThrowError(WalletInvalidKeyError)
).rejects.toThrow(WalletInvalidKeyError)

await askarWallet.open({ ...walletConfig, id: 'AskarWallet Key Rotation', key: newKey })

Expand Down
8 changes: 8 additions & 0 deletions packages/bbs-signatures/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.5.7

### Patch Changes

- Updated dependencies [352383f]
- Updated dependencies [1044c9d]
- @credo-ts/core@0.5.7

## 0.5.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/bbs-signatures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@credo-ts/bbs-signatures",
"main": "src/index",
"types": "src/index",
"version": "0.5.6",
"version": "0.5.7",
"files": [
"build"
],
Expand Down
10 changes: 10 additions & 0 deletions packages/cheqd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.5.7

### Patch Changes

- 8474776: Fix a build issue where importing cheqd pacakge would not work and give type errors
- Updated dependencies [352383f]
- Updated dependencies [1044c9d]
- @credo-ts/core@0.5.7
- @credo-ts/anoncreds@0.5.7

## 0.5.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cheqd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@credo-ts/cheqd",
"main": "src/index",
"types": "src/index",
"version": "0.5.6",
"version": "0.5.7",
"files": [
"build"
],
Expand Down
7 changes: 7 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.5.7

### Patch Changes

- 352383f: Fix a build issue where the types would reference source code not available in the published NPM package
- 1044c9d: make credential_preview optional on V2CredentialOfferMessage

## 0.5.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@credo-ts/core",
"main": "src/index",
"types": "src/index",
"version": "0.5.6",
"version": "0.5.7",
"files": [
"build"
],
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/agent/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Subject } from 'rxjs'
import { concatMap, takeUntil } from 'rxjs/operators'

import { InjectionSymbols } from '../constants'
import { SigningProviderToken, X509Service } from '../crypto'
import { SigningProviderToken } from '../crypto'
import { JwsService } from '../crypto/JwsService'
import { CredoError } from '../error'
import { DependencyManager } from '../plugins'
Expand Down Expand Up @@ -59,7 +59,6 @@ export class Agent<AgentModules extends AgentModulesInput = any> extends BaseAge
dependencyManager.registerSingleton(DidCommMessageRepository)
dependencyManager.registerSingleton(StorageVersionRepository)
dependencyManager.registerSingleton(StorageUpdateService)
dependencyManager.registerSingleton(X509Service)

// This is a really ugly hack to make tsyringe work without any SigningProviders registered
// It is currently impossible to use @injectAll if there are no instances registered for the
Expand Down
Loading

0 comments on commit bdc50c3

Please sign in to comment.