iron-session 8.0.0-beta.4 → 8.0.0-beta.5

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.cjs CHANGED
@@ -1,484 +1,28 @@
1
1
  'use strict';
2
2
 
3
- var module$1 = require('module');
3
+ var cookie = require('cookie');
4
+ var ironWebcrypto = require('iron-webcrypto');
5
+ var crypto = require('uncrypto');
4
6
 
5
- var require$1=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('out.js', document.baseURI).href)));
6
- var __create = Object.create;
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
13
- get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
14
- }) : x)(function(x) {
15
- if (typeof require$1 !== "undefined")
16
- return require$1.apply(this, arguments);
17
- throw Error('Dynamic require of "' + x + '" is not supported');
18
- });
19
- var __commonJS = (cb, mod) => function __require2() {
20
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
21
- };
22
- var __copyProps = (to, from, except, desc) => {
23
- if (from && typeof from === "object" || typeof from === "function") {
24
- for (let key of __getOwnPropNames(from))
25
- if (!__hasOwnProp.call(to, key) && key !== except)
26
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
- }
28
- return to;
29
- };
30
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
- // If the importer is in node compatibility mode or this is not an ESM
32
- // file that has been converted to a CommonJS file using a Babel-
33
- // compatible transform (i.e. "__esModule" has not been set), then set
34
- // "default" to the CommonJS "module.exports" for node compatibility.
35
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
- mod
37
- ));
38
-
39
- // node_modules/.pnpm/cookie@0.6.0/node_modules/cookie/index.js
40
- var require_cookie = __commonJS({
41
- "node_modules/.pnpm/cookie@0.6.0/node_modules/cookie/index.js"(exports) {
42
- exports.parse = parse2;
43
- exports.serialize = serialize2;
44
- var __toString = Object.prototype.toString;
45
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
46
- function parse2(str, options) {
47
- if (typeof str !== "string") {
48
- throw new TypeError("argument str must be a string");
49
- }
50
- var obj = {};
51
- var opt = options || {};
52
- var dec = opt.decode || decode;
53
- var index = 0;
54
- while (index < str.length) {
55
- var eqIdx = str.indexOf("=", index);
56
- if (eqIdx === -1) {
57
- break;
58
- }
59
- var endIdx = str.indexOf(";", index);
60
- if (endIdx === -1) {
61
- endIdx = str.length;
62
- } else if (endIdx < eqIdx) {
63
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
64
- continue;
65
- }
66
- var key = str.slice(index, eqIdx).trim();
67
- if (void 0 === obj[key]) {
68
- var val = str.slice(eqIdx + 1, endIdx).trim();
69
- if (val.charCodeAt(0) === 34) {
70
- val = val.slice(1, -1);
71
- }
72
- obj[key] = tryDecode(val, dec);
73
- }
74
- index = endIdx + 1;
75
- }
76
- return obj;
77
- }
78
- function serialize2(name, val, options) {
79
- var opt = options || {};
80
- var enc = opt.encode || encode;
81
- if (typeof enc !== "function") {
82
- throw new TypeError("option encode is invalid");
83
- }
84
- if (!fieldContentRegExp.test(name)) {
85
- throw new TypeError("argument name is invalid");
86
- }
87
- var value = enc(val);
88
- if (value && !fieldContentRegExp.test(value)) {
89
- throw new TypeError("argument val is invalid");
90
- }
91
- var str = name + "=" + value;
92
- if (null != opt.maxAge) {
93
- var maxAge = opt.maxAge - 0;
94
- if (isNaN(maxAge) || !isFinite(maxAge)) {
95
- throw new TypeError("option maxAge is invalid");
96
- }
97
- str += "; Max-Age=" + Math.floor(maxAge);
98
- }
99
- if (opt.domain) {
100
- if (!fieldContentRegExp.test(opt.domain)) {
101
- throw new TypeError("option domain is invalid");
102
- }
103
- str += "; Domain=" + opt.domain;
104
- }
105
- if (opt.path) {
106
- if (!fieldContentRegExp.test(opt.path)) {
107
- throw new TypeError("option path is invalid");
108
- }
109
- str += "; Path=" + opt.path;
110
- }
111
- if (opt.expires) {
112
- var expires = opt.expires;
113
- if (!isDate(expires) || isNaN(expires.valueOf())) {
114
- throw new TypeError("option expires is invalid");
115
- }
116
- str += "; Expires=" + expires.toUTCString();
117
- }
118
- if (opt.httpOnly) {
119
- str += "; HttpOnly";
120
- }
121
- if (opt.secure) {
122
- str += "; Secure";
123
- }
124
- if (opt.partitioned) {
125
- str += "; Partitioned";
126
- }
127
- if (opt.priority) {
128
- var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
129
- switch (priority) {
130
- case "low":
131
- str += "; Priority=Low";
132
- break;
133
- case "medium":
134
- str += "; Priority=Medium";
135
- break;
136
- case "high":
137
- str += "; Priority=High";
138
- break;
139
- default:
140
- throw new TypeError("option priority is invalid");
141
- }
142
- }
143
- if (opt.sameSite) {
144
- var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
145
- switch (sameSite) {
146
- case true:
147
- str += "; SameSite=Strict";
148
- break;
149
- case "lax":
150
- str += "; SameSite=Lax";
151
- break;
152
- case "strict":
153
- str += "; SameSite=Strict";
154
- break;
155
- case "none":
156
- str += "; SameSite=None";
157
- break;
158
- default:
159
- throw new TypeError("option sameSite is invalid");
160
- }
161
- }
162
- return str;
163
- }
164
- function decode(str) {
165
- return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
166
- }
167
- function encode(val) {
168
- return encodeURIComponent(val);
169
- }
170
- function isDate(val) {
171
- return __toString.call(val) === "[object Date]" || val instanceof Date;
172
- }
173
- function tryDecode(str, decode2) {
174
- try {
175
- return decode2(str);
176
- } catch (e) {
177
- return str;
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
178
18
  }
179
- }
180
- }
181
- });
182
-
183
- // src/core.ts
184
- var import_cookie = __toESM(require_cookie(), 1);
185
-
186
- // node_modules/.pnpm/iron-webcrypto@1.0.0/node_modules/iron-webcrypto/dist/index.js
187
- var alphabetByEncoding = {};
188
- var alphabetByValue = new Array(64);
189
- for (let i = 0, start = "A".charCodeAt(0), limit = "Z".charCodeAt(0); i + start <= limit; i++) {
190
- const char = String.fromCharCode(i + start);
191
- alphabetByEncoding[char] = i;
192
- alphabetByValue[i] = char;
193
- }
194
- for (let i = 0, start = "a".charCodeAt(0), limit = "z".charCodeAt(0); i + start <= limit; i++) {
195
- const char = String.fromCharCode(i + start);
196
- const index = i + 26;
197
- alphabetByEncoding[char] = index;
198
- alphabetByValue[index] = char;
199
- }
200
- for (let i = 0; i < 10; i++) {
201
- alphabetByEncoding[i.toString(10)] = i + 52;
202
- const char = i.toString(10);
203
- const index = i + 52;
204
- alphabetByEncoding[char] = index;
205
- alphabetByValue[index] = char;
206
- }
207
- alphabetByEncoding["+"] = 62;
208
- alphabetByValue[62] = "+";
209
- alphabetByEncoding["/"] = 63;
210
- alphabetByValue[63] = "/";
211
- var bitsPerLetter = 6;
212
- var bitsPerByte = 8;
213
- var maxLetterValue = 63;
214
- var fromBase64 = (input) => {
215
- let totalByteLength = input.length / 4 * 3;
216
- if (input.slice(-2) === "==") {
217
- totalByteLength -= 2;
218
- } else if (input.slice(-1) === "=") {
219
- totalByteLength--;
220
- }
221
- const out = new ArrayBuffer(totalByteLength);
222
- const dataView = new DataView(out);
223
- for (let i = 0; i < input.length; i += 4) {
224
- let bits = 0;
225
- let bitLength = 0;
226
- for (let j = i, limit = i + 3; j <= limit; j++) {
227
- if (input[j] !== "=") {
228
- if (!(input[j] in alphabetByEncoding)) {
229
- throw new TypeError(`Invalid character ${input[j]} in base64 string.`);
230
- }
231
- bits |= alphabetByEncoding[input[j]] << (limit - j) * bitsPerLetter;
232
- bitLength += bitsPerLetter;
233
- } else {
234
- bits >>= bitsPerLetter;
235
- }
236
- }
237
- const chunkOffset = i / 4 * 3;
238
- bits >>= bitLength % bitsPerByte;
239
- const byteLength = Math.floor(bitLength / bitsPerByte);
240
- for (let k = 0; k < byteLength; k++) {
241
- const offset = (byteLength - k - 1) * bitsPerByte;
242
- dataView.setUint8(chunkOffset + k, (bits & 255 << offset) >> offset);
243
- }
244
- }
245
- return new Uint8Array(out);
246
- };
247
- function toBase64(input) {
248
- let str = "";
249
- for (let i = 0; i < input.length; i += 3) {
250
- let bits = 0;
251
- let bitLength = 0;
252
- for (let j = i, limit = Math.min(i + 3, input.length); j < limit; j++) {
253
- bits |= input[j] << (limit - j - 1) * bitsPerByte;
254
- bitLength += bitsPerByte;
255
- }
256
- const bitClusterCount = Math.ceil(bitLength / bitsPerLetter);
257
- bits <<= bitClusterCount * bitsPerLetter - bitLength;
258
- for (let k = 1; k <= bitClusterCount; k++) {
259
- const offset = (bitClusterCount - k) * bitsPerLetter;
260
- str += alphabetByValue[(bits & maxLetterValue << offset) >> offset];
261
- }
262
- str += "==".slice(0, 4 - bitClusterCount);
19
+ });
263
20
  }
