@absolutejs/auth 0.34.0 → 0.35.0-beta.0
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/dist/client/index.js +33 -1
- package/dist/client/index.js.map +2 -2
- package/dist/client/react.js +33 -1
- package/dist/client/react.js.map +2 -2
- package/dist/client/solid.js +33 -1
- package/dist/client/solid.js.map +2 -2
- package/dist/client/svelte.js +33 -1
- package/dist/client/svelte.js.map +2 -2
- package/dist/client/vue.js +33 -1
- package/dist/client/vue.js.map +2 -2
- package/dist/htmx/index.js +33 -1
- package/dist/htmx/index.js.map +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1594 -43
- package/dist/index.js.map +55 -10
- package/dist/plugins/index.js +33 -1
- package/dist/plugins/index.js.map +2 -2
- package/dist/telemetry/tracing.d.ts +15 -0
- package/dist/types.d.ts +8 -0
- package/package.json +7 -1
package/dist/plugins/index.js
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
|
|
2
34
|
// src/credentials/emailValidation.ts
|
|
3
35
|
import { resolveMx } from "dns/promises";
|
|
4
36
|
var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u;
|
|
@@ -179,5 +211,5 @@ export {
|
|
|
179
211
|
denyDisposableEmailPlugin
|
|
180
212
|
};
|
|
181
213
|
|
|
182
|
-
//# debugId=
|
|
214
|
+
//# debugId=D4F9FA5D4087E8A964756E2164756E21
|
|
183
215
|
//# sourceMappingURL=index.js.map
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"// PostHog server-side identify. Pair with audit events that have a `userId` (register,\n// credentials_login, oauth_login, …) to push the user to PostHog with their\n// email/properties so server-side events tie back to the right person.\n//\n// ~25 lines; one POST per event. Drop into the audit chain via composition or use as\n// an `AuditSink` directly.\n\nimport type { AuditEvent, AuditSink } from '../audit/types';\n\nexport type PosthogIdentifyOptions = {\n\thost?: string; // defaults to PostHog Cloud US\n\tprojectApiKey: string;\n\t// Pull the properties to send from the audit event metadata + your own enrichment.\n\tproperties?: (event: AuditEvent) => Record<string, unknown>;\n};\n\nconst DEFAULT_HOST = 'https://us.i.posthog.com';\n\nexport const posthogIdentifyPlugin = ({\n\thost = DEFAULT_HOST,\n\tprojectApiKey,\n\tproperties = (event) => ({ ...(event.metadata ?? {}) })\n}: PosthogIdentifyOptions): AuditSink => ({\n\tappend: async (event) => {\n\t\tif (event.userId === undefined) return;\n\t\tawait fetch(`${host}/capture/`, {\n\t\t\tbody: JSON.stringify({\n\t\t\t\tapi_key: projectApiKey,\n\t\t\t\tdistinct_id: event.userId,\n\t\t\t\tevent: '$identify',\n\t\t\t\tproperties: {\n\t\t\t\t\t$set: properties(event),\n\t\t\t\t\t$set_once: { first_seen_event: event.type }\n\t\t\t\t},\n\t\t\t\ttimestamp: new Date(event.at).toISOString()\n\t\t\t}),\n\t\t\theaders: { 'content-type': 'application/json' },\n\t\t\tmethod: 'POST'\n\t\t}).catch(() => undefined);\n\t}\n});\n",
|
|
11
11
|
"// Slack webhook plugin. Pair with `audit.onAuditEvent` OR drop into the audit chain\n// (it's a valid `AuditSink`) to post a one-line summary of chosen audit events to a\n// Slack channel webhook. Fire-and-forget, ~30 lines — copy + modify if you want a\n// different message shape.\n\nimport type { AuditEvent, AuditEventType, AuditSink } from '../audit/types';\n\nexport type SlackAlertOptions = {\n\t// Optional event-type allow-list. Without it, EVERY event posts — typically you\n\t// want to filter to security-relevant events like login failures + MFA failures.\n\tevents?: readonly AuditEventType[];\n\t// Build the Slack message body from the event. Default is one short line; override\n\t// to use Block Kit, attachments, mentions, etc.\n\tformatMessage?: (event: AuditEvent) => string;\n\twebhookUrl: string;\n};\n\nconst defaultFormat = (event: AuditEvent) => {\n\tconst when = new Date(event.at).toISOString();\n\tconst who = event.userId ?? event.ip ?? 'unknown';\n\n\treturn `🔐 *${event.type}* — ${who} at ${when}`;\n};\n\nexport const slackAlertPlugin = ({\n\tevents,\n\tformatMessage = defaultFormat,\n\twebhookUrl\n}: SlackAlertOptions): AuditSink => ({\n\tappend: async (event) => {\n\t\tif (events !== undefined && !events.includes(event.type)) return;\n\t\tawait fetch(webhookUrl, {\n\t\t\tbody: JSON.stringify({ text: formatMessage(event) }),\n\t\t\theaders: { 'content-type': 'application/json' },\n\t\t\tmethod: 'POST'\n\t\t}).catch(() => undefined);\n\t}\n});\n"
|
|
12
12
|
],
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A,UACX,MAAM,WAAW,KAAK;AAAA,UACtB,WAAW,EAAE,kBAAkB,MAAM,KAAK;AAAA,QAC3C;AAAA,QACA,WAAW,IAAI,KAAK,MAAM,EAAE,EAAE,YAAY;AAAA,MAC3C,CAAC;AAAA,MACD,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,QAAQ;AAAA,IACT,CAAC,EAAE,MAAM,MAAG;AAAA,MAAG;AAAA,KAAS;AAAA;AAE1B;;ACvBA,IAAM,gBAAgB,CAAC,UAAsB;AAAA,EAC5C,MAAM,OAAO,IAAI,KAAK,MAAM,EAAE,EAAE,YAAY;AAAA,EAC5C,MAAM,MAAM,MAAM,UAAU,MAAM,MAAM;AAAA,EAExC,OAAO,iBAAM,MAAM,gBAAW,UAAU;AAAA;AAGlC,IAAM,mBAAmB;AAAA,EAC/B;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,OACoC;AAAA,EACpC,QAAQ,OAAO,UAAU;AAAA,IACxB,IAAI,WAAW,aAAa,CAAC,OAAO,SAAS,MAAM,IAAI;AAAA,MAAG;AAAA,IAC1D,MAAM,MAAM,YAAY;AAAA,MACvB,MAAM,KAAK,UAAU,EAAE,MAAM,cAAc,KAAK,EAAE,CAAC;AAAA,MACnD,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,QAAQ;AAAA,IACT,CAAC,EAAE,MAAM,MAAG;AAAA,MAAG;AAAA,KAAS;AAAA;AAE1B;",
|
|
14
|
+
"debugId": "D4F9FA5D4087E8A964756E2164756E21",
|
|
15
15
|
"names": []
|
|
16
16
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Attributes, Span, TracerProvider } from '@opentelemetry/api';
|
|
2
|
+
export type TracingConfig = {
|
|
3
|
+
/** Plug in your `@opentelemetry/sdk-trace-node` (or `-web` / `-bun`) TracerProvider
|
|
4
|
+
* here. When omitted, every `withSpan` call short-circuits and the package never
|
|
5
|
+
* loads `@opentelemetry/api`. */
|
|
6
|
+
tracerProvider: TracerProvider;
|
|
7
|
+
/** Service name attribute attached to every span. Defaults to `@absolutejs/auth`. */
|
|
8
|
+
serviceName?: string;
|
|
9
|
+
};
|
|
10
|
+
type SpanWork<Result> = (span: Span | undefined) => Promise<Result>;
|
|
11
|
+
type WithSpanFn = <Result>(name: string, attributes: Attributes | undefined, work: SpanWork<Result>) => Promise<Result>;
|
|
12
|
+
export declare const __resetTracingForTests: () => void;
|
|
13
|
+
export declare const initTracing: (config: TracingConfig) => Promise<void>;
|
|
14
|
+
export declare const withSpan: WithSpanFn;
|
|
15
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import type { ScimConfig } from './scim/config';
|
|
|
19
19
|
import type { SessionsConfig } from './session/sessionsConfig';
|
|
20
20
|
import type { AuthSessionStore } from './session/types';
|
|
21
21
|
import type { SSOConfig } from './sso/config';
|
|
22
|
+
import type { TracingConfig } from './telemetry/tracing';
|
|
22
23
|
import type { WebAuthnConfig } from './webauthn/config';
|
|
23
24
|
import type { WebhooksConfig } from './webhooks/config';
|
|
24
25
|
export type AuthIntent = 'login' | 'link_identity' | 'link_connector';
|
|
@@ -199,6 +200,13 @@ export type AuthConfig<UserType> = {
|
|
|
199
200
|
* dev server. If you run prod without setting `NODE_ENV=production`, set
|
|
200
201
|
* `cookieSecure: true` explicitly. */
|
|
201
202
|
cookieSecure?: boolean;
|
|
203
|
+
/** OpenTelemetry instrumentation. Pass your configured `TracerProvider` (from
|
|
204
|
+
* `@opentelemetry/sdk-trace-node` / `-web` / `-bun`) and the package emits spans for
|
|
205
|
+
* every key flow: `auth.credentials.login`, `auth.oauth.callback`, `auth.mfa.challenge`,
|
|
206
|
+
* `auth.webhook.deliver`, etc. Pipe the spans into Datadog / Honeycomb / Grafana Tempo /
|
|
207
|
+
* Sentry / Jaeger / whichever APM you already pay for. `@opentelemetry/api` is an
|
|
208
|
+
* OPTIONAL peer dep — consumers that leave `tracing` unset never load it. */
|
|
209
|
+
tracing?: TracingConfig;
|
|
202
210
|
authorizeRoute?: AuthorizeRoute;
|
|
203
211
|
profileRoute?: RouteString;
|
|
204
212
|
callbackRoute?: RouteString;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.35.0-beta.0",
|
|
3
3
|
"name": "@absolutejs/auth",
|
|
4
4
|
"description": "An authorization library for absolutejs",
|
|
5
5
|
"repository": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
+
"@opentelemetry/api": ">=1.7",
|
|
31
32
|
"elysia": ">= 1.4.26",
|
|
32
33
|
"react": ">=18 <20",
|
|
33
34
|
"solid-js": ">=1.8",
|
|
@@ -35,6 +36,9 @@
|
|
|
35
36
|
"vue": ">=3.4"
|
|
36
37
|
},
|
|
37
38
|
"peerDependenciesMeta": {
|
|
39
|
+
"@opentelemetry/api": {
|
|
40
|
+
"optional": true
|
|
41
|
+
},
|
|
38
42
|
"react": {
|
|
39
43
|
"optional": true
|
|
40
44
|
},
|
|
@@ -57,6 +61,8 @@
|
|
|
57
61
|
"devDependencies": {
|
|
58
62
|
"@absolutejs/absolute": "^0.19.0-beta.1023",
|
|
59
63
|
"@eslint/js": "^10.0.1",
|
|
64
|
+
"@opentelemetry/api": "^1.9.1",
|
|
65
|
+
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
60
66
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
61
67
|
"@types/bun": "1.2.9",
|
|
62
68
|
"@types/react": "^19.0.0",
|