@gorth-io/structure 0.0.0-alpha.6 → 0.0.0-alpha.8

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 (115) hide show
  1. package/README.md +78 -7
  2. package/dist/cores/ably/spaces/index.cjs +1 -1
  3. package/dist/cores/ably/spaces/index.d.cts +1 -3
  4. package/dist/cores/ably/spaces/index.d.ts +1 -3
  5. package/dist/cores/ably/spaces/index.js +1 -1
  6. package/dist/modules/auth/server/bearer.cjs +1 -0
  7. package/dist/modules/auth/server/bearer.d.cts +25 -0
  8. package/dist/modules/auth/server/bearer.d.cts.map +1 -0
  9. package/dist/modules/auth/server/bearer.d.ts +25 -0
  10. package/dist/modules/auth/server/bearer.d.ts.map +1 -0
  11. package/dist/modules/auth/server/bearer.js +2 -0
  12. package/dist/modules/auth/server/bearer.js.map +1 -0
  13. package/dist/modules/auth/server/claims.cjs +1 -0
  14. package/dist/modules/auth/server/claims.d.cts +37 -0
  15. package/dist/modules/auth/server/claims.d.cts.map +1 -0
  16. package/dist/modules/auth/server/claims.d.ts +37 -0
  17. package/dist/modules/auth/server/claims.d.ts.map +1 -0
  18. package/dist/modules/auth/server/claims.js +2 -0
  19. package/dist/modules/auth/server/claims.js.map +1 -0
  20. package/dist/modules/auth/server/grant-guard.cjs +1 -1
  21. package/dist/modules/auth/server/grant-guard.d.cts.map +1 -1
  22. package/dist/modules/auth/server/grant-guard.d.ts.map +1 -1
  23. package/dist/modules/auth/server/grant-guard.js +1 -1
  24. package/dist/modules/auth/server/grant-guard.js.map +1 -1
  25. package/dist/modules/auth/server/index.cjs +1 -1
  26. package/dist/modules/auth/server/index.d.cts +7 -2
  27. package/dist/modules/auth/server/index.d.ts +7 -2
  28. package/dist/modules/auth/server/index.js +1 -1
  29. package/dist/modules/auth/server/machine.cjs +1 -0
  30. package/dist/modules/auth/server/machine.d.cts +28 -0
  31. package/dist/modules/auth/server/machine.d.cts.map +1 -0
  32. package/dist/modules/auth/server/machine.d.ts +28 -0
  33. package/dist/modules/auth/server/machine.d.ts.map +1 -0
  34. package/dist/modules/auth/server/machine.js +2 -0
  35. package/dist/modules/auth/server/machine.js.map +1 -0
  36. package/dist/modules/auth/server/proof.cjs +1 -1
  37. package/dist/modules/auth/server/proof.d.cts +17 -0
  38. package/dist/modules/auth/server/proof.d.cts.map +1 -1
  39. package/dist/modules/auth/server/proof.d.ts +17 -0
  40. package/dist/modules/auth/server/proof.d.ts.map +1 -1
  41. package/dist/modules/auth/server/proof.js +1 -1
  42. package/dist/modules/auth/server/proof.js.map +1 -1
  43. package/dist/modules/auth/server/provider.cjs +1 -0
  44. package/dist/modules/auth/server/provider.d.cts +9 -0
  45. package/dist/modules/auth/server/provider.d.cts.map +1 -0
  46. package/dist/modules/auth/server/provider.d.ts +9 -0
  47. package/dist/modules/auth/server/provider.d.ts.map +1 -0
  48. package/dist/modules/auth/server/provider.js +2 -0
  49. package/dist/modules/auth/server/provider.js.map +1 -0
  50. package/dist/modules/auth/server/user-info.cjs +1 -0
  51. package/dist/modules/auth/server/user-info.d.cts +19 -0
  52. package/dist/modules/auth/server/user-info.d.cts.map +1 -0
  53. package/dist/modules/auth/server/user-info.d.ts +19 -0
  54. package/dist/modules/auth/server/user-info.d.ts.map +1 -0
  55. package/dist/modules/auth/server/user-info.js +2 -0
  56. package/dist/modules/auth/server/user-info.js.map +1 -0
  57. package/dist/modules/database/index.cjs +1 -0
  58. package/dist/modules/database/index.d.cts +18 -0
  59. package/dist/modules/database/index.d.cts.map +1 -0
  60. package/dist/modules/database/index.d.ts +18 -0
  61. package/dist/modules/database/index.d.ts.map +1 -0
  62. package/dist/modules/database/index.js +2 -0
  63. package/dist/modules/database/index.js.map +1 -0
  64. package/dist/modules/database/postgres.cjs +1 -0
  65. package/dist/modules/database/postgres.d.cts +5 -0
  66. package/dist/modules/database/postgres.d.cts.map +1 -0
  67. package/dist/modules/database/postgres.d.ts +5 -0
  68. package/dist/modules/database/postgres.d.ts.map +1 -0
  69. package/dist/modules/database/postgres.js +2 -0
  70. package/dist/modules/database/postgres.js.map +1 -0
  71. package/dist/modules/desktop/index.cjs +1 -1
  72. package/dist/modules/desktop/index.d.cts +4 -2
  73. package/dist/modules/desktop/index.d.ts +4 -2
  74. package/dist/modules/desktop/index.js +1 -1
  75. package/dist/modules/desktop/proxy.cjs +1 -0
  76. package/dist/modules/desktop/proxy.d.cts +22 -0
  77. package/dist/modules/desktop/proxy.d.cts.map +1 -0
  78. package/dist/modules/desktop/proxy.d.ts +22 -0
  79. package/dist/modules/desktop/proxy.d.ts.map +1 -0
  80. package/dist/modules/desktop/proxy.js +2 -0
  81. package/dist/modules/desktop/proxy.js.map +1 -0
  82. package/dist/modules/desktop/release.cjs +1 -0
  83. package/dist/modules/desktop/release.d.cts +5 -0
  84. package/dist/modules/desktop/release.d.cts.map +1 -0
  85. package/dist/modules/desktop/release.d.ts +5 -0
  86. package/dist/modules/desktop/release.d.ts.map +1 -0
  87. package/dist/modules/desktop/release.js +2 -0
  88. package/dist/modules/desktop/release.js.map +1 -0
  89. package/dist/modules/desktop/rpc.cjs +1 -1
  90. package/dist/modules/desktop/rpc.d.cts +8 -1
  91. package/dist/modules/desktop/rpc.d.cts.map +1 -1
  92. package/dist/modules/desktop/rpc.d.ts +8 -1
  93. package/dist/modules/desktop/rpc.d.ts.map +1 -1
  94. package/dist/modules/desktop/rpc.js +1 -1
  95. package/dist/modules/desktop/rpc.js.map +1 -1
  96. package/dist/modules/http/failure.cjs +1 -0
  97. package/dist/modules/http/failure.d.cts +14 -0
  98. package/dist/modules/http/failure.d.cts.map +1 -0
  99. package/dist/modules/http/failure.d.ts +14 -0
  100. package/dist/modules/http/failure.d.ts.map +1 -0
  101. package/dist/modules/http/failure.js +2 -0
  102. package/dist/modules/http/failure.js.map +1 -0
  103. package/dist/modules/http/index.cjs +1 -1
  104. package/dist/modules/http/index.d.cts +2 -1
  105. package/dist/modules/http/index.d.ts +2 -1
  106. package/dist/modules/http/index.js +1 -1
  107. package/dist/utils/normalization.cjs +1 -0
  108. package/dist/utils/normalization.d.cts +10 -0
  109. package/dist/utils/normalization.d.cts.map +1 -0
  110. package/dist/utils/normalization.d.ts +10 -0
  111. package/dist/utils/normalization.d.ts.map +1 -0
  112. package/dist/utils/normalization.js +2 -0
  113. package/dist/utils/normalization.js.map +1 -0
  114. package/docs/modules.md +65 -1
  115. package/package.json +16 -7
