@nauth-toolkit/recaptcha 0.1.92 → 0.1.93
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.
- package/LICENSE +90 -0
- package/dist/src/providers/recaptcha-enterprise.provider.d.ts +21 -6
- package/dist/src/providers/recaptcha-enterprise.provider.d.ts.map +1 -1
- package/dist/src/providers/recaptcha-enterprise.provider.js +18 -7
- package/dist/src/providers/recaptcha-enterprise.provider.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
NAUTH TOOLKIT EARLY ACCESS LICENSE
|
|
2
|
+
Version 1.0 (December 2025)
|
|
3
|
+
|
|
4
|
+
================================================================================
|
|
5
|
+
FUTURE OPEN SOURCE NOTICE
|
|
6
|
+
================================================================================
|
|
7
|
+
NAuth Toolkit will transition to an open-source license (MIT or Apache 2.0) for
|
|
8
|
+
core authentication features once the project reaches production readiness.
|
|
9
|
+
|
|
10
|
+
This Early Access License is temporary and designed to:
|
|
11
|
+
• Allow developers to build with nauth-toolkit during preview/beta
|
|
12
|
+
• Provide clear expectations during the pre-release phase
|
|
13
|
+
• Enable feedback and real-world testing before GA
|
|
14
|
+
|
|
15
|
+
We're committed to keeping core auth free and open source. Premium features
|
|
16
|
+
(enterprise SSO, advanced compliance, hosted options) will be offered separately
|
|
17
|
+
under fair commercial terms.
|
|
18
|
+
|
|
19
|
+
================================================================================
|
|
20
|
+
EARLY ACCESS LICENSE TERMS
|
|
21
|
+
================================================================================
|
|
22
|
+
|
|
23
|
+
1. Grant of Use
|
|
24
|
+
You are granted a free, non-exclusive, non-transferable license to:
|
|
25
|
+
- Install and use nauth-toolkit packages in development, testing, staging,
|
|
26
|
+
and production environments
|
|
27
|
+
- Modify the code for your own internal use
|
|
28
|
+
- Deploy applications using nauth-toolkit to serve your users
|
|
29
|
+
|
|
30
|
+
You may NOT:
|
|
31
|
+
- Redistribute NAuth Toolkit as a standalone product or service
|
|
32
|
+
- Sell, sublicense, or offer NAuth Toolkit as part of a competing auth
|
|
33
|
+
platform or toolkit
|
|
34
|
+
- Remove or alter copyright notices
|
|
35
|
+
|
|
36
|
+
2. No Fees During Early Access
|
|
37
|
+
There are no license fees, subscription costs, or usage charges during the
|
|
38
|
+
Early Access period. You may use nauth-toolkit freely for commercial and
|
|
39
|
+
non-commercial purposes within the terms of this license.
|
|
40
|
+
|
|
41
|
+
3. Production Use
|
|
42
|
+
Production use is permitted but comes with standard early-access caveats:
|
|
43
|
+
- Features and APIs may change between preview releases
|
|
44
|
+
- Support is community-based (GitHub issues/discussions)
|
|
45
|
+
- No SLA or guaranteed uptime (you run it on your infrastructure)
|
|
46
|
+
|
|
47
|
+
We recommend thorough testing and having rollback plans for critical systems.
|
|
48
|
+
|
|
49
|
+
4. Future Transition
|
|
50
|
+
When nauth-toolkit releases v1.0 GA:
|
|
51
|
+
- Core packages will adopt an open-source license (MIT or Apache 2.0)
|
|
52
|
+
- Your existing deployments will continue to work
|
|
53
|
+
- Premium features (if any) will be clearly documented with separate licensing
|
|
54
|
+
- No forced upgrades or surprise fees
|
|
55
|
+
|
|
56
|
+
5. Ownership
|
|
57
|
+
NAuth Toolkit is developed and maintained by Noorix Digital Solutions.
|
|
58
|
+
You retain full ownership of your applications and data.
|
|
59
|
+
|
|
60
|
+
6. Data and Privacy
|
|
61
|
+
NAuth Toolkit runs in YOUR infrastructure and database. You control all data.
|
|
62
|
+
You are responsible for compliance with applicable data protection laws.
|
|
63
|
+
|
|
64
|
+
7. Disclaimer of Warranty
|
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
66
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
67
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
68
|
+
|
|
69
|
+
8. Limitation of Liability
|
|
70
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
|
|
71
|
+
SPECIAL, CONSEQUENTIAL, OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO LOSS
|
|
72
|
+
OF PROFITS, REVENUE, DATA, OR USE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
73
|
+
DAMAGES.
|
|
74
|
+
|
|
75
|
+
9. Termination
|
|
76
|
+
This license remains in effect until:
|
|
77
|
+
- You stop using nauth-toolkit, or
|
|
78
|
+
- The project transitions to open source (at which point the new license applies)
|
|
79
|
+
|
|
80
|
+
If you breach these terms, your license terminates and you must stop using the
|
|
81
|
+
software.
|
|
82
|
+
|
|
83
|
+
10. Contact and Support
|
|
84
|
+
- Documentation: https://nauth.dev
|
|
85
|
+
- Issues/Discussions: GitHub (when public repository launches)
|
|
86
|
+
- Commercial inquiries: Contact admin@noorix.com
|
|
87
|
+
|
|
88
|
+
================================================================================
|
|
89
|
+
Thank you for being an early adopter. Your feedback shapes the future of NAuth.
|
|
90
|
+
================================================================================
|
|
@@ -9,7 +9,13 @@ export interface RecaptchaEnterpriseConfig {
|
|
|
9
9
|
projectId: string;
|
|
10
10
|
/**
|
|
11
11
|
* API key from Google Cloud Console
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* Requirements:
|
|
14
|
+
* 1. Created in: Google Cloud Console → APIs & Services → Credentials
|
|
15
|
+
* 2. Must have reCAPTCHA Enterprise API enabled
|
|
16
|
+
* 3. Recommended: Restrict to IP addresses or HTTP referrers for security
|
|
17
|
+
*
|
|
18
|
+
* Note: This is different from the site key. The API key authenticates your backend.
|
|
13
19
|
*/
|
|
14
20
|
apiKey: string;
|
|
15
21
|
/**
|
|
@@ -33,12 +39,20 @@ export interface RecaptchaEnterpriseConfig {
|
|
|
33
39
|
/**
|
|
34
40
|
* Google reCAPTCHA Enterprise Provider
|
|
35
41
|
*
|
|
36
|
-
* Implements advanced bot detection
|
|
37
|
-
*
|
|
42
|
+
* Implements advanced bot detection using Google's Enterprise REST API.
|
|
43
|
+
*
|
|
44
|
+
* Features:
|
|
45
|
+
* - Advanced fraud detection with risk scores
|
|
38
46
|
* - Custom rules and actions
|
|
39
47
|
* - Detailed analytics and reporting
|
|
40
48
|
* - SLA guarantees
|
|
41
49
|
*
|
|
50
|
+
* Setup:
|
|
51
|
+
* 1. Enable reCAPTCHA Enterprise API in Google Cloud Console
|
|
52
|
+
* 2. Create an API key with reCAPTCHA Enterprise API permission
|
|
53
|
+
* 3. Create a site key in reCAPTCHA Enterprise console
|
|
54
|
+
* 4. Add domains to site key whitelist (including localhost for dev)
|
|
55
|
+
*
|
|
42
56
|
* Enterprise is recommended for:
|
|
43
57
|
* - High-traffic production applications
|
|
44
58
|
* - Advanced security requirements
|
|
@@ -47,7 +61,7 @@ export interface RecaptchaEnterpriseConfig {
|
|
|
47
61
|
* @example
|
|
48
62
|
* ```typescript
|
|
49
63
|
* const provider = new RecaptchaEnterpriseProvider({
|
|
50
|
-
* projectId: 'my-project',
|
|
64
|
+
* projectId: 'my-project-id',
|
|
51
65
|
* apiKey: process.env.RECAPTCHA_ENTERPRISE_API_KEY!,
|
|
52
66
|
* siteKey: process.env.RECAPTCHA_ENTERPRISE_SITE_KEY!,
|
|
53
67
|
* });
|
|
@@ -59,7 +73,7 @@ export interface RecaptchaEnterpriseConfig {
|
|
|
59
73
|
* }
|
|
60
74
|
*
|
|
61
75
|
* if (result.score && result.score < 0.5) {
|
|
62
|
-
* //
|
|
76
|
+
* // Handle low score - potential bot
|
|
63
77
|
* }
|
|
64
78
|
* ```
|
|
65
79
|
*/
|
|
@@ -74,8 +88,9 @@ export declare class RecaptchaEnterpriseProvider implements RecaptchaProvider {
|
|
|
74
88
|
* Verify reCAPTCHA Enterprise token with Google's API
|
|
75
89
|
*
|
|
76
90
|
* Uses the reCAPTCHA Enterprise REST API for assessment creation.
|
|
91
|
+
* The API key is passed as a query parameter for authentication.
|
|
77
92
|
*
|
|
78
|
-
* @param token - Token from client
|
|
93
|
+
* @param token - Token from client (generated by grecaptcha.enterprise.execute)
|
|
79
94
|
* @param remoteIp - Client IP address (optional but recommended)
|
|
80
95
|
* @param action - Action name used when generating token (e.g., 'login', 'signup')
|
|
81
96
|
* @returns Verification result with score and risk analysis
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recaptcha-enterprise.provider.d.ts","sourceRoot":"","sources":["../../../src/providers/recaptcha-enterprise.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAEjG;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB
|
|
1
|
+
{"version":3,"file":"recaptcha-enterprise.provider.d.ts","sourceRoot":"","sources":["../../../src/providers/recaptcha-enterprise.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAEjG;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;;;;OASG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,2BAA4B,YAAW,iBAAiB;IACnE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,yBAAyB;IAQ7C;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;CA6DtG"}
|
|
@@ -4,12 +4,20 @@ exports.RecaptchaEnterpriseProvider = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Google reCAPTCHA Enterprise Provider
|
|
6
6
|
*
|
|
7
|
-
* Implements advanced bot detection
|
|
8
|
-
*
|
|
7
|
+
* Implements advanced bot detection using Google's Enterprise REST API.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Advanced fraud detection with risk scores
|
|
9
11
|
* - Custom rules and actions
|
|
10
12
|
* - Detailed analytics and reporting
|
|
11
13
|
* - SLA guarantees
|
|
12
14
|
*
|
|
15
|
+
* Setup:
|
|
16
|
+
* 1. Enable reCAPTCHA Enterprise API in Google Cloud Console
|
|
17
|
+
* 2. Create an API key with reCAPTCHA Enterprise API permission
|
|
18
|
+
* 3. Create a site key in reCAPTCHA Enterprise console
|
|
19
|
+
* 4. Add domains to site key whitelist (including localhost for dev)
|
|
20
|
+
*
|
|
13
21
|
* Enterprise is recommended for:
|
|
14
22
|
* - High-traffic production applications
|
|
15
23
|
* - Advanced security requirements
|
|
@@ -18,7 +26,7 @@ exports.RecaptchaEnterpriseProvider = void 0;
|
|
|
18
26
|
* @example
|
|
19
27
|
* ```typescript
|
|
20
28
|
* const provider = new RecaptchaEnterpriseProvider({
|
|
21
|
-
* projectId: 'my-project',
|
|
29
|
+
* projectId: 'my-project-id',
|
|
22
30
|
* apiKey: process.env.RECAPTCHA_ENTERPRISE_API_KEY!,
|
|
23
31
|
* siteKey: process.env.RECAPTCHA_ENTERPRISE_SITE_KEY!,
|
|
24
32
|
* });
|
|
@@ -30,7 +38,7 @@ exports.RecaptchaEnterpriseProvider = void 0;
|
|
|
30
38
|
* }
|
|
31
39
|
*
|
|
32
40
|
* if (result.score && result.score < 0.5) {
|
|
33
|
-
* //
|
|
41
|
+
* // Handle low score - potential bot
|
|
34
42
|
* }
|
|
35
43
|
* ```
|
|
36
44
|
*/
|
|
@@ -51,8 +59,9 @@ class RecaptchaEnterpriseProvider {
|
|
|
51
59
|
* Verify reCAPTCHA Enterprise token with Google's API
|
|
52
60
|
*
|
|
53
61
|
* Uses the reCAPTCHA Enterprise REST API for assessment creation.
|
|
62
|
+
* The API key is passed as a query parameter for authentication.
|
|
54
63
|
*
|
|
55
|
-
* @param token - Token from client
|
|
64
|
+
* @param token - Token from client (generated by grecaptcha.enterprise.execute)
|
|
56
65
|
* @param remoteIp - Client IP address (optional but recommended)
|
|
57
66
|
* @param action - Action name used when generating token (e.g., 'login', 'signup')
|
|
58
67
|
* @returns Verification result with score and risk analysis
|
|
@@ -60,7 +69,8 @@ class RecaptchaEnterpriseProvider {
|
|
|
60
69
|
* @throws Error if network request fails or times out
|
|
61
70
|
*/
|
|
62
71
|
async verify(token, remoteIp, action) {
|
|
63
|
-
// Build assessment
|
|
72
|
+
// Build assessment URL with API key as query parameter
|
|
73
|
+
// This is the correct way to authenticate with API keys per Google docs
|
|
64
74
|
const assessmentUrl = `${this.apiEndpoint}/projects/${this.projectId}/assessments?key=${this.apiKey}`;
|
|
65
75
|
const requestBody = {
|
|
66
76
|
event: {
|
|
@@ -85,7 +95,8 @@ class RecaptchaEnterpriseProvider {
|
|
|
85
95
|
});
|
|
86
96
|
clearTimeout(timeoutId);
|
|
87
97
|
if (!response.ok) {
|
|
88
|
-
|
|
98
|
+
const errorBody = await response.text();
|
|
99
|
+
throw new Error(`reCAPTCHA Enterprise API returned status ${response.status}: ${errorBody}`);
|
|
89
100
|
}
|
|
90
101
|
const data = await response.json();
|
|
91
102
|
// Extract token properties from assessment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recaptcha-enterprise.provider.js","sourceRoot":"","sources":["../../../src/providers/recaptcha-enterprise.provider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"recaptcha-enterprise.provider.js","sourceRoot":"","sources":["../../../src/providers/recaptcha-enterprise.provider.ts"],"names":[],"mappings":";;;AA4CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,2BAA2B;IACrB,SAAS,CAAS;IAClB,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,WAAW,CAAS;IACpB,OAAO,CAAS;IAEjC,YAAY,MAAiC;QAC3C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,+CAA+C,CAAC;QACzF,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC;IACzC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,QAAiB,EAAE,MAAe;QAC5D,uDAAuD;QACvD,wEAAwE;QACxE,MAAM,aAAa,GAAG,GAAG,IAAI,CAAC,WAAW,aAAa,IAAI,CAAC,SAAS,oBAAoB,IAAI,CAAC,MAAM,EAAE,CAAC;QAEtG,MAAM,WAAW,GAAG;YAClB,KAAK,EAAE;gBACL,KAAK;gBACL,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,GAAG,CAAC,MAAM,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;gBACzC,GAAG,CAAC,QAAQ,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;aAC7C;SACF,CAAC;QAEF,IAAI,CAAC;YACH,sCAAsC;YACtC,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;YACzC,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