Skip to content

Commit

Permalink
feat: Add static bearer token callback function option
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Dec 21, 2023
1 parent 9e3fc6a commit 2d5cd5a
Show file tree
Hide file tree
Showing 45 changed files with 491 additions and 157 deletions.
4 changes: 0 additions & 4 deletions packages/agent-config/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.agent-config





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.agent-config
Expand Down
4 changes: 0 additions & 4 deletions packages/contact-manager-rest-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.contact-manager-rest-api





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.contact-manager-rest-api
Expand Down
4 changes: 0 additions & 4 deletions packages/contact-manager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.contact-manager





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.contact-manager
Expand Down
4 changes: 0 additions & 4 deletions packages/data-store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.data-store





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.data-store
Expand Down
3 changes: 2 additions & 1 deletion packages/data-store/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"references": [
{
"path": "../ssi-sdk-core"
}, {
},
{
"path": "../ssi-types"
}
]
Expand Down
4 changes: 0 additions & 4 deletions packages/dev/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.dev





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.dev
Expand Down
4 changes: 0 additions & 4 deletions packages/issuance-branding/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.issuance-branding





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.issuance-branding
Expand Down
4 changes: 0 additions & 4 deletions packages/kv-store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.kv-store-temp





## [0.17.4](https://github.com/uport-project/veramo/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.kv-store-temp
Expand Down
4 changes: 0 additions & 4 deletions packages/ms-authenticator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.ms-authenticator





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.ms-authenticator
Expand Down
4 changes: 0 additions & 4 deletions packages/ms-request-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.ms-request-api





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.ms-request-api
Expand Down
4 changes: 0 additions & 4 deletions packages/oid4vci-issuer-rest-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer-rest-api





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer-rest-api
Expand Down
4 changes: 0 additions & 4 deletions packages/oid4vci-issuer-rest-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer-rest-client