@@ -0,0 +1,14 @@
1
+ export interface ServiceFailure {
2
+ status: number;
3
+ code: string;
4
+ headers?: HeadersInit;
5
+ details?: Record<string, unknown>;
6
+ }
7
+ /** Only public codes belong here; never pass provider messages or credentials. */
8
+ export declare class ServiceError extends Error {
9
+ readonly code: string;
10
+ readonly status: number;
11
+ constructor(code: string, status?: number);
12
+ }
13
+ export declare function serviceFailure(error: unknown): ServiceFailure | undefined;
14
+ //# sourceMappingURL=failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.d.ts","names":[],"sources":["../../../src/modules/http/failure.ts"],"mappings":"A,iBAEiB;EACf;EACA;EACA,UAAU;EACV,UAAU;;;qBAIC,qBAAqB;WAEd;WACA;EADA,YAAA,cACA;;wBAcJ,eAAe,iBAAiB"}
@@ -0,0 +1,2 @@
1
+ import{ZodError as e}from"zod";var t=class extends Error{code;status;constructor(e,t=500){if(!/^[a-z][a-z0-9_]{0,127}$/.test(e)||!Number.isInteger(t)||t<400||t>599)throw TypeError(`Invalid service error contract`);super(e),this.code=e,this.status=t,this.name=`ServiceError`}};function n(n){if(n instanceof t)return{status:n.status,code:n.code};if(n instanceof e)return{status:400,code:`validation_error`,details:{issues:n.issues.map(e=>({code:e.code,path:e.path}))}}}export{t as ServiceError,n as serviceFailure};
2
+ //# sourceMappingURL=failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.js","names":["ServiceError","code","status","serviceFailure","error","ZodError","issue"],"sources":["../../../src/modules/http/failure.ts"],"sourcesContent":["import { ZodError } from \"zod\";\n\nexport interface ServiceFailure {\n status: number;\n code: string;\n headers?: HeadersInit;\n details?: Record<string, unknown>;\n}\n\n/** Only public codes belong here; never pass provider messages or credentials. */\nexport class ServiceError extends Error {\n constructor(\n public readonly code: string,\n public readonly status = 500,\n ) {\n if (\n !/^[a-z][a-z0-9_]{0,127}$/.test(code) ||\n !Number.isInteger(status) ||\n status < 400 ||\n status > 599\n )\n throw new TypeError(\"Invalid service error contract\");\n super(code);\n this.name = \"ServiceError\";\n }\n}\n\nexport function serviceFailure(error: unknown): ServiceFailure | undefined {\n if (error instanceof ServiceError) return { status: error.status, code: error.code };\n if (error instanceof ZodError)\n return {\n status: 400,\n code: \"validation_error\",\n details: {\n // Do not return custom messages, inputs or schema internals by default.\n issues: error.issues.map((issue) => ({ code: issue.code, path: issue.path })),\n },\n };\n}\n"],"mappings":"A,+BAUA,IAAaA,EAAb,cAAkC,KAAM,CAEpB,KACA,OAFlB,YACE,EACA,EAAyB,IACzB,CACA,GACE,CAAC,0BAA0B,KAAKC,CAAI,GACpC,CAAC,OAAO,UAAUC,CAAM,GACxBA,EAAS,KACTA,EAAS,IAET,MAAU,UAAU,gCAAgC,EACtD,MAAMD,CAAI,EAVM,KAAA,KAAAA,EACA,KAAA,OAAAC,EAUhB,KAAK,KAAO,cACd,CACF,EAEA,SAAgBC,EAAe,EAA4C,CACzE,GAAIC,aAAiBJ,EAAc,MAAO,CAAE,OAAQI,EAAM,OAAQ,KAAMA,EAAM,IAAK,EACnF,GAAIA,aAAiBC,EACnB,MAAO,CACL,OAAQ,IACR,KAAM,mBACN,QAAS,CAEP,OAAQD,EAAM,OAAO,IAAK,IAAW,CAAE,KAAME,EAAM,KAAM,KAAMA,EAAM,IAAK,EAAE,CAC9E,CACF,CACJ,C"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./caller.cjs"),t=require("./error.cjs"),n=require("./fetcher.cjs"),r=require("./response.cjs");exports.CallerError=t.CallerError,exports.createCaller=e.createCaller,exports.createFetcher=n.createFetcher,exports.normalizeCallerError=t.normalizeCallerError,exports.toWebResponse=r.toWebResponse;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./caller.cjs"),t=require("./error.cjs"),n=require("./fetcher.cjs"),r=require("./response.cjs"),i=require("./failure.cjs");exports.CallerError=t.CallerError,exports.ServiceError=i.ServiceError,exports.createCaller=e.createCaller,exports.createFetcher=n.createFetcher,exports.normalizeCallerError=t.normalizeCallerError,exports.serviceFailure=i.serviceFailure,exports.toWebResponse=r.toWebResponse;
@@ -2,4 +2,5 @@ import { createCaller } from "./caller.cjs";
2
2
  import { E as FetcherOptions, G as CallerError, K as normalizeCallerError, W as WebResponseOptions, _ as CallerToastOptions, f as CallerErrorOptions, g as CallerResponseHandler, h as CallerRequestOptions, m as CallerOptions } from "../../interface-BR9QNgXO.cjs";
