-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(*): Expose requestState.headers to response and populate debug …
…headers only in backend (#2898)
- Loading branch information
Showing
14 changed files
with
101 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@clerk/clerk-sdk-node': minor | ||
'@clerk/backend': minor | ||
'@clerk/fastify': minor | ||
'@clerk/nextjs': minor | ||
'@clerk/remix': minor | ||
--- | ||
|
||
Expose debug headers in response for handshake / signed-out states from SDKs using headers returned from `authenticateRequest()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type QUnit from 'qunit'; | ||
|
||
import { handshake, signedIn, signedOut } from '../authStatus'; | ||
|
||
export default (QUnit: QUnit) => { | ||
const { module, test } = QUnit; | ||
|
||
module('signed-in', () => { | ||
test('does not include debug headers', assert => { | ||
const authObject = signedIn({} as any, {} as any, undefined, 'token'); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-status'), null); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-reason'), null); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-message'), null); | ||
}); | ||
}); | ||
|
||
module('signed-out', () => { | ||
test('includes debug headers', assert => { | ||
const headers = new Headers({ 'custom-header': 'value' }); | ||
const authObject = signedOut({} as any, 'auth-reason', 'auth-message', headers); | ||
|
||
assert.strictEqual(authObject.headers.get('custom-header'), 'value'); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-status'), 'signed-out'); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-reason'), 'auth-reason'); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-message'), 'auth-message'); | ||
}); | ||
}); | ||
|
||
module('handshake', () => { | ||
test('includes debug headers', assert => { | ||
const headers = new Headers({ location: '/' }); | ||
const authObject = handshake({} as any, 'auth-reason', 'auth-message', headers); | ||
|
||
assert.strictEqual(authObject.headers.get('location'), '/'); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-status'), 'handshake'); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-reason'), 'auth-reason'); | ||
assert.strictEqual(authObject.headers.get('x-clerk-auth-message'), 'auth-message'); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters