0.23.4 • Published 24 hours ago

@sphereon/ssi-sdk.siopv2-oid4vp-op-auth v0.23.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
24 hours ago

Warning: This package still is in very early development. Breaking changes without notice will happen at this point!


A Veramo authentication plugin using the Self Issued OpenID Provider v2 (SIOP) authentication library for having clients / people conforming to the Self Issued OpenID Provider v2 (SIOPv2) and OpenID Connect for Verifiable Presentations (OIDC4VP) as specified in the OpenID Connect working group.

Self Issued OpenID Provider v2 (SIOP)

For more information about Self Issued OpenID Provider v2 (SIOP), see the documentation in the readme.

Requirements

For this plugin a DID resolver is also required. A DID resolver can be added to the agent as plugin as seen in the example below.

Available functions

  • getSessionForSiop
  • registerSessionForSiop
  • removeSessionForSiop
  • registerCustomApprovalForSiop
  • removeCustomApprovalForSiop
  • authenticateWithSiop
  • getSiopAuthorizationRequestFromRP
  • getSiopAuthorizationRequestDetails
  • verifySiopAuthorizationRequestURI
  • sendSiopAuthorizationResponse

The following functions can also be used on the session object without the need of a session id first.

  • authenticateWithSiop
  • getSiopAuthorizationRequestFromRP
  • getSiopAuthorizationRequestDetails
  • verifySiopAuthorizationRequestURI
  • sendSiopAuthorizationResponse

Usage

Adding the plugin to an agent:

import { IDidAuthSiopOpAuthenticator } from '@sphereon/ssi-sdk-did-auth-siop-authenticator'
import { Resolver } from 'did-resolver'
import { getDidKeyResolver } from '@veramo/did-provider-key'
import { DIDResolverPlugin } from '@veramo/did-resolver'
import { getUniResolver } from '@sphereon/did-uni-client'

const agent = createAgent<IDidAuthSiopOpAuthenticator & IResolver>({
  plugins: [
    new DidAuthSiopOpAuthenticator(),
    new DIDResolverPlugin({
      resolver: new Resolver({
        ...getDidKeyResolver(),
        ...getUniResolver('lto', { resolveUrl: 'https://uniresolver.test.sphereon.io/1.0/identifiers' }),
        ...getUniResolver('factom', { resolveUrl: 'https://uniresolver.test.sphereon.io/1.0/identifiers' }),
      }),
    }),
  ],
})

Get an OP session:

const sessionId = 'example_session_id'
const opSession = await agent.getSessionForSiop({
  sessionId,
})

Register an OP session:

const sessionId = 'example_session_id'
const identifier = {
  did: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a',
  provider: 'example_provider',
  controllerKeyId: `did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller`,
  keys: [
    {
      kid: `did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#controller`,
      kms: 'example_kms',
      type: 'Ed25519' as const,
      publicKeyHex: '1e21e21e...',
      privateKeyHex: 'elfcvtswdbn...',
    },
  ],
  services: [],
}

const opSession = await agent.registerSessionForSiop({
  sessionId,
  identifier,
})

Remove an OP session:

const sessionId = 'example_session_id'
const opSession = await agent.removeSessionForSiop({
  sessionId,
})

Authenticate with DID auth SIOP:

It is possible to register custom approval functions as an extra confirmation before sending the authentication response. These functions can then be used as an optional parameter. It is also possible to directly provide a custom approval function.

These custom approval functions can also be provided at agent creation.

await agent.registerCustomApprovalForSiop({
  key: 'example_key',
  customApproval: (verifiedAuthorizationRequest: VerifiedAuthorizationRequest) => Promise.resolve(),
})
const sessionId = 'example_session_id'
const stateId = 'example_state_id'
const redirectUrl = 'https://example.com'
const customApprovalKey = 'example_key'
const authenticationResponse = await agent.authenticateWithSiop({
  sessionId,
  stateId,
  redirectUrl,
  customApproval: customApprovalKey,
})
const authenticationResponse = await agent.authenticateWithSiop({
  sessionId,
  stateId,
  redirectUrl,
  customApproval: (verifiedAuthorizationRequest: VerifiedAuthorizationRequest) => {
    return Promise.resolve()
  },
})

