authhero 4.102.0 → 4.103.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/README.md +24 -25
- package/dist/assets/u/widget/index.esm.js +1 -1
- package/dist/authhero.cjs +87 -87
- package/dist/authhero.d.ts +131 -34
- package/dist/authhero.mjs +10759 -10518
- package/dist/stats.html +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -110,49 +110,48 @@ const dataAdapter = {
|
|
|
110
110
|
const { app } = init({ dataAdapter });
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
## Outbox
|
|
113
|
+
## Outbox relay in cron
|
|
114
114
|
|
|
115
115
|
Authhero uses a transactional outbox to deliver audit events and webhook
|
|
116
116
|
dispatches. Events are delivered per-request by default, but you should also
|
|
117
|
-
|
|
117
|
+
sweep the outbox on a schedule as a safety net for events that failed
|
|
118
118
|
in-request delivery (e.g. a transient webhook 5xx).
|
|
119
119
|
|
|
120
|
-
Use `
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
`
|
|
120
|
+
Use `runOutboxRelay` as the entire body of your scheduled handler — it
|
|
121
|
+
builds the same destination array the inline dispatcher uses, mints
|
|
122
|
+
per-tenant `auth-service` tokens via the same in-process path, runs
|
|
123
|
+
`drainOutbox`, and then `cleanupOutbox`:
|
|
124
124
|
|
|
125
125
|
```ts
|
|
126
|
-
import {
|
|
127
|
-
createDefaultDestinations,
|
|
128
|
-
drainOutbox,
|
|
129
|
-
cleanupOutbox,
|
|
130
|
-
} from "authhero";
|
|
126
|
+
import { runOutboxRelay } from "authhero";
|
|
131
127
|
|
|
132
128
|
// Cloudflare Workers scheduled handler (one per cron trigger)
|
|
133
129
|
export default {
|
|
134
130
|
async scheduled(_event, env) {
|
|
135
|
-
|
|
131
|
+
await runOutboxRelay({
|
|
136
132
|
dataAdapter,
|
|
137
|
-
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
(await mintServiceToken(tenantId, "webhook")).access_token,
|
|
133
|
+
issuer: env.ISSUER,
|
|
134
|
+
webhookInvoker, // same function passed to init()
|
|
135
|
+
retentionDays: 7,
|
|
141
136
|
});
|
|
142
|
-
|
|
143
|
-
await drainOutbox(dataAdapter.outbox, destinations);
|
|
144
|
-
await cleanupOutbox(dataAdapter.outbox, { retentionDays: 7 });
|
|
145
137
|
},
|
|
146
138
|
};
|
|
147
139
|
```
|
|
148
140
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
Passing the same `webhookInvoker` you pass to `init()` is important: without
|
|
142
|
+
it, cron-drained `hook.*` events would bypass any custom payload shaping,
|
|
143
|
+
auth headers, or non-HTTP transports your invoker implements, and diverge
|
|
144
|
+
silently from per-request deliveries.
|
|
145
|
+
|
|
146
|
+
### Lower-level escape hatches
|
|
152
147
|
|
|
153
|
-
If you need something custom,
|
|
154
|
-
`
|
|
155
|
-
|
|
148
|
+
If you need something custom, `drainOutbox`, `cleanupOutbox`, and
|
|
149
|
+
`createDefaultDestinations` are also exported. `createDefaultDestinations`
|
|
150
|
+
accepts the same optional `webhookInvoker` so you can wire up invoker
|
|
151
|
+
parity without the full one-call wrapper. The underlying destination
|
|
152
|
+
classes (`LogsDestination`, `WebhookDestination`,
|
|
153
|
+
`RegistrationFinalizerDestination`) and the `EventDestination` interface
|
|
154
|
+
are also public.
|
|
156
155
|
|
|
157
156
|
## Contributing
|
|
158
157
|
|