ras-stack 5.5.5 → 6.0.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 (190) hide show
  1. package/README.md +32 -34
  2. package/dist/cli.d.ts +0 -27
  3. package/dist/cli.js +4 -32
  4. package/dist/cli.js.map +1 -1
  5. package/package.json +12 -228
  6. package/config/vite.mjs +0 -3
  7. package/dist/auth/client.d.ts +0 -11
  8. package/dist/auth/client.js +0 -57
  9. package/dist/auth/client.js.map +0 -1
  10. package/dist/auth/index.d.ts +0 -9
  11. package/dist/auth/index.js +0 -6
  12. package/dist/auth/index.js.map +0 -1
  13. package/dist/auth/origins.d.ts +0 -13
  14. package/dist/auth/origins.js +0 -41
  15. package/dist/auth/origins.js.map +0 -1
  16. package/dist/auth/providers.d.ts +0 -11
  17. package/dist/auth/providers.js +0 -26
  18. package/dist/auth/providers.js.map +0 -1
  19. package/dist/auth/random.d.ts +0 -2
  20. package/dist/auth/random.js +0 -10
  21. package/dist/auth/random.js.map +0 -1
  22. package/dist/auth/react.d.ts +0 -18
  23. package/dist/auth/react.js +0 -34
  24. package/dist/auth/react.js.map +0 -1
  25. package/dist/auth/secret.d.ts +0 -8
  26. package/dist/auth/secret.js +0 -44
  27. package/dist/auth/secret.js.map +0 -1
  28. package/dist/auth/settings.d.ts +0 -54
  29. package/dist/auth/settings.js +0 -37
  30. package/dist/auth/settings.js.map +0 -1
  31. package/dist/build/cli.d.ts +0 -1
  32. package/dist/build/cli.js +0 -24
  33. package/dist/build/cli.js.map +0 -1
  34. package/dist/build/index.d.ts +0 -17
  35. package/dist/build/index.js +0 -93
  36. package/dist/build/index.js.map +0 -1
  37. package/dist/changesets/cli.d.ts +0 -1
  38. package/dist/changesets/cli.js +0 -14
  39. package/dist/changesets/cli.js.map +0 -1
  40. package/dist/changesets/index.d.ts +0 -1
  41. package/dist/changesets/index.js +0 -38
  42. package/dist/changesets/index.js.map +0 -1
  43. package/dist/config.d.ts +0 -3
  44. package/dist/config.js +0 -3
  45. package/dist/config.js.map +0 -1
  46. package/dist/conformance/index.d.ts +0 -9
  47. package/dist/conformance/index.js +0 -92
  48. package/dist/conformance/index.js.map +0 -1
  49. package/dist/database/index.d.ts +0 -19
  50. package/dist/database/index.js +0 -21
  51. package/dist/database/index.js.map +0 -1
  52. package/dist/database/libsql.d.ts +0 -14
  53. package/dist/database/libsql.js +0 -31
  54. package/dist/database/libsql.js.map +0 -1
  55. package/dist/database/postgres.d.ts +0 -13
  56. package/dist/database/postgres.js +0 -16
  57. package/dist/database/postgres.js.map +0 -1
  58. package/dist/database/pragmas.d.ts +0 -7
  59. package/dist/database/pragmas.js +0 -12
  60. package/dist/database/pragmas.js.map +0 -1
  61. package/dist/database/sqlite.d.ts +0 -20
  62. package/dist/database/sqlite.js +0 -45
  63. package/dist/database/sqlite.js.map +0 -1
  64. package/dist/email/index.d.ts +0 -63
  65. package/dist/email/index.js +0 -95
  66. package/dist/email/index.js.map +0 -1
  67. package/dist/managed/catalog.d.ts +0 -40
  68. package/dist/managed/catalog.js +0 -114
  69. package/dist/managed/catalog.js.map +0 -1
  70. package/dist/managed/cli.d.ts +0 -1
  71. package/dist/managed/cli.js +0 -54
  72. package/dist/managed/cli.js.map +0 -1
  73. package/dist/managed/environment.d.ts +0 -5
  74. package/dist/managed/environment.js +0 -52
  75. package/dist/managed/environment.js.map +0 -1
  76. package/dist/managed/files.d.ts +0 -4
  77. package/dist/managed/files.js +0 -30
  78. package/dist/managed/files.js.map +0 -1
  79. package/dist/managed/install.d.ts +0 -4
  80. package/dist/managed/install.js +0 -62
  81. package/dist/managed/install.js.map +0 -1
  82. package/dist/managed/model.d.ts +0 -24
  83. package/dist/managed/model.js +0 -30
  84. package/dist/managed/model.js.map +0 -1
  85. package/dist/managed/plan.d.ts +0 -13
  86. package/dist/managed/plan.js +0 -99
  87. package/dist/managed/plan.js.map +0 -1
  88. package/dist/managed/pnpm.d.ts +0 -23
  89. package/dist/managed/pnpm.js +0 -2808
  90. package/dist/managed/pnpm.js.map +0 -7
  91. package/dist/managed/process.d.ts +0 -4
  92. package/dist/managed/process.js +0 -23
  93. package/dist/managed/process.js.map +0 -1
  94. package/dist/managed/sync.d.ts +0 -6
  95. package/dist/managed/sync.js +0 -96
  96. package/dist/managed/sync.js.map +0 -1
  97. package/dist/managed/tools.d.ts +0 -1
  98. package/dist/managed/tools.js +0 -7
  99. package/dist/managed/tools.js.map +0 -1
  100. package/dist/posthog/config.d.ts +0 -19
  101. package/dist/posthog/config.js +0 -51
  102. package/dist/posthog/config.js.map +0 -1
  103. package/dist/posthog/index.d.ts +0 -4
  104. package/dist/posthog/index.js +0 -3
  105. package/dist/posthog/index.js.map +0 -1
  106. package/dist/posthog/proxy.d.ts +0 -30
  107. package/dist/posthog/proxy.js +0 -51
  108. package/dist/posthog/proxy.js.map +0 -1
  109. package/dist/posthog/react.d.ts +0 -39
  110. package/dist/posthog/react.js +0 -81
  111. package/dist/posthog/react.js.map +0 -1
  112. package/dist/posthog/request.d.ts +0 -12
  113. package/dist/posthog/request.js +0 -22
  114. package/dist/posthog/request.js.map +0 -1
  115. package/dist/posthog/server.d.ts +0 -67
  116. package/dist/posthog/server.js +0 -388
  117. package/dist/posthog/server.js.map +0 -1
  118. package/dist/query/index.d.ts +0 -8
  119. package/dist/query/index.js +0 -17
  120. package/dist/query/index.js.map +0 -1
  121. package/dist/realtime/client.d.ts +0 -19
  122. package/dist/realtime/client.js +0 -37
  123. package/dist/realtime/client.js.map +0 -1
  124. package/dist/realtime/environment.d.ts +0 -10
  125. package/dist/realtime/environment.js +0 -28
  126. package/dist/realtime/environment.js.map +0 -1
  127. package/dist/realtime/index.d.ts +0 -6
  128. package/dist/realtime/index.js +0 -4
  129. package/dist/realtime/index.js.map +0 -1
  130. package/dist/realtime/publisher.d.ts +0 -37
  131. package/dist/realtime/publisher.js +0 -195
  132. package/dist/realtime/publisher.js.map +0 -1
  133. package/dist/realtime/react.d.ts +0 -13
  134. package/dist/realtime/react.js +0 -78
  135. package/dist/realtime/react.js.map +0 -1
  136. package/dist/realtime/tokens.d.ts +0 -6
  137. package/dist/realtime/tokens.js +0 -13
  138. package/dist/realtime/tokens.js.map +0 -1
  139. package/dist/runtime/dev.d.ts +0 -21
  140. package/dist/runtime/dev.js +0 -138
  141. package/dist/runtime/dev.js.map +0 -1
  142. package/dist/runtime/index.d.ts +0 -2
  143. package/dist/runtime/index.js +0 -2
  144. package/dist/runtime/index.js.map +0 -1
  145. package/dist/runtime/stack.d.ts +0 -65
  146. package/dist/runtime/stack.js +0 -226
  147. package/dist/runtime/stack.js.map +0 -1
  148. package/dist/server/canonical-host.d.ts +0 -6
  149. package/dist/server/canonical-host.js +0 -23
  150. package/dist/server/canonical-host.js.map +0 -1
  151. package/dist/server/errors.d.ts +0 -1
  152. package/dist/server/errors.js +0 -20
  153. package/dist/server/errors.js.map +0 -1
  154. package/dist/server/health.d.ts +0 -10
  155. package/dist/server/health.js +0 -12
  156. package/dist/server/health.js.map +0 -1
  157. package/dist/server/index.d.ts +0 -7
  158. package/dist/server/index.js +0 -5
  159. package/dist/server/index.js.map +0 -1
  160. package/dist/server/rpc.d.ts +0 -19
  161. package/dist/server/rpc.js +0 -52
  162. package/dist/server/rpc.js.map +0 -1
  163. package/dist/server/server-function.d.ts +0 -8
  164. package/dist/server/server-function.js +0 -18
  165. package/dist/server/server-function.js.map +0 -1
  166. package/dist/server/singleton.d.ts +0 -4
  167. package/dist/server/singleton.js +0 -48
  168. package/dist/server/singleton.js.map +0 -1
  169. package/dist/spacetime/index.d.ts +0 -36
  170. package/dist/spacetime/index.js +0 -103
  171. package/dist/spacetime/index.js.map +0 -1
  172. package/dist/tanstack/client.d.ts +0 -11
  173. package/dist/tanstack/client.js +0 -33
  174. package/dist/tanstack/client.js.map +0 -1
  175. package/dist/tanstack/middleware.d.ts +0 -9
  176. package/dist/tanstack/middleware.js +0 -32
  177. package/dist/tanstack/middleware.js.map +0 -1
  178. package/dist/tanstack/server.d.ts +0 -10
  179. package/dist/tanstack/server.js +0 -14
  180. package/dist/tanstack/server.js.map +0 -1
  181. package/dist/uploads/index.d.ts +0 -29
  182. package/dist/uploads/index.js +0 -83
  183. package/dist/uploads/index.js.map +0 -1
  184. package/dist/vite/config.d.ts +0 -18
  185. package/dist/vite/config.js +0 -88
  186. package/dist/vite/config.js.map +0 -1
  187. package/dist/vite/index.d.ts +0 -2
  188. package/dist/vite/index.js +0 -2
  189. package/dist/vite/index.js.map +0 -1
  190. package/pnpmfile.mjs +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"origins.js","sourceRoot":"","sources":["../../src/auth/origins.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,WAAW,CAAC,KAAyB;IACnD,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE;QAAE,OAAO,SAAS,CAAA;IACpC,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAA;IAClH,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAA;IAChF,OAAO,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,QAAQ,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,S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,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK,aAAa,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;AACnH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,OAAO,GAAkB,EAAE;IAC7E,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;QAAE,MAAM,IAAI,QAAQ,CAAC,gCAAgC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;AACtH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAO,GAAkB,EAAE;IACxD,OAAO,CAAC,OAAiB,EAAE,EAAE,CAC3B,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/G,CAAC","sourcesContent":["export type OriginOptions = {\n configured?: readonly (string | undefined)[]\n allowReferer?: boolean\n trustForwardedHeaders?: boolean\n}\n\nexport function parseOrigin(value: string | undefined) {\n if (!value?.trim()) return undefined\n try {\n return new URL(value).origin\n } catch {\n return undefined\n }\n}\n\nexport function forwardedOrigin(request: Request) {\n const host = request.headers.get('x-forwarded-host')?.split(',')[0]?.trim() || request.headers.get('host')?.trim()\n const protocol = request.headers.get('x-forwarded-proto')?.split(',')[0]?.trim()\n return host && (protocol === 'http' || protocol === 'https') ? parseOrigin(`${protocol}://${host}`) : undefined\n}\n\nexport function acceptedOrigins(request: Request, options: OriginOptions = {}) {\n return [\n new URL(request.url).origin,\n ...(options.trustForwardedHeaders ? [forwardedOrigin(request)] : []),\n ...(options.configured ?? []).map(parseOrigin),\n ].filter((origin): origin is string => Boolean(origin))\n}\n\n/** Where users reach the application, for absolute links: the first configured origin, then a trusted forwarded origin, then the request's. */\nexport function publicOrigin(request: Request, options: OriginOptions = {}) {\n return (\n options.configured?.map(parseOrigin).find(Boolean) ??\n (options.trustForwardedHeaders ? forwardedOrigin(request) : undefined) ??\n new URL(request.url).origin\n )\n}\n\nexport function validSameOriginRequest(request: Request, options: OriginOptions = {}) {\n const origin =\n request.headers.get('origin') || (options.allowReferer ? parseOrigin(request.headers.get('referer') ?? undefined) : undefined)\n const site = request.headers.get('sec-fetch-site')\n return Boolean(origin && (!site || site === 'same-origin') && acceptedOrigins(request, options).includes(origin))\n}\n\nexport function requireSameOrigin(request: Request, options: OriginOptions = {}) {\n if (!validSameOriginRequest(request, options)) throw new Response('cross-origin mutation rejected', { status: 403 })\n}\n\nexport function trustedOrigins(options: OriginOptions = {}) {\n return (request?: Request) =>\n request ? acceptedOrigins(request, options).filter((origin) => origin !== new URL(request.url).origin) : []\n}\n"]}