Get authorization request from the relying party:

For more detailed information see: Self Issued OpenID Provider v2 (SIOP)

const sessionId = 'example_session_id'
const stateId = 'example_state_id'
const redirectUrl = 'https://example.com'
const authorizationRequest = await agent.getSiopAuthorizationRequestFromRP({
  sessionId,
  stateId,
  redirectUrl,
})

Get authorization request details:

For more detailed information see: Self Issued OpenID Provider v2 (SIOP)

const sessionId = 'example_session_id'
const authorizationRequestDetailsResponse = await agent.getSiopAuthorizationRequestDetails({
  sessionId,
  verifiedAuthorizationRequest: createAuthorizationResponse,
})

Verify authorization request URI:

For more detailed information see: Self Issued OpenID Provider v2 (SIOP)

const sessionId = 'example_session_id'
const verifiedAuthorizationResponse = await agent.verifySiopAuthorizationRequestURI({
  sessionId,
  requestURI: createAuthorizationResponse,
})

Send authorization response:

For more detailed information see: Self Issued OpenID Provider v2 (SIOP)

const sessionId = 'example_session_id'
const authorizationResponse = await agent.sendSiopAuthorizationResponse({
  sessionId,
  verifiedAuthorizationRequest: verifiedAuthorizationResponse,
})

Installation

yarn add @sphereon/ssi-sdk-did-auth-siop-authenticator

Build

yarn build
0.23.5-unstable.17

24 hours ago

0.23.5-next.12

6 days ago

0.23.5-next.11

7 days ago

0.23.5-next.10

9 days ago

0.23.1-next.7

14 days ago

0.23.3-next.3

14 days ago

0.23.4

14 days ago

0.23.2

14 days ago

0.23.2-next.4

14 days ago

0.23.1-next.2

14 days ago

0.23.1

14 days ago

0.23.0

15 days ago

0.21.2-next.25

15 days ago

0.21.2-next.23

27 days ago

0.21.2-next.8

29 days ago

0.21.2-next.7

29 days ago

0.21.2-next.6

29 days ago

0.21.2-next.17

28 days ago

0.21.1

1 month ago

0.22.0

1 month ago

0.21.1-next.8

1 month ago

0.21.1-next.4

1 month ago

0.21.1-unstable.5

2 months ago

0.19.1-next.125

2 months ago

0.19.1-next.126

2 months ago

0.21.0

2 months ago

0.19.1-next.119

2 months ago

0.19.1-next.135

2 months ago

0.21.1-next.2

2 months ago

0.19.1-next.117

2 months ago

0.19.1-next.113

2 months ago

0.19.1-next.114

2 months ago

0.19.1-next.115

2 months ago

0.19.1-next.116

2 months ago

0.19.1-next.111

2 months ago

0.19.1-next.112

2 months ago

0.19.1-next.105

2 months ago

0.19.1-next.110

2 months ago

0.19.1-next.106

2 months ago

0.19.1-next.108

2 months ago

0.19.1-next.109

2 months ago

0.19.1-next.98

2 months ago

0.19.1-next.99

2 months ago

0.19.1-next.102

2 months ago

0.19.1-next.100

2 months ago

0.19.1-next.101

2 months ago

0.19.1-next.96

2 months ago

0.19.1-unstable.88

2 months ago

0.19.1-unstable.89

2 months ago

0.19.1-unstable.86

2 months ago

0.19.1-unstable.87

2 months ago

0.19.1-unstable.93

2 months ago

0.19.1-unstable.94

2 months ago

0.19.1-unstable.91

2 months ago

0.19.1-unstable.92

2 months ago

0.19.1-unstable.90

2 months ago

0.19.1-unstable.84

2 months ago

0.19.1-unstable.85

2 months ago

0.19.1-unstable.82

2 months ago

0.19.1-unstable.80

2 months ago

0.19.1-unstable.81

