Skip to content

Commit

Permalink
chore: update deps and VC API readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jul 30, 2023
1 parent ba897de commit a7cf5cd
Show file tree
Hide file tree
Showing 17 changed files with 572 additions and 423 deletions.
42 changes: 21 additions & 21 deletions packages/express-support/src/functions.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import express, {NextFunction} from 'express'
import express, { NextFunction } from 'express'
import process from 'process'

export function env(key?: string, prefix?: string): string | undefined {
if (!key) {
return
}
return process.env[`${prefix ? prefix.trim() : ''}${key}`]
if (!key) {
return
}
return process.env[`${prefix ? prefix.trim() : ''}${key}`]
}

export function sendErrorResponse(response: express.Response, statusCode: number, message: string | object, error?: Error) {
console.log(message)
if (error) {
console.log(error)
}
response.statusCode = statusCode
if (typeof message === 'string' && !message.startsWith('{')) {
message = {error: message}
}
if (typeof message === 'string' && message.startsWith('{')) {
return response.status(statusCode).end(message)
}
return response.status(statusCode).json(message)
console.log(message)
if (error) {
console.log(error)
}
response.statusCode = statusCode
if (typeof message === 'string' && !message.startsWith('{')) {
message = { error: message }
}
if (typeof message === 'string' && message.startsWith('{')) {
return response.status(statusCode).end(message)
}
return response.status(statusCode).json(message)
}

export const jsonErrorHandler = (err: any, req: express.Request, res: express.Response, next: NextFunction) => {
if (res.headersSent) {
return next(err)
}
return sendErrorResponse(res, 500, err.message, err)
if (res.headersSent) {
return next(err)
}
return sendErrorResponse(res, 500, err.message, err)
}
8 changes: 4 additions & 4 deletions packages/oid4vci-issuer-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/pex": "^2.0.1",
"@sphereon/pex-models": "^2.0.2",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.key-manager": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.key-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.kms-local": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.13.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.13.0",
"@sphereon/ssi-sdk-ext.key-utils": "0.13.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.13.0",
"@sphereon/ssi-sdk.data-store": "workspace:*",
"@sphereon/ssi-sdk.vc-handler-ld-local": "workspace:*",
"@types/body-parser": "^1.19.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@sphereon/oid4vci-common": "0.6.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-utils": "0.13.0",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
"@types/uuid": "^9.0.1",
"@veramo/core": "4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@sphereon/oid4vci-common": "0.6.0",
"@sphereon/oid4vci-issuer": "0.6.0",
"@sphereon/ssi-sdk-ext.did-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-utils": "0.13.0",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
"@sphereon/ssi-sdk.oid4vci-issuer-store": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation-exchange/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@sphereon/pex": "2.0.1",
"@sphereon/pex-models": "^2.0.2",
"@sphereon/ssi-sdk-ext.did-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-utils": "0.13.0",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
"@sphereon/ssi-types": "workspace:*",
"@veramo/core": "4.2.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-op-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@sphereon/did-auth-siop": "0.3.2-unstable.6",
"@sphereon/pex": "2.0.1",
"@sphereon/pex-models": "2.0.2",
"@sphereon/ssi-sdk-ext.did-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-utils": "0.13.0",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-sdk.presentation-exchange": "workspace:*",
"@sphereon/ssi-types": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@sphereon/did-auth-siop": "0.3.2-unstable.6",
"@sphereon/pex": "2.0.1",
"@sphereon/ssi-sdk-ext.did-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-utils": "0.13.0",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
"@sphereon/ssi-sdk.presentation-exchange": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@sphereon/did-uni-client": "^0.6.0",
"@sphereon/pex": "^2.0.1",
"@sphereon/pex-models": "^2.0.2",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.13.0",
"@sphereon/ssi-sdk.data-store": "workspace:*",
"@sphereon/ssi-sdk.vc-handler-ld-local": "workspace:*",
"@types/body-parser": "^1.19.2",
Expand Down
112 changes: 54 additions & 58 deletions packages/uni-resolver-registrar-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
**Warning: This package is in early development. Breaking changes without notice will happen at this point!**

---

This module provides a DIF Universal Resolver and Universal Registrar API, to allow DIDs managed by the agent to be
resolved using standardized APIs, as well as to create and manage new DIDs using the registrar APIs.

Expand Down Expand Up @@ -71,12 +72,8 @@ curl -X GET\
}
}
],
"authentication": [
"did:web:ddip.sphereon.com#JWK2020-RSA"
],
"assertionMethod": [
"did:web:ddip.sphereon.com#JWK2020-RSA"
],
"authentication": ["did:web:ddip.sphereon.com#JWK2020-RSA"],
"assertionMethod": ["did:web:ddip.sphereon.com#JWK2020-RSA"],
"service": []
}
}
Expand Down Expand Up @@ -162,44 +159,43 @@ Note: You can have multiple instances of the UniResolverApiServer, as long as yo
for each instance and that the same express is being used.

