@workos-inc/authkit-nextjs 3.0.1 → 4.0.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.
@@ -11,6 +11,6 @@ export async function validateApiKey() {
11
11
  if (!value) {
12
12
  return { apiKey: null };
13
13
  }
14
- return getWorkOS().apiKeys.validateApiKey({ value });
14
+ return getWorkOS().apiKeys.createValidation({ value });
15
15
  }
16
16
  //# sourceMappingURL=validate-api-key.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-api-key.js","sourceRoot":"","sources":["../../src/validate-api-key.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7D,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,SAAS,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACvD,CAAC"}
1
+ {"version":3,"file":"validate-api-key.js","sourceRoot":"","sources":["../../src/validate-api-key.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7D,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,SAAS,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workos-inc/authkit-nextjs",
3
- "version": "3.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "Authentication and session helpers for using WorkOS & AuthKit with Next.js",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@sindresorhus/fnv1a": "^3.1.0",
27
- "@workos-inc/node": "^8.9.0",
27
+ "@workos-inc/node": "^9.0.0",
28
28
  "iron-session": "^8.0.4",
29
29
  "jose": "^5.10.0",
30
30
  "path-to-regexp": "^6.3.0",
@@ -60,6 +60,9 @@
60
60
  "bugs": {
61
61
  "url": "https://github.com/workos/authkit-nextjs/issues"
62
62
  },
63
+ "engines": {
64
+ "node": ">=22.11.0"
65
+ },
63
66
  "scripts": {
64
67
  "clean": "rm -rf dist",
65
68
  "prebuild": "pnpm run clean",
@@ -16,7 +16,7 @@ describe('validate-api-key.ts', () => {
16
16
  nextHeaders._reset();
17
17
  });
18
18
 
19
- describe('validateApiKey', () => {
19
+ describe('createValidation', () => {
20
20
  it('should return valid API key when Bearer token is present and valid', async () => {
21
21
  const mockApiKeyResponse = {
22
22
  apiKey: {
@@ -32,14 +32,14 @@ describe('validate-api-key.ts', () => {
32
32
  },
33
33
  };
34
34
 
35
- vi.spyOn(workos.apiKeys, 'validateApiKey').mockResolvedValue(mockApiKeyResponse);
35
+ vi.spyOn(workos.apiKeys, 'createValidation').mockResolvedValue(mockApiKeyResponse);
36
36
 
37
37
  const nextHeaders = await headers();
38
38
  nextHeaders.set('authorization', 'Bearer sk_test_1234567890');
39
39
 
40
40
  const result = await validateApiKey();
41
41
 
42
- expect(workos.apiKeys.validateApiKey).toHaveBeenCalledWith({
42
+ expect(workos.apiKeys.createValidation).toHaveBeenCalledWith({
43
43
  value: 'sk_test_1234567890',
44
44
  });
45
45
  expect(result).toEqual(mockApiKeyResponse);
@@ -49,7 +49,7 @@ describe('validate-api-key.ts', () => {
49
49
  // Don't set any authorization header
50
50
  const result = await validateApiKey();
51
51
 
52
- expect(workos.apiKeys.validateApiKey).not.toHaveBeenCalled();
52
+ expect(workos.apiKeys.createValidation).not.toHaveBeenCalled();
53
53
  expect(result).toEqual({ apiKey: null });
54
54
  });
55
55
 
@@ -59,7 +59,7 @@ describe('validate-api-key.ts', () => {
59
59
 
60
60
  const result = await validateApiKey();
61
61
 
62
- expect(workos.apiKeys.validateApiKey).not.toHaveBeenCalled();
62
+ expect(workos.apiKeys.createValidation).not.toHaveBeenCalled();
63
63
  expect(result).toEqual({ apiKey: null });
64
64
  });
65
65
 
@@ -69,7 +69,7 @@ describe('validate-api-key.ts', () => {
69
69
 
70
70
  const result = await validateApiKey();
71
71
 
72
- expect(workos.apiKeys.validateApiKey).not.toHaveBeenCalled();
72
+ expect(workos.apiKeys.createValidation).not.toHaveBeenCalled();
73
73
  expect(result).toEqual({ apiKey: null });
74
74
  });
75
75
 
@@ -79,7 +79,7 @@ describe('validate-api-key.ts', () => {
79
79
 
80
80
  const result = await validateApiKey();
81
81
 
82
- expect(workos.apiKeys.validateApiKey).not.toHaveBeenCalled();
82
+ expect(workos.apiKeys.createValidation).not.toHaveBeenCalled();
83
83
  expect(result).toEqual({ apiKey: null });
84
84
  });
85
85
 
@@ -89,20 +89,20 @@ describe('validate-api-key.ts', () => {
89
89
 
90
90
  const result = await validateApiKey();
91
91
 
92
- expect(workos.apiKeys.validateApiKey).not.toHaveBeenCalled();
92
+ expect(workos.apiKeys.createValidation).not.toHaveBeenCalled();
93
93
  expect(result).toEqual({ apiKey: null });
94
94
  });
95
95
 
96
96
  it('should return { apiKey: null } when WorkOS validation fails', async () => {
97
97
  const mockResponse = { apiKey: null };
98
- vi.spyOn(workos.apiKeys, 'validateApiKey').mockResolvedValue(mockResponse);
98
+ vi.spyOn(workos.apiKeys, 'createValidation').mockResolvedValue(mockResponse);
99
99
 
100
100
  const nextHeaders = await headers();
101
101
  nextHeaders.set('authorization', 'Bearer invalid_key');
102
102
 
103
103
  const result = await validateApiKey();
104
104
 
105
- expect(workos.apiKeys.validateApiKey).toHaveBeenCalledWith({
105
+ expect(workos.apiKeys.createValidation).toHaveBeenCalledWith({
106
106
  value: 'invalid_key',
107
107
  });
108
108
  expect(result).toEqual({ apiKey: null });
@@ -15,5 +15,5 @@ export async function validateApiKey() {
15
15
  return { apiKey: null };
16
16
  }
17
17
 
18
- return getWorkOS().apiKeys.validateApiKey({ value });
18
+ return getWorkOS().apiKeys.createValidation({ value });
19
19
  }