Skip to content

Commit

Permalink
feat: add generateRandomState
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 7, 2022
1 parent ad60b2c commit a39cc6b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [discoveryRequest](functions/discoveryRequest.md)
- [generateRandomCodeVerifier](functions/generateRandomCodeVerifier.md)
- [generateRandomNonce](functions/generateRandomNonce.md)
- [generateRandomState](functions/generateRandomState.md)
- [getValidatedIdTokenClaims](functions/getValidatedIdTokenClaims.md)
- [introspectionRequest](functions/introspectionRequest.md)
- [isOAuth2Error](functions/isOAuth2Error.md)
Expand Down
11 changes: 11 additions & 0 deletions docs/functions/generateRandomState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Function: generateRandomState

**generateRandomState**(): `string`

Generate random `state` value.

**`see`** [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.1)

#### Returns

`string`
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,15 @@ export function generateRandomCodeVerifier() {
return randomBytes()
}

/**
* Generate random `state` value.
*
* @see {@link https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.1 RFC 6749 - The OAuth 2.0 Authorization Framework}
*/
export function generateRandomState() {
return randomBytes()
}

/**
* Generate random `nonce` value.
*
Expand Down

0 comments on commit a39cc6b

Please sign in to comment.