@draftlab/auth 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.
Files changed (86) hide show
  1. package/dist/adapters/node.d.ts +18 -0
  2. package/dist/adapters/node.js +71 -0
  3. package/dist/allow-CixonwTW.d.ts +59 -0
  4. package/dist/allow-DX5cehSc.js +63 -0
  5. package/dist/allow.d.ts +2 -0
  6. package/dist/allow.js +4 -0
  7. package/dist/base-DRutbxgL.js +422 -0
  8. package/dist/client.d.ts +413 -0
  9. package/dist/client.js +209 -0
  10. package/dist/code-l_uvMR1j.d.ts +212 -0
  11. package/dist/core-8WTqfnb4.d.ts +129 -0
  12. package/dist/core-CncE5rPg.js +498 -0
  13. package/dist/core.d.ts +9 -0
  14. package/dist/core.js +14 -0
  15. package/dist/error-CWAdNAzm.d.ts +243 -0
  16. package/dist/error-DgAKK7b2.js +237 -0
  17. package/dist/error.d.ts +2 -0
  18. package/dist/error.js +3 -0
  19. package/dist/form-6XKM_cOk.js +61 -0
  20. package/dist/icon-Ci5uqGB_.js +192 -0
  21. package/dist/index.d.ts +9 -0
  22. package/dist/index.js +14 -0
  23. package/dist/keys-EEfxEGfO.js +140 -0
  24. package/dist/keys.d.ts +67 -0
  25. package/dist/keys.js +5 -0
  26. package/dist/oauth2-B7-6Z7Lc.js +155 -0
  27. package/dist/oauth2-DtKwtl8p.d.ts +176 -0
  28. package/dist/password-Cm0dRMwa.d.ts +385 -0
  29. package/dist/pkce-276Za_rZ.js +162 -0
  30. package/dist/pkce.d.ts +72 -0
  31. package/dist/pkce.js +3 -0
  32. package/dist/provider/code.d.ts +4 -0
  33. package/dist/provider/code.js +145 -0
  34. package/dist/provider/facebook.d.ts +137 -0
  35. package/dist/provider/facebook.js +85 -0
  36. package/dist/provider/github.d.ts +141 -0
  37. package/dist/provider/github.js +88 -0
  38. package/dist/provider/google.d.ts +113 -0
  39. package/dist/provider/google.js +62 -0
  40. package/dist/provider/oauth2.d.ts +4 -0
  41. package/dist/provider/oauth2.js +7 -0
  42. package/dist/provider/password.d.ts +4 -0
  43. package/dist/provider/password.js +366 -0
  44. package/dist/provider/provider.d.ts +3 -0
  45. package/dist/provider/provider.js +44 -0
  46. package/dist/provider-CwWMG-1l.d.ts +227 -0
  47. package/dist/random-SXMYlaVr.js +87 -0
  48. package/dist/random.d.ts +66 -0
  49. package/dist/random.js +3 -0
  50. package/dist/select-BjySLL8I.js +280 -0
  51. package/dist/storage/memory.d.ts +82 -0
  52. package/dist/storage/memory.js +127 -0
  53. package/dist/storage/storage.d.ts +2 -0
  54. package/dist/storage/storage.js +3 -0
  55. package/dist/storage/turso.d.ts +31 -0
  56. package/dist/storage/turso.js +117 -0
  57. package/dist/storage/unstorage.d.ts +38 -0
  58. package/dist/storage/unstorage.js +97 -0
  59. package/dist/storage-BEaqEPNQ.js +62 -0
  60. package/dist/storage-CxKerLlc.d.ts +162 -0
  61. package/dist/subject-DiQdRWGt.d.ts +62 -0
  62. package/dist/subject.d.ts +3 -0
  63. package/dist/subject.js +36 -0
  64. package/dist/theme-C9by7VXf.d.ts +209 -0
  65. package/dist/theme-CswaLtbW.js +120 -0
  66. package/dist/themes/theme.d.ts +2 -0
  67. package/dist/themes/theme.js +3 -0
  68. package/dist/types.d.ts +94 -0
  69. package/dist/types.js +0 -0
  70. package/dist/ui/base.d.ts +43 -0
  71. package/dist/ui/base.js +4 -0
  72. package/dist/ui/code.d.ts +158 -0
  73. package/dist/ui/code.js +197 -0
  74. package/dist/ui/form.d.ts +31 -0
  75. package/dist/ui/form.js +3 -0
  76. package/dist/ui/icon.d.ts +98 -0
  77. package/dist/ui/icon.js +3 -0
  78. package/dist/ui/password.d.ts +54 -0
  79. package/dist/ui/password.js +300 -0
  80. package/dist/ui/select.d.ts +233 -0
  81. package/dist/ui/select.js +6 -0
  82. package/dist/util-CSdHUFOo.js +108 -0
  83. package/dist/util-ChlgVqPN.d.ts +72 -0
  84. package/dist/util.d.ts +2 -0
  85. package/dist/util.js +3 -0
  86. package/package.json +63 -0
