@noresponse/node 2.0.10 → 2.0.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.11
4
+
5
+ No changes detected.
6
+
3
7
  ## 2.0.10
4
8
 
5
9
  No changes detected.
package/README.md CHANGED
@@ -201,6 +201,19 @@ async function handler(req, res) {
201
201
 
202
202
  `constructEvent(payload, headers, secrets, { toleranceSeconds })` takes the raw body (a `Buffer`, `Uint8Array` or the exact text), any header object (Fetch `Headers`, Node `IncomingHttpHeaders`, a plain object or entries) and refuses a repeated signature header, a delivery older than 300 seconds, an unknown key id or a bad signature with a `WebhookVerificationError` whose `code` says which. Deliveries are at least once: deduplicate on `event.id`. The same functions are on `NoResponse.webhooks` and `nr.webhooks`. This module uses `node:crypto`.
203
203
 
204
+ ### Late results
205
+
206
+ An assessment can be revised after you allowed the signup. `handleLateResult` verifies the delivery with `constructEvent`, applies your policy and acts through your auth provider's admin API:
207
+
208
+ ```ts
209
+ import { clerkActions, handleLateResult } from "@noresponse/node"; // or workosActions, auth0Actions
210
+
211
+ const provider = clerkActions({ secretKey: process.env.CLERK_SECRET_KEY! });
212
+ const result = await handleLateResult(rawBody, request.headers, secrets, provider, { policy: { review: "ban" } });
213
+ ```
214
+
215
+ The default policy revokes sessions on `review` and does nothing otherwise. `ban` blocks the user in Clerk and Auth0; WorkOS has no block, so its ban deletes the user permanently. Pass `userId` when the provider's user id is not your `accountId`. A refused provider call throws `ProviderActionError`; answer the webhook with a 5xx so we retry it.
216
+
204
217
  ## Auth adapters
205
218
 
206
219
  Map a session your backend has already verified into `authContext`:
@@ -5,7 +5,8 @@
5
5
  export { NoResponse, Assessments, Keys, DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, type NoResponseOptions, type CreateOptions, type GetOptions, type AssessmentPage, type ResponseMeta, type WithMeta, type WaitOptions, } from "./client.js";
6
6
  export * from "./errors.js";
7
7
  export { constructEvent, verificationResponse, isExpiredEvent, WebhookVerificationError, DEFAULT_TOLERANCE_SECONDS, type WebhookEvent, type AssessmentUpdatedEvent, type AssessmentExpiredEvent, type EndpointVerificationEvent, type AssessmentExpired, type EndpointVerification, type ConstructEventOptions, type HeaderInput, type WebhookSecrets, type WebhookErrorCode, } from "./webhooks.js";
8
- export { fromAuth0, fromClerk, fromCognito, fromEntra, fromFirebase, fromKeycloak, fromOIDC, fromOry, fromOryOAuth2, fromSupabase, fromWorkOS, type VerifiedClaims, type AuthContextOverrides } from "./auth.js";
8
+ export { handleLateResult, lateResultAction, clerkActions, workosActions, auth0Actions, ProviderActionError, DEFAULT_LATE_RESULT_POLICY, type LateResult, type LateResultAction, type LateResultOptions, type LateResultPolicy, type LateResultProvider, type ClerkActionsOptions, type WorkOSActionsOptions, type Auth0ActionsOptions, } from "./late-results.js";
9
+ export { fromAuth0, fromClerk, fromCognito, fromEntra, fromFirebase, fromKeycloak, fromOIDC, fromOry, fromOryOAuth2, fromSupabase, fromWorkOS, type VerifiedClaims, type AuthContextOverrides, } from "./auth.js";
9
10
  export { DEFAULT_WAIT_TIMEOUT_MS, MIN_POLL_INTERVAL_MS } from "./wait.js";
10
11
  export * from "./models/index.js";
11
12
  export type { CreateAssessmentRequest, GetAssessmentRequest, RecordAssessmentOutcomeRequest } from "./models/operations/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,cAA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AK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACjF,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.NoResponseCore = exports.HTTPClient = exports.ServerList = exports.SDK_METADATA = exports.MIN_POLL_INTERVAL_MS = exports.DEFAULT_WAIT_TIMEOUT_MS = exports.fromWorkOS = exports.fromSupabase = exports.fromOryOAuth2 = exports.fromOry = exports.fromOIDC = exports.fromKeycloak = exports.fromFirebase = exports.fromEntra = exports.fromCognito = exports.fromClerk = exports.fromAuth0 = exports.DEFAULT_TOLERANCE_SECONDS = exports.WebhookVerificationError = exports.isExpiredEvent = exports.verificationResponse = exports.constructEvent = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_BASE_URL = exports.Keys = exports.Assessments = exports.NoResponse = void 0;
17
+ exports.NoResponseCore = exports.HTTPClient = exports.ServerList = exports.SDK_METADATA = exports.MIN_POLL_INTERVAL_MS = exports.DEFAULT_WAIT_TIMEOUT_MS = exports.fromWorkOS = exports.fromSupabase = exports.fromOryOAuth2 = exports.fromOry = exports.fromOIDC = exports.fromKeycloak = exports.fromFirebase = exports.fromEntra = exports.fromCognito = exports.fromClerk = exports.fromAuth0 = exports.DEFAULT_LATE_RESULT_POLICY = exports.ProviderActionError = exports.auth0Actions = exports.workosActions = exports.clerkActions = exports.lateResultAction = exports.handleLateResult = exports.DEFAULT_TOLERANCE_SECONDS = exports.WebhookVerificationError = exports.isExpiredEvent = exports.verificationResponse = exports.constructEvent = exports.DEFAULT_TIMEOUT_MS = exports.DEFAULT_BASE_URL = exports.Keys = exports.Assessments = exports.NoResponse = void 0;
18
18
  /**
19
19
  * @noresponse/node entry point. Hand-written (listed in .genignore); the
20
20
  * generated client lives under ./sdk, ./funcs, ./models and ./lib.
@@ -32,6 +32,14 @@ Object.defineProperty(exports, "verificationResponse", { enumerable: true, get:
32
32
  Object.defineProperty(exports, "isExpiredEvent", { enumerable: true, get: function () { return webhooks_js_1.isExpiredEvent; } });
33
33
  Object.defineProperty(exports, "WebhookVerificationError", { enumerable: true, get: function () { return webhooks_js_1.WebhookVerificationError; } });
34
34
  Object.defineProperty(exports, "DEFAULT_TOLERANCE_SECONDS", { enumerable: true, get: function () { return webhooks_js_1.DEFAULT_TOLERANCE_SECONDS; } });
35
+ const late_results_js_1 = require("./late-results.js");
36
+ Object.defineProperty(exports, "handleLateResult", { enumerable: true, get: function () { return late_results_js_1.handleLateResult; } });
37
+ Object.defineProperty(exports, "lateResultAction", { enumerable: true, get: function () { return late_results_js_1.lateResultAction; } });
38
+ Object.defineProperty(exports, "clerkActions", { enumerable: true, get: function () { return late_results_js_1.clerkActions; } });
39
+ Object.defineProperty(exports, "workosActions", { enumerable: true, get: function () { return late_results_js_1.workosActions; } });
40
+ Object.defineProperty(exports, "auth0Actions", { enumerable: true, get: function () { return late_results_js_1.auth0Actions; } });
41
+ Object.defineProperty(exports, "ProviderActionError", { enumerable: true, get: function () { return late_results_js_1.ProviderActionError; } });
42
+ Object.defineProperty(exports, "DEFAULT_LATE_RESULT_POLICY", { enumerable: true, get: function () { return late_results_js_1.DEFAULT_LATE_RESULT_POLICY; } });
35
43
  const auth_js_1 = require("./auth.js");
36
44
  Object.defineProperty(exports, "fromAuth0", { enumerable: true, get: function () { return auth_js_1.fromAuth0; } });
37
45
  Object.defineProperty(exports, "fromClerk", { enumerable: true, get: function () { return auth_js_1.fromClerk; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,2CAaqB;AAZnB,uGAAA,UAAU,OAAA;AACV,wGAAA,WAAW,OAAA;AACX,iGAAA,IAAI,OAAA;AACJ,6GAAA,gBAAgB,OAAA;AAChB,+GAAA,kBAAkB,OAAA;AASpB,8CAA4B;AAC5B,+CAgBuB;AAfrB,6GAAA,cAAc,OAAA;AACd,mHAAA,oBAAoB,OAAA;AACpB,6GAAA,cAAc,OAAA;AACd,uHAAA,wBAAwB,OAAA;AACxB,wHAAA,yBAAyB,OAAA;AAY3B,uCAYoE;AAXlE,oGAAA,SAAS,OAAA;AACT,oGAAA,SAAS,OAAA;AACT,sGAAA,WAAW,OAAA;AACX,oGAAA,SAAS,OAAA;AACT,uGAAA,YAAY,OAAA;AACZ,uGAAA,YAAY,OAAA;AACZ,mGAAA,QAAQ,OAAA;AACR,kGAAA,OAAO,OAAA;AACP,wGAAA,aAAa,OAAA;AACb,uGAAA,YAAY,OAAA;AACZ,qGAAA,UAAU,OAAA;AAEZ,uCAA0E;AAAjE,kHAAA,uBAAuB,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AACtD,oDAAkC;AAElC,+CAA4E;AAAnE,yGAAA,YAAY,OAAA;AAAE,uGAAA,UAAU,OAAA;AACjC,2CAAiF;AAAxE,qGAAA,UAAU,OAAA;AAInB,uCAA2C;AAAlC,yGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,2CAaqB;AAZnB,uGAAA,UAAU,OAAA;AACV,wGAAA,WAAW,OAAA;AACX,iGAAA,IAAI,OAAA;AACJ,6GAAA,gBAAgB,OAAA;AAChB,+GAAA,kBAAkB,OAAA;AASpB,8CAA4B;AAC5B,+CAgBuB;AAfrB,6GAAA,cAAc,OAAA;AACd,mHAAA,oBAAoB,OAAA;AACpB,6GAAA,cAAc,OAAA;AACd,uHAAA,wBAAwB,OAAA;AACxB,wHAAA,yBAAyB,OAAA;AAY3B,uDAgB2B;AAfzB,mHAAA,gBAAgB,OAAA;AAChB,mHAAA,gBAAgB,OAAA;AAChB,+GAAA,YAAY,OAAA;AACZ,gHAAA,aAAa,OAAA;AACb,+GAAA,YAAY,OAAA;AACZ,sHAAA,mBAAmB,OAAA;AACnB,6HAAA,0BAA0B,OAAA;AAU5B,uCAcmB;AAbjB,oGAAA,SAAS,OAAA;AACT,oGAAA,SAAS,OAAA;AACT,sGAAA,WAAW,OAAA;AACX,oGAAA,SAAS,OAAA;AACT,uGAAA,YAAY,OAAA;AACZ,uGAAA,YAAY,OAAA;AACZ,mGAAA,QAAQ,OAAA;AACR,kGAAA,OAAO,OAAA;AACP,wGAAA,aAAa,OAAA;AACb,uGAAA,YAAY,OAAA;AACZ,qGAAA,UAAU,OAAA;AAIZ,uCAA0E;AAAjE,kHAAA,uBAAuB,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AACtD,oDAAkC;AAElC,+CAA4E;AAAnE,yGAAA,YAAY,OAAA;AAAE,uGAAA,UAAU,OAAA;AACjC,2CAAiF;AAAxE,qGAAA,UAAU,OAAA;AAInB,uCAA2C;AAAlC,yGAAA,cAAc,OAAA"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Late-result handlers. Hand-written; not generated.
3
+ *
4
+ * An assessment can be revised after the signup was allowed: a slow source
5
+ * settles and the recommendation rises. NoResponse sends the new version as a
6
+ * signed assessment.updated webhook. handleLateResult verifies that delivery
7
+ * with constructEvent, picks an action from your policy, and acts through the
8
+ * auth provider's admin API: revoke the user's sessions or ban the user.
9
+ *
10
+ * The handler verifies the delivery itself, so it never acts on an unverified
11
+ * event. The provider calls are thin: you pass the credentials, and each
12
+ * action is the provider's documented admin endpoint.
13
+ */
14
+ import { type ConstructEventOptions, type HeaderInput, type WebhookEvent, type WebhookSecrets } from "./webhooks.js";
15
+ /** What to do to the user. "ban" also ends every session. */
16
+ export type LateResultAction = "none" | "revoke_sessions" | "ban";
17
+ /** The action for each recommendation. A recommendation you leave out does nothing. */
18
+ export type LateResultPolicy = Readonly<Partial<Record<"allow" | "step_up" | "review", LateResultAction>>>;
19
+ /** Revoke sessions on review; do nothing on allow or step_up. Banning is opt-in. */
20
+ export declare const DEFAULT_LATE_RESULT_POLICY: LateResultPolicy;
21
+ /** The two admin actions, for one auth provider. Build one with clerkActions, workosActions or auth0Actions. */
22
+ export interface LateResultProvider {
23
+ readonly name: string;
24
+ /** End every active session of the user. */
25
+ revokeSessions(userId: string): Promise<void>;
26
+ /** Stop the user signing in again and end their sessions. */
27
+ ban(userId: string): Promise<void>;
28
+ }
29
+ export type LateResultOptions = ConstructEventOptions & {
30
+ /** Recommendation to action. Defaults to DEFAULT_LATE_RESULT_POLICY. */
31
+ policy?: LateResultPolicy;
32
+ /**
33
+ * The provider user id for the assessment's account_id. Defaults to the
34
+ * account_id itself, as when you assess with the provider's user id.
35
+ * Return null or undefined to take no action.
36
+ */
37
+ userId?: (accountId: string, event: WebhookEvent) => string | null | undefined | Promise<string | null | undefined>;
38
+ };
39
+ export type LateResult = {
40
+ /** The verified event. Answer an endpoint.verification with verificationResponse(event). */
41
+ event: WebhookEvent;
42
+ /** The action taken. "none" when the policy, the event or the user id called for nothing. */
43
+ action: LateResultAction;
44
+ /** The provider user id acted on, when an action was taken. */
45
+ userId?: string;
46
+ };
47
+ /** Thrown when the provider's admin API refuses a call. Answer the webhook with a 5xx so NoResponse retries it. */
48
+ export declare class ProviderActionError extends Error {
49
+ readonly provider: string;
50
+ readonly status: number;
51
+ constructor(provider: string, status: number, message: string);
52
+ }
53
+ /** The action your policy names for a verified event. Only a served assessment with a recommendation can act. */
54
+ export declare function lateResultAction(event: WebhookEvent, policy?: LateResultPolicy): LateResultAction;
55
+ /**
56
+ * Verify a webhook delivery and apply your policy to it.
57
+ *
58
+ * `payload`, `headers`, `secrets` and the tolerance options are exactly what
59
+ * constructEvent takes; a delivery that fails verification throws
60
+ * WebhookVerificationError before any provider call. Deduplicate on
61
+ * `result.event.id` and ignore versions older than one you have acted on.
62
+ */
63
+ export declare function handleLateResult(payload: Uint8Array | string, headers: HeaderInput, secrets: WebhookSecrets, provider: LateResultProvider, options?: LateResultOptions): Promise<LateResult>;
64
+ type Fetch = typeof fetch;
65
+ export type ClerkActionsOptions = {
66
+ /** Clerk secret key (sk_...). */
67
+ secretKey: string;
68
+ /** Default https://api.clerk.com/v1. */
69
+ baseUrl?: string;
70
+ fetch?: Fetch;
71
+ };
72
+ /**
73
+ * Clerk Backend API. revokeSessions lists the user's active sessions
74
+ * (GET /sessions?user_id&status=active) and revokes each
75
+ * (POST /sessions/{id}/revoke). ban is POST /users/{id}/ban, which revokes
76
+ * every session and blocks sign-in.
77
+ */
78
+ export declare function clerkActions(options: ClerkActionsOptions): LateResultProvider;
79
+ export type WorkOSActionsOptions = {
80
+ /** WorkOS API key (sk_...). */
81
+ apiKey: string;
82
+ /** Default https://api.workos.com. */
83
+ baseUrl?: string;
84
+ fetch?: Fetch;
85
+ };
86
+ /**
87
+ * WorkOS User Management. revokeSessions pages through
88
+ * GET /user_management/users/{id}/sessions and revokes each active one with
89
+ * POST /user_management/sessions/revoke. WorkOS has no block or ban, so ban
90
+ * revokes the sessions and then deletes the user
91
+ * (DELETE /user_management/users/{id}); deletion is permanent.
92
+ */
93
+ export declare function workosActions(options: WorkOSActionsOptions): LateResultProvider;
94
+ export type Auth0ActionsOptions = {
95
+ /** Your Auth0 tenant domain, such as example.eu.auth0.com. The Management API is https://{domain}/api/v2. */
96
+ domain?: string;
97
+ /** The Management API base URL in place of domain. */
98
+ baseUrl?: string;
99
+ /** A Management API access token with update:users, delete:sessions and delete:refresh_tokens. */
100
+ token: string;
101
+ fetch?: Fetch;
102
+ };
103
+ /**
104
+ * Auth0 Management API. revokeSessions deletes every session
105
+ * (DELETE /users/{id}/sessions) and refresh token
106
+ * (DELETE /users/{id}/refresh-tokens). ban first sets blocked: true
107
+ * (PATCH /users/{id}), then does the same.
108
+ */
109
+ export declare function auth0Actions(options: Auth0ActionsOptions): LateResultProvider;
110
+ export {};
111
+ //# sourceMappingURL=late-results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"late-results.d.ts","sourceRoot":"","sources":["../../src/late-results.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAErI,6DAA6D;AAC7D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,iBAAiB,GAAG,KAAK,CAAC;AAElE,uFAAuF;AACvF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,SAAS,GAAG,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAE3G,oFAAoF;AACpF,eAAO,MAAM,0BAA0B,EAAE,gBAA+F,CAAC;AAEzI,gHAAgH;AAChH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,6DAA6D;IAC7D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG;IACtD,wEAAwE;IACxE,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACrH,CAAC;AAEF,MAAM,MAAM,UAA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aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,kBAAkB,CA0B/E;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,6GAA6G;IAC7G,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAkB7E"}
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProviderActionError = exports.DEFAULT_LATE_RESULT_POLICY = void 0;
4
+ exports.lateResultAction = lateResultAction;
5
+ exports.handleLateResult = handleLateResult;
6
+ exports.clerkActions = clerkActions;
7
+ exports.workosActions = workosActions;
8
+ exports.auth0Actions = auth0Actions;
9
+ /**
10
+ * Late-result handlers. Hand-written; not generated.
11
+ *
12
+ * An assessment can be revised after the signup was allowed: a slow source
13
+ * settles and the recommendation rises. NoResponse sends the new version as a
14
+ * signed assessment.updated webhook. handleLateResult verifies that delivery
15
+ * with constructEvent, picks an action from your policy, and acts through the
16
+ * auth provider's admin API: revoke the user's sessions or ban the user.
17
+ *
18
+ * The handler verifies the delivery itself, so it never acts on an unverified
19
+ * event. The provider calls are thin: you pass the credentials, and each
20
+ * action is the provider's documented admin endpoint.
21
+ */
22
+ const webhooks_js_1 = require("./webhooks.js");
23
+ /** Revoke sessions on review; do nothing on allow or step_up. Banning is opt-in. */
24
+ exports.DEFAULT_LATE_RESULT_POLICY = Object.freeze({ allow: "none", step_up: "none", review: "revoke_sessions" });
25
+ /** Thrown when the provider's admin API refuses a call. Answer the webhook with a 5xx so NoResponse retries it. */
26
+ class ProviderActionError extends Error {
27
+ provider;
28
+ status;
29
+ constructor(provider, status, message) {
30
+ super(message);
31
+ this.name = "ProviderActionError";
32
+ this.provider = provider;
33
+ this.status = status;
34
+ }
35
+ }
36
+ exports.ProviderActionError = ProviderActionError;
37
+ const ACTIONS = ["none", "revoke_sessions", "ban"];
38
+ /** The action your policy names for a verified event. Only a served assessment with a recommendation can act. */
39
+ function lateResultAction(event, policy = exports.DEFAULT_LATE_RESULT_POLICY) {
40
+ if (event.type !== "assessment.updated" || event.data.status === "expired")
41
+ return "none";
42
+ const data = event.data;
43
+ const recommendation = data.recommendation ?? data.risk?.recommendation;
44
+ if (recommendation !== "allow" && recommendation !== "step_up" && recommendation !== "review")
45
+ return "none";
46
+ const action = Object.prototype.hasOwnProperty.call(policy, recommendation) ? policy[recommendation] : undefined;
47
+ if (action === undefined)
48
+ return "none";
49
+ if (!ACTIONS.includes(action))
50
+ throw new TypeError(`unknown late result action ${String(action)}`);
51
+ return action;
52
+ }
53
+ /**
54
+ * Verify a webhook delivery and apply your policy to it.
55
+ *
56
+ * `payload`, `headers`, `secrets` and the tolerance options are exactly what
57
+ * constructEvent takes; a delivery that fails verification throws
58
+ * WebhookVerificationError before any provider call. Deduplicate on
59
+ * `result.event.id` and ignore versions older than one you have acted on.
60
+ */
61
+ async function handleLateResult(payload, headers, secrets, provider, options = {}) {
62
+ const { policy, userId: resolve, ...verify } = options;
63
+ const event = (0, webhooks_js_1.constructEvent)(payload, headers, secrets, verify);
64
+ const action = lateResultAction(event, policy);
65
+ if (action === "none" || event.type !== "assessment.updated")
66
+ return { event, action: "none" };
67
+ const accountId = event.data.accountId;
68
+ const userId = resolve ? await resolve(accountId, event) : accountId;
69
+ if (userId === null || userId === undefined || userId === "")
70
+ return { event, action: "none" };
71
+ if (action === "ban")
72
+ await provider.ban(userId);
73
+ else
74
+ await provider.revokeSessions(userId);
75
+ return { event, action, userId };
76
+ }
77
+ function caller(name, baseUrl, authorization, fetcher) {
78
+ const base = baseUrl.replace(/\/+$/, "");
79
+ const run = fetcher ?? globalThis.fetch;
80
+ return async ({ method, path, query, body, allow404 }) => {
81
+ const url = new URL(base + path);
82
+ for (const [key, value] of Object.entries(query ?? {}))
83
+ url.searchParams.set(key, value);
84
+ const headers = { authorization, accept: "application/json" };
85
+ if (body !== undefined)
86
+ headers["content-type"] = "application/json";
87
+ const response = await run(url, { method, headers, ...(body !== undefined ? { body: JSON.stringify(body) } : {}) });
88
+ const text = await response.text();
89
+ if (allow404 && response.status === 404)
90
+ return undefined;
91
+ if (!response.ok)
92
+ throw new ProviderActionError(name, response.status, `${name} ${method} ${path} answered ${response.status}`);
93
+ if (!text)
94
+ return undefined;
95
+ try {
96
+ return JSON.parse(text);
97
+ }
98
+ catch {
99
+ return undefined;
100
+ }
101
+ };
102
+ }
103
+ const segment = (id) => {
104
+ if (typeof id !== "string" || id === "")
105
+ throw new TypeError("user id must be a non-empty string");
106
+ return encodeURIComponent(id);
107
+ };
108
+ function sessions(body) {
109
+ if (Array.isArray(body))
110
+ return body;
111
+ const data = body?.data;
112
+ return Array.isArray(data) ? data : [];
113
+ }
114
+ /**
115
+ * Clerk Backend API. revokeSessions lists the user's active sessions
116
+ * (GET /sessions?user_id&status=active) and revokes each
117
+ * (POST /sessions/{id}/revoke). ban is POST /users/{id}/ban, which revokes
118
+ * every session and blocks sign-in.
119
+ */
120
+ function clerkActions(options) {
121
+ if (!options?.secretKey)
122
+ throw new TypeError("clerkActions needs secretKey");
123
+ const call = caller("clerk", options.baseUrl ?? "https://api.clerk.com/v1", `Bearer ${options.secretKey}`, options.fetch);
124
+ const PAGE = 100;
125
+ return {
126
+ name: "clerk",
127
+ async revokeSessions(userId) {
128
+ segment(userId);
129
+ const active = [];
130
+ for (let offset = 0; offset < PAGE * 1000; offset += PAGE) {
131
+ const page = sessions(await call({ method: "GET", path: "/sessions", query: { user_id: userId, status: "active", limit: String(PAGE), offset: String(offset) } }));
132
+ for (const s of page)
133
+ if (s.status === "active" && typeof s.id === "string" && s.id)
134
+ active.push(s.id);
135
+ if (page.length < PAGE)
136
+ break;
137
+ }
138
+ for (const id of active)
139
+ await call({ method: "POST", path: `/sessions/${encodeURIComponent(id)}/revoke` });
140
+ },
141
+ async ban(userId) {
142
+ await call({ method: "POST", path: `/users/${segment(userId)}/ban` });
143
+ },
144
+ };
145
+ }
146
+ /**
147
+ * WorkOS User Management. revokeSessions pages through
148
+ * GET /user_management/users/{id}/sessions and revokes each active one with
149
+ * POST /user_management/sessions/revoke. WorkOS has no block or ban, so ban
150
+ * revokes the sessions and then deletes the user
151
+ * (DELETE /user_management/users/{id}); deletion is permanent.
152
+ */
153
+ function workosActions(options) {
154
+ if (!options?.apiKey)
155
+ throw new TypeError("workosActions needs apiKey");
156
+ const call = caller("workos", options.baseUrl ?? "https://api.workos.com", `Bearer ${options.apiKey}`, options.fetch);
157
+ const revokeSessions = async (userId) => {
158
+ const user = segment(userId);
159
+ const active = [];
160
+ let after;
161
+ for (let round = 0; round < 1000; round++) {
162
+ const query = { limit: "100" };
163
+ if (after)
164
+ query["after"] = after;
165
+ const body = (await call({ method: "GET", path: `/user_management/users/${user}/sessions`, query }));
166
+ for (const s of sessions(body))
167
+ if (s.status === "active" && typeof s.id === "string" && s.id)
168
+ active.push(s.id);
169
+ const next = body?.list_metadata?.after;
170
+ if (typeof next !== "string" || next === "")
171
+ break;
172
+ after = next;
173
+ }
174
+ for (const id of active)
175
+ await call({ method: "POST", path: "/user_management/sessions/revoke", body: { session_id: id } });
176
+ };
177
+ return {
178
+ name: "workos",
179
+ revokeSessions,
180
+ async ban(userId) {
181
+ await revokeSessions(userId);
182
+ await call({ method: "DELETE", path: `/user_management/users/${segment(userId)}`, allow404: true });
183
+ },
184
+ };
185
+ }
186
+ /**
187
+ * Auth0 Management API. revokeSessions deletes every session
188
+ * (DELETE /users/{id}/sessions) and refresh token
189
+ * (DELETE /users/{id}/refresh-tokens). ban first sets blocked: true
190
+ * (PATCH /users/{id}), then does the same.
191
+ */
192
+ function auth0Actions(options) {
193
+ if (!options?.token)
194
+ throw new TypeError("auth0Actions needs token");
195
+ const base = options.baseUrl ?? (options.domain ? `https://${options.domain}/api/v2` : undefined);
196
+ if (!base)
197
+ throw new TypeError("auth0Actions needs domain or baseUrl");
198
+ const call = caller("auth0", base, `Bearer ${options.token}`, options.fetch);
199
+ const revokeSessions = async (userId) => {
200
+ const user = segment(userId);
201
+ await call({ method: "DELETE", path: `/users/${user}/sessions` });
202
+ await call({ method: "DELETE", path: `/users/${user}/refresh-tokens` });
203
+ };
204
+ return {
205
+ name: "auth0",
206
+ revokeSessions,
207
+ async ban(userId) {
208
+ await call({ method: "PATCH", path: `/users/${segment(userId)}`, body: { blocked: true } });
209
+ await revokeSessions(userId);
210
+ },
211
+ };
212
+ }
213
+ //# sourceMappingURL=late-results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"late-results.js","sourceRoot":"","sources":["../../src/late-results.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,+CAAqI;AAQrI,oFAAoF;AACvE,QAAA,0BAA0B,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;AA+BzI,mHAAmH;AACnH,yBAAiC,SAAQ,KAAK;IACnC,QAAQ,CAAS;IACjB,MAAM,CAAS;IACxB,YAAY,QAAgB,EAAE,MAAc,EAAE,OAAe,EAAE;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAAA,CACtB;CACF;;AAED,MAAM,OAAO,GAAsB,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAC;AAEtE,iHAAiH;AACjH,0BAAiC,KAAmB,EAAE,MAAM,GAAqB,QAAA,0BAA0B,EAAoB;IAC7H,IAAI,KAAK,CAAC,IAAI,KAAK,oBAAoB,IAA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vE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,OAAO,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,cAAc,GAAG,KAAK,EAAE,MAAc,EAAiB,EAAE,CAAC;QAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,IAAI,WAAW,EAAE,CAAC,CAAC;QAClE,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,IAAI,iBAAiB,EAAE,CAAC,CAAC;IAAA,CACzE,CAAC;IACF,OAAO;QACL,IAAI,EAAE,OAAO;QACb,cAAc;QACd,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YAC5F,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;QAAA,CAC9B;KACF,CAAC;AAAA,CACH"}
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
31
31
  export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "1";
34
- readonly sdkVersion: "2.0.10";
34
+ readonly sdkVersion: "2.0.11";
35
35
  readonly genVersion: "internal";
36
- readonly userAgent: "noresponse-sdk/typescript 2.0.10 internal 1 @noresponse/node";
36
+ readonly userAgent: "noresponse-sdk/typescript 2.0.11 internal 1 @noresponse/node";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -28,8 +28,8 @@ function serverURLFromOptions(options) {
28
28
  exports.SDK_METADATA = {
29
29
  language: "typescript",
30
30
  openapiDocVersion: "1",
31
- sdkVersion: "2.0.10",
31
+ sdkVersion: "2.0.11",
32
32
  genVersion: "internal",
33
- userAgent: "noresponse-sdk/typescript 2.0.10 internal 1 @noresponse/node",
33
+ userAgent: "noresponse-sdk/typescript 2.0.11 internal 1 @noresponse/node",
34
34
  };
35
35
  //# sourceMappingURL=config.js.map
@@ -5,7 +5,8 @@
5
5
  export { NoResponse, Assessments, Keys, DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, type NoResponseOptions, type CreateOptions, type GetOptions, type AssessmentPage, type ResponseMeta, type WithMeta, type WaitOptions, } from "./client.js";
6
6
  export * from "./errors.js";
7
7
  export { constructEvent, verificationResponse, isExpiredEvent, WebhookVerificationError, DEFAULT_TOLERANCE_SECONDS, type WebhookEvent, type AssessmentUpdatedEvent, type AssessmentExpiredEvent, type EndpointVerificationEvent, type AssessmentExpired, type EndpointVerification, type ConstructEventOptions, type HeaderInput, type WebhookSecrets, type WebhookErrorCode, } from "./webhooks.js";
8
- export { fromAuth0, fromClerk, fromCognito, fromEntra, fromFirebase, fromKeycloak, fromOIDC, fromOry, fromOryOAuth2, fromSupabase, fromWorkOS, type VerifiedClaims, type AuthContextOverrides } from "./auth.js";
8
+ export { handleLateResult, lateResultAction, clerkActions, workosActions, auth0Actions, ProviderActionError, DEFAULT_LATE_RESULT_POLICY, type LateResult, type LateResultAction, type LateResultOptions, type LateResultPolicy, type LateResultProvider, type ClerkActionsOptions, type WorkOSActionsOptions, type Auth0ActionsOptions, } from "./late-results.js";
9
+ export { fromAuth0, fromClerk, fromCognito, fromEntra, fromFirebase, fromKeycloak, fromOIDC, fromOry, fromOryOAuth2, fromSupabase, fromWorkOS, type VerifiedClaims, type AuthContextOverrides, } from "./auth.js";
9
10
  export { DEFAULT_WAIT_TIMEOUT_MS, MIN_POLL_INTERVAL_MS } from "./wait.js";
10
11
  export * from "./models/index.js";
11
12
  export type { CreateAssessmentRequest, GetAssessmentRequest, RecordAssessmentOutcomeRequest } from "./models/operations/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,aAAa,EACb,YAAY,EACZ,UAAU,EACV,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1E,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAClI,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACjF,YAAY,EAAE,MAAM,EAAE,MAAM,i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AU,EACV,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1E,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAClI,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACjF,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
package/dist/esm/index.js CHANGED
@@ -5,7 +5,8 @@
5
5
  export { NoResponse, Assessments, Keys, DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS, } from "./client.js";
6
6
  export * from "./errors.js";
7
7
  export { constructEvent, verificationResponse, isExpiredEvent, WebhookVerificationError, DEFAULT_TOLERANCE_SECONDS, } from "./webhooks.js";
8
- export { fromAuth0, fromClerk, fromCognito, fromEntra, fromFirebase, fromKeycloak, fromOIDC, fromOry, fromOryOAuth2, fromSupabase, fromWorkOS } from "./auth.js";
8
+ export { handleLateResult, lateResultAction, clerkActions, workosActions, auth0Actions, ProviderActionError, DEFAULT_LATE_RESULT_POLICY, } from "./late-results.js";
9
+ export { fromAuth0, fromClerk, fromCognito, fromEntra, fromFirebase, fromKeycloak, fromOIDC, fromOry, fromOryOAuth2, fromSupabase, fromWorkOS, } from "./auth.js";
9
10
  export { DEFAULT_WAIT_TIMEOUT_MS, MIN_POLL_INTERVAL_MS } from "./wait.js";
10
11
  export * from "./models/index.js";
11
12
  export { SDK_METADATA, ServerList } from "./lib/config.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,kBAAkB,GAQnB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GAW1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,aAAa,EACb,YAAY,EACZ,UAAU,EACsC,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1E,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAwC,MAAM,eAAe,CAAC;AAIjF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,UAAU,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,kBAAkB,GAQnB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GAW1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,GAS3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,aAAa,EACb,YAAY,EACZ,UAAU,GAGX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1E,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAwC,MAAM,eAAe,CAAC;AAIjF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Late-result handlers. Hand-written; not generated.
3
+ *
4
+ * An assessment can be revised after the signup was allowed: a slow source
5
+ * settles and the recommendation rises. NoResponse sends the new version as a
6
+ * signed assessment.updated webhook. handleLateResult verifies that delivery
7
+ * with constructEvent, picks an action from your policy, and acts through the
8
+ * auth provider's admin API: revoke the user's sessions or ban the user.
9
+ *
10
+ * The handler verifies the delivery itself, so it never acts on an unverified
11
+ * event. The provider calls are thin: you pass the credentials, and each
12
+ * action is the provider's documented admin endpoint.
13
+ */
14
+ import { type ConstructEventOptions, type HeaderInput, type WebhookEvent, type WebhookSecrets } from "./webhooks.js";
15
+ /** What to do to the user. "ban" also ends every session. */
16
+ export type LateResultAction = "none" | "revoke_sessions" | "ban";
17
+ /** The action for each recommendation. A recommendation you leave out does nothing. */
18
+ export type LateResultPolicy = Readonly<Partial<Record<"allow" | "step_up" | "review", LateResultAction>>>;
19
+ /** Revoke sessions on review; do nothing on allow or step_up. Banning is opt-in. */
20
+ export declare const DEFAULT_LATE_RESULT_POLICY: LateResultPolicy;
21
+ /** The two admin actions, for one auth provider. Build one with clerkActions, workosActions or auth0Actions. */
22
+ export interface LateResultProvider {
23
+ readonly name: string;
24
+ /** End every active session of the user. */
25
+ revokeSessions(userId: string): Promise<void>;
26
+ /** Stop the user signing in again and end their sessions. */
27
+ ban(userId: string): Promise<void>;
28
+ }
29
+ export type LateResultOptions = ConstructEventOptions & {
30
+ /** Recommendation to action. Defaults to DEFAULT_LATE_RESULT_POLICY. */
31
+ policy?: LateResultPolicy;
32
+ /**
33
+ * The provider user id for the assessment's account_id. Defaults to the
34
+ * account_id itself, as when you assess with the provider's user id.
35
+ * Return null or undefined to take no action.
36
+ */
37
+ userId?: (accountId: string, event: WebhookEvent) => string | null | undefined | Promise<string | null | undefined>;
38
+ };
39
+ export type LateResult = {
40
+ /** The verified event. Answer an endpoint.verification with verificationResponse(event). */
41
+ event: WebhookEvent;
42
+ /** The action taken. "none" when the policy, the event or the user id called for nothing. */
43
+ action: LateResultAction;
44
+ /** The provider user id acted on, when an action was taken. */
45
+ userId?: string;
46
+ };
47
+ /** Thrown when the provider's admin API refuses a call. Answer the webhook with a 5xx so NoResponse retries it. */
48
+ export declare class ProviderActionError extends Error {
49
+ readonly provider: string;
50
+ readonly status: number;
51
+ constructor(provider: string, status: number, message: string);
52
+ }
53
+ /** The action your policy names for a verified event. Only a served assessment with a recommendation can act. */
54
+ export declare function lateResultAction(event: WebhookEvent, policy?: LateResultPolicy): LateResultAction;
55
+ /**
56
+ * Verify a webhook delivery and apply your policy to it.
57
+ *
58
+ * `payload`, `headers`, `secrets` and the tolerance options are exactly what
59
+ * constructEvent takes; a delivery that fails verification throws
60
+ * WebhookVerificationError before any provider call. Deduplicate on
61
+ * `result.event.id` and ignore versions older than one you have acted on.
62
+ */
63
+ export declare function handleLateResult(payload: Uint8Array | string, headers: HeaderInput, secrets: WebhookSecrets, provider: LateResultProvider, options?: LateResultOptions): Promise<LateResult>;
64
+ type Fetch = typeof fetch;
65
+ export type ClerkActionsOptions = {
66
+ /** Clerk secret key (sk_...). */
67
+ secretKey: string;
68
+ /** Default https://api.clerk.com/v1. */
69
+ baseUrl?: string;
70
+ fetch?: Fetch;
71
+ };
72
+ /**
73
+ * Clerk Backend API. revokeSessions lists the user's active sessions
74
+ * (GET /sessions?user_id&status=active) and revokes each
75
+ * (POST /sessions/{id}/revoke). ban is POST /users/{id}/ban, which revokes
76
+ * every session and blocks sign-in.
77
+ */
78
+ export declare function clerkActions(options: ClerkActionsOptions): LateResultProvider;
79
+ export type WorkOSActionsOptions = {
80
+ /** WorkOS API key (sk_...). */
81
+ apiKey: string;
82
+ /** Default https://api.workos.com. */
83
+ baseUrl?: string;
84
+ fetch?: Fetch;
85
+ };
86
+ /**
87
+ * WorkOS User Management. revokeSessions pages through
88
+ * GET /user_management/users/{id}/sessions and revokes each active one with
89
+ * POST /user_management/sessions/revoke. WorkOS has no block or ban, so ban
90
+ * revokes the sessions and then deletes the user
91
+ * (DELETE /user_management/users/{id}); deletion is permanent.
92
+ */
93
+ export declare function workosActions(options: WorkOSActionsOptions): LateResultProvider;
94
+ export type Auth0ActionsOptions = {
95
+ /** Your Auth0 tenant domain, such as example.eu.auth0.com. The Management API is https://{domain}/api/v2. */
96
+ domain?: string;
97
+ /** The Management API base URL in place of domain. */
98
+ baseUrl?: string;
99
+ /** A Management API access token with update:users, delete:sessions and delete:refresh_tokens. */
100
+ token: string;
101
+ fetch?: Fetch;
102
+ };
103
+ /**
104
+ * Auth0 Management API. revokeSessions deletes every session
105
+ * (DELETE /users/{id}/sessions) and refresh token
106
+ * (DELETE /users/{id}/refresh-tokens). ban first sets blocked: true
107
+ * (PATCH /users/{id}), then does the same.
108
+ */
109
+ export declare function auth0Actions(options: Auth0ActionsOptions): LateResultProvider;
110
+ export {};
111
+ //# sourceMappingURL=late-results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"late-results.d.ts","sourceRoot":"","sources":["../../src/late-results.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAErI,6DAA6D;AAC7D,MAAM,MAAM,gBAAgB,GAAG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/**
2
+ * Late-result handlers. Hand-written; not generated.
3
+ *
4
+ * An assessment can be revised after the signup was allowed: a slow source
5
+ * settles and the recommendation rises. NoResponse sends the new version as a
6
+ * signed assessment.updated webhook. handleLateResult verifies that delivery
7
+ * with constructEvent, picks an action from your policy, and acts through the
8
+ * auth provider's admin API: revoke the user's sessions or ban the user.
9
+ *
10
+ * The handler verifies the delivery itself, so it never acts on an unverified
11
+ * event. The provider calls are thin: you pass the credentials, and each
12
+ * action is the provider's documented admin endpoint.
13
+ */
14
+ import { constructEvent } from "./webhooks.js";
15
+ /** Revoke sessions on review; do nothing on allow or step_up. Banning is opt-in. */
16
+ export const DEFAULT_LATE_RESULT_POLICY = Object.freeze({ allow: "none", step_up: "none", review: "revoke_sessions" });
17
+ /** Thrown when the provider's admin API refuses a call. Answer the webhook with a 5xx so NoResponse retries it. */
18
+ export class ProviderActionError extends Error {
19
+ provider;
20
+ status;
21
+ constructor(provider, status, message) {
22
+ super(message);
23
+ this.name = "ProviderActionError";
24
+ this.provider = provider;
25
+ this.status = status;
26
+ }
27
+ }
28
+ const ACTIONS = ["none", "revoke_sessions", "ban"];
29
+ /** The action your policy names for a verified event. Only a served assessment with a recommendation can act. */
30
+ export function lateResultAction(event, policy = DEFAULT_LATE_RESULT_POLICY) {
31
+ if (event.type !== "assessment.updated" || event.data.status === "expired")
32
+ return "none";
33
+ const data = event.data;
34
+ const recommendation = data.recommendation ?? data.risk?.recommendation;
35
+ if (recommendation !== "allow" && recommendation !== "step_up" && recommendation !== "review")
36
+ return "none";
37
+ const action = Object.prototype.hasOwnProperty.call(policy, recommendation) ? policy[recommendation] : undefined;
38
+ if (action === undefined)
39
+ return "none";
40
+ if (!ACTIONS.includes(action))
41
+ throw new TypeError(`unknown late result action ${String(action)}`);
42
+ return action;
43
+ }
44
+ /**
45
+ * Verify a webhook delivery and apply your policy to it.
46
+ *
47
+ * `payload`, `headers`, `secrets` and the tolerance options are exactly what
48
+ * constructEvent takes; a delivery that fails verification throws
49
+ * WebhookVerificationError before any provider call. Deduplicate on
50
+ * `result.event.id` and ignore versions older than one you have acted on.
51
+ */
52
+ export async function handleLateResult(payload, headers, secrets, provider, options = {}) {
53
+ const { policy, userId: resolve, ...verify } = options;
54
+ const event = constructEvent(payload, headers, secrets, verify);
55
+ const action = lateResultAction(event, policy);
56
+ if (action === "none" || event.type !== "assessment.updated")
57
+ return { event, action: "none" };
58
+ const accountId = event.data.accountId;
59
+ const userId = resolve ? await resolve(accountId, event) : accountId;
60
+ if (userId === null || userId === undefined || userId === "")
61
+ return { event, action: "none" };
62
+ if (action === "ban")
63
+ await provider.ban(userId);
64
+ else
65
+ await provider.revokeSessions(userId);
66
+ return { event, action, userId };
67
+ }
68
+ function caller(name, baseUrl, authorization, fetcher) {
69
+ const base = baseUrl.replace(/\/+$/, "");
70
+ const run = fetcher ?? globalThis.fetch;
71
+ return async ({ method, path, query, body, allow404 }) => {
72
+ const url = new URL(base + path);
73
+ for (const [key, value] of Object.entries(query ?? {}))
74
+ url.searchParams.set(key, value);
75
+ const headers = { authorization, accept: "application/json" };
76
+ if (body !== undefined)
77
+ headers["content-type"] = "application/json";
78
+ const response = await run(url, { method, headers, ...(body !== undefined ? { body: JSON.stringify(body) } : {}) });
79
+ const text = await response.text();
80
+ if (allow404 && response.status === 404)
81
+ return undefined;
82
+ if (!response.ok)
83
+ throw new ProviderActionError(name, response.status, `${name} ${method} ${path} answered ${response.status}`);
84
+ if (!text)
85
+ return undefined;
86
+ try {
87
+ return JSON.parse(text);
88
+ }
89
+ catch {
90
+ return undefined;
91
+ }
92
+ };
93
+ }
94
+ const segment = (id) => {
95
+ if (typeof id !== "string" || id === "")
96
+ throw new TypeError("user id must be a non-empty string");
97
+ return encodeURIComponent(id);
98
+ };
99
+ function sessions(body) {
100
+ if (Array.isArray(body))
101
+ return body;
102
+ const data = body?.data;
103
+ return Array.isArray(data) ? data : [];
104
+ }
105
+ /**
106
+ * Clerk Backend API. revokeSessions lists the user's active sessions
107
+ * (GET /sessions?user_id&status=active) and revokes each
108
+ * (POST /sessions/{id}/revoke). ban is POST /users/{id}/ban, which revokes
109
+ * every session and blocks sign-in.
110
+ */
111
+ export function clerkActions(options) {
112
+ if (!options?.secretKey)
113
+ throw new TypeError("clerkActions needs secretKey");
114
+ const call = caller("clerk", options.baseUrl ?? "https://api.clerk.com/v1", `Bearer ${options.secretKey}`, options.fetch);
115
+ const PAGE = 100;
116
+ return {
117
+ name: "clerk",
118
+ async revokeSessions(userId) {
119
+ segment(userId);
120
+ const active = [];
121
+ for (let offset = 0; offset < PAGE * 1000; offset += PAGE) {
122
+ const page = sessions(await call({ method: "GET", path: "/sessions", query: { user_id: userId, status: "active", limit: String(PAGE), offset: String(offset) } }));
123
+ for (const s of page)
124
+ if (s.status === "active" && typeof s.id === "string" && s.id)
125
+ active.push(s.id);
126
+ if (page.length < PAGE)
127
+ break;
128
+ }
129
+ for (const id of active)
130
+ await call({ method: "POST", path: `/sessions/${encodeURIComponent(id)}/revoke` });
131
+ },
132
+ async ban(userId) {
133
+ await call({ method: "POST", path: `/users/${segment(userId)}/ban` });
134
+ },
135
+ };
136
+ }
137
+ /**
138
+ * WorkOS User Management. revokeSessions pages through
139
+ * GET /user_management/users/{id}/sessions and revokes each active one with
140
+ * POST /user_management/sessions/revoke. WorkOS has no block or ban, so ban
141
+ * revokes the sessions and then deletes the user
142
+ * (DELETE /user_management/users/{id}); deletion is permanent.
143
+ */
144
+ export function workosActions(options) {
145
+ if (!options?.apiKey)
146
+ throw new TypeError("workosActions needs apiKey");
147
+ const call = caller("workos", options.baseUrl ?? "https://api.workos.com", `Bearer ${options.apiKey}`, options.fetch);
148
+ const revokeSessions = async (userId) => {
149
+ const user = segment(userId);
150
+ const active = [];
151
+ let after;
152
+ for (let round = 0; round < 1000; round++) {
153
+ const query = { limit: "100" };
154
+ if (after)
155
+ query["after"] = after;
156
+ const body = (await call({ method: "GET", path: `/user_management/users/${user}/sessions`, query }));
157
+ for (const s of sessions(body))
158
+ if (s.status === "active" && typeof s.id === "string" && s.id)
159
+ active.push(s.id);
160
+ const next = body?.list_metadata?.after;
161
+ if (typeof next !== "string" || next === "")
162
+ break;
163
+ after = next;
164
+ }
165
+ for (const id of active)
166
+ await call({ method: "POST", path: "/user_management/sessions/revoke", body: { session_id: id } });
167
+ };
168
+ return {
169
+ name: "workos",
170
+ revokeSessions,
171
+ async ban(userId) {
172
+ await revokeSessions(userId);
173
+ await call({ method: "DELETE", path: `/user_management/users/${segment(userId)}`, allow404: true });
174
+ },
175
+ };
176
+ }
177
+ /**
178
+ * Auth0 Management API. revokeSessions deletes every session
179
+ * (DELETE /users/{id}/sessions) and refresh token
180
+ * (DELETE /users/{id}/refresh-tokens). ban first sets blocked: true
181
+ * (PATCH /users/{id}), then does the same.
182
+ */
183
+ export function auth0Actions(options) {
184
+ if (!options?.token)
185
+ throw new TypeError("auth0Actions needs token");
186
+ const base = options.baseUrl ?? (options.domain ? `https://${options.domain}/api/v2` : undefined);
187
+ if (!base)
188
+ throw new TypeError("auth0Actions needs domain or baseUrl");
189
+ const call = caller("auth0", base, `Bearer ${options.token}`, options.fetch);
190
+ const revokeSessions = async (userId) => {
191
+ const user = segment(userId);
192
+ await call({ method: "DELETE", path: `/users/${user}/sessions` });
193
+ await call({ method: "DELETE", path: `/users/${user}/refresh-tokens` });
194
+ };
195
+ return {
196
+ name: "auth0",
197
+ revokeSessions,
198
+ async ban(userId) {
199
+ await call({ method: "PATCH", path: `/users/${segment(userId)}`, body: { blocked: true } });
200
+ await revokeSessions(userId);
201
+ },
202
+ };
203
+ }
204
+ //# sourceMappingURL=late-results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"late-results.js","sourceRoot":"","sources":["../../src/late-results.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,cAAc,EAAwF,MAAM,eAAe,CAAC;AAQrI,oFAAoF;AACpF,MAAM,CAAC,MAAM,0BAA0B,GAAqB,MAAM,CAAC,MAAM,CAAC,E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AAG,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YAC5F,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;QAAA,CAC9B;KACF,CAAC;AAAA,CACH"}
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
31
31
  export declare const SDK_METADATA: {
32
32
  readonly language: "typescript";
33
33
  readonly openapiDocVersion: "1";
34
- readonly sdkVersion: "2.0.10";
34
+ readonly sdkVersion: "2.0.11";
35
35
  readonly genVersion: "internal";
36
- readonly userAgent: "noresponse-sdk/typescript 2.0.10 internal 1 @noresponse/node";
36
+ readonly userAgent: "noresponse-sdk/typescript 2.0.11 internal 1 @noresponse/node";
37
37
  };
38
38
  //# sourceMappingURL=config.d.ts.map
@@ -24,8 +24,8 @@ export function serverURLFromOptions(options) {
24
24
  export const SDK_METADATA = {
25
25
  language: "typescript",
26
26
  openapiDocVersion: "1",
27
- sdkVersion: "2.0.10",
27
+ sdkVersion: "2.0.11",
28
28
  genVersion: "internal",
29
- userAgent: "noresponse-sdk/typescript 2.0.10 internal 1 @noresponse/node",
29
+ userAgent: "noresponse-sdk/typescript 2.0.11 internal 1 @noresponse/node",
30
30
  };
31
31
  //# sourceMappingURL=config.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noresponse/node",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "author": "NoResponse",
5
5
  "bugs": {
6
6
  "url": "https://github.com/noresponsehq/node/issues"