@workos-inc/authkit-nextjs 2.12.2 → 2.14.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 (46) hide show
  1. package/README.md +138 -73
  2. package/dist/esm/errors.js +33 -0
  3. package/dist/esm/errors.js.map +1 -0
  4. package/dist/esm/get-authorization-url.js +7 -2
  5. package/dist/esm/get-authorization-url.js.map +1 -1
  6. package/dist/esm/index.js +3 -1
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/middleware-helpers.js +99 -0
  9. package/dist/esm/middleware-helpers.js.map +1 -0
  10. package/dist/esm/session.js +11 -35
  11. package/dist/esm/session.js.map +1 -1
  12. package/dist/esm/types/errors.d.ts +15 -0
  13. package/dist/esm/types/index.d.ts +3 -1
  14. package/dist/esm/types/middleware-helpers.d.ts +25 -0
  15. package/dist/esm/types/session.d.ts +1 -1
  16. package/dist/esm/types/validate-api-key.d.ts +1 -1
  17. package/dist/esm/types/workos.d.ts +1 -1
  18. package/dist/esm/utils.js +0 -2
  19. package/dist/esm/utils.js.map +1 -1
  20. package/dist/esm/workos.js +1 -1
  21. package/package.json +20 -21
  22. package/src/actions.spec.ts +14 -12
  23. package/src/auth.spec.ts +27 -29
  24. package/src/authkit-callback-route.spec.ts +31 -29
  25. package/src/components/authkit-provider.spec.tsx +67 -71
  26. package/src/components/button.spec.tsx +4 -6
  27. package/src/components/impersonation.spec.tsx +25 -25
  28. package/src/components/min-max-button.spec.tsx +2 -1
  29. package/src/components/tokenStore.spec.ts +21 -21
  30. package/src/components/useAccessToken.spec.tsx +73 -77
  31. package/src/components/useTokenClaims.spec.tsx +22 -22
  32. package/src/cookie.spec.ts +14 -9
  33. package/src/errors.spec.ts +108 -0
  34. package/src/errors.ts +46 -0
  35. package/src/get-authorization-url.spec.ts +12 -13
  36. package/src/get-authorization-url.ts +6 -10
  37. package/src/index.ts +16 -2
  38. package/src/middleware-helpers.spec.ts +231 -0
  39. package/src/middleware-helpers.ts +130 -0
  40. package/src/session.spec.ts +81 -73
  41. package/src/session.ts +16 -38
  42. package/src/utils.spec.ts +14 -31
  43. package/src/utils.ts +0 -2
  44. package/src/validate-api-key.spec.ts +4 -6
  45. package/src/workos.spec.ts +2 -2
  46. package/src/workos.ts +1 -1
@@ -1,9 +1,7 @@
1
- import { describe, it, expect, beforeEach, jest } from '@jest/globals';
2
-
3
1
  import { validateApiKey } from './validate-api-key.js';
4
2
  import { getWorkOS } from './workos.js';
5
3
 
6
- // These are mocked in jest.setup.ts
4
+ // These are mocked in vitest.setup.ts
7
5
  import { headers } from 'next/headers';
8
6
 
9
7
  const workos = getWorkOS();
@@ -11,7 +9,7 @@ const workos = getWorkOS();
11
9
  describe('validate-api-key.ts', () => {
12
10
  beforeEach(async () => {
13
11
  // Clear all mocks between tests
14
- jest.clearAllMocks();
12
+ vi.clearAllMocks();
15
13
 
16
14
  const nextHeaders = await headers();
17
15
  // @ts-expect-error - _reset is part of the mock
@@ -34,7 +32,7 @@ describe('validate-api-key.ts', () => {
34
32
  },
35
33
  };
36
34
 
37
- jest.spyOn(workos.apiKeys, 'validateApiKey').mockResolvedValue(mockApiKeyResponse);
35
+ vi.spyOn(workos.apiKeys, 'validateApiKey').mockResolvedValue(mockApiKeyResponse);
38
36
 
39
37
  const nextHeaders = await headers();
40
38
  nextHeaders.set('authorization', 'Bearer sk_test_1234567890');
@@ -97,7 +95,7 @@ describe('validate-api-key.ts', () => {
97
95
 
98
96
  it('should return { apiKey: null } when WorkOS validation fails', async () => {
99
97
  const mockResponse = { apiKey: null };
100
- jest.spyOn(workos.apiKeys, 'validateApiKey').mockResolvedValue(mockResponse);
98
+ vi.spyOn(workos.apiKeys, 'validateApiKey').mockResolvedValue(mockResponse);
101
99
 
102
100
  const nextHeaders = await headers();
103
101
  nextHeaders.set('authorization', 'Bearer invalid_key');
@@ -4,7 +4,7 @@ import { getWorkOS, VERSION } from './workos.js';
4
4
  describe('workos', () => {
5
5
  const workos = getWorkOS();
6
6
  beforeEach(() => {
7
- jest.clearAllMocks();
7
+ vi.clearAllMocks();
8
8
  });
9
9
 
10
10
  it('initializes WorkOS with the correct configuration', () => {
@@ -35,7 +35,7 @@ describe('workos', () => {
35
35
  const originalEnv = process.env;
36
36
 
37
37
  beforeEach(() => {
38
- jest.resetModules();
38
+ vi.resetModules();
39
39
  process.env = { ...originalEnv };
40
40
  });
41
41
 
package/src/workos.ts CHANGED
@@ -2,7 +2,7 @@ import { WorkOS } from '@workos-inc/node';
2
2
  import { WORKOS_API_HOSTNAME, WORKOS_API_KEY, WORKOS_API_HTTPS, WORKOS_API_PORT } from './env-variables.js';
3
3
  import { lazy } from './utils.js';
4
4
 
5
- export const VERSION = '2.12.2';
5
+ export const VERSION = '2.14.0';
6
6
 
7
7
  const options = {
8
8
  apiHostname: WORKOS_API_HOSTNAME,