@cabin-id/nextjs 0.0.1 → 0.1.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.
Files changed (74) hide show
  1. package/dist/cjs/client/provider.js +10 -11
  2. package/dist/cjs/client/provider.js.map +1 -1
  3. package/dist/cjs/client/request.js +43 -0
  4. package/dist/cjs/client/request.js.map +1 -0
  5. package/dist/cjs/component.client.js +30 -0
  6. package/dist/cjs/component.client.js.map +1 -1
  7. package/dist/cjs/components/SignInButton.js +1 -1
  8. package/dist/cjs/components/SignInButton.js.map +1 -1
  9. package/dist/cjs/constants.js +1 -1
  10. package/dist/cjs/constants.js.map +1 -1
  11. package/dist/cjs/package.json +9 -0
  12. package/dist/cjs/server/getCurrentUser.js.map +1 -1
  13. package/dist/cjs/server/middleware.js +21 -25
  14. package/dist/cjs/server/middleware.js.map +1 -1
  15. package/dist/cjs/types.js.map +1 -1
  16. package/dist/esm/client/provider.js +10 -11
  17. package/dist/esm/client/provider.js.map +1 -1
  18. package/dist/esm/client/request.js +19 -0
  19. package/dist/esm/client/request.js.map +1 -0
  20. package/dist/esm/component.client.js +6 -0
  21. package/dist/esm/component.client.js.map +1 -1
  22. package/dist/esm/components/SignInButton.js +1 -1
  23. package/dist/esm/components/SignInButton.js.map +1 -1
  24. package/dist/esm/constants.js +1 -1
  25. package/dist/esm/constants.js.map +1 -1
  26. package/dist/esm/package.json +9 -0
  27. package/dist/esm/server/getCurrentUser.js.map +1 -1
  28. package/dist/esm/server/middleware.js +24 -26
  29. package/dist/esm/server/middleware.js.map +1 -1
  30. package/dist/types/api/getUserInfo.d.ts +2 -0
  31. package/dist/types/client/provider.d.ts +7 -0
  32. package/dist/types/client/provider.d.ts.map +1 -1
  33. package/dist/types/client/request.d.ts +3 -0
  34. package/dist/types/client/request.d.ts.map +1 -0
  35. package/dist/types/component.client.d.ts +3 -0
  36. package/dist/types/component.client.d.ts.map +1 -1
  37. package/dist/types/component.server.d.ts +2 -0
  38. package/dist/types/components/SignInButton.d.ts +3 -0
  39. package/dist/types/components/index.d.ts +2 -0
  40. package/dist/types/constants.d.ts +68 -0
  41. package/dist/types/constants.d.ts.map +1 -1
  42. package/dist/types/hooks/index.d.ts +2 -0
  43. package/dist/types/hooks/useUser.d.ts +2 -0
  44. package/dist/types/hooks/useUser.d.ts.map +1 -1
  45. package/dist/types/icons/logo.d.ts +3 -0
  46. package/dist/types/index.d.ts +7 -0
  47. package/dist/types/server/auth.d.ts +4 -0
  48. package/dist/types/server/createRedirect.d.ts +21 -0
  49. package/dist/types/server/getCurrentUser.d.ts +3 -0
  50. package/dist/types/server/getCurrentUser.d.ts.map +1 -1
  51. package/dist/types/server/middleware.d.ts +88 -0
  52. package/dist/types/server/middleware.d.ts.map +1 -1
  53. package/dist/types/server/routeMatcher.d.ts +10 -0
  54. package/dist/types/server/serverRedirectWithAuth.d.ts +2 -0
  55. package/dist/types/server/type.d.ts +5 -0
  56. package/dist/types/server/utils.d.ts +10 -0
  57. package/dist/types/types.d.ts +36 -0
  58. package/dist/types/types.d.ts.map +1 -1
  59. package/dist/types/utils/assertValidSecretKey.d.ts +2 -0
  60. package/dist/types/utils/isomorphicAtob.d.ts +6 -0
  61. package/dist/types/utils/isomorphicBtoa.d.ts +2 -0
  62. package/dist/types/utils/key.d.ts +5 -0
  63. package/dist/types/utils/path.d.ts +4 -0
  64. package/dist/types/utils/response.d.ts +13 -0
  65. package/dist/types/utils.d.ts +4 -0
  66. package/package.json +4 -5
  67. package/dist/cjs/global.d.js +0 -17
  68. package/dist/cjs/global.d.js.map +0 -1
  69. package/dist/cjs/styles/global.css +0 -334
  70. package/dist/cjs/styles/global.css.map +0 -1
  71. package/dist/esm/global.d.js +0 -1
  72. package/dist/esm/global.d.js.map +0 -1
  73. package/dist/esm/styles/global.css +0 -334
  74. package/dist/esm/styles/global.css.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/middleware.ts"],"sourcesContent":["import { NextFetchEvent, NextMiddleware, NextResponse } from 'next/server';\nimport { NextRequest } from 'next/server';\nimport {\n constants,\n CUSTOM_SIGN_IN_URL,\n PUBLISHABLE_KEY,\n SECRET_KEY,\n} from '../constants';\nimport { createRouteMatcher, RouteMatcherParam } from './routeMatcher';\nimport {\n apiEndpointUnauthorizedNextResponse,\n assertKey,\n // decorateRequest,\n redirectAdapter,\n} from './utils';\nimport { NextMiddlewareReturn } from './type';\nimport { isRedirect, mergeResponses, setHeader } from '../utils/response';\nimport { createRedirect } from './createRedirect';\n// import { serverRedirectWithAuth } from './serverRedirectWithAuth';\n\ntype BeforeAuthHandler = (\n req: NextRequest,\n evt: NextFetchEvent\n) => NextMiddlewareReturn | false | Promise<false>;\n\ntype AfterAuthHandler = (\n auth: { isPublicRoute: boolean; isApiRoute: boolean },\n req: NextRequest,\n evt: NextFetchEvent\n) => NextMiddlewareReturn;\n\nexport type AuthenticateRequestOptions = {\n publishableKey?: string;\n secretKey?: string;\n domain?: string;\n isSatellite?: boolean;\n proxyUrl?: string;\n signInUrl?: string;\n signUpUrl?: string;\n afterSignInUrl?: string;\n afterSignUpUrl?: string;\n};\n\ntype AuthMiddlewareParams = AuthenticateRequestOptions & {\n /**\n * A function that is called before the authentication middleware is executed.\n * If a redirect response is returned, the middleware will respect it and redirect the user.\n * If false is returned, the auth middleware will not execute and the request will be handled as if the auth middleware was not present.\n */\n beforeAuth?: BeforeAuthHandler;\n /**\n * A function that is called after the authentication middleware is executed.\n * This function has access to the auth object and can be used to execute logic based on the auth state.\n */\n afterAuth?: AfterAuthHandler;\n /**\n * A list of routes that should be accessible without authentication.\n * You can use glob patterns to match multiple routes or a function to match against the request object.\n * Path patterns and regular expressions are supported, for example: `['/foo', '/bar(.*)'] or `[/^\\/foo\\/.*$/]`\n * The sign in and sign up URLs are included by default, unless a function is provided.\n * For more information, see: https://clerk.com/docs\n */\n publicRoutes?: RouteMatcherParam;\n /**\n * A list of routes that should be ignored by the middleware.\n * This list typically includes routes for static files or Next.js internals.\n * For improved performance, these routes should be skipped using the default config.matcher instead.\n */\n ignoredRoutes?: IgnoredRoutesParam;\n /**\n * A list of routes that should be treated as API endpoints.\n * When user is signed out, the middleware will return a 401 response for these routes, instead of redirecting the user.\n *\n * If omitted, the following heuristics will be used to determine an API endpoint:\n * - The route path is ['/api/(.*)', '/trpc/(.*)'],\n * - or the request has `Content-Type` set to `application/json`,\n * - or the request method is not one of: `GET`, `OPTIONS` ,` HEAD`\n *\n * @default undefined\n */\n apiRoutes?: ApiRoutesParam;\n};\n\nexport interface AuthMiddleware {\n (params?: AuthMiddlewareParams): NextMiddleware;\n}\n\n/**\n * The default ideal matcher that excludes the _next directory (internals) and all static files,\n * but it will match the root route (/) and any routes that start with /api or /trpc.\n */\nexport const DEFAULT_CONFIG_MATCHER = [\n '/((?!.+\\\\.[\\\\w]+$|_next).*)',\n '/',\n '/(api|trpc)(.*)',\n];\n\n/**\n * Any routes matching this path will be ignored by the middleware.\n * This is the inverted version of DEFAULT_CONFIG_MATCHER.\n */\nexport const DEFAULT_IGNORED_ROUTES = [`/((?!api|trpc))(_next.*|.+\\\\.[\\\\w]+$)`];\n/**\n * Any routes matching this path will be treated as API endpoints by the middleware.\n */\nexport const DEFAULT_API_ROUTES = ['/api/(.*)', '/trpc/(.*)'];\n\ntype IgnoredRoutesParam =\n | Array<RegExp | string>\n | RegExp\n | string\n | ((req: NextRequest) => boolean);\n\ntype ApiRoutesParam = IgnoredRoutesParam;\n\nconst authMiddleware: AuthMiddleware = (...args: unknown[]) => {\n const [params = {}] = args as [AuthMiddlewareParams?];\n\n const publishableKey = assertKey(\n params.publishableKey || PUBLISHABLE_KEY,\n () => {\n throw new Error('Publish Key is not exist');\n }\n );\n const secretKey = assertKey(params.secretKey || SECRET_KEY, () => {\n throw new Error('Secret Key is not valid');\n });\n\n const signInUrl = params.signInUrl || CUSTOM_SIGN_IN_URL;\n const signUpUrl = params.signUpUrl || CUSTOM_SIGN_IN_URL;\n\n const options = {\n ...params,\n publishableKey,\n secretKey,\n signInUrl,\n signUpUrl,\n };\n\n const isIgnoredRoute = createRouteMatcher(\n options.ignoredRoutes || DEFAULT_IGNORED_ROUTES\n );\n const isPublicRoute = createRouteMatcher(\n withDefaultPublicRoutes(options.publicRoutes)\n );\n const isApiRoute = createApiRoutes(options.apiRoutes);\n const defaultAfterAuth = createDefaultAfterAuth(\n isPublicRoute,\n isApiRoute,\n options\n );\n\n return async (_req: NextRequest, evt: NextFetchEvent) => {\n const url = _req.nextUrl;\n const accessToken = url.searchParams.get(constants.QueryParams.Token);\n const userId = url.searchParams.get(constants.QueryParams.UserId);\n\n if (isIgnoredRoute(_req) || isPublicRoute(_req)) {\n return;\n }\n const nextRequest = _req;\n\n const beforeAuthRes = await (options.beforeAuth &&\n options.beforeAuth(nextRequest, evt));\n\n if (beforeAuthRes === false) {\n return setHeader(\n NextResponse.next(),\n constants.Headers.AuthReason,\n 'skip'\n );\n } else if (beforeAuthRes && isRedirect(beforeAuthRes)) {\n return setHeader(\n beforeAuthRes,\n constants.Headers.AuthReason,\n 'before-auth-redirect'\n );\n }\n\n const requestState = {\n token: accessToken,\n userId,\n };\n\n const auth = {\n ...requestState,\n isPublicRoute: isPublicRoute(nextRequest),\n isApiRoute: isApiRoute(nextRequest),\n };\n\n const afterAuthRes = await (options.afterAuth || defaultAfterAuth)(\n auth,\n nextRequest,\n evt\n );\n\n const finalRes =\n mergeResponses(beforeAuthRes, afterAuthRes) || NextResponse.next();\n\n if (accessToken && userId) {\n const path = url.pathname;\n const response = NextResponse.redirect(new URL(path || '/', _req.url));\n response.cookies.set(constants.Cookies.Client, accessToken);\n response.cookies.set(constants.Cookies.User, userId);\n return response;\n }\n \n // if (isRedirect(finalRes)) {\n // const res = serverRedirectWithAuth(finalRes);\n // return res;\n // }\n\n const result =\n // decorateRequest(_req, finalRes, requestState, secretKey) ||\n NextResponse.next();\n\n return result;\n };\n};\n\nconst withDefaultPublicRoutes = (\n publicRoutes: RouteMatcherParam | undefined\n) => {\n if (typeof publicRoutes === 'function') {\n return publicRoutes;\n }\n\n const routes = [publicRoutes || ''].flat().filter(Boolean);\n // TODO: refactor it to use common config file eg SIGN_IN_URL from ./clerkClient\n // we use process.env for now to support testing\n const signInUrl = process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || '';\n if (signInUrl) {\n routes.push(matchRoutesStartingWith(signInUrl));\n }\n // TODO: refactor it to use common config file eg SIGN_UP_URL from ./clerkClient\n // we use process.env for now to support testing\n const signUpUrl = process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || '';\n if (signUpUrl) {\n routes.push(matchRoutesStartingWith(signUpUrl));\n }\n return routes;\n};\n\nconst matchRoutesStartingWith = (path: string) => {\n path = path.replace(/\\/$/, '');\n return new RegExp(`^${path}(/.*)?$`);\n};\n\nconst isRequestMethodIndicatingApiRoute = (req: NextRequest): boolean => {\n const requestMethod = req.method.toLowerCase();\n return !['get', 'head', 'options'].includes(requestMethod);\n};\n\nconst isRequestContentTypeJson = (req: NextRequest): boolean => {\n const requestContentType = req.headers.get(constants.Headers.ContentType);\n return requestContentType === constants.ContentTypes.Json;\n};\n\n// - Default behavior:\n// If the route path is `['/api/(.*)*', '*/trpc/(.*)']`\n// or Request has `Content-Type: application/json`\n// or Request method is not-GET,OPTIONS,HEAD,\n// then this is considered an API route.\n//\n// - If the user has provided a specific `apiRoutes` prop in `authMiddleware` then all the above are discarded,\n// and only routes that match the user’s provided paths are considered API routes.\nconst createApiRoutes = (\n apiRoutes: RouteMatcherParam | undefined\n): ((req: NextRequest) => boolean) => {\n if (apiRoutes) {\n return createRouteMatcher(apiRoutes);\n }\n const isDefaultApiRoute = createRouteMatcher(DEFAULT_API_ROUTES);\n return (req: NextRequest) =>\n isDefaultApiRoute(req) ||\n isRequestMethodIndicatingApiRoute(req) ||\n isRequestContentTypeJson(req);\n};\n\nexport const createDefaultAfterAuth = (\n isPublicRoute: ReturnType<typeof createRouteMatcher>,\n isApiRoute: ReturnType<typeof createApiRoutes>,\n options: {\n signInUrl: string;\n signUpUrl: string;\n publishableKey: string;\n secretKey: string;\n }\n) => {\n return (auth: any, req: NextRequest) => {\n if (!auth.userId && !isPublicRoute(req)) {\n if (isApiRoute(req)) {\n return apiEndpointUnauthorizedNextResponse();\n }\n return createRedirect({\n redirectAdapter,\n signInUrl: options.signInUrl,\n signUpUrl: options.signUpUrl,\n publishableKey: options.publishableKey,\n // We're setting baseUrl to '' here as we want to keep the legacy behavior of\n // the redirectToSignIn, redirectToSignUp helpers in the backend package.\n baseUrl: '',\n }).redirectToSignIn({ returnBackUrl: req.nextUrl.href });\n }\n return NextResponse.next();\n };\n};\n\nexport { authMiddleware };\n"],"mappings":"AAAA,SAAyC,oBAAoB;AAE7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA6C;AACtD;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAEP,SAAS,YAAY,gBAAgB,iBAAiB;AACtD,SAAS,sBAAsB;AA0ExB,MAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF;AAMO,MAAM,yBAAyB,CAAC,uCAAuC;AAIvE,MAAM,qBAAqB,CAAC,aAAa,YAAY;AAU5D,MAAM,iBAAiC,IAAI,SAAoB;AAC7D,QAAM,CAAC,SAAS,CAAC,CAAC,IAAI;AAEtB,QAAM,iBAAiB;AAAA,IACrB,OAAO,kBAAkB;AAAA,IACzB,MAAM;AACJ,YAAM,IAAI,MAAM,0BAA0B;AAAA,IAC5C;AAAA,EACF;AACA,QAAM,YAAY,UAAU,OAAO,aAAa,YAAY,MAAM;AAChE,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C,CAAC;AAED,QAAM,YAAY,OAAO,aAAa;AACtC,QAAM,YAAY,OAAO,aAAa;AAEtC,QAAM,UAAU;AAAA,IACd,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,iBAAiB;AAAA,IAC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,KAAK,UAAU,CAAC,cAAc,GAAG,GAAG;AACvC,UAAI,WAAW,GAAG,GAAG;AACnB,eAAO,oCAAoC;AAAA,MAC7C;AACA,aAAO,eAAe;AAAA,QACpB;AAAA,QACA,WAAW,QAAQ;AAAA,QACnB,WAAW,QAAQ;AAAA,QACnB,gBAAgB,QAAQ;AAAA;AAAA;AAAA,QAGxB,SAAS;AAAA,MACX,CAAC,EAAE,iBAAiB,EAAE,eAAe,IAAI,QAAQ,KAAK,CAAC;AAAA,IACzD;AACA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/middleware.ts"],"sourcesContent":["import { NextFetchEvent, NextMiddleware, NextResponse } from 'next/server';\nimport { NextRequest } from 'next/server';\nimport {\n constants,\n CUSTOM_AFTER_SIGN_IN_URL,\n CUSTOM_SIGN_IN_URL,\n frontendApi,\n PUBLISHABLE_KEY,\n SECRET_KEY,\n} from '../constants';\nimport { createRouteMatcher, RouteMatcherParam } from './routeMatcher';\nimport {\n apiEndpointUnauthorizedNextResponse,\n assertKey,\n // decorateRequest,\n redirectAdapter,\n} from './utils';\nimport { NextMiddlewareReturn } from './type';\nimport { isRedirect, setHeader } from '../utils/response';\nimport { createRedirect } from './createRedirect';\n// import { serverRedirectWithAuth } from './serverRedirectWithAuth';\n\ntype BeforeAuthHandler = (\n req: NextRequest,\n evt: NextFetchEvent\n) => NextMiddlewareReturn | false | Promise<false>;\n\ntype AfterAuthHandler = (\n auth: { isPublicRoute: boolean; isApiRoute: boolean },\n req: NextRequest,\n evt: NextFetchEvent\n) => NextMiddlewareReturn;\n\nexport type AuthenticateRequestOptions = {\n publishableKey?: string;\n secretKey?: string;\n domain?: string;\n isSatellite?: boolean;\n proxyUrl?: string;\n signInUrl?: string;\n signUpUrl?: string;\n afterSignInUrl?: string;\n afterSignUpUrl?: string;\n};\n\ntype AuthMiddlewareParams = AuthenticateRequestOptions & {\n /**\n * A function that is called before the authentication middleware is executed.\n * If a redirect response is returned, the middleware will respect it and redirect the user.\n * If false is returned, the auth middleware will not execute and the request will be handled as if the auth middleware was not present.\n */\n beforeAuth?: BeforeAuthHandler;\n /**\n * A function that is called after the authentication middleware is executed.\n * This function has access to the auth object and can be used to execute logic based on the auth state.\n */\n afterAuth?: AfterAuthHandler;\n /**\n * A list of routes that should be accessible without authentication.\n * You can use glob patterns to match multiple routes or a function to match against the request object.\n * Path patterns and regular expressions are supported, for example: `['/foo', '/bar(.*)'] or `[/^\\/foo\\/.*$/]`\n * The sign in and sign up URLs are included by default, unless a function is provided.\n * For more information, see: https://clerk.com/docs\n */\n publicRoutes?: RouteMatcherParam;\n /**\n * A list of routes that should be ignored by the middleware.\n * This list typically includes routes for static files or Next.js internals.\n * For improved performance, these routes should be skipped using the default config.matcher instead.\n */\n ignoredRoutes?: IgnoredRoutesParam;\n /**\n * A list of routes that should be treated as API endpoints.\n * When user is signed out, the middleware will return a 401 response for these routes, instead of redirecting the user.\n *\n * If omitted, the following heuristics will be used to determine an API endpoint:\n * - The route path is ['/api/(.*)', '/trpc/(.*)'],\n * - or the request has `Content-Type` set to `application/json`,\n * - or the request method is not one of: `GET`, `OPTIONS` ,` HEAD`\n *\n * @default undefined\n */\n apiRoutes?: ApiRoutesParam;\n};\n\nexport interface AuthMiddleware {\n (params?: AuthMiddlewareParams): NextMiddleware;\n}\n\n/**\n * The default ideal matcher that excludes the _next directory (internals) and all static files,\n * but it will match the root route (/) and any routes that start with /api or /trpc.\n */\nexport const DEFAULT_CONFIG_MATCHER = [\n '/((?!.+\\\\.[\\\\w]+$|_next).*)',\n '/',\n '/(api|trpc)(.*)',\n];\n\n/**\n * Any routes matching this path will be ignored by the middleware.\n * This is the inverted version of DEFAULT_CONFIG_MATCHER.\n */\nexport const DEFAULT_IGNORED_ROUTES = [`/((?!api|trpc))(_next.*|.+\\\\.[\\\\w]+$)`];\n/**\n * Any routes matching this path will be treated as API endpoints by the middleware.\n */\nexport const DEFAULT_API_ROUTES = ['/api/(.*)', '/trpc/(.*)'];\n\ntype IgnoredRoutesParam =\n | Array<RegExp | string>\n | RegExp\n | string\n | ((req: NextRequest) => boolean);\n\ntype ApiRoutesParam = IgnoredRoutesParam;\n\nconst authMiddleware: AuthMiddleware = (...args: unknown[]) => {\n const [params = {}] = args as [AuthMiddlewareParams?];\n\n const publishableKey = assertKey(\n params.publishableKey || PUBLISHABLE_KEY,\n () => {\n throw new Error('Publish Key is not exist');\n }\n );\n const secretKey = assertKey(params.secretKey || SECRET_KEY, () => {\n throw new Error('Secret Key is not valid');\n });\n\n const signInUrl = params.signInUrl || CUSTOM_SIGN_IN_URL;\n const signUpUrl = params.signUpUrl || CUSTOM_SIGN_IN_URL;\n\n const options = {\n ...params,\n publishableKey,\n secretKey,\n signInUrl,\n signUpUrl,\n };\n\n const isIgnoredRoute = createRouteMatcher(\n options.ignoredRoutes || DEFAULT_IGNORED_ROUTES\n );\n const isPublicRoute = createRouteMatcher(\n withDefaultPublicRoutes(options.publicRoutes)\n );\n // const isApiRoute = createApiRoutes(options.apiRoutes);\n // const defaultAfterAuth = createDefaultAfterAuth(\n // isPublicRoute,\n // isApiRoute,\n // options\n // );\n\n return async (_req: NextRequest, evt: NextFetchEvent) => {\n const url = _req.nextUrl;\n\n const accessToken = url.searchParams.get(constants.QueryParams.Token);\n const userId = url.searchParams.get(constants.QueryParams.UserId);\n\n if (isIgnoredRoute(_req) || isPublicRoute(_req)) {\n return;\n }\n const nextRequest = _req;\n\n const beforeAuthRes = await (options.beforeAuth &&\n options.beforeAuth(nextRequest, evt));\n\n if (beforeAuthRes === false) {\n return setHeader(\n NextResponse.next(),\n constants.Headers.AuthReason,\n 'skip'\n );\n } else if (beforeAuthRes && isRedirect(beforeAuthRes)) {\n return setHeader(\n beforeAuthRes,\n constants.Headers.AuthReason,\n 'before-auth-redirect'\n );\n }\n\n // const requestState = {\n // token: accessToken,\n // userId,\n // };\n\n // const auth = {\n // ...requestState,\n // isPublicRoute: isPublicRoute(nextRequest),\n // isApiRoute: isApiRoute(nextRequest),\n // };\n\n // const afterAuthRes = await (options.afterAuth || defaultAfterAuth)(\n // auth,\n // nextRequest,\n // evt\n // );\n\n // const finalRes =\n // mergeResponses(beforeAuthRes, afterAuthRes) || NextResponse.next();\n\n if (accessToken && userId) {\n const path = url.pathname;\n const response = NextResponse.redirect(new URL(path || '/', _req.url));\n response.cookies.set(constants.Cookies.Client, accessToken);\n response.cookies.set(constants.Cookies.User, userId);\n return response;\n }\n\n // console.log(finalRes);\n\n // if (isRedirect(finalRes)) {\n // const res = serverRedirectWithAuth(finalRes);\n // return res;\n // }\n\n const result = checkAuth(_req);\n\n return result;\n };\n};\n\nconst withDefaultPublicRoutes = (\n publicRoutes: RouteMatcherParam | undefined\n) => {\n if (typeof publicRoutes === 'function') {\n return publicRoutes;\n }\n\n const routes = [publicRoutes || ''].flat().filter(Boolean);\n // TODO: refactor it to use common config file eg SIGN_IN_URL from ./clerkClient\n // we use process.env for now to support testing\n const signInUrl = process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL || '';\n if (signInUrl) {\n routes.push(matchRoutesStartingWith(signInUrl));\n }\n // TODO: refactor it to use common config file eg SIGN_UP_URL from ./clerkClient\n // we use process.env for now to support testing\n const signUpUrl = process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL || '';\n if (signUpUrl) {\n routes.push(matchRoutesStartingWith(signUpUrl));\n }\n return routes;\n};\n\nconst matchRoutesStartingWith = (path: string) => {\n path = path.replace(/\\/$/, '');\n return new RegExp(`^${path}(/.*)?$`);\n};\n\nconst isRequestMethodIndicatingApiRoute = (req: NextRequest): boolean => {\n const requestMethod = req.method.toLowerCase();\n return !['get', 'head', 'options'].includes(requestMethod);\n};\n\nconst isRequestContentTypeJson = (req: NextRequest): boolean => {\n const requestContentType = req.headers.get(constants.Headers.ContentType);\n return requestContentType === constants.ContentTypes.Json;\n};\n\n// - Default behavior:\n// If the route path is `['/api/(.*)*', '*/trpc/(.*)']`\n// or Request has `Content-Type: application/json`\n// or Request method is not-GET,OPTIONS,HEAD,\n// then this is considered an API route.\n//\n// - If the user has provided a specific `apiRoutes` prop in `authMiddleware` then all the above are discarded,\n// and only routes that match the user’s provided paths are considered API routes.\nconst createApiRoutes = (\n apiRoutes: RouteMatcherParam | undefined\n): ((req: NextRequest) => boolean) => {\n if (apiRoutes) {\n return createRouteMatcher(apiRoutes);\n }\n const isDefaultApiRoute = createRouteMatcher(DEFAULT_API_ROUTES);\n return (req: NextRequest) =>\n isDefaultApiRoute(req) ||\n isRequestMethodIndicatingApiRoute(req) ||\n isRequestContentTypeJson(req);\n};\n\nexport const createDefaultAfterAuth = (\n isPublicRoute: ReturnType<typeof createRouteMatcher>,\n isApiRoute: ReturnType<typeof createApiRoutes>,\n options: {\n signInUrl: string;\n signUpUrl: string;\n publishableKey: string;\n secretKey: string;\n }\n) => {\n return (auth: any, req: NextRequest) => {\n if (!auth.userId && !isPublicRoute(req)) {\n if (isApiRoute(req)) {\n return apiEndpointUnauthorizedNextResponse();\n }\n return createRedirect({\n redirectAdapter,\n signInUrl: options.signInUrl,\n signUpUrl: options.signUpUrl,\n publishableKey: options.publishableKey,\n // We're setting baseUrl to '' here as we want to keep the legacy behavior of\n // the redirectToSignIn, redirectToSignUp helpers in the backend package.\n baseUrl: '',\n }).redirectToSignIn({ returnBackUrl: req.nextUrl.href });\n }\n return NextResponse.next();\n };\n};\n\nconst checkAuth = (req: NextRequest): any => {\n const accessToken = req.cookies.get(constants.Cookies.Client);\n\n if (!accessToken && req.nextUrl.href !== CUSTOM_SIGN_IN_URL) {\n if (CUSTOM_SIGN_IN_URL) {\n return NextResponse.redirect(new URL(CUSTOM_SIGN_IN_URL));\n }\n\n if (frontendApi) {\n const params = new URLSearchParams({\n redirect_url: CUSTOM_AFTER_SIGN_IN_URL || '/',\n });\n return NextResponse.redirect(\n new URL(`${frontendApi}/sign-in?${params.toString()}`)\n );\n }\n throw new Error(\n 'You are not authentication. Please provide CABIN ID PUBLISH KEY to redirect to authentication page'\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A,MACvD;AAAA,IACF;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,aAAa,KAAK;AAC3B;","names":[]}
@@ -0,0 +1,2 @@
1
+ export declare const getUserInfo: (accessToken: string) => Promise<any>;
2
+ //# sourceMappingURL=getUserInfo.d.ts.map
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { PropsWithChildren } from 'react';
3
+ import { CabinIDProviderProps } from '../types';
4
+ export declare const CabinIDContext: React.Context<CabinIDProviderProps>;
5
+ declare const CabinIDProvider: ({ children }: PropsWithChildren<any>) => React.JSX.Element;
6
+ export { CabinIDProvider };
7
+ //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/client/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAe,MAAM,UAAU,CAAC;AAG7D,eAAO,MAAM,cAAc,qCAGzB,CAAC;AAEH,QAAA,MAAM,eAAe,iBAAkB,kBAAkB,GAAG,CAAC,sBAiB5D,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/client/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAQ,MAAM,UAAU,CAAC;AAGtD,eAAO,MAAM,cAAc,qCAEzB,CAAC;AAEH,QAAA,MAAM,eAAe,iBAAkB,kBAAkB,GAAG,CAAC,sBAiB5D,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { User } from 'src/types';
2
+ export declare const getCurrentUser: () => Promise<User | null>;
3
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/client/request.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,eAAO,MAAM,cAAc,QAAa,QAAQ,IAAI,GAAG,IAAI,CAU1D,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { CabinIDProvider } from './client/provider';
2
+ export { useUser } from './hooks';
3
+ //# sourceMappingURL=component.client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.client.d.ts","sourceRoot":"","sources":["../../src/component.client.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"component.client.d.ts","sourceRoot":"","sources":["../../src/component.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { auth } from './server/auth';
2
+ //# sourceMappingURL=component.server.d.ts.map
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const SignInButton: () => React.JSX.Element;
3
+ //# sourceMappingURL=SignInButton.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { SignInButton } from './SignInButton';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,68 @@
1
+ export declare const API_URL = "http://localhost:3001/";
2
+ export declare const API_VERSION = "v1";
3
+ export declare const PUBLISHABLE_KEY: string;
4
+ export declare const SECRET_KEY: string;
5
+ export declare const CUSTOM_SIGN_IN_URL: string;
6
+ export declare const CUSTOM_SIGN_Up_URL: string;
7
+ export declare const CUSTOM_AFTER_SIGN_IN_URL: string;
8
+ export declare const CUSTOM_AFTER_SIGN_UP_URL: string;
9
+ export declare const baseApiUrl: string;
10
+ export declare const frontendApi: string | null;
11
+ /**
12
+ * @internal
13
+ */
14
+ export declare const constants: {
15
+ readonly Attributes: {
16
+ readonly AuthToken: "__clerkAuthToken";
17
+ readonly AuthSignature: "__clerkAuthSignature";
18
+ readonly AuthStatus: "__clerkAuthStatus";
19
+ readonly AuthReason: "__clerkAuthReason";
20
+ readonly AuthMessage: "__clerkAuthMessage";
21
+ readonly ClerkUrl: "__clerkUrl";
22
+ };
23
+ readonly Cookies: {
24
+ readonly Session: "__session";
25
+ readonly Client: "__client";
26
+ readonly User: "__user";
27
+ };
28
+ readonly Headers: {
29
+ readonly AuthToken: "x-cabin-id-auth-token";
30
+ readonly AuthSignature: "x-cabin-id-auth-signature";
31
+ readonly AuthStatus: "x-cabin-id-auth-status";
32
+ readonly AuthReason: "x-cabin-id-auth-reason";
33
+ readonly AuthMessage: "x-cabin-id-auth-message";
34
+ readonly CabinIdUrl: "x-cabin-id-cabin-id-url";
35
+ readonly EnableDebug: "x-cabin-id-debug";
36
+ readonly CabinIdRedirectTo: "x-cabin-id-redirect-to";
37
+ readonly CloudFrontForwardedProto: "cloudfront-forwarded-proto";
38
+ readonly Authorization: "authorization";
39
+ readonly ForwardedPort: "x-forwarded-port";
40
+ readonly ForwardedProto: "x-forwarded-proto";
41
+ readonly ForwardedHost: "x-forwarded-host";
42
+ readonly Accept: "accept";
43
+ readonly Referrer: "referer";
44
+ readonly UserAgent: "user-agent";
45
+ readonly Origin: "origin";
46
+ readonly Host: "host";
47
+ readonly ContentType: "content-type";
48
+ readonly SecFetchDest: "sec-fetch-dest";
49
+ readonly Location: "location";
50
+ };
51
+ readonly ContentTypes: {
52
+ readonly Json: "application/json";
53
+ };
54
+ readonly QueryParams: {
55
+ readonly UserId: "user_id";
56
+ readonly Token: "token";
57
+ };
58
+ readonly NextHeaders: {
59
+ readonly NextRewrite: "x-middleware-rewrite";
60
+ readonly NextResume: "x-middleware-next";
61
+ readonly NextRedirect: "Location";
62
+ readonly NextUrl: "next-url";
63
+ readonly NextAction: "next-action";
64
+ readonly NextjsData: "x-nextjs-data";
65
+ };
66
+ };
67
+ export type Constants = typeof constants;
68
+ //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAElD,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,eAAe,QACyB,CAAC;AACtD,eAAO,MAAM,UAAU,QAAyC,CAAC;AACjE,eAAO,MAAM,kBAAkB,QACsB,CAAC;AACtD,eAAO,MAAM,kBAAkB,QACsB,CAAC;AACtD,eAAO,MAAM,wBAAwB,QACqB,CAAC;AAC3D,eAAO,MAAM,wBAAwB,QACqB,CAAC;AAE3D,eAAO,MAAM,UAAU,QAAkC,CAAC;AAC1D,eAAO,MAAM,WAAW,eAAuC,CAAC;AA6DhE;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOZ,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,2BAA2B,CAAC;AAChD,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,eAAe,QACyB,CAAC;AACtD,eAAO,MAAM,UAAU,QAAyC,CAAC;AACjE,eAAO,MAAM,kBAAkB,QACsB,CAAC;AACtD,eAAO,MAAM,kBAAkB,QACsB,CAAC;AACtD,eAAO,MAAM,wBAAwB,QACqB,CAAC;AAC3D,eAAO,MAAM,wBAAwB,QACqB,CAAC;AAE3D,eAAO,MAAM,UAAU,QAAkC,CAAC;AAC1D,eAAO,MAAM,WAAW,eAAuC,CAAC;AA6DhE;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOZ,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { useUser } from './useUser';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const useUser: () => import("../types").User | null;
2
+ //# sourceMappingURL=useUser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUser.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUser.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,6CAMnB,CAAC"}
1
+ {"version":3,"file":"useUser.d.ts","sourceRoot":"","sources":["../../../src/hooks/useUser.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,sCAMnB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const CabinLogo: React.FC<React.SVGProps<SVGSVGElement>>;
3
+ //# sourceMappingURL=logo.d.ts.map
@@ -0,0 +1,7 @@
1
+ export { auth } from './server/auth';
2
+ export { currentUser } from './server/getCurrentUser';
3
+ export { CabinIDProvider } from './client/provider';
4
+ export { useUser } from './hooks';
5
+ export { authMiddleware } from './server/middleware';
6
+ export { SignInButton } from './components';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare const auth: () => {
2
+ userId: string | null;
3
+ };
4
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1,21 @@
1
+ type RedirectAdapter<RedirectReturn> = (url: string) => RedirectReturn;
2
+ type RedirectToParams = {
3
+ returnBackUrl?: string | URL | null;
4
+ };
5
+ export type RedirectFun<ReturnType> = (params?: RedirectToParams) => ReturnType;
6
+ /**
7
+ * @internal
8
+ */
9
+ type CreateRedirect = <ReturnType>(params: {
10
+ publishableKey: string;
11
+ redirectAdapter: RedirectAdapter<ReturnType>;
12
+ baseUrl: URL | string;
13
+ signInUrl?: URL | string;
14
+ signUpUrl?: URL | string;
15
+ }) => {
16
+ redirectToSignIn: RedirectFun<ReturnType>;
17
+ redirectToSignUp: RedirectFun<ReturnType>;
18
+ };
19
+ export declare const createRedirect: CreateRedirect;
20
+ export {};
21
+ //# sourceMappingURL=createRedirect.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { User } from '../types';
2
+ export declare function currentUser(): Promise<User | null>;
3
+ //# sourceMappingURL=getCurrentUser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCurrentUser.d.ts","sourceRoot":"","sources":["../../../src/server/getCurrentUser.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAYxD"}
1
+ {"version":3,"file":"getCurrentUser.d.ts","sourceRoot":"","sources":["../../../src/server/getCurrentUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAKhC,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAaxD"}
@@ -0,0 +1,88 @@
1
+ import { NextFetchEvent, NextMiddleware, NextResponse } from 'next/server';
2
+ import { NextRequest } from 'next/server';
3
+ import { createRouteMatcher, RouteMatcherParam } from './routeMatcher';
4
+ import { NextMiddlewareReturn } from './type';
5
+ type BeforeAuthHandler = (req: NextRequest, evt: NextFetchEvent) => NextMiddlewareReturn | false | Promise<false>;
6
+ type AfterAuthHandler = (auth: {
7
+ isPublicRoute: boolean;
8
+ isApiRoute: boolean;
9
+ }, req: NextRequest, evt: NextFetchEvent) => NextMiddlewareReturn;
10
+ export type AuthenticateRequestOptions = {
11
+ publishableKey?: string;
12
+ secretKey?: string;
13
+ domain?: string;
14
+ isSatellite?: boolean;
15
+ proxyUrl?: string;
16
+ signInUrl?: string;
17
+ signUpUrl?: string;
18
+ afterSignInUrl?: string;
19
+ afterSignUpUrl?: string;
20
+ };
21
+ type AuthMiddlewareParams = AuthenticateRequestOptions & {
22
+ /**
23
+ * A function that is called before the authentication middleware is executed.
24
+ * If a redirect response is returned, the middleware will respect it and redirect the user.
25
+ * If false is returned, the auth middleware will not execute and the request will be handled as if the auth middleware was not present.
26
+ */
27
+ beforeAuth?: BeforeAuthHandler;
28
+ /**
29
+ * A function that is called after the authentication middleware is executed.
30
+ * This function has access to the auth object and can be used to execute logic based on the auth state.
31
+ */
32
+ afterAuth?: AfterAuthHandler;
33
+ /**
34
+ * A list of routes that should be accessible without authentication.
35
+ * You can use glob patterns to match multiple routes or a function to match against the request object.
36
+ * Path patterns and regular expressions are supported, for example: `['/foo', '/bar(.*)'] or `[/^\/foo\/.*$/]`
37
+ * The sign in and sign up URLs are included by default, unless a function is provided.
38
+ * For more information, see: https://clerk.com/docs
39
+ */
40
+ publicRoutes?: RouteMatcherParam;
41
+ /**
42
+ * A list of routes that should be ignored by the middleware.
43
+ * This list typically includes routes for static files or Next.js internals.
44
+ * For improved performance, these routes should be skipped using the default config.matcher instead.
45
+ */
46
+ ignoredRoutes?: IgnoredRoutesParam;
47
+ /**
48
+ * A list of routes that should be treated as API endpoints.
49
+ * When user is signed out, the middleware will return a 401 response for these routes, instead of redirecting the user.
50
+ *
51
+ * If omitted, the following heuristics will be used to determine an API endpoint:
52
+ * - The route path is ['/api/(.*)', '/trpc/(.*)'],
53
+ * - or the request has `Content-Type` set to `application/json`,
54
+ * - or the request method is not one of: `GET`, `OPTIONS` ,` HEAD`
55
+ *
56
+ * @default undefined
57
+ */
58
+ apiRoutes?: ApiRoutesParam;
59
+ };
60
+ export interface AuthMiddleware {
61
+ (params?: AuthMiddlewareParams): NextMiddleware;
62
+ }
63
+ /**
64
+ * The default ideal matcher that excludes the _next directory (internals) and all static files,
65
+ * but it will match the root route (/) and any routes that start with /api or /trpc.
66
+ */
67
+ export declare const DEFAULT_CONFIG_MATCHER: string[];
68
+ /**
69
+ * Any routes matching this path will be ignored by the middleware.
70
+ * This is the inverted version of DEFAULT_CONFIG_MATCHER.
71
+ */
72
+ export declare const DEFAULT_IGNORED_ROUTES: string[];
73
+ /**
74
+ * Any routes matching this path will be treated as API endpoints by the middleware.
75
+ */
76
+ export declare const DEFAULT_API_ROUTES: string[];
77
+ type IgnoredRoutesParam = Array<RegExp | string> | RegExp | string | ((req: NextRequest) => boolean);
78
+ type ApiRoutesParam = IgnoredRoutesParam;
79
+ declare const authMiddleware: AuthMiddleware;
80
+ declare const createApiRoutes: (apiRoutes: RouteMatcherParam | undefined) => ((req: NextRequest) => boolean);
81
+ export declare const createDefaultAfterAuth: (isPublicRoute: ReturnType<typeof createRouteMatcher>, isApiRoute: ReturnType<typeof createApiRoutes>, options: {
82
+ signInUrl: string;
83
+ signUpUrl: string;
84
+ publishableKey: string;
85
+ secretKey: string;
86
+ }) => (auth: any, req: NextRequest) => NextResponse<unknown>;
87
+ export { authMiddleware };
88
+ //# sourceMappingURL=middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/server/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAK9C,KAAK,iBAAiB,GAAG,CACvB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,cAAc,KAChB,oBAAoB,GA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W,KAAK,OAAO,CAShC,CAAC;AAEF,eAAO,MAAM,sBAAsB,kBAClB,WAAW,yBAAyB,CAAC,cACxC,WAAW,sBAAsB,CAAC,WACrC;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,YAEa,GAAG,OAAO,WAAW,0BAiBpC,CAAC;AAyBF,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type Link from "next/link";
2
+ import type { NextRequest } from "next/server";
3
+ import type { Autocomplete } from "../types";
4
+ type WithPathPatternWildcard<T> = `${T & string}(.*)`;
5
+ type NextTypedRoute<T = Parameters<typeof Link>["0"]["href"]> = T extends string ? T : never;
6
+ type RouteMatcherWithNextTypedRoutes = Autocomplete<WithPathPatternWildcard<NextTypedRoute> | NextTypedRoute>;
7
+ export type RouteMatcherParam = Array<RegExp | RouteMatcherWithNextTypedRoutes> | RegExp | RouteMatcherWithNextTypedRoutes | ((req: NextRequest) => boolean);
8
+ export declare const createRouteMatcher: (routes: RouteMatcherParam) => (req: NextRequest) => boolean;
9
+ export {};
10
+ //# sourceMappingURL=routeMatcher.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const serverRedirectWithAuth: (res: Response) => Response;
2
+ //# sourceMappingURL=serverRedirectWithAuth.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { NextMiddleware } from "next/server";
2
+ export type NextMiddlewareRequestParam = Parameters<NextMiddleware>['0'];
3
+ export type NextMiddlewareEvtParam = Parameters<NextMiddleware>['1'];
4
+ export type NextMiddlewareReturn = ReturnType<NextMiddleware>;
5
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { NextResponse } from 'next/server';
2
+ import type { NextRequest } from 'next/server';
3
+ export declare function assertKey(key: string, onError: () => never): string;
4
+ export declare const apiEndpointUnauthorizedNextResponse: () => NextResponse<null>;
5
+ export declare const redirectAdapter: (url: string | URL) => NextResponse<unknown>;
6
+ export declare const setRequestHeadersOnNextResponse: (res: NextResponse | Response, req: Request, newHeaders: Record<string, string>) => void;
7
+ type RequestState = any;
8
+ export declare function decorateRequest(req: NextRequest, res: Response, requestState: RequestState, secretKey: string): Response;
9
+ export {};
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,36 @@
1
+ import type { NextRequest } from 'next/server';
2
+ export type User = {
3
+ id: string;
4
+ avatar: string | null;
5
+ email: string | null;
6
+ phoneNumber: string;
7
+ firstName: string;
8
+ lastName: string;
9
+ address: string | null;
10
+ createdAt: string;
11
+ updatedAt: string;
12
+ };
13
+ export type CabinIDProviderProps = {
14
+ user: User | null;
15
+ };
16
+ export type LogoutParams = {
17
+ redirectUrl?: string;
18
+ };
19
+ export type ResponseDataType<T> = {
20
+ data?: T;
21
+ error: any;
22
+ loading: boolean;
23
+ };
24
+ /**
25
+ * Enables autocompletion for a union type, while keeping the ability to use any string
26
+ * or type of `T`
27
+ */
28
+ export type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
29
+ /**
30
+ * Omit without union flattening
31
+ * */
32
+ export type Without<T, W> = {
33
+ [P in keyof T as Exclude<P, W>]: T[P];
34
+ };
35
+ export type IgnoredRoutesParam = Array<RegExp | string> | RegExp | string | ((req: NextRequest) => boolean);
36
+ //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MA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B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,GAAG,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,MAAM,IAC5C,CAAC,GACD,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAE/B;;KAEK;AACL,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GACtB,MAAM,GACN,MAAM,GACN,CAAC,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function assertValidSecretKey(val: unknown): asserts val is string;
2
+ //# sourceMappingURL=assertValidSecretKey.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A function that decodes a string of data which has been encoded using base-64 encoding.
3
+ * Uses `atob` if available, otherwise uses `Buffer` from `global`. If neither are available, returns the data as-is.
4
+ */
5
+ export declare const isomorphicAtob: (data: string) => string;
6
+ //# sourceMappingURL=isomorphicAtob.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare const isomorphicBtoa: (data: string) => string;
2
+ //# sourceMappingURL=isomorphicBtoa.d.ts.map
@@ -0,0 +1,5 @@
1
+ type PublishableKey = string;
2
+ export declare function isPublishableKey(key: string): boolean;
3
+ export declare function parsePublishableKey(key: string | undefined): PublishableKey | null;
4
+ export {};
5
+ //# sourceMappingURL=key.d.ts.map
@@ -0,0 +1,4 @@
1
+ type PathString = string | null | undefined;
2
+ export declare function joinPaths(...args: PathString[]): string;
3
+ export {};
4
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { NextResponse } from 'next/server';
2
+ /**
3
+ * A function that merges two Response objects into a single response.
4
+ * The final response respects the body and the status of the last response,
5
+ * but the cookies and headers of all responses are merged.
6
+ */
7
+ export declare const mergeResponses: (...responses: (NextResponse | Response | null | undefined | void)[]) => NextResponse<unknown> | undefined;
8
+ export declare const isRedirect: (res: Response) => string | null;
9
+ export declare const setHeader: <T extends Response>(res: T, name: string, val: string) => T;
10
+ export declare const stringifyHeaders: (headers: {
11
+ forEach: Headers['forEach'];
12
+ }) => string;
13
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare const paths: {
2
+ toRegexp: (path: string) => RegExp;
3
+ };
4
+ //# sourceMappingURL=utils.d.ts.map
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@cabin-id/nextjs",
3
- "version": "0.0.1",
3
+ "description": "NextJS SDK for CabinID",
4
+ "version": "0.1.1",
4
5
  "main": "./dist/index.js",
5
6
  "module": "./dist/index.mjs",
6
7
  "author": "CabinVN",
8
+ "homepage": "https://cabinid.dev",
7
9
  "sideEffects": false,
8
10
  "exports": {
9
11
  ".": {
@@ -34,12 +36,9 @@
34
36
  "@types/react-dom": "^18.2.19",
35
37
  "autoprefixer": "^10.4.19",
36
38
  "eslint": "^8.57.0",
37
- "postcss": "^8.4.38",
38
39
  "react": "^18.2.0",
39
- "tailwindcss": "^3.4.3",
40
40
  "tsup": "^8.0.2",
41
- "typescript": "^5.3.3",
42
- "@cabin-id/tailwind-config": "0.0.4"
41
+ "typescript": "^5.3.3"
43
42
  },
44
43
  "dependencies": {
45
44
  "cookies-next": "^4.1.1",
@@ -1,17 +0,0 @@
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 __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var global_d_exports = {};
16
- module.exports = __toCommonJS(global_d_exports);
17
- //# sourceMappingURL=global.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/global.d.ts"],"sourcesContent":["declare global {\n namespace NodeJS {\n interface ProcessEnv {\n CABIN_ID_SECRET_KEY: string | undefined;\n NEXT_PUBLIC_CABIN_ID_PUBLISH_KEY: string | undefined;\n NEXT_PUBLIC_CABIN_ID_SIGN_IN_URL: string | undefined;\n NEXT_PUBLIC_CABIN_ID_SIGN_UP_URL: string | undefined;\n NEXT_PUBLIC_CABIN_ID_AFTER_SIGN_IN_URL: string | undefined;\n NEXT_PUBLIC_CABIN_ID_AFTER_SIGN_UP_URL: string | undefined;\n }\n }\n}\n\nexport {};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}