naystack 1.6.1 → 1.7.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 (64) hide show
  1. package/README.md +39 -22
  2. package/dist/auth/email/client.d.mts +17 -0
  3. package/dist/auth/email/client.d.ts +17 -0
  4. package/dist/auth/email/index.cjs.js +3 -3
  5. package/dist/auth/email/index.d.mts +6 -6
  6. package/dist/auth/email/index.d.ts +6 -6
  7. package/dist/auth/email/index.esm.js +2 -2
  8. package/dist/auth/email/routes/delete.d.mts +3 -3
  9. package/dist/auth/email/routes/delete.d.ts +3 -3
  10. package/dist/auth/email/routes/get.d.mts +3 -3
  11. package/dist/auth/email/routes/get.d.ts +3 -3
  12. package/dist/auth/email/routes/post.d.mts +3 -3
  13. package/dist/auth/email/routes/post.d.ts +3 -3
  14. package/dist/auth/email/routes/put.d.mts +3 -3
  15. package/dist/auth/email/routes/put.d.ts +3 -3
  16. package/dist/auth/email/token.cjs.js +3 -3
  17. package/dist/auth/email/token.d.mts +2 -2
  18. package/dist/auth/email/token.d.ts +2 -2
  19. package/dist/auth/email/token.esm.js +3 -3
  20. package/dist/auth/email/types.d.mts +5 -4
  21. package/dist/auth/email/types.d.ts +5 -4
  22. package/dist/auth/email/utils.d.mts +3 -3
  23. package/dist/auth/email/utils.d.ts +3 -3
  24. package/dist/auth/google/get.d.mts +3 -3
  25. package/dist/auth/google/get.d.ts +3 -3
  26. package/dist/auth/google/index.cjs.js +3 -3
  27. package/dist/auth/google/index.d.mts +7 -7
  28. package/dist/auth/google/index.d.ts +7 -7
  29. package/dist/auth/google/index.esm.js +2 -2
  30. package/dist/auth/index.cjs.js +12 -12
  31. package/dist/auth/index.d.mts +3 -3
  32. package/dist/auth/index.d.ts +3 -3
  33. package/dist/auth/index.esm.js +9 -9
  34. package/dist/auth/instagram/index.cjs.js +6 -6
  35. package/dist/auth/instagram/index.d.mts +8 -9
  36. package/dist/auth/instagram/index.d.ts +8 -9
  37. package/dist/auth/instagram/index.esm.js +5 -5
  38. package/dist/auth/instagram/route.cjs.js +3 -3
  39. package/dist/auth/instagram/route.d.mts +3 -3
  40. package/dist/auth/instagram/route.d.ts +3 -3
  41. package/dist/auth/instagram/route.esm.js +3 -3
  42. package/dist/file/client.d.mts +7 -7
  43. package/dist/file/client.d.ts +7 -7
  44. package/dist/graphql/client.d.mts +5 -5
  45. package/dist/graphql/client.d.ts +5 -5
  46. package/dist/graphql/index.cjs.js +20 -6
  47. package/dist/graphql/index.d.mts +2 -2
  48. package/dist/graphql/index.d.ts +2 -2
  49. package/dist/graphql/index.esm.js +18 -4
  50. package/dist/graphql/init.cjs.js +3 -3
  51. package/dist/graphql/init.d.mts +4 -4
  52. package/dist/graphql/init.d.ts +4 -4
  53. package/dist/graphql/init.esm.js +2 -2
  54. package/dist/graphql/utils.cjs.js +17 -3
  55. package/dist/graphql/utils.d.mts +16 -16
  56. package/dist/graphql/utils.d.ts +16 -16
  57. package/dist/graphql/utils.esm.js +16 -2
  58. package/dist/index.d.mts +1 -1
  59. package/dist/index.d.ts +1 -1
  60. package/dist/socials/instagram/webhook.d.mts +2 -2
  61. package/dist/socials/instagram/webhook.d.ts +2 -2
  62. package/dist/utils/route.d.mts +20 -0
  63. package/dist/utils/route.d.ts +20 -0
  64. package/package.json +1 -1
@@ -9,10 +9,10 @@ import { NextRequest } from 'next/server';
9
9
  *
10
10
  * @param options - Configuration object.
11
11
  * @param options.secret - The verify token you configured in the Meta Developer Portal.