@@ -1,11 +0,0 @@
1
- export type ProviderCredentials = {
2
- clientId: string;
3
- clientSecret: string;
4
- };
5
- export type ProviderEnvironmentOptions = {
6
- prefix?: string;
7
- rejectPartial?: boolean;
8
- };
9
- export declare function configuredProviders<const Provider extends string>(providers: readonly Provider[], environment?: NodeJS.ProcessEnv, options?: ProviderEnvironmentOptions): Provider[];
10
- export declare function providerCredentials(provider: string, environment?: NodeJS.ProcessEnv, options?: ProviderEnvironmentOptions): ProviderCredentials | undefined;
11
- export declare function configuredProviderOptions<const Provider extends string>(providers: readonly Provider[], environment?: NodeJS.ProcessEnv, environmentOptions?: ProviderEnvironmentOptions): Partial<Record<Provider, ProviderCredentials>>;
@@ -1,26 +0,0 @@
1
- function providerEnvironmentKeys(provider, prefix = '') {
2
- const name = provider.toUpperCase().replaceAll('-', '_');
3
- return { clientId: `${prefix}${name}_CLIENT_ID`, clientSecret: `${prefix}${name}_CLIENT_SECRET` };
4
- }
5
- export function configuredProviders(providers, environment = process.env, options = {}) {
6
- return providers.filter((provider) => Boolean(providerCredentials(provider, environment, options)));
7
- }
8
- export function providerCredentials(provider, environment = process.env, options = {}) {
9
- const keys = providerEnvironmentKeys(provider, options.prefix);
10
- const clientId = environment[keys.clientId]?.trim();
11
- const clientSecret = environment[keys.clientSecret]?.trim();
12
- if (options.rejectPartial !== false && Boolean(clientId) !== Boolean(clientSecret)) {
13
- throw new Error(`${keys.clientId} and ${keys.clientSecret} must be configured together`);
14
- }
15
- return clientId && clientSecret ? { clientId, clientSecret } : undefined;
16
- }
17
- export function configuredProviderOptions(providers, environment = process.env, environmentOptions = {}) {
18
- const providerOptions = {};
19
- for (const provider of providers) {
20
- const credentials = providerCredentials(provider, environment, environmentOptions);
21
- if (credentials)
22
- providerOptions[provider] = credentials;
23
- }
24
- return providerOptions;
25
- }
26
- //# sourceMappingURL=providers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/auth/providers.ts"],"names":[],"mappings":"AAGA,SAAS,uBAAuB,CAAC,QAAgB,EAAE,MAAM,GAAG,EAAE;IAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACxD,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,GAAG,IAAI,YAAY,EAAE,YAAY,EAAE,GAAG,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAA;AACnG,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,SAA8B,EAC9B,WAAW,GAAsB,OAAO,CAAC,GAAG,EAC5C,OAAO,GAA+B,EAAE;IAExC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;AACrG,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,WAAW,GAAsB,OAAO,CAAC,GAAG,EAC5C,OAAO,GAA+B,EAAE;IAExC,MAAM,IAAI,GAAG,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9D,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAA;IACnD,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAA;IAC3D,IAAI,OAAO,CAAC,aAAa,KAAK,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACnF,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,QAAQ,IAAI,CAAC,YAAY,8BAA8B,CAAC,CAAA;IAC1F,CAAC;IACD,OAAO,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1E,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,SAA8B,EAC9B,WAAW,GAAsB,OAAO,CAAC,GAAG,EAC5C,kBAAkB,GAA+B,EAAE;IAEnD,MAAM,eAAe,GAAmD,EAAE,CAAA;IAC1E,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,WAAW,GAAG,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAA;QAClF,IAAI,WAAW;YAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAA;IAC1D,CAAC;IACD,OAAO,eAAe,CAAA;AACxB,CAAC","sourcesContent":["export type ProviderCredentials = { clientId: string; clientSecret: string }\nexport type ProviderEnvironmentOptions = { prefix?: string; rejectPartial?: boolean }\n\nfunction providerEnvironmentKeys(provider: string, prefix = '') {\n const name = provider.toUpperCase().replaceAll('-', '_')\n return { clientId: `${prefix}${name}_CLIENT_ID`, clientSecret: `${prefix}${name}_CLIENT_SECRET` }\n}\n\nexport function configuredProviders<const Provider extends string>(\n providers: readonly Provider[],\n environment: NodeJS.ProcessEnv = process.env,\n options: ProviderEnvironmentOptions = {},\n) {\n return providers.filter((provider) => Boolean(providerCredentials(provider, environment, options)))\n}\n\nexport function providerCredentials(\n provider: string,\n environment: NodeJS.ProcessEnv = process.env,\n options: ProviderEnvironmentOptions = {},\n): ProviderCredentials | undefined {\n const keys = providerEnvironmentKeys(provider, options.prefix)\n const clientId = environment[keys.clientId]?.trim()\n const clientSecret = environment[keys.clientSecret]?.trim()\n if (options.rejectPartial !== false && Boolean(clientId) !== Boolean(clientSecret)) {\n throw new Error(`${keys.clientId} and ${keys.clientSecret} must be configured together`)\n }\n return clientId && clientSecret ? { clientId, clientSecret } : undefined\n}\n\nexport function configuredProviderOptions<const Provider extends string>(\n providers: readonly Provider[],\n environment: NodeJS.ProcessEnv = process.env,\n environmentOptions: ProviderEnvironmentOptions = {},\n): Partial<Record<Provider, ProviderCredentials>> {\n const providerOptions: Partial<Record<Provider, ProviderCredentials>> = {}\n for (const provider of providers) {\n const credentials = providerCredentials(provider, environment, environmentOptions)\n if (credentials) providerOptions[provider] = credentials\n }\n return providerOptions\n}\n"]}
@@ -1,2 +0,0 @@
1
- export declare function randomToken(bytes?: number): string;
2
- export declare function randomId(bytes?: number): string;
@@ -1,10 +0,0 @@
1
- import crypto from 'node:crypto';
2
- export function randomToken(bytes = 16) {
3
- if (!Number.isSafeInteger(bytes) || bytes < 1)
4
- throw new RangeError('Token bytes must be a positive integer');
5
- return crypto.randomBytes(bytes).toString('base64url');
6
- }
7
- export function randomId(bytes = 8) {
8
- return randomToken(bytes);
9
- }
10
- //# sourceMappingURL=random.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/auth/random.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,MAAM,UAAU,WAAW,CAAC,KAAK,GAAG,EAAE;IACpC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC,CAAA;IAC7G,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACxD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAK,GAAG,CAAC;IAChC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC","sourcesContent":["import crypto from 'node:crypto'\n\nexport function randomToken(bytes = 16) {\n if (!Number.isSafeInteger(bytes) || bytes < 1) throw new RangeError('Token bytes must be a positive integer')\n return crypto.randomBytes(bytes).toString('base64url')\n}\n\nexport function randomId(bytes = 8) {\n return randomToken(bytes)\n}\n"]}
@@ -1,18 +0,0 @@
1
- export type AuthActionResult<T, TFailure = unknown> = {
2
- data?: T;
3
- error?: TFailure | null;
4
- };
5
- export type AuthActionState = {
6
- busy: boolean;
7
- error?: string;
8
- };
9
- export declare function useAuthAction(options?: {
10
- failureMessage?: (failure: unknown) => string;
11
- }): {
12
- busy: boolean;
13
- error?: string;
14
- clearError: () => void;
15
- run: <T, TFailure>(work: () => Promise<AuthActionResult<T, TFailure>>) => Promise<AuthActionResult<T, TFailure> | {
16
- error: unknown;
17
- }>;
18
- };
@@ -1,34 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react';
2
- import { authFailureMessage } from './client.js';
3
- const defaultFailureMessage = (failure) => authFailureMessage(failure, 'That did not work. Try again.');
4
- export function useAuthAction(options = {}) {
5
- const failureMessage = options.failureMessage ?? defaultFailureMessage;
6
- const [state, setState] = useState({ busy: false });
7
- const active = useRef(true);
8
- const invocation = useRef(0);
9
- useEffect(() => {
10
- active.current = true;
11
- return () => {
12
- active.current = false;
13
- };
14
- }, []);
15
- const clearError = useCallback(() => setState((current) => ({ busy: current.busy })), []);
16
- const run = useCallback(async (work) => {
17
- const current = ++invocation.current;
18
- setState({ busy: true });
19
- try {
20
- const result = await work();
21
- if (active.current && current === invocation.current) {
22
- setState(result.error ? { busy: false, error: failureMessage(result.error) } : { busy: false });
23
- }
24
- return result;
25
- }
26
- catch (error) {
27
- if (active.current && current === invocation.current)
28
- setState({ busy: false, error: failureMessage(error) });
29
- return { error };
30
- }
31
- }, [failureMessage]);
32
- return { ...state, clearError, run };
33
- }
34
- //# sourceMappingURL=react.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/auth/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAKhD,MAAM,qBAAqB,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,+BAA+B,CAAC,CAAA;AAEhH,MAAM,UAAU,aAAa,CAAC,OAAO,GAAsD,EAAE;IAC3F,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,qBAAqB,CAAA;IACtE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAkB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACpE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;QACrB,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA;QACxB,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACzF,MAAM,GAAG,GAAG,WAAW,CACrB,KAAK,EAAe,IAAkD,EAAE,EAAE;QACxE,MAAM,OAAO,GAAG,EAAE,UAAU,CAAC,OAAO,CAAA;QACpC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QACxB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAA;YAC3B,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;gBACrD,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;YACjG,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,MAAM,CAAC,OAAO,IAAI,OAAO,KAAK,UAAU,CAAC,OAAO;gBAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YAC7G,OAAO,EAAE,KAAK,EAAoC,CAAA;QACpD,CAAC;IACH,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAA;IACD,OAAO,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,CAAA;AACtC,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\nimport { authFailureMessage } from './client.js'\n\nexport type AuthActionResult<T, TFailure = unknown> = { data?: T; error?: TFailure | null }\nexport type AuthActionState = { busy: boolean; error?: string }\n\nconst defaultFailureMessage = (failure: unknown) => authFailureMessage(failure, 'That did not work. Try again.')\n\nexport function useAuthAction(options: { failureMessage?: (failure: unknown) => string } = {}) {\n const failureMessage = options.failureMessage ?? defaultFailureMessage\n const [state, setState] = useState<AuthActionState>({ busy: false })\n const active = useRef(true)\n const invocation = useRef(0)\n useEffect(() => {\n active.current = true\n return () => {\n active.current = false\n }\n }, [])\n const clearError = useCallback(() => setState((current) => ({ busy: current.busy })), [])\n const run = useCallback(\n async <T, TFailure>(work: () => Promise<AuthActionResult<T, TFailure>>) => {\n const current = ++invocation.current\n setState({ busy: true })\n try {\n const result = await work()\n if (active.current && current === invocation.current) {\n setState(result.error ? { busy: false, error: failureMessage(result.error) } : { busy: false })\n }\n return result\n } catch (error) {\n if (active.current && current === invocation.current) setState({ busy: false, error: failureMessage(error) })\n return { error } satisfies AuthActionResult<never>\n }\n },\n [failureMessage],\n )\n return { ...state, clearError, run }\n}\n"]}
@@ -1,8 +0,0 @@
1
- export type PersistedSecretOptions = {
2
- directory: string;
3
- environment?: NodeJS.ProcessEnv;
4
- environmentKey?: string;
5
- filename?: string;
6
- bytes?: number;
7
- };
8
- export declare function persistedSecret(options: PersistedSecretOptions): string;
@@ -1,44 +0,0 @@
1
- import crypto from 'node:crypto';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import { errorHasCode } from '../server/errors.js';
5
- import { randomToken } from './random.js';
6
- export function persistedSecret(options) {
7
- const environment = options.environment ?? process.env;
8
- const configured = environment[options.environmentKey ?? 'AUTH_SECRET']?.trim();
9
- if (configured)
10
- return configured;
11
- const file = path.join(options.directory, options.filename ?? 'auth.secret');
12
- try {
13
- return readSecret(file);
14
- }
15
- catch (error) {
16
- if (!errorHasCode(error, 'ENOENT'))
17
- throw error;
18
- }
19
- fs.mkdirSync(options.directory, { recursive: true });
20
- const secret = randomToken(options.bytes ?? 32);
21
- const temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
22
- try {
23
- fs.writeFileSync(temporary, secret, { mode: 0o600, flag: 'wx' });
24
- try {
25
- fs.linkSync(temporary, file);
26
- return secret;
27
- }
28
- catch (error) {
29
- if (!errorHasCode(error, 'EEXIST'))
30
- throw error;
31
- return readSecret(file);
32
- }
33
- }
34
- finally {
35
- fs.rmSync(temporary, { force: true });
36
- }
37
- }
38
- function readSecret(file) {
39
- const secret = fs.readFileSync(file, 'utf8').trim();
40
- if (!secret)
41
- throw new Error(`Secret file is empty: ${file}`);
42
- return secret;
43
- }
44
- //# sourceMappingURL=secret.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"secret.js","sourceRoot":"","sources":["../../src/auth/secret.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAUzC,MAAM,UAAU,eAAe,CAAC,OAA+B;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAA;IACtD,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,CAAA;IAC/E,IAAI,UAAU;QAAE,OAAO,UAAU,CAAA;IAEjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAA;IAC5E,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC;YAAE,MAAM,KAAK,CAAA;IACjD,CAAC;IAED,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAC/C,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,MAAM,CAAA;IACrE,IAAI,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAChE,IAAI,CAAC;YACH,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;YAC5B,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC;gBAAE,MAAM,KAAK,CAAA;YAC/C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACvC,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IACnD,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAA;IAC7D,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import crypto from 'node:crypto'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { errorHasCode } from '../server/errors.js'\nimport { randomToken } from './random.js'\n\nexport type PersistedSecretOptions = {\n directory: string\n environment?: NodeJS.ProcessEnv\n environmentKey?: string\n filename?: string\n bytes?: number\n}\n\nexport function persistedSecret(options: PersistedSecretOptions) {\n const environment = options.environment ?? process.env\n const configured = environment[options.environmentKey ?? 'AUTH_SECRET']?.trim()\n if (configured) return configured\n\n const file = path.join(options.directory, options.filename ?? 'auth.secret')\n try {\n return readSecret(file)\n } catch (error) {\n if (!errorHasCode(error, 'ENOENT')) throw error\n }\n\n fs.mkdirSync(options.directory, { recursive: true })\n const secret = randomToken(options.bytes ?? 32)\n const temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`\n try {\n fs.writeFileSync(temporary, secret, { mode: 0o600, flag: 'wx' })\n try {\n fs.linkSync(temporary, file)\n return secret\n } catch (error) {\n if (!errorHasCode(error, 'EEXIST')) throw error\n return readSecret(file)\n }\n } finally {\n fs.rmSync(temporary, { force: true })\n }\n}\n\nfunction readSecret(file: string) {\n const secret = fs.readFileSync(file, 'utf8').trim()\n if (!secret) throw new Error(`Secret file is empty: ${file}`)\n return secret\n}\n"]}
@@ -1,54 +0,0 @@
1
- export type RateLimitRule = {
2
- window: number;
3
- max: number;
4
- };
5
- export type SessionOptions = {
6
- expiresIn?: number | undefined;
7
- updateAge?: number | undefined;
8
- };
9
- export type StandardAccountOptions = {
10
- encryptOAuthTokens?: boolean;
11
- };
12
- export type StandardEmailAndPasswordOptions = {
13
- enabled?: boolean;
14
- revokeSessionsOnPasswordReset?: boolean;
15
- };
16
- export declare function standardSessionOptions<const Options extends object>(overrides?: Options & SessionOptions): Options & {
17
- expiresIn: number;
18
- updateAge: number;
19
- };
20
- export declare function standardAccountOptions<Options extends object>(overrides?: Options & StandardAccountOptions): Options & {
21
- encryptOAuthTokens: boolean;
22
- };
23
- export declare function standardEmailAndPasswordOptions<Options extends object>(overrides?: Options & StandardEmailAndPasswordOptions): Options & {
24
- enabled: boolean;
25
- revokeSessionsOnPasswordReset: boolean;
26
- };
27
- export declare function standardRateLimitOptions(customRules?: Record<string, RateLimitRule>): {
28
- enabled: boolean;
29
- storage: 'database';
30
- window: number;
31
- max: number;
32
- customRules: {
33
- '/sign-in/email': {
34
- window: number;
35
- max: number;
36
- };
37
- '/sign-up/email': {
38
- window: number;
39
- max: number;
40
- };
41
- '/request-password-reset': {
42
- window: number;
43
- max: number;
44
- };
45
- '/send-verification-email': {
46
- window: number;
47
- max: number;
48
- };
49
- '/admin/set-user-password': {
50
- window: number;
51
- max: number;
52
- };
53
- };
54
- };
@@ -1,37 +0,0 @@
1
- export function standardSessionOptions(overrides = {}) {
2
- return {
3
- ...overrides,
4
- expiresIn: overrides.expiresIn ?? 60 * 60 * 24 * 90,
5
- updateAge: overrides.updateAge ?? 60 * 60 * 24,
6
- };
7
- }
8
- export function standardAccountOptions(overrides = {}) {
9
- return {
10
- ...overrides,
11
- encryptOAuthTokens: overrides.encryptOAuthTokens ?? true,
12
- };
13
- }
14
- export function standardEmailAndPasswordOptions(overrides = {}) {
15
- return {
16
- ...overrides,
17
- enabled: overrides.enabled ?? true,
18
- revokeSessionsOnPasswordReset: overrides.revokeSessionsOnPasswordReset ?? true,
19
- };
20
- }
21
- export function standardRateLimitOptions(customRules = {}) {
22
- return {
23
- enabled: true,
24
- storage: 'database',
25
- window: 60,
26
- max: 120,
27
- customRules: {
28
- '/sign-in/email': { window: 60, max: 20 },
29
- '/sign-up/email': { window: 60, max: 15 },
30
- '/request-password-reset': { window: 60, max: 5 },
31
- '/send-verification-email': { window: 60, max: 5 },
32
- '/admin/set-user-password': { window: 60, max: 10 },
33
- ...customRules,
34
- },
35
- };
36
- }
37
- //# sourceMappingURL=settings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/auth/settings.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,sBAAsB,CAA+B,SAAS,GAA6B,EAA8B;IACvI,OAAO;QACL,GAAG,SAAS;QACZ,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;QACnD,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE;KAC/C,CAAA;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,SAAS,GAAqC,EAAsC;IAEpF,OAAO;QACL,GAAG,SAAS;QACZ,kBAAkB,EAAE,SAAS,CAAC,kBAAkB,IAAI,IAAI;KACzD,CAAA;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,SAAS,GAA8C,EAA+C;IAEtG,OAAO;QACL,GAAG,SAAS;QACZ,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,IAAI;QAClC,6BAA6B,EAAE,SAAS,CAAC,6BAA6B,IAAI,IAAI;KAC/E,CAAA;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,WAAW,GAAkC,EAAE;IACtF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,UAAmB;QAC5B,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,GAAG;QACR,WAAW,EAAE;YACX,gBAAgB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;YACzC,gBAAgB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;YACzC,yBAAyB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;YACjD,0BAA0B,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;YAClD,0BAA0B,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;YACnD,GAAG,WAAW;SACf;KACF,CAAA;AACH,CAAC","sourcesContent":["export type RateLimitRule = { window: number; max: number }\n\nexport type SessionOptions = { expiresIn?: number | undefined; updateAge?: number | undefined }\nexport type StandardAccountOptions = { encryptOAuthTokens?: boolean }\nexport type StandardEmailAndPasswordOptions = { enabled?: boolean; revokeSessionsOnPasswordReset?: boolean }\n\nexport function standardSessionOptions<const Options extends object>(overrides: Options & SessionOptions = {} as Options & SessionOptions) {\n return {\n ...overrides,\n expiresIn: overrides.expiresIn ?? 60 * 60 * 24 * 90,\n updateAge: overrides.updateAge ?? 60 * 60 * 24,\n }\n}\n\nexport function standardAccountOptions<Options extends object>(\n overrides: Options & StandardAccountOptions = {} as Options & StandardAccountOptions,\n) {\n return {\n ...overrides,\n encryptOAuthTokens: overrides.encryptOAuthTokens ?? true,\n }\n}\n\nexport function standardEmailAndPasswordOptions<Options extends object>(\n overrides: Options & StandardEmailAndPasswordOptions = {} as Options & StandardEmailAndPasswordOptions,\n) {\n return {\n ...overrides,\n enabled: overrides.enabled ?? true,\n revokeSessionsOnPasswordReset: overrides.revokeSessionsOnPasswordReset ?? true,\n }\n}\n\nexport function standardRateLimitOptions(customRules: Record<string, RateLimitRule> = {}) {\n return {\n enabled: true,\n storage: 'database' as const,\n window: 60,\n max: 120,\n customRules: {\n '/sign-in/email': { window: 60, max: 20 },\n '/sign-up/email': { window: 60, max: 15 },\n '/request-password-reset': { window: 60, max: 5 },\n '/send-verification-email': { window: 60, max: 5 },\n '/admin/set-user-password': { window: 60, max: 10 },\n ...customRules,\n },\n }\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function runAssetsCli(arguments_: string[]): Promise<void>;
package/dist/build/cli.js DELETED
@@ -1,24 +0,0 @@
1
- import { checkServerAssets, loadServerAssetsConfig, syncServerAssets } from './index.js';
2
- export async function runAssetsCli(arguments_) {
3
- const [command, configFile] = arguments_;
4
- if (command !== 'check' && command !== 'sync') {
5
- console.error('usage: ras assets <check|sync> [config-file]');
6
- process.exitCode = 2;
7
- return;
8
- }
9
- const root = process.cwd();
10
- const config = await loadServerAssetsConfig(root, configFile);
11
- if (command === 'sync') {
12
- await syncServerAssets(root, config);
13
- }
14
- else {
15
- const drift = await checkServerAssets(root, config);
16
- for (const destination of drift)
17
- console.error(`server asset drift: ${destination}`);
18
- if (drift.length > 0) {
19
- console.error('run ras assets sync after the production build');
20
- process.exitCode = 1;
21
- }
22
- }
23
- }
24
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/build/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAExF,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,UAAoB;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,UAAU,CAAA;IACxC,IAAI,OAAO,KAAK,OAAO,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9C,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAA;QAC7D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC1B,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAC7D,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,MAAM,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACtC,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACnD,KAAK,MAAM,WAAW,IAAI,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,uBAAuB,WAAW,EAAE,CAAC,CAAA;QACpF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;YAC/D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { checkServerAssets, loadServerAssetsConfig, syncServerAssets } from './index.js'\n\nexport async function runAssetsCli(arguments_: string[]): Promise<void> {\n const [command, configFile] = arguments_\n if (command !== 'check' && command !== 'sync') {\n console.error('usage: ras assets <check|sync> [config-file]')\n process.exitCode = 2\n return\n }\n\n const root = process.cwd()\n const config = await loadServerAssetsConfig(root, configFile)\n if (command === 'sync') {\n await syncServerAssets(root, config)\n } else {\n const drift = await checkServerAssets(root, config)\n for (const destination of drift) console.error(`server asset drift: ${destination}`)\n if (drift.length > 0) {\n console.error('run ras assets sync after the production build')\n process.exitCode = 1\n }\n }\n}\n"]}
@@ -1,17 +0,0 @@
1
- export type ServerAsset = {
2
- source: string;
3
- destination: string;
4
- };
5
- export type ServerAssetsConfig = {
6
- outputDirectory: string;
7
- assets: ServerAsset[];
8
- };
9
- export declare function loadServerAssetsConfig(root: string, configFile?: string): Promise<{
10
- outputDirectory: string;
11
- assets: {
12
- source: any;
13
- destination: any;
14
- }[];
15
- }>;
16
- export declare function syncServerAssets(root: string, config: ServerAssetsConfig): Promise<void>;
17
- export declare function checkServerAssets(root: string, config: ServerAssetsConfig): Promise<string[]>;
@@ -1,93 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { cp, lstat, mkdir, readFile, readdir, rm } from 'node:fs/promises';
3
- import path from 'node:path';
4
- export async function loadServerAssetsConfig(root, configFile = 'ras-stack.assets.json') {
5
- const source = JSON.parse(await readFile(path.resolve(root, configFile), 'utf8'));
6
- if (!source || typeof source !== 'object' || !('outputDirectory' in source) || !('assets' in source)) {
7
- throw new Error(`${configFile} must contain outputDirectory and assets`);
8
- }
9
- if (typeof source.outputDirectory !== 'string' || !Array.isArray(source.assets)) {
10
- throw new Error(`${configFile} must contain a string outputDirectory and an assets array`);
11
- }
12
- const assets = source.assets.map((asset, index) => {
13
- if (!asset ||
14
- typeof asset !== 'object' ||
15
- !('source' in asset) ||
16
- typeof asset.source !== 'string' ||
17
- !('destination' in asset) ||
18
- typeof asset.destination !== 'string') {
19
- throw new Error(`${configFile} assets[${index}] must contain string source and destination paths`);
20
- }
21
- return { source: asset.source, destination: asset.destination };
22
- });
23
- return { outputDirectory: source.outputDirectory, assets };
24
- }
25
- export async function syncServerAssets(root, config) {
26
- const paths = assetPaths(root, config);
27
- await Promise.all(paths.map(async (asset) => {
28
- await manifest(asset.source);
29
- await rm(asset.destination, { force: true, recursive: true });
30
- await mkdir(path.dirname(asset.destination), { recursive: true });
31
- await cp(asset.source, asset.destination, { recursive: true });
32
- }));
33
- }
34
- export async function checkServerAssets(root, config) {
35
- const compared = await Promise.all(assetPaths(root, config).map(async (asset) => {
36
- const [source, destination] = await Promise.all([manifest(asset.source), manifest(asset.destination).catch(() => undefined)]);
37
- return !destination || !equalManifest(source, destination) ? asset.label : undefined;
38
- }));
39
- return compared.filter((destination) => destination !== undefined);
40
- }
41
- function assetPaths(root, config) {
42
- const repository = path.resolve(root);
43
- const output = containedPath(repository, config.outputDirectory, 'outputDirectory');
44
- const assets = config.assets.map((asset, index) => ({
45
- source: containedPath(repository, asset.source, `assets[${index}].source`),
46
- destination: containedPath(output, asset.destination, `assets[${index}].destination`),
47
- label: asset.destination,
48
- }));
49
- for (const [index, asset] of assets.entries()) {
50
- for (const other of assets.slice(index + 1)) {
51
- if (contains(asset.destination, other.destination) || contains(other.destination, asset.destination)) {
52
- throw new Error(`asset destinations must not overlap: ${asset.label} and ${other.label}`);
53
- }
54
- }
55
- }
56
- return assets;
57
- }
58
- function contains(parent, child) {
59
- const relative = path.relative(parent, child);
60
- return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
61
- }
62
- function containedPath(parent, child, name) {
63
- if (!child.trim())
64
- throw new Error(`${name} must not be empty`);
65
- const resolved = path.resolve(parent, child);
66
- if (resolved === parent || !contains(parent, resolved))
67
- throw new Error(`${name} must stay inside ${parent}`);
68
- return resolved;
69
- }
70
- async function manifest(root) {
71
- const files = new Map();
72
- const visit = async (current) => {
73
- const info = await lstat(current);
74
- if (info.isSymbolicLink())
75
- throw new Error(`server assets must not contain symbolic links: ${current}`);
76
- if (info.isFile()) {
77
- files.set(path.relative(root, current) || '.', createHash('sha256')
78
- .update(await readFile(current))
79
- .digest('hex'));
80
- return;
81
- }
82
- if (!info.isDirectory())
83
- throw new Error(`server assets must contain only files and directories: ${current}`);
84
- const entries = await readdir(current);
85
- await Promise.all(entries.map((entry) => visit(path.join(current, entry))));
86
- };
87
- await visit(root);
88
- return files;
89
- }
90
- function equalManifest(left, right) {
91
- return left.size === right.size && [...left].every(([name, digest]) => right.get(name) === digest);
92
- }
93
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAA;AAK5B,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,IAAY,EAAE,UAAU,GAAG,uBAAuB;IAC7F,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAY,CAAA;IAC5F,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,iBAAiB,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,EAAE,CAAC;QACrG,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,0CAA0C,CAAC,CAAA;IAC1E,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,4DAA4D,CAAC,CAAA;IAC5F,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAChD,IACE,CAAC,KAAK;YACN,OAAO,KAAK,KA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G,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAA;AACpG,CAAC","sourcesContent":["import { createHash } from 'node:crypto'\nimport { cp, lstat, mkdir, readFile, readdir, rm } from 'node:fs/promises'\nimport path from 'node:path'\n\nexport type ServerAsset = { source: string; destination: string }\nexport type ServerAssetsConfig = { outputDirectory: string; assets: ServerAsset[] }\n\nexport async function loadServerAssetsConfig(root: string, configFile = 'ras-stack.assets.json') {\n const source = JSON.parse(await readFile(path.resolve(root, configFile), 'utf8')) as unknown\n if (!source || typeof source !== 'object' || !('outputDirectory' in source) || !('assets' in source)) {\n throw new Error(`${configFile} must contain outputDirectory and assets`)\n }\n if (typeof source.outputDirectory !== 'string' || !Array.isArray(source.assets)) {\n throw new Error(`${configFile} must contain a string outputDirectory and an assets array`)\n }\n const assets = source.assets.map((asset, index) => {\n if (\n !asset ||\n typeof asset !== 'object' ||\n !('source' in asset) ||\n typeof asset.source !== 'string' ||\n !('destination' in asset) ||\n typeof asset.destination !== 'string'\n ) {\n throw new Error(`${configFile} assets[${index}] must contain string source and destination paths`)\n }\n return { source: asset.source, destination: asset.destination }\n })\n return { outputDirectory: source.outputDirectory, assets } satisfies ServerAssetsConfig\n}\n\nexport async function syncServerAssets(root: string, config: ServerAssetsConfig) {\n const paths = assetPaths(root, config)\n await Promise.all(\n paths.map(async (asset) => {\n await manifest(asset.source)\n await rm(asset.destination, { force: true, recursive: true })\n await mkdir(path.dirname(asset.destination), { recursive: true })\n await cp(asset.source, asset.destination, { recursive: true })\n }),\n )\n}\n\nexport async function checkServerAssets(root: string, config: ServerAssetsConfig) {\n const compared = await Promise.all(\n assetPaths(root, config).map(async (asset) => {\n const [source, destination] = await Promise.all([manifest(asset.source), manifest(asset.destination).catch(() => undefined)])\n return !destination || !equalManifest(source, destination) ? asset.label : undefined\n }),\n )\n return compared.filter((destination) => destination !== undefined)\n}\n\nfunction assetPaths(root: string, config: ServerAssetsConfig) {\n const repository = path.resolve(root)\n const output = containedPath(repository, config.outputDirectory, 'outputDirectory')\n const assets = config.assets.map((asset, index) => ({\n source: containedPath(repository, asset.source, `assets[${index}].source`),\n destination: containedPath(output, asset.destination, `assets[${index}].destination`),\n label: asset.destination,\n }))\n for (const [index, asset] of assets.entries()) {\n for (const other of assets.slice(index + 1)) {\n if (contains(asset.destination, other.destination) || contains(other.destination, asset.destination)) {\n throw new Error(`asset destinations must not overlap: ${asset.label} and ${other.label}`)\n }\n }\n }\n return assets\n}\n\nfunction contains(parent: string, child: string) {\n const relative = path.relative(parent, child)\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative))\n}\n\nfunction containedPath(parent: string, child: string, name: string) {\n if (!child.trim()) throw new Error(`${name} must not be empty`)\n const resolved = path.resolve(parent, child)\n if (resolved === parent || !contains(parent, resolved)) throw new Error(`${name} must stay inside ${parent}`)\n return resolved\n}\n\nasync function manifest(root: string) {\n const files = new Map<string, string>()\n const visit = async (current: string) => {\n const info = await lstat(current)\n if (info.isSymbolicLink()) throw new Error(`server assets must not contain symbolic links: ${current}`)\n if (info.isFile()) {\n files.set(\n path.relative(root, current) || '.',\n createHash('sha256')\n .update(await readFile(current))\n .digest('hex'),\n )\n return\n }\n if (!info.isDirectory()) throw new Error(`server assets must contain only files and directories: ${current}`)\n const entries = await readdir(current)\n await Promise.all(entries.map((entry) => visit(path.join(current, entry))))\n }\n await visit(root)\n return files\n}\n\nfunction equalManifest(left: Map<string, string>, right: Map<string, string>) {\n return left.size === right.size && [...left].every(([name, digest]) => right.get(name) === digest)\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function runChangesetsCli(arguments_: string[]): Promise<void>;
@@ -1,14 +0,0 @@
1
- import { checkChangesets } from './index.js';
2
- export async function runChangesetsCli(arguments_) {
3
- if (arguments_.length !== 1 || arguments_[0] !== 'check') {
4
- console.error('usage: ras changesets check');
5
- process.exitCode = 2;
6
- return;
7
- }
8
- const errors = await checkChangesets(process.cwd());
9
- for (const message of errors)
10
- console.error(message);
11
- if (errors.length > 0)
12
- process.exitCode = 1;
13
- }
14
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/changesets/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAAoB;IACzD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;QACzD,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAC5C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IACnD,KAAK,MAAM,OAAO,IAAI,MAAM;QAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACpD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AAC7C,CAAC","sourcesContent":["import { checkChangesets } from './index.js'\n\nexport async function runChangesetsCli(arguments_: string[]): Promise<void> {\n if (arguments_.length !== 1 || arguments_[0] !== 'check') {\n console.error('usage: ras changesets check')\n process.exitCode = 2\n return\n }\n const errors = await checkChangesets(process.cwd())\n for (const message of errors) console.error(message)\n if (errors.length > 0) process.exitCode = 1\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function checkChangesets(root: string): Promise<string[]>;
@@ -1,38 +0,0 @@
1
- import { parseChangesetFile } from '@changesets/parse';
2
- import { getPackages } from '@manypkg/get-packages';
3
- import { readdir, readFile } from 'node:fs/promises';
4
- import { join } from 'node:path';
5
- import { errorHasCode } from '../server/errors.js';
6
- export async function checkChangesets(root) {
7
- const files = await readdir(join(root, '.changeset')).catch((error) => {
8
- if (errorHasCode(error, 'ENOENT'))
9
- return [];
10
- throw error;
11
- });
12
- const changesets = files.filter((file) => file.endsWith('.md') && file !== 'README.md').toSorted();
13
- if (changesets.length === 0)
14
- return [];
15
- const { packages } = await getPackages(root);
16
- const names = new Set(packages.map(({ packageJson }) => packageJson.name));
17
- const errors = [];
18
- for (const file of changesets) {
19
- const path = `.changeset/${file}`;
20
- // Read serially so a large changeset directory does not open every file at once.
21
- // oxlint-disable-next-line no-await-in-loop
22
- const contents = await readFile(join(root, path), 'utf8');
23
- let releases;
24
- try {
25
- releases = parseChangesetFile(contents).releases;
26
- }
27
- catch {
28
- errors.push(`${path}: missing or invalid frontmatter`);
29
- continue;
30
- }
31
- for (const { name } of releases) {
32
- if (!names.has(name))
33
- errors.push(`${path}: unknown package ${JSON.stringify(name)}`);
34
- }
35
- }
36
- return errors;
37
- }
38
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/changesets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC7E,IAAI,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC;YAAE,OAAO,EAAE,CAAA;QAC5C,MAAM,KAAK,CAAA;IACb,CAAC,CAAC,CAAA;IACF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAA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/get-packages'\nimport { readdir, readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { errorHasCode } from '../server/errors.js'\n\nexport async function checkChangesets(root: string): Promise<string[]> {\n const files = await readdir(join(root, '.changeset')).catch((error: unknown) => {\n if (errorHasCode(error, 'ENOENT')) return []\n throw error\n })\n const changesets = files.filter((file) => file.endsWith('.md') && file !== 'README.md').toSorted()\n if (changesets.length === 0) return []\n const { packages } = await getPackages(root)\n const names = new Set(packages.map(({ packageJson }) => packageJson.name))\n const errors: string[] = []\n for (const file of changesets) {\n const path = `.changeset/${file}`\n // Read serially so a large changeset directory does not open every file at once.\n // oxlint-disable-next-line no-await-in-loop\n const contents = await readFile(join(root, path), 'utf8')\n let releases\n try {\n releases = parseChangesetFile(contents).releases\n } catch {\n errors.push(`${path}: missing or invalid frontmatter`)\n continue\n }\n for (const { name } of releases) {\n if (!names.has(name)) errors.push(`${path}: unknown package ${JSON.stringify(name)}`)\n }\n }\n return errors\n}\n"]}
package/dist/config.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { defineConfig, defineIntegration } from './managed/model.js';
2
- export type { Integration, RasConfig } from './managed/model.js';
3
- export { betterAuth, email, libsql, nitro, oxfmt, oxlint, playwright, posthog, postgres, realtime, sqlite, tailwind, tanstackQuery, tanstackStart, typescript, uploads, vite, vitest, } from './managed/catalog.js';
package/dist/config.js DELETED
@@ -1,3 +0,0 @@
1
- export { defineConfig, defineIntegration } from './managed/model.js';
2
- export { betterAuth, email, libsql, nitro, oxfmt, oxlint, playwright, posthog, postgres, realtime, sqlite, tailwind, tanstackQuery, tanstackStart, typescript, uploads, vite, vitest, } from './managed/catalog.js';
3
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEpE,OAAO,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,EACN,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,aAAa,EACb,aAAa,EACb,UAAU,EACV,OAAO,EACP,IAAI,EACJ,MAAM,GACP,MAAM,sBAAsB,CAAA","sourcesContent":["export { defineConfig, defineIntegration } from './managed/model.js'\nexport type { Integration, RasConfig } from './managed/model.js'\nexport {\n betterAuth,\n email,\n libsql,\n nitro,\n oxfmt,\n oxlint,\n playwright,\n posthog,\n postgres,\n realtime,\n sqlite,\n tailwind,\n tanstackQuery,\n tanstackStart,\n typescript,\n uploads,\n vite,\n vitest,\n} from './managed/catalog.js'\n"]}
@@ -1,9 +0,0 @@
1
- import type { databaseTarget } from '../database/index.js';
2
- export type { DatabaseTarget } from '../database/index.js';
3
- export declare function assertMutationOriginConformance(guard: (request: Request) => void | Promise<void>, options?: {
4
- trustForwardedHeaders?: boolean;
5
- }): Promise<void>;
6
- export type SqlitePragmaReader = (name: 'journal_mode' | 'synchronous' | 'busy_timeout' | 'foreign_keys') => unknown;
7
- export declare function assertSqliteConformance(readPragma: SqlitePragmaReader): Promise<void>;
8
- export type DatabaseTargetResolver = typeof databaseTarget;
9
- export declare function assertDatabaseTargetConformance(resolve: DatabaseTargetResolver): void;