3
3
  import { createFetcher } from "./fetcher.cjs";
4
4
  import { toWebResponse } from "./response.cjs";
5
- export { CallerError, type CallerErrorOptions, type CallerOptions, type CallerRequestOptions, type CallerResponseHandler, type CallerToastOptions, type FetcherOptions, type WebResponseOptions, createCaller, createFetcher, normalizeCallerError, toWebResponse };
5
+ import { ServiceError, ServiceFailure, serviceFailure } from "./failure.cjs";
6
+ export { CallerError, type CallerErrorOptions, type CallerOptions, type CallerRequestOptions, type CallerResponseHandler, type CallerToastOptions, type FetcherOptions, ServiceError, type ServiceFailure, type WebResponseOptions, createCaller, createFetcher, normalizeCallerError, serviceFailure, toWebResponse };
@@ -2,4 +2,5 @@ import { createCaller } from "./caller.js";
2
2
  import { E as FetcherOptions, G as CallerError, K as normalizeCallerError, W as WebResponseOptions, _ as CallerToastOptions, f as CallerErrorOptions, g as CallerResponseHandler, h as CallerRequestOptions, m as CallerOptions } from "../../interface-ii8DV63k.js";
3
3
  import { createFetcher } from "./fetcher.js";
4
4
  import { toWebResponse } from "./response.js";
