samlify 2.11.0 → 2.13.0

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.
Files changed (83) hide show
  1. package/README.md +1 -1
  2. package/build/src/api.js +52 -3
  3. package/build/src/api.js.map +1 -1
  4. package/build/src/binding-post.js +236 -182
  5. package/build/src/binding-post.js.map +1 -1
  6. package/build/src/binding-redirect.js +303 -215
  7. package/build/src/binding-redirect.js.map +1 -1
  8. package/build/src/binding-simplesign.js +285 -137
  9. package/build/src/binding-simplesign.js.map +1 -1
  10. package/build/src/entity-idp.js +130 -47
  11. package/build/src/entity-idp.js.map +1 -1
  12. package/build/src/entity-sp.js +81 -39
  13. package/build/src/entity-sp.js.map +1 -1
  14. package/build/src/entity.js +100 -62
  15. package/build/src/entity.js.map +1 -1
  16. package/build/src/extractor.js +119 -155
  17. package/build/src/extractor.js.map +1 -1
  18. package/build/src/flow.js +100 -96
  19. package/build/src/flow.js.map +1 -1
  20. package/build/src/libsaml.js +318 -261
  21. package/build/src/libsaml.js.map +1 -1
  22. package/build/src/metadata-idp.js +60 -30
  23. package/build/src/metadata-idp.js.map +1 -1
  24. package/build/src/metadata-sp.js +51 -41
  25. package/build/src/metadata-sp.js.map +1 -1
  26. package/build/src/metadata.js +47 -43
  27. package/build/src/metadata.js.map +1 -1
  28. package/build/src/options.js +73 -0
  29. package/build/src/options.js.map +1 -0
  30. package/build/src/urn.js +28 -1
  31. package/build/src/urn.js.map +1 -1
  32. package/build/src/utility.js +165 -83
  33. package/build/src/utility.js.map +1 -1
  34. package/build/src/validator.js +27 -10
  35. package/build/src/validator.js.map +1 -1
  36. package/package.json +17 -7
  37. package/types/src/api.d.ts +33 -3
  38. package/types/src/binding-post.d.ts +67 -34
  39. package/types/src/binding-redirect.d.ts +58 -31
  40. package/types/src/binding-simplesign.d.ts +77 -21
  41. package/types/src/entity-idp.d.ts +40 -31
  42. package/types/src/entity-sp.d.ts +37 -27
  43. package/types/src/entity.d.ts +71 -77
  44. package/types/src/extractor.d.ts +31 -22
  45. package/types/src/flow.d.ts +24 -2
  46. package/types/src/libsaml.d.ts +172 -118
  47. package/types/src/metadata-idp.d.ts +27 -11
  48. package/types/src/metadata-sp.d.ts +29 -19
  49. package/types/src/metadata.d.ts +59 -34
  50. package/types/src/options.d.ts +37 -0
  51. package/types/src/types.d.ts +250 -24
  52. package/types/src/urn.d.ts +7 -0
  53. package/types/src/utility.d.ts +144 -89
  54. package/types/src/validator.d.ts +21 -0
  55. package/.circleci/config.yml +0 -98
  56. package/.editorconfig +0 -19
  57. package/.github/FUNDING.yml +0 -1
  58. package/.github/workflows/deploy-docs.yml +0 -56
  59. package/.pre-commit.sh +0 -15
  60. package/.snyk +0 -4
  61. package/Makefile +0 -25
  62. package/index.ts +0 -28
  63. package/src/api.ts +0 -36
  64. package/src/binding-post.ts +0 -336
  65. package/src/binding-redirect.ts +0 -335
  66. package/src/binding-simplesign.ts +0 -231
  67. package/src/entity-idp.ts +0 -145
  68. package/src/entity-sp.ts +0 -114
  69. package/src/entity.ts +0 -243
  70. package/src/extractor.ts +0 -399
  71. package/src/flow.ts +0 -469
  72. package/src/libsaml.ts +0 -777
  73. package/src/metadata-idp.ts +0 -146
  74. package/src/metadata-sp.ts +0 -203
  75. package/src/metadata.ts +0 -166
  76. package/src/types.ts +0 -127
  77. package/src/urn.ts +0 -210
  78. package/src/utility.ts +0 -231
  79. package/src/validator.ts +0 -44
  80. package/tsconfig.json +0 -41
  81. package/tslint.json +0 -35
  82. package/types.d.ts +0 -2
  83. package/vitest.config.ts +0 -12
