@happyvertical/smrt-cli 0.51.14 → 0.51.16

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-Dz-PO2sa.js +157 -0
  3. package/dist/ApiKeyCollection-Bfb_nw81-Dks_0546.js +2 -0
  4. package/dist/AuditLogCollection-B1YonCAP-Db9tLDtf.js +2 -0
  5. package/dist/NostrIdentity-n70E0vck-CZwoR7Rs.js +4189 -0
  6. package/dist/NostrIdentityCollection-Ca74dkaL-DESXyrjY.js +2 -0
  7. package/dist/OidcIdentity-CChQnYNH-DV9jiJ5r.js +117 -0
  8. package/dist/OidcIdentityCollection-D3L0WYbM-C85jz9CB.js +2 -0
  9. package/dist/ProfileAssetCollection-V8u4wqSL-BKz6v8py.js +2 -0
  10. package/dist/ProfileCollection-BvhD2cfL-CT6ctQ3l.js +1753 -0
  11. package/dist/ProfileMetadataCollection-DxX_BJKV-StatXt-E.js +2 -0
  12. package/dist/ProfileMetafieldCollection-CMKhVi2I--ba-T4qA.js +2 -0
  13. package/dist/ProfileRelationshipCollection-DUVgaIqf-B4TDc4TQ.js +2 -0
  14. package/dist/ProfileRelationshipTermCollection-DtA9OM23-1ZkGUm00.js +2 -0
  15. package/dist/ProfileRelationshipType-BRiRka6t-Dw1efEX5.js +101 -0
  16. package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-GEu0alx6.js +2 -0
  17. package/dist/{commands-BhDS-TVS.js → commands-CL85adn5.js} +95 -21
  18. package/dist/{config-DfBo4hHU.js → config-hqNo4lzH.js} +1 -13
  19. package/dist/dist-9EA_5mOX.js +142 -0
  20. package/dist/dist-BIA7A6wF.js +3712 -0
  21. package/dist/dist-mLcl4Ttr.js +1487 -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-DhC5lyKE.js +161 -0
  25. package/dist/resolveIdentity-73HQnTlT-DQB4z5h5.js +2 -0
  26. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  27. package/package.json +8 -7