5
- export { CallerError, type CallerErrorOptions, type CallerOptions, type CallerRequestOptions, type CallerResponseHandler, type CallerToastOptions, type FetcherOptions, type WebResponseOptions, createCaller, createFetcher, normalizeCallerError, toWebResponse };
5
+ import { ServiceError, ServiceFailure, serviceFailure } from "./failure.js";
6
+ export { CallerError, type CallerErrorOptions, type CallerOptions, type CallerRequestOptions, type CallerResponseHandler, type CallerToastOptions, type FetcherOptions, ServiceError, type ServiceFailure, type WebResponseOptions, createCaller, createFetcher, normalizeCallerError, serviceFailure, toWebResponse };
@@ -1 +1 @@
1
- import{createCaller as e}from"./caller.js";import{CallerError as t,normalizeCallerError as n}from"./error.js";import{createFetcher as r}from"./fetcher.js";import{toWebResponse as i}from"./response.js";export{t as CallerError,e as createCaller,r as createFetcher,n as normalizeCallerError,i as toWebResponse};
1
+ import{createCaller as e}from"./caller.js";import{CallerError as t,normalizeCallerError as n}from"./error.js";import{createFetcher as r}from"./fetcher.js";import{toWebResponse as i}from"./response.js";import{ServiceError as a,serviceFailure as o}from"./failure.js";export{t as CallerError,a as ServiceError,e as createCaller,r as createFetcher,n as normalizeCallerError,o as serviceFailure,i as toWebResponse};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t={}){try{if(typeof e!=`string`||e!==e.trim())throw Error();let n=new URL(e);if(n.username||n.password||n.hash||!t.allowQuery&&n.search||t.originOnly&&n.pathname!==`/`||n.protocol!==`https:`&&!(t.allowLoopbackHttp&&n.protocol===`http:`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(n.hostname)))throw Error();return n}catch{throw TypeError(`Invalid HTTP endpoint`)}}function t(e){let t=typeof e==`string`&&/^\d+$/.test(e)?Number(e):e;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw TypeError(`Invalid byte count`);return t}function n(e){let t=e instanceof Date?e.getTime():typeof e==`string`?Date.parse(e):e;if(!Number.isSafeInteger(t)||t<0)throw TypeError(`Invalid timestamp`);return t}exports.parseByteCount=t,exports.parseEpochMilliseconds=n,exports.parseHttpEndpoint=e;
@@ -0,0 +1,10 @@
1
+ export interface HttpEndpointOptions {
2
+ allowLoopbackHttp?: boolean;
3
+ allowQuery?: boolean;
4
+ originOnly?: boolean;
5
+ }
6
+ /** Syntax/transport validation only; callers still own destination allowlists. */
7
+ export declare function parseHttpEndpoint(value: string, options?: HttpEndpointOptions): URL;
8
+ export declare function parseByteCount(value: unknown): number;
9
+ export declare function parseEpochMilliseconds(value: Date | string | number): number;
10
+ //# sourceMappingURL=normalization.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.d.cts","names":[],"sources":["../../src/utils/normalization.ts"],"mappings":"A,iBAAiB;EACf;EACA;EACA;;;wBAIc,kBACd,eACA,UAAS,sBACR;wBAwBa,eAAe;wBAQf,uBAAuB,OAAO"}
@@ -0,0 +1,10 @@
1
+ export interface HttpEndpointOptions {
2
+ allowLoopbackHttp?: boolean;
3
+ allowQuery?: boolean;
4
+ originOnly?: boolean;
5
+ }
6
+ /** Syntax/transport validation only; callers still own destination allowlists. */
7
+ export declare function parseHttpEndpoint(value: string, options?: HttpEndpointOptions): URL;
8
+ export declare function parseByteCount(value: unknown): number;
9
+ export declare function parseEpochMilliseconds(value: Date | string | number): number;
10
+ //# sourceMappingURL=normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.d.ts","names":[],"sources":["../../src/utils/normalization.ts"],"mappings":"A,iBAAiB;EACf;EACA;EACA;;;wBAIc,kBACd,eACA,UAAS,sBACR;wBAwBa,eAAe;wBAQf,uBAAuB,OAAO"}
@@ -0,0 +1,2 @@
1
+ function e(e,t={}){try{if(typeof e!=`string`||e!==e.trim())throw Error();let n=new URL(e);if(n.username||n.password||n.hash||!t.allowQuery&&n.search||t.originOnly&&n.pathname!==`/`||n.protocol!==`https:`&&!(t.allowLoopbackHttp&&n.protocol===`http:`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(n.hostname)))throw Error();return n}catch{throw TypeError(`Invalid HTTP endpoint`)}}function t(e){let t=typeof e==`string`&&/^\d+$/.test(e)?Number(e):e;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw TypeError(`Invalid byte count`);return t}function n(e){let t=e instanceof Date?e.getTime():typeof e==`string`?Date.parse(e):e;if(!Number.isSafeInteger(t)||t<0)throw TypeError(`Invalid timestamp`);return t}export{t as parseByteCount,n as parseEpochMilliseconds,e as parseHttpEndpoint};
2
+ //# sourceMappingURL=normalization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.js","names":["parseHttpEndpoint","value","url","options","parseByteCount","number","parseEpochMilliseconds","result"],"sources":["../../src/utils/normalization.ts"],"sourcesContent":["export interface HttpEndpointOptions {\n allowLoopbackHttp?: boolean;\n allowQuery?: boolean;\n originOnly?: boolean;\n}\n\n/** Syntax/transport validation only; callers still own destination allowlists. */\nexport function parseHttpEndpoint(\n value: string,\n options: HttpEndpointOptions = {},\n): URL {\n try {\n if (typeof value !== \"string\" || value !== value.trim()) throw new Error();\n const url = new URL(value);\n if (\n url.username ||\n url.password ||\n url.hash ||\n (!options.allowQuery && url.search) ||\n (options.originOnly && url.pathname !== \"/\") ||\n (url.protocol !== \"https:\" &&\n !(\n options.allowLoopbackHttp &&\n url.protocol === \"http:\" &&\n [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname)\n ))\n )\n throw new Error();\n return url;\n } catch {\n throw new TypeError(\"Invalid HTTP endpoint\");\n }\n}\n\nexport function parseByteCount(value: unknown): number {\n const number =\n typeof value === \"string\" && /^\\d+$/.test(value) ? Number(value) : value;\n if (typeof number !== \"number\" || !Number.isSafeInteger(number) || number < 0)\n throw new TypeError(\"Invalid byte count\");\n return number;\n}\n\nexport function parseEpochMilliseconds(value: Date | string | number): number {\n const result =\n value instanceof Date\n ? value.getTime()\n : typeof value === \"string\"\n ? Date.parse(value)\n : value;\n if (!Number.isSafeInteger(result) || result < 0)\n throw new TypeError(\"Invalid timestamp\");\n return result;\n}\n"],"mappings":"AAOA,SAAgBA,EACd,EACA,EAA+B,CAAC,EAC3B,CACL,GAAI,CACF,GAAI,OAAOC,GAAU,UAAYA,IAAUA,EAAM,KAAK,EAAG,MAAU,MAAM,EACzE,IAAMC,EAAM,IAAI,IAAID,CAAK,EACzB,GACEC,EAAI,UACJA,EAAI,UACJA,EAAI,MACH,CAACC,EAAQ,YAAcD,EAAI,QAC3BC,EAAQ,YAAcD,EAAI,WAAa,KACvCA,EAAI,WAAa,UAChB,EACEC,EAAQ,mBACRD,EAAI,WAAa,SACjB,CAAC,YAAa,YAAa,OAAO,CAAC,CAAC,SAASA,EAAI,QAAQ,GAG7D,MAAU,MAAM,EAClB,OAAOA,CACT,MAAQ,CACN,MAAU,UAAU,uBAAuB,CAC7C,CACF,CAEA,SAAgBE,EAAe,EAAwB,CACrD,IAAMC,EACJ,OAAOJ,GAAU,UAAY,QAAQ,KAAKA,CAAK,EAAI,OAAOA,CAAK,EAAIA,EACrE,GAAI,OAAOI,GAAW,UAAY,CAAC,OAAO,cAAcA,CAAM,GAAKA,EAAS,EAC1E,MAAU,UAAU,oBAAoB,EAC1C,OAAOA,CACT,CAEA,SAAgBC,EAAuB,EAAuC,CAC5E,IAAMC,EACJN,aAAiB,KACbA,EAAM,QAAQ,EACd,OAAOA,GAAU,SACf,KAAK,MAAMA,CAAK,EAChBA,EACR,GAAI,CAAC,OAAO,cAAcM,CAAM,GAAKA,EAAS,EAC5C,MAAU,UAAU,mBAAmB,EACzC,OAAOA,CACT,C"}
package/docs/modules.md CHANGED
@@ -30,7 +30,71 @@ Desktop RPC still requires app-owned IPC sender/frame validation and trusted
30
30
  preload transport. Shortcut policies/registration/persistence stay in the app.