2 months ago

0.19.1-unstable.78

2 months ago

0.19.1-unstable.77

2 months ago

0.19.1-unstable.75

2 months ago

0.19.1-next.75

2 months ago

0.19.1-unstable.73

2 months ago

0.19.1-unstable.74

2 months ago

0.19.1-unstable.69

2 months ago

0.19.1-unstable.67

2 months ago

0.19.1-unstable.65

2 months ago

0.19.1-unstable.63

2 months ago

0.19.1-next.2

2 months ago

0.18.2-unstable.98

2 months ago

0.19.1-next.24

2 months ago

0.19.0

2 months ago

0.18.2-next.96

2 months ago

0.18.2-unstable.57

2 months ago

0.18.2-unstable.97

2 months ago

0.18.2-next.95

2 months ago

0.18.2-next.94

2 months ago

0.18.2-next.92

2 months ago

0.18.2-unstable.96

2 months ago

0.18.2-unstable.95

2 months ago

0.18.2-unstable.55

2 months ago

0.18.2-unstable.89

2 months ago

0.18.2-unstable.88

2 months ago

0.18.2-unstable.90

2 months ago

0.18.2-unstable.87

2 months ago

0.18.2-unstable.85

2 months ago

0.18.2-next.58

3 months ago

0.18.2-next.62

3 months ago

0.18.2-unstable.12

3 months ago

0.18.2-unstable.61

3 months ago

0.18.2-next.77

3 months ago

0.18.2-unstable.56

3 months ago

0.18.2-unstable.53

3 months ago

0.18.2-unstable.67

3 months ago

0.18.2-next.57

3 months ago

0.18.2-unstable.64

3 months ago

0.18.2-unstable.59

3 months ago

0.18.2-unstable.60

3 months ago

0.18.2-next.47

3 months ago

0.18.2-next.15

3 months ago

0.18.2-next.17

3 months ago

0.18.2-unstable.54

3 months ago

0.18.2-unstable.51

3 months ago

0.18.2-unstable.50

3 months ago

0.18.2-next.14

3 months ago

0.18.2-unstable.22

3 months ago

0.18.2-next.12

3 months ago

0.18.2-unstable.46

3 months ago

0.18.2-next.9

3 months ago

0.18.2-unstable.14

3 months ago

0.18.2-unstable.13

3 months ago

0.18.2-unstable.44

3 months ago

0.18.2-unstable.34

3 months ago

0.18.2-unstable.36

3 months ago

0.18.2-unstable.35

3 months ago

0.18.2-unstable.33

3 months ago

0.18.2-unstable.32

3 months ago

0.18.2-unstable.30

3 months ago

0.18.2-unstable.5

3 months ago

0.18.2-unstable.6

3 months ago

0.18.2-unstable.7

3 months ago

0.18.2-unstable.8

3 months ago

0.18.2-unstable.10

3 months ago

0.17.6-unstable.79

3 months ago

0.18.2-next.3

4 months ago

0.18.2-unstable.25

4 months ago

0.18.2-unstable.24

4 months ago

0.18.1

4 months ago

0.18.1-next.8

4 months ago

0.18.1-next.3

4 months ago

0.18.1-next.2

4 months ago

0.18.1-next.4

4 months ago

0.17.6-next.61

4 months ago

0.18.0

4 months ago

0.17.6-next.58

4 months ago

0.17.6-unstable.74

4 months ago

0.17.6-unstable.72

4 months ago

0.17.6-unstable.73

4 months ago

0.17.6-unstable.71

4 months ago

0.17.6-next.57

4 months ago

0.17.6-next.56

5 months ago

0.17.6-next.52

5 months ago

0.17.6-unstable.69

5 months ago

0.17.6-unstable.54

5 months ago

0.17.6-unstable.55

5 months ago

0.17.6-unstable.23

5 months ago

0.17.2

7 months ago

0.14.2-unstable.13

9 months ago

0.17.3

7 months ago

0.17.4

7 months ago

0.17.5

7 months ago

0.16.1-next.3

7 months ago

