@mastra/auth-workos 1.5.2-alpha.0 → 1.5.4

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
@@ -11,27 +11,28 @@ var WebSessionStorage = class extends CookieSessionStorage {
11
11
  super(config);
12
12
  }
13
13
  /**
14
- * Extract the encrypted session cookie from a Request.
14
+ * Extract a named cookie from a Request.
15
15
  *
16
16
  * @param request - Standard Web Request object
17
- * @returns The encrypted session string or null if not present
17
+ * @param name - Cookie name
18
+ * @returns The decoded cookie value or null if not present
18
19
  */
19
- async getSession(request) {
20
+ async getCookie(request, name) {
20
21
  const cookieHeader = request.headers.get("Cookie");
21
22
  if (!cookieHeader) {
22
23
  return null;
23
24
  }
24
25
  const cookies = cookieHeader.split(";").reduce(
25
26
  (acc, cookie) => {
26
- const [name, ...valueParts] = cookie.trim().split("=");
27
- if (name) {
28
- acc[name] = decodeURIComponent(valueParts.join("="));
27
+ const [cookieName, ...valueParts] = cookie.trim().split("=");
28
+ if (cookieName) {
29
+ acc[cookieName] = decodeURIComponent(valueParts.join("="));
29
30
  }
30
31
  return acc;
31
32
  },
32
33
  {}
33
34
  );
34
- return cookies[this.cookieName] || null;
35
+ return cookies[name] ?? null;
35
36
  }
36
37
  };
37
38