Skip to content

Commit 39b76e7

Browse files
committed
[MOL-13183][SW] add deprecation warnings and update changelog
1 parent a18a3f6 commit 39b76e7

File tree

2 files changed

+42
-23
lines changed

2 files changed

+42
-23
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelogs
22

3+
## x.x.x
4+
5+
- NdiOidcHelper
6+
- `scope` can now be passed in to`constructAuthorizationUrl`
7+
- Added `constructAuthorizationUrlV2`
8+
- Added `getUserInfo` and `ververifyUserInfo` to fetch myinfo data from NDI instead of MyInfo
9+
- Add deprecation warnings for `constructAuthorizationUrl`, `getIdTokenPayload` and `extractNricAndUuidFromPayload` to encourage using the full NDI PKCE flow
10+
311
## 8.4.7
412

513
- Update convenience test suite to include SingPass login with PKCE

src/singpass/singpass-helper-ndi.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,6 @@ export class NdiOidcHelper {
9090
return this.constructAuthorizationUrl(state, nonce, codeVerifier, userInfoScope.join(" "));
9191
};
9292

93-
public constructAuthorizationUrl = async (
94-
state: string,
95-
nonce?: string,
96-
codeVerifier?: string,
97-
scope: string = "openid",
98-
): Promise<string> => {
99-
const { authorization_endpoint } = await this.getOidcConfig();
100-
101-
const queryParams = {
102-
state,
103-
...(nonce ? { nonce } : {}),
104-
redirect_uri: this.redirectUri,
105-
scope,
106-
client_id: this.clientID,
107-
response_type: "code",
108-
...(codeVerifier
109-
? { code_challenge_method: "S256", code_challenge: generators.codeChallenge(codeVerifier) }
110-
: {}),
111-
};
112-
const queryString = querystringUtil.stringify(queryParams);
113-
return `${authorization_endpoint}?${queryString}`;
114-
};
115-
11693
/**
11794
* Get tokens from Singpass endpoint. Note: This will fail if not on an IP whitelisted by SP.
11895
* Use getIdTokenPayload on returned Token Response to get the token payload
@@ -189,7 +166,39 @@ export class NdiOidcHelper {
189166
}
190167
};
191168

169+
// =========================================================================
170+
// Deprecated
171+
// =========================================================================
172+
173+
/**
174+
* @deprecated should use constructAuthorizationUrlV2
175+
*/
176+
public constructAuthorizationUrl = async (
177+
state: string,
178+
nonce?: string,
179+
codeVerifier?: string,
180+
scope: string = "openid",
181+
): Promise<string> => {
182+
const { authorization_endpoint } = await this.getOidcConfig();
183+
184+
const queryParams = {
185+
state,
186+
...(nonce ? { nonce } : {}),
187+
redirect_uri: this.redirectUri,
188+
scope,
189+
client_id: this.clientID,
190+
response_type: "code",
191+
...(codeVerifier
192+
? { code_challenge_method: "S256", code_challenge: generators.codeChallenge(codeVerifier) }
193+
: {}),
194+
};
195+
const queryString = querystringUtil.stringify(queryParams);
196+
return `${authorization_endpoint}?${queryString}`;
197+
};
198+
192199
/**
200+
* @deprecated should not be used with full NDI PKCE flow
201+
*
193202
* Decrypts the ID Token JWT inside the TokenResponse to get the payload
194203
* Use extractNricAndUuidFromPayload on the returned Token Payload to get the NRIC and UUID
195204
*/
@@ -216,6 +225,8 @@ export class NdiOidcHelper {
216225
}
217226

218227
/**
228+
* @deprecated should not be used with full NDI PKCE flow
229+
*
219230
* Returns the nric and uuid from the token payload
220231
*/
221232
public extractNricAndUuidFromPayload(payload: TokenPayload): { nric: string; uuid: string } {

0 commit comments

Comments
 (0)