0.19.0 • Published 8 months ago

@sphereon/oid4vci-issuer v0.19.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
8 months ago

CI codecov NPM Version

IMPORTANT the packages are in an early development stage and currently only supports the pre-authorized code flow of OpenID4VCI! Work is underway for the Authorized Flows as well, but not fully supported yet

Background

The OpenID4VCI issuer is used in issuer type applications, where an organization is issuing the credential(s)

Credential Offer State Manager

The CredentialOfferState is used to track of the creation date of the credential offer:

export interface CredentialOfferState {
  credentialOffer: CredentialOfferPayloadV1_0_11
  createdOn: number
}

The ICredentialOfferStateManager allows to have a custom implementation of the state manager:

export interface ICredentialOfferStateManager {
  setState(state: string, payload: CredentialOfferState): Promise<Map<string, CredentialOfferState>>

  getState(state: string): Promise<CredentialOfferState | undefined>

  hasState(state: string): Promise<boolean>

  deleteState(state: string): Promise<boolean>

  clearExpiredStates(timestamp?: number): Promise<void> // clears all expired states compared against timestamp if provided, otherwise current timestamp

  clearAllStates(): Promise<void> // clears all states
}

Here is an example, an in-memory implementation of the ICredentialOfferStateManager

export class MemoryCredentialOfferStateManager implements ICredentialOfferStateManager {
  private readonly credentialOfferStateManager: Map<string, CredentialOfferState>
  constructor() {
    this.credentialOfferStateManager = new Map()
  }

  async clearAllStates(): Promise<void> {
    this.credentialOfferStateManager.clear()
  }

  async clearExpiredStates(timestamp?: number): Promise<void> {
    const states = Array.from(this.credentialOfferStateManager.entries())
    timestamp = timestamp ?? +new Date()
    for (const [issuerState, state] of states) {
      if (state.createdOn < timestamp) {
        this.credentialOfferStateManager.delete(issuerState)
      }
    }
  }

  async deleteState(state: string): Promise<boolean> {
    return this.credentialOfferStateManager.delete(state)
  }

  async getState(state: string): Promise<CredentialOfferState | undefined> {
    return this.credentialOfferStateManager.get(state)
  }

  async hasState(state: string): Promise<boolean> {
    return this.credentialOfferStateManager.has(state)
  }

  async setState(state: string, payload: CredentialOfferState): Promise<Map<string, CredentialOfferState>> {
    return this.credentialOfferStateManager.set(state, payload)
  }
}

Usage

Pass an instance of the state manager to the VC Issuer Builder

const vcIssuer = new VcIssuerBuilder()
  .withAuthorizationServer('https://authorization-server')
  .withCredentialEndpoint('https://credential-endpoint')
  .withCredentialIssuer('https://credential-issuer')
  .withIssuerDisplay({
    name: 'example issuer',
    locale: 'en-US',
  })
  .withCredentialsSupported(credentialsSupported)
  .withInMemoryCredentialOfferStates(new MemoryCredentialOfferStateManager())
  .build()
0.16.1-fix.230

1 year ago

0.16.1-fix.234

12 months ago

0.17.1-next.39

8 months ago

0.17.1-next.40

8 months ago

0.17.0

10 months ago

0.16.1-next.309

12 months ago

0.18.2

9 months ago

0.16.1-next.401

10 months ago

0.16.1-next.403

10 months ago

0.16.1-next.402

10 months ago

0.16.1-next.356

11 months ago

0.16.1-next.235

1 year ago

0.16.1-next.237

12 months ago

0.16.1-next.231

1 year ago

0.16.1-next.233

1 year ago

0.16.1-next.225

1 year ago

0.16.1-next.224

1 year ago

0.16.1-next.226

1 year ago

0.16.1-next.229

1 year ago

0.16.1-next.341

12 months ago

0.16.1-next.344

11 months ago

0.16.1-next.339

12 months ago

0.16.1-fix.189

1 year ago

0.16.1-next.252

12 months ago

0.19.0

8 months ago

0.16.1-fix.196

1 year ago

0.16.1-next.197

1 year ago

0.16.1-fix.195

1 year ago

0.16.1-next.181

1 year ago

0.16.1-next.187

1 year ago

0.16.1-fix.173

1 year ago

0.16.1-next.172

1 year ago

0.16.1-next.168

1 year ago

0.16.1-fix.170

1 year ago

0.16.1-next.166

1 year ago

0.16.1-next.69

1 year ago

0.16.1-next.66

1 year ago

0.16.1-next.3

1 year ago

0.10.4-next.3

2 years ago

0.14.1-next.10

1 year ago

0.13.1-next.4

2 years ago

0.13.1-next.9

2 years ago

0.12.1-next.2

2 years ago

0.12.1-next.3

2 years ago

0.12.1-next.4

2 years ago

0.12.1-next.5

2 years ago

0.16.1-next.48

1 year ago

0.15.0

1 year ago

0.15.1

1 year ago

0.13.1-next.13

1 year ago

0.13.1-next.10

2 years ago

0.13.1-next.11

2 years ago

0.12.1-next.25

2 years ago

0.12.1-next.24

2 years ago

0.12.1-next.23

2 years ago

0.15.1-next.9

1 year ago

0.12.1-next.22

2 years ago

0.15.1-next.4

1 year ago

0.12.1-next.29

2 years ago

0.12.1-next.28

2 years ago

0.12.1-next.27

2 years ago

0.12.1-next.21

2 years ago

0.16.0

1 year ago

0.12.1-next.19

2 years ago

0.16.1-next.50

1 year ago

0.15.2-next.38

1 year ago

0.13.0

2 years ago

0.10.4-next.25

2 years ago

0.10.4-next.24

2 years ago

0.10.4-next.23

2 years ago

0.10.4-next.22

2 years ago

0.10.4-next.21

2 years ago

0.16.1-next.26

1 year ago

0.16.1-next.29

1 year ago

0.10.4-next.20

2 years ago

0.14.0

2 years ago

0.16.1-next.24

1 year ago

0.16.1-next.25

1 year ago

0.10.4-next.17

2 years ago

0.10.4-next.14

2 years ago

0.10.4-next.19

2 years ago

0.10.4-next.18

2 years ago

0.16.1-next.15

1 year ago

0.16.1-next.13

1 year ago

0.16.1-next.14

1 year ago

0.15.2-next.7

1 year ago

0.10.4-next.119

2 years ago

0.10.4-next.31

2 years ago

0.10.4-next.30

2 years ago

0.12.0

2 years ago

0.16.1-next.8

1 year ago

0.16.1-next.4

1 year ago

0.16.1-next.5

1 year ago

0.16.1-next.6

1 year ago

0.16.1-next.7

1 year ago

0.15.2-next.3

1 year ago

0.10.3

2 years ago

0.10.3-next.8

2 years ago

0.10.3-next.6

2 years ago

0.10.3-next.4

2 years ago

0.10.3-next.3

2 years ago

0.10.1

2 years ago

0.10.2

2 years ago

0.10.2-next.5

2 years ago

0.10.2-next.3

2 years ago

0.10.1-next.7

2 years ago

0.10.1-next.3

2 years ago

0.10.1-next.5

2 years ago

0.10.1-next.2

2 years ago

0.9.1-next.6

2 years ago

0.10.0

2 years ago

0.9.1-next.4

2 years ago

0.9.1-next.2

2 years ago

0.8.2-next.88

2 years ago

0.8.2-next.87

2 years ago

0.9.0

2 years ago

0.8.2-next.48

2 years ago

0.8.2-next.37

2 years ago

0.8.2-next.46

2 years ago

0.8.2-next.35

2 years ago

0.8.2-next.34

2 years ago

0.8.2-next.28

2 years ago

0.8.2-next.26

2 years ago

0.6.1-next.6

2 years ago

0.6.1-next.8

2 years ago

0.7.3-next.2

2 years ago

0.7.3-next.3

2 years ago

0.7.1-next.8

2 years ago

0.7.1-next.9

2 years ago

0.7.1-next.7

2 years ago

0.8.2-next.9

2 years ago

0.8.2-next.4

2 years ago

0.6.1-next.11

2 years ago

0.6.1-next.10

2 years ago

0.8.2-next.6

2 years ago

0.7.1-next.26

2 years ago

0.6.1-next.13

2 years ago

0.6.1-next.12

2 years ago

0.7.4-next.11

2 years ago

0.7.4-next.10

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.3

2 years ago

0.7.0

2 years ago

0.7.1-next.10

2 years ago

0.7.4-unstable.8

2 years ago

0.7.1-next.11

2 years ago

0.7.1-next.12

2 years ago

0.7.1-next.13

2 years ago

0.7.1-next.14

2 years ago

0.7.1-next.15

2 years ago

0.7.1-next.16

2 years ago

0.7.4-unstable.3

2 years ago

0.8.2-next.12

2 years ago

0.7.4-next.4

2 years ago

0.7.4-next.3

2 years ago

0.7.1-next.17

2 years ago

0.7.1-next.18

2 years ago

0.7.2-next.3

2 years ago

0.7.4-next.9

2 years ago

0.8.1

2 years ago

0.6.1-next.3

3 years ago

0.4.1-next.314

3 years ago

0.4.1-next.311

3 years ago

0.4.1-next.315

3 years ago

0.6.0

3 years ago

0.4.1-next.306

3 years ago

0.4.1-next.285

3 years ago