31
31
  Supabase credentials/RLS/ownership remain app responsibilities.
32
32
 
33
- Use `pnpm verify` before releasing. The app-owned Better Auth SDK peer and direct
33
+ Use `bun run typecheck`, `bun run test`, `bun run test:types` and `bun run test:exports` before releasing. The app-owned Better Auth SDK peer and direct
34
34
  import requirements are listed in auth.md. GitHub distribution remains private-to-npm;
35
35
  pin consumers to a tested release commit/tag. No app dependency or DB/cloud state
36
36
  is changed by building this package.
37
+
38
+ ## Shared infrastructure extraction (M03–M10, M15–M20)
39
+
40
+ These are library mechanisms, not an application migration. Use the public
41
+ `@gorth-io/structure` subpaths after publishing/installing a new version.
42
+ Better Auth remains an external host peer; `cores/auth/*` remains blocked.
43
+
44
+ | Public entry | API | Host responsibilities |
45
+ | --- | --- | --- |
46
+ | `modules/auth/server` | `createBearerVerifier`, `authFailure`, claim/continuity assertions | Trusted issuer/JWKS/audience, scopes, client-to-app binding, revocation and local ACL |
47
+ | `modules/auth/server` | `createOAuthProviderConfig`, `mapOAuthUserProfile` | Call native `genericOAuth`; create the auth instance, hooks, cookies, provider ID and app policy |
48
+ | `modules/auth/server` | `createUserInfoCache`, `oauthUserInfoSchema` | Inject loader/parser/admission predicate; own endpoint, transport and DB synchronization |
49
+ | `modules/auth/server` | `createAtomicProofStorage`, existing proof/logout/revocation helpers | Durable atomic expired-key replacement/insert-if-absent, SQL transactions, receipt persistence |
50
+ | `modules/auth/server` | `createMachineTokenRequest`, `parseMachineToken` | Supply credentials, scopes/resources and trusted token endpoint; execute the grant via bounded transport |
51
+ | `modules/http` | `ServiceError`, `serviceFailure` | Public error vocabulary; explicitly map other native/framework errors |
52
+ | `modules/database` | `parseDatabasePoolOptions`, `createDatabasePoolFactory` | Read env; cache, close and observe pools; own schema/migrations |
53
+ | `modules/database/postgres` | `createPostgresPool` | Node-only explicit factory call; no eager connection on import |
54
+ | `modules/desktop` | `releaseVersion`, `isNewerRelease`, `parseRelease`, proxy schema/config | Artifact trust/signatures, download/install, OS state and credentials |
55
+ | `modules/desktop` | `resolveDesktopRpcPolicy` | Forge/env/socket lifecycle, IPC origin/frame checks and renderer boundaries |
56
+ | `utils/normalization` | `parseHttpEndpoint`, `parseByteCount`, `parseEpochMilliseconds` | Destination allowlists and application-specific defaults; display formatters remain separate |
57
+
58
+ ```ts
59
+ import { genericOAuth } from "better-auth/plugins/generic-oauth";
60
+ import { createOAuthProviderConfig } from "@gorth-io/structure/modules/auth/server";
61
+
62
+ // All values/callbacks below come from the owning app's validated configuration.
63
+ const config = createOAuthProviderConfig({
64
+ ...providerOptions,
65
+ scopes: requestedScopes,
66
+ resources: registeredResources,
67
+ });
68
+ const providerPlugin = genericOAuth({ config: [config] });
69
+ ```
70
+
71
+ `createBearerVerifier` is JWT Bearer-only and rejects DPoP-bound grants. Use
72
+ the existing `createResourceAuth` with durable proof/revocation stores for DPoP.
73
+ Its `authorize` callback must still enforce the owning service's client/scope
74
+ binding and local status. `authFailure` projects safe codes/challenges, not raw
75
+ provider causes. `serviceFailure` omits validation input/custom messages.
76
+
77
+ `createUserInfoCache` adds typed profile parsing, expected-subject checking and
78
+ an injected admission predicate to the existing bounded/coalescing/fenced cache.
79
+ `createSessionGrantGuard` re-reads the app binding around native SDK operations;
80
+ `assertTokenContinuity` binds verified sub/sid to that local session. These helpers
81
+ do not implement refresh, account linking, user persistence or app authorization.
82
+
83
+ The replay adapter has no in-memory fallback. Its `reserve` callback must be
84
+ atomic across all deployment instances; tests using a fake store do not prove
85
+ production database atomicity. Rate-limit storage follows the same host-owned rule.
86
+
87
+ `createAtomicDpopReplayStore({ reserve })` accepts the native SDK reservation
88
+ directly. It preserves both `now` and `expiresAt` as Date values, so a durable SQL
89
+ adapter keeps the verifier's clock and transaction boundary. Duplicate reservations
90
+ return false; invalid input and storage failures fail closed. It does not verify
91
+ proofs or replace the native Better Auth DPoP verifier.
92
+
93
+ M16 implements data/protocol normalization only. No localized byte/date/name UI
94
+ formatter was moved from Primitive or an app. M19 exposes existing RPC option
95
+ validation; `.env.local` loading remains a host concern using the platform API.
96
+
97
+ Verification: `bun run typecheck`, `bun run test:types`, `bun run test`,
98
+ `bun run build`, then `bun run test:exports`. No install/publish/database command
99
+ is part of these checks. The Ably Spaces facade now follows its installed SDK's
100
+ named exports (`createSpacesClient`); that SDK no longer has a default export.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gorth-io/structure",
3
- "version": "0.0.0-alpha.6",
4
- "description": "",
3
+ "version": "0.0.0-alpha.8",
4
+ "description": "TypeScript infrastructure for HTTP clients, authentication coordination, Supabase, and database integrations in the gorth-io ecosystem.",
5
5
  "type": "module",
