@parsrun/auth 0.1.0

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 (54) hide show
  1. package/README.md +133 -0
  2. package/dist/adapters/hono.d.ts +9 -0
  3. package/dist/adapters/hono.js +6 -0
  4. package/dist/adapters/hono.js.map +1 -0
  5. package/dist/adapters/index.d.ts +9 -0
  6. package/dist/adapters/index.js +7 -0
  7. package/dist/adapters/index.js.map +1 -0
  8. package/dist/authorization-By1Xp8Za.d.ts +213 -0
  9. package/dist/base-BKyR8rcE.d.ts +646 -0
  10. package/dist/chunk-42MGHABB.js +263 -0
  11. package/dist/chunk-42MGHABB.js.map +1 -0
  12. package/dist/chunk-7GOBAL4G.js +3 -0
  13. package/dist/chunk-7GOBAL4G.js.map +1 -0
  14. package/dist/chunk-G5I3T73A.js +152 -0
  15. package/dist/chunk-G5I3T73A.js.map +1 -0
  16. package/dist/chunk-IB4WUQDZ.js +410 -0
  17. package/dist/chunk-IB4WUQDZ.js.map +1 -0
  18. package/dist/chunk-MOG4Y6I7.js +415 -0
  19. package/dist/chunk-MOG4Y6I7.js.map +1 -0
  20. package/dist/chunk-NK4TJV2W.js +295 -0
  21. package/dist/chunk-NK4TJV2W.js.map +1 -0
  22. package/dist/chunk-RHNVRCF3.js +838 -0
  23. package/dist/chunk-RHNVRCF3.js.map +1 -0
  24. package/dist/chunk-YTCPXJR5.js +570 -0
  25. package/dist/chunk-YTCPXJR5.js.map +1 -0
  26. package/dist/cloudflare-kv-L64CZKDK.js +105 -0
  27. package/dist/cloudflare-kv-L64CZKDK.js.map +1 -0
  28. package/dist/deno-kv-F55HKKP6.js +111 -0
  29. package/dist/deno-kv-F55HKKP6.js.map +1 -0
  30. package/dist/index-C3kz9XqE.d.ts +226 -0
  31. package/dist/index-DOGcetyD.d.ts +1041 -0
  32. package/dist/index.d.ts +1579 -0
  33. package/dist/index.js +4294 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/jwt-manager-CH8H0kmm.d.ts +182 -0
  36. package/dist/providers/index.d.ts +90 -0
  37. package/dist/providers/index.js +3 -0
  38. package/dist/providers/index.js.map +1 -0
  39. package/dist/providers/otp/index.d.ts +3 -0
  40. package/dist/providers/otp/index.js +4 -0
  41. package/dist/providers/otp/index.js.map +1 -0
  42. package/dist/redis-5TIS6XCA.js +121 -0
  43. package/dist/redis-5TIS6XCA.js.map +1 -0
  44. package/dist/security/index.d.ts +301 -0
  45. package/dist/security/index.js +5 -0
  46. package/dist/security/index.js.map +1 -0
  47. package/dist/session/index.d.ts +117 -0
  48. package/dist/session/index.js +4 -0
  49. package/dist/session/index.js.map +1 -0
  50. package/dist/storage/index.d.ts +97 -0
  51. package/dist/storage/index.js +3 -0
  52. package/dist/storage/index.js.map +1 -0
  53. package/dist/types-DSjafxJ4.d.ts +193 -0
  54. package/package.json +102 -0
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Multi-runtime KV Storage interface
3
+ * Supports: Memory, Redis, Cloudflare KV, Deno KV
4
+ */
5
+ /**
6
+ * Base KV Storage interface that all adapters must implement
7
+ */
8
+ interface KVStorage {
9
+ /**
10
+ * Get a value by key
11
+ * @param key - The key to retrieve
12
+ * @returns The value or null if not found
13
+ */
14
+ get<T = unknown>(key: string): Promise<T | null>;
15
+ /**
16
+ * Set a value with optional TTL
17
+ * @param key - The key to set
18
+ * @param value - The value to store
19
+ * @param ttl - Time to live in seconds (optional)
20
+ */
21
+ set<T = unknown>(key: string, value: T, ttl?: number): Promise<void>;
22
+ /**
23
+ * Delete a key
24
+ * @param key - The key to delete
25
+ */
26
+ delete(key: string): Promise<void>;
27
+ /**
28
+ * Check if a key exists
29
+ * @param key - The key to check
30
+ */
31
+ has(key: string): Promise<boolean>;
32
+ /**
33
+ * Get multiple values by keys
34
+ * @param keys - Array of keys to retrieve
35
+ */
36
+ getMany?<T = unknown>(keys: string[]): Promise<(T | null)[]>;
37
+ /**
38
+ * Set multiple values
39
+ * @param entries - Array of [key, value, ttl?] tuples
40
+ */
41
+ setMany?<T = unknown>(entries: Array<[key: string, value: T, ttl?: number]>): Promise<void>;
42
+ /**
43
+ * Delete multiple keys
44
+ * @param keys - Array of keys to delete
45
+ */
46
+ deleteMany?(keys: string[]): Promise<void>;
47
+ /**
48
+ * Get all keys matching a pattern (optional)
49
+ * @param pattern - Glob pattern to match
50
+ */
51
+ keys?(pattern?: string): Promise<string[]>;
52
+ /**
53
+ * Clear all keys (optional, mainly for testing)
54
+ */
55
+ clear?(): Promise<void>;
56
+ /**
57
+ * Close the connection (for Redis, etc.)
58
+ */
59
+ close?(): Promise<void>;
60
+ }
61
+ /**
62
+ * Storage types
63
+ */
64
+ type StorageType = 'memory' | 'redis' | 'cloudflare-kv' | 'deno-kv' | 'custom';
65
+ /**
66
+ * Redis configuration
67
+ */
68
+ interface RedisConfig {
69
+ /** Redis connection URL (redis://...) */
70
+ url?: string;
71
+ /** Existing Redis client instance */
72
+ client?: unknown;
73
+ /** Key prefix for namespacing */
74
+ prefix?: string;
75
+ }
76
+ /**
77
+ * Cloudflare KV configuration
78
+ */
79
+ interface CloudflareKVConfig {
80
+ /** KV namespace binding */
81
+ binding: KVNamespace;
82
+ /** Key prefix for namespacing */
83
+ prefix?: string;
84
+ }
85
+ /**
86
+ * Deno KV configuration
87
+ */
88
+ interface DenoKVConfig {
89
+ /** Path to KV database (optional, uses default if not provided) */
90
+ path?: string;
91
+ /** Key prefix for namespacing */
92
+ prefix?: string;
93
+ }
94
+ /**
95
+ * Memory storage configuration
96
+ */
97
+ interface MemoryConfig {
98
+ /** Maximum number of entries (default: 10000) */
99
+ maxSize?: number;
100
+ /** Key prefix for namespacing */
101
+ prefix?: string;
102
+ }
103
+ /**
104
+ * Storage configuration
105
+ */
106
+ interface StorageConfig {
107
+ /** Storage type */
108
+ type?: StorageType;
109
+ /** Redis configuration */
110
+ redis?: RedisConfig;
111
+ /** Cloudflare KV configuration */
112
+ cloudflareKv?: CloudflareKVConfig;
113
+ /** Deno KV configuration */
114
+ denoKv?: DenoKVConfig;
115
+ /** Memory configuration */
116
+ memory?: MemoryConfig;
117
+ /** Custom storage adapter */
118
+ custom?: KVStorage;
119
+ }
120
+ /**
121
+ * Cloudflare KV Namespace type (for type safety)
122
+ */
123
+ interface KVNamespace {
124
+ get(key: string, options?: {
125
+ type?: 'text' | 'json' | 'arrayBuffer' | 'stream';
126
+ }): Promise<string | null>;
127
+ get(key: string, options: {
128
+ type: 'json';
129
+ }): Promise<unknown | null>;
130
+ put(key: string, value: string | ArrayBuffer | ReadableStream, options?: {
131
+ expirationTtl?: number;
132
+ expiration?: number;
133
+ metadata?: unknown;
134
+ }): Promise<void>;
135
+ delete(key: string): Promise<void>;
136
+ list(options?: {
137
+ prefix?: string;
138
+ limit?: number;
139
+ cursor?: string;
140
+ }): Promise<{
141
+ keys: Array<{
142
+ name: string;
143
+ expiration?: number;
144
+ metadata?: unknown;
145
+ }>;
146
+ list_complete: boolean;
147
+ cursor?: string;
148
+ }>;
149
+ }
150
+ /**
151
+ * Deno KV types (for type safety)
152
+ */
153
+ interface DenoKv {
154
+ get<T = unknown>(key: Deno.KvKey): Promise<Deno.KvEntryMaybe<T>>;
155
+ set(key: Deno.KvKey, value: unknown, options?: {
156
+ expireIn?: number;
157
+ }): Promise<Deno.KvCommitResult>;
158
+ delete(key: Deno.KvKey): Promise<void>;
159
+ list<T = unknown>(selector: Deno.KvListSelector, options?: Deno.KvListOptions): Deno.KvListIterator<T>;
160
+ close(): void;
161
+ }
162
+ declare namespace Deno {
163
+ type KvKey = readonly unknown[];
164
+ interface KvEntryMaybe<T> {
165
+ key: KvKey;
166
+ value: T | null;
167
+ versionstamp: string | null;
168
+ }
169
+ interface KvCommitResult {
170
+ ok: true;
171
+ versionstamp: string;
172
+ }
173
+ interface KvListSelector {
174
+ prefix?: KvKey;
175
+ start?: KvKey;
176
+ end?: KvKey;
177
+ }
178
+ interface KvListOptions {
179
+ limit?: number;
180
+ cursor?: string;
181
+ reverse?: boolean;
182
+ consistency?: 'strong' | 'eventual';
183
+ }
184
+ interface KvListIterator<T> extends AsyncIterableIterator<KvEntry<T>> {
185
+ }
186
+ interface KvEntry<T> {
187
+ key: KvKey;
188
+ value: T;
189
+ versionstamp: string;
190
+ }
191
+ }
192
+
193
+ export type { CloudflareKVConfig as C, DenoKVConfig as D, KVStorage as K, MemoryConfig as M, RedisConfig as R, StorageConfig as S, StorageType as a, KVNamespace as b, DenoKv as c };
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@parsrun/auth",
3
+ "version": "0.1.0",
4
+ "description": "Passwordless-first, multi-runtime authentication for Pars framework",
5
+ "keywords": [
6
+ "pars",
7
+ "auth",
8
+ "authentication",
9
+ "passwordless",
10
+ "otp",
11
+ "multi-tenant",
12
+ "multi-runtime",
13
+ "edge",
14
+ "cloudflare-workers",
15
+ "deno"
16
+ ],
17
+ "homepage": "https://pars.run",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/parsrun/pars",
21
+ "directory": "packages/auth"
22
+ },
23
+ "license": "MIT",
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./storage": {
31
+ "types": "./dist/storage/index.d.ts",
32
+ "import": "./dist/storage/index.js"
33
+ },
34
+ "./session": {
35
+ "types": "./dist/session/index.d.ts",
36
+ "import": "./dist/session/index.js"
37
+ },
38
+ "./security": {
39
+ "types": "./dist/security/index.d.ts",
40
+ "import": "./dist/security/index.js"
41
+ },
42
+ "./providers": {
43
+ "types": "./dist/providers/index.d.ts",
44
+ "import": "./dist/providers/index.js"
45
+ },
46
+ "./providers/otp": {
47
+ "types": "./dist/providers/otp/index.d.ts",
48
+ "import": "./dist/providers/otp/index.js"
49
+ },
50
+ "./adapters": {
51
+ "types": "./dist/adapters/index.d.ts",
52
+ "import": "./dist/adapters/index.js"
53
+ },
54
+ "./adapters/hono": {
55
+ "types": "./dist/adapters/hono.d.ts",
56
+ "import": "./dist/adapters/hono.js"
57
+ }
58
+ },
59
+ "main": "./dist/index.js",
60
+ "types": "./dist/index.d.ts",
61
+ "files": ["dist"],
62
+ "scripts": {
63
+ "build": "tsup",
64
+ "dev": "tsup --watch",
65
+ "test": "vitest run",
66
+ "test:watch": "vitest",
67
+ "typecheck": "tsc --noEmit",
68
+ "clean": "rm -rf dist node_modules"
69
+ },
70
+ "dependencies": {
71
+ "@parsrun/core": "workspace:*",
72
+ "@parsrun/types": "workspace:*",
73
+ "jose": "^5.9.6"
74
+ },
75
+ "devDependencies": {
76
+ "drizzle-orm": "^0.38.4",
77
+ "hono": "^4.6.14",
78
+ "tsup": "^8.3.5",
79
+ "typescript": "^5.7.2",
80
+ "vitest": "^2.1.8"
81
+ },
82
+ "peerDependencies": {
83
+ "hono": ">=4.0.0",
84
+ "ioredis": ">=5.0.0",
85
+ "@upstash/redis": ">=1.0.0",
86
+ "drizzle-orm": ">=0.30.0"
87
+ },
88
+ "peerDependenciesMeta": {
89
+ "hono": {
90
+ "optional": true
91
+ },
92
+ "ioredis": {
93
+ "optional": true
94
+ },
95
+ "@upstash/redis": {
96
+ "optional": true
97
+ },
98
+ "drizzle-orm": {
99
+ "optional": true
100
+ }
101
+ }
102
+ }