@timeback/sdk 0.1.4

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.
Files changed (136) hide show
  1. package/README.md +612 -0
  2. package/dist/client/adapters/react/SignInButton.d.ts +60 -0
  3. package/dist/client/adapters/react/SignInButton.d.ts.map +1 -0
  4. package/dist/client/adapters/react/index.d.ts +47 -0
  5. package/dist/client/adapters/react/index.d.ts.map +1 -0
  6. package/dist/client/adapters/react/index.js +478 -0
  7. package/dist/client/adapters/react/provider.d.ts +78 -0
  8. package/dist/client/adapters/react/provider.d.ts.map +1 -0
  9. package/dist/client/adapters/solid/SignInButton.d.ts +52 -0
  10. package/dist/client/adapters/solid/SignInButton.d.ts.map +1 -0
  11. package/dist/client/adapters/solid/SignInButton.tsx +321 -0
  12. package/dist/client/adapters/solid/context.d.ts +73 -0
  13. package/dist/client/adapters/solid/context.d.ts.map +1 -0
  14. package/dist/client/adapters/solid/context.tsx +91 -0
  15. package/dist/client/adapters/solid/index.d.ts +46 -0
  16. package/dist/client/adapters/solid/index.d.ts.map +1 -0
  17. package/dist/client/adapters/solid/index.ts +50 -0
  18. package/dist/client/adapters/svelte/SignInButton.svelte +234 -0
  19. package/dist/client/adapters/svelte/SignInButton.svelte.d.ts +24 -0
  20. package/dist/client/adapters/svelte/index.d.ts +37 -0
  21. package/dist/client/adapters/svelte/index.d.ts.map +1 -0
  22. package/dist/client/adapters/svelte/index.ts +42 -0
  23. package/dist/client/adapters/svelte/stores.d.ts +66 -0
  24. package/dist/client/adapters/svelte/stores.d.ts.map +1 -0
  25. package/dist/client/adapters/svelte/stores.ts +143 -0
  26. package/dist/client/adapters/vue/SignInButton.vue +260 -0
  27. package/dist/client/adapters/vue/SignInButton.vue.d.ts +53 -0
  28. package/dist/client/adapters/vue/index.d.ts +43 -0
  29. package/dist/client/adapters/vue/index.d.ts.map +1 -0
  30. package/dist/client/adapters/vue/index.ts +48 -0
  31. package/dist/client/adapters/vue/provider.d.ts +94 -0
  32. package/dist/client/adapters/vue/provider.d.ts.map +1 -0
  33. package/dist/client/adapters/vue/provider.ts +147 -0
  34. package/dist/client/index.d.ts +9 -0
  35. package/dist/client/index.d.ts.map +1 -0
  36. package/dist/client/lib/activity/activity.class.d.ts +73 -0
  37. package/dist/client/lib/activity/activity.class.d.ts.map +1 -0
  38. package/dist/client/lib/activity/activity.d.ts +16 -0
  39. package/dist/client/lib/activity/activity.d.ts.map +1 -0
  40. package/dist/client/lib/activity/index.d.ts +6 -0
  41. package/dist/client/lib/activity/index.d.ts.map +1 -0
  42. package/dist/client/lib/utils.d.ts +20 -0
  43. package/dist/client/lib/utils.d.ts.map +1 -0
  44. package/dist/client/namespaces/activity.d.ts +41 -0
  45. package/dist/client/namespaces/activity.d.ts.map +1 -0
  46. package/dist/client/namespaces/auth.d.ts +33 -0
  47. package/dist/client/namespaces/auth.d.ts.map +1 -0
  48. package/dist/client/namespaces/index.d.ts +7 -0
  49. package/dist/client/namespaces/index.d.ts.map +1 -0
  50. package/dist/client/namespaces/user.d.ts +29 -0
  51. package/dist/client/namespaces/user.d.ts.map +1 -0
  52. package/dist/client/timeback-client.class.d.ts +37 -0
  53. package/dist/client/timeback-client.class.d.ts.map +1 -0
  54. package/dist/client/timeback-client.d.ts +29 -0
  55. package/dist/client/timeback-client.d.ts.map +1 -0
  56. package/dist/client.d.ts +30 -0
  57. package/dist/client.d.ts.map +1 -0
  58. package/dist/client.js +198 -0
  59. package/dist/config.d.ts +20 -0
  60. package/dist/config.d.ts.map +1 -0
  61. package/dist/config.js +0 -0
  62. package/dist/edge.d.ts +13 -0
  63. package/dist/edge.d.ts.map +1 -0
  64. package/dist/edge.js +1149 -0
  65. package/dist/identity.d.ts +14 -0
  66. package/dist/identity.d.ts.map +1 -0
  67. package/dist/identity.js +1019 -0
  68. package/dist/index.d.ts +48 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +84921 -0
  71. package/dist/server/adapters/express.d.ts +66 -0
  72. package/dist/server/adapters/express.d.ts.map +1 -0
  73. package/dist/server/adapters/express.js +67332 -0
  74. package/dist/server/adapters/native.d.ts +47 -0
  75. package/dist/server/adapters/native.d.ts.map +1 -0
  76. package/dist/server/adapters/native.js +190 -0
  77. package/dist/server/adapters/nextjs.d.ts +32 -0
  78. package/dist/server/adapters/nextjs.d.ts.map +1 -0
  79. package/dist/server/adapters/nextjs.js +202 -0
  80. package/dist/server/adapters/nuxt.d.ts +98 -0
  81. package/dist/server/adapters/nuxt.d.ts.map +1 -0
  82. package/dist/server/adapters/nuxt.js +67401 -0
  83. package/dist/server/adapters/solid-start.d.ts +63 -0
  84. package/dist/server/adapters/solid-start.d.ts.map +1 -0
  85. package/dist/server/adapters/solid-start.js +67300 -0
  86. package/dist/server/adapters/svelte-kit.d.ts +84 -0
  87. package/dist/server/adapters/svelte-kit.d.ts.map +1 -0
  88. package/dist/server/adapters/svelte-kit.js +243 -0
  89. package/dist/server/adapters/tanstack-start.d.ts +42 -0
  90. package/dist/server/adapters/tanstack-start.d.ts.map +1 -0
  91. package/dist/server/adapters/tanstack-start.js +67278 -0
  92. package/dist/server/adapters/types.d.ts +294 -0
  93. package/dist/server/adapters/types.d.ts.map +1 -0
  94. package/dist/server/adapters/utils.d.ts +76 -0
  95. package/dist/server/adapters/utils.d.ts.map +1 -0
  96. package/dist/server/handlers/activity.d.ts +28 -0
  97. package/dist/server/handlers/activity.d.ts.map +1 -0
  98. package/dist/server/handlers/identity-full.d.ts +28 -0
  99. package/dist/server/handlers/identity-full.d.ts.map +1 -0
  100. package/dist/server/handlers/identity-only.d.ts +22 -0
  101. package/dist/server/handlers/identity-only.d.ts.map +1 -0
  102. package/dist/server/handlers/index.d.ts +9 -0
  103. package/dist/server/handlers/index.d.ts.map +1 -0
  104. package/dist/server/handlers/user.d.ts +31 -0
  105. package/dist/server/handlers/user.d.ts.map +1 -0
  106. package/dist/server/index.d.ts +9 -0
  107. package/dist/server/index.d.ts.map +1 -0
  108. package/dist/server/lib/build-activity-events.d.ts +39 -0
  109. package/dist/server/lib/build-activity-events.d.ts.map +1 -0
  110. package/dist/server/lib/build-user-profile.d.ts +62 -0
  111. package/dist/server/lib/build-user-profile.d.ts.map +1 -0
  112. package/dist/server/lib/index.d.ts +14 -0
  113. package/dist/server/lib/index.d.ts.map +1 -0
  114. package/dist/server/lib/logger.d.ts +21 -0
  115. package/dist/server/lib/logger.d.ts.map +1 -0
  116. package/dist/server/lib/oidc.d.ts +76 -0
  117. package/dist/server/lib/oidc.d.ts.map +1 -0
  118. package/dist/server/lib/resolve-activity-course.d.ts +22 -0
  119. package/dist/server/lib/resolve-activity-course.d.ts.map +1 -0
  120. package/dist/server/lib/resolve-timeback-id.d.ts +28 -0
  121. package/dist/server/lib/resolve-timeback-id.d.ts.map +1 -0
  122. package/dist/server/lib/resolve-timeback-user.d.ts +42 -0
  123. package/dist/server/lib/resolve-timeback-user.d.ts.map +1 -0
  124. package/dist/server/lib/utils.d.ts +54 -0
  125. package/dist/server/lib/utils.d.ts.map +1 -0
  126. package/dist/server/timeback-identity.d.ts +19 -0
  127. package/dist/server/timeback-identity.d.ts.map +1 -0
  128. package/dist/server/timeback.d.ts +68 -0
  129. package/dist/server/timeback.d.ts.map +1 -0
  130. package/dist/server/types.d.ts +421 -0
  131. package/dist/server/types.d.ts.map +1 -0
  132. package/dist/shared/constants.d.ts +18 -0
  133. package/dist/shared/constants.d.ts.map +1 -0
  134. package/dist/shared/types.d.ts +159 -0
  135. package/dist/shared/types.d.ts.map +1 -0
  136. package/package.json +119 -0