12
- * @param options.callback - Called for each webhook event: `(type, value, pageId) => Promise<void>`.
12
+ * @param options.callback - Called for each webhook event: `(type, value, id) => Promise<void>`.
13
13
  * - `type` — Event type (e.g. `"messaging"`, `"changes"`).
14
14
  * - `value` — Event payload.
15
- * - `id` — The page/account id from the entry.
15
+ * - `id` — The entry id (page or account id) from the webhook payload.
16
16
  * @returns Object with `GET` and `POST` — export as your route's handlers.
17
17
  *
18
18
  * @example
@@ -9,10 +9,10 @@ import { NextRequest } from 'next/server';
9
9
  *
10
10
  * @param options - Configuration object.
11
11
  * @param options.secret - The verify token you configured in the Meta Developer Portal.
12
- * @param options.callback - Called for each webhook event: `(type, value, pageId) => Promise<void>`.
12
+ * @param options.callback - Called for each webhook event: `(type, value, id) => Promise<void>`.
13
13
  * - `type` — Event type (e.g. `"messaging"`, `"changes"`).
14
14
  * - `value` — Event payload.
15
- * - `id` — The page/account id from the entry.
15
+ * - `id` — The entry id (page or account id) from the webhook payload.
16
16
  * @returns Object with `GET` and `POST` — export as your route's handlers.
17
17
  *
18
18
  * @example
@@ -1,11 +1,31 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
2
 
3
+ /**
4
+ * Returns CORS headers for the given origin if it is in the allowed list.
5
+ *
6
+ * @param origin - The `Origin` header value from the request.
7
+ * @param allowedOrigins - List of permitted origins.
8
+ * @returns CORS headers object, or `null` if the origin is not allowed.
9
+ *
10
+ * @category Utils
11
+ */
3
12
  declare function getCorsHeaders(origin: string | null, allowedOrigins: string[]): {
4
13
  "Access-Control-Allow-Origin": string;
5
14
  "Access-Control-Allow-Methods": string;
6
15
  "Access-Control-Allow-Headers": string;
7
16
  "Access-Control-Allow-Credentials": string;
8
17
  } | null;
18
+ /**
19
+ * Wraps a Next.js route handler to add CORS headers for the specified allowed origins.
20
+ * Same-origin requests are passed through unchanged. Cross-origin requests from
21
+ * unlisted origins are rejected with HTTP 403.
22
+ *
23
+ * @param handler - The route handler to wrap.
24
+ * @param allowedOrigins - List of permitted origins. If empty or undefined, the handler is returned as-is (no CORS).
25
+ * @returns The wrapped handler with CORS support.
26
+ *
27
+ * @category Utils
28
+ */
9
29
  declare function withCors<T extends (req: NextRequest) => Promise<NextResponse | Response | undefined> | NextResponse | Response | undefined>(handler: T, allowedOrigins?: string[]): T;
10
30
 
11
31
  export { getCorsHeaders, withCors };
@@ -1,11 +1,31 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
2
 
3
+ /**
4
+ * Returns CORS headers for the given origin if it is in the allowed list.
5
+ *
6
+ * @param origin - The `Origin` header value from the request.
7
+ * @param allowedOrigins - List of permitted origins.
8
+ * @returns CORS headers object, or `null` if the origin is not allowed.
9
+ *
10
+ * @category Utils
11
+ */
3
12
  declare function getCorsHeaders(origin: string | null, allowedOrigins: string[]): {
4
13
  "Access-Control-Allow-Origin": string;
5
14
  "Access-Control-Allow-Methods": string;
6
15
  "Access-Control-Allow-Headers": string;
7
16
  "Access-Control-Allow-Credentials": string;
8
17
  } | null;
18
+ /**
19
+ * Wraps a Next.js route handler to add CORS headers for the specified allowed origins.
20
+ * Same-origin requests are passed through unchanged. Cross-origin requests from
21
+ * unlisted origins are rejected with HTTP 403.
22
+ *
23
+ * @param handler - The route handler to wrap.
24
+ * @param allowedOrigins - List of permitted origins. If empty or undefined, the handler is returned as-is (no CORS).
25
+ * @returns The wrapped handler with CORS support.
26
+ *
27
+ * @category Utils
28
+ */
9
29
  declare function withCors<T extends (req: NextRequest) => Promise<NextResponse | Response | undefined> | NextResponse | Response | undefined>(handler: T, allowedOrigins?: string[]): T;
10
30
 
11
31
  export { getCorsHeaders, withCors };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",