@@ -37,18 +37,25 @@ exports.readPrivateKey = readPrivateKey;
37
37
  exports.isNonEmptyArray = isNonEmptyArray;
38
38
  exports.castArrayOpt = castArrayOpt;
39
39
  exports.notEmpty = notEmpty;
40
+ exports.escapeXPathValue = escapeXPathValue;
41
+ exports.camelCase = camelCase;
40
42
  /**
41
- * @file utility.ts
42
- * @author tngan
43
- * @desc Library for some common functions (e.g. de/inflation, en/decoding)
44
- */
43
+ * @file utility.ts
44
+ * @author tngan
45
+ * @desc Common helpers (encoding, compression, certificate / key handling).
46
+ */
45
47
  var crypto_1 = require("crypto");
46
48
  var zlib_1 = require("zlib");
47
49
  var BASE64_STR = 'base64';
48
50
  /**
49
- * @desc Mimic lodash.zipObject
50
- * @param arr1 {string[]}
51
- * @param arr2 {[]}
51
+ * Build an object by zipping two parallel arrays of keys and values.
52
+ * When `skipDuplicated` is false, colliding keys are aggregated into arrays
53
+ * so duplicate keys do not clobber earlier values.
54
+ *
55
+ * @param arr1 key array
56
+ * @param arr2 value array (same index as keys)
57
+ * @param skipDuplicated when true (default) later writes overwrite earlier ones
58
+ * @returns object composed from key/value pairs
52
59
  */
53
60
  function zipObject(arr1, arr2, skipDuplicated) {
54
61
  if (skipDuplicated === void 0) { skipDuplicated = true; }
@@ -57,7 +64,6 @@ function zipObject(arr1, arr2, skipDuplicated) {
57
64
  res[l] = arr2[i];
58
65
  return res;
59
66
  }
60
- // if key exists, aggregate with array in order to get rid of duplicate key
61
67
  if (res[l] !== undefined) {
62
68
  res[l] = Array.isArray(res[l])
63
69
  ? res[l].concat(arr2[i])
@@ -69,9 +75,10 @@ function zipObject(arr1, arr2, skipDuplicated) {
69
75
  }, {});
70
76
  }
71
77
  /**
72
- * @desc Alternative to lodash.flattenDeep
73
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_flattendeep
74
- * @param input {[]}
78
+ * Recursively flatten a nested array into a single-level array.
79
+ *
80
+ * @param input nested array input
81
+ * @returns flattened array
75
82
  */
