@noresponse/node 0.0.1-bootstrap.0 → 1.0.1
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 +202 -0
- package/README.md +35 -0
- package/dist/auth.d.ts +11 -0
- package/dist/auth.js +111 -0
- package/dist/generated/models.d.ts +306 -0
- package/dist/generated/models.js +2 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +244 -0
- package/dist/webhooks.d.ts +17 -0
- package/dist/webhooks.js +87 -0
- package/package.json +35 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 NoResponse
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @noresponse/node
|
|
2
|
+
|
|
3
|
+
Server-side Node / TypeScript client for the provider-facing NoResponse signup API. Install it with `npm install @noresponse/node` (Node 20 or later). To work on the SDK, run `npm ci && npm test` in this folder; builds emit `dist/index.js` and type declarations.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { NoResponse, type Assessment } from "@noresponse/node";
|
|
7
|
+
|
|
8
|
+
const nr = new NoResponse({
|
|
9
|
+
apiKey: process.env.NORESPONSE_API_KEY!, // server-only
|
|
10
|
+
baseUrl: process.env.NORESPONSE_API_URL!, // https://api.noresponse.org in production
|
|
11
|
+
timeoutMs: 5000, // transport timeout; configurable per deployment
|
|
12
|
+
});
|
|
13
|
+
const assessment: Assessment = await nr.assess({
|
|
14
|
+
accountId: "usr_123",
|
|
15
|
+
email: "person@example.com", // email, username or phone: at least one
|
|
16
|
+
name: "Jane A. Doe", // optional, used only for matching
|
|
17
|
+
ip: "73.162.18.45", // optional, the signup's public IP
|
|
18
|
+
idempotencyKey: "signup-usr_123-0000001",
|
|
19
|
+
});
|
|
20
|
+
if (assessment.status === "pending") {
|
|
21
|
+
// No recommendation yet: never allow. Apply YOUR fallback, then wait for the webhook or poll.
|
|
22
|
+
} else if (assessment.risk?.recommendation === "step_up") {
|
|
23
|
+
// Your app decides whether to request an additional verification step.
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Also provides `getAssessment(assessmentId, { responseMode })`, `queryAssessments({ account_id, limit, cursor, responseMode })` and `recordOutcome(assessmentId, { outcome, idempotencyKey, observedAt, externalRef, notes })`, which reports what was later learned about the account (`confirmed_abuse`, `account_takeover`, `chargeback`, `false_positive`, `legitimate` or `unknown`). `responseMode: "detailed"` (with the `detailed` key scope) adds `risk.details` and `signals[]`; `raw` is refused. Pass `flow` (`signup`, `login`, `recovery`, or `profile_change`) and an uppercase `region` when the event is not the default signup. The client retries network failures, 429 and 503 a bounded number of times while preserving the same idempotency key.
|
|
28
|
+
|
|
29
|
+
Webhooks: `verifyWebhook(rawBody, headerPairs, secrets, nowSeconds?)` checks the `v1=` HMAC-SHA256 signature over the exact raw request bytes, the 300-second timestamp window and the event id, and returns the typed `WebhookEvent`. It takes **raw header pairs** so it can refuse a repeated header, including a case variant. Never parse then re-stringify the body before verifying. An `assessment.updated` event's `data` is the full assessment, exactly as `getAssessment` returns it: `webhookAssessment(event)` returns it as a typed `Assessment`. Keep the highest `assessment_version` per assessment. When receiving `endpoint.verification`, respond with `webhookVerificationResponse(event)`.
|
|
30
|
+
|
|
31
|
+
See [example rules](../docs/example-rules.md) for turning an assessment into an action, for example "step up when `breach_name_mismatch` or `proxy_ip` fired".
|
|
32
|
+
|
|
33
|
+
This SDK never makes the allow/deny decision for a provider. `pending`, HTTP 429/503 and network timeouts must follow provider-defined fail-open/step-up policy; idempotency keys must be reused for retries of the **same request body**. No tenant keys in browser bundles, environment values in logs, or production traffic before the API release GO decision.
|
|
34
|
+
|
|
35
|
+
Every request, response, summary, detail, signal and webhook type is generated from the provider OpenAPI contract into `src/generated/models.ts` and re-exported from the package (for example `Assessment`, `Risk`, `RiskReason`, `RiskSummary`, `Signal`, `WebhookEvent`). The committed package-lock.json makes the TypeScript toolchain reproducible; use npm ci in CI and local validation. See [provider onboarding](../docs/provider-onboarding.md) for key rotation, webhook verification, retries and staging setup.
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AssessmentRequestAuthContext } from "./generated/models.js";
|
|
2
|
+
export type VerifiedClaims = Record<string, unknown>;
|
|
3
|
+
export type AuthContextOverrides = Partial<AssessmentRequestAuthContext>;
|
|
4
|
+
/** Map verified WorkOS/AuthKit claims plus verified user/session-record overrides. */
|
|
5
|
+
export declare function fromWorkOS(claims: VerifiedClaims, overrides?: AuthContextOverrides): AssessmentRequestAuthContext;
|
|
6
|
+
/** Map verified Clerk session claims. Pass Session.createdAt as session_created_at. */
|
|
7
|
+
export declare function fromClerk(claims: VerifiedClaims, overrides?: AuthContextOverrides): AssessmentRequestAuthContext;
|
|
8
|
+
/** Map verified Auth0 ID-token, userinfo, or normalized session claims. Do not pass an opaque API access token. */
|
|
9
|
+
export declare function fromAuth0(claims: VerifiedClaims, overrides?: AuthContextOverrides): AssessmentRequestAuthContext;
|
|
10
|
+
/** Generic OIDC adapter for providers without a first-class helper. */
|
|
11
|
+
export declare function fromOIDC(provider: string, claims: VerifiedClaims, overrides?: AuthContextOverrides): AssessmentRequestAuthContext;
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
function text(value) {
|
|
2
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
3
|
+
}
|
|
4
|
+
function iso(value) {
|
|
5
|
+
if (typeof value === "string")
|
|
6
|
+
return value;
|
|
7
|
+
// Whole UTC seconds (the fraction is truncated), as the Go and Python helpers write it.
|
|
8
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
9
|
+
return new Date(Math.trunc(value) * 1000).toISOString().replace(".000Z", "Z");
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
// Defaults are the auth-context.schema.json bounds for roles and scopes (32
|
|
13
|
+
// items of at most 64 characters); audiences are 8 x 256 and amr 8 x 32. The
|
|
14
|
+
// Go and Python helpers apply the same caps. Over-long values are dropped,
|
|
15
|
+
// not truncated.
|
|
16
|
+
function bounded(values, limit, maxLength) {
|
|
17
|
+
const kept = values
|
|
18
|
+
.filter((item) => typeof item === "string" && item.length > 0 && [...item].length <= maxLength)
|
|
19
|
+
.slice(0, limit);
|
|
20
|
+
return kept.length ? kept : undefined;
|
|
21
|
+
}
|
|
22
|
+
function strings(value, limit = 32, maxLength = 64) {
|
|
23
|
+
if (typeof value === "string")
|
|
24
|
+
return bounded(value.split(/\s+/), limit, maxLength);
|
|
25
|
+
return Array.isArray(value) ? bounded(value, limit, maxLength) : undefined;
|
|
26
|
+
}
|
|
27
|
+
function delimitedStrings(value, limit = 32, maxLength = 64) {
|
|
28
|
+
if (typeof value !== "string")
|
|
29
|
+
return strings(value, limit, maxLength);
|
|
30
|
+
return bounded(value.split(/[\s,]+/).map(item => item.trim()), limit, maxLength);
|
|
31
|
+
}
|
|
32
|
+
function audiences(value) {
|
|
33
|
+
return strings(value, 8, 256);
|
|
34
|
+
}
|
|
35
|
+
function object(value) {
|
|
36
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
37
|
+
}
|
|
38
|
+
function actorPresent(value) {
|
|
39
|
+
const record = object(value);
|
|
40
|
+
return Boolean(record ? text(record.sub) ?? text(record.email) : text(value));
|
|
41
|
+
}
|
|
42
|
+
function base(provider, claims, overrides = {}, options = {}) {
|
|
43
|
+
const issuer = text(overrides.issuer) ?? text(claims.iss);
|
|
44
|
+
const subject = text(overrides.subject) ?? text(claims.sub);
|
|
45
|
+
if (!issuer || !subject)
|
|
46
|
+
throw new Error("NoResponse auth context requires verified issuer and subject");
|
|
47
|
+
const claimAudiences = audiences(claims.aud);
|
|
48
|
+
const mergedAudiences = overrides.audiences ?? claimAudiences;
|
|
49
|
+
return {
|
|
50
|
+
provider,
|
|
51
|
+
issuer,
|
|
52
|
+
subject,
|
|
53
|
+
...(mergedAudiences?.length ? { audiences: mergedAudiences, audience: overrides.audience ?? mergedAudiences[0] } : {}),
|
|
54
|
+
...(options.includeIssuedAt !== false && iso(claims.iat) ? { issued_at: iso(claims.iat) } : {}),
|
|
55
|
+
...(iso(claims.exp) ? { expires_at: iso(claims.exp) } : {}),
|
|
56
|
+
...(iso(claims.auth_time) ? { auth_time: iso(claims.auth_time) } : {}),
|
|
57
|
+
...(text(claims.sid) ? { session_id: text(claims.sid) } : {}),
|
|
58
|
+
...(text(claims.jti) ? { token_id: text(claims.jti) } : {}),
|
|
59
|
+
verified: true,
|
|
60
|
+
transport: "backend",
|
|
61
|
+
...overrides,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Map verified WorkOS/AuthKit claims plus verified user/session-record overrides. */
|
|
65
|
+
export function fromWorkOS(claims, overrides = {}) {
|
|
66
|
+
const defaults = {
|
|
67
|
+
organization_id: text(claims.org_id),
|
|
68
|
+
roles: strings(claims.roles ?? claims.role),
|
|
69
|
+
scopes: strings(claims.permissions),
|
|
70
|
+
impersonated: actorPresent(claims.act),
|
|
71
|
+
};
|
|
72
|
+
return base("workos", claims, { ...defaults, ...overrides });
|
|
73
|
+
}
|
|
74
|
+
/** Map verified Clerk session claims. Pass Session.createdAt as session_created_at. */
|
|
75
|
+
export function fromClerk(claims, overrides = {}) {
|
|
76
|
+
const org = object(claims.o);
|
|
77
|
+
const secondFactorAgeMinutes = Array.isArray(claims.fva) && typeof claims.fva[1] === "number" && Number.isFinite(claims.fva[1]) ? claims.fva[1] : undefined;
|
|
78
|
+
const mfa = secondFactorAgeMinutes !== undefined && secondFactorAgeMinutes >= 0
|
|
79
|
+
? { present: true, age_seconds: Math.trunc(secondFactorAgeMinutes * 60) }
|
|
80
|
+
: undefined;
|
|
81
|
+
const defaults = {
|
|
82
|
+
organization_id: text(org?.id) ?? text(claims.org_id),
|
|
83
|
+
// Clerk's role claim is one role slug, never a list.
|
|
84
|
+
roles: bounded([org?.rol], 32, 64) ?? bounded([claims.org_role], 32, 64),
|
|
85
|
+
scopes: delimitedStrings(org?.per) ?? delimitedStrings(claims.org_permissions),
|
|
86
|
+
impersonated: actorPresent(claims.act),
|
|
87
|
+
...(mfa ? { mfa } : {}),
|
|
88
|
+
};
|
|
89
|
+
// iat is a 60-second token refresh clock, so it is not sent as issued_at; session age is the session_created_at override.
|
|
90
|
+
return base("clerk", claims, { ...defaults, ...overrides }, { includeIssuedAt: false });
|
|
91
|
+
}
|
|
92
|
+
/** Map verified Auth0 ID-token, userinfo, or normalized session claims. Do not pass an opaque API access token. */
|
|
93
|
+
export function fromAuth0(claims, overrides = {}) {
|
|
94
|
+
const amr = strings(claims.amr, 8, 32);
|
|
95
|
+
const mfaMethods = amr?.filter(method => method.toLowerCase() !== "pwd");
|
|
96
|
+
const defaults = {
|
|
97
|
+
organization_id: text(claims.org_id),
|
|
98
|
+
scopes: strings(claims.scope) ?? strings(claims.permissions),
|
|
99
|
+
email_verified: typeof claims.email_verified === "boolean" ? claims.email_verified : undefined,
|
|
100
|
+
phone_verified: typeof claims.phone_number_verified === "boolean" ? claims.phone_number_verified : undefined,
|
|
101
|
+
impersonated: actorPresent(claims.act),
|
|
102
|
+
...(mfaMethods?.length ? { mfa: { present: amr?.some(method => method.toLowerCase() === "mfa") ?? false, methods: mfaMethods } } : {}),
|
|
103
|
+
};
|
|
104
|
+
return base("auth0", claims, { ...defaults, ...overrides });
|
|
105
|
+
}
|
|
106
|
+
/** Generic OIDC adapter for providers without a first-class helper. */
|
|
107
|
+
export function fromOIDC(provider, claims, overrides = {}) {
|
|
108
|
+
if (!/^[a-z0-9][a-z0-9._-]{1,31}$/.test(provider))
|
|
109
|
+
throw new Error("provider must be a lowercase provider slug");
|
|
110
|
+
return base(provider, claims, overrides);
|
|
111
|
+
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
export type AssessmentRequest = {
|
|
2
|
+
account_id: string;
|
|
3
|
+
identifiers: AssessmentRequestIdentifiers;
|
|
4
|
+
policy_context?: AssessmentRequestPolicyContext;
|
|
5
|
+
request_id?: string;
|
|
6
|
+
deadline_ms?: number;
|
|
7
|
+
response_mode?: AssessmentRequestResponseMode;
|
|
8
|
+
client_context?: AssessmentRequestClientContext;
|
|
9
|
+
auth_context?: AssessmentRequestAuthContext;
|
|
10
|
+
};
|
|
11
|
+
export type AssessmentRequestIdentifiers = {
|
|
12
|
+
email?: string;
|
|
13
|
+
username?: string;
|
|
14
|
+
phone?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
ip?: string;
|
|
17
|
+
};
|
|
18
|
+
export type AssessmentRequestPolicyContext = {
|
|
19
|
+
flow?: AssessmentRequestPolicyContextFlow;
|
|
20
|
+
region?: string;
|
|
21
|
+
};
|
|
22
|
+
export type AssessmentRequestPolicyContextFlow = "signup" | "login" | "recovery" | "profile_change";
|
|
23
|
+
export type AssessmentRequestResponseMode = "standard" | "detailed";
|
|
24
|
+
export type AssessmentRequestClientContext = {
|
|
25
|
+
timezone?: string;
|
|
26
|
+
locale?: string;
|
|
27
|
+
platform?: AssessmentRequestClientContextPlatform;
|
|
28
|
+
app_version?: string;
|
|
29
|
+
user_agent?: string;
|
|
30
|
+
device_id?: string;
|
|
31
|
+
session_id?: string;
|
|
32
|
+
form_duration_ms?: number;
|
|
33
|
+
client_observed_at?: string;
|
|
34
|
+
};
|
|
35
|
+
export type AssessmentRequestClientContextPlatform = "web" | "ios" | "android" | "other";
|
|
36
|
+
export type AssessmentRequestAuthContext = {
|
|
37
|
+
provider: string;
|
|
38
|
+
issuer: string;
|
|
39
|
+
audience?: string;
|
|
40
|
+
audiences?: string[];
|
|
41
|
+
subject: string;
|
|
42
|
+
session_id?: string;
|
|
43
|
+
organization_id?: string;
|
|
44
|
+
tenant_id?: string;
|
|
45
|
+
token_id?: string;
|
|
46
|
+
issued_at?: string;
|
|
47
|
+
expires_at?: string;
|
|
48
|
+
session_created_at?: string;
|
|
49
|
+
auth_time?: string;
|
|
50
|
+
account_created_at?: string;
|
|
51
|
+
email_verified?: boolean;
|
|
52
|
+
phone_verified?: boolean;
|
|
53
|
+
assurance_level?: AssessmentRequestAuthContextAssuranceLevel;
|
|
54
|
+
impersonated?: boolean;
|
|
55
|
+
transport?: AssessmentRequestAuthContextTransport;
|
|
56
|
+
verified: boolean;
|
|
57
|
+
mfa?: AssessmentRequestAuthContextMfa;
|
|
58
|
+
roles?: string[];
|
|
59
|
+
scopes?: string[];
|
|
60
|
+
};
|
|
61
|
+
export type AssessmentRequestAuthContextAssuranceLevel = "unknown" | "low" | "medium" | "high";
|
|
62
|
+
export type AssessmentRequestAuthContextTransport = "backend" | "browser";
|
|
63
|
+
export type AssessmentRequestAuthContextMfa = {
|
|
64
|
+
present?: boolean;
|
|
65
|
+
methods?: string[];
|
|
66
|
+
age_seconds?: number;
|
|
67
|
+
};
|
|
68
|
+
export type Assessment = {
|
|
69
|
+
schema_version: "1";
|
|
70
|
+
assessment_id: string;
|
|
71
|
+
account_id: string;
|
|
72
|
+
request_id?: string;
|
|
73
|
+
status: Status;
|
|
74
|
+
recommendation?: Recommendation;
|
|
75
|
+
confidence: Confidence;
|
|
76
|
+
risk?: Risk;
|
|
77
|
+
signals?: Signal[];
|
|
78
|
+
incomplete_sources: IncompleteSource[];
|
|
79
|
+
policy_version: string;
|
|
80
|
+
policy_basis: "heuristic_unvalidated";
|
|
81
|
+
assessment_version: number;
|
|
82
|
+
created_at: string;
|
|
83
|
+
updated_at: string;
|
|
84
|
+
expires_at: string;
|
|
85
|
+
assessment_url?: string;
|
|
86
|
+
timing: AssessmentTiming;
|
|
87
|
+
};
|
|
88
|
+
export type Status = "complete" | "partial" | "pending";
|
|
89
|
+
export type Recommendation = "allow" | "step_up" | "review";
|
|
90
|
+
export type Confidence = "low" | "medium" | "high" | "unavailable";
|
|
91
|
+
export type Risk = {
|
|
92
|
+
score: number;
|
|
93
|
+
band: RiskBand;
|
|
94
|
+
recommendation: Recommendation;
|
|
95
|
+
confidence: RiskConfidence;
|
|
96
|
+
policy_version: string;
|
|
97
|
+
policy_basis: "heuristic_unvalidated";
|
|
98
|
+
reasons: RiskReason[];
|
|
99
|
+
summary?: RiskSummary;
|
|
100
|
+
coverage: RiskCoverage;
|
|
101
|
+
details?: RiskDetails;
|
|
102
|
+
};
|
|
103
|
+
export type RiskBand = "low" | "medium" | "high" | "critical";
|
|
104
|
+
export type RiskConfidence = "low" | "medium" | "high";
|
|
105
|
+
export type RiskReason = {
|
|
106
|
+
code: ReasonCode;
|
|
107
|
+
weight: number;
|
|
108
|
+
identifier?: ReasonIdentifier;
|
|
109
|
+
};
|
|
110
|
+
export type ReasonCode = "no_digital_footprint" | "voip_number" | "disposable_email" | "new_email" | "spam_reports" | "fraud_flag" | "identity_mismatch" | "country_mismatch" | "proxy_ip" | "seen_before" | "shared_ip" | "many_recent_signups" | "established_accounts" | "aged_identity" | "breach_name_match" | "breach_cooccurrence" | "breach_name_mismatch" | "breach_phone_mismatch" | "recent_password_exposure" | "credential_list_exposure" | "abuse_ecosystem_member" | "no_breach_history" | "automation_fast_submit" | "client_clock_skew" | "bot_or_automation" | "auth_email_verified" | "auth_phone_verified" | "auth_mfa_recent" | "auth_new_session" | "auth_new_account" | "auth_impersonated" | "context_timezone_mismatch" | "context_locale_mismatch" | "context_line_country_mismatch" | "prior_abuse_link";
|
|
111
|
+
export type ReasonIdentifier = "email" | "username" | "phone" | "name" | "ip" | "context";
|
|
112
|
+
export type RiskSummary = {
|
|
113
|
+
phone?: RiskSummaryPhone;
|
|
114
|
+
email?: RiskSummaryEmail;
|
|
115
|
+
username?: RiskSummaryUsername;
|
|
116
|
+
ip?: IpSummary;
|
|
117
|
+
consistency?: Consistency;
|
|
118
|
+
};
|
|
119
|
+
export type RiskSummaryPhone = {
|
|
120
|
+
line_type?: RiskSummaryPhoneLineType;
|
|
121
|
+
country?: string;
|
|
122
|
+
report_count?: number;
|
|
123
|
+
carrier?: string;
|
|
124
|
+
};
|
|
125
|
+
export type RiskSummaryPhoneLineType = "mobile" | "voip" | "landline" | "toll_free" | "other";
|
|
126
|
+
export type RiskSummaryEmail = {
|
|
127
|
+
disposable?: boolean;
|
|
128
|
+
accounts_found?: number;
|
|
129
|
+
breach?: BreachSummary;
|
|
130
|
+
};
|
|
131
|
+
export type BreachSummary = {
|
|
132
|
+
found: boolean;
|
|
133
|
+
breach_count?: number;
|
|
134
|
+
first_year?: number;
|
|
135
|
+
last_year?: number;
|
|
136
|
+
exposed?: BreachExposed[];
|
|
137
|
+
in_credential_lists?: boolean;
|
|
138
|
+
recent_password_exposure?: boolean;
|
|
139
|
+
truncated?: boolean;
|
|
140
|
+
};
|
|
141
|
+
export type BreachExposed = "email" | "username" | "name" | "password" | "password_hash" | "phone" | "address" | "dob" | "ip" | "payment" | "security_qa";
|
|
142
|
+
export type RiskSummaryUsername = {
|
|
143
|
+
accounts_found?: number;
|
|
144
|
+
breach?: BreachSummary;
|
|
145
|
+
};
|
|
146
|
+
export type IpSummary = {
|
|
147
|
+
country?: string;
|
|
148
|
+
type?: IpSummaryType;
|
|
149
|
+
seen_in_tenant?: number;
|
|
150
|
+
};
|
|
151
|
+
export type IpSummaryType = "residential" | "hosting" | "vpn" | "proxy" | "tor" | "mobile" | "unknown";
|
|
152
|
+
export type Consistency = {
|
|
153
|
+
name?: ConsistencyValue;
|
|
154
|
+
phone?: ConsistencyValue;
|
|
155
|
+
ip?: ConsistencyValue;
|
|
156
|
+
country?: ConsistencyCountry;
|
|
157
|
+
};
|
|
158
|
+
export type ConsistencyValue = "match" | "partial" | "mismatch" | "unknown";
|
|
159
|
+
export type ConsistencyCountry = "consistent" | "mismatch" | "unknown";
|
|
160
|
+
export type RiskCoverage = {
|
|
161
|
+
answered: number;
|
|
162
|
+
failed: number;
|
|
163
|
+
pending: number;
|
|
164
|
+
};
|
|
165
|
+
export type RiskDetails = {
|
|
166
|
+
phone_names?: RiskDetailsPhoneName[];
|
|
167
|
+
breaches?: Breach[];
|
|
168
|
+
breach_names?: RiskDetailsBreachName[];
|
|
169
|
+
};
|
|
170
|
+
export type RiskDetailsPhoneName = {
|
|
171
|
+
value: string;
|
|
172
|
+
seen_by: number;
|
|
173
|
+
};
|
|
174
|
+
export type Breach = {
|
|
175
|
+
name: string;
|
|
176
|
+
domain?: string;
|
|
177
|
+
category?: string;
|
|
178
|
+
kind: BreachKind;
|
|
179
|
+
year?: number;
|
|
180
|
+
month?: number;
|
|
181
|
+
matched_on: BreachSelector;
|
|
182
|
+
exposed?: BreachExposed[];
|
|
183
|
+
};
|
|
184
|
+
export type BreachKind = "site_breach" | "credential_list" | "stealer_log" | "scrape" | "hacking_forum" | "abuse_service" | "darkweb_site";
|
|
185
|
+
export type BreachSelector = "email" | "username" | "ip";
|
|
186
|
+
export type RiskDetailsBreachName = {
|
|
187
|
+
value: string;
|
|
188
|
+
seen_in: number;
|
|
189
|
+
};
|
|
190
|
+
export type Signal = {
|
|
191
|
+
type: string;
|
|
192
|
+
identifier: IdentifierKind;
|
|
193
|
+
outcome: SignalOutcome;
|
|
194
|
+
source_id: string;
|
|
195
|
+
reason?: FailureReason;
|
|
196
|
+
evidence_ref?: string;
|
|
197
|
+
observed_at?: string;
|
|
198
|
+
last_checked_at?: string;
|
|
199
|
+
freshness: Freshness;
|
|
200
|
+
enrichment?: PhoneEnrichment;
|
|
201
|
+
};
|
|
202
|
+
export type IdentifierKind = "email" | "username" | "phone" | "ip";
|
|
203
|
+
export type SignalOutcome = "found" | "not_found" | "inconclusive" | "blocked" | "unavailable";
|
|
204
|
+
export type FailureReason = "timed_out" | "rate_limited" | "blocked" | "source_error" | "unavailable" | "deferred" | "insufficient_evidence";
|
|
205
|
+
export type Freshness = "fresh" | "stale" | "unknown";
|
|
206
|
+
export type PhoneEnrichment = {
|
|
207
|
+
fields: PhoneEnrichmentFields;
|
|
208
|
+
};
|
|
209
|
+
export type PhoneEnrichmentFields = {
|
|
210
|
+
phone?: string;
|
|
211
|
+
name?: string;
|
|
212
|
+
carrier?: string;
|
|
213
|
+
line_type?: string;
|
|
214
|
+
entity_type?: string;
|
|
215
|
+
country_code?: string;
|
|
216
|
+
country?: string;
|
|
217
|
+
state?: string;
|
|
218
|
+
city?: string;
|
|
219
|
+
location?: string;
|
|
220
|
+
national_format?: string;
|
|
221
|
+
job_title?: string;
|
|
222
|
+
company_name?: string;
|
|
223
|
+
email?: string;
|
|
224
|
+
website?: string;
|
|
225
|
+
first_call_at?: string;
|
|
226
|
+
last_call_at?: string;
|
|
227
|
+
matched_name?: string;
|
|
228
|
+
alternate_names?: Array<string | number | boolean | Record<string, unknown> | unknown[]>;
|
|
229
|
+
name_candidates?: Array<string | number | boolean | Record<string, unknown> | unknown[]>;
|
|
230
|
+
timezones?: Array<string | number | boolean | Record<string, unknown> | unknown[]>;
|
|
231
|
+
emails?: Array<string | number | boolean | Record<string, unknown> | unknown[]>;
|
|
232
|
+
websites?: Array<string | number | boolean | Record<string, unknown> | unknown[]>;
|
|
233
|
+
locations?: Array<string | number | boolean | Record<string, unknown> | unknown[]>;
|
|
234
|
+
social_profiles?: Array<string | number | boolean | Record<string, unknown> | unknown[]>;
|
|
235
|
+
report_count?: number;
|
|
236
|
+
tag_count?: number;
|
|
237
|
+
total_calls?: number;
|
|
238
|
+
calls_60_days?: number;
|
|
239
|
+
reports_60_days?: number;
|
|
240
|
+
searches_60_days?: number;
|
|
241
|
+
comment_count?: number;
|
|
242
|
+
names_count?: number;
|
|
243
|
+
spam_report_count?: number;
|
|
244
|
+
};
|
|
245
|
+
export type IncompleteSource = {
|
|
246
|
+
lane: Lane;
|
|
247
|
+
reason: IncompleteReason;
|
|
248
|
+
};
|
|
249
|
+
export type Lane = "accounts" | "phone" | "breach" | "ip";
|
|
250
|
+
export type IncompleteReason = "timed_out" | "rate_limited" | "blocked" | "source_error" | "unavailable" | "deferred";
|
|
251
|
+
export type AssessmentTiming = {
|
|
252
|
+
deadline_ms: number;
|
|
253
|
+
elapsed_ms: number;
|
|
254
|
+
};
|
|
255
|
+
export type AssessmentList = {
|
|
256
|
+
schema_version: "1";
|
|
257
|
+
account_id: string;
|
|
258
|
+
items: Assessment[];
|
|
259
|
+
next_cursor?: string;
|
|
260
|
+
retention_days: number;
|
|
261
|
+
};
|
|
262
|
+
export type WebhookEvent = {
|
|
263
|
+
id: string;
|
|
264
|
+
type: WebhookEventType;
|
|
265
|
+
created_at: string;
|
|
266
|
+
data: unknown;
|
|
267
|
+
};
|
|
268
|
+
export type WebhookEventType = "assessment.updated" | "endpoint.verification";
|
|
269
|
+
export type Problem = {
|
|
270
|
+
type: string;
|
|
271
|
+
title: string;
|
|
272
|
+
status: number;
|
|
273
|
+
detail: string;
|
|
274
|
+
instance?: string;
|
|
275
|
+
code: string;
|
|
276
|
+
request_id: string;
|
|
277
|
+
invalid_params?: ProblemInvalidParam[];
|
|
278
|
+
};
|
|
279
|
+
export type ProblemInvalidParam = {
|
|
280
|
+
field: string;
|
|
281
|
+
reason: string;
|
|
282
|
+
example?: string;
|
|
283
|
+
};
|
|
284
|
+
export type AssessmentQuery = {
|
|
285
|
+
account_id: string;
|
|
286
|
+
limit?: number;
|
|
287
|
+
cursor?: string;
|
|
288
|
+
response_mode?: AssessmentQueryResponseMode;
|
|
289
|
+
};
|
|
290
|
+
export type AssessmentQueryResponseMode = "standard" | "detailed";
|
|
291
|
+
export type WebhookVerificationResponse = {
|
|
292
|
+
challenge: string;
|
|
293
|
+
};
|
|
294
|
+
export type AssessmentOutcomeRequest = {
|
|
295
|
+
outcome: Outcome;
|
|
296
|
+
observed_at?: string;
|
|
297
|
+
external_ref?: string;
|
|
298
|
+
notes?: string;
|
|
299
|
+
};
|
|
300
|
+
export type Outcome = "confirmed_abuse" | "account_takeover" | "chargeback" | "false_positive" | "legitimate" | "unknown";
|
|
301
|
+
export type AssessmentOutcome = {
|
|
302
|
+
id: string;
|
|
303
|
+
assessment_id: string;
|
|
304
|
+
outcome: Outcome;
|
|
305
|
+
received_at: string;
|
|
306
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** Server-side NoResponse signup client. Never expose the API key in browser code. */
|
|
2
|
+
import type { Assessment, AssessmentList, AssessmentOutcome, AssessmentQuery, AssessmentRequest, Outcome } from "./generated/models.js";
|
|
3
|
+
export type * from "./generated/models.js";
|
|
4
|
+
export { verifyWebhook, webhookAssessment, webhookVerificationResponse } from "./webhooks.js";
|
|
5
|
+
export { fromAuth0, fromClerk, fromOIDC, fromWorkOS } from "./auth.js";
|
|
6
|
+
export type ResponseMode = NonNullable<AssessmentRequest["response_mode"]>;
|
|
7
|
+
export type Flow = NonNullable<NonNullable<AssessmentRequest["policy_context"]>["flow"]>;
|
|
8
|
+
export declare class NoResponseError extends Error {
|
|
9
|
+
readonly status: number;
|
|
10
|
+
readonly type?: string | undefined;
|
|
11
|
+
readonly code?: string | undefined;
|
|
12
|
+
readonly detail?: string | undefined;
|
|
13
|
+
readonly requestId?: string;
|
|
14
|
+
readonly retryAfter?: number;
|
|
15
|
+
readonly retryable: boolean;
|
|
16
|
+
constructor(status: number, message: string, type?: string | undefined, code?: string | undefined, detail?: string | undefined, metadata?: {
|
|
17
|
+
requestId?: string;
|
|
18
|
+
retryAfter?: number;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export type NoResponseConfig = {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
fetch?: typeof fetch;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
/** Safe retries for network errors, 429 and 503. POST assessment retries reuse the same Idempotency-Key. */
|
|
27
|
+
maxRetries?: number;
|
|
28
|
+
/** Base delay for a transient retry when Retry-After is absent. */
|
|
29
|
+
retryBaseDelayMs?: number;
|
|
30
|
+
};
|
|
31
|
+
export declare class NoResponse {
|
|
32
|
+
private readonly config;
|
|
33
|
+
private readonly baseUrl;
|
|
34
|
+
constructor(config: NoResponseConfig);
|
|
35
|
+
assess(input: {
|
|
36
|
+
accountId: string;
|
|
37
|
+
email?: string;
|
|
38
|
+
username?: string;
|
|
39
|
+
phone?: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
ip?: string;
|
|
42
|
+
/** Customer event policy. Defaults to signup when omitted. */
|
|
43
|
+
flow?: Flow;
|
|
44
|
+
/** ISO 3166-1 alpha-2 region used for consistency checks. */
|
|
45
|
+
region?: string;
|
|
46
|
+
requestId?: string;
|
|
47
|
+
deadlineMs?: number;
|
|
48
|
+
responseMode?: ResponseMode;
|
|
49
|
+
/** Bounded, tenant-scoped client hints. Raw user agents and opaque IDs are never returned. */
|
|
50
|
+
clientContext?: AssessmentRequest["client_context"];
|
|
51
|
+
/** Normalized claims from a provider-verified backend session. Never pass a raw token. */
|
|
52
|
+
authContext?: AssessmentRequest["auth_context"];
|
|
53
|
+
idempotencyKey: string;
|
|
54
|
+
}): Promise<Assessment>;
|
|
55
|
+
getAssessment(assessmentId: string, options?: {
|
|
56
|
+
responseMode?: ResponseMode;
|
|
57
|
+
}): Promise<Assessment>;
|
|
58
|
+
private getAssessmentWithHeaders;
|
|
59
|
+
waitForAssessment(assessmentId: string, options?: {
|
|
60
|
+
responseMode?: ResponseMode;
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
}): Promise<Assessment>;
|
|
63
|
+
queryAssessments(query: AssessmentQuery & {
|
|
64
|
+
responseMode?: ResponseMode;
|
|
65
|
+
}): Promise<AssessmentList>;
|
|
66
|
+
/**
|
|
67
|
+
* Report what was later learned about an assessed account. confirmed_abuse, account_takeover and
|
|
68
|
+
* chargeback report abuse; false_positive and legitimate withdraw this tenant's earlier report;
|
|
69
|
+
* unknown is recorded only. A retry with the same idempotencyKey and body answers the same record.
|
|
70
|
+
*/
|
|
71
|
+
recordOutcome(assessmentId: string, input: {
|
|
72
|
+
outcome: Outcome;
|
|
73
|
+
/** RFC 3339 time the provider observed the outcome; defaults to when NoResponse receives it. */
|
|
74
|
+
observedAt?: string;
|
|
75
|
+
externalRef?: string;
|
|
76
|
+
notes?: string;
|
|
77
|
+
idempotencyKey: string;
|
|
78
|
+
}): Promise<AssessmentOutcome>;
|
|
79
|
+
private validateMode;
|
|
80
|
+
private request;
|
|
81
|
+
private waitForRetry;
|
|
82
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
export { verifyWebhook, webhookAssessment, webhookVerificationResponse } from "./webhooks.js";
|
|
2
|
+
export { fromAuth0, fromClerk, fromOIDC, fromWorkOS } from "./auth.js";
|
|
3
|
+
const LOOKUP_IDENTIFIERS = ["email", "username", "phone"];
|
|
4
|
+
const MATCH_IDENTIFIERS = ["name", "ip"];
|
|
5
|
+
const IDEMPOTENCY = /^[A-Za-z0-9._:-]{16,128}$/;
|
|
6
|
+
const ASSESSMENT_ID = /^asm_[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
7
|
+
const OUTCOMES = ["confirmed_abuse", "account_takeover", "chargeback", "false_positive", "legitimate", "unknown"];
|
|
8
|
+
const EXTERNAL_REF = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
9
|
+
const RFC3339 = /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?(?:Z|[+-][0-9]{2}:[0-9]{2})$/;
|
|
10
|
+
export class NoResponseError extends Error {
|
|
11
|
+
status;
|
|
12
|
+
type;
|
|
13
|
+
code;
|
|
14
|
+
detail;
|
|
15
|
+
requestId;
|
|
16
|
+
retryAfter;
|
|
17
|
+
retryable;
|
|
18
|
+
constructor(status, message, type, code, detail, metadata = {}) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.type = type;
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.detail = detail;
|
|
24
|
+
this.name = "NoResponseError";
|
|
25
|
+
this.requestId = metadata.requestId;
|
|
26
|
+
this.retryAfter = metadata.retryAfter;
|
|
27
|
+
this.retryable = status === 429 || status === 503;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class NoResponse {
|
|
31
|
+
config;
|
|
32
|
+
baseUrl;
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this.config = config;
|
|
35
|
+
if (!config.apiKey)
|
|
36
|
+
throw new Error("NoResponse API key required");
|
|
37
|
+
if (config.timeoutMs !== undefined && (!Number.isInteger(config.timeoutMs) || config.timeoutMs <= 0)) {
|
|
38
|
+
throw new Error("timeoutMs must be a positive integer");
|
|
39
|
+
}
|
|
40
|
+
if (config.maxRetries !== undefined && (!Number.isInteger(config.maxRetries) || config.maxRetries < 0)) {
|
|
41
|
+
throw new Error("maxRetries must be a non-negative integer");
|
|
42
|
+
}
|
|
43
|
+
if (config.retryBaseDelayMs !== undefined && (!Number.isInteger(config.retryBaseDelayMs) || config.retryBaseDelayMs < 0)) {
|
|
44
|
+
throw new Error("retryBaseDelayMs must be a non-negative integer");
|
|
45
|
+
}
|
|
46
|
+
const url = new URL(config.baseUrl);
|
|
47
|
+
if (url.search || url.hash || /[?#]$/.test(config.baseUrl))
|
|
48
|
+
throw new Error("baseUrl must not include a query or fragment");
|
|
49
|
+
if (url.protocol !== "https:" && url.hostname !== "localhost" && url.hostname !== "127.0.0.1") {
|
|
50
|
+
throw new Error("NoResponse requires HTTPS outside localhost");
|
|
51
|
+
}
|
|
52
|
+
this.baseUrl = url.toString().replace(/\/$/, "");
|
|
53
|
+
}
|
|
54
|
+
async assess(input) {
|
|
55
|
+
const identifiers = {};
|
|
56
|
+
for (const key of LOOKUP_IDENTIFIERS)
|
|
57
|
+
if (input[key] !== undefined)
|
|
58
|
+
identifiers[key] = input[key];
|
|
59
|
+
if (!Object.keys(identifiers).length)
|
|
60
|
+
throw new Error("At least one of email, username or phone required");
|
|
61
|
+
for (const key of MATCH_IDENTIFIERS)
|
|
62
|
+
if (input[key] !== undefined)
|
|
63
|
+
identifiers[key] = input[key];
|
|
64
|
+
if (input.name !== undefined && (input.name.length < 1 || input.name.length > 128))
|
|
65
|
+
throw new Error("name must be 1-128 characters");
|
|
66
|
+
if (!IDEMPOTENCY.test(input.idempotencyKey))
|
|
67
|
+
throw new Error("Valid 16-128 character idempotencyKey required");
|
|
68
|
+
if (input.deadlineMs !== undefined && (!Number.isInteger(input.deadlineMs) || input.deadlineMs < 50 || input.deadlineMs > 500)) {
|
|
69
|
+
throw new Error("deadlineMs must be 50–500");
|
|
70
|
+
}
|
|
71
|
+
if (input.region !== undefined && !/^[A-Z]{2}$/.test(input.region))
|
|
72
|
+
throw new Error("region must be an uppercase ISO alpha-2 code");
|
|
73
|
+
if (input.responseMode !== undefined && input.responseMode !== "standard" && input.responseMode !== "detailed") {
|
|
74
|
+
throw new Error("responseMode must be standard or detailed; raw is never served");
|
|
75
|
+
}
|
|
76
|
+
const body = { account_id: input.accountId, identifiers: identifiers };
|
|
77
|
+
if (input.requestId !== undefined)
|
|
78
|
+
body.request_id = input.requestId;
|
|
79
|
+
if (input.deadlineMs !== undefined)
|
|
80
|
+
body.deadline_ms = input.deadlineMs;
|
|
81
|
+
if (input.flow !== undefined || input.region !== undefined) {
|
|
82
|
+
body.policy_context = { flow: input.flow ?? "signup", ...(input.region !== undefined ? { region: input.region } : {}) };
|
|
83
|
+
}
|
|
84
|
+
if (input.responseMode !== undefined)
|
|
85
|
+
body.response_mode = input.responseMode;
|
|
86
|
+
if (input.clientContext !== undefined)
|
|
87
|
+
body.client_context = input.clientContext;
|
|
88
|
+
if (input.authContext !== undefined)
|
|
89
|
+
body.auth_context = input.authContext;
|
|
90
|
+
return this.request("/v1/assessments", {
|
|
91
|
+
method: "POST", body: JSON.stringify(body), headers: { "Idempotency-Key": input.idempotencyKey },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async getAssessment(assessmentId, options = {}) {
|
|
95
|
+
if (!ASSESSMENT_ID.test(assessmentId))
|
|
96
|
+
throw new Error("Invalid assessment ID");
|
|
97
|
+
this.validateMode(options.responseMode);
|
|
98
|
+
const suffix = options.responseMode ? `?response_mode=${options.responseMode}` : "";
|
|
99
|
+
return this.request(`/v1/assessments/${assessmentId}${suffix}`, { method: "GET" });
|
|
100
|
+
}
|
|
101
|
+
async getAssessmentWithHeaders(assessmentId, options = {}) {
|
|
102
|
+
if (!ASSESSMENT_ID.test(assessmentId))
|
|
103
|
+
throw new Error("Invalid assessment ID");
|
|
104
|
+
this.validateMode(options.responseMode);
|
|
105
|
+
const suffix = options.responseMode ? `?response_mode=${options.responseMode}` : "";
|
|
106
|
+
let retryAfter;
|
|
107
|
+
const assessment = await this.request(`/v1/assessments/${assessmentId}${suffix}`, {
|
|
108
|
+
method: "GET",
|
|
109
|
+
onResponse: (headers) => { retryAfter = parseRetryAfter(headers.get("Retry-After")); },
|
|
110
|
+
});
|
|
111
|
+
return { assessment, retryAfter };
|
|
112
|
+
}
|
|
113
|
+
async waitForAssessment(assessmentId, options = {}) {
|
|
114
|
+
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
115
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0)
|
|
116
|
+
throw new Error("wait timeoutMs must be a positive integer");
|
|
117
|
+
const deadline = Date.now() + timeoutMs;
|
|
118
|
+
for (;;) {
|
|
119
|
+
const { assessment, retryAfter } = await this.getAssessmentWithHeaders(assessmentId, options);
|
|
120
|
+
if (assessment.status !== "pending")
|
|
121
|
+
return assessment;
|
|
122
|
+
const remaining = deadline - Date.now();
|
|
123
|
+
if (remaining <= 0)
|
|
124
|
+
throw new Error("Timed out waiting for assessment");
|
|
125
|
+
const delay = retryAfter === undefined ? 500 : retryAfter * 1000;
|
|
126
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(delay, remaining)));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async queryAssessments(query) {
|
|
130
|
+
if (!query.account_id || (query.limit !== undefined && (!Number.isInteger(query.limit) || query.limit < 1 || query.limit > 50))) {
|
|
131
|
+
throw new Error("Invalid assessment query");
|
|
132
|
+
}
|
|
133
|
+
if (query.responseMode !== undefined && query.response_mode !== undefined)
|
|
134
|
+
throw new Error("Supply only one response mode");
|
|
135
|
+
const mode = query.responseMode ?? query.response_mode;
|
|
136
|
+
this.validateMode(mode);
|
|
137
|
+
const body = { account_id: query.account_id };
|
|
138
|
+
if (query.limit !== undefined)
|
|
139
|
+
body.limit = query.limit;
|
|
140
|
+
if (query.cursor !== undefined)
|
|
141
|
+
body.cursor = query.cursor;
|
|
142
|
+
if (mode !== undefined)
|
|
143
|
+
body.response_mode = mode;
|
|
144
|
+
return this.request("/v1/assessments/query", { method: "POST", body: JSON.stringify(body) });
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Report what was later learned about an assessed account. confirmed_abuse, account_takeover and
|
|
148
|
+
* chargeback report abuse; false_positive and legitimate withdraw this tenant's earlier report;
|
|
149
|
+
* unknown is recorded only. A retry with the same idempotencyKey and body answers the same record.
|
|
150
|
+
*/
|
|
151
|
+
async recordOutcome(assessmentId, input) {
|
|
152
|
+
if (!ASSESSMENT_ID.test(assessmentId))
|
|
153
|
+
throw new Error("Invalid assessment ID");
|
|
154
|
+
if (!OUTCOMES.includes(input.outcome))
|
|
155
|
+
throw new Error(`outcome must be one of ${OUTCOMES.join(", ")}`);
|
|
156
|
+
if (!IDEMPOTENCY.test(input.idempotencyKey))
|
|
157
|
+
throw new Error("Valid 16-128 character idempotencyKey required");
|
|
158
|
+
if (input.observedAt !== undefined && !RFC3339.test(input.observedAt))
|
|
159
|
+
throw new Error("observedAt must be an RFC 3339 time");
|
|
160
|
+
if (input.externalRef !== undefined && !EXTERNAL_REF.test(input.externalRef))
|
|
161
|
+
throw new Error("externalRef must be 1-128 safe characters");
|
|
162
|
+
if (input.notes !== undefined && (input.notes.length < 1 || [...input.notes].length > 500))
|
|
163
|
+
throw new Error("notes must be 1-500 characters");
|
|
164
|
+
const body = { outcome: input.outcome };
|
|
165
|
+
if (input.observedAt !== undefined)
|
|
166
|
+
body.observed_at = input.observedAt;
|
|
167
|
+
if (input.externalRef !== undefined)
|
|
168
|
+
body.external_ref = input.externalRef;
|
|
169
|
+
if (input.notes !== undefined)
|
|
170
|
+
body.notes = input.notes;
|
|
171
|
+
return this.request(`/v1/assessments/${assessmentId}/outcomes`, {
|
|
172
|
+
method: "POST", body: JSON.stringify(body), headers: { "Idempotency-Key": input.idempotencyKey },
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
validateMode(mode) {
|
|
176
|
+
if (mode !== undefined && mode !== "standard" && mode !== "detailed")
|
|
177
|
+
throw new Error("responseMode must be standard or detailed; raw is never served");
|
|
178
|
+
}
|
|
179
|
+
async request(path, options) {
|
|
180
|
+
const transport = this.config.fetch ?? fetch;
|
|
181
|
+
const maxRetries = this.config.maxRetries ?? 2;
|
|
182
|
+
const baseDelay = this.config.retryBaseDelayMs ?? 100;
|
|
183
|
+
let lastError;
|
|
184
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
185
|
+
let response;
|
|
186
|
+
try {
|
|
187
|
+
response = await transport(this.baseUrl + path, {
|
|
188
|
+
method: options.method,
|
|
189
|
+
headers: {
|
|
190
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
191
|
+
Accept: "application/json",
|
|
192
|
+
...(options.body ? { "Content-Type": "application/json" } : {}),
|
|
193
|
+
...options.headers,
|
|
194
|
+
},
|
|
195
|
+
body: options.body,
|
|
196
|
+
signal: AbortSignal.timeout(this.config.timeoutMs ?? 5000),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
lastError = error;
|
|
201
|
+
if (attempt >= maxRetries)
|
|
202
|
+
throw error;
|
|
203
|
+
await this.waitForRetry(attempt, undefined, baseDelay);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (!response.ok) {
|
|
207
|
+
let problem = {};
|
|
208
|
+
try {
|
|
209
|
+
const parsed = await response.json();
|
|
210
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
211
|
+
const body = parsed;
|
|
212
|
+
problem = {
|
|
213
|
+
...(typeof body.type === "string" ? { type: body.type } : {}),
|
|
214
|
+
...(typeof body.code === "string" ? { code: body.code } : {}),
|
|
215
|
+
...(typeof body.detail === "string" ? { detail: body.detail } : {}),
|
|
216
|
+
...(typeof body.request_id === "string" ? { request_id: body.request_id } : {}),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch { /* preserve the typed error for malformed bodies */ }
|
|
221
|
+
const retryAfter = parseRetryAfter(response.headers.get("Retry-After"));
|
|
222
|
+
const error = new NoResponseError(response.status, `NoResponse request failed (HTTP ${response.status})`, problem.type, problem.code, problem.detail, { requestId: problem.request_id ?? response.headers.get("X-Request-ID") ?? undefined, retryAfter });
|
|
223
|
+
lastError = error;
|
|
224
|
+
if (attempt < maxRetries && error.retryable) {
|
|
225
|
+
await this.waitForRetry(attempt, retryAfter, baseDelay);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
throw error;
|
|
229
|
+
}
|
|
230
|
+
options.onResponse?.(response.headers);
|
|
231
|
+
return response.json();
|
|
232
|
+
}
|
|
233
|
+
throw lastError instanceof Error ? lastError : new Error("NoResponse request failed");
|
|
234
|
+
}
|
|
235
|
+
async waitForRetry(attempt, retryAfter, baseDelay) {
|
|
236
|
+
const delay = retryAfter !== undefined ? retryAfter * 1000 : baseDelay * (2 ** Math.min(attempt, 6));
|
|
237
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function parseRetryAfter(value) {
|
|
241
|
+
if (!value || !/^[1-9][0-9]{0,3}$/.test(value))
|
|
242
|
+
return undefined;
|
|
243
|
+
return Number(value);
|
|
244
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Assessment, WebhookEvent } from "./generated/models.js";
|
|
2
|
+
/**
|
|
3
|
+
* Verify a delivery against the raw request bytes and return the typed event.
|
|
4
|
+
* Header pairs retain duplicates, so a repeated or case-variant header is refused.
|
|
5
|
+
* For assessment.updated, `data` is the assessment exactly as GET returns it;
|
|
6
|
+
* webhookAssessment(event) returns it as a typed Assessment.
|
|
7
|
+
*/
|
|
8
|
+
export declare function verifyWebhook(rawBody: Uint8Array, headerPairs: ReadonlyArray<readonly [string, string]>, secrets: Readonly<Record<string, string | Uint8Array>>, nowSeconds?: number): WebhookEvent;
|
|
9
|
+
/**
|
|
10
|
+
* The typed assessment carried by a verified assessment.updated event. Throws for
|
|
11
|
+
* any other event, and for data that is not a full assessment (for example an
|
|
12
|
+
* expiry notice or a pre-v1 pointer payload).
|
|
13
|
+
*/
|
|
14
|
+
export declare function webhookAssessment(event: WebhookEvent): Assessment;
|
|
15
|
+
export declare function webhookVerificationResponse(event: WebhookEvent): {
|
|
16
|
+
challenge: string;
|
|
17
|
+
};
|
package/dist/webhooks.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
const EVENT_TYPES = new Set(["assessment.updated", "endpoint.verification"]);
|
|
3
|
+
function isRecord(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
/** The envelope fields, read from the v1 names (id, type) or the earlier event_id/event_type. */
|
|
7
|
+
function envelope(event) {
|
|
8
|
+
const body = isRecord(event) ? event : {};
|
|
9
|
+
return { id: body.id ?? body.event_id, type: body.type ?? body.event_type, data: body.data };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Verify a delivery against the raw request bytes and return the typed event.
|
|
13
|
+
* Header pairs retain duplicates, so a repeated or case-variant header is refused.
|
|
14
|
+
* For assessment.updated, `data` is the assessment exactly as GET returns it;
|
|
15
|
+
* webhookAssessment(event) returns it as a typed Assessment.
|
|
16
|
+
*/
|
|
17
|
+
export function verifyWebhook(rawBody, headerPairs, secrets, nowSeconds = Math.floor(Date.now() / 1000)) {
|
|
18
|
+
const required = ["nr-webhook-id", "nr-webhook-timestamp", "nr-webhook-key-id", "nr-webhook-signature"];
|
|
19
|
+
const headers = new Map();
|
|
20
|
+
for (const [key, value] of headerPairs) {
|
|
21
|
+
const name = key.toLowerCase();
|
|
22
|
+
if (!required.includes(name))
|
|
23
|
+
continue;
|
|
24
|
+
if (headers.has(name))
|
|
25
|
+
throw new Error("Duplicate webhook header");
|
|
26
|
+
headers.set(name, value);
|
|
27
|
+
}
|
|
28
|
+
if (required.some(name => !headers.get(name)))
|
|
29
|
+
throw new Error("Missing webhook header");
|
|
30
|
+
const timestamp = headers.get("nr-webhook-timestamp");
|
|
31
|
+
if (!/^[0-9]{1,12}$/.test(timestamp) || Math.abs(nowSeconds - Number(timestamp)) > 300) {
|
|
32
|
+
throw new Error("Invalid webhook timestamp");
|
|
33
|
+
}
|
|
34
|
+
const keyId = headers.get("nr-webhook-key-id");
|
|
35
|
+
if (!/^whk_[A-Za-z0-9]{8,64}$/.test(keyId) || !Object.prototype.hasOwnProperty.call(secrets, keyId)) {
|
|
36
|
+
throw new Error("Unknown webhook key");
|
|
37
|
+
}
|
|
38
|
+
const signature = headers.get("nr-webhook-signature");
|
|
39
|
+
if (!/^v1=[0-9a-f]{64}$/.test(signature))
|
|
40
|
+
throw new Error("Malformed webhook signature");
|
|
41
|
+
const expected = createHmac("sha256", secrets[keyId]).update(timestamp).update(".").update(rawBody).digest();
|
|
42
|
+
if (!timingSafeEqual(expected, Buffer.from(signature.slice(3), "hex")))
|
|
43
|
+
throw new Error("Invalid webhook signature");
|
|
44
|
+
let event;
|
|
45
|
+
try {
|
|
46
|
+
event = JSON.parse(Buffer.from(rawBody).toString("utf8"));
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new Error("Invalid webhook JSON");
|
|
50
|
+
}
|
|
51
|
+
const { id, type } = envelope(event);
|
|
52
|
+
if (!isRecord(event) || id !== headers.get("nr-webhook-id")) {
|
|
53
|
+
throw new Error("Webhook event ID mismatch");
|
|
54
|
+
}
|
|
55
|
+
if (typeof type !== "string" || !EVENT_TYPES.has(type)) {
|
|
56
|
+
throw new Error("Unknown webhook event");
|
|
57
|
+
}
|
|
58
|
+
return event;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The typed assessment carried by a verified assessment.updated event. Throws for
|
|
62
|
+
* any other event, and for data that is not a full assessment (for example an
|
|
63
|
+
* expiry notice or a pre-v1 pointer payload).
|
|
64
|
+
*/
|
|
65
|
+
export function webhookAssessment(event) {
|
|
66
|
+
const { type, data } = envelope(event);
|
|
67
|
+
if (type !== "assessment.updated")
|
|
68
|
+
throw new Error("Not an assessment event");
|
|
69
|
+
if (!isRecord(data) ||
|
|
70
|
+
typeof data.assessment_id !== "string" ||
|
|
71
|
+
typeof data.assessment_version !== "number" ||
|
|
72
|
+
typeof data.status !== "string" ||
|
|
73
|
+
typeof data.created_at !== "string" ||
|
|
74
|
+
!Array.isArray(data.incomplete_sources) ||
|
|
75
|
+
!isRecord(data.timing)) {
|
|
76
|
+
throw new Error("Webhook data is not a full assessment");
|
|
77
|
+
}
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
export function webhookVerificationResponse(event) {
|
|
81
|
+
const { type, data } = envelope(event);
|
|
82
|
+
const challenge = isRecord(data) ? data.challenge : undefined;
|
|
83
|
+
if (type !== "endpoint.verification" || typeof challenge !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(challenge)) {
|
|
84
|
+
throw new Error("Invalid endpoint verification event");
|
|
85
|
+
}
|
|
86
|
+
return { challenge };
|
|
87
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@noresponse/node",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Server-only NoResponse signup and webhook SDK",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/noresponsehq/noresponse.git",
|
|
10
|
+
"directory": "apps/identity-intelligence/sdks/typescript"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc --project tsconfig.json",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"test": "npm run build && tsc --project tests/tsconfig.json && node --test tests/*.test.mjs"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "5.9.3",
|
|
33
|
+
"@types/node": "22.15.30"
|
|
34
|
+
}
|
|
35
|
+
}
|