@open-norantec/utilities 2.6.0 → 2.6.2
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.
|
@@ -26,7 +26,7 @@ type AuthenticationMethodMap<Bindings extends BindingsType, SS extends z.ZodObje
|
|
|
26
26
|
type AuthKey<AMM extends AuthenticationMethodMap<{}, z.ZodObject>> = Extract<keyof AMM, string>;
|
|
27
27
|
type HandlerContext<IS extends HTTPBodyType, Bindings extends BindingsType, SS extends z.ZodObject, A extends Array<keyof AuthenticationMethodMap<Bindings, SS>>> = BaseContext<Bindings, SS> & {
|
|
28
28
|
authentication: A extends [] ? null : A[number];
|
|
29
|
-
|
|
29
|
+
identifier: string;
|
|
30
30
|
input: IS extends string ? ReadableStreamDefaultReader<Uint8Array> : z.infer<IS>;
|
|
31
31
|
};
|
|
32
32
|
interface HookContext {
|
package/dist/hono-util.class.js
CHANGED
|
@@ -126,7 +126,7 @@ class HonoUtil {
|
|
|
126
126
|
query: c.req.query.bind(c.req),
|
|
127
127
|
queries: c.req.queries.bind(c.req),
|
|
128
128
|
};
|
|
129
|
-
const
|
|
129
|
+
const authenticateResult = yield attempt_util_class_1.AttemptUtil.execPromise((() => __awaiter(this, void 0, void 0, function* () {
|
|
130
130
|
let authenticationValue = null;
|
|
131
131
|
if (!Array.isArray(authenticationTypes) || authenticationTypes.length === 0) {
|
|
132
132
|
return {
|
|
@@ -150,8 +150,12 @@ class HonoUtil {
|
|
|
150
150
|
if (!(finalResult === null || finalResult === void 0 ? void 0 : finalResult.type))
|
|
151
151
|
throw new StatusError(401);
|
|
152
152
|
return { authenticationValue: finalResult.result, authentication: finalResult.type };
|
|
153
|
-
}))();
|
|
154
|
-
|
|
153
|
+
}))());
|
|
154
|
+
if (authenticateResult instanceof Error) {
|
|
155
|
+
return c.json({ error: authenticateResult.message }, authenticateResult instanceof StatusError ? authenticateResult.status : 400);
|
|
156
|
+
}
|
|
157
|
+
const { authentication, authenticationValue } = authenticateResult;
|
|
158
|
+
const rawOutput = yield attempt_util_class_1.AttemptUtil.execPromise(handler(Object.assign({ input, authentication: authentication, identifier: authenticationValue }, baseContext)));
|
|
155
159
|
if (rawOutput instanceof Error) {
|
|
156
160
|
console.log('Handler error', rawOutput, rawOutput === null || rawOutput === void 0 ? void 0 : rawOutput.message, rawOutput === null || rawOutput === void 0 ? void 0 : rawOutput.stack);
|
|
157
161
|
return c.json({ error: rawOutput.message }, rawOutput instanceof StatusError ? rawOutput.status : 400);
|