@opengovsg/refx-ts-sdk 0.0.0-develop-alpha-1763534116 → 0.0.0-develop-alpha-1763535866

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,12 +81,16 @@ function createJwtFetcher(signer) {
81
81
  function createSignedJwt({ privateKey, issuer, subject }) {
82
82
  const issuedAt = Math.floor(Date.now() / 1000);
83
83
  const expiresAtEpochSeconds = issuedAt + JWT_TTL_SECONDS;
84
- const token = jsonwebtoken_1.default.sign({}, privateKey, {
84
+ const signOptions = {
85
85
  algorithm: "ES256",
86
86
  issuer,
87
87
  expiresIn: JWT_TTL_SECONDS,
88
- subject,
89
- });
88
+ };
89
+ // Only add the claim if a value is provided(not null or undefined)
90
+ if (subject != null) {
91
+ signOptions.subject = subject;
92
+ }
93
+ const token = jsonwebtoken_1.default.sign({}, privateKey, signOptions);
90
94
  return {
91
95
  token,
92
96
  expiresAtEpochSeconds,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengovsg/refx-ts-sdk",
3
- "version": "0.0.0-develop-alpha-1763534116",
3
+ "version": "0.0.0-develop-alpha-1763535866",
4
4
  "private": false,
5
5
  "repository": "https://github.com/opengovsg/refer-ts-sdk",
6
6
  "main": "./index.js",
@@ -81,12 +81,16 @@ function createJwtFetcher(signer) {
81
81
  function createSignedJwt({ privateKey, issuer, subject }) {
82
82
  const issuedAt = Math.floor(Date.now() / 1000);
83
83
  const expiresAtEpochSeconds = issuedAt + JWT_TTL_SECONDS;
84
- const token = jsonwebtoken_1.default.sign({}, privateKey, {
84
+ const signOptions = {
85
85
  algorithm: "ES256",
86
86
  issuer,
87
87
  expiresIn: JWT_TTL_SECONDS,
88
- subject,
89
- });
88
+ };
89
+ // Only add the claim if a value is provided(not null or undefined)
90
+ if (subject != null) {
91
+ signOptions.subject = subject;
92
+ }
93
+ const token = jsonwebtoken_1.default.sign({}, privateKey, signOptions);
90
94
  return {
91
95
  token,
92
96
  expiresAtEpochSeconds,