@getstrata/core 0.5.82 → 0.5.83

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.83
4
+
5
+ - `MEMBER_ABILITIES` includes `auth:tokens:delete` so Jetstream-style personal access token revoke works for members (`DELETE /auth/tokens/:id`). HTML `/account/tokens/:id/revoke` was already authenticated-only.
6
+ - `buildOtpauthUrl()` defaults the issuer through `appDisplayName()` (`APP_NAME`).
7
+
3
8
  ## 0.5.82
4
9
 
5
10
  - `MEMBER_ABILITIES` includes `organizations:create` so Jetstream-style extra teams work for members (HTML `POST /organizations` and JSON `POST /organizations`). `OrganizationPolicy.create` already allowed any authenticated user.
@@ -1,5 +1,5 @@
1
- declare const MEMBER_ABILITIES: readonly ["organizations:read", "organizations:create", "projects:read", "projects:create", "tasks:read", "tasks:create", "comments:read", "comments:create", "attachments:read", "attachments:create", "auth:tokens:read", "auth:tokens:write"];
2
- declare const ADMIN_ABILITIES: readonly ["organizations:read", "organizations:create", "projects:read", "projects:create", "tasks:read", "tasks:create", "comments:read", "comments:create", "attachments:read", "attachments:create", "auth:tokens:read", "auth:tokens:write", "organizations:create", "organizations:update", "organizations:delete", "projects:update", "projects:delete", "tasks:update", "tasks:delete", "comments:update", "comments:delete", "attachments:delete", "webhooks:read", "webhooks:write", "audit:read"];
1
+ declare const MEMBER_ABILITIES: readonly ["organizations:read", "organizations:create", "projects:read", "projects:create", "tasks:read", "tasks:create", "comments:read", "comments:create", "attachments:read", "attachments:create", "auth:tokens:read", "auth:tokens:write", "auth:tokens:delete"];
2
+ declare const ADMIN_ABILITIES: readonly ["organizations:read", "organizations:create", "projects:read", "projects:create", "tasks:read", "tasks:create", "comments:read", "comments:create", "attachments:read", "attachments:create", "auth:tokens:read", "auth:tokens:write", "auth:tokens:delete", "organizations:create", "organizations:update", "organizations:delete", "projects:update", "projects:delete", "tasks:update", "tasks:delete", "comments:update", "comments:delete", "attachments:delete", "webhooks:read", "webhooks:write", "audit:read"];
3
3
  declare const PLATFORM_ADMIN_ABILITIES: readonly ["*"];
4
4
  interface AbilityCatalog {
5
5
  member: readonly string[];
@@ -57,7 +57,8 @@ var MEMBER_ABILITIES = [
57
57
  "attachments:read",
58
58
  "attachments:create",
59
59
  "auth:tokens:read",
60
- "auth:tokens:write"
60
+ "auth:tokens:write",
61
+ "auth:tokens:delete"
61
62
  ];
62
63
  var ADMIN_ABILITIES = [
63
64
  ...MEMBER_ABILITIES,
@@ -1,6 +1,62 @@
1
1
  // @bun
2
2
  // ../../src/core/security/totp.ts
3
3
  import { createHmac, randomBytes } from "crypto";
4
+
5
+ // ../../src/core/runtime/appKeyPrefix.ts
6
+ function appKeyPrefix() {
7
+ return process.env.APP_KEY_PREFIX?.trim() || "workhub";
8
+ }
9
+ function appCookieName(kind) {
10
+ return `${appKeyPrefix()}_${kind}`;
11
+ }
12
+ function appDevSecret(kind) {
13
+ return `${appKeyPrefix()}-dev-${kind}`;
14
+ }
15
+ function namespacedRedisKey(kind) {
16
+ return `${appKeyPrefix()}:${kind}`;
17
+ }
18
+ function smtpEhloHost() {
19
+ const raw = process.env.MAIL_EHLO?.trim() || `${appKeyPrefix()}.local`;
20
+ const safe = raw.replace(/[^a-zA-Z0-9.-]/g, "");
21
+ return safe || "strata.local";
22
+ }
23
+ function siemEventType() {
24
+ return process.env.SIEM_EVENT_TYPE?.trim() || `${appKeyPrefix()}.audit`;
25
+ }
26
+ function appUserAgent() {
27
+ return process.env.APP_USER_AGENT?.trim() || appKeyPrefix();
28
+ }
29
+ function otelServiceName() {
30
+ return process.env.OTEL_SERVICE_NAME?.trim() || `${appKeyPrefix()}-api`;
31
+ }
32
+ function webhookSignatureHeader() {
33
+ return process.env.WEBHOOK_SIGNATURE_HEADER?.trim() || `x-${appKeyPrefix()}-signature`;
34
+ }
35
+ function appDisplayName() {
36
+ return process.env.APP_NAME?.trim() || "WorkHub";
37
+ }
38
+ function appEnv() {
39
+ return process.env.APP_ENV?.trim() || "local";
40
+ }
41
+ function appUrl() {
42
+ return (process.env.APP_URL?.trim() || "http://localhost:3000").replace(/\/$/, "");
43
+ }
44
+ function apiPrefix() {
45
+ const raw = process.env.API_PREFIX?.trim() || "/api/v1";
46
+ const withSlash = raw.startsWith("/") ? raw : `/${raw}`;
47
+ const trimmed = withSlash.replace(/\/+$/, "");
48
+ return trimmed || "/api/v1";
49
+ }
50
+ function sdkClientClassName() {
51
+ const override = process.env.APP_SDK_CLASS?.trim();
52
+ if (override && /^[A-Za-z_][A-Za-z0-9_]*$/.test(override)) {
53
+ return override;
54
+ }
55
+ const fromName = appDisplayName().replace(/[^A-Za-z0-9]/g, "");
56
+ return fromName ? `${fromName}Client` : "AppClient";
57
+ }
58
+
59
+ // ../../src/core/security/totp.ts
4
60
  function decodeBase32(input) {
5
61
  const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
6
62
  const normalized = input.replace(/=+$/u, "").toUpperCase();
@@ -35,7 +91,7 @@ function generateTotpSecret(byteLength = 20) {
35
91
  return encodeBase32(randomBytes(byteLength));
36
92
  }
37
93
  function buildOtpauthUrl(options) {
38
- const issuer = options.issuer?.trim() || process.env.APP_NAME?.trim() || "WorkHub";
94
+ const issuer = options.issuer?.trim() || appDisplayName();
39
95
  const label = `${issuer}:${options.account}`;
40
96
  const params = new URLSearchParams({
41
97
  secret: options.secret,
package/dist/index.js CHANGED
@@ -208,7 +208,8 @@ var MEMBER_ABILITIES = [
208
208
  "attachments:read",
209
209
  "attachments:create",
210
210
  "auth:tokens:read",
211
- "auth:tokens:write"
211
+ "auth:tokens:write",
212
+ "auth:tokens:delete"
212
213
  ];
213
214
  var ADMIN_ABILITIES = [
214
215
  ...MEMBER_ABILITIES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "0.5.82",
3
+ "version": "0.5.83",
4
4
  "description": "Strata — Laravel-inspired Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",