@@ -0,0 +1,72 @@
1
+ import { RouterContext } from "@draftlab/router/types";
2
+
3
+ //#region src/util.d.ts
4
+
5
+ /**
6
+ * Utility type that flattens complex types for better IntelliSense display.
7
+ * Converts intersections and complex mapped types into cleaner object types.
8
+ *
9
+ * @template T - The type to prettify
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * type Complex = { a: string } & { b: number }
14
+ * type Clean = Prettify<Complex> // { a: string; b: number }
15
+ * ```
16
+ */
17
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
18
+ /**
19
+ * Constructs a complete URL relative to the current request context.
20
+ * Handles proxy headers (x-forwarded-*) to ensure correct URL generation
21
+ * in containerized and load-balanced environments.
22
+ *
23
+ * @param ctx - Router context containing request information
24
+ * @param path - Relative path to append to the base URL
25
+ * @returns Complete URL string with proper protocol, host, and port
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const callbackUrl = getRelativeUrl(ctx, "/callback")
30
+ * // Returns: "https://myapp.com/auth/callback"
31
+ * ```
32
+ */
33
+ declare const getRelativeUrl: (ctx: RouterContext, path: string) => string;
34
+ /**
35
+ * Determines if two domain names are considered a match for security purposes.
36
+ * Uses effective TLD+1 matching to allow subdomains while preventing
37
+ * unauthorized cross-domain requests.
38
+ *
39
+ * @param a - First domain name to compare
40
+ * @param b - Second domain name to compare
41
+ * @returns True if domains are considered a security match
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * isDomainMatch("app.example.com", "auth.example.com") // true
46
+ * isDomainMatch("example.com", "evil.com") // false
47
+ * isDomainMatch("app.co.uk", "auth.co.uk") // true (handles two-part TLD)
48
+ * ```
49
+ */
50
+ declare const isDomainMatch: (a: string, b: string) => boolean;
51
+ /**
52
+ * Creates a lazy-evaluated function that caches the result of the first execution.
53
+ * Subsequent calls return the cached value without re-executing the function.
54
+ *
55
+ * @template T - The return type of the lazy function
56
+ * @param fn - Function to execute lazily
57
+ * @returns Function that returns the cached result
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const expensiveOperation = lazy(() => {
62
+ * // Computing... (only logs once)
63
+ * return heavyComputation()
64
+ * })
65
+ *
66
+ * const result1 = expensiveOperation() // Executes and caches
67
+ * const result2 = expensiveOperation() // Returns cached value
68
+ * ```
69
+ */
70
+ declare const lazy: <T>(fn: () => T) => (() => T);
71
+ //#endregion
72
+ export { Prettify, getRelativeUrl, isDomainMatch, lazy };
package/dist/util.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { Prettify, getRelativeUrl, isDomainMatch, lazy } from "./util-ChlgVqPN.js";
2
+ export { Prettify, getRelativeUrl, isDomainMatch, lazy };
package/dist/util.js ADDED
@@ -0,0 +1,3 @@
1
+ import { getRelativeUrl, isDomainMatch, lazy } from "./util-CSdHUFOo.js";
2
+
3
+ export { getRelativeUrl, isDomainMatch, lazy };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@draftlab/auth",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "Core implementation",
6
+ "author": "Matheus Pergoli",
7
+ "main": "dist/index.js",
8
+ "typings": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./*": {
18
+ "import": "./dist/*.js",
19
+ "types": "./dist/*.d.ts"
20
+ },
21
+ "./ui": {
22
+ "import": "./dist/ui/index.js",
23
+ "types": "./dist/ui/index.d.ts"
24
+ }
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/Draft-Lab/auth.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/Draft-Lab/auth/issues"
32
+ },
33
+ "license": "MIT",
34
+ "devDependencies": {
35
+ "@changesets/cli": "^2.29.5",
36
+ "@types/node": "^24.0.12",
37
+ "tsdown": "^0.12.9",
38
+ "typescript": "^5.8.3",
39
+ "@draftlab/tsconfig": "0.1.0"
40
+ },
41
+ "peerDependencies": {
42
+ "@libsql/client": "^0.15.0",
43
+ "unstorage": "^1.0.0"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "@libsql/client": {
47
+ "optional": true
48
+ },
49
+ "unstorage": {
50
+ "optional": true
51
+ }
52
+ },
53
+ "dependencies": {
54
+ "@standard-schema/spec": "^1.0.0",
55
+ "jose": "^6.0.11",
56
+ "@draftlab/router": "0.1.0"
57
+ },
58
+ "scripts": {
59
+ "build": "tsdown",
60
+ "deploy": "tsdown && changeset publish",
61
+ "clean": "rm -rf dist .turbo node_modules"
62
+ }
63
+ }