264
- return str;
21
+ n.default = e;
22
+ return Object.freeze(n);
265
23
  }
266
- var stringToBuffer = (value) => {
267
- return new TextEncoder().encode(value);
268
- };
269
- var bufferToString = (value) => {
270
- return new TextDecoder().decode(value);
271
- };
272
- var base64urlEncode = (value) => toBase64(typeof value === "string" ? stringToBuffer(value) : value).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
273
- var base64urlDecode = (value) => fromBase64(
274
- value.replace(/-/g, "+").replace(/_/g, "/") + Array((4 - value.length % 4) % 4 + 1).join("=")
275
- );
276
- var defaults = {
277
- encryption: { saltBits: 256, algorithm: "aes-256-cbc", iterations: 1, minPasswordlength: 32 },
278
- integrity: { saltBits: 256, algorithm: "sha256", iterations: 1, minPasswordlength: 32 },
279
- ttl: 0,
280
- timestampSkewSec: 60,
281
- localtimeOffsetMsec: 0
282
- };
283
- var clone = (options) => ({
284
- ...options,
285
- encryption: { ...options.encryption },
286
- integrity: { ...options.integrity }
287
- });
288
- var algorithms = {
289
- "aes-128-ctr": { keyBits: 128, ivBits: 128, name: "AES-CTR" },
290
- "aes-256-cbc": { keyBits: 256, ivBits: 128, name: "AES-CBC" },
291
- sha256: { keyBits: 256, name: "SHA-256" }
292
- };
293
- var macFormatVersion = "2";
294
- var macPrefix = `Fe26.${macFormatVersion}`;
295
- var randomBytes = (_crypto, size) => {
296
- const bytes = new Uint8Array(size);
297
- _crypto.getRandomValues(bytes);
298
- return bytes;
299
- };
300
- var randomBits = (_crypto, bits) => {
301
- if (bits < 1)
302
- throw Error("Invalid random bits count");
303
- const bytes = Math.ceil(bits / 8);
304
- return randomBytes(_crypto, bytes);
305
- };
306
- var pbkdf2 = async (_crypto, password, salt, iterations, keyLength, hash) => {
307
- const passwordBuffer = stringToBuffer(password);
308
- const importedKey = await _crypto.subtle.importKey("raw", passwordBuffer, "PBKDF2", false, [
309
- "deriveBits"
310
- ]);
311
- const saltBuffer = stringToBuffer(salt);
312
- const params = { name: "PBKDF2", hash, salt: saltBuffer, iterations };
313
- const derivation = await _crypto.subtle.deriveBits(params, importedKey, keyLength * 8);
314
- return derivation;
315
- };
316
- var generateKey = async (_crypto, password, options) => {
317
- var _a;
318
- if (!(password == null ? void 0 : password.length))
319
- throw new Error("Empty password");
320
- if (options == null || typeof options !== "object")
321
- throw new Error("Bad options");
322
- if (!(options.algorithm in algorithms))
323
- throw new Error(`Unknown algorithm: ${options.algorithm}`);
324
- const algorithm = algorithms[options.algorithm];
325
- const result = {};
326
- const hmac = (_a = options.hmac) != null ? _a : false;
327
- const id = hmac ? { name: "HMAC", hash: algorithm.name } : { name: algorithm.name };
328
- const usage = hmac ? ["sign", "verify"] : ["encrypt", "decrypt"];
329
- if (typeof password === "string") {
330
- if (password.length < options.minPasswordlength)
331
- throw new Error(
332
- `Password string too short (min ${options.minPasswordlength} characters required)`
333
- );
334
- let { salt = "" } = options;
335
- if (!salt) {
336
- const { saltBits = 0 } = options;
337
- if (!saltBits)
338
- throw new Error("Missing salt and saltBits options");
339
- const randomSalt = randomBits(_crypto, saltBits);
340
- salt = [...new Uint8Array(randomSalt)].map((x) => x.toString(16).padStart(2, "0")).join("");
341
- }
342
- const derivedKey = await pbkdf2(
343
- _crypto,
344
- password,
345
- salt,
346
- options.iterations,
347
- algorithm.keyBits / 8,
348
- "SHA-1"
349
- );
350
- const importedEncryptionKey = await _crypto.subtle.importKey(
351
- "raw",
352
- derivedKey,
353
- id,
354
- false,
355
- usage
356
- );
357
- result.key = importedEncryptionKey;
358
- result.salt = salt;
359
- } else {
360
- if (password.length < algorithm.keyBits / 8)
361
- throw new Error("Key buffer (password) too small");
362
- result.key = await _crypto.subtle.importKey("raw", password, id, false, usage);
363
- result.salt = "";
364
- }
365
- if (options.iv)
366
- result.iv = options.iv;
367
- else if ("ivBits" in algorithm)
368
- result.iv = randomBits(_crypto, algorithm.ivBits);
369
- return result;
370
- };
371
- var encrypt = async (_crypto, password, options, data) => {
372
- const key = await generateKey(_crypto, password, options);
373
- const textBuffer = stringToBuffer(data);
374
- const encrypted = await _crypto.subtle.encrypt(
375
- { name: algorithms[options.algorithm].name, iv: key.iv },
376
- key.key,
377
- textBuffer
378
- );
379
- return { encrypted: new Uint8Array(encrypted), key };
380
- };
381
- var decrypt = async (_crypto, password, options, data) => {
382
- const key = await generateKey(_crypto, password, options);
383
- const decrypted = await _crypto.subtle.decrypt(
384
- { name: algorithms[options.algorithm].name, iv: key.iv },
385
- key.key,
386
- typeof data === "string" ? stringToBuffer(data) : data
387
- );
388
- return bufferToString(new Uint8Array(decrypted));
389
- };
390
- var hmacWithPassword = async (_crypto, password, options, data) => {
391
- const key = await generateKey(_crypto, password, { ...options, hmac: true });
392
- const textBuffer = stringToBuffer(data);
393
- const signed = await _crypto.subtle.sign({ name: "HMAC" }, key.key, textBuffer);
394
- const digest = base64urlEncode(new Uint8Array(signed));
395
- return { digest, salt: key.salt };
396
- };
397
- var normalizePassword = (password) => {
398
- if (typeof password === "string" || password instanceof Uint8Array)
399
- return { encryption: password, integrity: password };
400
- if ("secret" in password)
401
- return { id: password.id, encryption: password.secret, integrity: password.secret };
402
- return { id: password.id, encryption: password.encryption, integrity: password.integrity };
403
- };
404
- var seal = async (_crypto, object, password, options) => {
405
- if (!password)
406
- throw Error("Empty password");
407
- const opts = clone(options);
408
- const now = Date.now() + (opts.localtimeOffsetMsec || 0);
409
- const objectString = JSON.stringify(object);
410
- const pass = normalizePassword(password);
411
- const { id = "" } = pass;
412
- if (id && !/^\w+$/.test(id))
413
- throw new Error("Invalid password id");
414
- const { encrypted, key } = await encrypt(_crypto, pass.encryption, opts.encryption, objectString);
415
- const encryptedB64 = base64urlEncode(new Uint8Array(encrypted));
416
- const iv = base64urlEncode(key.iv);
417
- const expiration = opts.ttl ? now + opts.ttl : "";
418
- const macBaseString = `${macPrefix}*${id}*${key.salt}*${iv}*${encryptedB64}*${expiration}`;
419
- const mac = await hmacWithPassword(_crypto, pass.integrity, opts.integrity, macBaseString);
420
- const sealed = `${macBaseString}*${mac.salt}*${mac.digest}`;
421
- return sealed;
422
- };
423
- var fixedTimeComparison = (a, b) => {
424
- let mismatch = a.length === b.length ? 0 : 1;
425
- if (mismatch)
426
- b = a;
427
- for (let i = 0; i < a.length; i += 1)
428
- mismatch |= a.charCodeAt(i) ^ b.charCodeAt(i);
429
- return mismatch === 0;
430
- };
431
- var unseal = async (_crypto, sealed, password, options) => {
432
- if (!password)
433
- throw Error("Empty password");
434
- const opts = clone(options);
435
- const now = Date.now() + (opts.localtimeOffsetMsec || 0);
436
- const parts = sealed.split("*");
437
- if (parts.length !== 8)
438
- throw new Error("Incorrect number of sealed components");
439
- const prefix = parts[0];
440
- let passwordId = parts[1];
441
- const encryptionSalt = parts[2];
442
- const encryptionIv = parts[3];
443
- const encryptedB64 = parts[4];
444
- const expiration = parts[5];
445
- const hmacSalt = parts[6];
446
- const hmac = parts[7];
447
- const macBaseString = `${prefix}*${passwordId}*${encryptionSalt}*${encryptionIv}*${encryptedB64}*${expiration}`;
448
- if (macPrefix !== prefix)
449
- throw new Error("Wrong mac prefix");
450
- if (expiration) {
451
- if (!/^\d+$/.exec(expiration))
452
- throw new Error("Invalid expiration");
453
- const exp = parseInt(expiration, 10);
454
- if (exp <= now - opts.timestampSkewSec * 1e3)
455
- throw new Error("Expired seal");
456
- }
457
- if (typeof password === "undefined" || typeof password === "string" && password.length === 0)
458
- throw new Error("Empty password");
459
- let pass = "";
460
- passwordId = passwordId || "default";
461
- if (typeof password === "string" || password instanceof Uint8Array)
462
- pass = password;
463
- else if (!(passwordId in password))
464
- throw new Error(`Cannot find password: ${passwordId}`);
465
- else
466
- pass = password[passwordId];
467
- pass = normalizePassword(pass);
468
- const macOptions = opts.integrity;
469
- macOptions.salt = hmacSalt;
470
- const mac = await hmacWithPassword(_crypto, pass.integrity, macOptions, macBaseString);
471
- if (!fixedTimeComparison(mac.digest, hmac))
472
- throw new Error("Bad hmac value");
473
- const encrypted = base64urlDecode(encryptedB64);
474
- const decryptOptions = opts.encryption;
475
- decryptOptions.salt = encryptionSalt;
476
- decryptOptions.iv = base64urlDecode(encryptionIv);
477
- const decrypted = await decrypt(_crypto, pass.encryption, decryptOptions, encrypted);
478
- if (decrypted)
479
- return JSON.parse(decrypted);
480
- return null;
481
- };
24
+
25
+ var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
482
26
 