## [0.17.4](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer-rest-client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export class OID4VCIRestClient implements IAgentPlugin {
Accept: 'application/json',
}
if (this.authOpts?.enabled === true) {
if (!this.authOpts.staticBearerToken) {
if (!this.authOpts.bearerToken) {
throw Error(`Cannot have authentication enabled, whilst not enabling static bearer tokens at this point`)
}
headers.Authorization = `Bearer ${this.authOpts.staticBearerToken}`
headers.Authorization = `Bearer ${this.authOpts.bearerToken}`
}
return headers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IOID4VCIClientCreateOfferUriRequestArgs extends IOID4VCIClientC

export interface IRestClientAuthenticationOpts {
enabled?: boolean
staticBearerToken?: string
bearerToken?: () => Promise<string> | string
}

export interface IOID4VCIClientGetIssueStatusArgs {
Expand Down
4 changes: 0 additions & 4 deletions packages/oid4vci-issuer-store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer-store





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer-store
Expand Down
4 changes: 0 additions & 4 deletions packages/oid4vci-issuer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.oid4vci-issuer
Expand Down
4 changes: 0 additions & 4 deletions packages/presentation-exchange/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.presentation-exchange





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.presentation-exchange
Expand Down
4 changes: 0 additions & 4 deletions packages/qr-code-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.qr-code-generator





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.qr-code-generator
Expand Down
4 changes: 0 additions & 4 deletions packages/siopv2-oid4vp-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-common





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-common
Expand Down
4 changes: 0 additions & 4 deletions packages/siopv2-oid4vp-op-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-op-auth





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-op-auth
Expand Down
4 changes: 0 additions & 4 deletions packages/siopv2-oid4vp-rp-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-rp-auth





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-rp-auth
Expand Down
4 changes: 0 additions & 4 deletions packages/siopv2-oid4vp-rp-rest-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-api
Expand Down
4 changes: 0 additions & 4 deletions packages/siopv2-oid4vp-rp-rest-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-client





## [0.17.4](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
Accept: 'application/json',
}
if (this.authOpts?.enabled === true) {
if (!this.authOpts.staticBearerToken) {
if (!this.authOpts.bearerToken) {
throw Error(`Cannot have authentication enabled, whilst not enabling static bearer tokens at this point`)
}
headers.Authorization = `Bearer ${this.authOpts.staticBearerToken}`
headers.Authorization = `Bearer ${this.authOpts.bearerToken}`
}
return headers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface ISiopClientGetAuthStatusArgs {

export interface Siopv2RestClientAuthenticationOpts {
enabled?: boolean
staticBearerToken?: string
bearerToken?: () => Promise<string> | string
}

export interface Siopv2RestClientOpts {
Expand Down
4 changes: 0 additions & 4 deletions packages/ssi-express-support/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-express-support





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-express-support
Expand Down
29 changes: 18 additions & 11 deletions packages/ssi-express-support/src/express-utils.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
import express, { NextFunction } from 'express'
export function sendErrorResponse(response: express.Response, statusCode: number, message: string | object, error?: any) {
if (!message) {
let msg = message
if (!msg) {
console.error('Message was null when calling sendErrorResponse. This should not happen')
message = 'An unexpected error occurred'
msg = 'An unexpected error occurred'
statusCode = 500
} else {
console.error(`sendErrorResponse: ${typeof message === 'string' ? message : JSON.stringify(message)}`)
console.error(`sendErrorResponse: ${typeof msg === 'string' ? msg : JSON.stringify(msg)}`)
}
if (error) {
console.error(JSON.stringify(error))
if (error instanceof Error) {
console.error(error.message)
}
console.error(`error: ${JSON.stringify(error)}`)
}
if(statusCode == 500) {
if (statusCode === 500) {
console.error(Error().stack)
}
if (response.headersSent) {
console.error(`sendErrorResponse headers already sent`)
return response
}
response.statusCode = statusCode
if (typeof message === 'string' && !message.startsWith('{')) {
message = { error: message }
if (typeof msg === 'string' && !msg.startsWith('{')) {
msg = { error: msg }
}
if (typeof message === 'string' && message.startsWith('{')) {
if (typeof msg === 'string' && msg.startsWith('{')) {
response.header('Content-Type', 'application/json')
return response.status(statusCode).end(message)
return response.status(statusCode).end(msg)
}
return response.status(statusCode).json(message)
return response.status(statusCode).json(msg)
}

export const jsonErrorHandler = (err: any, req: express.Request, res: express.Response, next: NextFunction) => {
const statusCode: number = 'statusCode' in err ? err.statusCode : 500
const errorMsg = typeof err === 'string' ? err : err.message ?? err
let errorMsg = typeof err === 'string' ? err : err.message ?? err
if (typeof errorMsg !== 'string') {
errorMsg = JSON.stringify(errorMsg)
}
if (res.headersSent) {
console.log('Headers already sent, when calling error handler. Will defer to next error handler')
console.log(`Error was: ${JSON.stringify(err)}`)
Expand Down
4 changes: 0 additions & 4 deletions packages/ssi-sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.core





## [0.17.4](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.core
Expand Down
4 changes: 2 additions & 2 deletions packages/ssi-sdk-core/src/utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export const flattenArray = <T>(args: { items: Array<T | Array<T>> }): Array<T>
export const flattenMigrations = <T>(args: { migrations: Array<T | Array<T>> }): Array<T> => args.migrations.flat() as Array<T>

type QueryRunnerType = {
query(query: string, parameters: any[] | undefined, useStructuredResult: true): Promise<any>
query(query: string, parameters?: any[]): Promise<any>
query(query: string, parameters: any[] | undefined, useStructuredResult: true): Promise<any>
query(query: string, parameters?: any[]): Promise<any>
}

/**
Expand Down
4 changes: 0 additions & 4 deletions packages/ssi-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-types





## [0.17.4](https://github.com/Sphereon-OpenSource/ssi-sdk/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-types
Expand Down
4 changes: 0 additions & 4 deletions packages/uni-resolver-registrar-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.uni-resolver-registrar-api





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.uni-resolver-registrar-api
Expand Down
4 changes: 0 additions & 4 deletions packages/vc-handler-ld-local/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

**Note:** Version bump only for package @sphereon/ssi-sdk.vc-handler-ld-local





## [0.17.4](https://github.com/Sphereon-Opensource/SSI-SDK/compare/v0.17.3...v0.17.4) (2023-10-01)

**Note:** Version bump only for package @sphereon/ssi-sdk.vc-handler-ld-local
Expand Down
Loading

0 comments on commit 2d5cd5a

Please sign in to comment.