-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from chvarkov/develop
feat: dynamic recaptcha configuration.
- Loading branch information
Showing
19 changed files
with
280 additions
and
70 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { RecaptchaRemoteIpProvider, RecaptchaResponseProvider, ScoreValidator } from "../types"; | ||
import { RecaptchaRemoteIpProvider, RecaptchaResponseProvider, ScoreValidator, SkipIfValue } from '../types'; | ||
|
||
export interface GoogleRecaptchaGuardOptions { | ||
response: RecaptchaResponseProvider; | ||
remoteIp?: RecaptchaRemoteIpProvider; | ||
skipIf?: boolean | (<Req = unknown>(request: Req) => boolean | Promise<boolean>); | ||
skipIf?: SkipIfValue; | ||
score?: ScoreValidator; | ||
} |
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,38 @@ | ||
import { GoogleRecaptchaModuleOptions } from '../interfaces/google-recaptcha-module-options'; | ||
import { GoogleRecaptchaEnterpriseOptions } from '../interfaces/google-recaptcha-enterprise-options'; | ||
import { ScoreValidator, SkipIfValue } from '../types'; | ||
|
||
export class RecaptchaConfigRef { | ||
get valueOf(): GoogleRecaptchaModuleOptions { | ||
return this.value; | ||
} | ||
|
||
constructor(private readonly value: GoogleRecaptchaModuleOptions) { | ||
} | ||
|
||
setSecretKey(secretKey: string): this { | ||
this.value.secretKey = secretKey; | ||
this.value.enterprise = undefined; | ||
|
||
return this; | ||
} | ||
|
||
setEnterpriseOptions(options: GoogleRecaptchaEnterpriseOptions): this { | ||
this.value.secretKey = undefined; | ||
this.value.enterprise = options; | ||
|
||
return this; | ||
} | ||
|
||
setScore(score: ScoreValidator): this { | ||
this.value.score = score; | ||
|
||
return this; | ||
} | ||
|
||
setSkipIf(skipIf: SkipIfValue): this { | ||
this.value.skipIf = skipIf; | ||
|
||
return this; | ||
} | ||
} |
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.