timeback 0.1.1 → 0.1.3
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 +208 -10
- package/dist/client/adapters/react/index.d.ts +1 -1
- package/dist/client/adapters/react/index.d.ts.map +1 -1
- package/dist/client/adapters/solid/index.d.ts +1 -1
- package/dist/client/adapters/solid/index.d.ts.map +1 -1
- package/dist/client/adapters/solid/index.ts +1 -1
- package/dist/client/adapters/svelte/index.d.ts +1 -1
- package/dist/client/adapters/svelte/index.d.ts.map +1 -1
- package/dist/client/adapters/svelte/index.ts +1 -1
- package/dist/client/adapters/vue/index.d.ts +1 -1
- package/dist/client/adapters/vue/index.d.ts.map +1 -1
- package/dist/client/adapters/vue/index.ts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/edge.d.ts +13 -0
- package/dist/edge.d.ts.map +1 -0
- package/dist/edge.js +1149 -0
- package/dist/identity.d.ts +14 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +1019 -0
- package/dist/index.d.ts +24 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8987 -145
- package/dist/server/adapters/express.d.ts +9 -5
- package/dist/server/adapters/express.d.ts.map +1 -1
- package/dist/server/adapters/express.js +8854 -93
- package/dist/server/adapters/native.d.ts +7 -5
- package/dist/server/adapters/native.d.ts.map +1 -1
- package/dist/server/adapters/native.js +120 -439
- package/dist/server/adapters/nextjs.d.ts +5 -3
- package/dist/server/adapters/nextjs.d.ts.map +1 -1
- package/dist/server/adapters/nextjs.js +120 -439
- package/dist/server/adapters/nuxt.d.ts +6 -4
- package/dist/server/adapters/nuxt.d.ts.map +1 -1
- package/dist/server/adapters/nuxt.js +8900 -168
- package/dist/server/adapters/solid-start.d.ts +5 -3
- package/dist/server/adapters/solid-start.d.ts.map +1 -1
- package/dist/server/adapters/solid-start.js +8821 -78
- package/dist/server/adapters/svelte-kit.d.ts +5 -3
- package/dist/server/adapters/svelte-kit.d.ts.map +1 -1
- package/dist/server/adapters/svelte-kit.js +134 -463
- package/dist/server/adapters/tanstack-start.d.ts +5 -3
- package/dist/server/adapters/tanstack-start.d.ts.map +1 -1
- package/dist/server/adapters/tanstack-start.js +8794 -44
- package/dist/server/adapters/types.d.ts +25 -11
- package/dist/server/adapters/types.d.ts.map +1 -1
- package/dist/server/adapters/utils.d.ts +66 -5
- package/dist/server/adapters/utils.d.ts.map +1 -1
- package/dist/server/handlers/activity.d.ts +1 -1
- package/dist/server/handlers/activity.d.ts.map +1 -1
- package/dist/server/handlers/identity-full.d.ts +28 -0
- package/dist/server/handlers/identity-full.d.ts.map +1 -0
- package/dist/server/handlers/identity-only.d.ts +22 -0
- package/dist/server/handlers/identity-only.d.ts.map +1 -0
- package/dist/server/handlers/index.d.ts +1 -1
- package/dist/server/handlers/index.d.ts.map +1 -1
- package/dist/server/handlers/user.d.ts +1 -1
- package/dist/server/handlers/user.d.ts.map +1 -1
- package/dist/server/index.d.ts +3 -4
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/lib/index.d.ts +2 -1
- package/dist/server/lib/index.d.ts.map +1 -1
- package/dist/server/lib/resolve-timeback-user.d.ts +42 -0
- package/dist/server/lib/resolve-timeback-user.d.ts.map +1 -0
- package/dist/server/lib/utils.d.ts +15 -0
- package/dist/server/lib/utils.d.ts.map +1 -1
- package/dist/server/timeback-identity.d.ts +19 -0
- package/dist/server/timeback-identity.d.ts.map +1 -0
- package/dist/server/timeback.d.ts +33 -13
- package/dist/server/timeback.d.ts.map +1 -1
- package/dist/server/types.d.ts +135 -33
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shared/types.d.ts +49 -5
- package/dist/shared/types.d.ts.map +1 -1
- package/package.json +10 -1
- package/dist/server/handlers/identity.d.ts +0 -24
- package/dist/server/handlers/identity.d.ts.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public type definitions for server framework adapters.
|
|
5
5
|
*/
|
|
6
|
-
import type { Handlers, TimebackInstance } from '../types';
|
|
6
|
+
import type { Handlers, IdentityOnlyHandlers, IdentityOnlyInstance, TimebackInstance } from '../types';
|
|
7
7
|
/**
|
|
8
8
|
* Flexible input that accepts either a TimebackInstance or just the handlers.
|
|
9
9
|
*
|
|
@@ -12,6 +12,20 @@ import type { Handlers, TimebackInstance } from '../types';
|
|
|
12
12
|
* - `toNextjsHandler(timeback.handle)`
|
|
13
13
|
*/
|
|
14
14
|
export type TimebackInput = TimebackInstance | Handlers;
|
|
15
|
+
/**
|
|
16
|
+
* Flexible input that accepts either an IdentityOnlyInstance or just the handlers.
|
|
17
|
+
*
|
|
18
|
+
* Allows both:
|
|
19
|
+
* - `toNextjsHandler(timeback)`
|
|
20
|
+
* - `toNextjsHandler(timeback.handle)`
|
|
21
|
+
*/
|
|
22
|
+
export type IdentityOnlyInput = IdentityOnlyInstance | IdentityOnlyHandlers;
|
|
23
|
+
/**
|
|
24
|
+
* Union of all valid inputs for adapters.
|
|
25
|
+
*
|
|
26
|
+
* Adapters accept either full Timeback instances or identity-only instances.
|
|
27
|
+
*/
|
|
28
|
+
export type AnyTimebackInput = TimebackInput | IdentityOnlyInput;
|
|
15
29
|
/**
|
|
16
30
|
* Next.js route handlers.
|
|
17
31
|
*/
|
|
@@ -69,8 +83,8 @@ export type ExpressLikeHandler = (req: ExpressLikeRequest, res: ExpressLikeRespo
|
|
|
69
83
|
* Options for the native handler.
|
|
70
84
|
*/
|
|
71
85
|
export interface NativeHandlerOptions {
|
|
72
|
-
/** Timeback instance or handlers */
|
|
73
|
-
timeback:
|
|
86
|
+
/** Timeback instance or handlers (full or identity-only) */
|
|
87
|
+
timeback: AnyTimebackInput;
|
|
74
88
|
/**
|
|
75
89
|
* Custom callback path for OAuth redirect.
|
|
76
90
|
*
|
|
@@ -96,8 +110,8 @@ export interface SvelteKitRequestEvent {
|
|
|
96
110
|
* Uses generics to properly type the resolve function with the actual SvelteKit event type.
|
|
97
111
|
*/
|
|
98
112
|
export interface SvelteKitHandlerOptions<TEvent extends SvelteKitRequestEvent = SvelteKitRequestEvent> {
|
|
99
|
-
/** Timeback instance or handlers */
|
|
100
|
-
timeback:
|
|
113
|
+
/** Timeback instance or handlers (full or identity-only) */
|
|
114
|
+
timeback: AnyTimebackInput;
|
|
101
115
|
/** SvelteKit request event */
|
|
102
116
|
event: TEvent;
|
|
103
117
|
/** SvelteKit resolve function */
|
|
@@ -145,8 +159,8 @@ export interface SolidStartEvent {
|
|
|
145
159
|
* Options for the SolidStart middleware handler.
|
|
146
160
|
*/
|
|
147
161
|
export interface SolidStartHandlerOptions {
|
|
148
|
-
/** Timeback instance or handlers */
|
|
149
|
-
timeback:
|
|
162
|
+
/** Timeback instance or handlers (full or identity-only) */
|
|
163
|
+
timeback: AnyTimebackInput;
|
|
150
164
|
/** SolidStart event containing the request */
|
|
151
165
|
event: SolidStartEvent;
|
|
152
166
|
/** Base path for Timeback routes (default: '/api/timeback') */
|
|
@@ -204,8 +218,8 @@ export interface TanStackStartHandlers {
|
|
|
204
218
|
* Options for the TanStack Start handler.
|
|
205
219
|
*/
|
|
206
220
|
export interface TanStackStartHandlerOptions {
|
|
207
|
-
/** Timeback instance or handlers */
|
|
208
|
-
timeback:
|
|
221
|
+
/** Timeback instance or handlers (full or identity-only) */
|
|
222
|
+
timeback: AnyTimebackInput;
|
|
209
223
|
/** Custom callback path for OAuth (if different from default) */
|
|
210
224
|
callbackPath?: string;
|
|
211
225
|
}
|
|
@@ -244,8 +258,8 @@ export interface NuxtLikeEvent {
|
|
|
244
258
|
* Options for the Nuxt middleware handler.
|
|
245
259
|
*/
|
|
246
260
|
export interface NuxtHandlerOptions<TEvent extends NuxtLikeEvent = NuxtLikeEvent> {
|
|
247
|
-
/** Timeback instance or handlers */
|
|
248
|
-
timeback:
|
|
261
|
+
/** Timeback instance or handlers (full or identity-only) */
|
|
262
|
+
timeback: AnyTimebackInput;
|
|
249
263
|
/** Nuxt/H3 event */
|
|
250
264
|
event: TEvent;
|
|
251
265
|
/** Base path for Timeback routes (default: '/api/timeback') */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,UAAU,CAAA;AAMjB;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,QAAQ,CAAA;AAEvD;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,oBAAoB,CAAA;AAE3E;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,iBAAiB,CAAA;AAMhE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACxC,IAAI,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACzC,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACxC,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC3C,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC1C;AASD;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAA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;;GASG;AACH,MAAM,WAAW,aAAa;IAC7B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kDAAkD;IAClD,IAAI,CAAC,EAAE;QACN,GAAG,EAAE,uBAAuB,CAAA;KAC5B,CAAA;IACD,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa;IAC/E,4DAA4D;IAC5D,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,kBAAkB,CAAA;IACvB,IAAI,EAAE,kBAAkB,CAAA;IACxB,GAAG,EAAE,kBAAkB,CAAA;IACvB,MAAM,EAAE,kBAAkB,CAAA;IAC1B,KAAK,EAAE,kBAAkB,CAAA;CACzB"}
|
|
@@ -3,13 +3,74 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Shared utilities for server framework adapters.
|
|
5
5
|
*/
|
|
6
|
-
import type { Handlers } from '../types';
|
|
7
|
-
import type {
|
|
6
|
+
import type { Handlers, IdentityOnlyHandlers } from '../types';
|
|
7
|
+
import type { AnyTimebackInput } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Union of handler types returned by getHandlers.
|
|
10
|
+
*/
|
|
11
|
+
type AnyHandlers = Handlers | IdentityOnlyHandlers;
|
|
12
|
+
/**
|
|
13
|
+
* A canonical route identifier for Timeback's built-in endpoints.
|
|
14
|
+
*/
|
|
15
|
+
type TimebackRouteId = 'identity.signIn' | 'identity.callback' | 'identity.signOut' | 'user.me' | 'activity';
|
|
16
|
+
/**
|
|
17
|
+
* Normalize a path-like string to a pathname only (no query string).
|
|
18
|
+
*
|
|
19
|
+
* Some frameworks may provide path-like values that include a query string
|
|
20
|
+
* (e.g. `/api/timeback/identity/signin?returnTo=/`). Route matching should
|
|
21
|
+
* operate on pathnames only.
|
|
22
|
+
*
|
|
23
|
+
* @param path - Path-like string (may include query string)
|
|
24
|
+
* @returns Pathname only (no query string)
|
|
25
|
+
*/
|
|
26
|
+
export declare function normalizePathname(path: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Attempt to map a request to a Timeback built-in route.
|
|
29
|
+
*
|
|
30
|
+
* This consolidates route matching logic so adapters don't each re-implement
|
|
31
|
+
* their own `endsWith(...)` chains.
|
|
32
|
+
*
|
|
33
|
+
* Matching strategy:
|
|
34
|
+
* - If `callbackPath` is provided and equals the request pathname, treat it as
|
|
35
|
+
* the identity callback route (GET only).
|
|
36
|
+
* - If `basePath` is provided, match *exactly* against `basePath + ROUTES.*`
|
|
37
|
+
* by stripping the base path and comparing the relative path.
|
|
38
|
+
* - If `basePath` is not provided, fall back to suffix matching (`endsWith`)
|
|
39
|
+
* to support catch-all mounts where the mount prefix isn't known.
|
|
40
|
+
*
|
|
41
|
+
* @param params - Matching inputs
|
|
42
|
+
* @param params.pathname - Request pathname (may include query string; will be normalized)
|
|
43
|
+
* @param params.method - HTTP method
|
|
44
|
+
* @param params.basePath - Optional base path (recommended when available)
|
|
45
|
+
* @param params.callbackPath - Optional custom callback path
|
|
46
|
+
* @returns A matched route id, or null if not a Timeback route
|
|
47
|
+
*/
|
|
48
|
+
export declare function matchTimebackRoute(params: {
|
|
49
|
+
pathname: string;
|
|
50
|
+
method: string;
|
|
51
|
+
basePath?: string;
|
|
52
|
+
callbackPath?: string;
|
|
53
|
+
}): TimebackRouteId | null;
|
|
8
54
|
/**
|
|
9
55
|
* Extract handlers from flexible input.
|
|
10
56
|
*
|
|
11
|
-
* @param input - TimebackInstance or
|
|
12
|
-
* @returns Handlers object
|
|
57
|
+
* @param input - TimebackInstance, IdentityOnlyInstance, or their handlers
|
|
58
|
+
* @returns Handlers object (full or identity-only)
|
|
59
|
+
*/
|
|
60
|
+
export declare function getHandlers(input: AnyTimebackInput): AnyHandlers;
|
|
61
|
+
/**
|
|
62
|
+
* Check if handlers include activity tracking (full SDK).
|
|
63
|
+
*
|
|
64
|
+
* @param handlers - Handlers to check
|
|
65
|
+
* @returns True if handlers include activity tracking
|
|
66
|
+
*/
|
|
67
|
+
export declare function hasActivityHandler(handlers: AnyHandlers): handlers is Handlers;
|
|
68
|
+
/**
|
|
69
|
+
* Check if handlers include user handlers (full SDK).
|
|
70
|
+
*
|
|
71
|
+
* @param handlers - Handlers to check
|
|
72
|
+
* @returns True if handlers include user handlers
|
|
13
73
|
*/
|
|
14
|
-
export declare function
|
|
74
|
+
export declare function hasUserHandler(handlers: AnyHandlers): handlers is Handlers;
|
|
75
|
+
export {};
|
|
15
76
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;GAEG;AACH,KAAK,WAAW,GAAG,QAAQ,GAAG,oBAAoB,CAAA;AAElD;;GAEG;AACH,KAAK,eAAe,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,GAClB,SAAS,GACT,UAAU,CAAA;AAEb;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBtD;AA8BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,eAAe,GAAG,IAAI,CAsDzB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,IAAI,QAAQ,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,QAAQ,IAAI,QAAQ,CAE1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/activity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAkCtF;;GAEG;AACH,UAAU,qBAAqB;IAC9B,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,SAAS,EAAE,SAAS,CAAA;IACpB,
|
|
1
|
+
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/activity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAkCtF;;GAEG;AACH,UAAU,qBAAqB;IAC9B,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;CACnB;AAED;;GAEG;AACH,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE1D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,CAuCpF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Handlers (full SDK)
|
|
3
|
+
*
|
|
4
|
+
* This module includes Timeback user resolution and therefore depends on Timeback API access.
|
|
5
|
+
*/
|
|
6
|
+
import type { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { ApiCredentials, Environment, IdentityConfig } from '../types';
|
|
8
|
+
type FullIdentityHandlerParams<TState = unknown> = {
|
|
9
|
+
env: Environment;
|
|
10
|
+
identity: IdentityConfig<TState>;
|
|
11
|
+
api: {
|
|
12
|
+
credentials: ApiCredentials;
|
|
13
|
+
getClient: () => TimebackClient;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Create identity route handlers (full SDK).
|
|
18
|
+
*
|
|
19
|
+
* @param params - Handler configuration
|
|
20
|
+
* @returns Identity handlers
|
|
21
|
+
*/
|
|
22
|
+
export declare function createIdentityHandlers<TState = unknown>(params: FullIdentityHandlerParams<TState>): {
|
|
23
|
+
signIn: (req: Request) => Promise<Response>;
|
|
24
|
+
callback: (req: Request) => Promise<Response>;
|
|
25
|
+
signOut: () => Response;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=identity-full.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-full.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/identity-full.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EACX,cAAc,EAGd,WAAW,EACX,cAAc,EAEd,MAAM,UAAU,CAAA;AAEjB,KAAK,yBAAyB,CAAC,MAAM,GAAG,OAAO,IAAI;IAClD,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;IAChC,GAAG,EAAE;QACJ,WAAW,EAAE,cAAc,CAAA;QAC3B,SAAS,EAAE,MAAM,cAAc,CAAA;KAC/B,CAAA;CACD,CAAA;AAwQD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,GAAG,OAAO,EACtD,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC,GACvC;IACF,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC3C,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC7C,OAAO,EAAE,MAAM,QAAQ,CAAA;CACvB,CAQA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Handlers (identity-only)
|
|
3
|
+
*
|
|
4
|
+
* This module is intentionally minimal and does NOT import Timeback API client code.
|
|
5
|
+
* It is safe to include in edge runtimes (e.g. Cloudflare Workers / workerd).
|
|
6
|
+
*/
|
|
7
|
+
import type { Environment, IdentityOnlyCallbackSuccessContext, SsoIdentityConfig } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Create identity route handlers (identity-only mode).
|
|
10
|
+
*
|
|
11
|
+
* @param params - Handler configuration
|
|
12
|
+
* @returns Identity-only handlers
|
|
13
|
+
*/
|
|
14
|
+
export declare function createIdentityOnlyHandlers<TState = unknown>(params: {
|
|
15
|
+
env: Environment;
|
|
16
|
+
identity: SsoIdentityConfig<TState, IdentityOnlyCallbackSuccessContext<TState>>;
|
|
17
|
+
}): {
|
|
18
|
+
signIn: (req: Request) => Promise<Response>;
|
|
19
|
+
callback: (req: Request) => Promise<Response>;
|
|
20
|
+
signOut: () => Response;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=identity-only.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-only.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/identity-only.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAEX,WAAW,EACX,kCAAkC,EAClC,iBAAiB,EACjB,MAAM,UAAU,CAAA;AAuPjB;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,EAAE;IACpE,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,iBAAiB,CAAC,MAAM,EAAE,kCAAkC,CAAC,MAAM,CAAC,CAAC,CAAA;CAC/E;;;;EAYA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Route handlers for Timeback server operations.
|
|
5
5
|
*/
|
|
6
|
-
export { createIdentityHandlers } from './identity';
|
|
6
|
+
export { createIdentityHandlers } from './identity-full';
|
|
7
7
|
export { createActivityHandler } from './activity';
|
|
8
8
|
export { createUserHandler } from './user';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/user.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE3E;;GAEG;AACH,UAAU,iBAAiB;IAC1B,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/user.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE3E;;GAEG;AACH,UAAU,iBAAiB;IAC1B,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;CACnB;AAED;;GAEG;AACH,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CA4BxE"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Server-side exports for the Timeback SDK.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export
|
|
8
|
-
export type { CallbackSuccessContext
|
|
9
|
-
export type { CallbackErrorContext as IdentityCallbackError } from './types';
|
|
6
|
+
export { createTimeback } from './timeback';
|
|
7
|
+
export { createTimebackIdentity } from './timeback-identity';
|
|
8
|
+
export type { TimebackConfig, TimebackInstance, Environment, ApiCredentials, IdentityConfig, SsoIdentityConfig, CustomIdentityConfig, Handlers, IdentityOnlyConfig, IdentityOnlyInstance, IdentityOnlyHandlers, BuildStateContext, CallbackSuccessContext, IdentityOnlyCallbackSuccessContext, CallbackErrorContext, OIDCTokens, OIDCUserInfo, IdpData, TimebackUserResolutionErrorCode, } from './types';
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,YAAY,EAEX,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,QAAQ,EAER,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EAEpB,iBAAiB,EACjB,sBAAsB,EACtB,kCAAkC,EAClC,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,OAAO,EAEP,+BAA+B,GAC/B,MAAM,SAAS,CAAA"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Internal utilities for the server SDK.
|
|
5
5
|
*/
|
|
6
6
|
export { getIssuer, buildAuthorizationUrl, exchangeCodeForTokens, getUserInfo } from './oidc';
|
|
7
|
-
export { jsonResponse, redirectResponse, encodeBase64Url, decodeBase64Url } from './utils';
|
|
7
|
+
export { jsonResponse, redirectResponse, encodeBase64Url, decodeBase64Url, mapEnvForApi, } from './utils';
|
|
8
8
|
export { ssoLog, oidcLog, createScopedLogger } from './logger';
|
|
9
|
+
export { resolveTimebackUserByEmail, TimebackUserResolutionError } from './resolve-timeback-user';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC7F,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC7F,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,GACZ,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC9D,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeback User Resolution
|
|
3
|
+
*
|
|
4
|
+
* Resolves the Timeback user by email using server credentials.
|
|
5
|
+
*/
|
|
6
|
+
import { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { TimebackAuthUser } from '../../shared/types';
|
|
8
|
+
import type { ApiCredentials, Environment, OIDCUserInfo, TimebackUserResolutionErrorCode } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when Timeback user resolution fails.
|
|
11
|
+
*/
|
|
12
|
+
export declare class TimebackUserResolutionError extends Error {
|
|
13
|
+
readonly code: TimebackUserResolutionErrorCode;
|
|
14
|
+
constructor(message: string, code: TimebackUserResolutionErrorCode);
|
|
15
|
+
}
|
|
16
|
+
interface ResolveTimebackUserByEmailParams {
|
|
17
|
+
/** Environment (staging/production) */
|
|
18
|
+
env: Environment;
|
|
19
|
+
/** API credentials for Timeback API */
|
|
20
|
+
apiCredentials: ApiCredentials;
|
|
21
|
+
/** OIDC user info from the IdP */
|
|
22
|
+
userInfo: OIDCUserInfo;
|
|
23
|
+
/**
|
|
24
|
+
* Optional pre-configured Timeback client to use (e.g. `timeback.api`).
|
|
25
|
+
*
|
|
26
|
+
* When provided, this function will use it and will NOT close it.
|
|
27
|
+
*/
|
|
28
|
+
client?: TimebackClient;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a TimebackAuthUser by looking up the Timeback user via email.
|
|
32
|
+
*
|
|
33
|
+
* Uses server API credentials to query OneRoster for a user matching the IdP email.
|
|
34
|
+
* Strict mode: fails if no user found or if multiple users match (ambiguous).
|
|
35
|
+
*
|
|
36
|
+
* @param params - Resolution parameters
|
|
37
|
+
* @returns Resolved TimebackAuthUser with Timeback profile and IdP claims
|
|
38
|
+
* @throws {TimebackUserResolutionError} If resolution fails
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveTimebackUserByEmail(params: ResolveTimebackUserByEmailParams): Promise<TimebackAuthUser>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=resolve-timeback-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-timeback-user.d.ts","sourceRoot":"","sources":["../../../src/server/lib/resolve-timeback-user.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAM/C,OAAO,KAAK,EAAkB,gBAAgB,EAAmB,MAAM,oBAAoB,CAAA;AAC3F,OAAO,KAAK,EACX,cAAc,EACd,WAAW,EACX,YAAY,EACZ,+BAA+B,EAC/B,MAAM,UAAU,CAAA;AAIjB;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;aAGpC,IAAI,EAAE,+BAA+B;IAFtD,YACC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,+BAA+B,EAIrD;CACD;AAED,UAAU,gCAAgC;IACzC,uCAAuC;IACvC,GAAG,EAAE,WAAW,CAAA;IAChB,uCAAuC;IACvC,cAAc,EAAE,cAAc,CAAA;IAC9B,kCAAkC;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;CACvB;AAkBD;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAC/C,MAAM,EAAE,gCAAgC,GACtC,OAAO,CAAC,gBAAgB,CAAC,CAiG3B"}
|
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Internal utility functions for the server SDK.
|
|
5
5
|
*/
|
|
6
|
+
import type { Environment } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Map SDK environment to the environment used for outbound Timeback API calls.
|
|
9
|
+
*
|
|
10
|
+
* The SDK's `env` config controls runtime mode, but for outbound service calls
|
|
11
|
+
* (OneRoster, Caliper, etc.) we need a real Timeback environment:
|
|
12
|
+
*
|
|
13
|
+
* - `local` → `staging` (local dev uses staging services)
|
|
14
|
+
* - `staging` → `staging`
|
|
15
|
+
* - `production` → `production`
|
|
16
|
+
*
|
|
17
|
+
* @param env - SDK environment setting
|
|
18
|
+
* @returns Environment to use for TimebackClient
|
|
19
|
+
*/
|
|
20
|
+
export declare function mapEnvForApi(env: Environment): 'staging' | 'production';
|
|
6
21
|
/**
|
|
7
22
|
* Create a JSON response.
|
|
8
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/server/lib/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,SAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAItF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAI7E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAIrD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAKrD"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/server/lib/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,CAMvE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,SAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAItF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,CAI7E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAIrD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAKrD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeback Server SDK (Identity-only)
|
|
3
|
+
*
|
|
4
|
+
* This file is intentionally Node-free so it can be used in edge runtimes
|
|
5
|
+
* (e.g. Cloudflare Workers / workerd) without pulling in Node-only deps
|
|
6
|
+
* like `jiti`, `fs`, etc.
|
|
7
|
+
*/
|
|
8
|
+
import type { IdentityOnlyConfig, IdentityOnlyInstance } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Create an identity-only Timeback server instance.
|
|
11
|
+
*
|
|
12
|
+
* Use this when you only need SSO authentication without activity tracking
|
|
13
|
+
* or Timeback API integration. Does not require `timeback.config.ts`.
|
|
14
|
+
*
|
|
15
|
+
* @param config - Identity-only configuration
|
|
16
|
+
* @returns Identity-only Timeback server instance
|
|
17
|
+
*/
|
|
18
|
+
export declare function createTimebackIdentity<TState = unknown>(config: IdentityOnlyConfig<TState>): IdentityOnlyInstance<TState>;
|
|
19
|
+
//# sourceMappingURL=timeback-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeback-identity.d.ts","sourceRoot":"","sources":["../../src/server/timeback-identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEvE;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,GAAG,OAAO,EACtD,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAChC,oBAAoB,CAAC,MAAM,CAAC,CAY9B"}
|
|
@@ -1,48 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Timeback Server SDK
|
|
3
3
|
*
|
|
4
|
-
* Factory
|
|
4
|
+
* Factory functions to create Timeback server instances.
|
|
5
5
|
*/
|
|
6
6
|
import type { TimebackConfig, TimebackInstance } from './types';
|
|
7
7
|
/**
|
|
8
8
|
* Create a Timeback server instance.
|
|
9
9
|
*
|
|
10
10
|
* Returns a framework-agnostic instance with raw handlers.
|
|
11
|
+
*
|
|
11
12
|
* Use an adapter to integrate with your framework:
|
|
12
13
|
* - `toNextjsHandler()` for Next.js App Router
|
|
13
14
|
* - `toHonoApp()` / `toHonoMiddleware()` for Hono
|
|
14
15
|
* - `toExpressMiddleware()` / `mountExpressRoutes()` for Express
|
|
15
16
|
*
|
|
17
|
+
* When using SSO mode, the callback receives an enriched `TimebackAuthUser` with
|
|
18
|
+
* `user.id` being the canonical Timeback user ID (timebackId).
|
|
19
|
+
*
|
|
16
20
|
* @param config - Server configuration
|
|
17
21
|
* @returns Timeback instance with handlers
|
|
18
22
|
*
|
|
19
|
-
* @example
|
|
23
|
+
* @example SSO mode
|
|
20
24
|
* ```typescript
|
|
21
|
-
* import {
|
|
25
|
+
* import { createTimeback } from 'timeback'
|
|
22
26
|
* import { toNextjsHandler } from 'timeback/nextjs'
|
|
23
27
|
*
|
|
24
|
-
* const timeback = await
|
|
28
|
+
* const timeback = await createTimeback({
|
|
25
29
|
* env: 'production',
|
|
26
30
|
* api: {
|
|
27
31
|
* clientId: process.env.TIMEBACK_API_CLIENT_ID!,
|
|
28
32
|
* clientSecret: process.env.TIMEBACK_API_CLIENT_SECRET!,
|
|
29
33
|
* },
|
|
30
34
|
* identity: {
|
|
31
|
-
* mode: '
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* }
|
|
35
|
+
* mode: 'sso',
|
|
36
|
+
* clientId: process.env.AWS_COGNITO_CLIENT_ID!,
|
|
37
|
+
* clientSecret: process.env.AWS_COGNITO_CLIENT_SECRET!,
|
|
38
|
+
* onCallbackSuccess: async ({ user, state, redirect }) => {
|
|
39
|
+
* // user.id is the timebackId (canonical stable identifier)
|
|
40
|
+
* await setSession({ id: user.id, email: user.email })
|
|
41
|
+
* return redirect(state.returnTo ?? '/')
|
|
39
42
|
* },
|
|
43
|
+
* onCallbackError: ({ error, redirect }) => redirect('/?error=sso_failed'),
|
|
44
|
+
* getUser: (req) => getSessionUser(req),
|
|
40
45
|
* },
|
|
41
46
|
* })
|
|
42
47
|
*
|
|
43
48
|
* // For Next.js App Router
|
|
44
49
|
* export const { GET, POST } = toNextjsHandler(timeback)
|
|
45
50
|
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example Custom identity mode (bring your own auth)
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const timeback = await createTimeback({
|
|
55
|
+
* env: 'production',
|
|
56
|
+
* api: { ... },
|
|
57
|
+
* identity: {
|
|
58
|
+
* mode: 'custom',
|
|
59
|
+
* getUser: async (req) => {
|
|
60
|
+
* const session = await getSession(req)
|
|
61
|
+
* return session ? { id: session.userId, email: session.email } : undefined
|
|
62
|
+
* },
|
|
63
|
+
* },
|
|
64
|
+
* })
|
|
65
|
+
* ```
|
|
46
66
|
*/
|
|
47
|
-
export declare function
|
|
67
|
+
export declare function createTimeback<TState = unknown>(config: TimebackConfig<TState>): Promise<TimebackInstance<TState>>;
|
|
48
68
|
//# sourceMappingURL=timeback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeback.d.ts","sourceRoot":"","sources":["../../src/server/timeback.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"timeback.d.ts","sourceRoot":"","sources":["../../src/server/timeback.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAsB,cAAc,CAAC,MAAM,GAAG,OAAO,EACpD,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAC5B,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAgEnC"}
|