0.17.0

7 months ago

0.17.1

7 months ago

0.17.2-next.2

7 months ago

0.17.2-next.4

7 months ago

0.14.2-unstable.31

9 months ago

0.14.2-unstable.32

9 months ago

0.17.6-unstable.4

7 months ago

0.15.2-next.96

8 months ago

0.17.6-unstable.3

7 months ago

0.15.2-next.95

8 months ago

0.15.2-next.97

8 months ago

0.17.6-unstable.8

6 months ago

0.15.2-unstable.24

9 months ago

0.17.6-unstable.6

7 months ago

0.15.2-unstable.26

9 months ago

0.17.6-unstable.5

7 months ago

0.15.2-unstable.25

9 months ago

0.13.1-next.3

10 months ago

0.13.1-next.4

10 months ago

0.13.1-next.5

10 months ago

0.13.1-next.6

10 months ago

0.13.1-next.7

10 months ago

0.13.1-next.8

10 months ago

0.15.2-unstable.17

9 months ago

0.15.2-unstable.16

9 months ago

0.15.2-unstable.11

9 months ago

0.15.2-unstable.10

9 months ago

0.15.2-unstable.13

9 months ago

0.15.2-unstable.15

9 months ago

0.13.1-next.32

9 months ago

0.17.1-next.2

7 months ago

0.13.1-next.33

9 months ago

0.15.0

9 months ago

0.15.1

9 months ago

0.13.1-next.17

10 months ago

0.13.1-next.14

10 months ago

0.13.1-next.15

10 months ago

0.13.1-next.10

10 months ago

0.13.1-next.18

10 months ago

0.16.0

7 months ago

0.13.1-next.27

10 months ago

0.13.1-next.28

9 months ago

0.13.1-next.25

10 months ago

0.13.1-next.26

10 months ago

0.13.1-next.23

10 months ago

0.13.1-next.24

10 months ago

0.15.1-next.2

9 months ago

0.17.3-next.2

7 months ago

0.15.2-next.39

8 months ago

0.15.2-next.32

8 months ago

0.15.2-next.33

8 months ago

0.15.2-unstable.8

9 months ago

0.15.2-unstable.7

9 months ago

0.15.2-unstable.9

9 months ago

0.13.1-unstable.10

10 months ago

0.13.1-unstable.13

10 months ago

0.13.1-unstable.12

10 months ago

0.13.1-unstable.11

10 months ago

0.13.1-unstable.18

9 months ago

0.13.1-unstable.15

10 months ago

0.15.2-unstable.76

8 months ago

0.15.2-next.113

8 months ago

0.15.2-next.110

8 months ago

0.15.2-next.111

8 months ago

0.17.6-next.7

7 months ago

0.17.6-next.6

7 months ago

0.17.6-next.9

6 months ago

0.17.6-next.3

7 months ago

0.17.6-next.2

7 months ago

0.17.6-next.5

7 months ago

0.17.6-next.4

7 months ago

0.14.2-next.28

9 months ago

0.14.2-next.27

9 months ago

0.14.2-next.29

9 months ago

0.14.2-next.23

9 months ago

0.15.2-next.103

8 months ago

0.14.2-next.26

9 months ago

0.15.2-next.104

8 months ago

0.14.2-next.25

9 months ago

0.14.0

9 months ago

0.15.2-next.109

8 months ago

0.14.1

9 months ago

0.15.2-unstable.91

8 months ago

0.15.2-unstable.93

8 months ago

0.15.2-next.124

7 months ago

0.15.2-unstable.92

8 months ago

0.15.2-next.121

7 months ago

0.15.2-next.29

8 months ago

0.14.2-next.18

9 months ago

0.15.2-next.116

8 months ago

0.15.2-unstable.97

8 months ago

0.15.2-next.117

8 months ago

0.15.2-next.114

8 months ago

0.15.2-unstable.99

8 months ago

0.15.2-unstable.98

8 months ago

0.14.2-next.14

9 months ago

0.15.2-next.118

8 months ago

0.14.2-next.40

