@opexa/portal-components 0.0.1

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.
@@ -0,0 +1,8 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ declare const config: {
4
+ matcher: string[];
5
+ };
6
+ declare function middleware(request: NextRequest): Promise<NextResponse<unknown>>;
7
+
8
+ export { config, middleware };
@@ -0,0 +1,8 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ declare const config: {
4
+ matcher: string[];
5
+ };
6
+ declare function middleware(request: NextRequest): Promise<NextResponse<unknown>>;
7
+
8
+ export { config, middleware };
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/middleware.ts
21
+ var middleware_exports = {};
22
+ __export(middleware_exports, {
23
+ config: () => config,
24
+ middleware: () => middleware
25
+ });
26
+ module.exports = __toCommonJS(middleware_exports);
27
+ var import_portal_sdk_core = require("@opexa/portal-sdk-core");
28
+
29
+ // ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constants.js
30
+ var daysInYear = 365.2425;
31
+ var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
32
+ var minTime = -maxTime;
33
+ var millisecondsInMinute = 6e4;
34
+ var secondsInHour = 3600;
35
+ var secondsInDay = secondsInHour * 24;
36
+ var secondsInWeek = secondsInDay * 7;
37
+ var secondsInYear = secondsInDay * daysInYear;
38
+ var secondsInMonth = secondsInYear / 12;
39
+ var secondsInQuarter = secondsInMonth * 3;
40
+ var constructFromSymbol = Symbol.for("constructDateFrom");
41
+
42
+ // ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constructFrom.js
43
+ function constructFrom(date, value) {
44
+ if (typeof date === "function") return date(value);
45
+ if (date && typeof date === "object" && constructFromSymbol in date)
46
+ return date[constructFromSymbol](value);
47
+ if (date instanceof Date) return new date.constructor(value);
48
+ return new Date(value);
49
+ }
50
+
51
+ // ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/toDate.js
52
+ function toDate(argument, context) {
53
+ return constructFrom(context || argument, argument);
54
+ }
55
+
56
+ // ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addMinutes.js
57
+ function addMinutes(date, amount, options) {
58
+ const _date = toDate(date, options == null ? void 0 : options.in);
59
+ _date.setTime(_date.getTime() + amount * millisecondsInMinute);
60
+ return _date;
61
+ }
62
+
63
+ // src/lib/middleware.ts
64
+ var import_server = require("next/server");
65
+
66
+ // src/lib/constants/index.ts
67
+ var import_zod = require("zod");
68
+ var SITE_ID = import_zod.z.string().min(1, 'Environment variable "NEXT_PUBLIC_SITE_ID" must be 1 or more characters').max(32, 'Environment variable "NEXT_PUBLIC_SITE_ID" must not be more than 32 characters').trim().parse(process.env.NEXT_PUBLIC_SITE_ID);
69
+ var PLATFORM_ID = import_zod.z.string().min(1, 'Environment variable "NEXT_PUBLIC_PLATFORM_ID" must be 1 or more characters').max(32, 'Environment variable "NEXT_PUBLIC_PLATFORM_ID" must not be more than 32 characters').trim().parse(process.env.NEXT_PUBLIC_PLATFORM_ID);
70
+ var PLATFORM_CODE = import_zod.z.string().min(4, 'Environment variable "NEXT_PUBLIC_PLATFORM_CODE" must be at least 4 characters').max(8, 'Environment variable "NEXT_PUBLIC_PLATFORM_CODE" must not be more than 8 characters').trim().parse(process.env.NEXT_PUBLIC_PLATFORM_CODE);
71
+ var ENVIRONMENT = import_zod.z.enum(["production", "development"]).catch("development").parse(process.env.NEXT_PUBLIC_ENVIRONMENT);
72
+ var BYPASS_RECAPTCHA = import_zod.z.any().transform(Boolean).catch(false).parse(process.env.NEXT_PUBLIC_BYPASS_RECAPTCHA);
73
+ var ACCESS_TOKEN_COOKIE_NAME = "WebPortalAuthAccessToken";
74
+ var REFRESH_TOKEN_COOKIE_NAME = "WebPortalAuthRefreshToken";
75
+
76
+ // src/lib/middleware.ts
77
+ var config = {
78
+ matcher: ["/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)"]
79
+ };
80
+ async function middleware(request) {
81
+ var _a, _b;
82
+ const accessToken = (_a = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)) == null ? void 0 : _a.value;
83
+ const refreshToken = (_b = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)) == null ? void 0 : _b.value;
84
+ const response = import_server.NextResponse.next();
85
+ if (!accessToken && refreshToken) {
86
+ try {
87
+ const data = await (0, import_portal_sdk_core.refreshSession)({
88
+ headers: {
89
+ Authorization: `Bearer ${refreshToken}`
90
+ },
91
+ environment: ENVIRONMENT
92
+ });
93
+ response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, data.accessToken, {
94
+ expires: addMinutes(/* @__PURE__ */ new Date(), 9),
95
+ httpOnly: true,
96
+ sameSite: "strict"
97
+ });
98
+ } catch {
99
+ response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
100
+ }
101
+ }
102
+ return response;
103
+ }
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ config,
107
+ middleware
108
+ });
109
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/middleware.ts","../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constants.js","../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constructFrom.js","../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/toDate.js","../../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/addMinutes.js","../src/lib/constants/index.ts"],"sourcesContent":["import { refreshSession } from '@opexa/portal-sdk-core';\r\nimport { addMinutes } from 'date-fns';\r\nimport { NextRequest, NextResponse } from 'next/server';\r\nimport { ACCESS_TOKEN_COOKIE_NAME, ENVIRONMENT, REFRESH_TOKEN_COOKIE_NAME } from './constants';\r\n\r\nexport const config = {\r\n matcher: ['/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'],\r\n};\r\n\r\nexport async function middleware(request: NextRequest) {\r\n const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;\r\n const refreshToken = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)?.value;\r\n\r\n const response = NextResponse.next();\r\n\r\n if (!accessToken && refreshToken) {\r\n try {\r\n const data = await refreshSession({\r\n headers: {\r\n Authorization: `Bearer ${refreshToken}`,\r\n },\r\n environment: ENVIRONMENT,\r\n });\r\n\r\n response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, data.accessToken, {\r\n expires: addMinutes(new Date(), 9),\r\n httpOnly: true,\r\n sameSite: 'strict',\r\n });\r\n } catch {\r\n response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);\r\n }\r\n }\r\n\r\n return response;\r\n}\r\n","/**\n * @module constants\n * @summary Useful constants\n * @description\n * Collection of useful date constants.\n *\n * The constants could be imported from `date-fns/constants`:\n *\n * ```ts\n * import { maxTime, minTime } from \"./constants/date-fns/constants\";\n *\n * function isAllowedTime(time) {\n * return time <= maxTime && time >= minTime;\n * }\n * ```\n */\n\n/**\n * @constant\n * @name daysInWeek\n * @summary Days in 1 week.\n */\nexport const daysInWeek = 7;\n\n/**\n * @constant\n * @name daysInYear\n * @summary Days in 1 year.\n *\n * @description\n * How many days in a year.\n *\n * One years equals 365.2425 days according to the formula:\n *\n * > Leap year occurs every 4 years, except for years that are divisible by 100 and not divisible by 400.\n * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days\n */\nexport const daysInYear = 365.2425;\n\n/**\n * @constant\n * @name maxTime\n * @summary Maximum allowed time.\n *\n * @example\n * import { maxTime } from \"./constants/date-fns/constants\";\n *\n * const isValid = 8640000000000001 <= maxTime;\n * //=> false\n *\n * new Date(8640000000000001);\n * //=> Invalid Date\n */\nexport const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;\n\n/**\n * @constant\n * @name minTime\n * @summary Minimum allowed time.\n *\n * @example\n * import { minTime } from \"./constants/date-fns/constants\";\n *\n * const isValid = -8640000000000001 >= minTime;\n * //=> false\n *\n * new Date(-8640000000000001)\n * //=> Invalid Date\n */\nexport const minTime = -maxTime;\n\n/**\n * @constant\n * @name millisecondsInWeek\n * @summary Milliseconds in 1 week.\n */\nexport const millisecondsInWeek = 604800000;\n\n/**\n * @constant\n * @name millisecondsInDay\n * @summary Milliseconds in 1 day.\n */\nexport const millisecondsInDay = 86400000;\n\n/**\n * @constant\n * @name millisecondsInMinute\n * @summary Milliseconds in 1 minute\n */\nexport const millisecondsInMinute = 60000;\n\n/**\n * @constant\n * @name millisecondsInHour\n * @summary Milliseconds in 1 hour\n */\nexport const millisecondsInHour = 3600000;\n\n/**\n * @constant\n * @name millisecondsInSecond\n * @summary Milliseconds in 1 second\n */\nexport const millisecondsInSecond = 1000;\n\n/**\n * @constant\n * @name minutesInYear\n * @summary Minutes in 1 year.\n */\nexport const minutesInYear = 525600;\n\n/**\n * @constant\n * @name minutesInMonth\n * @summary Minutes in 1 month.\n */\nexport const minutesInMonth = 43200;\n\n/**\n * @constant\n * @name minutesInDay\n * @summary Minutes in 1 day.\n */\nexport const minutesInDay = 1440;\n\n/**\n * @constant\n * @name minutesInHour\n * @summary Minutes in 1 hour.\n */\nexport const minutesInHour = 60;\n\n/**\n * @constant\n * @name monthsInQuarter\n * @summary Months in 1 quarter.\n */\nexport const monthsInQuarter = 3;\n\n/**\n * @constant\n * @name monthsInYear\n * @summary Months in 1 year.\n */\nexport const monthsInYear = 12;\n\n/**\n * @constant\n * @name quartersInYear\n * @summary Quarters in 1 year\n */\nexport const quartersInYear = 4;\n\n/**\n * @constant\n * @name secondsInHour\n * @summary Seconds in 1 hour.\n */\nexport const secondsInHour = 3600;\n\n/**\n * @constant\n * @name secondsInMinute\n * @summary Seconds in 1 minute.\n */\nexport const secondsInMinute = 60;\n\n/**\n * @constant\n * @name secondsInDay\n * @summary Seconds in 1 day.\n */\nexport const secondsInDay = secondsInHour * 24;\n\n/**\n * @constant\n * @name secondsInWeek\n * @summary Seconds in 1 week.\n */\nexport const secondsInWeek = secondsInDay * 7;\n\n/**\n * @constant\n * @name secondsInYear\n * @summary Seconds in 1 year.\n */\nexport const secondsInYear = secondsInDay * daysInYear;\n\n/**\n * @constant\n * @name secondsInMonth\n * @summary Seconds in 1 month\n */\nexport const secondsInMonth = secondsInYear / 12;\n\n/**\n * @constant\n * @name secondsInQuarter\n * @summary Seconds in 1 quarter.\n */\nexport const secondsInQuarter = secondsInMonth * 3;\n\n/**\n * @constant\n * @name constructFromSymbol\n * @summary Symbol enabling Date extensions to inherit properties from the reference date.\n *\n * The symbol is used to enable the `constructFrom` function to construct a date\n * using a reference date and a value. It allows to transfer extra properties\n * from the reference date to the new date. It's useful for extensions like\n * [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as\n * a constructor argument.\n */\nexport const constructFromSymbol = Symbol.for(\"constructDateFrom\");\n","import { constructFromSymbol } from \"./constants.js\";\n\n/**\n * @name constructFrom\n * @category Generic Helpers\n * @summary Constructs a date using the reference date and the value\n *\n * @description\n * The function constructs a new date using the constructor from the reference\n * date and the given value. It helps to build generic functions that accept\n * date extensions.\n *\n * It defaults to `Date` if the passed reference date is a number or a string.\n *\n * Starting from v3.7.0, it allows to construct a date using `[Symbol.for(\"constructDateFrom\")]`\n * enabling to transfer extra properties from the reference date to the new date.\n * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)\n * that accept a time zone as a constructor argument.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n *\n * @param date - The reference date to take constructor from\n * @param value - The value to create the date\n *\n * @returns Date initialized using the given date and value\n *\n * @example\n * import { constructFrom } from \"./constructFrom/date-fns\";\n *\n * // A function that clones a date preserving the original type\n * function cloneDate<DateType extends Date>(date: DateType): DateType {\n * return constructFrom(\n * date, // Use constructor from the given date\n * date.getTime() // Use the date value to create a new date\n * );\n * }\n */\nexport function constructFrom(date, value) {\n if (typeof date === \"function\") return date(value);\n\n if (date && typeof date === \"object\" && constructFromSymbol in date)\n return date[constructFromSymbol](value);\n\n if (date instanceof Date) return new date.constructor(value);\n\n return new Date(value);\n}\n\n// Fallback for modularized imports:\nexport default constructFrom;\n","import { constructFrom } from \"./constructFrom.js\";\n\n/**\n * @name toDate\n * @category Common Helpers\n * @summary Convert the given argument to an instance of Date.\n *\n * @description\n * Convert the given argument to an instance of Date.\n *\n * If the argument is an instance of Date, the function returns its clone.\n *\n * If the argument is a number, it is treated as a timestamp.\n *\n * If the argument is none of the above, the function returns Invalid Date.\n *\n * Starting from v3.7.0, it clones a date using `[Symbol.for(\"constructDateFrom\")]`\n * enabling to transfer extra properties from the reference date to the new date.\n * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)\n * that accept a time zone as a constructor argument.\n *\n * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param argument - The value to convert\n *\n * @returns The parsed date in the local time zone\n *\n * @example\n * // Clone the date:\n * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))\n * //=> Tue Feb 11 2014 11:30:30\n *\n * @example\n * // Convert the timestamp to date:\n * const result = toDate(1392098430000)\n * //=> Tue Feb 11 2014 11:30:30\n */\nexport function toDate(argument, context) {\n // [TODO] Get rid of `toDate` or `constructFrom`?\n return constructFrom(context || argument, argument);\n}\n\n// Fallback for modularized imports:\nexport default toDate;\n","import { millisecondsInMinute } from \"./constants.js\";\nimport { toDate } from \"./toDate.js\";\n\n/**\n * The {@link addMinutes} function options.\n */\n\n/**\n * @name addMinutes\n * @category Minute Helpers\n * @summary Add the specified number of minutes to the given date.\n *\n * @description\n * Add the specified number of minutes to the given date.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.\n *\n * @param date - The date to be changed\n * @param amount - The amount of minutes to be added.\n * @param options - An object with options\n *\n * @returns The new date with the minutes added\n *\n * @example\n * // Add 30 minutes to 10 July 2014 12:00:00:\n * const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)\n * //=> Thu Jul 10 2014 12:30:00\n */\nexport function addMinutes(date, amount, options) {\n const _date = toDate(date, options?.in);\n _date.setTime(_date.getTime() + amount * millisecondsInMinute);\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default addMinutes;\n","import { z } from 'zod';\r\n\r\nexport const SITE_ID = z\r\n .string()\r\n .min(1, 'Environment variable \"NEXT_PUBLIC_SITE_ID\" must be 1 or more characters')\r\n .max(32, 'Environment variable \"NEXT_PUBLIC_SITE_ID\" must not be more than 32 characters')\r\n .trim()\r\n .parse(process.env.NEXT_PUBLIC_SITE_ID);\r\n\r\nexport const PLATFORM_ID = z\r\n .string()\r\n .min(1, 'Environment variable \"NEXT_PUBLIC_PLATFORM_ID\" must be 1 or more characters')\r\n .max(32, 'Environment variable \"NEXT_PUBLIC_PLATFORM_ID\" must not be more than 32 characters')\r\n .trim()\r\n .parse(process.env.NEXT_PUBLIC_PLATFORM_ID);\r\n\r\nexport const PLATFORM_CODE = z\r\n .string()\r\n .min(4, 'Environment variable \"NEXT_PUBLIC_PLATFORM_CODE\" must be at least 4 characters')\r\n .max(8, 'Environment variable \"NEXT_PUBLIC_PLATFORM_CODE\" must not be more than 8 characters')\r\n .trim()\r\n .parse(process.env.NEXT_PUBLIC_PLATFORM_CODE);\r\n\r\nexport const ENVIRONMENT = z\r\n .enum(['production', 'development'])\r\n .catch('development')\r\n .parse(process.env.NEXT_PUBLIC_ENVIRONMENT);\r\n\r\nexport const BYPASS_RECAPTCHA = z\r\n .any()\r\n .transform(Boolean)\r\n .catch(false)\r\n .parse(process.env.NEXT_PUBLIC_BYPASS_RECAPTCHA);\r\n\r\nexport const ACCESS_TOKEN_COOKIE_NAME: string = 'WebPortalAuthAccessToken';\r\nexport const REFRESH_TOKEN_COOKIE_NAME: string = 'WebPortalAuthRefreshToken';\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA+B;;;ACqCxB,IAAM,aAAa;AAgBnB,IAAM,UAAU,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,KAAK;AAgBjD,IAAM,UAAU,CAAC;AAqBjB,IAAM,uBAAuB;AAsE7B,IAAM,gBAAgB;AActB,IAAM,eAAe,gBAAgB;AAOrC,IAAM,gBAAgB,eAAe;AAOrC,IAAM,gBAAgB,eAAe;AAOrC,IAAM,iBAAiB,gBAAgB;AAOvC,IAAM,mBAAmB,iBAAiB;AAa1C,IAAM,sBAAsB,OAAO,IAAI,mBAAmB;;;AClL1D,SAAS,cAAc,MAAM,OAAO;AACzC,MAAI,OAAO,SAAS,WAAY,QAAO,KAAK,KAAK;AAEjD,MAAI,QAAQ,OAAO,SAAS,YAAY,uBAAuB;AAC7D,WAAO,KAAK,mBAAmB,EAAE,KAAK;AAExC,MAAI,gBAAgB,KAAM,QAAO,IAAI,KAAK,YAAY,KAAK;AAE3D,SAAO,IAAI,KAAK,KAAK;AACvB;;;ACNO,SAAS,OAAO,UAAU,SAAS;AAExC,SAAO,cAAc,WAAW,UAAU,QAAQ;AACpD;;;ACdO,SAAS,WAAW,MAAM,QAAQ,SAAS;AAChD,QAAM,QAAQ,OAAO,MAAM,mCAAS,EAAE;AACtC,QAAM,QAAQ,MAAM,QAAQ,IAAI,SAAS,oBAAoB;AAC7D,SAAO;AACT;;;AJ/BA,oBAA0C;;;AKF1C,iBAAkB;AAEX,IAAM,UAAU,aACpB,OAAO,EACP,IAAI,GAAG,yEAAyE,EAChF,IAAI,IAAI,gFAAgF,EACxF,KAAK,EACL,MAAM,QAAQ,IAAI,mBAAmB;AAEjC,IAAM,cAAc,aACxB,OAAO,EACP,IAAI,GAAG,6EAA6E,EACpF,IAAI,IAAI,oFAAoF,EAC5F,KAAK,EACL,MAAM,QAAQ,IAAI,uBAAuB;AAErC,IAAM,gBAAgB,aAC1B,OAAO,EACP,IAAI,GAAG,gFAAgF,EACvF,IAAI,GAAG,qFAAqF,EAC5F,KAAK,EACL,MAAM,QAAQ,IAAI,yBAAyB;AAEvC,IAAM,cAAc,aACxB,KAAK,CAAC,cAAc,aAAa,CAAC,EAClC,MAAM,aAAa,EACnB,MAAM,QAAQ,IAAI,uBAAuB;AAErC,IAAM,mBAAmB,aAC7B,IAAI,EACJ,UAAU,OAAO,EACjB,MAAM,KAAK,EACX,MAAM,QAAQ,IAAI,4BAA4B;AAE1C,IAAM,2BAAmC;AACzC,IAAM,4BAAoC;;;AL9B1C,IAAM,SAAS;AAAA,EACpB,SAAS,CAAC,0EAA0E;AACtF;AAEA,eAAsB,WAAW,SAAsB;AATvD;AAUE,QAAM,eAAc,aAAQ,QAAQ,IAAI,wBAAwB,MAA5C,mBAA+C;AACnE,QAAM,gBAAe,aAAQ,QAAQ,IAAI,yBAAyB,MAA7C,mBAAgD;AAErE,QAAM,WAAW,2BAAa,KAAK;AAEnC,MAAI,CAAC,eAAe,cAAc;AAChC,QAAI;AACF,YAAM,OAAO,UAAM,uCAAe;AAAA,QAChC,SAAS;AAAA,UACP,eAAe,UAAU,YAAY;AAAA,QACvC;AAAA,QACA,aAAa;AAAA,MACf,CAAC;AAED,eAAS,QAAQ,IAAI,0BAA0B,KAAK,aAAa;AAAA,QAC/D,SAAS,WAAW,oBAAI,KAAK,GAAG,CAAC;AAAA,QACjC,UAAU;AAAA,QACV,UAAU;AAAA,MACZ,CAAC;AAAA,IACH,QAAQ;AACN,eAAS,QAAQ,OAAO,yBAAyB;AAAA,IACnD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,42 @@
1
+ import {
2
+ ACCESS_TOKEN_COOKIE_NAME,
3
+ ENVIRONMENT,
4
+ REFRESH_TOKEN_COOKIE_NAME,
5
+ addMinutes
6
+ } from "./chunk-HP26SZP3.mjs";
7
+
8
+ // src/lib/middleware.ts
9
+ import { refreshSession } from "@opexa/portal-sdk-core";
10
+ import { NextResponse } from "next/server";
11
+ var config = {
12
+ matcher: ["/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)"]
13
+ };
14
+ async function middleware(request) {
15
+ var _a, _b;
16
+ const accessToken = (_a = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)) == null ? void 0 : _a.value;
17
+ const refreshToken = (_b = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)) == null ? void 0 : _b.value;
18
+ const response = NextResponse.next();
19
+ if (!accessToken && refreshToken) {
20
+ try {
21
+ const data = await refreshSession({
22
+ headers: {
23
+ Authorization: `Bearer ${refreshToken}`
24
+ },
25
+ environment: ENVIRONMENT
26
+ });
27
+ response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, data.accessToken, {
28
+ expires: addMinutes(/* @__PURE__ */ new Date(), 9),
29
+ httpOnly: true,
30
+ sameSite: "strict"
31
+ });
32
+ } catch {
33
+ response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
34
+ }
35
+ }
36
+ return response;
37
+ }
38
+ export {
39
+ config,
40
+ middleware
41
+ };
42
+ //# sourceMappingURL=middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/middleware.ts"],"sourcesContent":["import { refreshSession } from '@opexa/portal-sdk-core';\r\nimport { addMinutes } from 'date-fns';\r\nimport { NextRequest, NextResponse } from 'next/server';\r\nimport { ACCESS_TOKEN_COOKIE_NAME, ENVIRONMENT, REFRESH_TOKEN_COOKIE_NAME } from './constants';\r\n\r\nexport const config = {\r\n matcher: ['/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'],\r\n};\r\n\r\nexport async function middleware(request: NextRequest) {\r\n const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;\r\n const refreshToken = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)?.value;\r\n\r\n const response = NextResponse.next();\r\n\r\n if (!accessToken && refreshToken) {\r\n try {\r\n const data = await refreshSession({\r\n headers: {\r\n Authorization: `Bearer ${refreshToken}`,\r\n },\r\n environment: ENVIRONMENT,\r\n });\r\n\r\n response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, data.accessToken, {\r\n expires: addMinutes(new Date(), 9),\r\n httpOnly: true,\r\n sameSite: 'strict',\r\n });\r\n } catch {\r\n response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);\r\n }\r\n }\r\n\r\n return response;\r\n}\r\n"],"mappings":";;;;;;;;AAAA,SAAS,sBAAsB;AAE/B,SAAsB,oBAAoB;AAGnC,IAAM,SAAS;AAAA,EACpB,SAAS,CAAC,0EAA0E;AACtF;AAEA,eAAsB,WAAW,SAAsB;AATvD;AAUE,QAAM,eAAc,aAAQ,QAAQ,IAAI,wBAAwB,MAA5C,mBAA+C;AACnE,QAAM,gBAAe,aAAQ,QAAQ,IAAI,yBAAyB,MAA7C,mBAAgD;AAErE,QAAM,WAAW,aAAa,KAAK;AAEnC,MAAI,CAAC,eAAe,cAAc;AAChC,QAAI;AACF,YAAM,OAAO,MAAM,eAAe;AAAA,QAChC,SAAS;AAAA,UACP,eAAe,UAAU,YAAY;AAAA,QACvC;AAAA,QACA,aAAa;AAAA,MACf,CAAC;AAED,eAAS,QAAQ,IAAI,0BAA0B,KAAK,aAAa;AAAA,QAC/D,SAAS,WAAW,oBAAI,KAAK,GAAG,CAAC;AAAA,QACjC,UAAU;AAAA,QACV,UAAU;AAAA,MACZ,CAAC;AAAA,IACH,QAAQ;AACN,eAAS,QAAQ,OAAO,yBAAyB;AAAA,IACnD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
Binary file
package/dist/theme.css ADDED
@@ -0,0 +1,237 @@
1
+ @plugin 'tailwindcss-plugin-zag';
2
+
3
+ @layer base {
4
+ button {
5
+ cursor: pointer;
6
+ }
7
+
8
+ @media screen and (min-width: 0px) and (orientation: portrait) {
9
+ :root {
10
+ --root-fs: 12px;
11
+ }
12
+ }
13
+
14
+ @media screen and (min-width: 350px) and (orientation: portrait) {
15
+ :root {
16
+ --root-fs: 14px;
17
+ }
18
+ }
19
+
20
+ @media screen and (min-width: 400px) and (orientation: portrait) {
21
+ :root {
22
+ --root-fs: 16px;
23
+ }
24
+ }
25
+
26
+ @media screen and (min-width: 450px) and (orientation: portrait) {
27
+ :root {
28
+ --root-fs: 18px;
29
+ }
30
+ }
31
+
32
+ @media screen and (min-width: 500px) and (orientation: portrait) {
33
+ :root {
34
+ --root-fs: 20px;
35
+ }
36
+ }
37
+
38
+ @media screen and (min-width: 550px) and (orientation: portrait) {
39
+ :root {
40
+ --root-fs: 22px;
41
+ }
42
+ }
43
+
44
+ @media screen and (min-width: 600px) and (orientation: portrait) {
45
+ :root {
46
+ --root-fs: 24px;
47
+ }
48
+ }
49
+
50
+ @media screen and (min-width: 650px) and (orientation: portrait) {
51
+ :root {
52
+ --root-fs: 26px;
53
+ }
54
+ }
55
+
56
+ @media screen and (min-width: 700px) and (orientation: portrait) {
57
+ :root {
58
+ --root-fs: 28px;
59
+ }
60
+ }
61
+
62
+ @media screen and (min-width: 750px) and (orientation: portrait) {
63
+ :root {
64
+ --root-fs: 30px;
65
+ }
66
+ }
67
+
68
+ @media screen and (min-width: 800px) and (orientation: portrait) {
69
+ :root {
70
+ --root-fs: 28px;
71
+ }
72
+ }
73
+
74
+ @media screen and (min-width: 850px) and (orientation: portrait) {
75
+ :root {
76
+ --root-fs: 30px;
77
+ }
78
+ }
79
+
80
+ @media screen and (min-width: 900px) and (orientation: portrait) {
81
+ :root {
82
+ --root-fs: 32px;
83
+ }
84
+ }
85
+
86
+ @media screen and (min-width: 950px) and (orientation: portrait) {
87
+ :root {
88
+ --root-fs: 34px;
89
+ }
90
+ }
91
+
92
+ @media screen and (min-width: 1000px) and (orientation: portrait) {
93
+ :root {
94
+ --root-fs: 36px;
95
+ }
96
+ }
97
+
98
+ @media screen and (min-width: 1024px) and (orientation: portrait) {
99
+ :root {
100
+ --root-fs: 16px;
101
+ }
102
+ }
103
+
104
+ html {
105
+ font-size: var(--root-fs, 16px);
106
+ }
107
+ }
108
+
109
+ @theme {
110
+ --font-sans: var(--font-sans);
111
+ --font-mono: var(--font-mono);
112
+
113
+ --color-accent-50: var(--color-amber-50);
114
+ --color-accent-100: var(--color-amber-100);
115
+ --color-accent-200: var(--color-amber-200);
116
+ --color-accent-300: var(--color-amber-300);
117
+ --color-accent-400: var(--color-amber-400);
118
+ --color-accent-500: var(--color-amber-500);
119
+ --color-accent-600: var(--color-amber-600);
120
+ --color-accent-700: var(--color-amber-700);
121
+ --color-accent-800: var(--color-amber-800);
122
+ --color-accent-900: var(--color-amber-900);
123
+ --color-accent-950: var(--color-amber-950);
124
+
125
+ --color-gray-50: var(--color-neutral-50);
126
+ --color-gray-100: var(--color-neutral-100);
127
+ --color-gray-200: var(--color-neutral-200);
128
+ --color-gray-300: var(--color-neutral-300);
129
+ --color-gray-400: var(--color-neutral-400);
130
+ --color-gray-500: var(--color-neutral-500);
131
+ --color-gray-600: var(--color-neutral-600);
132
+ --color-gray-700: var(--color-neutral-700);
133
+ --color-gray-800: var(--color-neutral-800);
134
+ --color-gray-900: var(--color-neutral-900);
135
+ --color-gray-950: var(--color-neutral-950);
136
+
137
+ --spacing-4\.5: 1.125rem;
138
+ --spacing-5\.5: 1.375rem;
139
+ --spacing-6\.5: 1.625rem;
140
+ --spacing-7\.5: 1.875rem;
141
+ --spacing-8\.5: 2.25rem;
142
+ --spacing-9\.5: 2.375rem;
143
+ --spacing-13: 3.25rem;
144
+ --spacing-18: 4.5rem;
145
+ --spacing-xxs: 0.125rem;
146
+ --spacing-xs: 0.25rem;
147
+ --spacing-sm: 0.375rem;
148
+ --spacing-md: 0.5rem;
149
+ --spacing-lg: 0.75rem;
150
+ --spacing-xl: 1rem;
151
+ --spacing-2xl: 1.25rem;
152
+ --spacing-3xl: 1.5rem;
153
+ --spacing-4xl: 2rem;
154
+ --spacing-5xl: 2.5rem;
155
+ --spacing-6xl: 3rem;
156
+ --spacing-7xl: 4rem;
157
+ --spacing-8xl: 5rem;
158
+
159
+ --z-dropdown: 1000;
160
+ --z-sticky: 1100;
161
+ --z-banner: 1200;
162
+ --z-backdrop: 1300;
163
+ --z-dialog: 1400;
164
+ --z-popover: 1500;
165
+ --z-toast: 1600;
166
+ --z-tooltip: 1900;
167
+
168
+ --radius-xs: 0.25rem;
169
+ --radius-sm: 0.375rem;
170
+ --radius-md: 0.5rem;
171
+ --radius-xl: 0.75rem;
172
+
173
+ --shadow-xs: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
174
+ --shadow-sm: 0px 1px 2px 0px rgba(16, 24, 40, 0.06), 0px 1px 3px 0px rgba(16, 24, 40, 0.1);
175
+ --shadow-md: 0px 2px 4px -2px rgba(16, 24, 40, 0.06), 0px 4px 8px -2px rgba(16, 24, 40, 0.1);
176
+ --shadow-lg: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
177
+ --shadow-xl: 0px 20px 24px -4px rgba(16, 24, 40, 0.08), 0px 8px 8px -4px rgba(16, 24, 40, 0.03);
178
+ --shadow-none: 0 0 #0000;
179
+
180
+ --animate-backdrop-in: backdrop-in 400ms cubic-bezier(0.05, 0.7, 0.1, 1);
181
+ --animate-backdrop-out: backdrop-out 250ms cubic-bezier(0.3, 0, 0.8, 0.15);
182
+ --animate-dialog-in: dialog-in 400ms cubic-bezier(0.05, 0.7, 0.1, 1);
183
+ --animate-dialog-out: dialog-out 250ms cubic-bezier(0.3, 0, 0.8, 0.15);
184
+
185
+ @keyframes backdrop-in {
186
+ 0% {
187
+ opacity: 0;
188
+ }
189
+ 100% {
190
+ opacity: 1;
191
+ }
192
+ }
193
+
194
+ @keyframes backdrop-out {
195
+ 0% {
196
+ opacity: 1;
197
+ }
198
+ 100% {
199
+ opacity: 0;
200
+ }
201
+ }
202
+
203
+ @keyframes dialog-in {
204
+ 0% {
205
+ opacity: 0;
206
+ transform: scale(0.8);
207
+ }
208
+ 100% {
209
+ opacity: 1;
210
+ transform: scale(1);
211
+ }
212
+ }
213
+
214
+ @keyframes dialog-out {
215
+ 0% {
216
+ opacity: 1;
217
+ transform: scale(1);
218
+ }
219
+ 100% {
220
+ opacity: 0;
221
+ transform: scale(0.8);
222
+ }
223
+ }
224
+ }
225
+
226
+ @utility z-* {
227
+ z-index: --value(--z-\*, integer);
228
+ }
229
+
230
+ @utility arrow-bg-* {
231
+ --arrow-bg: --value(--color-\*, [color]);
232
+ }
233
+
234
+ @utility arrow-size-* {
235
+ --arrow-size: calc(var(--spacing) * --value(integer));
236
+ --arrow-size: --value([\*]);
237
+ }
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@opexa/portal-components",
3
+ "version": "0.0.1",
4
+ "exports": {
5
+ ".": {
6
+ "types": "./dist/index.d.ts",
7
+ "import": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "require": "./dist/index.cjs"
12
+ },
13
+ "./handlers": {
14
+ "types": "./dist/handlers.d.ts",
15
+ "import": {
16
+ "types": "./dist/handlers.d.ts",
17
+ "default": "./dist/handlers.js"
18
+ },
19
+ "require": "./dist/handlers.cjs"
20
+ },
21
+ "./middleware": {
22
+ "types": "./dist/middleware.d.ts",
23
+ "import": {
24
+ "types": "./dist/middleware.d.ts",
25
+ "default": "./dist/middleware.js"
26
+ },
27
+ "require": "./dist/middleware.cjs"
28
+ },
29
+ "./theme.css": "./dist/theme.css",
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "dev": "next dev --turbopack",
40
+ "build": "tsup",
41
+ "build:app": "next build",
42
+ "start": "next start",
43
+ "lint": "next lint",
44
+ "release": "release-it"
45
+ },
46
+ "dependencies": {
47
+ "date-fns": "^4.1.0",
48
+ "embla-carousel-autoplay": "^8.6.0",
49
+ "embla-carousel-react": "^8.6.0",
50
+ "lodash-es": "^4.17.21",
51
+ "tailwind-merge": "^3.3.0",
52
+ "tailwindcss-plugin-zag": "^0.1.0",
53
+ "tiny-invariant": "^1.3.3",
54
+ "usehooks-ts": "^3.1.1",
55
+ "zustand": "^5.0.4"
56
+ },
57
+ "devDependencies": {
58
+ "@ark-ui/react": "^5.9.1",
59
+ "@eslint/eslintrc": "^3",
60
+ "@hookform/resolvers": "^4.1.3",
61
+ "@opexa/portal-sdk-core": "^0.0.3",
62
+ "@tailwindcss/postcss": "^4",
63
+ "@tanstack/react-query": "^5.76.1",
64
+ "@total-typescript/ts-reset": "^0.6.1",
65
+ "@tsconfig/next": "^2.0.3",
66
+ "@types/lodash-es": "^4.17.12",
67
+ "@types/node": "^22",
68
+ "@types/react": "^19",
69
+ "@types/react-dom": "^19",
70
+ "eslint": "^9",
71
+ "eslint-config-next": "15.3.2",
72
+ "next": "15.3.2",
73
+ "react": "^19.1.0",
74
+ "react-dom": "^19.1.0",
75
+ "react-hook-form": "^7.54.2",
76
+ "release-it": "^18.1.2",
77
+ "tailwindcss": "^4",
78
+ "tsup": "^8.1.0",
79
+ "type-fest": "^4.41.0",
80
+ "typescript": "^5",
81
+ "zod": "^3.25.7"
82
+ },
83
+ "peerDependencies": {
84
+ "@ark-ui/react": "^5.0.0",
85
+ "@hookform/resolvers": "^4.0.0",
86
+ "@opexa/portal-sdk-core": "^0.0.3",
87
+ "@tanstack/react-query": "^5.0.0",
88
+ "next": "^15.0.0",
89
+ "react": "^19.0.0",
90
+ "react-dom": "^19.0.0",
91
+ "react-hook-form": "^7.0.0",
92
+ "tailwindcss": "^4.0.0",
93
+ "zod": "^3.0.0"
94
+ }
95
+ }