@timeback/sdk 0.1.6 → 0.1.7
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/adapters/react/hooks/types.d.ts +15 -0
- package/dist/client/adapters/react/hooks/types.d.ts.map +1 -0
- package/dist/client/adapters/react/hooks/useTimebackVerification.d.ts +18 -0
- package/dist/client/adapters/react/hooks/useTimebackVerification.d.ts.map +1 -0
- package/dist/client/adapters/react/index.d.ts +2 -0
- package/dist/client/adapters/react/index.d.ts.map +1 -1
- package/dist/client/adapters/react/index.js +139 -9
- package/dist/client/auth/bearer.d.ts +17 -0
- package/dist/client/auth/bearer.d.ts.map +1 -0
- package/dist/client/auth/index.d.ts +3 -0
- package/dist/client/auth/index.d.ts.map +1 -0
- package/dist/client/auth/types.d.ts +39 -0
- package/dist/client/auth/types.d.ts.map +1 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/lib/fetch.d.ts +19 -0
- package/dist/client/lib/fetch.d.ts.map +1 -0
- package/dist/client/namespaces/user.d.ts +25 -2
- package/dist/client/namespaces/user.d.ts.map +1 -1
- package/dist/client/timeback-client.class.d.ts +15 -0
- package/dist/client/timeback-client.class.d.ts.map +1 -1
- package/dist/client/timeback-client.d.ts +3 -0
- package/dist/client/timeback-client.d.ts.map +1 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +69 -6
- package/dist/edge.js +85291 -169
- package/dist/identity.js +85186 -74
- package/dist/index.js +773 -493
- package/dist/server/adapters/express.d.ts.map +1 -1
- package/dist/server/adapters/express.js +169 -193
- package/dist/server/adapters/native.d.ts.map +1 -1
- package/dist/server/adapters/native.js +32 -1
- package/dist/server/adapters/nextjs.js +32 -1
- package/dist/server/adapters/nuxt.d.ts.map +1 -1
- package/dist/server/adapters/nuxt.js +173 -193
- package/dist/server/adapters/solid-start.d.ts.map +1 -1
- package/dist/server/adapters/solid-start.js +173 -193
- package/dist/server/adapters/svelte-kit.d.ts.map +1 -1
- package/dist/server/adapters/svelte-kit.js +37 -1
- package/dist/server/adapters/tanstack-start.d.ts.map +1 -1
- package/dist/server/adapters/tanstack-start.js +168 -193
- package/dist/server/adapters/utils.d.ts +1 -1
- package/dist/server/adapters/utils.d.ts.map +1 -1
- package/dist/server/{lib/build-activity-events.d.ts → handlers/activity/caliper.d.ts} +29 -4
- package/dist/server/handlers/activity/caliper.d.ts.map +1 -0
- package/dist/server/handlers/activity/gradebook.d.ts +56 -0
- package/dist/server/handlers/activity/gradebook.d.ts.map +1 -0
- package/dist/server/handlers/activity/handler.d.ts +15 -0
- package/dist/server/handlers/activity/handler.d.ts.map +1 -0
- package/dist/server/handlers/activity/index.d.ts +9 -0
- package/dist/server/handlers/activity/index.d.ts.map +1 -0
- package/dist/server/handlers/activity/resolve.d.ts +39 -0
- package/dist/server/handlers/activity/resolve.d.ts.map +1 -0
- package/dist/server/handlers/activity/schema.d.ts +52 -0
- package/dist/server/handlers/activity/schema.d.ts.map +1 -0
- package/dist/server/handlers/activity/types.d.ts +52 -0
- package/dist/server/handlers/activity/types.d.ts.map +1 -0
- package/dist/server/handlers/identity/handler.d.ts +14 -0
- package/dist/server/handlers/identity/handler.d.ts.map +1 -0
- package/dist/server/handlers/identity/index.d.ts +8 -0
- package/dist/server/handlers/identity/index.d.ts.map +1 -0
- package/dist/server/handlers/identity/oidc.d.ts +43 -0
- package/dist/server/handlers/identity/oidc.d.ts.map +1 -0
- package/dist/server/handlers/identity/types.d.ts +24 -0
- package/dist/server/handlers/identity/types.d.ts.map +1 -0
- package/dist/server/handlers/identity-only/handler.d.ts +15 -0
- package/dist/server/handlers/identity-only/handler.d.ts.map +1 -0
- package/dist/server/handlers/identity-only/index.d.ts +8 -0
- package/dist/server/handlers/identity-only/index.d.ts.map +1 -0
- package/dist/server/handlers/identity-only/oidc.d.ts +26 -0
- package/dist/server/handlers/identity-only/oidc.d.ts.map +1 -0
- package/dist/server/handlers/identity-only/types.d.ts +19 -0
- package/dist/server/handlers/identity-only/types.d.ts.map +1 -0
- package/dist/server/handlers/index.d.ts +5 -2
- package/dist/server/handlers/index.d.ts.map +1 -1
- package/dist/server/{lib/build-user-profile.d.ts → handlers/user/enrollments.d.ts} +7 -2
- package/dist/server/handlers/user/enrollments.d.ts.map +1 -0
- package/dist/server/handlers/user/handler.d.ts +17 -0
- package/dist/server/handlers/user/handler.d.ts.map +1 -0
- package/dist/server/handlers/user/index.d.ts +10 -0
- package/dist/server/handlers/user/index.d.ts.map +1 -0
- package/dist/server/handlers/user/profile.d.ts +22 -0
- package/dist/server/handlers/user/profile.d.ts.map +1 -0
- package/dist/server/handlers/user/types.d.ts +35 -0
- package/dist/server/handlers/user/types.d.ts.map +1 -0
- package/dist/server/handlers/user/verify.d.ts +25 -0
- package/dist/server/handlers/user/verify.d.ts.map +1 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/lib/index.d.ts +4 -5
- package/dist/server/lib/index.d.ts.map +1 -1
- package/dist/server/lib/resolve.d.ts +4 -42
- package/dist/server/lib/resolve.d.ts.map +1 -1
- package/dist/server/lib/sso.d.ts +86 -0
- package/dist/server/lib/sso.d.ts.map +1 -0
- package/dist/server/lib/utils.d.ts +32 -1
- package/dist/server/lib/utils.d.ts.map +1 -1
- package/dist/server/timeback-identity.d.ts.map +1 -1
- package/dist/server/timeback.d.ts.map +1 -1
- package/dist/server/types.d.ts +16 -9
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shared/constants.d.ts +1 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/types.d.ts +15 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/package.json +6 -2
- package/dist/server/handlers/activity.d.ts +0 -25
- package/dist/server/handlers/activity.d.ts.map +0 -1
- package/dist/server/handlers/identity-full.d.ts +0 -28
- package/dist/server/handlers/identity-full.d.ts.map +0 -1
- package/dist/server/handlers/identity-only.d.ts +0 -22
- package/dist/server/handlers/identity-only.d.ts.map +0 -1
- package/dist/server/handlers/user.d.ts +0 -31
- package/dist/server/handlers/user.d.ts.map +0 -1
- package/dist/server/lib/build-activity-events.d.ts.map +0 -1
- package/dist/server/lib/build-user-profile.d.ts.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity Handler Schema
|
|
3
|
+
*
|
|
4
|
+
* Zod schemas and validation logic for activity submissions.
|
|
5
|
+
*/
|
|
6
|
+
import * as z from 'zod';
|
|
7
|
+
import type { AppConfig, Environment } from '../../types';
|
|
8
|
+
import type { ValidationResult } from './types';
|
|
9
|
+
/** Zod schema for validating activity payloads. */
|
|
10
|
+
export declare const activityPayloadSchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
course: z.ZodUnion<readonly [z.ZodObject<{
|
|
14
|
+
subject: z.ZodEnum<{
|
|
15
|
+
FastMath: "FastMath";
|
|
16
|
+
Language: "Language";
|
|
17
|
+
Math: "Math";
|
|
18
|
+
None: "None";
|
|
19
|
+
Other: "Other";
|
|
20
|
+
Reading: "Reading";
|
|
21
|
+
Science: "Science";
|
|
22
|
+
"Social Studies": "Social Studies";
|
|
23
|
+
Vocabulary: "Vocabulary";
|
|
24
|
+
Writing: "Writing";
|
|
25
|
+
}>;
|
|
26
|
+
grade: z.ZodUnion<readonly [z.ZodLiteral<-1>, z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>, z.ZodLiteral<8>, z.ZodLiteral<9>, z.ZodLiteral<10>, z.ZodLiteral<11>, z.ZodLiteral<12>, z.ZodLiteral<13>]>;
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
|
+
code: z.ZodString;
|
|
29
|
+
}, z.core.$strip>]>;
|
|
30
|
+
startedAt: z.ZodISODateTime;
|
|
31
|
+
endedAt: z.ZodISODateTime;
|
|
32
|
+
elapsedMs: z.ZodNumber;
|
|
33
|
+
pausedMs: z.ZodNumber;
|
|
34
|
+
metrics: z.ZodObject<{
|
|
35
|
+
totalQuestions: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
correctQuestions: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
xpEarned: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
masteredUnits: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
attemptNumber: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
pctCompleteApp: z.ZodPipe<z.ZodOptional<z.ZodNumber>, z.ZodTransform<number | undefined, number | undefined>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
/**
|
|
44
|
+
* Validate the activity request body and resolve config dependencies.
|
|
45
|
+
*
|
|
46
|
+
* @param body - Raw request body
|
|
47
|
+
* @param appConfig - App configuration
|
|
48
|
+
* @param env - Environment
|
|
49
|
+
* @returns Validated data or error response
|
|
50
|
+
*/
|
|
51
|
+
export declare function validateActivityRequest(body: unknown, appConfig: AppConfig, env: Environment): ValidationResult;
|
|
52
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/activity/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAUxB,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AA0C/C,mDAAmD;AACnD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAchC,CAAA;AAmBF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,WAAW,GACd,gBAAgB,CAoElB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity Handler Types
|
|
3
|
+
*
|
|
4
|
+
* Feature-local types for the activity submission flow.
|
|
5
|
+
*/
|
|
6
|
+
import type { ActivityCourseRef } from '../../../shared/types';
|
|
7
|
+
import type { ApiCredentials, AppConfig, Environment, IdentityConfig, TimebackConfig } from '../../types';
|
|
8
|
+
/** User identity info needed for activity submission. */
|
|
9
|
+
export interface ActivityUserInfo {
|
|
10
|
+
email: string;
|
|
11
|
+
/** Timeback ID if already resolved (SSO mode). When present, skip lookup. */
|
|
12
|
+
timebackId?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Validated activity payload ready for submission. */
|
|
15
|
+
export interface ValidatedActivityPayload {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
course: ActivityCourseRef;
|
|
19
|
+
startedAt: string;
|
|
20
|
+
endedAt: string;
|
|
21
|
+
elapsedMs: number;
|
|
22
|
+
pausedMs: number;
|
|
23
|
+
metrics: {
|
|
24
|
+
totalQuestions?: number;
|
|
25
|
+
correctQuestions?: number;
|
|
26
|
+
xpEarned?: number;
|
|
27
|
+
masteredUnits?: number;
|
|
28
|
+
};
|
|
29
|
+
attemptNumber?: number;
|
|
30
|
+
pctCompleteApp?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Result of request validation - either valid data or an error response. */
|
|
33
|
+
export type ValidationResult = {
|
|
34
|
+
ok: true;
|
|
35
|
+
payload: ValidatedActivityPayload;
|
|
36
|
+
course: AppConfig['courses'][number];
|
|
37
|
+
sensor: string;
|
|
38
|
+
} | {
|
|
39
|
+
ok: false;
|
|
40
|
+
response: Response;
|
|
41
|
+
};
|
|
42
|
+
/** Configuration for the activity handler. */
|
|
43
|
+
export interface ActivityHandlerConfig {
|
|
44
|
+
env: Environment;
|
|
45
|
+
identity: IdentityConfig;
|
|
46
|
+
appConfig: AppConfig;
|
|
47
|
+
api: ApiCredentials;
|
|
48
|
+
hooks?: TimebackConfig['hooks'];
|
|
49
|
+
}
|
|
50
|
+
/** Activity handler type. */
|
|
51
|
+
export type ActivityHandler = (req: Request) => Promise<Response>;
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/activity/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,KAAK,EACX,cAAc,EACd,SAAS,EACT,WAAW,EACX,cAAc,EACd,cAAc,EACd,MAAM,aAAa,CAAA;AAMpB,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAMD,uDAAuD;AACvD,MAAM,WAAW,wBAAwB;IACxC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,iBAAiB,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,aAAa,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;CACvB;AAMD,6EAA6E;AAC7E,MAAM,MAAM,gBAAgB,GACzB;IACA,EAAE,EAAE,IAAI,CAAA;IACR,OAAO,EAAE,wBAAwB,CAAA;IACjC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;IACpC,MAAM,EAAE,MAAM,CAAA;CACb,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAA;AAMpC,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACrC,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;CAC/B;AAED,6BAA6B;AAC7B,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { IdentityHandlerParams, IdentityHandlers } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Create identity route handlers (full SDK).
|
|
9
|
+
*
|
|
10
|
+
* @param params - Handler configuration
|
|
11
|
+
* @returns Identity handlers
|
|
12
|
+
*/
|
|
13
|
+
export declare function createIdentityHandlers<TState = unknown>(params: IdentityHandlerParams<TState>): IdentityHandlers;
|
|
14
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAEtE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,GAAG,OAAO,EACtD,MAAM,EAAE,qBAAqB,CAAC,MAAM,CAAC,GACnC,gBAAgB,CAQlB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Handler (full SDK)
|
|
3
|
+
*
|
|
4
|
+
* Route handlers for SSO authentication with Timeback user resolution.
|
|
5
|
+
*/
|
|
6
|
+
export { createIdentityHandlers } from './handler';
|
|
7
|
+
export type { IdentityHandlerParams, IdentityHandlers } from './types';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAClD,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity OIDC Flow
|
|
3
|
+
*
|
|
4
|
+
* Sign-in, callback, and token exchange for SSO authentication.
|
|
5
|
+
* This is the full SDK version that resolves Timeback users.
|
|
6
|
+
*/
|
|
7
|
+
import type { Environment, IdentityConfig } from '../../types';
|
|
8
|
+
import type { IdentityHandlerParams } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Handle sign-in request.
|
|
11
|
+
*
|
|
12
|
+
* @param req - Incoming request
|
|
13
|
+
* @param env - Environment configuration
|
|
14
|
+
* @param identity - Identity configuration
|
|
15
|
+
* @returns Redirect response to IdP
|
|
16
|
+
*/
|
|
17
|
+
export declare function handleSignIn<TState>(req: Request, env: Environment, identity: IdentityConfig<TState>): Promise<Response>;
|
|
18
|
+
/**
|
|
19
|
+
* Exchange code for tokens and complete SSO flow (full SDK).
|
|
20
|
+
*
|
|
21
|
+
* @param code - Authorization code
|
|
22
|
+
* @param url - Callback URL
|
|
23
|
+
* @param state - Decoded state (if provided)
|
|
24
|
+
* @param req - Incoming request
|
|
25
|
+
* @param env - Environment configuration
|
|
26
|
+
* @param identity - SSO identity configuration
|
|
27
|
+
* @param api - Timeback API provider (credentials + shared client getter)
|
|
28
|
+
* @returns Success or error response
|
|
29
|
+
*/
|
|
30
|
+
export declare function completeCallback<TState>(code: string, url: URL, state: TState | undefined, req: Request, env: Environment, identity: IdentityConfig<TState> & {
|
|
31
|
+
mode: 'sso';
|
|
32
|
+
}, api: IdentityHandlerParams<TState>['api']): Promise<Response>;
|
|
33
|
+
/**
|
|
34
|
+
* Handle callback request.
|
|
35
|
+
*
|
|
36
|
+
* @param req - Incoming request
|
|
37
|
+
* @param env - Environment configuration
|
|
38
|
+
* @param identity - Identity configuration
|
|
39
|
+
* @param api - Timeback API provider (credentials + shared client getter)
|
|
40
|
+
* @returns Response from callback handler
|
|
41
|
+
*/
|
|
42
|
+
export declare function handleCallback<TState>(req: Request, env: Environment, identity: IdentityConfig<TState>, api: IdentityHandlerParams<TState>['api']): Promise<Response>;
|
|
43
|
+
//# sourceMappingURL=oidc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oidc.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity/oidc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,OAAO,KAAK,EAA0B,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAMpD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,MAAM,EACxC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,GAC9B,OAAO,CAAC,QAAQ,CAAC,CAcnB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAC5C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,EAClD,GAAG,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CA0DnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAC1C,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,EAChC,GAAG,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAiBnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Handler Types (full SDK)
|
|
3
|
+
*
|
|
4
|
+
* Feature-local types for the identity/SSO handlers.
|
|
5
|
+
*/
|
|
6
|
+
import type { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { ApiCredentials, CallbackErrorContext, CallbackSuccessContext, Environment, IdentityConfig, SsoIdentityConfig } from '../../types';
|
|
8
|
+
/** Configuration for identity handlers (full SDK). */
|
|
9
|
+
export interface IdentityHandlerParams<TState = unknown> {
|
|
10
|
+
env: Environment;
|
|
11
|
+
identity: IdentityConfig<TState>;
|
|
12
|
+
api: {
|
|
13
|
+
credentials: ApiCredentials;
|
|
14
|
+
getClient: () => TimebackClient;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Identity handlers returned by createIdentityHandlers. */
|
|
18
|
+
export interface IdentityHandlers {
|
|
19
|
+
signIn: (req: Request) => Promise<Response>;
|
|
20
|
+
callback: (req: Request) => Promise<Response>;
|
|
21
|
+
signOut: () => Response;
|
|
22
|
+
}
|
|
23
|
+
export type { CallbackErrorContext, CallbackSuccessContext, Environment, IdentityConfig, SsoIdentityConfig, };
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EACX,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,MAAM,aAAa,CAAA;AAEpB,sDAAsD;AACtD,MAAM,WAAW,qBAAqB,CAAC,MAAM,GAAG,OAAO;IACtD,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;AAED,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAChC,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;AAGD,YAAY,EACX,oBAAoB,EACpB,sBAAsB,EACtB,WAAW,EACX,cAAc,EACd,iBAAiB,GACjB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity-Only Handlers
|
|
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 { IdentityOnlyHandlerParams, IdentityOnlyHandlers } 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: IdentityOnlyHandlerParams<TState>): IdentityOnlyHandlers;
|
|
15
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity-only/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE9E;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,GAAG,OAAO,EAC1D,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC,GACvC,oBAAoB,CAYtB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity-Only Handler
|
|
3
|
+
*
|
|
4
|
+
* Route handlers for SSO authentication without Timeback user resolution (edge-safe).
|
|
5
|
+
*/
|
|
6
|
+
export { createIdentityOnlyHandlers } from './handler';
|
|
7
|
+
export type { IdentityOnlyHandlerParams, IdentityOnlyHandlers } from './types';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity-only/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACtD,YAAY,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity-Only OIDC Flow
|
|
3
|
+
*
|
|
4
|
+
* Sign-in, callback, and token exchange for SSO authentication (edge-safe).
|
|
5
|
+
* This module is intentionally minimal and does NOT import Timeback API client code.
|
|
6
|
+
*/
|
|
7
|
+
import type { Environment, IdentityOnlyCallbackSuccessContext, SsoIdentityConfig } from '../../types';
|
|
8
|
+
/**
|
|
9
|
+
* Handle sign-in request.
|
|
10
|
+
*
|
|
11
|
+
* @param req - Incoming request
|
|
12
|
+
* @param env - Environment configuration
|
|
13
|
+
* @param identity - Identity-only SSO configuration
|
|
14
|
+
* @returns Redirect response to IdP
|
|
15
|
+
*/
|
|
16
|
+
export declare function handleSignIn<TState>(req: Request, env: Environment, identity: SsoIdentityConfig<TState, IdentityOnlyCallbackSuccessContext<TState>>): Promise<Response>;
|
|
17
|
+
/**
|
|
18
|
+
* Handle callback request for identity-only mode.
|
|
19
|
+
*
|
|
20
|
+
* @param req - Incoming request
|
|
21
|
+
* @param env - Environment configuration
|
|
22
|
+
* @param identity - Identity-only SSO configuration
|
|
23
|
+
* @returns Response from callback handler
|
|
24
|
+
*/
|
|
25
|
+
export declare function handleCallback<TState>(req: Request, env: Environment, identity: SsoIdentityConfig<TState, IdentityOnlyCallbackSuccessContext<TState>>): Promise<Response>;
|
|
26
|
+
//# sourceMappingURL=oidc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oidc.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity-only/oidc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EACX,WAAW,EACX,kCAAkC,EAClC,iBAAiB,EACjB,MAAM,aAAa,CAAA;AAMpB;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,MAAM,EACxC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,iBAAiB,CAAC,MAAM,EAAE,kCAAkC,CAAC,MAAM,CAAC,CAAC,GAC7E,OAAO,CAAC,QAAQ,CAAC,CASnB;AA4ED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAC1C,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,iBAAiB,CAAC,MAAM,EAAE,kCAAkC,CAAC,MAAM,CAAC,CAAC,GAC7E,OAAO,CAAC,QAAQ,CAAC,CAYnB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity-Only Handler Types
|
|
3
|
+
*
|
|
4
|
+
* Feature-local types for identity-only SSO handlers (edge-safe).
|
|
5
|
+
*/
|
|
6
|
+
import type { CallbackErrorContext, Environment, IdentityOnlyCallbackSuccessContext, SsoIdentityConfig } from '../../types';
|
|
7
|
+
/** Configuration for identity-only handlers. */
|
|
8
|
+
export interface IdentityOnlyHandlerParams<TState = unknown> {
|
|
9
|
+
env: Environment;
|
|
10
|
+
identity: SsoIdentityConfig<TState, IdentityOnlyCallbackSuccessContext<TState>>;
|
|
11
|
+
}
|
|
12
|
+
/** Identity-only handlers returned by createIdentityOnlyHandlers. */
|
|
13
|
+
export interface IdentityOnlyHandlers {
|
|
14
|
+
signIn: (req: Request) => Promise<Response>;
|
|
15
|
+
callback: (req: Request) => Promise<Response>;
|
|
16
|
+
signOut: () => Response;
|
|
17
|
+
}
|
|
18
|
+
export type { CallbackErrorContext, Environment, IdentityOnlyCallbackSuccessContext, SsoIdentityConfig, };
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/identity-only/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,oBAAoB,EACpB,WAAW,EACX,kCAAkC,EAClC,iBAAiB,EACjB,MAAM,aAAa,CAAA;AAEpB,gDAAgD;AAChD,MAAM,WAAW,yBAAyB,CAAC,MAAM,GAAG,OAAO;IAC1D,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,iBAAiB,CAAC,MAAM,EAAE,kCAAkC,CAAC,MAAM,CAAC,CAAC,CAAA;CAC/E;AAED,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACpC,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;AAGD,YAAY,EACX,oBAAoB,EACpB,WAAW,EACX,kCAAkC,EAClC,iBAAiB,GACjB,CAAA"}
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Route handlers for Timeback server operations.
|
|
5
5
|
*/
|
|
6
|
-
export { createIdentityHandlers } from './identity-full';
|
|
7
6
|
export { createActivityHandler } from './activity';
|
|
8
|
-
export {
|
|
7
|
+
export { createIdentityHandlers } from './identity';
|
|
8
|
+
export { createUserHandler, createUserVerifyHandler } from './user';
|
|
9
|
+
export type { ActivityHandler, ActivityHandlerConfig } from './activity';
|
|
10
|
+
export type { IdentityHandlerParams, IdentityHandlers } from './identity';
|
|
11
|
+
export type { UserHandler, UserHandlerConfig, UserVerifyHandler, UserVerifyHandlerConfig } from './user';
|
|
9
12
|
//# 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,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAA;AAEnE,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACxE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACzE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* User Enrollment Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helpers for processing enrollments and building profile data.
|
|
5
|
+
*/
|
|
6
|
+
import type { AppConfig } from '../../types';
|
|
2
7
|
type EnrollmentGoals = NonNullable<AppConfig['courses'][number]['metadata']>['goals'];
|
|
3
8
|
type EnrollmentLike = {
|
|
4
9
|
course: {
|
|
@@ -59,4 +64,4 @@ export declare function getUtcDayRange(date: Date): {
|
|
|
59
64
|
*/
|
|
60
65
|
export declare function sumXp(facts: ActivityFacts): number;
|
|
61
66
|
export {};
|
|
62
|
-
//# sourceMappingURL=
|
|
67
|
+
//# sourceMappingURL=enrollments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrollments.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/user/enrollments.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,KAAK,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;AAErF,KAAK,cAAc,GAAG;IACrB,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACrC,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,eAAe,CAAA;KAAE,CAAA;CACtC,CAAA;AAED,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,eAAe,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CAAC,CAAA;AAEhG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,EAC7B,MAAM,EAAE,SAAS,GAAG,YAAY,GAC9B,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAW3C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,WAAW,EAAE,cAAc,EAAE,EAC7B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GACnD,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAUnD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,WAAW,EAAE,cAAc,EAAE,GAC3B,eAAe,GAAG,SAAS,CAE7B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,CAQrE;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CASlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Handler
|
|
3
|
+
*
|
|
4
|
+
* HTTP route handler for user profile data.
|
|
5
|
+
*/
|
|
6
|
+
import type { UserHandler, UserHandlerConfig } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Create the user profile handler.
|
|
9
|
+
*
|
|
10
|
+
* Returns the current user's profile, including identity and enriched data
|
|
11
|
+
* from the Timeback API.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Handler configuration
|
|
14
|
+
* @returns The user profile request handler
|
|
15
|
+
*/
|
|
16
|
+
export declare function createUserHandler(config: UserHandlerConfig): UserHandler;
|
|
17
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/user/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AA6C7D;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW,CAiDxE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Handler
|
|
3
|
+
*
|
|
4
|
+
* Route handler for user profile data.
|
|
5
|
+
*/
|
|
6
|
+
export { createUserHandler } from './handler';
|
|
7
|
+
export { createUserVerifyHandler } from './verify';
|
|
8
|
+
export { buildUserProfile } from './profile';
|
|
9
|
+
export type { ResolvedUser, UserHandler, UserHandlerConfig, UserVerifyHandler, UserVerifyHandlerConfig, } from './types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/user/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,YAAY,EACX,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,GACvB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Profile Building
|
|
3
|
+
*
|
|
4
|
+
* Utilities for building enriched user profile data.
|
|
5
|
+
*/
|
|
6
|
+
import type { TimebackClient } from '@timeback/core';
|
|
7
|
+
import type { TimebackProfile } from '../../../shared/types';
|
|
8
|
+
import type { AppConfig } from '../../types';
|
|
9
|
+
import type { ResolvedUser } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Build enriched user profile from Timeback data.
|
|
12
|
+
*
|
|
13
|
+
* Fetches enrollments and analytics to build a complete profile.
|
|
14
|
+
*
|
|
15
|
+
* @param client - Timeback API client
|
|
16
|
+
* @param user - Resolved user info
|
|
17
|
+
* @param appConfig - App configuration
|
|
18
|
+
* @param apiEnv - API environment
|
|
19
|
+
* @returns Enriched user profile
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildUserProfile(client: TimebackClient, user: ResolvedUser, appConfig: AppConfig, apiEnv: 'staging' | 'production'): Promise<TimebackProfile>;
|
|
22
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/user/profile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAQ5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACrC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,SAAS,GAAG,YAAY,GAC9B,OAAO,CAAC,eAAe,CAAC,CAoC1B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Handler Types
|
|
3
|
+
*
|
|
4
|
+
* Feature-local types for the user profile handler.
|
|
5
|
+
*/
|
|
6
|
+
import type { ApiCredentials, AppConfig, Environment, IdentityConfig } from '../../types';
|
|
7
|
+
/** Configuration for the user handler. */
|
|
8
|
+
export interface UserHandlerConfig {
|
|
9
|
+
env: Environment;
|
|
10
|
+
identity: IdentityConfig;
|
|
11
|
+
api: ApiCredentials;
|
|
12
|
+
appConfig: AppConfig;
|
|
13
|
+
}
|
|
14
|
+
/** User handler type. */
|
|
15
|
+
export type UserHandler = (req: Request) => Promise<Response>;
|
|
16
|
+
/** Configuration for the user verify handler. */
|
|
17
|
+
export interface UserVerifyHandlerConfig {
|
|
18
|
+
env: Environment;
|
|
19
|
+
identity: IdentityConfig;
|
|
20
|
+
api: ApiCredentials;
|
|
21
|
+
}
|
|
22
|
+
/** User verify handler type. */
|
|
23
|
+
export type UserVerifyHandler = (req: Request) => Promise<Response>;
|
|
24
|
+
/** Resolved Timeback user info. */
|
|
25
|
+
export interface ResolvedUser {
|
|
26
|
+
id: string;
|
|
27
|
+
email: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
school?: {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
33
|
+
grade?: number;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/user/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEzF,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,SAAS,EAAE,SAAS,CAAA;CACpB;AAED,yBAAyB;AACzB,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE7D,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACvC,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;CACnB;AAED,gCAAgC;AAChC,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEnE,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Verify Handler
|
|
3
|
+
*
|
|
4
|
+
* Lightweight endpoint to check whether the current user can be resolved in Timeback.
|
|
5
|
+
*
|
|
6
|
+
* This is intentionally cheaper than `/user/me`:
|
|
7
|
+
* - In custom identity mode, it resolves the Timeback user by email
|
|
8
|
+
* - In SSO mode, it expects your app session to provide the Timeback identity via `getUser()`
|
|
9
|
+
* - It does NOT fetch enrollments/analytics or build an enriched profile
|
|
10
|
+
*/
|
|
11
|
+
import type { UserVerifyHandler, UserVerifyHandlerConfig } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Create the user verification handler.
|
|
14
|
+
*
|
|
15
|
+
* Returns:
|
|
16
|
+
* - `200 { verified: true, timebackId: "..." }` when the user can be resolved
|
|
17
|
+
* - `200 { verified: false }` when the user does not exist in Timeback
|
|
18
|
+
* - `401` when the request is not authenticated
|
|
19
|
+
* - `409` when the user resolution is ambiguous
|
|
20
|
+
*
|
|
21
|
+
* @param config - Handler configuration
|
|
22
|
+
* @returns Verify handler
|
|
23
|
+
*/
|
|
24
|
+
export declare function createUserVerifyHandler(config: UserVerifyHandlerConfig): UserVerifyHandler;
|
|
25
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/server/handlers/user/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AA0BzE;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,iBAAiB,CA0D1F"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { createTimeback } from './timeback';
|
|
7
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';
|
|
8
|
+
export type { TimebackConfig, TimebackInstance, Environment, EnvironmentInput, ApiCredentials, IdentityConfig, SsoIdentityConfig, CustomIdentityConfig, Handlers, IdentityOnlyConfig, IdentityOnlyInstance, IdentityOnlyHandlers, BuildStateContext, CallbackSuccessContext, IdentityOnlyCallbackSuccessContext, CallbackErrorContext, OIDCTokens, OIDCUserInfo, IdpData, TimebackUserResolutionErrorCode, } from './types';
|
|
9
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,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"}
|
|
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,gBAAgB,EAChB,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"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server Library
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Shared utilities for the server SDK.
|
|
5
5
|
*/
|
|
6
6
|
export { getIssuer, buildAuthorizationUrl, exchangeCodeForTokens, getUserInfo } from './oidc';
|
|
7
|
-
export { jsonResponse, redirectResponse, encodeBase64Url, decodeBase64Url, mapEnvForApi, } from './utils';
|
|
7
|
+
export { jsonResponse, redirectResponse, encodeBase64Url, decodeBase64Url, mapEnvForApi, normalizeEnv, safeIdSegment, hashSuffix64Base36, } from './utils';
|
|
8
8
|
export { ssoLog, oidcLog, createScopedLogger } from './logger';
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export { buildCourseLookup, getUtcDayRange, mapEnrollmentsToCourses, pickGoalsFromEnrollments, sumXp, } from './build-user-profile';
|
|
9
|
+
export { lookupTimebackIdByEmail, resolveStatusForUserResolutionError, resolveTimebackUserByEmail, TimebackUserResolutionError, } from './resolve';
|
|
10
|
+
export { buildErrorContext, computeRedirectUri, handleIdpError, handleMissingCode, initiateSignIn, parseCallback, tryDecodeState, } from './sso';
|
|
12
11
|
//# 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,EACN,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,
|
|
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,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,GAClB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC9D,OAAO,EACN,uBAAuB,EACvB,mCAAmC,EACnC,0BAA0B,EAC1B,2BAA2B,GAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,GACd,MAAM,OAAO,CAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolution Utilities
|
|
2
|
+
* User Resolution Utilities
|
|
3
3
|
*
|
|
4
|
-
* Functions for resolving Timeback users
|
|
5
|
-
*
|
|
6
|
-
* ## User Resolution
|
|
4
|
+
* Functions for resolving Timeback users by email.
|
|
7
5
|
*
|
|
8
6
|
* - `resolveTimebackUserByEmail` — Full user resolution returning profile + IdP claims.
|
|
9
7
|
* Used by SSO callback to build the authenticated user object.
|
|
@@ -13,15 +11,10 @@
|
|
|
13
11
|
*
|
|
14
12
|
* - `resolveStatusForUserResolutionError` — Maps error codes to HTTP status.
|
|
15
13
|
* Used by handlers to return appropriate status codes on resolution failure.
|
|
16
|
-
*
|
|
17
|
-
* ## Course Resolution
|
|
18
|
-
*
|
|
19
|
-
* - `resolveActivityCourse` — Resolves a course selector to a config entry.
|
|
20
|
-
* Used by activity handler to match client payload to configured courses.
|
|
21
14
|
*/
|
|
22
15
|
import { TimebackClient } from '@timeback/core';
|
|
23
|
-
import type {
|
|
24
|
-
import type { ApiCredentials,
|
|
16
|
+
import type { TimebackAuthUser } from '../../shared/types';
|
|
17
|
+
import type { ApiCredentials, Environment, OIDCUserInfo, TimebackUserResolutionErrorCode } from '../types';
|
|
25
18
|
/**
|
|
26
19
|
* Error thrown when Timeback user resolution fails.
|
|
27
20
|
*/
|
|
@@ -77,36 +70,5 @@ export declare function resolveTimebackUserByEmail(params: ResolveTimebackUserBy
|
|
|
77
70
|
* @throws {TimebackUserResolutionError} If lookup fails
|
|
78
71
|
*/
|
|
79
72
|
export declare function lookupTimebackIdByEmail(params: LookupTimebackIdByEmailParams): Promise<string>;
|
|
80
|
-
/**
|
|
81
|
-
* Error thrown when a course selector cannot be resolved against config.
|
|
82
|
-
*/
|
|
83
|
-
export declare class ActivityCourseResolutionError extends Error {
|
|
84
|
-
readonly code: 'unknown_course' | 'ambiguous_course';
|
|
85
|
-
readonly selector: ActivityCourseRef;
|
|
86
|
-
readonly count?: number;
|
|
87
|
-
constructor(code: ActivityCourseResolutionError['code'], selector: ActivityCourseRef, count?: number);
|
|
88
|
-
/**
|
|
89
|
-
* Get a human-readable description of the selector.
|
|
90
|
-
*
|
|
91
|
-
* @returns Human-readable selector description
|
|
92
|
-
*/
|
|
93
|
-
get selectorDescription(): string;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Resolve a course config entry from an activity course selector.
|
|
97
|
-
*
|
|
98
|
-
* **Use case:** Activity handler — match the client's course selector
|
|
99
|
-
* to a configured course in `timeback.config.json`.
|
|
100
|
-
*
|
|
101
|
-
* Supports two selector modes:
|
|
102
|
-
* - **subjectGrade**: Match by `(subject, grade)`
|
|
103
|
-
* - **courseCode**: Match by `courseCode`
|
|
104
|
-
*
|
|
105
|
-
* @param courses - Configured courses from `timeback.config.json`
|
|
106
|
-
* @param courseRef - Course selector from the client payload
|
|
107
|
-
* @returns Matched course config entry
|
|
108
|
-
* @throws {ActivityCourseResolutionError} When selector is unknown or ambiguous
|
|
109
|
-
*/
|
|
110
|
-
export declare function resolveActivityCourse(courses: AppConfig['courses'], courseRef: ActivityCourseRef): AppConfig['courses'][number];
|
|
111
73
|
export {};
|
|
112
74
|
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/server/lib/resolve.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/server/lib/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;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;AAQjB;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;aAGpC,IAAI,EAAE,+BAA+B;IAFtD,YACC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,+BAA+B,EAIrD;CACD;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,GAAG,EAAE,2BAA2B,GAAG,MAAM,CAE5F;AAMD,UAAU,gCAAgC;IACzC,uCAAuC;IACvC,GAAG,EAAE,WAAW,CAAA;IAChB,uCAAuC;IACvC,cAAc,EAAE,cAAc,CAAA;IAC9B,kCAAkC;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;CACvB;AAED,UAAU,6BAA6B;IACtC,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,qCAAqC;IACrC,MAAM,EAAE,cAAc,CAAA;CACtB;AA2FD;;;;;;;;;GASG;AACH,wBAAsB,0BAA0B,CAC/C,MAAM,EAAE,gCAAgC,GACtC,OAAO,CAAC,gBAAgB,CAAC,CAsD3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC5C,MAAM,EAAE,6BAA6B,GACnC,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
|