@nihplod/sso-verify 1.1.2 → 1.1.3

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.
package/dist/index.js CHANGED
@@ -187,6 +187,13 @@ function createTokenVerifier(options) {
187
187
  }
188
188
  return data;
189
189
  }
190
+ function normalizeLocalPayload(payload) {
191
+ const p = payload;
192
+ if (!p.sub && typeof p.id === "string" && p.id) {
193
+ p.sub = p.id;
194
+ }
195
+ return p.sub ? p : null;
196
+ }
190
197
  async function verifyLocally(token) {
191
198
  if (!accessTokenSecret) return null;
192
199
  try {
@@ -200,7 +207,7 @@ function createTokenVerifier(options) {
200
207
  if (payload.type !== "access_token") {
201
208
  return null;
202
209
  }
203
- return payload;
210
+ return normalizeLocalPayload(payload);
204
211
  } catch {
205
212
  return null;
206
213
  }
@@ -219,7 +226,7 @@ function createTokenVerifier(options) {
219
226
  clockTolerance: clockToleranceSeconds
220
227
  });
221
228
  if (payload.type !== "access_token") return null;
222
- return payload;
229
+ return normalizeLocalPayload(payload);
223
230
  }
224
231
  const jwks = getJwksKeySet();
225
232
  if (jwks) {
@@ -230,7 +237,7 @@ function createTokenVerifier(options) {
230
237
  clockTolerance: clockToleranceSeconds
231
238
  });
232
239
  if (payload.type !== "access_token") return null;
233
- return payload;
240
+ return normalizeLocalPayload(payload);
234
241
  }
235
242
  return null;
236
243
  } catch {
package/dist/index.mjs CHANGED
@@ -166,6 +166,13 @@ function createTokenVerifier(options) {
166
166
  }
167
167
  return data;
168
168
  }
169
+ function normalizeLocalPayload(payload) {
170
+ const p = payload;
171
+ if (!p.sub && typeof p.id === "string" && p.id) {
172
+ p.sub = p.id;
173
+ }
174
+ return p.sub ? p : null;
175
+ }
169
176
  async function verifyLocally(token) {
170
177
  if (!accessTokenSecret) return null;
171
178
  try {
@@ -179,7 +186,7 @@ function createTokenVerifier(options) {
179
186
  if (payload.type !== "access_token") {
180
187
  return null;
181
188
  }
182
- return payload;
189
+ return normalizeLocalPayload(payload);
183
190
  } catch {
184
191
  return null;
185
192
  }
@@ -198,7 +205,7 @@ function createTokenVerifier(options) {
198
205
  clockTolerance: clockToleranceSeconds
199
206
  });
200
207
  if (payload.type !== "access_token") return null;
201
- return payload;
208
+ return normalizeLocalPayload(payload);
202
209
  }
203
210
  const jwks = getJwksKeySet();
204
211
  if (jwks) {
@@ -209,7 +216,7 @@ function createTokenVerifier(options) {
209
216
  clockTolerance: clockToleranceSeconds
210
217
  });
211
218
  if (payload.type !== "access_token") return null;
212
- return payload;
219
+ return normalizeLocalPayload(payload);
213
220
  }
214
221
  return null;
215
222
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nihplod/sso-verify",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "NIHPLOD 一网通 SSO Token 验证工具包 — 供子项目在后端验证主站签发的 Access Token",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",