@authhero/adapter-interfaces 3.8.0 → 3.10.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/adapter-interfaces.cjs +1 -1
- package/dist/adapter-interfaces.d.ts +77 -5
- package/dist/adapter-interfaces.mjs +461 -429
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/adapters/Users.d.ts +25 -3
- package/dist/types/types/auth0/Totals.d.ts +7 -0
- package/dist/types/utils/base64url.d.ts +22 -0
- package/dist/types/utils/cursor.d.ts +20 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { User, Totals, UserInsert } from "../types";
|
|
2
|
+
import { AuditEventInsert } from "../types/AuditEvent";
|
|
2
3
|
import { ListParams } from "../types/ListParams";
|
|
3
4
|
import { CreateOptions } from "../types/ImportMetadata";
|
|
4
5
|
export interface ListUsersResponse extends Totals {
|
|
5
6
|
users: User[];
|
|
6
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* An outbox event to persist atomically with a business write. It carries a
|
|
10
|
+
* caller-assigned `id` so the enqueuer can relay it (push it onto the request's
|
|
11
|
+
* outbox-event list for delivery) without a return round-trip from the adapter.
|
|
12
|
+
*/
|
|
13
|
+
export type OutboxEventInsert = AuditEventInsert & {
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Options common to the event-emitting user writes. When `outboxEvents` are
|
|
18
|
+
* supplied, the adapter MUST persist them in the same atomic unit as the
|
|
19
|
+
* business write — a single `db.batch()` on D1, one transaction on
|
|
20
|
+
* kysely/better-sqlite3 — so the business row and its event row commit together
|
|
21
|
+
* or not at all (the defining guarantee of the transactional outbox pattern).
|
|
22
|
+
*/
|
|
23
|
+
export interface WriteOptions {
|
|
24
|
+
outboxEvents?: OutboxEventInsert[];
|
|
25
|
+
}
|
|
7
26
|
export interface UserDataAdapter {
|
|
8
27
|
get(tenant_id: string, id: string): Promise<User | null>;
|
|
9
28
|
create(tenantId: string, user: UserInsert, options?: CreateOptions): Promise<User>;
|
|
@@ -12,10 +31,13 @@ export interface UserDataAdapter {
|
|
|
12
31
|
* registration hooks, linking, webhooks, etc.). Intended to be called from
|
|
13
32
|
* inside a registration pipeline that owns hook orchestration and transaction
|
|
14
33
|
* boundaries itself. The DB-level behavior is identical to `create`.
|
|
34
|
+
*
|
|
35
|
+
* Pass `options.outboxEvents` to persist post-registration outbox events in
|
|
36
|
+
* the same atomic unit as the user row.
|
|
15
37
|
*/
|
|
16
|
-
rawCreate(tenantId: string, user: UserInsert): Promise<User>;
|
|
17
|
-
remove(tenantId: string, id: string): Promise<boolean>;
|
|
38
|
+
rawCreate(tenantId: string, user: UserInsert, options?: WriteOptions): Promise<User>;
|
|
39
|
+
remove(tenantId: string, id: string, options?: WriteOptions): Promise<boolean>;
|
|
18
40
|
list(tenantId: string, params?: ListParams): Promise<ListUsersResponse>;
|
|
19
|
-
update(tenantId: string, id: string, user: Partial<User
|
|
41
|
+
update(tenantId: string, id: string, user: Partial<User>, options?: WriteOptions): Promise<boolean>;
|
|
20
42
|
unlink(tenantId: string, id: string, provider: string, linked_user_id: string): Promise<boolean>;
|
|
21
43
|
}
|
|
@@ -4,10 +4,17 @@ export declare const totalsSchema: z.ZodObject<{
|
|
|
4
4
|
limit: z.ZodNumber;
|
|
5
5
|
length: z.ZodNumber;
|
|
6
6
|
total: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
next: z.ZodOptional<z.ZodString>;
|
|
7
8
|
}, z.core.$strip>;
|
|
8
9
|
export interface Totals {
|
|
9
10
|
start: number;
|
|
10
11
|
limit: number;
|
|
11
12
|
length: number;
|
|
12
13
|
total?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Opaque keyset cursor for the next page. Set only when the caller paginated
|
|
16
|
+
* with from/take and more rows may follow; absent on the last page and for
|
|
17
|
+
* offset (page/per_page) pagination.
|
|
18
|
+
*/
|
|
19
|
+
next?: string;
|
|
13
20
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL-safe base64 ("base64url", RFC 4648 §5) without padding.
|
|
3
|
+
*
|
|
4
|
+
* This is the canonical base64url implementation for the AuthHero packages.
|
|
5
|
+
* It lives in `adapter-interfaces` (the lowest package) so every other package
|
|
6
|
+
* can depend on it, replacing scattered hand-rolled `btoa/atob` variants and
|
|
7
|
+
* the `oslo/encoding` dependency we are migrating away from.
|
|
8
|
+
*
|
|
9
|
+
* Both byte- and string-oriented helpers are provided:
|
|
10
|
+
* - `encodeBase64Url` / `decodeBase64Url` work on raw bytes (`Uint8Array`),
|
|
11
|
+
* matching how most callers use it (hashes, random bytes, JWT segments).
|
|
12
|
+
* - `encodeBase64UrlString` / `decodeBase64UrlString` wrap those with UTF-8
|
|
13
|
+
* (de)coding for the common "encode a JSON/text payload" case.
|
|
14
|
+
*/
|
|
15
|
+
/** Encode raw bytes as a padding-free base64url string. */
|
|
16
|
+
export declare function encodeBase64Url(bytes: Uint8Array): string;
|
|
17
|
+
/** Decode a base64url string (with or without padding) back to raw bytes. */
|
|
18
|
+
export declare function decodeBase64Url(input: string): Uint8Array;
|
|
19
|
+
/** Encode a UTF-8 string as a padding-free base64url string. */
|
|
20
|
+
export declare function encodeBase64UrlString(input: string): string;
|
|
21
|
+
/** Decode a base64url string produced from UTF-8 text back to that string. */
|
|
22
|
+
export declare function decodeBase64UrlString(input: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface CursorPayload {
|
|
2
|
+
/**
|
|
3
|
+
* Value of the sort column on the last row of the previous page. `null` when
|
|
4
|
+
* that column was null on the boundary row. Absent for id-only ordering.
|
|
5
|
+
*/
|
|
6
|
+
s?: string | number | null;
|
|
7
|
+
/** Id of the last row of the previous page — the unique tiebreaker. */
|
|
8
|
+
i: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Encode a keyset position into an opaque cursor token suitable for returning
|
|
12
|
+
* as `next` and accepting back as `from`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function encodeCursor(payload: CursorPayload): string;
|
|
15
|
+
/**
|
|
16
|
+
* Decode an opaque cursor token. Returns `null` for malformed or unparseable
|
|
17
|
+
* tokens so callers can fall back gracefully (e.g. start from the beginning)
|
|
18
|
+
* instead of throwing on client-supplied input.
|
|
19
|
+
*/
|
|
20
|
+
export declare function decodeCursor(token: string): CursorPayload | null;
|