6
6
  "author": "Gorthenburg",
7
7
  "license": "GORTH",
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public",
26
+ "tag": "alpha",
26
27
  "registry": "https://registry.npmjs.org"
27
28
  },
28
29
  "main": "./dist/index.cjs",
@@ -38,6 +39,11 @@
38
39
  },
39
40
  "packageManager": "bun@1.4.4",
40
41
  "exports": {
42
+ "./modules/database": {
43
+ "types": "./dist/modules/database/index.d.ts",
44
+ "import": "./dist/modules/database/index.js",
45
+ "require": "./dist/modules/database/index.cjs"
46
+ },
41
47
  "./utils/*": {
42
48
  "types": "./dist/utils/*.d.ts",
43
49
  "import": "./dist/utils/*.js",
@@ -108,6 +114,9 @@
108
114
  },
109
115
  "typesVersions": {
110
116
  "*": {
117
+ "modules/database": [
118
+ "dist/modules/database/index.d.ts"
119
+ ],
111
120
  "utils/*": [
112
121
  "dist/utils/*.d.ts"
113
122
  ],
@@ -144,7 +153,7 @@
144
153
  "build": "tsdown --minify",
145
154
  "prepack": "bun run build",
146
155
  "verify": "bun verify",
147
- "dev": "tsdown --format esm,cjs --dts --out-dir dist --watch",
156
+ "dev": "tsdown --format esm,cjs --dts --out-dir dist --watch --no-clean",
148
157
  "lint": "eslint",
149
158
  "format": "prettier --write \"**/*.{ts,tsx}\"",
150
159
  "typecheck": "tsc --noEmit",
@@ -157,10 +166,10 @@
157
166
  "@ably/ai-transport": "^0.11.0",
158
167
  "@ably/chat": "^2.0.0",
159
168
  "@ably/spaces": "^0.6.0",
160
- "@supabase/postgrest-js": "^2.118.0",
169
+ "@supabase/postgrest-js": "^2.119.0",
161
170
  "@supabase/server": "^1.9.2",
162
171
  "@supabase/ssr": "^0.12.7",
163
- "@supabase/supabase-js": "^2.118.0",
172
+ "@supabase/supabase-js": "^2.119.0",
164
173
  "ably": "^2.30.0",
165
174
  "axios": "^1.21.0",
166
175
  "graphql": "^16.14.2",
@@ -175,7 +184,7 @@
175
184
  "devDependencies": {
176
185
  "@types/node": "^26.6.6",
177
186
  "@types/pg": "^8.23.1",
178
- "better-auth": "1.7.16",
187
+ "better-auth": "1.7.17",
179
188
  "eslint": "^9.39.5",
180
189
  "prettier": "^3.9.10",
181
190
  "tsdown": "^0.23.5",
@@ -184,6 +193,6 @@
184
193
  "vitest": "^5.1.0"
185
194
  },
186
195
  "peerDependencies": {
187
- "better-auth": "^1.7.16"
196
+ "better-auth": "^1.7.17"
188
197
  }
189
198
  }