483
27
  // src/core.ts
484
28
  var timestampSkewSec = 60;
@@ -492,8 +36,8 @@ var defaultOptions = {
492
36
  function normalizeStringPasswordToMap(password) {
493
37
  return typeof password === "string" ? { 1: password } : password;
494
38
  }
495
- function parseSeal(seal2) {
496
- const [sealWithoutVersion, tokenVersionAsString] = seal2.split(versionDelimiter);
39
+ function parseSeal(seal) {
40
+ const [sealWithoutVersion, tokenVersionAsString] = seal.split(versionDelimiter);
497
41
  const tokenVersion = tokenVersionAsString == null ? null : parseInt(tokenVersionAsString, 10);
498
42
  return { sealWithoutVersion, tokenVersion };
499
43
  }
@@ -504,7 +48,7 @@ function computeCookieMaxAge(ttl) {
504
48
  return ttl - timestampSkewSec;
505
49
  }
506
50
  function getCookie(req, cookieName) {
507
- return (0, import_cookie.parse)(
51
+ return cookie.parse(
508
52
  ("headers" in req && typeof req.headers.get === "function" ? req.headers.get("cookie") : req.headers.cookie) ?? ""
509
53
  )[cookieName] ?? "";
510
54
  }
@@ -530,7 +74,7 @@ function setCookie(res, cookieValue) {
530
74
  cookieValue
531
75
  ]);
532
76
  }
533
- function createSealData(_crypto = globalThis.crypto ?? __require("crypto").webcrypto) {
77
+ function createSealData(_crypto) {
534
78
  return async function sealData2(data, {
535
79
  password,
536
80
  ttl = fourteenDaysInSeconds
@@ -544,23 +88,23 @@ function createSealData(_crypto = globalThis.crypto ?? __require("crypto").webcr
544
88
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
545
89
  secret: passwordsMap[mostRecentPasswordId]
546
90
  };
547
- const seal2 = await seal(_crypto, data, passwordForSeal, {
548
- ...defaults,
91
+ const seal = await ironWebcrypto.seal(_crypto, data, passwordForSeal, {
92
+ ...ironWebcrypto.defaults,
549
93
  ttl: ttl * 1e3
550
94
  });
551
- return `${seal2}${versionDelimiter}${currentMajorVersion}`;
95
+ return `${seal}${versionDelimiter}${currentMajorVersion}`;
552
96
  };
553
97
  }
554
- function createUnsealData(_crypto = globalThis.crypto ??= __require("crypto").webcrypto) {
555
- return async function unsealData2(seal2, {
98
+ function createUnsealData(_crypto) {
99
+ return async function unsealData2(seal, {
556
100
  password,
557
101
  ttl = fourteenDaysInSeconds
558
102
  }) {
559
103
  const passwordsMap = normalizeStringPasswordToMap(password);
560
- const { sealWithoutVersion, tokenVersion } = parseSeal(seal2);
104
+ const { sealWithoutVersion, tokenVersion } = parseSeal(seal);
561
105
  try {
562
- const data = await unseal(_crypto, sealWithoutVersion, passwordsMap, {
563
- ...defaults,
106
+ const data = await ironWebcrypto.unseal(_crypto, sealWithoutVersion, passwordsMap, {
107
+ ...ironWebcrypto.defaults,
564
108
  ttl: ttl * 1e3
565
109
  }) ?? {};
566
110
  if (tokenVersion === 2) {
@@ -637,13 +181,13 @@ function createGetIronSession(sealData2, unsealData2) {
637
181
  );
638
182
  }
639
183
  const mergedOptions = mergeOptions(userSessionOptions, saveOptions);
640
- const seal2 = await sealData2(session, {
184
+ const seal = await sealData2(session, {
641
185
  password: passwordsMap,
642
186
  ttl: mergedOptions.ttl
643
187
  });
644
- const cookieValue = (0, import_cookie.serialize)(
188
+ const cookieValue = cookie.serialize(
645
189
  mergedOptions.cookieName,
646
- seal2,
190
+ seal,
647
191
  mergedOptions.cookieOptions
648
192
  );
649
193
  if (cookieValue.length > 4096) {
@@ -663,7 +207,7 @@ function createGetIronSession(sealData2, unsealData2) {
663
207
  userSessionOptions,
664
208
  destroyOptions
665
209
  );
666
- const cookieValue = (0, import_cookie.serialize)(mergedOptions.cookieName, "", {
210
+ const cookieValue = cookie.serialize(mergedOptions.cookieName, "", {
667
211
  ...mergedOptions.cookieOptions,
668
212
  maxAge: 0
669
213
  });
@@ -711,11 +255,11 @@ function createGetServerActionIronSession(sealData2, unsealData2) {
711
255
  save: {
712
256
  value: async function save(saveOptions) {
713
257
  const mergedOptions = mergeOptions(userSessionOptions, saveOptions);
714
- const seal2 = await sealData2(session, {
258
+ const seal = await sealData2(session, {
715
259
  password: passwordsMap,
716
260
  ttl: mergedOptions.ttl
717
261
  });
718
- const cookieLength = mergedOptions.cookieName.length + seal2.length + JSON.stringify(mergedOptions.cookieOptions).length;
262
+ const cookieLength = mergedOptions.cookieName.length + seal.length + JSON.stringify(mergedOptions.cookieOptions).length;
719
263
  if (cookieLength > 4096) {
720
264
  throw new Error(
721
265
  `iron-session: Cookie length is too big (${cookieLength} bytes), browsers will refuse it. Try to remove some data.`
@@ -723,7 +267,7 @@ function createGetServerActionIronSession(sealData2, unsealData2) {
723
267
  }
724
268
  cookieHandler.set(
725
269
  mergedOptions.cookieName,
726
- seal2,
270
+ seal,
727
271
  mergedOptions.cookieOptions
728
272
  );
729
273
  }
@@ -761,25 +305,13 @@ function createResponse(originalResponse, bodyString, options) {
761
305
  headers: mergeHeaders(options?.headers, originalResponse.headers)
762
306
  });
763
307
  }
764
-
765
- // src/index.ts
766
- var sealData = createSealData();
767
- var unsealData = createUnsealData();
308
+ var sealData = createSealData(crypto__namespace);
309
+ var unsealData = createUnsealData(crypto__namespace);
768
310
  var getIronSession = createGetIronSession(sealData, unsealData);
769
311
  var getServerActionIronSession = createGetServerActionIronSession(
770
312
  sealData,
771
313
  unsealData
772
314
  );
773
- /*! Bundled license information:
774
-
775
- cookie/index.js:
776
- (*!
777
- * cookie
778
- * Copyright(c) 2012-2014 Roman Shtylman
779
- * Copyright(c) 2015 Douglas Christopher Wilson
780
- * MIT Licensed
781
- *)
782
- */
783
315
 
784
316
  exports.createGetIronSession = createGetIronSession;
785
317
  exports.createGetServerActionIronSession = createGetServerActionIronSession;