@timeback/sdk 0.1.6 → 0.1.8
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 +91 -2
- package/dist/chunk-07j8zre9.js +2 -0
- package/dist/chunk-3886xy48.js +8 -0
- package/dist/chunk-9se82640.js +1 -0
- package/dist/chunk-ahy54f2r.js +2 -0
- package/dist/chunk-ewsp6v3b.js +16 -0
- package/dist/chunk-j1xdrfqj.js +2 -0
- package/dist/chunk-qaa129bd.js +2 -0
- package/dist/chunk-qr0bbnsr.js +1 -0
- package/dist/chunk-rgbpvxbv.js +1 -0
- package/dist/chunk-whc53e0y.js +11 -0
- package/dist/client/adapters/react/hooks/types.d.ts +61 -0
- package/dist/client/adapters/react/hooks/types.d.ts.map +1 -0
- package/dist/client/adapters/react/hooks/useTimebackProfile.d.ts +42 -0
- package/dist/client/adapters/react/hooks/useTimebackProfile.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 +3 -0
- package/dist/client/adapters/react/index.d.ts.map +1 -1
- package/dist/client/adapters/react/index.js +2 -364
- package/dist/client/adapters/solid/index.d.ts +3 -0
- package/dist/client/adapters/solid/index.d.ts.map +1 -1
- package/dist/client/adapters/solid/index.ts +12 -0
- package/dist/client/adapters/solid/primitives/createTimebackProfile.d.ts +58 -0
- package/dist/client/adapters/solid/primitives/createTimebackProfile.d.ts.map +1 -0
- package/dist/client/adapters/solid/primitives/createTimebackProfile.ts +209 -0
- package/dist/client/adapters/solid/primitives/createTimebackVerification.d.ts +36 -0
- package/dist/client/adapters/solid/primitives/createTimebackVerification.d.ts.map +1 -0
- package/dist/client/adapters/solid/primitives/createTimebackVerification.ts +133 -0
- package/dist/client/adapters/solid/types.d.ts +86 -0
- package/dist/client/adapters/solid/types.d.ts.map +1 -0
- package/dist/client/adapters/solid/types.ts +85 -0
- package/dist/client/adapters/svelte/index.d.ts +2 -1
- package/dist/client/adapters/svelte/index.d.ts.map +1 -1
- package/dist/client/adapters/svelte/index.ts +11 -2
- package/dist/client/adapters/svelte/{stores.d.ts → stores/client.d.ts} +11 -9
- package/dist/client/adapters/svelte/stores/client.d.ts.map +1 -0
- package/dist/client/adapters/svelte/{stores.ts → stores/client.ts} +24 -52
- package/dist/client/adapters/svelte/stores/index.d.ts +10 -0
- package/dist/client/adapters/svelte/stores/index.d.ts.map +1 -0
- package/dist/client/adapters/svelte/stores/index.ts +22 -0
- package/dist/client/adapters/svelte/stores/profile.d.ts +66 -0
- package/dist/client/adapters/svelte/stores/profile.d.ts.map +1 -0
- package/dist/client/adapters/svelte/stores/profile.ts +168 -0
- package/dist/client/adapters/svelte/stores/verification.d.ts +43 -0
- package/dist/client/adapters/svelte/stores/verification.d.ts.map +1 -0
- package/dist/client/adapters/svelte/stores/verification.ts +126 -0
- package/dist/client/adapters/svelte/types.d.ts +35 -0
- package/dist/client/adapters/svelte/types.d.ts.map +1 -0
- package/dist/client/adapters/vue/composables/useTimebackProfile.d.ts +51 -0
- package/dist/client/adapters/vue/composables/useTimebackProfile.d.ts.map +1 -0
- package/dist/client/adapters/vue/composables/useTimebackProfile.ts +186 -0
- package/dist/client/adapters/vue/composables/useTimebackVerification.d.ts +44 -0
- package/dist/client/adapters/vue/composables/useTimebackVerification.d.ts.map +1 -0
- package/dist/client/adapters/vue/composables/useTimebackVerification.ts +128 -0
- package/dist/client/adapters/vue/index.d.ts +3 -0
- package/dist/client/adapters/vue/index.d.ts.map +1 -1
- package/dist/client/adapters/vue/index.ts +12 -1
- package/dist/client/adapters/vue/types.d.ts +86 -0
- package/dist/client/adapters/vue/types.d.ts.map +1 -0
- package/dist/client/adapters/vue/types.ts +85 -0
- 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/activity/activity.class.d.ts +5 -5
- package/dist/client/lib/activity/activity.class.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/lib/user-cache.d.ts +39 -0
- package/dist/client/lib/user-cache.d.ts.map +1 -0
- package/dist/client/lib/user-cache.ts +168 -0
- package/dist/client/namespaces/activity.d.ts +2 -3
- package/dist/client/namespaces/activity.d.ts.map +1 -1
- 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 +3 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -194
- package/dist/edge.js +1 -1149
- package/dist/identity.js +1 -1019
- package/dist/index.js +22 -104603
- package/dist/server/adapters/express.d.ts.map +1 -1
- package/dist/server/adapters/express.js +1 -85997
- package/dist/server/adapters/native.d.ts.map +1 -1
- package/dist/server/adapters/native.js +2 -190
- package/dist/server/adapters/nextjs.js +1 -202
- package/dist/server/adapters/nuxt.d.ts.map +1 -1
- package/dist/server/adapters/nuxt.js +1 -86066
- package/dist/server/adapters/solid-start.d.ts.map +1 -1
- package/dist/server/adapters/solid-start.js +1 -85965
- package/dist/server/adapters/svelte-kit.d.ts.map +1 -1
- package/dist/server/adapters/svelte-kit.js +1 -243
- package/dist/server/adapters/tanstack-start.d.ts.map +1 -1
- package/dist/server/adapters/tanstack-start.js +1 -85943
- package/dist/server/adapters/utils.d.ts +1 -1
- package/dist/server/adapters/utils.d.ts.map +1 -1
- package/dist/server/handlers/activity/attempts.d.ts +51 -0
- package/dist/server/handlers/activity/attempts.d.ts.map +1 -0
- package/dist/server/handlers/activity/caliper.d.ts +133 -0
- package/dist/server/handlers/activity/caliper.d.ts.map +1 -0
- package/dist/server/handlers/activity/completion.d.ts +43 -0
- package/dist/server/handlers/activity/completion.d.ts.map +1 -0
- package/dist/server/handlers/activity/handler.d.ts +32 -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/progress.d.ts +47 -0
- package/dist/server/handlers/activity/progress.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 +51 -0
- package/dist/server/handlers/activity/schema.d.ts.map +1 -0
- package/dist/server/handlers/activity/types.d.ts +51 -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 +93 -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 +23 -10
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shared/constants.d.ts +7 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/types.d.ts +77 -8
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/xp-calculator.d.ts +25 -0
- package/dist/shared/xp-calculator.d.ts.map +1 -0
- package/package.json +8 -2
- package/dist/client/adapters/svelte/stores.d.ts.map +0 -1
- 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 +0 -67
- 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,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 { deriveCourseStructureIds, jsonResponse, redirectResponse, encodeBase64Url, decodeBase64Url, mapEnvForApi, normalizeEnv, safeIdSegment, sameInstant, hashSuffix64Base36, sha256Hex, } 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,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,GACT,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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSO Flow Helpers
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for SSO sign-in and callback handling.
|
|
5
|
+
* Used by both full SDK and identity-only handlers.
|
|
6
|
+
*/
|
|
7
|
+
import type { BuildStateContext, CallbackErrorContext, Environment } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Build callback error context.
|
|
10
|
+
*
|
|
11
|
+
* @param error - The error that occurred
|
|
12
|
+
* @param errorCode - Optional error code (IdP or internal)
|
|
13
|
+
* @param state - Decoded state (if provided)
|
|
14
|
+
* @param req - Incoming request
|
|
15
|
+
* @returns Callback error context
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildErrorContext<TState>(error: Error, errorCode: string | undefined, state: TState | undefined, req: Request): CallbackErrorContext<TState>;
|
|
18
|
+
/**
|
|
19
|
+
* Try to decode base64url-encoded state.
|
|
20
|
+
*
|
|
21
|
+
* @param stateParam - Base64url encoded state
|
|
22
|
+
* @returns Decoded state or undefined
|
|
23
|
+
*/
|
|
24
|
+
export declare function tryDecodeState<TState>(stateParam: string): TState | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Handle IdP error response.
|
|
27
|
+
*
|
|
28
|
+
* @param errorParam - Error code from IdP
|
|
29
|
+
* @param url - Callback URL
|
|
30
|
+
* @param state - Decoded state (if provided)
|
|
31
|
+
* @param req - Incoming request
|
|
32
|
+
* @param onCallbackError - Optional custom error handler
|
|
33
|
+
* @returns Error response
|
|
34
|
+
*/
|
|
35
|
+
export declare function handleIdpError<TState>(errorParam: string, url: URL, state: TState | undefined, req: Request, onCallbackError?: (ctx: CallbackErrorContext<TState>) => Response | Promise<Response>): Response | Promise<Response>;
|
|
36
|
+
/**
|
|
37
|
+
* Handle missing authorization code in callback URL.
|
|
38
|
+
*
|
|
39
|
+
* @param state - Decoded state (if provided)
|
|
40
|
+
* @param req - Incoming request
|
|
41
|
+
* @param onCallbackError - Optional custom error handler
|
|
42
|
+
* @returns Error response
|
|
43
|
+
*/
|
|
44
|
+
export declare function handleMissingCode<TState>(state: TState | undefined, req: Request, onCallbackError?: (ctx: CallbackErrorContext<TState>) => Response | Promise<Response>): Response | Promise<Response>;
|
|
45
|
+
/** Parameters for initiating sign-in. */
|
|
46
|
+
interface SignInParams<TState> {
|
|
47
|
+
req: Request;
|
|
48
|
+
env: Environment;
|
|
49
|
+
clientId: string;
|
|
50
|
+
issuer?: string;
|
|
51
|
+
redirectUri?: string;
|
|
52
|
+
buildState?: (ctx: BuildStateContext) => TState;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Initiate SSO sign-in flow.
|
|
56
|
+
*
|
|
57
|
+
* Builds the authorization URL and returns a redirect response.
|
|
58
|
+
*
|
|
59
|
+
* @param params - Sign-in parameters
|
|
60
|
+
* @returns Redirect response to IdP
|
|
61
|
+
*/
|
|
62
|
+
export declare function initiateSignIn<TState>(params: SignInParams<TState>): Promise<Response>;
|
|
63
|
+
/** Parsed callback parameters. */
|
|
64
|
+
interface ParsedCallback<TState> {
|
|
65
|
+
url: URL;
|
|
66
|
+
code: string | null;
|
|
67
|
+
errorParam: string | null;
|
|
68
|
+
state: TState | undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse callback request parameters.
|
|
72
|
+
*
|
|
73
|
+
* @param req - Incoming callback request
|
|
74
|
+
* @returns Parsed callback parameters
|
|
75
|
+
*/
|
|
76
|
+
export declare function parseCallback<TState>(req: Request): ParsedCallback<TState>;
|
|
77
|
+
/**
|
|
78
|
+
* Compute redirect URI for callback.
|
|
79
|
+
*
|
|
80
|
+
* @param url - Callback URL
|
|
81
|
+
* @param configuredRedirectUri - Configured redirect URI (if any)
|
|
82
|
+
* @returns Computed redirect URI
|
|
83
|
+
*/
|
|
84
|
+
export declare function computeRedirectUri(url: URL, configuredRedirectUri?: string): string;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=sso.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sso.d.ts","sourceRoot":"","sources":["../../../src/server/lib/sso.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAMpF;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EACvC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,GAAG,EAAE,OAAO,GACV,oBAAoB,CAAC,MAAM,CAAC,CAS9B;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAO7E;AAMD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,MAAM,EACpC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,GAAG,EAAE,OAAO,EACZ,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GACnF,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAY9B;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EACvC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,GAAG,EAAE,OAAO,EACZ,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GACnF,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAU9B;AAMD,yCAAyC;AACzC,UAAU,YAAY,CAAC,MAAM;IAC5B,GAAG,EAAE,OAAO,CAAA;IACZ,GAAG,EAAE,WAAW,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,CAAA;CAC/C;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0B5F;AAMD,kCAAkC;AAClC,UAAU,cAAc,CAAC,MAAM;IAC9B,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAW1E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,CAOnF"}
|
|
@@ -3,7 +3,89 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Internal utility functions for the server SDK.
|
|
5
5
|
*/
|
|
6
|
-
import type { Environment } from '../types';
|
|
6
|
+
import type { Environment, EnvironmentInput } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* Derived resource IDs for a course structure.
|
|
9
|
+
*/
|
|
10
|
+
interface CourseStructureIds {
|
|
11
|
+
/** Course sourcedId (unchanged) */
|
|
12
|
+
course: string;
|
|
13
|
+
/** Derived component ID: `${courseId}-component` */
|
|
14
|
+
component: string;
|
|
15
|
+
/** Derived resource ID: `${courseId}-resource` */
|
|
16
|
+
resource: string;
|
|
17
|
+
/** Derived componentResource ID: `${courseId}-cr` */
|
|
18
|
+
componentResource: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Derive all resource IDs from the allocated courseId.
|
|
22
|
+
*
|
|
23
|
+
* This follows the SDK pattern where child IDs are deterministic
|
|
24
|
+
* suffixes of the course ID, keeping config files clean.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: This function is intentionally duplicated in `packages/cli/src/lib/course-structure.ts`.
|
|
27
|
+
*
|
|
28
|
+
* We accept the duplication because: (1) it's a tiny pure function with no dependencies,
|
|
29
|
+
* (2) the ID derivation pattern is stable and unlikely to change, and (3) extracting to a
|
|
30
|
+
* shared package would add cross-package dependency overhead for minimal benefit.
|
|
31
|
+
* If you modify this, update the CLI copy as well.
|
|
32
|
+
*
|
|
33
|
+
* @param courseId - The allocated OneRoster course ID
|
|
34
|
+
* @returns Derived IDs for all child resources
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const ids = deriveCourseStructureIds('abc-123')
|
|
39
|
+
* // {
|
|
40
|
+
* // course: 'abc-123',
|
|
41
|
+
* // component: 'abc-123-component',
|
|
42
|
+
* // resource: 'abc-123-resource',
|
|
43
|
+
* // componentResource: 'abc-123-cr'
|
|
44
|
+
* // }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function deriveCourseStructureIds(courseId: string): CourseStructureIds;
|
|
48
|
+
/**
|
|
49
|
+
* Build a safe ID segment from a string (URL-safe, no colons).
|
|
50
|
+
*
|
|
51
|
+
* `encodeURIComponent` escapes reserved characters into percent-encoded form.
|
|
52
|
+
* We additionally replace `%` with `_` so the resulting value:
|
|
53
|
+
* - stays URL-safe
|
|
54
|
+
* - avoids raw `%` characters (which can be awkward in some ID contexts)
|
|
55
|
+
*
|
|
56
|
+
* @param value - The value to make safe
|
|
57
|
+
* @returns A safe ID segment
|
|
58
|
+
*/
|
|
59
|
+
export declare function safeIdSegment(value: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Compare two datetime strings, tolerating minor formatting differences.
|
|
62
|
+
*
|
|
63
|
+
* Falls back to string equality if either value is not parseable.
|
|
64
|
+
*
|
|
65
|
+
* @param a - First datetime string
|
|
66
|
+
* @param b - Second datetime string
|
|
67
|
+
* @returns True if both represent the same instant
|
|
68
|
+
*/
|
|
69
|
+
export declare function sameInstant(a: string, b: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Create a compact deterministic hash suffix for IDs.
|
|
72
|
+
*
|
|
73
|
+
* Uses 64-bit FNV-1a over the input string and returns a base36-encoded suffix.
|
|
74
|
+
* This is **not** cryptographic, but is stable and compact for ID disambiguation.
|
|
75
|
+
*
|
|
76
|
+
* @param value - String to hash
|
|
77
|
+
* @returns Base36 hash suffix (lowercase alphanumeric)
|
|
78
|
+
*/
|
|
79
|
+
export declare function hashSuffix64Base36(value: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Create a SHA256 hex digest of a string.
|
|
82
|
+
*
|
|
83
|
+
* Used for deterministic IDs that must match timeback-api-2's hashing.
|
|
84
|
+
*
|
|
85
|
+
* @param value - String to hash
|
|
86
|
+
* @returns 64-character lowercase hex string
|
|
87
|
+
*/
|
|
88
|
+
export declare function sha256Hex(value: string): string;
|
|
7
89
|
/**
|
|
8
90
|
* Map SDK environment to the environment used for outbound Timeback API calls.
|
|
9
91
|
*
|
|
@@ -18,6 +100,15 @@ import type { Environment } from '../types';
|
|
|
18
100
|
* @returns Environment to use for TimebackClient
|
|
19
101
|
*/
|
|
20
102
|
export declare function mapEnvForApi(env: Environment): 'staging' | 'production';
|
|
103
|
+
/**
|
|
104
|
+
* Normalize a user-provided environment to a known SDK environment.
|
|
105
|
+
*
|
|
106
|
+
* Unknown values default to `staging`.
|
|
107
|
+
*
|
|
108
|
+
* @param env - User-provided environment value
|
|
109
|
+
* @returns Normalized SDK environment
|
|
110
|
+
*/
|
|
111
|
+
export declare function normalizeEnv(env: EnvironmentInput): Environment;
|
|
21
112
|
/**
|
|
22
113
|
* Create a JSON response.
|
|
23
114
|
*
|
|
@@ -51,4 +142,5 @@ export declare function encodeBase64Url(data: unknown): string;
|
|
|
51
142
|
* @returns Decoded object
|
|
52
143
|
*/
|
|
53
144
|
export declare function decodeBase64Url<T>(encoded: string): T;
|
|
145
|
+
export {};
|
|
54
146
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/server/lib/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/server/lib/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAM7D;;GAEG;AACH,UAAU,kBAAkB;IAC3B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAA;IACjB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAA;IAChB,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAO7E;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAKzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAcxD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,CAMvE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,GAAG,WAAW,CAK/D;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeback-identity.d.ts","sourceRoot":"","sources":["../../src/server/timeback-identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"timeback-identity.d.ts","sourceRoot":"","sources":["../../src/server/timeback-identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,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 +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;AAYH,OAAO,KAAK,EAAa,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAyC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAsB,cAAc,CAAC,MAAM,GAAG,OAAO,EACpD,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAC5B,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAiFnC"}
|