@@ -0,0 +1,1019 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
12
+
13
+ // node:util
14
+ var exports_util = {};
15
+ __export(exports_util, {
16
+ types: () => types,
17
+ promisify: () => promisify,
18
+ log: () => log,
19
+ isUndefined: () => isUndefined,
20
+ isSymbol: () => isSymbol,
21
+ isString: () => isString,
22
+ isRegExp: () => isRegExp,
23
+ isPrimitive: () => isPrimitive,
24
+ isObject: () => isObject,
25
+ isNumber: () => isNumber,
26
+ isNullOrUndefined: () => isNullOrUndefined,
27
+ isNull: () => isNull,
28
+ isFunction: () => isFunction,
29
+ isError: () => isError,
30
+ isDate: () => isDate,
31
+ isBuffer: () => isBuffer,
32
+ isBoolean: () => isBoolean,
33
+ isArray: () => isArray,
34
+ inspect: () => inspect,
35
+ inherits: () => inherits,
36
+ format: () => format,
37
+ deprecate: () => deprecate,
38
+ default: () => util_default,
39
+ debuglog: () => debuglog,
40
+ callbackifyOnRejected: () => callbackifyOnRejected,
41
+ callbackify: () => callbackify,
42
+ _extend: () => _extend,
43
+ TextEncoder: () => TextEncoder,
44
+ TextDecoder: () => TextDecoder
45
+ });
46
+ function format(f, ...args) {
47
+ if (!isString(f)) {
48
+ var objects = [f];
49
+ for (var i = 0;i < args.length; i++)
50
+ objects.push(inspect(args[i]));
51
+ return objects.join(" ");
52
+ }
53
+ var i = 0, len = args.length, str = String(f).replace(formatRegExp, function(x2) {
54
+ if (x2 === "%%")
55
+ return "%";
56
+ if (i >= len)
57
+ return x2;
58
+ switch (x2) {
59
+ case "%s":
60
+ return String(args[i++]);
61
+ case "%d":
62
+ return Number(args[i++]);
63
+ case "%j":
64
+ try {
65
+ return JSON.stringify(args[i++]);
66
+ } catch (_) {
67
+ return "[Circular]";
68
+ }
69
+ default:
70
+ return x2;
71
+ }
72
+ });
73
+ for (var x = args[i];i < len; x = args[++i])
74
+ if (isNull(x) || !isObject(x))
75
+ str += " " + x;
76
+ else
77
+ str += " " + inspect(x);
78
+ return str;
79
+ }
80
+ function deprecate(fn, msg) {
81
+ if (typeof process > "u" || process?.noDeprecation === true)
82
+ return fn;
83
+ var warned = false;
84
+ function deprecated(...args) {
85
+ if (!warned) {
86
+ if (process.throwDeprecation)
87
+ throw Error(msg);
88
+ else if (process.traceDeprecation)
89
+ console.trace(msg);
90
+ else
91
+ console.error(msg);
92
+ warned = true;
93
+ }
94
+ return fn.apply(this, ...args);
95
+ }
96
+ return deprecated;
97
+ }
98
+ function stylizeWithColor(str, styleType) {
99
+ var style = inspect.styles[styleType];
100
+ if (style)
101
+ return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
102
+ else
103
+ return str;
104
+ }
105
+ function stylizeNoColor(str, styleType) {
106
+ return str;
107
+ }
108
+ function arrayToHash(array) {
109
+ var hash = {};
110
+ return array.forEach(function(val, idx) {
111
+ hash[val] = true;
112
+ }), hash;
113
+ }
114
+ function formatValue(ctx, value, recurseTimes) {
115
+ if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) {
116
+ var ret = value.inspect(recurseTimes, ctx);
117
+ if (!isString(ret))
118
+ ret = formatValue(ctx, ret, recurseTimes);
119
+ return ret;
120
+ }
121
+ var primitive = formatPrimitive(ctx, value);
122
+ if (primitive)
123
+ return primitive;
124
+ var keys = Object.keys(value), visibleKeys = arrayToHash(keys);
125
+ if (ctx.showHidden)
126
+ keys = Object.getOwnPropertyNames(value);
127
+ if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0))
128
+ return formatError(value);
129
+ if (keys.length === 0) {
130
+ if (isFunction(value)) {
131
+ var name = value.name ? ": " + value.name : "";
132
+ return ctx.stylize("[Function" + name + "]", "special");
133
+ }
134
+ if (isRegExp(value))
135
+ return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
136
+ if (isDate(value))
137
+ return ctx.stylize(Date.prototype.toString.call(value), "date");
138
+ if (isError(value))
139
+ return formatError(value);
140
+ }
141
+ var base = "", array = false, braces = ["{", "}"];
142
+ if (isArray(value))
143
+ array = true, braces = ["[", "]"];
144
+ if (isFunction(value)) {
145
+ var n = value.name ? ": " + value.name : "";
146
+ base = " [Function" + n + "]";
147
+ }
148
+ if (isRegExp(value))
149
+ base = " " + RegExp.prototype.toString.call(value);
150
+ if (isDate(value))
151
+ base = " " + Date.prototype.toUTCString.call(value);
152
+ if (isError(value))
153
+ base = " " + formatError(value);
154
+ if (keys.length === 0 && (!array || value.length == 0))
155
+ return braces[0] + base + braces[1];
156
+ if (recurseTimes < 0)
157
+ if (isRegExp(value))
158
+ return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
159
+ else
160
+ return ctx.stylize("[Object]", "special");
161
+ ctx.seen.push(value);
162
+ var output;
163
+ if (array)
164
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
165
+ else
166
+ output = keys.map(function(key) {
167
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
168
+ });
169
+ return ctx.seen.pop(), reduceToSingleString(output, base, braces);
170
+ }
171
+ function formatPrimitive(ctx, value) {
172
+ if (isUndefined(value))
173
+ return ctx.stylize("undefined", "undefined");
174
+ if (isString(value)) {
175
+ var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'";
176
+ return ctx.stylize(simple, "string");
177
+ }
178
+ if (isNumber(value))
179
+ return ctx.stylize("" + value, "number");
180
+ if (isBoolean(value))
181
+ return ctx.stylize("" + value, "boolean");
182
+ if (isNull(value))
183
+ return ctx.stylize("null", "null");
184
+ }
185
+ function formatError(value) {
186
+ return "[" + Error.prototype.toString.call(value) + "]";
187
+ }
188
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
189
+ var output = [];
190
+ for (var i = 0, l = value.length;i < l; ++i)
191
+ if (hasOwnProperty(value, String(i)))
192
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
193
+ else
194
+ output.push("");
195
+ return keys.forEach(function(key) {
196
+ if (!key.match(/^\d+$/))
197
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
198
+ }), output;
199
+ }
200
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
201
+ var name, str, desc;
202
+ if (desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }, desc.get)
203
+ if (desc.set)
204
+ str = ctx.stylize("[Getter/Setter]", "special");
205
+ else
206
+ str = ctx.stylize("[Getter]", "special");
207
+ else if (desc.set)
208
+ str = ctx.stylize("[Setter]", "special");
209
+ if (!hasOwnProperty(visibleKeys, key))
210
+ name = "[" + key + "]";
211
+ if (!str)
212
+ if (ctx.seen.indexOf(desc.value) < 0) {
213
+ if (isNull(recurseTimes))
214
+ str = formatValue(ctx, desc.value, null);
215
+ else
216
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
217
+ if (str.indexOf(`
218
+ `) > -1)
219
+ if (array)
220
+ str = str.split(`
221
+ `).map(function(line) {
222
+ return " " + line;
223
+ }).join(`
224
+ `).slice(2);
225
+ else
226
+ str = `
227
+ ` + str.split(`
228
+ `).map(function(line) {
229
+ return " " + line;
230
+ }).join(`
231
+ `);
232
+ } else
233
+ str = ctx.stylize("[Circular]", "special");
234
+ if (isUndefined(name)) {
235
+ if (array && key.match(/^\d+$/))
236
+ return str;
237
+ if (name = JSON.stringify("" + key), name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/))
238
+ name = name.slice(1, -1), name = ctx.stylize(name, "name");
239
+ else
240
+ name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), name = ctx.stylize(name, "string");
241
+ }
242
+ return name + ": " + str;
243
+ }
244
+ function reduceToSingleString(output, base, braces) {
245
+ var numLinesEst = 0, length = output.reduce(function(prev, cur) {
246
+ if (numLinesEst++, cur.indexOf(`
247
+ `) >= 0)
248
+ numLinesEst++;
249
+ return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
250
+ }, 0);
251
+ if (length > 60)
252
+ return braces[0] + (base === "" ? "" : base + `
253
+ `) + " " + output.join(`,
254
+ `) + " " + braces[1];
255
+ return braces[0] + base + " " + output.join(", ") + " " + braces[1];
256
+ }
257
+ function isArray(ar) {
258
+ return Array.isArray(ar);
259
+ }
260
+ function isBoolean(arg) {
261
+ return typeof arg === "boolean";
262
+ }
263
+ function isNull(arg) {
264
+ return arg === null;
265
+ }
266
+ function isNullOrUndefined(arg) {
267
+ return arg == null;
268
+ }
269
+ function isNumber(arg) {
270
+ return typeof arg === "number";
271
+ }
272
+ function isString(arg) {
273
+ return typeof arg === "string";
274
+ }
275
+ function isSymbol(arg) {
276
+ return typeof arg === "symbol";
277
+ }
278
+ function isUndefined(arg) {
279
+ return arg === undefined;
280
+ }
281
+ function isRegExp(re) {
282
+ return isObject(re) && objectToString(re) === "[object RegExp]";
283
+ }
284
+ function isObject(arg) {
285
+ return typeof arg === "object" && arg !== null;
286
+ }
287
+ function isDate(d) {
288
+ return isObject(d) && objectToString(d) === "[object Date]";
289
+ }
290
+ function isError(e) {
291
+ return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
292
+ }
293
+ function isFunction(arg) {
294
+ return typeof arg === "function";
295
+ }
296
+ function isPrimitive(arg) {
297
+ return arg === null || typeof arg === "boolean" || typeof arg === "number" || typeof arg === "string" || typeof arg === "symbol" || typeof arg > "u";
298
+ }
299
+ function isBuffer(arg) {
300
+ return arg instanceof Buffer;
301
+ }
302
+ function objectToString(o) {
303
+ return Object.prototype.toString.call(o);
304
+ }
305
+ function pad(n) {
306
+ return n < 10 ? "0" + n.toString(10) : n.toString(10);
307
+ }
308
+ function timestamp() {
309
+ var d = new Date, time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(":");
310
+ return [d.getDate(), months[d.getMonth()], time].join(" ");
311
+ }
312
+ function log(...args) {
313
+ console.log("%s - %s", timestamp(), format.apply(null, args));
314
+ }
315
+ function inherits(ctor, superCtor) {
316
+ if (superCtor)
317
+ ctor.super_ = superCtor, ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } });
318
+ }
319
+ function _extend(origin, add) {
320
+ if (!add || !isObject(add))
321
+ return origin;
322
+ var keys = Object.keys(add), i = keys.length;
323
+ while (i--)
324
+ origin[keys[i]] = add[keys[i]];
325
+ return origin;
326
+ }
327
+ function hasOwnProperty(obj, prop) {
328
+ return Object.prototype.hasOwnProperty.call(obj, prop);
329
+ }
330
+ function callbackifyOnRejected(reason, cb) {
331
+ if (!reason) {
332
+ var newReason = Error("Promise was rejected with a falsy value");
333
+ newReason.reason = reason, reason = newReason;
334
+ }
335
+ return cb(reason);
336
+ }
337
+ function callbackify(original) {
338
+ if (typeof original !== "function")
339
+ throw TypeError('The "original" argument must be of type Function');
340
+ function callbackified(...args) {
341
+ var maybeCb = args.pop();
342
+ if (typeof maybeCb !== "function")
343
+ throw TypeError("The last argument must be of type Function");
344
+ var self = this, cb = function(...args2) {
345
+ return maybeCb.apply(self, ...args2);
346
+ };
347
+ original.apply(this, args).then(function(ret) {
348
+ process.nextTick(cb.bind(null, null, ret));
349
+ }, function(rej) {
350
+ process.nextTick(callbackifyOnRejected.bind(null, rej, cb));
351
+ });
352
+ }
353
+ return Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)), Object.defineProperties(callbackified, Object.getOwnPropertyDescriptors(original)), callbackified;
354
+ }
355
+ var formatRegExp, debuglog, inspect, types = () => {}, months, promisify, TextEncoder, TextDecoder, util_default;
356
+ var init_util = __esm(() => {
357
+ formatRegExp = /%[sdj%]/g;
358
+ debuglog = ((debugs = {}, debugEnvRegex = {}, debugEnv) => ((debugEnv = typeof process < "u" && false) && (debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase()), debugEnvRegex = new RegExp("^" + debugEnv + "$", "i"), (set) => {
359
+ if (set = set.toUpperCase(), !debugs[set])
360
+ if (debugEnvRegex.test(set))
361
+ debugs[set] = function(...args) {
362
+ console.error("%s: %s", set, pid, format.apply(null, ...args));
363
+ };
364
+ else
365
+ debugs[set] = function() {};
366
+ return debugs[set];
367
+ }))();
368
+ inspect = ((i) => (i.colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39] }, i.styles = { special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", regexp: "red" }, i.custom = Symbol.for("nodejs.util.inspect.custom"), i))(function(obj, opts, ...rest) {
369
+ var ctx = { seen: [], stylize: stylizeNoColor };
370
+ if (rest.length >= 1)
371
+ ctx.depth = rest[0];
372
+ if (rest.length >= 2)
373
+ ctx.colors = rest[1];
374
+ if (isBoolean(opts))
375
+ ctx.showHidden = opts;
376
+ else if (opts)
377
+ _extend(ctx, opts);
378
+ if (isUndefined(ctx.showHidden))
379
+ ctx.showHidden = false;
380
+ if (isUndefined(ctx.depth))
381
+ ctx.depth = 2;
382
+ if (isUndefined(ctx.colors))
383
+ ctx.colors = false;
384
+ if (ctx.colors)
385
+ ctx.stylize = stylizeWithColor;
386
+ return formatValue(ctx, obj, ctx.depth);
387
+ });
388
+ months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
389
+ promisify = ((x) => (x.custom = Symbol.for("nodejs.util.promisify.custom"), x))(function(original) {
390
+ if (typeof original !== "function")
391
+ throw TypeError('The "original" argument must be of type Function');
392
+ if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
393
+ var fn = original[kCustomPromisifiedSymbol];
394
+ if (typeof fn !== "function")
395
+ throw TypeError('The "nodejs.util.promisify.custom" argument must be of type Function');
396
+ return Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true }), fn;
397
+ }
398
+ function fn(...args) {
399
+ var promiseResolve, promiseReject, promise = new Promise(function(resolve, reject) {
400
+ promiseResolve = resolve, promiseReject = reject;
401
+ });
402
+ args.push(function(err, value) {
403
+ if (err)
404
+ promiseReject(err);
405
+ else
406
+ promiseResolve(value);
407
+ });
408
+ try {
409
+ original.apply(this, args);
410
+ } catch (err) {
411
+ promiseReject(err);
412
+ }
413
+ return promise;
414
+ }
415
+ if (Object.setPrototypeOf(fn, Object.getPrototypeOf(original)), kCustomPromisifiedSymbol)
416
+ Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true });
417
+ return Object.defineProperties(fn, Object.getOwnPropertyDescriptors(original));
418
+ });
419
+ ({ TextEncoder, TextDecoder } = globalThis);
420
+ util_default = { TextEncoder, TextDecoder, promisify, log, inherits, _extend, callbackifyOnRejected, callbackify };
421
+ });
422
+
423
+ // src/shared/constants.ts
424
+ var ROUTES = {
425
+ ACTIVITY: "/activity",
426
+ IDENTITY: {
427
+ SIGNIN: "/identity/signin",
428
+ SIGNOUT: "/identity/signout",
429
+ CALLBACK: "/identity/callback"
430
+ },
431
+ USER: {
432
+ ME: "/user/me"
433
+ }
434
+ };
435
+
436
+ // ../internal/logger/src/debug.ts
437
+ var patterns = null;
438
+ var debugAll = false;
439
+ var debugEnvSet = false;
440
+ function patternToRegex(pattern) {
441
+ const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
442
+ const regexStr = escaped.replace(/\*/g, ".*");
443
+ return new RegExp(`^${regexStr}$`);
444
+ }
445
+ function parseDebugEnv() {
446
+ if (patterns !== null)
447
+ return;
448
+ patterns = [];
449
+ if (typeof process === "undefined" || !process.env?.DEBUG) {
450
+ debugEnvSet = false;
451
+ return;
452
+ }
453
+ debugEnvSet = true;
454
+ const debugValue = process.env.DEBUG.trim();
455
+ if (debugValue === "1" || debugValue === "true" || debugValue === "*") {
456
+ debugAll = true;
457
+ return;
458
+ }
459
+ const parts = debugValue.split(",").map((p) => p.trim()).filter(Boolean);
460
+ for (const part of parts) {
461
+ if (part.startsWith("-")) {
462
+ patterns.push({
463
+ regex: patternToRegex(part.slice(1)),
464
+ exclude: true
465
+ });
466
+ } else {
467
+ patterns.push({
468
+ regex: patternToRegex(part),
469
+ exclude: false
470
+ });
471
+ }
472
+ }
473
+ const hasInclude = patterns.some((p) => !p.exclude);
474
+ if (!hasInclude && patterns.length > 0) {
475
+ debugAll = true;
476
+ }
477
+ }
478
+ function shouldShowDebug(scope) {
479
+ parseDebugEnv();
480
+ if (!debugEnvSet) {
481
+ return true;
482
+ }
483
+ if (debugAll) {
484
+ if (scope) {
485
+ for (const pattern of patterns) {
486
+ if (pattern.exclude && pattern.regex.test(scope)) {
487
+ return false;
488
+ }
489
+ }
490
+ }
491
+ return true;
492
+ }
493
+ if (!scope) {
494
+ return false;
495
+ }
496
+ for (const pattern of patterns) {
497
+ if (pattern.exclude && pattern.regex.test(scope)) {
498
+ return false;
499
+ }
500
+ }
501
+ for (const pattern of patterns) {
502
+ if (!pattern.exclude && pattern.regex.test(scope)) {
503
+ return true;
504
+ }
505
+ }
506
+ return false;
507
+ }
508
+
509
+ // ../internal/logger/src/env.ts
510
+ function isBrowser() {
511
+ return typeof globalThis !== "undefined" && "window" in globalThis;
512
+ }
513
+ function detectEnvironment() {
514
+ if (isBrowser()) {
515
+ return "browser";
516
+ }
517
+ if (typeof process !== "undefined" && process.env) {
518
+ if (process.env["NODE_ENV"] === "test" || process.env["BUN_ENV"] === "test") {
519
+ return "test";
520
+ }
521
+ if (false) {}
522
+ if (process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.CIRCLECI || process.env.JENKINS_URL || process.env.BUILDKITE) {
523
+ return "ci";
524
+ }
525
+ }
526
+ return "terminal";
527
+ }
528
+
529
+ // ../internal/logger/src/formatters/terminal.ts
530
+ var nodeInspect;
531
+ if (!isBrowser()) {
532
+ try {
533
+ const util = await Promise.resolve().then(() => (init_util(), exports_util));
534
+ nodeInspect = util.inspect;
535
+ } catch {}
536
+ }
537
+ var colors = {
538
+ reset: "\x1B[0m",
539
+ bold: "\x1B[1m",
540
+ dim: "\x1B[2m",
541
+ red: "\x1B[31m",
542
+ yellow: "\x1B[33m",
543
+ blue: "\x1B[34m",
544
+ cyan: "\x1B[36m"
545
+ };
546
+ function getLevelColor(level) {
547
+ switch (level) {
548
+ case "debug":
549
+ return colors.blue;
550
+ case "info":
551
+ return colors.cyan;
552
+ case "warn":
553
+ return colors.yellow;
554
+ case "error":
555
+ return colors.red;
556
+ }
557
+ }
558
+ function getConsoleMethod(level) {
559
+ switch (level) {
560
+ case "debug":
561
+ return console.debug;
562
+ case "info":
563
+ return console.info;
564
+ case "warn":
565
+ return console.warn;
566
+ case "error":
567
+ return console.error;
568
+ }
569
+ }
570
+ function formatContext(context) {
571
+ if (nodeInspect) {
572
+ return nodeInspect(context, {
573
+ depth: null,
574
+ colors: true,
575
+ breakLength: 80,
576
+ compact: false
577
+ });
578
+ }
579
+ return JSON.stringify(context, null, 2);
580
+ }
581
+ var terminalFormatter = (entry) => {
582
+ const levelColor = getLevelColor(entry.level);
583
+ const consoleMethod = getConsoleMethod(entry.level);
584
+ const levelUpper = entry.level.toUpperCase().padEnd(5);
585
+ const isoString = entry.timestamp.toISOString().replace(/\.\d{3}Z$/, "");
586
+ const timestamp2 = `${colors.dim}[${isoString}]${colors.reset}`;
587
+ const level = `${levelColor}${levelUpper}${colors.reset}`;
588
+ const scope = entry.scope ? `${colors.bold}[${entry.scope}]${colors.reset} ` : "";
589
+ const prefix = `${timestamp2} ${level} ${scope}${entry.message}`;
590
+ if (entry.context && Object.keys(entry.context).length > 0) {
591
+ consoleMethod(prefix, formatContext(entry.context));
592
+ } else {
593
+ consoleMethod(prefix);
594
+ }
595
+ };
596
+ // ../internal/logger/src/formatters/ci.ts
597
+ var LEVEL_PREFIX = {
598
+ debug: "[DEBUG]",
599
+ info: "[INFO]",
600
+ warn: "[WARN]",
601
+ error: "[ERROR]"
602
+ };
603
+ function formatContext2(context) {
604
+ return Object.entries(context).map(([key, value]) => `${key}=${formatValue2(value)}`).join(" ");
605
+ }
606
+ function formatValue2(value) {
607
+ if (typeof value === "string")
608
+ return value;
609
+ if (typeof value === "number")
610
+ return String(value);
611
+ if (typeof value === "boolean")
612
+ return String(value);
613
+ if (value === null)
614
+ return "null";
615
+ if (value === undefined)
616
+ return "undefined";
617
+ return JSON.stringify(value);
618
+ }
619
+ var ciFormatter = (entry) => {
620
+ const parts = [];
621
+ parts.push(entry.timestamp.toISOString());
622
+ parts.push(LEVEL_PREFIX[entry.level]);
623
+ if (entry.scope) {
624
+ parts.push(`[${entry.scope}]`);
625
+ }
626
+ parts.push(entry.message);
627
+ if (entry.context && Object.keys(entry.context).length > 0) {
628
+ parts.push(formatContext2(entry.context));
629
+ }
630
+ console.log(parts.join(" "));
631
+ };
632
+ // ../internal/logger/src/formatters/production.ts
633
+ var productionFormatter = (entry) => {
634
+ const output = {
635
+ timestamp: entry.timestamp.toISOString(),
636
+ level: entry.level,
637
+ ...entry.scope && { scope: entry.scope },
638
+ msg: entry.message
639
+ };
640
+ if (entry.context && Object.keys(entry.context).length > 0) {
641
+ Object.assign(output, entry.context);
642
+ }
643
+ console.log(JSON.stringify(output));
644
+ };
645
+ // ../internal/logger/src/formatters/browser.ts
646
+ var LEVEL_STYLES = {
647
+ debug: "color: gray",
648
+ info: "color: #0ea5e9",
649
+ warn: "color: #f59e0b",
650
+ error: "color: #ef4444; font-weight: bold"
651
+ };
652
+ var LEVEL_METHODS = {
653
+ debug: "log",
654
+ info: "info",
655
+ warn: "warn",
656
+ error: "error"
657
+ };
658
+ var browserFormatter = (entry) => {
659
+ const method = LEVEL_METHODS[entry.level];
660
+ const style = LEVEL_STYLES[entry.level];
661
+ const prefix = entry.scope ? `[${entry.scope}]` : "";
662
+ const label = `%c${prefix} ${entry.message}`;
663
+ if (entry.context && Object.keys(entry.context).length > 0) {
664
+ console[method](label, style, entry.context);
665
+ } else {
666
+ console[method](label, style);
667
+ }
668
+ };
669
+ // ../internal/logger/src/logger.ts
670
+ var LOG_LEVELS = ["debug", "info", "warn", "error"];
671
+ function getFormatter(env) {
672
+ switch (env) {
673
+ case "terminal":
674
+ return terminalFormatter;
675
+ case "ci":
676
+ return ciFormatter;
677
+ case "production":
678
+ return productionFormatter;
679
+ case "browser":
680
+ return browserFormatter;
681
+ case "test":
682
+ return () => {};
683
+ }
684
+ }
685
+ function getDefaultMinLevel() {
686
+ if (typeof process !== "undefined" && process.env?.DEBUG) {
687
+ return "debug";
688
+ }
689
+ return "info";
690
+ }
691
+ function shouldLog(level, minLevel) {
692
+ return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(minLevel);
693
+ }
694
+
695
+ class Logger {
696
+ scope;
697
+ minLevel;
698
+ environment;
699
+ formatter;
700
+ defaultContext;
701
+ constructor(options = {}) {
702
+ this.scope = options.scope;
703
+ this.minLevel = options.minLevel ?? getDefaultMinLevel();
704
+ this.defaultContext = options.defaultContext ?? {};
705
+ this.environment = options.environment ?? detectEnvironment();
706
+ this.formatter = getFormatter(this.environment);
707
+ }
708
+ child(scope) {
709
+ const childScope = this.scope ? `${this.scope}:${scope}` : scope;
710
+ return new Logger({
711
+ scope: childScope,
712
+ minLevel: this.minLevel,
713
+ environment: this.environment,
714
+ defaultContext: { ...this.defaultContext }
715
+ });
716
+ }
717
+ withContext(context) {
718
+ return new Logger({
719
+ scope: this.scope,
720
+ minLevel: this.minLevel,
721
+ environment: this.environment,
722
+ defaultContext: { ...this.defaultContext, ...context }
723
+ });
724
+ }
725
+ debug(message, context) {
726
+ this.log("debug", message, context);
727
+ }
728
+ info(message, context) {
729
+ this.log("info", message, context);
730
+ }
731
+ warn(message, context) {
732
+ this.log("warn", message, context);
733
+ }
734
+ error(message, context) {
735
+ this.log("error", message, context);
736
+ }
737
+ log(level, message, context) {
738
+ if (level === "debug" && !shouldShowDebug(this.scope)) {
739
+ return;
740
+ }
741
+ if (!shouldLog(level, this.minLevel)) {
742
+ return;
743
+ }
744
+ const entry = {
745
+ level,
746
+ message,
747
+ scope: this.scope,
748
+ context: context || Object.keys(this.defaultContext).length > 0 ? { ...this.defaultContext, ...context } : undefined,
749
+ timestamp: new Date
750
+ };
751
+ this.formatter(entry);
752
+ }
753
+ }
754
+ function createLogger(options = {}) {
755
+ return new Logger(options);
756
+ }
757
+ // src/server/lib/logger.ts
758
+ function isDebug() {
759
+ try {
760
+ const debug = typeof process === "undefined" ? undefined : process.env.DEBUG;
761
+ return debug === "1" || debug === "true";
762
+ } catch {
763
+ return false;
764
+ }
765
+ }
766
+ function createScopedLogger(scope) {
767
+ return createLogger({
768
+ scope: `timeback:${scope}`,
769
+ minLevel: isDebug() ? "debug" : "warn"
770
+ });
771
+ }
772
+ var ssoLog = createScopedLogger("sso");
773
+ var oidcLog = createScopedLogger("oidc");
774
+
775
+ // src/server/lib/oidc.ts
776
+ var discoveryCache = new Map;
777
+ async function fetchDiscoveryDocument(issuer) {
778
+ const cached = discoveryCache.get(issuer);
779
+ if (cached) {
780
+ return cached;
781
+ }
782
+ const url = `${issuer}/.well-known/openid-configuration`;
783
+ const response = await fetch(url);
784
+ if (!response.ok) {
785
+ oidcLog.error("Discovery fetch failed", { status: response.status });
786
+ throw new Error(`Failed to fetch OIDC discovery: ${response.statusText}`);
787
+ }
788
+ const doc = await response.json();
789
+ oidcLog.debug("Fetched OIDC discovery document", {
790
+ authEndpoint: doc.authorization_endpoint,
791
+ tokenEndpoint: doc.token_endpoint
792
+ });
793
+ discoveryCache.set(issuer, doc);
794
+ return doc;
795
+ }
796
+ function getIssuer(env) {
797
+ switch (env) {
798
+ case "production":
799
+ return "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_3uhuoRM3R";
800
+ case "staging":
801
+ return "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_5EUwTP9XD";
802
+ case "local":
803
+ throw new Error("Local environment is not yet supported for OIDC");
804
+ }
805
+ }
806
+ async function buildAuthorizationUrl(params) {
807
+ const discovery = await fetchDiscoveryDocument(params.issuer);
808
+ const url = new URL(discovery.authorization_endpoint);
809
+ url.searchParams.set("response_type", "code");
810
+ url.searchParams.set("client_id", params.clientId);
811
+ url.searchParams.set("redirect_uri", params.redirectUri);
812
+ url.searchParams.set("scope", "openid profile email");
813
+ url.searchParams.set("state", params.state);
814
+ return url.toString();
815
+ }
816
+ async function exchangeCodeForTokens(params) {
817
+ const discovery = await fetchDiscoveryDocument(params.issuer);
818
+ const response = await fetch(discovery.token_endpoint, {
819
+ method: "POST",
820
+ headers: {
821
+ "Content-Type": "application/x-www-form-urlencoded"
822
+ },
823
+ body: new URLSearchParams({
824
+ grant_type: "authorization_code",
825
+ client_id: params.clientId,
826
+ client_secret: params.clientSecret,
827
+ code: params.code,
828
+ redirect_uri: params.redirectUri
829
+ })
830
+ });
831
+ if (!response.ok) {
832
+ const text = await response.text();
833
+ oidcLog.error("Token exchange failed", { status: response.status, body: text });
834
+ throw new Error(`Token exchange failed: ${response.status} ${text}`);
835
+ }
836
+ const tokens = await response.json();
837
+ oidcLog.debug("Received tokens from IdP", { expiresIn: tokens.expires_in });
838
+ return tokens;
839
+ }
840
+ async function getUserInfo(params) {
841
+ const discovery = await fetchDiscoveryDocument(params.issuer);
842
+ const response = await fetch(discovery.userinfo_endpoint, {
843
+ headers: {
844
+ Authorization: `Bearer ${params.accessToken}`
845
+ }
846
+ });
847
+ if (!response.ok) {
848
+ throw new Error(`UserInfo request failed: ${response.statusText}`);
849
+ }
850
+ return response.json();
851
+ }
852
+
853
+ // src/server/lib/utils.ts
854
+ function jsonResponse(data, status = 200, headers) {
855
+ const responseHeaders = new Headers(headers);
856
+ responseHeaders.set("Content-Type", "application/json");
857
+ return new Response(JSON.stringify(data), { status, headers: responseHeaders });
858
+ }
859
+ function redirectResponse(url, headers) {
860
+ const responseHeaders = new Headers(headers);
861
+ responseHeaders.set("Location", url);
862
+ return new Response(null, { status: 302, headers: responseHeaders });
863
+ }
864
+ function encodeBase64Url(data) {
865
+ const json = JSON.stringify(data);
866
+ return btoa(json).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
867
+ }
868
+ function decodeBase64Url(encoded) {
869
+ const padded = encoded.replace(/-/g, "+").replace(/_/g, "/");
870
+ const json = atob(padded);
871
+ return JSON.parse(json);
872
+ }
873
+
874
+ // src/server/handlers/identity-only.ts
875
+ function buildErrorContext(error, errorCode, state, req) {
876
+ return {
877
+ error,
878
+ errorCode,
879
+ state,
880
+ req,
881
+ redirect: redirectResponse,
882
+ json: jsonResponse
883
+ };
884
+ }
885
+ function tryDecodeState(stateParam) {
886
+ try {
887
+ return decodeBase64Url(stateParam);
888
+ } catch {
889
+ ssoLog.warn("Failed to decode state");
890
+ return;
891
+ }
892
+ }
893
+ function handleCallbackError(errorParam, url, state, req, identity) {
894
+ const errorDesc = url.searchParams.get("error_description");
895
+ ssoLog.error("IdP returned error", { error: errorParam, description: errorDesc });
896
+ const error = new Error(errorDesc ?? errorParam);
897
+ if (identity.onCallbackError) {
898
+ return identity.onCallbackError(buildErrorContext(error, errorParam, state, req));
899
+ }
900
+ return jsonResponse({ error: errorParam }, 400);
901
+ }
902
+ function handleMissingCode(state, req, identity) {
903
+ ssoLog.error("Missing authorization code in callback");
904
+ const error = new Error("Missing authorization code");
905
+ if (identity.onCallbackError) {
906
+ return identity.onCallbackError(buildErrorContext(error, "missing_code", state, req));
907
+ }
908
+ return jsonResponse({ error: "Missing authorization code" }, 400);
909
+ }
910
+ async function handleSignIn(req, env, identity) {
911
+ const issuer = identity.issuer ?? getIssuer(env);
912
+ const url = new URL(req.url);
913
+ let redirectUri = identity.redirectUri;
914
+ if (!redirectUri) {
915
+ const basePath = url.pathname.replace(ROUTES.IDENTITY.SIGNIN, "");
916
+ redirectUri = `${url.origin}${basePath}${ROUTES.IDENTITY.CALLBACK}`;
917
+ }
918
+ ssoLog.debug("SSO sign-in initiated (identity-only)", {
919
+ env,
920
+ issuer,
921
+ clientId: identity.clientId,
922
+ redirectUri
923
+ });
924
+ const stateData = identity.buildState ? identity.buildState({ req, url }) : {};
925
+ const state = encodeBase64Url(stateData);
926
+ const authUrl = await buildAuthorizationUrl({
927
+ issuer,
928
+ clientId: identity.clientId,
929
+ redirectUri,
930
+ state
931
+ });
932
+ return redirectResponse(authUrl);
933
+ }
934
+ async function completeCallbackIdentityOnly(code, url, state, req, env, identity) {
935
+ try {
936
+ const issuer = identity.issuer ?? getIssuer(env);
937
+ let redirectUri = identity.redirectUri;
938
+ if (!redirectUri) {
939
+ const basePath = url.pathname.replace(ROUTES.IDENTITY.CALLBACK, "");
940
+ redirectUri = `${url.origin}${basePath}${ROUTES.IDENTITY.CALLBACK}`;
941
+ }
942
+ ssoLog.debug("Exchanging auth code for tokens (identity-only)", {
943
+ issuer,
944
+ clientId: identity.clientId
945
+ });
946
+ const tokens = await exchangeCodeForTokens({
947
+ issuer,
948
+ clientId: identity.clientId,
949
+ clientSecret: identity.clientSecret,
950
+ code,
951
+ redirectUri
952
+ });
953
+ const userInfo = await getUserInfo({ issuer, accessToken: tokens.access_token });
954
+ const identities = typeof userInfo.identities === "string" ? JSON.parse(userInfo.identities) : userInfo.identities;
955
+ ssoLog.debug("SSO completed (identity-only)", { user: { ...userInfo, identities } });
956
+ const ctx = {
957
+ tokens,
958
+ user: userInfo,
959
+ state,
960
+ req,
961
+ redirect: redirectResponse,
962
+ json: jsonResponse
963
+ };
964
+ return identity.onCallbackSuccess(ctx);
965
+ } catch (err) {
966
+ const error = err instanceof Error ? err : new Error("Unknown error");
967
+ ssoLog.error("Token exchange failed (identity-only)", { error: error.message });
968
+ if (identity.onCallbackError) {
969
+ return identity.onCallbackError(buildErrorContext(error, undefined, state, req));
970
+ }
971
+ return jsonResponse({ error: error.message }, 500);
972
+ }
973
+ }
974
+ async function handleCallbackIdentityOnly(req, env, identity) {
975
+ const url = new URL(req.url);
976
+ const code = url.searchParams.get("code");
977
+ const errorParam = url.searchParams.get("error");
978
+ const stateParam = url.searchParams.get("state");
979
+ ssoLog.debug("Received callback from IdP (identity-only)", {
980
+ hasCode: !!code,
981
+ error: errorParam
982
+ });
983
+ const state = stateParam ? tryDecodeState(stateParam) : undefined;
984
+ if (errorParam) {
985
+ return await handleCallbackError(errorParam, url, state, req, identity);
986
+ }
987
+ if (!code) {
988
+ return await handleMissingCode(state, req, identity);
989
+ }
990
+ return await completeCallbackIdentityOnly(code, url, state, req, env, identity);
991
+ }
992
+ function createIdentityOnlyHandlers(params) {
993
+ const { env, identity } = params;
994
+ if (identity.mode !== "sso") {
995
+ throw new Error('Identity-only mode requires identity.mode === "sso"');
996
+ }
997
+ return {
998
+ signIn: (req) => handleSignIn(req, env, identity),
999
+ callback: (req) => handleCallbackIdentityOnly(req, env, identity),
1000
+ signOut: () => redirectResponse("/")
1001
+ };
1002
+ }
1003
+
1004
+ // src/server/timeback-identity.ts
1005
+ function createTimebackIdentity(config) {
1006
+ const identity = createIdentityOnlyHandlers({
1007
+ env: config.env,
1008
+ identity: config.identity
1009
+ });
1010
+ return {
1011
+ config,
1012
+ handle: {
1013
+ identity
1014
+ }
1015
+ };
1016
+ }
1017
+ export {
1018
+ createTimebackIdentity
1019
+ };