0.19.0 • Published 2 months ago

@sphereon/oid4vci-issuer v0.19.0

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

7 months ago

0.16.1-fix.234

6 months ago

0.17.1-next.39

2 months ago

0.17.1-next.40

2 months ago

0.17.0

4 months ago

0.16.1-next.309

6 months ago

0.18.2

3 months ago

0.16.1-next.401

4 months ago

0.16.1-next.403

4 months ago

0.16.1-next.402

4 months ago

0.16.1-next.356

5 months ago

0.16.1-next.235

6 months ago

0.16.1-next.237

6 months ago

0.16.1-next.231

7 months ago

0.16.1-next.233

7 months ago

0.16.1-next.225

8 months ago

0.16.1-next.224

8 months ago

0.16.1-next.226

8 months ago

0.16.1-next.229

8 months ago

0.16.1-next.341

6 months ago

0.16.1-next.344

5 months ago

0.16.1-next.339

6 months ago

0.16.1-fix.189

8 months ago

0.16.1-next.252

6 months ago

0.19.0

2 months ago

0.16.1-fix.196

8 months ago

0.16.1-next.197

8 months ago

0.16.1-fix.195

8 months ago

0.16.1-next.181

8 months ago

0.16.1-next.187

8 months ago

0.16.1-fix.173

9 months ago

0.16.1-next.172

9 months ago

0.16.1-next.168

9 months ago

0.16.1-fix.170

9 months ago

0.16.1-next.166

9 months ago

0.16.1-next.69

9 months ago

0.16.1-unstable.86

10 months ago

0.16.1-unstable.57

10 months ago

0.16.1-unstable.96

10 months ago

0.16.1-unstable.122

10 months ago

0.16.1-unstable.121

10 months ago

0.16.1-unstable.120

10 months ago

0.16.1-unstable.91

10 months ago

0.16.1-next.66

9 months ago

0.16.1-unstable.92

10 months ago

0.16.1-unstable.93

10 months ago

0.16.1-unstable.94

10 months ago

0.16.1-unstable.101

10 months ago

0.16.1-unstable.100

10 months ago

0.16.1-unstable.105

10 months ago

0.16.1-next.3

12 months ago

0.10.4-next.3

1 year ago

0.14.1-next.10

1 year ago

0.13.1-next.4

1 year ago

0.16.1-unstable.67

10 months ago

0.16.1-unstable.68

10 months ago

0.13.1-next.9

1 year ago

0.12.1-next.2

1 year ago

0.12.1-next.3

1 year ago

0.12.1-next.4

1 year ago

0.12.1-next.5

1 year ago

0.16.1-next.48

10 months ago

0.15.0

1 year ago

0.15.1

12 months ago

0.16.1-unstable.5

12 months ago

0.13.1-next.13

12 months ago

0.13.1-next.10

1 year ago

0.13.1-next.11

1 year ago

0.12.1-next.25

1 year ago

0.12.1-next.24

1 year ago

0.12.1-next.23

1 year ago

0.15.1-next.9

12 months ago

0.12.1-next.22

1 year ago

0.15.1-next.4

12 months ago

0.12.1-next.29

1 year ago

0.12.1-next.28

1 year ago

0.12.1-next.27

1 year ago

0.12.1-next.21

1 year ago

0.16.0

12 months ago

0.12.1-next.19

1 year ago

0.16.1-next.50

10 months ago

0.15.2-next.38

12 months ago

0.13.0

1 year ago

0.15.2-unstable.8

12 months ago

0.10.4-next.25

1 year ago

0.10.4-next.24

1 year ago

0.10.4-next.23

1 year ago

0.10.4-next.22

1 year ago

0.10.4-next.21

1 year ago

0.16.1-next.26

10 months ago

0.16.1-next.29

10 months ago

0.10.4-next.20

1 year ago

0.14.0

1 year ago

0.16.1-next.24

11 months ago

0.16.1-next.25

11 months ago

0.10.4-next.17

1 year ago

0.10.4-next.14

1 year ago

0.10.4-next.19

1 year ago

0.10.4-next.18

1 year ago

0.16.1-next.15

11 months ago

0.16.1-next.13

11 months ago

0.16.1-next.14

11 months ago

0.16.1-unstable.32

10 months ago

0.16.1-unstable.33

11 months ago

0.16.1-unstable.34

10 months ago

0.15.2-next.7

12 months ago

0.10.4-next.119

1 year ago

0.10.4-next.31

1 year ago

0.10.4-next.30

1 year ago

0.16.1-unstable.16

11 months ago

0.12.0

1 year ago

0.16.1-next.8

11 months ago

0.16.1-next.4

11 months ago

0.16.1-next.5

11 months ago

0.16.1-unstable.25

11 months ago

0.16.1-next.6

11 months ago

0.16.1-next.7

11 months ago

0.16.1-unstable.27

11 months ago

0.16.1-unstable.28

11 months ago

0.15.2-next.3

12 months ago

0.10.3

1 year ago

0.10.3-next.8

1 year ago

0.10.3-next.6

1 year ago

0.10.3-next.4

1 year ago

0.10.3-next.3

1 year ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.2-next.5

1 year ago

0.10.2-next.3

1 year ago

0.10.1-next.7

1 year ago

0.10.1-next.3

1 year ago

0.10.1-next.5

1 year ago

0.10.1-next.2

1 year ago

0.9.1-next.6

1 year ago

0.10.0

1 year ago

0.9.1-next.4

1 year ago

0.9.1-next.2

1 year ago

0.8.2-next.88

1 year ago

0.8.2-next.87

1 year ago

0.9.0

1 year ago

0.8.2-next.48

1 year ago

0.8.2-next.37

1 year ago

0.8.2-next.46

1 year ago

0.8.2-next.35

1 year 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

2 years ago

0.4.1-next.314

2 years ago

0.4.1-next.311

2 years ago

0.4.1-next.315

2 years ago

0.6.0

2 years ago

0.4.1-next.306

2 years ago

0.4.1-next.285

2 years ago