@@ -0,0 +1,2 @@
1
+ import { E as NostrIdentityCollection_exports } from "./dist-BIA7A6wF.js";
2
+ export { NostrIdentityCollection_exports as n };
@@ -0,0 +1,117 @@
1
+ import { SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
2
+ //#region ../profiles/dist/chunks/OidcIdentity-CChQnYNH.js
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __decorateClass = (decorators, target, key, kind) => {
6
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
7
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+ var OidcIdentity = class extends SmrtObject {
12
+ profileId;
13
+ provider = "";
14
+ issuer = "";
15
+ subject = "";
16
+ identityKey = null;
17
+ email = "";
18
+ lastUsedAt = null;
19
+ constructor(options = {}) {
20
+ super(options);
21
+ if (options.profileId) this.profileId = options.profileId;
22
+ if (options.provider) this.provider = options.provider;
23
+ if (options.issuer) this.issuer = options.issuer;
24
+ if (options.subject) this.subject = options.subject;
25
+ if (options.email) this.email = options.email;
26
+ if (options.lastUsedAt !== void 0) this.lastUsedAt = options.lastUsedAt;
27
+ }
28
+ /**
29
+ * Get the linked Profile
30
+ */
31
+ async getProfile() {
32
+ return await this.getRelated("profileId");
33
+ }
34
+ /**
35
+ * Find identity by issuer and subject
36
+ */
37
+ static async findBySubject(issuer, subject, options = {}) {
38
+ const { OidcIdentityCollection } = await import("./OidcIdentityCollection-D3L0WYbM-C85jz9CB.js").then((n) => n.r);
39
+ return await (await OidcIdentityCollection.create(options)).findBySubject(issuer, subject);
40
+ }
41
+ /** Build the collision-free natural key for one OIDC issuer subject. */
42
+ static buildIdentityKey(issuer, subject) {
43
+ return JSON.stringify([issuer, subject]);
44
+ }
45
+ /** Keep the durable key derived from its natural-key source fields. */
46
+ async save() {
47
+ this.identityKey = this.issuer.trim() && this.subject.trim() ? OidcIdentity.buildIdentityKey(this.issuer, this.subject) : null;
48
+ return super.save();
49
+ }
50
+ /**
51
+ * Reuse an existing exact identity for its unchanged Profile.
52
+ *
53
+ * @deprecated Authentication links must be created through transactional
54
+ * provisioning. This compatibility method only refreshes a unique mapping
55
+ * that already belongs to the supplied Profile, including legacy Profile
56
+ * types, and deliberately refuses to create or rebind authority.
57
+ */
58
+ static async findOrCreate(profile, oidcData, options = {}) {
59
+ const profileId = profile.id;
60
+ if (typeof profileId !== "string" || !profileId) throw new Error("OidcIdentity.findOrCreate() requires a saved Profile.");
61
+ const { reuseExistingOidcIdentityForProfile } = await import("./resolveIdentity-73HQnTlT-DQB4z5h5.js").then((n) => n.i);
62
+ const profileOptions = profile.options ?? {};
63
+ return (await reuseExistingOidcIdentityForProfile(profileId, {
64
+ email: oidcData.email,
65
+ iss: oidcData.issuer,
66
+ sub: oidcData.subject
67
+ }, oidcData.provider, {
68
+ ...profileOptions,
69
+ ...options,
70
+ db: options.db ?? profileOptions.db
71
+ })).oidcIdentity;
72
+ }
73
+ /**
74
+ * Record usage of this identity
75
+ */
76
+ async recordUsage() {
77
+ for (let attempt = 0; attempt < 4; attempt += 1) {
78
+ await this.loadFromId();
79
+ this.lastUsedAt = /* @__PURE__ */ new Date();
80
+ try {
81
+ await this.save();
82
+ return;
83
+ } catch (error) {
84
+ if (attempt === 3 || !(error instanceof Error && "code" in error && error.code === "RUNTIME_REVISION_CONFLICT")) throw error;
85
+ }
86
+ }
87
+ }
88
+ };
89
+ __decorateClass([foreignKey("Profile", { required: true })], OidcIdentity.prototype, "profileId", 2);
90
+ __decorateClass([field({ type: "text" })], OidcIdentity.prototype, "provider", 2);
91
+ __decorateClass([field({
92
+ type: "text",
93
+ indexed: true
94
+ })], OidcIdentity.prototype, "issuer", 2);
95
+ __decorateClass([field({
96
+ type: "text",
97
+ indexed: true
98
+ })], OidcIdentity.prototype, "subject", 2);
99
+ __decorateClass([field({
100
+ type: "text",
101
+ nullable: true,
102
+ unique: true,
103
+ readonly: true
104
+ })], OidcIdentity.prototype, "identityKey", 2);
105
+ __decorateClass([field({ type: "text" })], OidcIdentity.prototype, "email", 2);
106
+ __decorateClass([field({
107
+ type: "datetime",
108
+ nullable: true
109
+ })], OidcIdentity.prototype, "lastUsedAt", 2);
110
+ OidcIdentity = __decorateClass([smrt({
111
+ tableName: "oidc_identities",
112
+ api: { include: ["list", "get"] },
113
+ mcp: { include: ["list", "get"] },
114
+ cli: { include: ["list", "get"] }
115
+ })], OidcIdentity);
116
+ //#endregion
117
+ export { OidcIdentity as t };
@@ -0,0 +1,2 @@
1
+ import { w as OidcIdentityCollection_exports } from "./dist-BIA7A6wF.js";
2
+ export { OidcIdentityCollection_exports as r };
@@ -0,0 +1,2 @@
1
+ import { x as ProfileAssetCollection_exports } from "./dist-BIA7A6wF.js";
2
+ export { ProfileAssetCollection_exports as n };