9 months ago

0.17.6-unstable.18

6 months ago

0.15.2-next.4

9 months ago

0.15.2-next.5

9 months ago

0.15.2-next.6

9 months ago

0.14.2-unstable.57

9 months ago

0.14.2-next.49

9 months ago

0.14.2-unstable.56

9 months ago

0.14.2-next.45

9 months ago

0.14.2-next.48

9 months ago

0.14.2-next.47

9 months ago

0.15.2-next.77

8 months ago

0.14.2-next.43

9 months ago

0.15.2-next.101

8 months ago

0.15.2-unstable.38

8 months ago

0.14.2-next.39

9 months ago

0.14.2-next.38

9 months ago

0.14.1-next.2

9 months ago

0.17.6-unstable.16

7 months ago

0.14.2-next.35

9 months ago

0.14.2-next.34

9 months ago

0.17.6-unstable.14

5 months ago

0.14.2-next.37

9 months ago

0.17.6-unstable.15

7 months ago

0.14.2-next.36

9 months ago

0.17.6-unstable.12

7 months ago

0.14.2-next.31

9 months ago

0.17.6-unstable.13

5 months ago

0.14.2-next.30

9 months ago

0.17.6-unstable.10

6 months ago

0.15.2-unstable.37

8 months ago

0.14.2-next.33

9 months ago

0.17.6-unstable.11

7 months ago

0.15.2-unstable.36

8 months ago

0.14.2-next.32

9 months ago

0.14.2-next.51

9 months ago

0.14.2-next.50

9 months ago

0.17.6-next.16

5 months ago

0.15.2-next.3

9 months ago

0.13.1-unstable.6

10 months ago

0.13.1-unstable.7

10 months ago

0.13.1-unstable.8

10 months ago

0.14.2-next.58

9 months ago

0.13.1-unstable.9

10 months ago

0.13.0

11 months ago

0.12.1-unstable.18

11 months ago

0.12.1-unstable.19

11 months ago

0.12.1-unstable.17

11 months ago

0.12.1-next.21

11 months ago

0.12.1-next.20

11 months ago

0.12.1-next.19

11 months ago

0.12.1-unstable.16

11 months ago

0.12.1-unstable.15

11 months ago

0.12.1-unstable.14

11 months ago

0.12.0

11 months ago

0.11.1-next.154

11 months ago

0.11.1-next.153

11 months ago

0.11.1-unstable.163

11 months ago

0.11.1-next.152

11 months ago

0.11.1-next.162

11 months ago

0.11.1-unstable.161

11 months ago

0.11.1-unstable.160

11 months ago

0.11.1-next.151

11 months ago

0.11.1-unstable.153

11 months ago

0.11.1-unstable.152

11 months ago

0.11.1-unstable.151

11 months ago

0.11.1-unstable.150

11 months ago

0.11.1-next.150

11 months ago

0.11.1-next.149

11 months ago

0.11.1-next.148

11 months ago

0.11.1-next.147

11 months ago

0.11.1-next.146

11 months ago

0.11.1-unstable.149

11 months ago

0.11.1-next.145

11 months ago

0.11.1-next.144

11 months ago

0.11.1-next.142

11 months ago

0.11.1-next.141

11 months ago

0.11.1-next.140

11 months ago

0.11.1-next.131

11 months ago

0.11.1-unstable.130

11 months ago

0.11.1-unstable.121

11 months ago

0.11.1-unstable.117

11 months ago

0.11.1-next.112

11 months ago

0.11.1-unstable.111

11 months ago

0.11.1-unstable.110

11 months ago

0.11.1-unstable.109

11 months ago

0.11.1-unstable.73

11 months ago

0.11.1-next.106

11 months ago

0.11.1-unstable.105

11 months ago

0.11.1-unstable.104

11 months ago

0.11.1-unstable.103

11 months ago

0.11.1-unstable.102

11 months ago

0.11.1-unstable.101

11 months ago

0.11.1-next.72

12 months ago

0.11.1-next.70

12 months ago

0.11.1-next.65

1 year ago