-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add nextjs-auth0 example * add refresh token test * return refresh_token from /oauth/token * tests passing * rollback config * add refresh_token functionality * store only the user.id * add changeset * fix tests * add refresh token test
- Loading branch information
Showing
9 changed files
with
266 additions
and
43 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,4 @@ | ||
--- | ||
"@simulacrum/auth0-simulator": minor | ||
--- | ||
Add the `refresh_token` flow |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { GrantType, RefreshToken } from '../types'; | ||
import { epochTime } from './date'; | ||
import { encode } from "base64-url"; | ||
import { assert } from 'assert-ts'; | ||
|
||
export function issueRefreshToken(scope: string, grantType: GrantType): boolean { | ||
return grantType === 'refresh_token' || scope.includes('offline_access'); | ||
} | ||
|
||
export function createRefreshToken({ exp, rotations = 0, scope, user, nonce }: Omit<RefreshToken, 'iat'>): string { | ||
assert(!!user.id, `no identifier for user`); | ||
|
||
return encode(JSON.stringify({ | ||
exp, | ||
iat: epochTime(), | ||
rotations, | ||
scope, | ||
user: { id: user.id }, | ||
nonce | ||
})); | ||
} |
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
Oops, something went wrong.