@happyvertical/smrt-cli 0.51.15 → 0.51.17

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 (27) hide show
  1. package/AGENTS.md +1 -0
  2. package/dist/ApiKey-BZmbOTnL-D3HXUD48.js +157 -0
  3. package/dist/ApiKeyCollection-Bfb_nw81-iisJ_4LE.js +2 -0
  4. package/dist/AuditLogCollection-B1YonCAP-BSaKxHp3.js +2 -0
  5. package/dist/NostrIdentity-n70E0vck-jJyb_ar3.js +4189 -0
  6. package/dist/NostrIdentityCollection-Ca74dkaL-M4K0-Bkw.js +2 -0
  7. package/dist/OidcIdentity-CChQnYNH-Cnye-7CI.js +117 -0
  8. package/dist/OidcIdentityCollection-D3L0WYbM-BOje5aiS.js +2 -0
  9. package/dist/ProfileAssetCollection-V8u4wqSL-DDnGXiJl.js +2 -0
  10. package/dist/ProfileCollection-BvhD2cfL-P9hC9GcP.js +1753 -0
  11. package/dist/ProfileMetadataCollection-DxX_BJKV-ZbSkGI11.js +2 -0
  12. package/dist/ProfileMetafieldCollection-CMKhVi2I-BrAonTjE.js +2 -0
  13. package/dist/ProfileRelationshipCollection-DUVgaIqf-0E090hxE.js +2 -0
  14. package/dist/ProfileRelationshipTermCollection-DtA9OM23-EGZ4UVpV.js +2 -0
  15. package/dist/ProfileRelationshipType-BRiRka6t-W3qx1WVa.js +101 -0
  16. package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-mvIAf7RC.js +2 -0
  17. package/dist/{commands-BhDS-TVS.js → commands-C3O2NOMh.js} +96 -22
  18. package/dist/{config-DfBo4hHU.js → config-hqNo4lzH.js} +1 -13
  19. package/dist/dist-A0mO7r3F.js +142 -0
  20. package/dist/dist-DNf1dFwn.js +1487 -0
  21. package/dist/dist-DrGZRXfi.js +3712 -0
  22. package/dist/index.js +14 -14
  23. package/dist/{json-validator-CjX8fHx9.js → json-validator-oEN7eUI3.js} +1 -1
  24. package/dist/oidcProvisioningPrimitives-CjOkg3Zd-BtqRL7sX.js +161 -0
  25. package/dist/resolveIdentity-73HQnTlT-C4CQBrRn.js +2 -0
  26. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  27. package/package.json +8 -7
package/AGENTS.md CHANGED
@@ -18,6 +18,7 @@ smrt db:migrate --apply-unblocked / --null-orphans # agents/db-migrate-partial-a
18
18
  smrt db:migrate-uuid # Convert schema-declared UUID text columns after data remap
19
19
  smrt db:migrate-int8
20
20
  smrt db:migrate-null-equal-indexes # ../core/agents/null-equal-indexes.md
21
+ smrt db:materialize-tenant-hierarchy [--dry-run] # smrt-users tenant hierarchy_path backfill (#3036)
21
22
  smrt db:drop-framework-base-tables # One-time drop of the five #2644-orphaned framework-base tables
22
23
  smrt db:drop-framework-base-tables --dry-run # Print the drop plan without executing
23
24
  smrt db:diff # Show schema differences without generating migration files
