@getstrata/core 0.5.70 → 0.5.71

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # @getstrata/core changelog
2
2
 
3
+ ## 0.5.71
4
+
5
+ - OpenAPI treats `POST /auth/login` and `POST /auth/register` as public (no bearer), including when routes are registered under `API_PREFIX`.
6
+ - Route summaries look up `PUBLIC_ROUTE_DESCRIPTIONS` after stripping `API_PREFIX`.
7
+
3
8
  ## 0.5.70
4
9
 
5
10
  - `OAuthProvider.getAuthorizationUrl` / `exchangeCode` accept an optional `redirectUri` so HTMX login can use `/oauth/:provider/callback` while the API keeps `OAUTH_REDIRECT_URI`.
package/README.md CHANGED
@@ -82,7 +82,7 @@ import type { Migration } from "@getstrata/core/database/migrations/types";
82
82
  Package name: **`@getstrata/core`** (npm org [`@getstrata`](https://www.npmjs.com/org/getstrata)).
83
83
 
84
84
  1. Add `NPM_TOKEN` to GitHub repository secrets.
85
- 2. Tag a release: `git tag v0.5.70 && git push origin v0.5.70`
85
+ 2. Tag a release: `git tag v0.5.71 && git push origin v0.5.71`
86
86
  3. [Release workflow](../../.github/workflows/release.yml) builds and runs `npm publish --access public`.
87
87
 
88
88
  Previously published as `@eyk-workhub/framework@0.1.0`, deprecated in favor of this package.
@@ -51,6 +51,7 @@ function sdkClientClassName() {
51
51
  var PUBLIC_ROUTE_DESCRIPTIONS = {
52
52
  "GET /auth/me": "Current authenticated user",
53
53
  "POST /auth/login": "Login with email and password",
54
+ "POST /auth/register": "Register with name, email, and password",
54
55
  "GET /auth/tokens": "List API tokens",
55
56
  "POST /auth/tokens": "Create API token",
56
57
  "DELETE /auth/tokens/:id": "Revoke API token",
@@ -83,27 +84,38 @@ var PUBLIC_ROUTE_DESCRIPTIONS = {
83
84
  function toOpenApiPath(path) {
84
85
  return path.replace(/:([A-Za-z_]+)/g, "{$1}");
85
86
  }
87
+ function toRelativeApiPath(path) {
88
+ const prefix = apiPrefix();
89
+ if (path === prefix) {
90
+ return "/";
91
+ }
92
+ if (path.startsWith(`${prefix}/`)) {
93
+ return path.slice(prefix.length);
94
+ }
95
+ return path;
96
+ }
86
97
  function requiresBearerAuth(path, method) {
87
- if (path.startsWith("/auth/login") || path.startsWith("/auth/oauth")) {
98
+ const relative = toRelativeApiPath(path);
99
+ if (relative.startsWith("/auth/login") || relative.startsWith("/auth/register") || relative.startsWith("/auth/oauth")) {
88
100
  return false;
89
101
  }
90
- if (path.startsWith("/scim/") || path.startsWith("/billing/webhooks/")) {
102
+ if (relative.startsWith("/scim/") || relative.startsWith("/billing/webhooks/") || path.startsWith("/scim/") || path.startsWith("/billing/webhooks/")) {
91
103
  return false;
92
104
  }
93
- if (["/health", "/ready", "/metrics", "/"].includes(path)) {
105
+ if (["/health", "/ready", "/metrics", "/"].includes(relative) || ["/health", "/ready", "/metrics", "/"].includes(path)) {
94
106
  return false;
95
107
  }
96
- if (method === "GET" && ["/organizations", "/projects", "/tasks", "/search"].some((prefix) => path.startsWith(prefix))) {
108
+ if (method === "GET" && ["/organizations", "/projects", "/tasks", "/search"].some((prefix) => relative.startsWith(prefix) || path.startsWith(prefix))) {
97
109
  return false;
98
110
  }
99
- return path.startsWith("/auth/") || ["POST", "PATCH", "PUT", "DELETE"].includes(method);
111
+ return relative.startsWith("/auth/") || ["POST", "PATCH", "PUT", "DELETE"].includes(method);
100
112
  }
101
113
  function generateOpenApiSpec(routes) {
102
114
  const paths = {};
103
115
  for (const route of routes) {
104
116
  const openApiPath = toOpenApiPath(route.path);
105
117
  const method = route.method.toLowerCase();
106
- const description = PUBLIC_ROUTE_DESCRIPTIONS[`${route.method} ${route.path}`] ?? `${route.method} ${route.path}`;
118
+ const description = PUBLIC_ROUTE_DESCRIPTIONS[`${route.method} ${toRelativeApiPath(route.path)}`] ?? PUBLIC_ROUTE_DESCRIPTIONS[`${route.method} ${route.path}`] ?? `${route.method} ${route.path}`;
107
119
  paths[openApiPath] ??= {};
108
120
  paths[openApiPath][method] = {
109
121
  summary: description,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "0.5.70",
3
+ "version": "0.5.71",
4
4
  "description": "Strata — Laravel-inspired Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",