76
83
  function flattenDeep(input) {
77
84
  return Array.isArray(input)
@@ -79,144 +86,168 @@ function flattenDeep(input) {
79
86
  : [input];
80
87
  }
81
88
  /**
82
- * @desc Alternative to lodash.last
83
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_last
84
- * @param input {[]}
89
+ * Return the last element of an array.
90
+ *
91
+ * @param input source array
92
+ * @returns the final element, or undefined when the array is empty
85
93
  */
86
94
  function last(input) {
87
95
  return input.slice(-1)[0];
88
96
  }
89
97
  /**
90
- * @desc Alternative to lodash.uniq
91
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_uniq
92
- * @param input {string[]}
98
+ * Return a copy of a string array with duplicates removed.
99
+ *
100
+ * @param input array with possible duplicates
101
+ * @returns array in original order without duplicates
93
102
  */
94
103
  function uniq(input) {
95
104
  var set = new Set(input);
96
105
  return __spreadArray([], __read(set), false);
97
106
  }
98
107
  /**
99
- * @desc Alternative to lodash.get
100
- * @reference https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
101
- * @param obj
102
- * @param path
103
- * @param defaultValue
108
+ * Safely read a dotted path from an object, returning `defaultValue` when
109
+ * any segment is missing.
110
+ *
111
+ * @param obj source object
112
+ * @param path dotted path expression (e.g. "a.b.c")
113
+ * @param defaultValue fallback when the path does not resolve
114
+ * @returns resolved value or the default
104
115
  */
105
116
  function get(obj, path, defaultValue) {
106
- return path.split('.')
107
- .reduce(function (a, c) { return (a && a[c] ? a[c] : (defaultValue || null)); }, obj);
117
+ if (defaultValue === void 0) { defaultValue = null; }
118
+ return path
119
+ .split('.')
120
+ .reduce(function (a, c) {
121
+ if (a && typeof a === 'object' && c in a) {
122
+ var next = a[c];
123
+ return next !== null && next !== void 0 ? next : defaultValue;
124
+ }
125
+ return defaultValue;
126
+ }, obj);
108
127
  }
109
128
  /**
110
- * @desc Check if the input is string
111
- * @param {any} input
129
+ * Type guard for strings.
130
+ *
131
+ * @param input value to test
132
+ * @returns true when the input is a string primitive
112
133
  */
113
134
  function isString(input) {
114
135
  return typeof input === 'string';
115
136
  }
116
137
  /**
117
- * @desc Encode string with base64 format
118
- * @param {string} message plain-text message
119
- * @return {string} base64 encoded string
120
- */
138
+ * Encode a string or byte array as base64.
139
+ *
140
+ * @param message plain text or raw bytes
141
+ * @returns base64 encoded string
142
+ */
121
143
  function base64Encode(message) {
122
144
  return Buffer.from(message).toString(BASE64_STR);
123
145
  }
124
146
  /**
125
- * @desc Decode string from base64 format
126
- * @param {string} base64Message encoded string
127
- * @param {boolean} isBytes determine the return value type (True: bytes False: string)
128
- * @return {bytes/string} decoded bytes/string depends on isBytes, default is {string}
129
- */
147
+ * Decode a base64 message. Returns either the decoded string or the raw
148
+ * Buffer depending on `isBytes`.
149
+ *
150
+ * @param base64Message base64 encoded payload
151
+ * @param isBytes when true, return a Buffer instead of a string
152
+ * @returns decoded string or Buffer
153
+ */
130
154
  function base64Decode(base64Message, isBytes) {
131
155
  var bytes = Buffer.from(base64Message, BASE64_STR);
132
156
  return Boolean(isBytes) ? bytes : bytes.toString();
133
157
  }
134
158
  /**
135
- * @desc Compress the string
136
- * @param {string} message
137
- * @return {string} compressed string
138
- */
159
+ * Raw-deflate a UTF-8 string and return the compressed bytes.
160
+ *
161
+ * @param message plain text
162
+ * @returns compressed bytes as a number array
163
+ */
139
164
  function deflateString(message) {
140
165
  var input = Buffer.from(message, 'utf8');
141
166
  return Array.from((0, zlib_1.deflateRawSync)(input));
142
167
  }
143
168
  /**
144
- * @desc Decompress the compressed string
145
- * @param {string} compressedString
146
- * @return {string} decompressed string
147
- */
169
+ * Raw-inflate a base64 string that was produced by {@link deflateString}.
170
+ *
171
+ * @param compressedString base64-encoded raw-deflate payload
172
+ * @returns decompressed UTF-8 string
173
+ */
148
174
  function inflateString(compressedString) {
149
175
  var inputBuffer = Buffer.from(compressedString, BASE64_STR);
150
176
  return (0, zlib_1.inflateRawSync)(inputBuffer).toString('utf8');
151
177
  }
152
178
  /**
153
- * @desc Abstract the normalizeCerString and normalizePemString
154
- * @param {buffer} File stream or string
155
- * @param {string} String for header and tail
156
- * @return {string} A formatted certificate string
157
- */
179
+ * Strip PEM header/footer, whitespace and newlines from a PEM payload.
180
+ */
158
181
  function _normalizeCerString(bin, format) {
159
- return bin.toString().replace(/\n/g, '').replace(/\r/g, '').replace("-----BEGIN ".concat(format, "-----"), '').replace("-----END ".concat(format, "-----"), '').replace(/ /g, '').replace(/\t/g, '');
182
+ return bin
183
+ .toString()
184
+ .replace(/\n/g, '')
185
+ .replace(/\r/g, '')
186
+ .replace("-----BEGIN ".concat(format, "-----"), '')
187
+ .replace("-----END ".concat(format, "-----"), '')
188
+ .replace(/ /g, '')
189
+ .replace(/\t/g, '');
160
190
  }
161
191
  /**
162
- * @desc Parse the .cer to string format without line break, header and footer
163
- * @param {string} certString declares the certificate contents
164
- * @return {string} certificiate in string format
165
- */
192
+ * Normalise a PEM certificate string to its base64 body.
193
+ *
194
+ * @param certString PEM-encoded X.509 certificate
195
+ * @returns certificate body without headers/whitespace
196
+ */
166
197
  function normalizeCerString(certString) {
167
198
  return _normalizeCerString(certString, 'CERTIFICATE');
168
199
  }
169
200
  /**
170
- * @desc Normalize the string in .pem format without line break, header and footer
171
- * @param {string} pemString
172
- * @return {string} private key in string format
173
- */
201
+ * Normalise a PEM RSA private key string to its base64 body.
202
+ *
203
+ * @param pemString PEM-encoded RSA private key
204
+ * @returns key body without headers/whitespace
205
+ */
174
206
  function normalizePemString(pemString) {
175
207
  return _normalizeCerString(pemString.toString(), 'RSA PRIVATE KEY');
176
208
  }
177
209
  /**
178
- * @desc Return the complete URL
179
- * @param {object} req HTTP request
180
- * @return {string} URL
181
- */
210
+ * Reconstruct the full URL (protocol + host + path) from an Express-style
211
+ * HTTP request.
212
+ *
213
+ * @param req Express-compatible request object
214
+ * @returns absolute URL string
215
+ */
182
216
  function getFullURL(req) {
183
217
  return "".concat(req.protocol, "://").concat(req.get('host')).concat(req.originalUrl);
184
218
  }
185
219
  /**
186
- * @desc Parse input string, return default value if it is undefined
187
- * @param {string/boolean}
188
- * @return {boolean}
189
- */
220
+ * Return `str` when it is truthy, otherwise the provided default.
221
+ */
190
222
  function parseString(str, defaultValue) {
191
223
  if (defaultValue === void 0) { defaultValue = ''; }
192
224
  return str || defaultValue;
193
225
  }
194
226
  /**
195
- * @desc Override the object by another object (rtl)
196
- * @param {object} default object
197
- * @param {object} object applied to the default object
198
- * @return {object} result object
199
- */
227
+ * Shallow-merge `obj2` on top of `obj1`, returning a new object.
228
+ */
200
229
  function applyDefault(obj1, obj2) {
201
230
  return Object.assign({}, obj1, obj2);
202
231
  }
203
232
  /**
204
- * @desc Get public key in pem format from the certificate included in the metadata
205
- * @param {string} x509 certificate
206
- * @return {string} public key fetched from the certificate
207
- */
233
+ * Extract the SPKI PEM public key from a base64 X.509 certificate body.
234
+ *
235
+ * @param x509Certificate normalised certificate body (no PEM wrappers)
236
+ * @returns PEM-encoded public key
237
+ */
208
238
  function getPublicKeyPemFromCertificate(x509Certificate) {
209
239
  var der = Buffer.from(x509Certificate, 'base64');
210
240
  var cert = new crypto_1.X509Certificate(der);
211
241
  return cert.publicKey.export({ type: 'spki', format: 'pem' });
212
242
  }
213
243
  /**
214
- * @desc Read private key from pem-formatted string
215
- * @param {string | Buffer} keyString pem-formatted string
216
- * @param {string} protected passphrase of the key
217
- * @return {string} string in pem format
218
- * If passphrase is used to protect the .pem content (recommend)
219
- */
244
+ * Read a PEM private key, optionally decrypting it with a passphrase.
245
+ *
246
+ * @param keyString PEM key contents
247
+ * @param passphrase optional passphrase protecting the key
248
+ * @param isOutputString when true, always return a string
249
+ * @returns PEM key as string or Buffer
250
+ */
220
251
  function readPrivateKey(keyString, passphrase, isOutputString) {
221
252
  if (isString(passphrase)) {
222
253
  var key = (0, crypto_1.createPrivateKey)({ key: keyString, format: 'pem', passphrase: passphrase });
@@ -226,25 +257,76 @@ function readPrivateKey(keyString, passphrase, isOutputString) {
226
257
  return keyString;
227
258
  }
228
259
  /**
229
- * @desc Inline syntax sugar
230
- */
260
+ * Coerce a value to a string when `isOutputString` is true, otherwise pass
261
+ * it through untouched.
262
+ */
231
263
  function convertToString(input, isOutputString) {
232
264
  return Boolean(isOutputString) ? String(input) : input;
233
265
  }
234
266
  /**
235
- * @desc Check if the input is an array with non-zero size
267
+ * Check that the input is an array with at least one element.
268
+ *
269
+ * @param a candidate value
270
+ * @returns true when the argument is a non-empty array
236
271
  */
237
272
  function isNonEmptyArray(a) {
238
273
  return Array.isArray(a) && a.length > 0;
239
274
  }
275
+ /**
276
+ * Wrap a single value in an array, or return the array unchanged.
277
+ * An undefined input returns an empty array.
278
+ *
279
+ * @param a scalar, array, or undefined
280
+ * @returns array form of the input
281
+ */
240
282
  function castArrayOpt(a) {
241
283
  if (a === undefined)
242
284
  return [];
243
285
  return Array.isArray(a) ? a : [a];
244
286
  }
287
+ /**
288
+ * Type guard removing `null` and `undefined` from a union.
289
+ *
290
+ * @param value value to narrow
291
+ * @returns true when the value is neither null nor undefined
292
+ */
245
293
  function notEmpty(value) {
246
294
  return value !== null && value !== undefined;
247
295
  }
296
+ /**
297
+ * Escape a string for safe use inside an XPath single-quoted string literal.
298
+ * Prevents XPath injection by splitting on single quotes and using concat().
299
+ *
300
+ * @param value raw string that may contain quotes
301
+ * @returns XPath-safe string expression
302
+ */
303
+ function escapeXPathValue(value) {
304
+ if (!value.includes("'")) {
305
+ return "'" + value + "'";
306
+ }
307
+ var parts = value.split("'").map(function (part) { return "'" + part + "'"; });
308
+ return 'concat(' + parts.join(",\"'\",") + ')';
309
+ }
310
+ /**
311
+ * Convert a string to camelCase, splitting on whitespace, `-`, `_`, `.`,
312
+ * and inferred case boundaries.
313
+ *
314
+ * @param input source string
315
+ * @returns camelCased output
316
+ */
317
+ function camelCase(input) {
318
+ var words = input
319
+ .replace(/([a-z\d])([A-Z])/g, '$1\0$2')
320
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1\0$2')
321
+ .split(/[\0\s\-_\.]+/)
322
+ .filter(function (w) { return w.length > 0; });
323
+ return words
324
+ .map(function (word, i) {
325
+ var lower = word.toLocaleLowerCase('en-US');
326
+ return i === 0 ? lower : lower.charAt(0).toLocaleUpperCase('en-US') + lower.slice(1);
327
+ })
328
+ .join('');
329
+ }
248
330
  var utility = {
249
331
  isString: isString,
250
332
  base64Encode: base64Encode,
@@ -1 +1 @@
1
- {"version":3,"file":"utility.js","sourceRoot":"","sources":["../../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M,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,GAAG,CAAC,EAAZ,CAAY,CAAC,CAAC;IAE7B,OAAO,KAAK;SACT,GAAG,CAAC,UAAC,IAAI,EAAE,CAAC;QACX,IAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,IAAM,OAAO,GAAG;IACd,QAAQ,UAAA;IACR,YAAY,cAAA;IACZ,YAAY,cAAA;IACZ,aAAa,eAAA;IACb,aAAa,eAAA;IACb,kBAAkB,oBAAA;IAClB,kBAAkB,oBAAA;IAClB,UAAU,YAAA;IACV,WAAW,aAAA;IACX,YAAY,cAAA;IACZ,8BAA8B,gCAAA;IAC9B,cAAc,gBAAA;IACd,eAAe,iBAAA;IACf,eAAe,iBAAA;CAChB,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * @file validator.ts
4
+ * @author tngan
5
+ * @desc Time-window validators for SAML `NotBefore` / `NotOnOrAfter` conditions.
6
+ */
2
7
  var __read = (this && this.__read) || function (o, n) {
3
8
  var m = typeof Symbol === "function" && o[Symbol.iterator];
4
9
  if (!m) return o;
@@ -17,27 +22,39 @@ var __read = (this && this.__read) || function (o, n) {
17
22
  };
18
23
  Object.defineProperty(exports, "__esModule", { value: true });
19
24
  exports.verifyTime = verifyTime;
25
+ /**
26
+ * Check whether the current clock falls within the provided SAML time
27
+ * window, applying a symmetric drift tolerance to both ends.
28
+ *
29
+ * Behaviour:
30
+ * - Both bounds missing: logs a warning and returns `true`.
31
+ * - Only `utcNotBefore` given: returns true when now is at or after it.
32
+ * - Only `utcNotOnOrAfter` given: returns true when now is strictly before it.
33
+ * - Both given: returns true only when both individual checks pass.
34
+ *
35
+ * @param utcNotBefore ISO-8601 lower bound (inclusive) or undefined
36
+ * @param utcNotOnOrAfter ISO-8601 upper bound (exclusive) or undefined
37
+ * @param drift tolerance applied to each bound, defaults to `[0, 0]`
38
+ * @returns whether the current time is within the configured window
39
+ */
20
40
  function verifyTime(utcNotBefore, utcNotOnOrAfter, drift) {
21
41
  if (drift === void 0) { drift = [0, 0]; }
22
42
  var now = new Date();
23
43
  if (!utcNotBefore && !utcNotOnOrAfter) {
24
- // show warning because user intends to have time check but the document doesn't include corresponding information
25
- console.warn('You intend to have time validation however the document doesn\'t include the valid range.');
44
+ console.warn("You intend to have time validation however the document doesn't include the valid range.");
26
45
  return true;
27
46
  }
28
- var notBeforeLocal = null;
29
- var notOnOrAfterLocal = null;
30
47
  var _a = __read(drift, 2), notBeforeDrift = _a[0], notOnOrAfterDrift = _a[1];
31
48
  if (utcNotBefore && !utcNotOnOrAfter) {
32
- notBeforeLocal = new Date(utcNotBefore);
33
- return +notBeforeLocal + notBeforeDrift <= +now;
49
+ var notBeforeLocal_1 = new Date(utcNotBefore);
50
+ return +notBeforeLocal_1 + notBeforeDrift <= +now;
34
51
  }
35
52
  if (!utcNotBefore && utcNotOnOrAfter) {
36
- notOnOrAfterLocal = new Date(utcNotOnOrAfter);
37
- return +now < +notOnOrAfterLocal + notOnOrAfterDrift;
53
+ var notOnOrAfterLocal_1 = new Date(utcNotOnOrAfter);
54
+ return +now < +notOnOrAfterLocal_1 + notOnOrAfterDrift;
38
55
  }
39
- notBeforeLocal = new Date(utcNotBefore);
40
- notOnOrAfterLocal = new Date(utcNotOnOrAfter);
56
+ var notBeforeLocal = new Date(utcNotBefore);
57
+ var notOnOrAfterLocal = new Date(utcNotOnOrAfter);
41
58
  return (+notBeforeLocal + notBeforeDrift <= +now &&
42
59
  +now < +notOnOrAfterLocal + notOnOrAfterDrift);
43
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA0CE,gCAAU;AAvCZ,SAAS,UAAU,CACjB,YAAgC,EAChC,eAAmC,EACnC,KAA8B;IAA9B,sBAAA,EAAA,SAAyB,CAAC,EAAE,CAAC,CAAC;IAG9B,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,IAAI,CAAC,YAAY,IAAI,CAAC,eAAe,EAAE,CAAC;QACtC,kHAAkH;QAClH,OAAO,CAAC,IAAI,CAAC,2FAA2F,CAAC,CAAC;QAC1G,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,cAAc,GAAgB,IAAI,CAAC;IACvC,IAAI,iBAAiB,GAAgB,IAAI,CAAC;IAEpC,IAAA,KAAA,OAAsC,KAAK,IAAA,EAA1C,cAAc,QAAA,EAAE,iBAAiB,QAAS,CAAC;IAElD,IAAI,YAAY,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,cAAc,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QACxC,OAAO,CAAC,cAAc,GAAG,cAAc,IAAI,CAAC,GAAG,CAAC;IAClD,CAAC;IACD,IAAI,CAAC,YAAY,IAAI,eAAe,EAAE,CAAC;QACrC,iBAAiB,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IACvD,CAAC;IAED,cAAc,GAAG,IAAI,IAAI,CAAC,YAAa,CAAC,CAAC;IACzC,iBAAiB,GAAG,IAAI,IAAI,CAAC,eAAgB,CAAC,CAAC;IAE/C,OAAO,CACL,CAAC,cAAc,GAAG,cAAc,IAAI,CAAC,GAAG;QACxC,CAAC,GAAG,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAC9C,CAAC;AAEJ,CAAC"}
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;AAoDM,gCAAU;AA/CnB;;;;;;;;;;;;;;GAcG;AACH,SAAS,UAAU,CACjB,YAAgC,EAChC,eAAmC,EACnC,KAA8B;IAA9B,sBAAA,EAAA,SAAyB,CAAC,EAAE,CAAC,CAAC;IAE9B,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,IAAI,CAAC,YAAY,IAAI,CAAC,eAAe,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,0FAA0F,CAAC,CAAC;QACzG,OAAO,IAAI,CAAC;IACd,CAAC;IAEK,IAAA,KAAA,OAAsC,KAAK,IAAA,EAA1C,cAAc,QAAA,EAAE,iBAAiB,QAAS,CAAC;IAElD,IAAI,YAAY,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,IAAM,gBAAc,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9C,OAAO,CAAC,gBAAc,GAAG,cAAc,IAAI,CAAC,GAAG,CAAC;IAClD,CAAC;IACD,IAAI,CAAC,YAAY,IAAI,eAAe,EAAE,CAAC;QACrC,IAAM,mBAAiB,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,GAAG,CAAC,mBAAiB,GAAG,iBAAiB,CAAC;IACvD,CAAC;IAED,IAAM,cAAc,GAAG,IAAI,IAAI,CAAC,YAAa,CAAC,CAAC;IAC/C,IAAM,iBAAiB,GAAG,IAAI,IAAI,CAAC,eAAgB,CAAC,CAAC;IAErD,OAAO,CACL,CAAC,cAAc,GAAG,cAAc,IAAI,CAAC,GAAG;QACxC,CAAC,GAAG,GAAG,CAAC,iBAAiB,GAAG,iBAAiB,CAC9C,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samlify",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "Node.js library for SAML SSO",
5
5
  "main": "build/index.js",
6
6
  "keywords": [
@@ -11,14 +11,21 @@
11
11
  "metadata"
12
12
  ],
13
13
  "typings": "types/index.d.ts",
14
+ "files": [
15
+ "build",
16
+ "types",
17
+ "LICENSE",
18
+ "README.md"
19
+ ],
14
20
  "scripts": {
15
- "build": "yarn audit;make rebuild",
21
+ "clean": "rm -rf build types",
22
+ "build": "yarn audit && rm -rf build && tsc",
16
23
  "docs:dev": "vitepress dev docs",
17
24
  "docs:build": "vitepress build docs",
18
25
  "docs:preview": "vitepress preview docs",
19
26
  "lint": "tslint -p .",
20
27
  "lint:fix": "tslint -p . --fix",
21
- "pretest": "make pretest",
28
+ "pretest": "mkdir -p build/test && cp -a test/key test/misc build/test",
22
29
  "test": "NODE_ENV=test vitest run",
23
30
  "test:watch": "NODE_ENV=test vitest",
24
31
  "coverage": "vitest run --coverage",
@@ -36,7 +43,6 @@
36
43
  "dependencies": {
37
44
  "@authenio/xml-encryption": "^2.0.2",
38
45
  "@xmldom/xmldom": "^0.8.11",
39
- "camelcase": "^9.0.0",
40
46
  "node-rsa": "^1.1.1",
41
47
  "xml": "^1.0.1",
42
48
  "xml-crypto": "^6.1.2",
@@ -44,20 +50,24 @@
44
50
  "xpath": "^0.0.34"
45
51
  },
46
52
  "resolutions": {
47
- "brace-expansion": ">=1.1.12",
48
53
  "diff": ">=4.0.4",
49
- "esbuild": ">=0.25.0"
54
+ "esbuild": ">=0.25.0",
55
+ "vitest/vite": "^6.4.2",
56
+ "vitest/vite-node/vite": "^6.4.2",
57
+ "vitepress/vite": "^6.4.2",
58
+ "vitepress/@vitejs/plugin-vue/vite": "^6.4.2"
50
59
  },
51
60
  "devDependencies": {
52
61
  "@authenio/samlify-xsd-schema-validator": "^1.0.5",
53
62
  "@types/node": "^25.4.0",
54
63
  "@types/node-rsa": "^1.1.4",
55
64
  "@types/xmldom": "^0.1.34",
65
+ "@vitest/coverage-v8": "^3.2.0",
56
66
  "timekeeper": "^2.3.1",
57
67
  "ts-node": "^10.9.2",
58
68
  "tslint": "^6.1.3",
59
69
  "typescript": "^5.9.3",
60
70
  "vitepress": "^1.6.4",
61
- "vitest": "^4.0.18"
71
+ "vitest": "^3.2.4"
62
72
  }
63
73
  }
@@ -1,13 +1,43 @@
1
- import { DOMParser as dom, Options as DOMParserOptions } from '@xmldom/xmldom';
1
+ /**
2
+ * @file api.ts
3
+ * @author tngan
4
+ * @desc Global module configuration: XML schema validator and DOM parser.
5
+ */
6
+ import { DOMParser as Dom, Options as DOMParserOptions } from '@xmldom/xmldom';
7
+ /** Module-wide runtime configuration. */
2
8
  interface Context extends ValidatorContext, DOMParserContext {
3
9
  }
10
+ /** Caller-supplied SAML XML schema validator. */
4
11
  interface ValidatorContext {
5
- validate?: (xml: string) => Promise<any>;
12
+ validate?: (xml: string) => Promise<unknown>;
6
13
  }
14
+ /** DOM parser used to decode SAML messages. */
7
15
  interface DOMParserContext {
8
- dom: dom;
16
+ dom: Dom;
9
17
  }
18
+ /**
19
+ * Return the module-wide runtime context (DOM parser and validator).
20
+ *
21
+ * @returns shared context object
22
+ */
10
23
  export declare function getContext(): Context;
24
+ /**
25
+ * Register the caller-supplied SAML schema validator. Throws when the
26
+ * supplied value does not expose a `validate` callback.
27
+ *
28
+ * @param params object with a `validate(xml)` callback
29
+ */
11
30
  export declare function setSchemaValidator(params: ValidatorContext): void;
31
+ /**
32
+ * Replace the module-wide DOM parser with one configured by the caller.
33
+ *
34
+ * The XXE-safe error handlers are merged into the supplied options as a
35
+ * baseline so callers can override unrelated settings without
36
+ * accidentally disabling XXE protection (`saml-core §6.4`,
37
+ * `saml-sec-consider §6.3.1`). A caller can still opt out by passing
38
+ * its own `errorHandler`, but it must do so explicitly.
39
+ *
40
+ * @param options xmldom parser options
41
+ */
12
42
  export declare function setDOMParserOptions(options?: DOMParserOptions): void;
13
43
  export {};