@@ -0,0 +1,157 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-jJyb_ar3.js";
3
+ import { SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
4
+ import { createHash, randomBytes } from "node:crypto";
5
+ //#region ../profiles/dist/chunks/ApiKey-BZmbOTnL.js
6
+ var ApiKey_BZmbOTnL_exports = /* @__PURE__ */ __exportAll({
7
+ n: () => ApiKey_exports,
8
+ t: () => ApiKey
9
+ });
10
+ var ApiKey_exports = /* @__PURE__ */ __exportAll$1({ ApiKey: () => ApiKey });
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __decorateClass = (decorators, target, key, kind) => {
14
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
15
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
16
+ if (kind && result) __defProp(target, key, result);
17
+ return result;
18
+ };
19
+ var ApiKey = class extends SmrtObject {
20
+ profileId;
21
+ keyHash = "";
22
+ /**
23
+ * First 8 characters of the key for identification (e.g., "sk_live_a1b2...")
24
+ */
25
+ keyPrefix = "";
26
+ /**
27
+ * Human-readable name for the key (e.g., "CI Bot", "Local CLI")
28
+ */
29
+ name = "";
30
+ /**
31
+ * Scopes/permissions for this key
32
+ */
33
+ scopes = [];
34
+ /**
35
+ * Last time this key was used
36
+ */
37
+ lastUsedAt = null;
38
+ /**
39
+ * When this key expires (null = never)
40
+ */
41
+ expiresAt = null;
42
+ /**
43
+ * When this key was revoked (null = active)
44
+ */
45
+ revokedAt = null;
46
+ constructor(options = {}) {
47
+ super(options);
48
+ if (options.profileId) this.profileId = options.profileId;
49
+ if (options.name) this.name = options.name;
50
+ if (options.scopes) this.scopes = options.scopes;
51
+ if (options.expiresAt !== void 0) this.expiresAt = options.expiresAt;
52
+ }
53
+ /**
54
+ * Get the linked Profile
55
+ */
56
+ async getProfile() {
57
+ return await this.getRelated("profileId");
58
+ }
59
+ /**
60
+ * Check if this key is valid (not expired, not revoked)
61
+ */
62
+ isValid() {
63
+ if (this.revokedAt) return false;
64
+ if (this.expiresAt && this.expiresAt < /* @__PURE__ */ new Date()) return false;
65
+ return true;
66
+ }
67
+ /**
68
+ * Check if this key has a specific scope
69
+ */
70
+ hasScope(scope) {
71
+ return this.scopes.includes(scope) || this.scopes.includes("*");
72
+ }
73
+ /**
74
+ * Revoke this key
75
+ */
76
+ async revoke() {
77
+ this.revokedAt = /* @__PURE__ */ new Date();
78
+ await this.save();
79
+ }
80
+ /**
81
+ * Record usage of this key
82
+ */
83
+ async recordUsage() {
84
+ for (let attempt = 0; attempt < 4; attempt += 1) {
85
+ if (this.isPersisted) await this.loadFromId();
86
+ if (!this.isValid()) return;
87
+ this.lastUsedAt = /* @__PURE__ */ new Date();
88
+ try {
89
+ await this.save();
90
+ return;
91
+ } catch (error) {
92
+ if (attempt === 3 || !(error instanceof Error && "code" in error && error.code === "RUNTIME_REVISION_CONFLICT")) throw error;
93
+ }
94
+ }
95
+ }
96
+ /**
97
+ * Hash an API key
98
+ */
99
+ static hashKey(key) {
100
+ return createHash("sha256").update(key).digest("hex");
101
+ }
102
+ /**
103
+ * Generate a new API key for a profile
104
+ */
105
+ static async generate(profile, options) {
106
+ const key = `sk_live_${randomBytes(32).toString("hex")}`;
107
+ const keyPrefix = key.substring(0, 16);
108
+ const keyHash = ApiKey.hashKey(key);
109
+ const apiKey = new ApiKey({
110
+ db: options.db || profile.options?.db,
111
+ profileId: profile.id,
112
+ name: options.name,
113
+ scopes: options.scopes || ["*"],
114
+ expiresAt: options.expiresAt ?? null
115
+ });
116
+ apiKey.keyHash = keyHash;
117
+ apiKey.keyPrefix = keyPrefix;
118
+ await apiKey.initialize();
119
+ await apiKey.save();
120
+ return {
121
+ key,
122
+ apiKey
123
+ };
124
+ }
125
+ /**
126
+ * Verify an API key and return the ApiKey record if valid
127
+ */
128
+ static async verify(key, options = {}) {
129
+ const keyHash = ApiKey.hashKey(key);
130
+ const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-iisJ_4LE.js").then((n) => n.n);
131
+ const apiKey = await (await ApiKeyCollection.create(options)).findOne({ where: { keyHash } });
132
+ if (!apiKey) return null;
133
+ if (!apiKey.isValid()) return null;
134
+ await apiKey.recordUsage();
135
+ if (!apiKey.isValid()) return null;
136
+ return apiKey;
137
+ }
138
+ };
139
+ __decorateClass([foreignKey("Profile", { required: true })], ApiKey.prototype, "profileId", 2);
140
+ __decorateClass([field({ indexed: true })], ApiKey.prototype, "keyHash", 2);
141
+ ApiKey = __decorateClass([smrt({
142
+ tableName: "api_keys",
143
+ sensitive: true,
144
+ api: { include: ["list", "get"] },
145
+ mcp: { include: ["list", "get"] },
146
+ cli: {
147
+ include: [
148
+ "list",
149
+ "get",
150
+ "create",
151
+ "revoke"
152
+ ],
153
+ skipApiCheck: true
154
+ }
155
+ })], ApiKey);
156
+ //#endregion
157
+ export { ApiKey_BZmbOTnL_exports as n, ApiKey as t };
@@ -0,0 +1,2 @@
1
+ import { j as ApiKeyCollection_exports } from "./dist-DrGZRXfi.js";
2
+ export { ApiKeyCollection_exports as n };
@@ -0,0 +1,2 @@
1
+ import { k as AuditLogCollection_exports } from "./dist-DrGZRXfi.js";
2
+ export { AuditLogCollection_exports as n };