opengovsg / sgid-client

The official TypeScript/JavaScript SDK for sgID
MIT License
11 stars 6 forks source link

feat: expose id token #68

Closed kwajiehao closed 1 year ago

kwajiehao commented 1 year ago

Overview

This PR does 2 things:

  1. Expose the id token as part of the callback() method
  2. Perform validation on the id token in a manner consistent across SDKs

1. Expose the ID token as part of the callback() method

Currently, we only expose the sub and access token after performing all the requisite checks on the ID token. But the id token is useful because it acts as proof that the user has been authenticated by sgID. Some relying parties want to store the ID token as part of their audit trail. This is why we're exposing the ID token here.

2. Perform validation on the id token in a manner consistent across SDKs

Validation is done according to the SDK implementation strategy here: https://www.notion.so/opengov/SDK-implementation-requirements-1f9b7cbd2bd4406b85d6645fe3e365dd

Note that in this case, the openid-client library does validation on the ID token for us, so behavior deviates from the Python SDK.

Tests