0.10.3 • Published 2 days ago

@sphereon/oid4vci-issuer v0.10.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 days 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.10.3

14 days ago

0.10.3-next.8

14 days ago

0.10.3-next.6

14 days ago

0.10.3-next.4

14 days ago

0.10.3-next.3

1 month ago

0.10.1

2 months ago

0.10.2

2 months ago

0.10.2-next.5

2 months ago

0.10.2-next.3

2 months ago

0.10.1-next.7

2 months ago

0.10.1-next.3

2 months ago

0.10.1-next.5

2 months ago

0.10.1-next.2

2 months ago

0.9.1-next.6

2 months ago

0.10.0

2 months ago

0.9.1-next.4

3 months ago

0.9.1-next.2

3 months ago

0.8.2-next.88

3 months ago

0.8.2-next.87

3 months ago

0.9.0

3 months ago

0.8.2-unstable.79

3 months ago

0.8.2-next.48

3 months ago

0.8.2-unstable.72

3 months ago

0.8.2-unstable.70

3 months ago

0.8.2-unstable.75

3 months ago

0.8.2-unstable.68

3 months ago

0.8.2-unstable.66

3 months ago

0.8.2-unstable.67

3 months ago

0.8.2-unstable.62

3 months ago

0.8.2-unstable.65

3 months ago

0.8.2-unstable.64

3 months ago

0.8.2-unstable.61

3 months ago

0.8.2-unstable.55

4 months ago

0.8.2-unstable.53

4 months ago

0.8.2-unstable.52

4 months ago

0.8.2-unstable.58

4 months ago

0.8.2-unstable.57

4 months ago

0.8.2-unstable.51

4 months ago

0.8.2-unstable.49

4 months ago

0.8.2-unstable.43

4 months ago

0.8.2-unstable.42

4 months ago

0.8.2-unstable.48

4 months ago

0.8.2-next.37

4 months ago

0.8.2-next.46

4 months ago

0.8.2-next.35

4 months ago

0.8.2-unstable.40

4 months ago

0.8.2-unstable.41

4 months ago

0.8.2-next.34

4 months ago

0.8.2-next.28

4 months ago

0.8.2-unstable.39

4 months ago

0.8.2-unstable.38

4 months ago

0.8.2-unstable.37

4 months ago

0.8.2-unstable.36

4 months ago

0.8.2-next.26

4 months ago

0.8.2-unstable.30

4 months ago

0.8.2-unstable.35

4 months ago

0.8.2-unstable.14

4 months ago

0.8.2-unstable.19

4 months ago

0.8.2-unstable.18

5 months ago

0.8.2-unstable.17

5 months ago

0.8.2-unstable.16

5 months ago

0.6.1-next.6

9 months ago

0.6.1-next.8

9 months ago

0.7.3-next.2

7 months ago

0.7.3-next.3

7 months ago

0.7.1-next.8

8 months ago

0.7.1-next.9

7 months ago

0.7.1-next.7

8 months ago

0.8.2-next.9

6 months ago

0.8.2-next.4

6 months ago

0.6.1-next.11

9 months ago

0.6.1-next.10

9 months ago

0.8.2-next.6

6 months ago

0.7.1-next.26

7 months ago

0.6.1-next.13

9 months ago

0.6.1-next.12

9 months ago

0.7.4-next.11

7 months ago

0.7.4-next.10

7 months ago

0.7.2

7 months ago

0.7.1

7 months ago

0.7.3

7 months ago

0.7.0

9 months ago

0.7.1-unstable.18

7 months ago

0.7.1-next.10

8 months ago

0.7.4-unstable.8

7 months ago

0.7.1-next.11

8 months ago

0.7.1-next.12

8 months ago

0.7.1-next.13

8 months ago

0.7.1-next.14

8 months ago

0.7.1-next.15

7 months ago

0.7.1-next.16

7 months ago

0.7.4-unstable.3

7 months ago

0.8.2-next.12

5 months ago

0.7.4-next.4

7 months ago

0.7.4-next.3

7 months ago

0.7.1-next.17

7 months ago

0.7.1-next.18

7 months ago

0.7.2-next.3

7 months ago

0.7.4-next.9

7 months ago

0.8.1

7 months ago

0.6.1-next.3

11 months ago

0.4.1-unstable.309

11 months ago

0.4.1-next.314

11 months ago

0.4.1-next.311

11 months ago

0.4.1-next.315

11 months ago

0.6.0

11 months ago

0.4.1-unstable.308

11 months ago

0.4.1-unstable.307

11 months ago

0.4.1-unstable.306

11 months ago

0.4.1-next.306

11 months ago

0.4.1-unstable.305

11 months ago

0.4.1-unstable.304

11 months ago

0.4.1-unstable.303

11 months ago

0.4.1-unstable.302

11 months ago

0.4.1-unstable.301

11 months ago

0.4.1-unstable.300

11 months ago

0.4.1-unstable.299

11 months ago

0.4.1-unstable.298

11 months ago

0.4.1-unstable.297

11 months ago

0.4.1-unstable.296

11 months ago

0.4.1-unstable.295

11 months ago

0.4.1-unstable.293

11 months ago

0.4.1-unstable.290

11 months ago

0.4.1-unstable.288

11 months ago

0.4.1-unstable.286

11 months ago

0.4.1-unstable.285

11 months ago

0.4.1-next.285

11 months ago

0.4.1-unstable.284

11 months ago

0.4.1-unstable.282

11 months ago

0.4.1-unstable.281

11 months ago

0.4.1-unstable.280

11 months ago

0.4.1-unstable.279

11 months ago

0.4.1-unstable.278

11 months ago

0.4.1-unstable.277

11 months ago

0.4.1-unstable.276

11 months ago

0.4.1-unstable.275

11 months ago

0.4.1-unstable.270

11 months ago

0.4.1-unstable.269

11 months ago

0.4.1-unstable.268

11 months ago

0.4.1-unstable.267

12 months ago

0.4.1-unstable.266

12 months ago

0.4.1-unstable.265

12 months ago

0.4.1-unstable.264

12 months ago

0.4.1-unstable.263

12 months ago

0.4.1-unstable.262

12 months ago

0.4.1-unstable.261

12 months ago

0.4.1-unstable.260

12 months ago

0.4.1-unstable.256

12 months ago

0.4.1-unstable.255

12 months ago

0.4.1-unstable.254

12 months ago

0.4.1-unstable.253

12 months ago

0.4.1-unstable.250

12 months ago

0.4.1-unstable.248

12 months ago

0.4.1-unstable.247

12 months ago