@authhero/adapter-interfaces 3.9.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.
@@ -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;
@@ -2,3 +2,5 @@ export * from "./user-id";
2
2
  export * from "./passthrough";
3
3
  export * from "./connection-attributes";
4
4
  export * from "./guards";
5
+ export * from "./base64url";
6
+ export * from "./cursor";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "3.9.0",
14
+ "version": "3.10.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],