kizlo 1.0.0-alpha.13 → 1.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/appearance/client.cjs +24 -0
- package/dist/appearance/client.d.cts +26 -0
- package/dist/appearance/client.d.cts.map +1 -0
- package/dist/appearance/client.d.ts +27 -0
- package/dist/appearance/client.d.ts.map +1 -0
- package/dist/appearance/client.js +22 -0
- package/dist/appearance/client.js.map +1 -0
- package/dist/appearance/type.d.cts +8 -0
- package/dist/appearance/type.d.cts.map +1 -0
- package/dist/appearance/type.d.ts +8 -0
- package/dist/appearance/type.d.ts.map +1 -0
- package/dist/auth/client.cjs +216 -0
- package/dist/auth/client.d.cts +458 -0
- package/dist/auth/client.d.cts.map +1 -0
- package/dist/auth/client.d.ts +459 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +211 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/types.d.cts +16 -0
- package/dist/auth/types.d.cts.map +1 -0
- package/dist/auth/types.d.ts +16 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/client.cjs +58 -0
- package/dist/client.d.cts +32 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +56 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.cjs +18 -0
- package/dist/constants.d.cts +9 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +13 -0
- package/dist/constants.js.map +1 -0
- package/dist/cookie.cjs +54 -0
- package/dist/cookie.js +52 -0
- package/dist/cookie.js.map +1 -0
- package/dist/core.cjs +70 -0
- package/dist/core.d.cts +23 -0
- package/dist/core.d.cts.map +1 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +69 -0
- package/dist/core.js.map +1 -0
- package/dist/extensions.cjs +104 -0
- package/dist/extensions.d.cts +75 -0
- package/dist/extensions.d.cts.map +1 -0
- package/dist/extensions.d.ts +75 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +90 -0
- package/dist/extensions.js.map +1 -0
- package/dist/http.cjs +104 -0
- package/dist/http.d.cts +25 -0
- package/dist/http.d.cts.map +1 -0
- package/dist/http.d.ts +25 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +103 -0
- package/dist/http.js.map +1 -0
- package/dist/index.cjs +73 -859
- package/dist/index.d.cts +19 -7009
- package/dist/index.d.ts +19 -7009
- package/dist/index.js +20 -801
- package/dist/integrations/nextjs/kizlo.client.cjs +22 -0
- package/dist/integrations/nextjs/kizlo.client.d.cts +17 -0
- package/dist/integrations/nextjs/kizlo.client.d.cts.map +1 -0
- package/dist/integrations/nextjs/kizlo.client.d.ts +17 -0
- package/dist/integrations/nextjs/kizlo.client.d.ts.map +1 -0
- package/dist/integrations/nextjs/kizlo.client.js +23 -0
- package/dist/integrations/nextjs/kizlo.client.js.map +1 -0
- package/dist/integrations/nextjs/kizlo.server.cjs +22 -0
- package/dist/integrations/nextjs/kizlo.server.d.cts +22 -0
- package/dist/integrations/nextjs/kizlo.server.d.cts.map +1 -0
- package/dist/integrations/nextjs/kizlo.server.d.ts +22 -0
- package/dist/integrations/nextjs/kizlo.server.d.ts.map +1 -0
- package/dist/integrations/nextjs/kizlo.server.js +23 -0
- package/dist/integrations/nextjs/kizlo.server.js.map +1 -0
- package/dist/integrations/nextjs/middleware.cjs +44 -0
- package/dist/integrations/nextjs/middleware.d.cts +16 -0
- package/dist/integrations/nextjs/middleware.d.cts.map +1 -0
- package/dist/integrations/nextjs/middleware.d.ts +16 -0
- package/dist/integrations/nextjs/middleware.d.ts.map +1 -0
- package/dist/integrations/nextjs/middleware.js +41 -0
- package/dist/integrations/nextjs/middleware.js.map +1 -0
- package/dist/integrations/nextjs/utils.cjs +78 -0
- package/dist/integrations/nextjs/utils.js +74 -0
- package/dist/integrations/nextjs/utils.js.map +1 -0
- package/dist/kizlo.cjs +29 -0
- package/dist/kizlo.d.cts +988 -0
- package/dist/kizlo.d.cts.map +1 -0
- package/dist/kizlo.d.ts +988 -0
- package/dist/kizlo.d.ts.map +1 -0
- package/dist/kizlo.js +29 -0
- package/dist/kizlo.js.map +1 -0
- package/dist/nextjs/server.cjs +7 -0
- package/dist/nextjs/server.d.cts +3 -0
- package/dist/nextjs/server.d.ts +4 -0
- package/dist/nextjs/server.js +5 -0
- package/dist/nextjs.cjs +3 -0
- package/dist/nextjs.d.cts +2 -0
- package/dist/nextjs.d.ts +2 -0
- package/dist/nextjs.js +3 -0
- package/dist/package.cjs +11 -0
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/post/service.cjs +72 -0
- package/dist/post/service.d.cts +22 -0
- package/dist/post/service.d.cts.map +1 -0
- package/dist/post/service.d.ts +24 -0
- package/dist/post/service.d.ts.map +1 -0
- package/dist/post/service.js +70 -0
- package/dist/post/service.js.map +1 -0
- package/dist/post/type.d.cts +12 -0
- package/dist/post/type.d.cts.map +1 -0
- package/dist/post/type.d.ts +12 -0
- package/dist/post/type.d.ts.map +1 -0
- package/dist/schema.cjs +13 -0
- package/dist/schema.d.cts +9 -0
- package/dist/schema.d.cts.map +1 -0
- package/dist/schema.d.ts +9 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +10 -0
- package/dist/schema.js.map +1 -0
- package/dist/server.cjs +187 -0
- package/dist/server.d.cts +40 -0
- package/dist/server.d.cts.map +1 -0
- package/dist/server.d.ts +40 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +181 -0
- package/dist/server.js.map +1 -0
- package/dist/types.cjs +10 -0
- package/dist/types.d.cts +159 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/user/client.cjs +41 -0
- package/dist/user/client.d.cts +110 -0
- package/dist/user/client.d.cts.map +1 -0
- package/dist/user/client.d.ts +111 -0
- package/dist/user/client.d.ts.map +1 -0
- package/dist/user/client.js +39 -0
- package/dist/user/client.js.map +1 -0
- package/dist/user/types.d.cts +9 -0
- package/dist/user/types.d.cts.map +1 -0
- package/dist/user/types.d.ts +9 -0
- package/dist/user/types.d.ts.map +1 -0
- package/dist/utils.cjs +76 -0
- package/dist/utils.d.cts +197 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.ts +197 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +65 -0
- package/dist/utils.js.map +1 -0
- package/package.json +52 -11
- package/dist/_internal.cjs +0 -892
- package/dist/_internal.d.cts +0 -959
- package/dist/_internal.d.cts.map +0 -1
- package/dist/_internal.d.ts +0 -959
- package/dist/_internal.d.ts.map +0 -1
- package/dist/_internal.js +0 -659
- package/dist/_internal.js.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/menus-BQUbBHjb.cjs +0 -2043
- package/dist/menus-Cj8cictC.js +0 -921
- package/dist/menus-Cj8cictC.js.map +0 -1
- package/dist/types-CCZeAl6v.d.ts +0 -35526
- package/dist/types-CCZeAl6v.d.ts.map +0 -1
- package/dist/types-D0rWUanT.d.cts +0 -35526
- package/dist/types-D0rWUanT.d.cts.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_utils = require('../utils.cjs');
|
|
3
|
+
const require_extensions = require('../extensions.cjs');
|
|
4
|
+
let __orpc_server = require("@orpc/server");
|
|
5
|
+
__orpc_server = require_rolldown_runtime.__toESM(__orpc_server);
|
|
6
|
+
|
|
7
|
+
//#region src/appearance/client.ts
|
|
8
|
+
var AppearanceService = class {
|
|
9
|
+
constructor(kizlo) {
|
|
10
|
+
this.kizlo = kizlo;
|
|
11
|
+
}
|
|
12
|
+
async menus(input) {
|
|
13
|
+
const response = await this.kizlo._.http.get(`/appearance/menus/${input.id}`);
|
|
14
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
15
|
+
return this.kizlo._.http.success(response.data);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const appearanceRouter = { menus: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
19
|
+
return require_utils.handleResult(await context.appearance.menus(input));
|
|
20
|
+
}) };
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.AppearanceService = AppearanceService;
|
|
24
|
+
exports.appearanceRouter = appearanceRouter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RetrieveMenusResult } from "./type.cjs";
|
|
2
|
+
import { KizloService } from "../kizlo.cjs";
|
|
3
|
+
import { SharedProcedureContext } from "../types.cjs";
|
|
4
|
+
import * as _orpc_server134 from "@orpc/server";
|
|
5
|
+
import * as _kizlo_contract19 from "@kizlo/contract";
|
|
6
|
+
import { ListMenuErrorCode, ListMenuInput } from "@kizlo/contract";
|
|
7
|
+
|
|
8
|
+
//#region src/appearance/client.d.ts
|
|
9
|
+
declare class AppearanceService {
|
|
10
|
+
private readonly kizlo;
|
|
11
|
+
constructor(kizlo: KizloService);
|
|
12
|
+
menus(input: ListMenuInput): Promise<RetrieveMenusResult>;
|
|
13
|
+
}
|
|
14
|
+
declare const appearanceRouter: {
|
|
15
|
+
menus: _orpc_server134.DecoratedProcedure<SharedProcedureContext & Record<never, never>, SharedProcedureContext, _orpc_server134.Schema<{
|
|
16
|
+
id: number;
|
|
17
|
+
}, {
|
|
18
|
+
id: number;
|
|
19
|
+
}>, _orpc_server134.Schema<_kizlo_contract19.MenuItem[], _kizlo_contract19.MenuItem[]>, _orpc_server134.MergedErrorMap<Record<never, never>, Record<ListMenuErrorCode, {
|
|
20
|
+
message: string;
|
|
21
|
+
status: number;
|
|
22
|
+
}>>, Record<never, never>>;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { AppearanceService, appearanceRouter };
|
|
26
|
+
//# sourceMappingURL=client.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":[],"sources":["../../src/appearance/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAOa,iBAAA;;qBACwB;eAEV,gBAAgB,QAAQ;;AAHtC,cAUA,gBAViB,EAAA;EACO,KAAA,oCAAA,CAiBpC,sBAAA,SAjBoC,CAAA,KAAA,EAAA,KAAA,CAAA,gDAAA,CAAA;IAEV,EAAA,EAAA,MAAA;EAAwB,CAAA,EAAA;IAAR,EAAA,EAAA,MAAA;EAAO,CAAA,CAAA,wBAAA,6BAAA,8BAAA,CAAA,gCAAA,OAAA,CAAA,KAAA,EAAA,KAAA,CAAA,QAAA,kBAAA,EAAA;IAOrC,OAAA,EAAA,MAQZ;IAAA,MAAA,EAAA,MAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RetrieveMenusResult } from "./type.js";
|
|
2
|
+
import "../index.js";
|
|
3
|
+
import { KizloService } from "../kizlo.js";
|
|
4
|
+
import { SharedProcedureContext } from "../types.js";
|
|
5
|
+
import * as _kizlo_contract19 from "@kizlo/contract";
|
|
6
|
+
import { ListMenuErrorCode, ListMenuInput } from "@kizlo/contract";
|
|
7
|
+
import * as _orpc_server134 from "@orpc/server";
|
|
8
|
+
|
|
9
|
+
//#region src/appearance/client.d.ts
|
|
10
|
+
declare class AppearanceService {
|
|
11
|
+
private readonly kizlo;
|
|
12
|
+
constructor(kizlo: KizloService);
|
|
13
|
+
menus(input: ListMenuInput): Promise<RetrieveMenusResult>;
|
|
14
|
+
}
|
|
15
|
+
declare const appearanceRouter: {
|
|
16
|
+
menus: _orpc_server134.DecoratedProcedure<SharedProcedureContext & Record<never, never>, SharedProcedureContext, _orpc_server134.Schema<{
|
|
17
|
+
id: number;
|
|
18
|
+
}, {
|
|
19
|
+
id: number;
|
|
20
|
+
}>, _orpc_server134.Schema<_kizlo_contract19.MenuItem[], _kizlo_contract19.MenuItem[]>, _orpc_server134.MergedErrorMap<Record<never, never>, Record<ListMenuErrorCode, {
|
|
21
|
+
message: string;
|
|
22
|
+
status: number;
|
|
23
|
+
}>>, Record<never, never>>;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AppearanceService, appearanceRouter };
|
|
27
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/appearance/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAOa,iBAAA;;qBACwB;eAEV,gBAAgB,QAAQ;;cAOtC;EAVA,KAAA,oCAAiB,CAkB7B,sBAAA,SAlB6B,CAAA,KAAA,EAAA,KAAA,CAAA,gDAAA,CAAA;IACO,EAAA,EAAA,MAAA;EAEV,CAAA,EAAA;IAAwB,EAAA,EAAA,MAAA;EAAR,CAAA,CAAA,wBAAA,6BAAA,8BAAA,CAAA,gCAAA,OAAA,CAAA,KAAA,EAAA,KAAA,CAAA,QAAA,kBAAA,EAAA;IAAO,OAAA,EAAA,MAAA;IAOrC,MAAA,EAAA,MAAA;EAQZ,CAAA,CAAA,CAAA,QAAA,CAAA,KAAA,EAAA,KAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { handleResult } from "../utils.js";
|
|
2
|
+
import { kz, procedureErrors } from "../extensions.js";
|
|
3
|
+
import { type } from "@orpc/server";
|
|
4
|
+
|
|
5
|
+
//#region src/appearance/client.ts
|
|
6
|
+
var AppearanceService = class {
|
|
7
|
+
constructor(kizlo) {
|
|
8
|
+
this.kizlo = kizlo;
|
|
9
|
+
}
|
|
10
|
+
async menus(input) {
|
|
11
|
+
const response = await this.kizlo._.http.get(`/appearance/menus/${input.id}`);
|
|
12
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
13
|
+
return this.kizlo._.http.success(response.data);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const appearanceRouter = { menus: kz.shared.input(type()).output(type()).errors(procedureErrors()).handler(async ({ input, context }) => {
|
|
17
|
+
return handleResult(await context.appearance.menus(input));
|
|
18
|
+
}) };
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AppearanceService, appearanceRouter };
|
|
22
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":["kizlo: KizloService"],"sources":["../../src/appearance/client.ts"],"sourcesContent":["import type { ListMenuErrorCode, ListMenuInput, ListMenuResponse } from \"@kizlo/contract\";\nimport { type } from \"@orpc/server\";\nimport { kz, procedureErrors } from \"../extensions\";\nimport type { KizloService } from \"../kizlo\";\nimport { handleResult } from \"../utils\";\nimport type { RetrieveMenusResult } from \"./type\";\n\nexport class AppearanceService {\n\tconstructor(private readonly kizlo: KizloService) {}\n\n\tpublic async menus(input: ListMenuInput): Promise<RetrieveMenusResult> {\n\t\tconst response = await this.kizlo._.http.get<ListMenuResponse, ListMenuErrorCode>(`/appearance/menus/${input.id}`);\n\t\tif (response.error) return this.kizlo._.http.error(response.error);\n\t\treturn this.kizlo._.http.success(response.data);\n\t}\n}\n\nexport const appearanceRouter = {\n\tmenus: kz.shared\n\t\t.input(type<ListMenuInput>())\n\t\t.output(type<ListMenuResponse>())\n\t\t.errors(procedureErrors<ListMenuErrorCode>())\n\t\t.handler(async ({ input, context }) => {\n\t\t\treturn handleResult(await context.appearance.menus(input));\n\t\t}),\n};\n"],"mappings":";;;;;AAOA,IAAa,oBAAb,MAA+B;CAC9B,YAAY,AAAiBA,OAAqB;EAArB;;CAE7B,MAAa,MAAM,OAAoD;EACtE,MAAM,WAAW,MAAM,KAAK,MAAM,EAAE,KAAK,IAAyC,qBAAqB,MAAM,KAAK;AAClH,MAAI,SAAS,MAAO,QAAO,KAAK,MAAM,EAAE,KAAK,MAAM,SAAS,MAAM;AAClE,SAAO,KAAK,MAAM,EAAE,KAAK,QAAQ,SAAS,KAAK;;;AAIjD,MAAa,mBAAmB,EAC/B,OAAO,GAAG,OACR,MAAM,MAAqB,CAAC,CAC5B,OAAO,MAAwB,CAAC,CAChC,OAAO,iBAAoC,CAAC,CAC5C,QAAQ,OAAO,EAAE,OAAO,cAAc;AACtC,QAAO,aAAa,MAAM,QAAQ,WAAW,MAAM,MAAM,CAAC;EACzD,EACH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KizloResult } from "../types.cjs";
|
|
2
|
+
import { ListMenuErrorCode, ListMenuResponse } from "@kizlo/contract";
|
|
3
|
+
|
|
4
|
+
//#region src/appearance/type.d.ts
|
|
5
|
+
type RetrieveMenusResult = KizloResult<ListMenuResponse, ListMenuErrorCode>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { RetrieveMenusResult };
|
|
8
|
+
//# sourceMappingURL=type.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.cts","names":[],"sources":["../../src/appearance/type.ts"],"sourcesContent":[],"mappings":";;;;KAGY,mBAAA,GAAsB,YAAY,kBAAkB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KizloResult } from "../types.js";
|
|
2
|
+
import { ListMenuErrorCode, ListMenuResponse } from "@kizlo/contract";
|
|
3
|
+
|
|
4
|
+
//#region src/appearance/type.d.ts
|
|
5
|
+
type RetrieveMenusResult = KizloResult<ListMenuResponse, ListMenuErrorCode>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { RetrieveMenusResult };
|
|
8
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","names":[],"sources":["../../src/appearance/type.ts"],"sourcesContent":[],"mappings":";;;;KAGY,mBAAA,GAAsB,YAAY,kBAAkB"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_utils = require('../utils.cjs');
|
|
3
|
+
const require_extensions = require('../extensions.cjs');
|
|
4
|
+
let __kizlo_shared = require("@kizlo/shared");
|
|
5
|
+
__kizlo_shared = require_rolldown_runtime.__toESM(__kizlo_shared);
|
|
6
|
+
let __orpc_server = require("@orpc/server");
|
|
7
|
+
__orpc_server = require_rolldown_runtime.__toESM(__orpc_server);
|
|
8
|
+
let jose = require("jose");
|
|
9
|
+
jose = require_rolldown_runtime.__toESM(jose);
|
|
10
|
+
let jose_errors = require("jose/errors");
|
|
11
|
+
jose_errors = require_rolldown_runtime.__toESM(jose_errors);
|
|
12
|
+
|
|
13
|
+
//#region src/auth/client.ts
|
|
14
|
+
var AuthService = class {
|
|
15
|
+
_jwks;
|
|
16
|
+
_userSessionCookieName;
|
|
17
|
+
_anonSessionCookieName;
|
|
18
|
+
constructor(kizlo) {
|
|
19
|
+
this.kizlo = kizlo;
|
|
20
|
+
this._userSessionCookieName = `${this.kizlo._.cookiePrefix}-session`;
|
|
21
|
+
this._anonSessionCookieName = `${this.kizlo._.cookiePrefix}-anon-session`;
|
|
22
|
+
}
|
|
23
|
+
async signUp(input) {
|
|
24
|
+
const response = await this.kizlo._.http.post("/auth/signup", { body: input });
|
|
25
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
26
|
+
return this.kizlo._.http.success(response.data);
|
|
27
|
+
}
|
|
28
|
+
async signInWithPassword(input) {
|
|
29
|
+
return this.withAuth(async ({ headers }) => {
|
|
30
|
+
const response = await this.kizlo._.http.post("/auth/signin/password", {
|
|
31
|
+
headers,
|
|
32
|
+
body: input
|
|
33
|
+
});
|
|
34
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
35
|
+
if (response.data) await this._setUserSessionCookie(response.data);
|
|
36
|
+
return this.kizlo._.http.success(response.data);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async signInWithToken(input) {
|
|
40
|
+
const response = await this.kizlo._.http.post("/auth/signin/token", { body: input });
|
|
41
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
42
|
+
return this.kizlo._.http.success(response.data);
|
|
43
|
+
}
|
|
44
|
+
async resetPassword(input) {
|
|
45
|
+
const response = await this.kizlo._.http.post("/auth/recover", { body: input });
|
|
46
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
47
|
+
return this.kizlo._.http.success(response.data);
|
|
48
|
+
}
|
|
49
|
+
async verifyToken(input) {
|
|
50
|
+
return this.withAuth(async ({ headers }) => {
|
|
51
|
+
const response = await this.kizlo._.http.post("/auth/verify", {
|
|
52
|
+
headers,
|
|
53
|
+
body: input
|
|
54
|
+
});
|
|
55
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
56
|
+
if (response.data.session) await this._setUserSessionCookie(response.data.session);
|
|
57
|
+
return this.kizlo._.http.success(response.data);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async resendToken(input) {
|
|
61
|
+
return this.withAuth(async ({ headers }) => {
|
|
62
|
+
const response = await this.kizlo._.http.post("/auth/resend", {
|
|
63
|
+
headers,
|
|
64
|
+
body: input
|
|
65
|
+
});
|
|
66
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
67
|
+
return this.kizlo._.http.success(response.data);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async refreshSession(input) {
|
|
71
|
+
console.log("Session expired, refreshing...");
|
|
72
|
+
if (!(input?.refresh_token ?? (await this._getUserSessionCookie())?.refresh_token)) return this.kizlo._.http.error("AUTH_SESSION_EXPIRED");
|
|
73
|
+
const response = await this.kizlo._.http.post("/auth/refresh", {
|
|
74
|
+
body: input,
|
|
75
|
+
headers: await this._getAuthHeaders()
|
|
76
|
+
});
|
|
77
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
78
|
+
if (response.data) await this._setUserSessionCookie(response.data);
|
|
79
|
+
console.log("Session refreshed successfully 👌");
|
|
80
|
+
return this.kizlo._.http.success(response.data);
|
|
81
|
+
}
|
|
82
|
+
async signOut(input) {
|
|
83
|
+
return this.withAuth(async ({ headers }) => {
|
|
84
|
+
const response = await this.kizlo._.http.post("/auth/signout", {
|
|
85
|
+
headers,
|
|
86
|
+
body: input
|
|
87
|
+
});
|
|
88
|
+
if (response.error) return this.kizlo._.http.error(response.error);
|
|
89
|
+
await this._setAnonSessionCookie();
|
|
90
|
+
await this._expireUserSessionCookie();
|
|
91
|
+
return this.kizlo._.http.success(response.data);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async getSession() {
|
|
95
|
+
return this.withAuth(({ session }) => session);
|
|
96
|
+
}
|
|
97
|
+
async getClaims(input) {
|
|
98
|
+
const data = await this._getUserSessionCookie();
|
|
99
|
+
if (!data) {
|
|
100
|
+
await this._setAnonSessionCookie();
|
|
101
|
+
return this.kizlo._.http.success(null);
|
|
102
|
+
}
|
|
103
|
+
const accessToken = input?.access_token ?? data.access_token;
|
|
104
|
+
try {
|
|
105
|
+
const { payload } = await (0, jose.jwtVerify)(accessToken, this._getJWKS());
|
|
106
|
+
return this.kizlo._.http.success(payload);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
if (err instanceof jose_errors.JWTExpired) {
|
|
109
|
+
if (input?.allow_expire) return this.kizlo._.http.success((0, jose.decodeJwt)(accessToken));
|
|
110
|
+
return this.kizlo._.http.error("AUTH_TOKEN_EXPIRED");
|
|
111
|
+
}
|
|
112
|
+
return this.kizlo._.http.error("AUTH_TOKEN_INVALID");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_getJWKS() {
|
|
116
|
+
this._jwks ??= (0, jose.createRemoteJWKSet)(new URL("/auth/.well-known/jwks.json", this.kizlo._.apiUrl), { cooldownDuration: 1e3 * 60 * 5 });
|
|
117
|
+
return this._jwks;
|
|
118
|
+
}
|
|
119
|
+
async withAuth(callback) {
|
|
120
|
+
let session = await this._getUserSessionCookie();
|
|
121
|
+
if (session) {
|
|
122
|
+
if (session.expires_at ? Date.now() > session.expires_at * 1e3 : false) {
|
|
123
|
+
const { data: refreshedSession, error: refreshError } = await this.refreshSession({ refresh_token: session.refresh_token });
|
|
124
|
+
if (!refreshError) session = refreshedSession;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return await Promise.resolve(callback({
|
|
128
|
+
session,
|
|
129
|
+
headers: await this._getAuthHeaders(session)
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
async _getUserSessionCookie() {
|
|
133
|
+
const value = await this.kizlo._.cookies.get(this._userSessionCookieName);
|
|
134
|
+
return value ? this._decodeSession(value) : null;
|
|
135
|
+
}
|
|
136
|
+
async _setUserSessionCookie(data) {
|
|
137
|
+
await this.kizlo._.cookies.set([{
|
|
138
|
+
value: this._encodeSession(data),
|
|
139
|
+
name: this._userSessionCookieName,
|
|
140
|
+
options: {
|
|
141
|
+
httpOnly: false,
|
|
142
|
+
path: "/",
|
|
143
|
+
sameSite: "lax",
|
|
144
|
+
expires: (0, __kizlo_shared.date)("1 year")
|
|
145
|
+
}
|
|
146
|
+
}]);
|
|
147
|
+
await this.kizlo._.cookies.delete(this._anonSessionCookieName);
|
|
148
|
+
}
|
|
149
|
+
async _expireUserSessionCookie() {
|
|
150
|
+
await this.kizlo._.cookies.delete(this._userSessionCookieName);
|
|
151
|
+
}
|
|
152
|
+
async _getAnonSessionCookie() {
|
|
153
|
+
const value = await this.kizlo._.cookies.get(this._anonSessionCookieName);
|
|
154
|
+
const token = value ? (0, __kizlo_shared.base64Decode)(value) : null;
|
|
155
|
+
return token?.startsWith("anon") ? token : null;
|
|
156
|
+
}
|
|
157
|
+
async _setAnonSessionCookie() {
|
|
158
|
+
if (await this._getAnonSessionCookie()) return;
|
|
159
|
+
await this.kizlo._.cookies.set([{
|
|
160
|
+
name: this._anonSessionCookieName,
|
|
161
|
+
value: (0, __kizlo_shared.base64Encode)((0, __kizlo_shared.random)({ prefix: "anon" })),
|
|
162
|
+
options: {
|
|
163
|
+
httpOnly: false,
|
|
164
|
+
path: "/",
|
|
165
|
+
sameSite: "lax",
|
|
166
|
+
expires: (0, __kizlo_shared.date)("1 year")
|
|
167
|
+
}
|
|
168
|
+
}]);
|
|
169
|
+
}
|
|
170
|
+
async _getAuthHeaders(session) {
|
|
171
|
+
const token = (session ?? await this._getUserSessionCookie())?.access_token ?? await this._getAnonSessionCookie();
|
|
172
|
+
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
173
|
+
}
|
|
174
|
+
_encodeSession(data) {
|
|
175
|
+
return (0, __kizlo_shared.base64Encode)(data);
|
|
176
|
+
}
|
|
177
|
+
_decodeSession(session) {
|
|
178
|
+
return (0, __kizlo_shared.base64Decode)(session);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const authRouter = {
|
|
182
|
+
signUp: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
183
|
+
return require_utils.handleResult(await context.auth.signUp(input));
|
|
184
|
+
}),
|
|
185
|
+
signInWithPassword: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
186
|
+
return require_utils.handleResult(await context.auth.signInWithPassword(input));
|
|
187
|
+
}),
|
|
188
|
+
signInWithToken: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
189
|
+
return require_utils.handleResult(await context.auth.signInWithToken(input));
|
|
190
|
+
}),
|
|
191
|
+
getClaims: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
192
|
+
return require_utils.handleResult(await context.auth.getClaims(input));
|
|
193
|
+
}),
|
|
194
|
+
getSession: require_extensions.kz.shared.output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ context }) => {
|
|
195
|
+
return require_utils.handleResult(await context.auth.getSession());
|
|
196
|
+
}),
|
|
197
|
+
resetPassword: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
198
|
+
return require_utils.handleResult(await context.auth.resetPassword(input));
|
|
199
|
+
}),
|
|
200
|
+
verifyToken: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
201
|
+
return require_utils.handleResult(await context.auth.verifyToken(input));
|
|
202
|
+
}),
|
|
203
|
+
resendToken: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
204
|
+
return require_utils.handleResult(await context.auth.resendToken(input));
|
|
205
|
+
}),
|
|
206
|
+
refreshSession: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
207
|
+
return require_utils.handleResult(await context.auth.refreshSession(input));
|
|
208
|
+
}),
|
|
209
|
+
signOut: require_extensions.kz.shared.input((0, __orpc_server.type)()).output((0, __orpc_server.type)()).errors(require_extensions.procedureErrors()).handler(async ({ input, context }) => {
|
|
210
|
+
return require_utils.handleResult(await context.auth.signOut(input));
|
|
211
|
+
})
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
//#endregion
|
|
215
|
+
exports.AuthService = AuthService;
|
|
216
|
+
exports.authRouter = authRouter;
|