```typescript

// agent is a configured SSI-SDK/Veramo agent (see below for an example)

// Let's first build express to listen on port 5000
const expressBuilder = ExpressBuilder.fromServerOpts({
port: 5000,
hostname: '0.0.0.0',
port: 5000,
hostname: '0.0.0.0',
}).withPassportAuth(false)
const expressArgs = expressBuilder.build({startListening: true})
const expressArgs = expressBuilder.build({ startListening: true })

// Now create the Universal Resolver API, with DID resolution and persistence enabled and authentication disabled
new UniResolverApiServer({
opts: {
enableFeatures: ['did-persist', 'did-resolve'],
endpointOpts: {
basePath: '/1.0', // Let's make sure the eventual path becomes <agent>/1.0/idenfitiers/<did>
globalAuth: {
authentication: {
enabled: false
},
},
opts: {
enableFeatures: ['did-persist', 'did-resolve'],
endpointOpts: {
basePath: '/1.0', // Let's make sure the eventual path becomes <agent>/1.0/idenfitiers/<did>
globalAuth: {
authentication: {
enabled: false,
},
},
},
expressArgs,
agent,
},
expressArgs,
agent,
})
// At this point you can execute the example above, as the Uniresolver is now listening on port 5000
```


## DID Web Service
This service hosts agent managed did:web DIDs at the appropriate locations as a did.json file. Meaning that whenever you hit

This service hosts agent managed did:web DIDs at the appropriate locations as a did.json file. Meaning that whenever you hit
https://agent/.well-known/did.json or http://agent/example/path/test/did.json for instance, the agent will lookup the appropriate DID managed by the agent.
If no DID is found for the URL, it will return the below response, with an HTTP code 404

```json
{
"error": "Not found"
"error": "Not found"
}
```

Expand Down Expand Up @@ -246,46 +242,46 @@ these DID methods.

```typescript
export const resolver = new Resolver({
...getDidWebResolver(),
...getDidKeyResolver(),
...getDidJwkResolver(),
...getDidIonResolver(),
...getDidWebResolver(),
...getDidKeyResolver(),
...getDidJwkResolver(),
...getDidIonResolver(),
})

export const didProviders = {
[`did:web`]: new WebDIDProvider({
defaultKms: 'local',
}),
[`did:key`]: new KeyDIDProvider({
defaultKms: 'local',
}),
[`did:ion`]: new IonDIDProvider({
defaultKms: 'local',
}),
[`did:jwk`]: new JwkDIDProvider({
defaultKms: 'local',
}),
[`did:web`]: new WebDIDProvider({
defaultKms: 'local',
}),
[`did:key`]: new KeyDIDProvider({
defaultKms: 'local',
}),
[`did:ion`]: new IonDIDProvider({
defaultKms: 'local',
}),
[`did:jwk`]: new JwkDIDProvider({
defaultKms: 'local',
}),
}

const agent = createAgent<IDIDManager & IKeyManager & IDataStore & IDataStoreORM & IResolver>({
plugins: [
new DataStore(dbConnection),
new DataStoreORM(dbConnection),
new KeyManager({
store: new KeyStore(dbConnection),
kms: {
local: new KeyManagementSystem(privateKeyStore),
},
}),
new DIDManager({
store: new DIDStore(dbConnection),
defaultProvider: 'did:jwk',
providers: didProviders,
}),
new DIDResolverPlugin({
resolver,
}),
],
plugins: [
new DataStore(dbConnection),
new DataStoreORM(dbConnection),
new KeyManager({
store: new KeyStore(dbConnection),
kms: {
local: new KeyManagementSystem(privateKeyStore),
},
}),
new DIDManager({
store: new DIDStore(dbConnection),
defaultProvider: 'did:jwk',
providers: didProviders,
}),
new DIDResolverPlugin({
resolver,
}),
],
})
```

Expand Down
10 changes: 5 additions & 5 deletions packages/uni-resolver-registrar-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"@sphereon/ssi-sdk.express-support": "workspace:*",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-types": "workspace:*",
"@sphereon/ssi-sdk-ext.did-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.key-utils": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.key-manager": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-utils": "0.13.0",
"@sphereon/ssi-sdk-ext.key-utils": "0.13.0",
"@sphereon/ssi-sdk-ext.key-manager": "0.13.0",
"casbin": "^5.26.1",
"@veramo/core": "4.2.0",
"body-parser": "^1.19.0",
Expand All @@ -34,8 +34,8 @@
"passport": "^0.6.0",
"passport-azure-ad": "^4.3.5",
"morgan": "^1.10.0",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.12.2-next.12",
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.13.0",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.13.0",
"@sphereon/ssi-sdk.data-store": "workspace:*",
"@sphereon/ssi-sdk.vc-handler-ld-local": "workspace:*",
"@types/morgan": "^1.9.4",
Expand Down
Loading

0 comments on commit a7cf5cd

Please sign in to comment.