@happyvertical/smrt-profiles 0.57.14 → 0.57.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 (45) hide show
  1. package/dist/chunks/{ApiKey-CVmlf3V6.js → ApiKey-9YuYcpWy.js} +3 -3
  2. package/dist/chunks/{ApiKey-CVmlf3V6.js.map → ApiKey-9YuYcpWy.js.map} +1 -1
  3. package/dist/chunks/{ApiKeyCollection-CiiDNFdD.js → ApiKeyCollection-BrJT9vo_.js} +3 -3
  4. package/dist/chunks/{ApiKeyCollection-CiiDNFdD.js.map → ApiKeyCollection-BrJT9vo_.js.map} +1 -1
  5. package/dist/chunks/{AuditLogCollection-WDHL-_AF.js → AuditLogCollection-BBbvr8Qc.js} +2 -2
  6. package/dist/chunks/{AuditLogCollection-WDHL-_AF.js.map → AuditLogCollection-BBbvr8Qc.js.map} +1 -1
  7. package/dist/chunks/{NostrIdentity-AC8fAdxe.js → NostrIdentity-RJaATTCt.js} +20 -9
  8. package/dist/chunks/{NostrIdentity-AC8fAdxe.js.map → NostrIdentity-RJaATTCt.js.map} +1 -1
  9. package/dist/chunks/{NostrIdentityCollection-CctlECpX.js → NostrIdentityCollection-BPNgPOBE.js} +2 -2
  10. package/dist/chunks/{NostrIdentityCollection-CctlECpX.js.map → NostrIdentityCollection-BPNgPOBE.js.map} +1 -1
  11. package/dist/chunks/{OidcIdentity-BUblgQLs.js → OidcIdentity-MVVO3MfG.js} +3 -3
  12. package/dist/chunks/{OidcIdentity-BUblgQLs.js.map → OidcIdentity-MVVO3MfG.js.map} +1 -1
  13. package/dist/chunks/{OidcIdentityCollection-ClOyaHeF.js → OidcIdentityCollection-s4mp3n62.js} +3 -3
  14. package/dist/chunks/{OidcIdentityCollection-ClOyaHeF.js.map → OidcIdentityCollection-s4mp3n62.js.map} +1 -1
  15. package/dist/chunks/{ProfileAssetCollection-CRMcjLJ-.js → ProfileAssetCollection-BuVAdOiv.js} +3 -3
  16. package/dist/chunks/{ProfileAssetCollection-CRMcjLJ-.js.map → ProfileAssetCollection-BuVAdOiv.js.map} +1 -1
  17. package/dist/chunks/{ProfileCollection-C4INKh7Y.js → ProfileCollection-CMS9dFc0.js} +26 -26
  18. package/dist/chunks/{ProfileCollection-C4INKh7Y.js.map → ProfileCollection-CMS9dFc0.js.map} +1 -1
  19. package/dist/chunks/{ProfileLinkCollection-DFfZRsgv.js → ProfileLinkCollection-ChK9iEBp.js} +3 -3
  20. package/dist/chunks/{ProfileLinkCollection-DFfZRsgv.js.map → ProfileLinkCollection-ChK9iEBp.js.map} +1 -1
  21. package/dist/chunks/{ProfileMetadataCollection-BIYKy4Y3.js → ProfileMetadataCollection-CAgJyjze.js} +2 -2
  22. package/dist/chunks/{ProfileMetadataCollection-BIYKy4Y3.js.map → ProfileMetadataCollection-CAgJyjze.js.map} +1 -1
  23. package/dist/chunks/{ProfileMetafieldCollection-Buz7gzag.js → ProfileMetafieldCollection-19ae6Lpf.js} +2 -2
  24. package/dist/chunks/{ProfileMetafieldCollection-Buz7gzag.js.map → ProfileMetafieldCollection-19ae6Lpf.js.map} +1 -1
  25. package/dist/chunks/{ProfileRelationshipCollection-C4g_QLI4.js → ProfileRelationshipCollection-BFSlTQ7J.js} +5 -5
  26. package/dist/chunks/{ProfileRelationshipCollection-C4g_QLI4.js.map → ProfileRelationshipCollection-BFSlTQ7J.js.map} +1 -1
  27. package/dist/chunks/{ProfileRelationshipTermCollection-C9J7mC7P.js → ProfileRelationshipTermCollection-OluL8BGP.js} +2 -2
  28. package/dist/chunks/{ProfileRelationshipTermCollection-C9J7mC7P.js.map → ProfileRelationshipTermCollection-OluL8BGP.js.map} +1 -1
  29. package/dist/chunks/{ProfileRelationshipType-U7IwF6Wf.js → ProfileRelationshipType-Cevy-vaF.js} +2 -2
  30. package/dist/chunks/{ProfileRelationshipType-U7IwF6Wf.js.map → ProfileRelationshipType-Cevy-vaF.js.map} +1 -1
  31. package/dist/chunks/{ProfileRelationshipTypeCollection-_n22WqTb.js → ProfileRelationshipTypeCollection-BRBpX00F.js} +3 -3
  32. package/dist/chunks/{ProfileRelationshipTypeCollection-_n22WqTb.js.map → ProfileRelationshipTypeCollection-BRBpX00F.js.map} +1 -1
  33. package/dist/chunks/{ProfileTypeCollection-B7kwi1mU.js → ProfileTypeCollection-B7m698Bl.js} +3 -3
  34. package/dist/chunks/{ProfileTypeCollection-B7kwi1mU.js.map → ProfileTypeCollection-B7m698Bl.js.map} +1 -1
  35. package/dist/chunks/{oidcProvisioningPrimitives-DNP9EZlU.js → oidcProvisioningPrimitives-Dl9qIcYS.js} +5 -5
  36. package/dist/chunks/{oidcProvisioningPrimitives-DNP9EZlU.js.map → oidcProvisioningPrimitives-Dl9qIcYS.js.map} +1 -1
  37. package/dist/chunks/{resolveIdentity-CkyqvctR.js → resolveIdentity-CR5p_g7K.js} +16 -16
  38. package/dist/chunks/{resolveIdentity-CkyqvctR.js.map → resolveIdentity-CR5p_g7K.js.map} +1 -1
  39. package/dist/index.js +24 -24
  40. package/dist/index.js.map +1 -1
  41. package/dist/internal/oidc-provisioning.js +2 -2
  42. package/dist/manifest.json +1 -1
  43. package/dist/smrt-knowledge.json +4 -4
  44. package/dist/utils.js +4 -4
  45. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import { y as __exportAll } from "./NostrIdentity-AC8fAdxe.js";
1
+ import { y as __exportAll } from "./NostrIdentity-RJaATTCt.js";
2
2
  import { SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
3
3
  import { createHash, randomBytes } from "node:crypto";
4
4
  //#region src/models/ApiKey.ts
@@ -129,7 +129,7 @@ var ApiKey = class extends SmrtObject {
129
129
  */
130
130
  static async verify(key, options = {}) {
131
131
  const keyHash = ApiKey.hashKey(key);
132
- const { ApiKeyCollection } = await import("./ApiKeyCollection-CiiDNFdD.js").then((n) => n.n);
132
+ const { ApiKeyCollection } = await import("./ApiKeyCollection-BrJT9vo_.js").then((n) => n.n);
133
133
  const apiKey = await (await ApiKeyCollection.create(options)).findOne({ where: { keyHash } });
134
134
  if (!apiKey) return null;
135
135
  if (!apiKey.isValid()) return null;
@@ -159,4 +159,4 @@ ApiKey = __decorateClass([smrt({
159
159
  //#endregion
160
160
  export { ApiKey_exports as n, ApiKey as t };
161
161
 
162
- //# sourceMappingURL=ApiKey-CVmlf3V6.js.map
162
+ //# sourceMappingURL=ApiKey-9YuYcpWy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApiKey-CVmlf3V6.js","names":[],"sources":["../../src/models/ApiKey.ts"],"sourcesContent":["/**\n * ApiKey - API keys for CLI and CI authentication\n *\n * Provides secure API key management with hashing, scopes, and expiration.\n * Keys are stored as hashes - the plaintext is only returned on creation.\n */\n\nimport { createHash, randomBytes } from 'node:crypto';\nimport {\n field,\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport type { Profile } from './Profile';\n\nexport interface ApiKeyOptions extends SmrtObjectOptions {\n profileId?: string;\n name?: string;\n scopes?: string[];\n expiresAt?: Date | null;\n}\n\nexport interface GenerateKeyResult {\n key: string;\n apiKey: ApiKey;\n}\n\n@smrt({\n tableName: 'api_keys',\n // The API-key store. Never in the change feed (#2937).\n sensitive: true,\n api: { include: ['list', 'get'] },\n mcp: { include: ['list', 'get'] },\n // create/revoke are admin operations invoked in-process via the CLI; only\n // read-only list/get are exposed over HTTP.\n cli: { include: ['list', 'get', 'create', 'revoke'], skipApiCheck: true },\n})\nexport class ApiKey extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-profiles\";\n /**\n * Link to the Profile (Person, Organization, Bot)\n */\n @foreignKey('Profile', { required: true })\n profileId?: string;\n\n /**\n * SHA-256 hash of the API key.\n *\n * Indexed: `verify()` looks keys up by this hash on every authenticated\n * request (#2364, epic #2382 finding A3).\n */\n @field({ indexed: true })\n keyHash: string = '';\n\n /**\n * First 8 characters of the key for identification (e.g., \"sk_live_a1b2...\")\n */\n keyPrefix: string = '';\n\n /**\n * Human-readable name for the key (e.g., \"CI Bot\", \"Local CLI\")\n */\n name: string = '';\n\n /**\n * Scopes/permissions for this key\n */\n scopes: string[] = [];\n\n /**\n * Last time this key was used\n */\n lastUsedAt: Date | null = null;\n\n /**\n * When this key expires (null = never)\n */\n expiresAt: Date | null = null;\n\n /**\n * When this key was revoked (null = active)\n */\n revokedAt: Date | null = null;\n\n constructor(options: ApiKeyOptions = {}) {\n super(options);\n if (options.profileId) this.profileId = options.profileId;\n if (options.name) this.name = options.name;\n if (options.scopes) this.scopes = options.scopes;\n if (options.expiresAt !== undefined) this.expiresAt = options.expiresAt;\n }\n\n /**\n * Get the linked Profile\n */\n async getProfile(): Promise<Profile | null> {\n return (await this.getRelated('profileId')) as Profile | null;\n }\n\n /**\n * Check if this key is valid (not expired, not revoked)\n */\n isValid(): boolean {\n if (this.revokedAt) return false;\n if (this.expiresAt && this.expiresAt < new Date()) return false;\n return true;\n }\n\n /**\n * Check if this key has a specific scope\n */\n hasScope(scope: string): boolean {\n return this.scopes.includes(scope) || this.scopes.includes('*');\n }\n\n /**\n * Revoke this key\n */\n async revoke(): Promise<void> {\n this.revokedAt = new Date();\n await this.save();\n }\n\n /**\n * Record usage of this key\n */\n async recordUsage(): Promise<void> {\n for (let attempt = 0; attempt < 4; attempt += 1) {\n if (this.isPersisted) await this.loadFromId();\n if (!this.isValid()) return;\n this.lastUsedAt = new Date();\n try {\n await this.save();\n return;\n } catch (error) {\n if (\n attempt === 3 ||\n !(\n error instanceof Error &&\n 'code' in error &&\n error.code === 'RUNTIME_REVISION_CONFLICT'\n )\n ) {\n throw error;\n }\n }\n }\n }\n\n /**\n * Hash an API key\n */\n static hashKey(key: string): string {\n return createHash('sha256').update(key).digest('hex');\n }\n\n /**\n * Generate a new API key for a profile\n */\n static async generate(\n profile: Profile,\n options: {\n name: string;\n scopes?: string[];\n expiresAt?: Date | null;\n db?: SmrtObjectOptions['db'];\n },\n ): Promise<GenerateKeyResult> {\n // Generate a random key: sk_live_<32 random bytes as hex>\n const randomPart = randomBytes(32).toString('hex');\n const key = `sk_live_${randomPart}`;\n const keyPrefix = key.substring(0, 16);\n const keyHash = ApiKey.hashKey(key);\n\n const apiKey = new ApiKey({\n db: options.db || profile.options?.db,\n profileId: profile.id as string,\n name: options.name,\n scopes: options.scopes || ['*'],\n expiresAt: options.expiresAt ?? null,\n });\n apiKey.keyHash = keyHash;\n apiKey.keyPrefix = keyPrefix;\n\n await apiKey.initialize();\n await apiKey.save();\n\n return { key, apiKey };\n }\n\n /**\n * Verify an API key and return the ApiKey record if valid\n */\n static async verify(\n key: string,\n options: SmrtObjectOptions = {},\n ): Promise<ApiKey | null> {\n const keyHash = ApiKey.hashKey(key);\n\n const { ApiKeyCollection } = await import(\n '../collections/ApiKeyCollection'\n );\n const collection = await ApiKeyCollection.create(options);\n\n const apiKey = await collection.findOne({\n where: { keyHash },\n });\n\n if (!apiKey) return null;\n if (!apiKey.isValid()) return null;\n\n // Record usage\n await apiKey.recordUsage();\n\n // A concurrent revocation may have been observed while recordUsage()\n // rehydrated after a revision conflict. Never authenticate that key.\n if (!apiKey.isValid()) return null;\n\n return apiKey;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCO,IAAM,SAAN,cAAqB,WAAW;CAKrC;CASA,UAAkB;;;;CAKlB,YAAoB;;;;CAKpB,OAAe;;;;CAKf,SAAmB,CAAC;;;;CAKpB,aAA0B;;;;CAK1B,YAAyB;;;;CAKzB,YAAyB;CAEzB,YAAY,UAAyB,CAAC,GAAG;EACvC,MAAM,OAAO;EACb,IAAI,QAAQ,WAAW,KAAK,YAAY,QAAQ;EAChD,IAAI,QAAQ,MAAM,KAAK,OAAO,QAAQ;EACtC,IAAI,QAAQ,QAAQ,KAAK,SAAS,QAAQ;EAC1C,IAAI,QAAQ,cAAc,KAAA,GAAW,KAAK,YAAY,QAAQ;CAChE;;;;CAKA,MAAM,aAAsC;EAC1C,OAAQ,MAAM,KAAK,WAAW,WAAW;CAC3C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;CACvB;;;;CAKA,aAAa,OACX,KACA,UAA6B,CAAC,GACN;EACxB,MAAM,UAAU,OAAO,QAAQ,GAAG;EAElC,MAAM,EAAE,qBAAqB,MAAM,OACjC,iCAAA,CAAA,MAAA,MAAA,EAAA,CAAA;EAIF,MAAM,SAAS,OAAM,MAFI,iBAAiB,OAAO,OAAO,EAAA,CAExB,QAAQ,EACtC,OAAO,EAAE,QAAQ,EACnB,CAAC;EAED,IAAI,CAAC,QAAQ,OAAO;EACpB,IAAI,CAAC,OAAO,QAAQ,GAAG,OAAO;EAG9B,MAAM,OAAO,YAAY;EAIzB,IAAI,CAAC,OAAO,QAAQ,GAAG,OAAO;EAE9B,OAAO;CACT;AACF;AAtLyC,cAA5B,QAAmC,mBAAkB,8BAAA;AAKhE,gBAAA,CADC,WAAW,WAAW,EAAE,UAAU,KAAK,CAAC,CAAA,GAJ9B,OAKX,WAAA,aAAA,CAAA;AASA,gBAAA,CADC,MAAM,EAAE,SAAS,KAAK,CAAC,CAAA,GAbb,OAcX,WAAA,WAAA,CAAA;AAdW,SAAN,gBAAA,CAVN,KAAK;CACJ,WAAW;CAEX,WAAW;CACX,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAChC,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAGhC,KAAK;EAAE,SAAS;GAAC;GAAQ;GAAO;GAAU;EAAQ;EAAG,cAAc;CAAK;AAC1E,CAAC,CAAA,GACY,MAAA"}
1
+ {"version":3,"file":"ApiKey-9YuYcpWy.js","names":[],"sources":["../../src/models/ApiKey.ts"],"sourcesContent":["/**\n * ApiKey - API keys for CLI and CI authentication\n *\n * Provides secure API key management with hashing, scopes, and expiration.\n * Keys are stored as hashes - the plaintext is only returned on creation.\n */\n\nimport { createHash, randomBytes } from 'node:crypto';\nimport {\n field,\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport type { Profile } from './Profile';\n\nexport interface ApiKeyOptions extends SmrtObjectOptions {\n profileId?: string;\n name?: string;\n scopes?: string[];\n expiresAt?: Date | null;\n}\n\nexport interface GenerateKeyResult {\n key: string;\n apiKey: ApiKey;\n}\n\n@smrt({\n tableName: 'api_keys',\n // The API-key store. Never in the change feed (#2937).\n sensitive: true,\n api: { include: ['list', 'get'] },\n mcp: { include: ['list', 'get'] },\n // create/revoke are admin operations invoked in-process via the CLI; only\n // read-only list/get are exposed over HTTP.\n cli: { include: ['list', 'get', 'create', 'revoke'], skipApiCheck: true },\n})\nexport class ApiKey extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-profiles\";\n /**\n * Link to the Profile (Person, Organization, Bot)\n */\n @foreignKey('Profile', { required: true })\n profileId?: string;\n\n /**\n * SHA-256 hash of the API key.\n *\n * Indexed: `verify()` looks keys up by this hash on every authenticated\n * request (#2364, epic #2382 finding A3).\n */\n @field({ indexed: true })\n keyHash: string = '';\n\n /**\n * First 8 characters of the key for identification (e.g., \"sk_live_a1b2...\")\n */\n keyPrefix: string = '';\n\n /**\n * Human-readable name for the key (e.g., \"CI Bot\", \"Local CLI\")\n */\n name: string = '';\n\n /**\n * Scopes/permissions for this key\n */\n scopes: string[] = [];\n\n /**\n * Last time this key was used\n */\n lastUsedAt: Date | null = null;\n\n /**\n * When this key expires (null = never)\n */\n expiresAt: Date | null = null;\n\n /**\n * When this key was revoked (null = active)\n */\n revokedAt: Date | null = null;\n\n constructor(options: ApiKeyOptions = {}) {\n super(options);\n if (options.profileId) this.profileId = options.profileId;\n if (options.name) this.name = options.name;\n if (options.scopes) this.scopes = options.scopes;\n if (options.expiresAt !== undefined) this.expiresAt = options.expiresAt;\n }\n\n /**\n * Get the linked Profile\n */\n async getProfile(): Promise<Profile | null> {\n return (await this.getRelated('profileId')) as Profile | null;\n }\n\n /**\n * Check if this key is valid (not expired, not revoked)\n */\n isValid(): boolean {\n if (this.revokedAt) return false;\n if (this.expiresAt && this.expiresAt < new Date()) return false;\n return true;\n }\n\n /**\n * Check if this key has a specific scope\n */\n hasScope(scope: string): boolean {\n return this.scopes.includes(scope) || this.scopes.includes('*');\n }\n\n /**\n * Revoke this key\n */\n async revoke(): Promise<void> {\n this.revokedAt = new Date();\n await this.save();\n }\n\n /**\n * Record usage of this key\n */\n async recordUsage(): Promise<void> {\n for (let attempt = 0; attempt < 4; attempt += 1) {\n if (this.isPersisted) await this.loadFromId();\n if (!this.isValid()) return;\n this.lastUsedAt = new Date();\n try {\n await this.save();\n return;\n } catch (error) {\n if (\n attempt === 3 ||\n !(\n error instanceof Error &&\n 'code' in error &&\n error.code === 'RUNTIME_REVISION_CONFLICT'\n )\n ) {\n throw error;\n }\n }\n }\n }\n\n /**\n * Hash an API key\n */\n static hashKey(key: string): string {\n return createHash('sha256').update(key).digest('hex');\n }\n\n /**\n * Generate a new API key for a profile\n */\n static async generate(\n profile: Profile,\n options: {\n name: string;\n scopes?: string[];\n expiresAt?: Date | null;\n db?: SmrtObjectOptions['db'];\n },\n ): Promise<GenerateKeyResult> {\n // Generate a random key: sk_live_<32 random bytes as hex>\n const randomPart = randomBytes(32).toString('hex');\n const key = `sk_live_${randomPart}`;\n const keyPrefix = key.substring(0, 16);\n const keyHash = ApiKey.hashKey(key);\n\n const apiKey = new ApiKey({\n db: options.db || profile.options?.db,\n profileId: profile.id as string,\n name: options.name,\n scopes: options.scopes || ['*'],\n expiresAt: options.expiresAt ?? null,\n });\n apiKey.keyHash = keyHash;\n apiKey.keyPrefix = keyPrefix;\n\n await apiKey.initialize();\n await apiKey.save();\n\n return { key, apiKey };\n }\n\n /**\n * Verify an API key and return the ApiKey record if valid\n */\n static async verify(\n key: string,\n options: SmrtObjectOptions = {},\n ): Promise<ApiKey | null> {\n const keyHash = ApiKey.hashKey(key);\n\n const { ApiKeyCollection } = await import(\n '../collections/ApiKeyCollection'\n );\n const collection = await ApiKeyCollection.create(options);\n\n const apiKey = await collection.findOne({\n where: { keyHash },\n });\n\n if (!apiKey) return null;\n if (!apiKey.isValid()) return null;\n\n // Record usage\n await apiKey.recordUsage();\n\n // A concurrent revocation may have been observed while recordUsage()\n // rehydrated after a revision conflict. Never authenticate that key.\n if (!apiKey.isValid()) return null;\n\n return apiKey;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCO,IAAM,SAAN,cAAqB,WAAW;CAKrC;CASA,UAAkB;;;;CAKlB,YAAoB;;;;CAKpB,OAAe;;;;CAKf,SAAmB,CAAC;;;;CAKpB,aAA0B;;;;CAK1B,YAAyB;;;;CAKzB,YAAyB;CAEzB,YAAY,UAAyB,CAAC,GAAG;EACvC,MAAM,OAAO;EACb,IAAI,QAAQ,WAAW,KAAK,YAAY,QAAQ;EAChD,IAAI,QAAQ,MAAM,KAAK,OAAO,QAAQ;EACtC,IAAI,QAAQ,QAAQ,KAAK,SAAS,QAAQ;EAC1C,IAAI,QAAQ,cAAc,KAAA,GAAW,KAAK,YAAY,QAAQ;CAChE;;;;CAKA,MAAM,aAAsC;EAC1C,OAAQ,MAAM,KAAK,WAAW,WAAW;CAC3C;;;;CAKA,UAAmB;EACjB,IAAI,KAAK,WAAW,OAAO;EAC3B,IAAI,KAAK,aAAa,KAAK,4BAAY,IAAI,KAAK,GAAG,OAAO;EAC1D,OAAO;CACT;;;;CAKA,SAAS,OAAwB;EAC/B,OAAO,KAAK,OAAO,SAAS,KAAK,KAAK,KAAK,OAAO,SAAS,GAAG;CAChE;;;;CAKA,MAAM,SAAwB;EAC5B,KAAK,4BAAY,IAAI,KAAK;EAC1B,MAAM,KAAK,KAAK;CAClB;;;;CAKA,MAAM,cAA6B;EACjC,KAAA,IAAS,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG;GAC/C,IAAI,KAAK,aAAa,MAAM,KAAK,WAAW;GAC5C,IAAI,CAAC,KAAK,QAAQ,GAAG;GACrB,KAAK,6BAAa,IAAI,KAAK;GAC3B,IAAI;IACF,MAAM,KAAK,KAAK;IAChB;GACF,SAAS,OAAO;IACd,IACE,YAAY,KACZ,EACE,iB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M,EAAE,SAAS,KAAK,CAAC,CAAA,GAbb,OAcX,WAAA,WAAA,CAAA;AAdW,SAAN,gBAAA,CAVN,KAAK;CACJ,WAAW;CAEX,WAAW;CACX,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAChC,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAGhC,KAAK;EAAE,SAAS;GAAC;GAAQ;GAAO;GAAU;EAAQ;EAAG,cAAc;CAAK;AAC1E,CAAC,CAAA,GACY,MAAA"}
@@ -1,5 +1,5 @@
1
- import { y as __exportAll } from "./NostrIdentity-AC8fAdxe.js";
2
- import { t as ApiKey } from "./ApiKey-CVmlf3V6.js";
1
+ import { y as __exportAll } from "./NostrIdentity-RJaATTCt.js";
2
+ import { t as ApiKey } from "./ApiKey-9YuYcpWy.js";
3
3
  import { SmrtCollection } from "@happyvertical/smrt-core";
4
4
  //#region src/collections/ApiKeyCollection.ts
5
5
  var ApiKeyCollection_exports = /* @__PURE__ */ __exportAll({ ApiKeyCollection: () => ApiKeyCollection });
@@ -81,4 +81,4 @@ var ApiKeyCollection = class extends SmrtCollection {
81
81
  //#endregion
82
82
  export { ApiKeyCollection_exports as n, ApiKeyCollection as t };
83
83
 
84
- //# sourceMappingURL=ApiKeyCollection-CiiDNFdD.js.map
84
+ //# sourceMappingURL=ApiKeyCollection-BrJT9vo_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApiKeyCollection-CiiDNFdD.js","names":[],"sources":["../../src/collections/ApiKeyCollection.ts"],"sourcesContent":["/**\n * ApiKeyCollection - Collection for managing API keys\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { ApiKey, type GenerateKeyResult } from '../models/ApiKey';\nimport type { Profile } from '../models/Profile';\n\nexport class ApiKeyCollection extends SmrtCollection<ApiKey> {\n static readonly _itemClass = ApiKey;\n\n /**\n * Find all keys for a profile\n */\n async findByProfile(profileId: string): Promise<ApiKey[]> {\n return await this.list({\n where: { profileId },\n });\n }\n\n /**\n * Find active (non-revoked, non-expired) keys for a profile\n */\n async findActiveByProfile(profileId: string): Promise<ApiKey[]> {\n const keys = await this.findByProfile(profileId);\n return keys.filter((key) => key.isValid());\n }\n\n /**\n * Find key by hash\n */\n async findByHash(keyHash: string): Promise<ApiKey | null> {\n return await this.findOne({\n where: { keyHash },\n });\n }\n\n /**\n * Verify an API key string and return the record if valid\n */\n async verify(key: string): Promise<ApiKey | null> {\n const keyHash = ApiKey.hashKey(key);\n const apiKey = await this.findByHash(keyHash);\n\n if (!apiKey) return null;\n if (!apiKey.isValid()) return null;\n\n // Record usage\n await apiKey.recordUsage();\n\n // recordUsage() reloads after a concurrent-write conflict. A revocation\n // observed by that reload must fail this authentication attempt closed.\n if (!apiKey.isValid()) return null;\n\n return apiKey;\n }\n\n /**\n * Generate a new key for a profile\n */\n async generateForProfile(\n profile: Profile,\n options: {\n name: string;\n scopes?: string[];\n expiresAt?: Date | null;\n },\n ): Promise<GenerateKeyResult> {\n return await ApiKey.generate(profile, {\n ...options,\n db: this.options.db,\n });\n }\n\n /**\n * Revoke all keys for a profile\n */\n async revokeAllForProfile(profileId: string): Promise<number> {\n const keys = await this.findActiveByProfile(profileId);\n for (const key of keys) {\n await key.revoke();\n }\n return keys.length;\n }\n\n /**\n * Revoke a specific key by prefix\n */\n async revokeByPrefix(keyPrefix: string): Promise<boolean> {\n const key = await this.findOne({\n where: { keyPrefix },\n });\n\n if (key?.isValid()) {\n await key.revoke();\n return true;\n }\n return false;\n }\n\n /**\n * Clean up expired keys (soft delete by setting revokedAt)\n */\n async cleanupExpired(): Promise<number> {\n const now = new Date();\n const allKeys = await this.list({});\n let cleaned = 0;\n\n for (const key of allKeys) {\n if (key.expiresAt && key.expiresAt < now && !key.revokedAt) {\n key.revokedAt = now;\n await key.save();\n cleaned++;\n }\n }\n\n return cleaned;\n }\n}\n"],"mappings":";;;;;AAQO,IAAM,mBAAN,cAA+B,eAAuB;CAC3D,OAAgB,aAAa;;;;CAK7B,MA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O,CAAC,IAAI,WAAW;GAC1D,IAAI,YAAY;GAChB,MAAM,IAAI,KAAK;GACf;EACF;EAGF,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"ApiKeyCollection-BrJT9vo_.js","names":[],"sources":["../../src/collections/ApiKeyCollection.ts"],"sourcesContent":["/**\n * ApiKeyCollection - Collection for managing API keys\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { ApiKey, type GenerateKeyResult } from '../models/ApiKey';\nimport type { Profile } from '../models/Profile';\n\nexport class ApiKeyCollection extends SmrtCollection<ApiKey> {\n static readonly _itemClass = ApiKey;\n\n /**\n * Find all keys for a profile\n */\n async findByProfile(profileId: string): Promise<ApiKey[]> {\n return await this.list({\n where: { profileId },\n });\n }\n\n /**\n * Find active (non-revoked, non-expired) keys for a profile\n */\n async findActiveByProfile(profileId: string): Promise<ApiKey[]> {\n const keys = await this.findByProfile(profileId);\n return keys.filter((key) => key.isValid());\n }\n\n /**\n * Find key by hash\n */\n async findByHash(keyHash: string): Promise<ApiKey | null> {\n return await this.findOne({\n where: { keyHash },\n });\n }\n\n /**\n * Verify an API key string and return the record if valid\n */\n async verify(key: string): Promise<ApiKey | null> {\n const keyHash = ApiKey.hashKey(key);\n const apiKey = await this.findByHash(keyHash);\n\n if (!apiKey) return null;\n if (!apiKey.isValid()) return null;\n\n // Record usage\n await apiKey.recordUsage();\n\n // recordUsage() reloads after a concurrent-write conflict. A revocation\n // observed by that reload must fail this authentication attempt closed.\n if (!apiKey.isValid()) return null;\n\n return apiKey;\n }\n\n /**\n * Generate a new key for a profile\n */\n async generateForProfile(\n profile: Profile,\n options: {\n name: string;\n scopes?: string[];\n expiresAt?: Date | null;\n },\n ): Promise<GenerateKeyResult> {\n return await ApiKey.generate(profile, {\n ...options,\n db: this.options.db,\n });\n }\n\n /**\n * Revoke all keys for a profile\n */\n async revokeAllForProfile(profileId: string): Promise<number> {\n const keys = await this.findActiveByProfile(profileId);\n for (const key of keys) {\n await key.revoke();\n }\n return keys.length;\n }\n\n /**\n * Revoke a specific key by prefix\n */\n async revokeByPrefix(keyPrefix: string): Promise<boolean> {\n const key = await this.findOne({\n where: { keyPrefix },\n });\n\n if (key?.isValid()) {\n await key.revoke();\n return true;\n }\n return false;\n }\n\n /**\n * Clean up expired keys (soft delete by setting revokedAt)\n */\n async cleanupExpired(): Promise<number> {\n const now = new Date();\n const allKeys = await this.list({});\n let cleaned = 0;\n\n for (const key of allKeys) {\n if (key.expiresAt && key.expiresAt < now && !key.revokedAt) {\n key.revokedAt = now;\n await key.save();\n cleaned++;\n }\n }\n\n return cleaned;\n }\n}\n"],"mappings":";;;;;AAQO,IAAM,mBAAN,cAA+B,eAAuB;CAC3D,OAAgB,aAAa;;;;CAK7B,MAAM,cAAc,WAAsC;EACxD,OAAO,MAAM,KAAK,KAAK,EACrB,OAAO,EAAE,UAAU,EACrB,CAAC;CACH;;;;CAKA,MAAM,oBAAoB,WAAsC;EAE9D,QAAO,MADY,KAAK,cAAc,SAAS,EAAA,CACnC,QAAQ,QAAQ,IAAI,QAAQ,CAAC;CAC3C;;;;CAKA,MAAM,WAAW,SAAyC;EACxD,OAAO,MAAM,KAAK,QAAQ,EACxB,OAAO,EAAE,QAAQ,EACnB,CAAC;CACH;;;;CAKA,MAAM,OAAO,KAAqC;EAChD,MAAM,UAAU,OAAO,QAAQ,GAAG;EAClC,MAAM,SAAS,MAAM,KAAK,WAAW,OAAO;EAE5C,IAAI,CAAC,QAAQ,OAAO;EACpB,IAAI,CAAC,OAAO,QAAQ,GAAG,OAAO;EAG9B,MAAM,OAAO,YAAY;EAIzB,IAAI,CAAC,OAAO,QAAQ,GAAG,OAAO;EAE9B,OAAO;CACT;;;;CAKA,MAAM,mBACJ,SACA,SAK4B;EAC5B,OAAO,MAAM,OAAO,SAAS,SAAS;GACpC,GAAG;GACH,IAAI,KAAK,QAAQ;EACnB,CAAC;CACH;;;;CAKA,MAAM,oBAAoB,WAAoC;EAC5D,MAAM,OAAO,MAAM,KAAK,oBAAoB,SAAS;EACrD,KAAA,MAAW,OAAO,MAChB,MAAM,IAAI,OAAO;EAEnB,OAAO,KAAK;CACd;;;;CAKA,MAAM,eAAe,WAAqC;EACxD,MAAM,MAAM,MAAM,KAAK,QAAQ,EAC7B,OAAO,EAAE,UAAU,EACrB,CAAC;EAED,IAAI,KAAK,QAAQ,GAAG;GAClB,MAAM,IAAI,OAAO;GACjB,OAAO;EACT;EACA,OAAO;CACT;;;;CAKA,MAAM,iBAAkC;EACtC,MAAM,sBAAM,IAAI,KAAK;EACrB,MAAM,UAAU,MAAM,KAAK,KAAK,CAAC,CAAC;EAClC,IAAI,UAAU;EAEd,KAAA,MAAW,OAAO,SAChB,IAAI,IAAI,aAAa,IAAI,YAAY,OAAO,CAAC,IAAI,WAAW;GAC1D,IAAI,YAAY;GAChB,MAAM,IAAI,KAAK;GACf;EACF;EAGF,OAAO;CACT;AACF"}
@@ -1,4 +1,4 @@
1
- import { y as __exportAll } from "./NostrIdentity-AC8fAdxe.js";
1
+ import { y as __exportAll } from "./NostrIdentity-RJaATTCt.js";
2
2
  import { SmrtCollection, SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
3
3
  import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
4
4
  //#region src/models/AuditLog.ts
@@ -206,4 +206,4 @@ var AuditLogCollection = class extends SmrtCollection {
206
206
  //#endregion
207
207
  export { AuditLogCollection_exports as n, AuditLog as r, AuditLogCollection as t };
208
208
 
209
- //# sourceMappingURL=AuditLogCollection-WDHL-_AF.js.map
209
+ //# sourceMappingURL=AuditLogCollection-BBbvr8Qc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuditLogCollection-WDHL-_AF.js","names":[],"sources":["../../src/models/AuditLog.ts","../../src/collections/AuditLogCollection.ts"],"sourcesContent":["/**\n * AuditLog - Tracks all actions for full audit trail\n *\n * Records who did what, when, and how (web, CLI, CI, webhook, MCP).\n * Supports pass-through identity for CI workflows.\n */\n\nimport {\n type AuditChange,\n field,\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport type { Profile } from './Profile';\n\nexport type AuditSource = 'web' | 'cli' | 'ci' | 'webhook' | 'mcp';\n\nexport interface AuditLogOptions extends SmrtObjectOptions {\n profileId?: string;\n action?: string;\n resourceType?: string;\n resourceId?: string;\n source?: AuditSource;\n metadata?: Record<string, unknown>;\n onBehalfOfId?: string | null;\n tenantId?: string | null;\n reason?: string;\n changes?: Record<string, AuditChange>;\n}\n\n@TenantScoped({ mode: 'optional', allowSuperAdminBypass: true })\n@smrt({\n tableName: 'audit_logs',\n sensitive: true,\n api: false,\n mcp: false,\n cli: false,\n})\nexport class AuditLog extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-profiles\";\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * The profile who performed the action\n */\n @foreignKey('Profile', { required: true })\n profileId?: string;\n\n /**\n * Action performed (e.g., 'issue.update', 'feedback.incorporate')\n */\n action: string = '';\n\n /** Optional explanation supplied by the caller. */\n reason: string = '';\n\n /** Public field changes only; sensitive values must never be supplied. */\n changes: Record<string, AuditChange> = {};\n\n /**\n * Type of resource affected (e.g., 'Issue', 'Repository')\n */\n @field({ indexed: true })\n resourceType: string = '';\n\n /**\n * ID of the affected resource\n */\n @field({ indexed: true })\n resourceId: string = '';\n\n /** Indexed retention/read timestamp independent of framework revision time. */\n @field({ indexed: true, default: 'current_timestamp' })\n occurredAt: Date = new Date();\n\n /**\n * Source of the action\n */\n source: AuditSource = 'web';\n\n /**\n * Additional context (CI run ID, request ID, etc.)\n */\n metadata: Record<string, unknown> = {};\n\n /**\n * For pass-through identity in CI - the actual person who triggered\n */\n @foreignKey('Profile', { nullable: true })\n onBehalfOfId?: string | null;\n\n constructor(options: AuditLogOptions = {}) {\n super(options);\n if (options.profileId) this.profileId = options.profileId;\n if (options.action) this.action = options.action;\n if (options.reason !== undefined) this.reason = options.reason;\n if (options.changes !== undefined) this.changes = options.changes;\n if (options.resourceType) this.resourceType = options.resourceType;\n if (options.resourceId) this.resourceId = options.resourceId;\n if (options.source) this.source = options.source;\n if (options.metadata) this.metadata = options.metadata;\n if (options.onBehalfOfId !== undefined)\n this.onBehalfOfId = options.onBehalfOfId;\n }\n\n /**\n * Get the profile who performed the action\n */\n async getProfile(): Promise<Profile | null> {\n return (await this.getRelated('profileId')) as Profile | null;\n }\n\n /**\n * Get the profile on whose behalf the action was performed (if any)\n */\n async getOnBehalfOf(): Promise<Profile | null> {\n if (!this.onBehalfOfId) return null;\n return (await this.getRelated('onBehalfOfId')) as Profile | null;\n }\n\n /**\n * Get the effective actor (onBehalfOf if set, otherwise profile)\n */\n async getEffectiveActor(): Promise<Profile | null> {\n const onBehalfOf = await this.getOnBehalfOf();\n if (onBehalfOf) return onBehalfOf;\n return await this.getProfile();\n }\n\n /**\n * Create an audit log entry\n */\n static async record(\n options: AuditLogOptions & {\n profile: Profile;\n onBehalfOf?: Profile | null;\n },\n ): Promise<AuditLog> {\n const log = new AuditLog({\n ...options,\n profileId: options.profile.id as string,\n onBehalfOfId: options.onBehalfOf?.id as string | undefined,\n });\n await log.initialize();\n await log.save();\n return log;\n }\n}\n","/**\n * AuditLogCollection - Collection for querying audit logs\n */\n\nimport { type AuditChange, SmrtCollection } from '@happyvertical/smrt-core';\nimport { AuditLog, type AuditSource } from '../models/AuditLog';\nimport type { Profile } from '../models/Profile';\n\nexport class AuditLogCollection extends SmrtCollection<AuditLog> {\n static readonly _itemClass = AuditLog;\n\n /**\n * Find logs for a profile (actions they performed)\n */\n async findByProfile(profileId: string): Promise<AuditLog[]> {\n return await this.list({\n where: { profileId },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs for a resource\n */\n async findByResource(\n resourceType: string,\n resourceId: string,\n ): Promise<AuditLog[]> {\n return await this.list({\n where: { resourceType, resourceId },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs by action type\n */\n async findByAction(action: string): Promise<AuditLog[]> {\n return await this.list({\n where: { action },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs by source\n */\n async findBySource(source: AuditSource): Promise<AuditLog[]> {\n return await this.list({\n where: { source },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs where actions were performed on behalf of someone\n */\n async findOnBehalfOf(profileId: string): Promise<AuditLog[]> {\n return await this.list({\n where: { onBehalfOfId: profileId },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Record a new audit log entry\n */\n async record(options: {\n profile: Profile;\n action: string;\n resourceType: string;\n resourceId: string;\n source?: AuditSource;\n metadata?: Record<string, unknown>;\n onBehalfOf?: Profile | null;\n reason?: string;\n changes?: Record<string, AuditChange>;\n }): Promise<AuditLog> {\n const log = new AuditLog({\n ...this.options,\n profileId: options.profile.id as string,\n action: options.action,\n reason: options.reason,\n changes: options.changes,\n resourceType: options.resourceType,\n resourceId: options.resourceId,\n source: options.source || 'web',\n metadata: options.metadata || {},\n onBehalfOfId: options.onBehalfOf?.id as string | undefined,\n });\n await log.initialize();\n await log.save();\n return log;\n }\n\n /**\n * Get recent activity for a profile\n */\n async getRecentActivity(\n profileId: string,\n limit: number = 50,\n ): Promise<AuditLog[]> {\n return await this.list({\n where: { profileId },\n orderBy: 'createdAt DESC',\n limit,\n });\n }\n\n /**\n * Get activity timeline for a resource\n */\n async getResourceTimeline(\n resourceType: string,\n resourceId: string,\n ): Promise<AuditLog[]> {\n return await this.list({\n where: { resourceType, resourceId },\n orderBy: 'createdAt ASC',\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCO,IAAM,WAAN,cAAuB,WAAW;CAEvC,WAA0B;CAM1B;;;;CAKA,SAAiB;;CAGjB,SAAiB;;CAGjB,UAAuC,CAAC;CAMxC,eAAuB;CAMvB,aAAqB;CAIrB,6BAAmB,IAAI,KAAK;;;;CAK5B,SAAsB;;;;CAKtB,WAA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vB,GAAG,KAAK;GACR,WAAW,QAAQ,QAAQ;GAC3B,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;GAChB,SAAS,QAAQ;GACjB,cAAc,QAAQ;GACtB,YAAY,QAAQ;GACpB,QAAQ,QAAQ,UAAU;GAC1B,UAAU,QAAQ,YAAY,CAAC;GAC/B,cAAc,QAAQ,YAAY;EACpC,CAAC;EACD,MAAM,IAAI,WAAW;EACrB,MAAM,IAAI,KAAK;EACf,OAAO;CACT;;;;CAKA,MAAM,kBACJ,WACA,QAAgB,IACK;EACrB,OAAO,MAAM,KAAK,KAAK;GACrB,OAAO,EAAE,UAAU;GACnB,SAAS;GACT;EACF,CAAC;CACH;;;;CAKA,MAAM,oBACJ,cACA,YACqB;EACrB,OAAO,MAAM,KAAK,KAAK;GACrB,OAAO;IAAE;IAAc;GAAW;GAClC,SAAS;EACX,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"AuditLogCollection-BBbvr8Qc.js","names":[],"sources":["../../src/models/AuditLog.ts","../../src/collections/AuditLogCollection.ts"],"sourcesContent":["/**\n * AuditLog - Tracks all actions for full audit trail\n *\n * Records who did what, when, and how (web, CLI, CI, webhook, MCP).\n * Supports pass-through identity for CI workflows.\n */\n\nimport {\n type AuditChange,\n field,\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport type { Profile } from './Profile';\n\nexport type AuditSource = 'web' | 'cli' | 'ci' | 'webhook' | 'mcp';\n\nexport interface AuditLogOptions extends SmrtObjectOptions {\n profileId?: string;\n action?: string;\n resourceType?: string;\n resourceId?: string;\n source?: AuditSource;\n metadata?: Record<string, unknown>;\n onBehalfOfId?: string | null;\n tenantId?: string | null;\n reason?: string;\n changes?: Record<string, AuditChange>;\n}\n\n@TenantScoped({ mode: 'optional', allowSuperAdminBypass: true })\n@smrt({\n tableName: 'audit_logs',\n sensitive: true,\n api: false,\n mcp: false,\n cli: false,\n})\nexport class AuditLog extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-profiles\";\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * The profile who performed the action\n */\n @foreignKey('Profile', { required: true })\n profileId?: string;\n\n /**\n * Action performed (e.g., 'issue.update', 'feedback.incorporate')\n */\n action: string = '';\n\n /** Optional explanation supplied by the caller. */\n reason: string = '';\n\n /** Public field changes only; sensitive values must never be supplied. */\n changes: Record<string, AuditChange> = {};\n\n /**\n * Type of resource affected (e.g., 'Issue', 'Repository')\n */\n @field({ indexed: true })\n resourceType: string = '';\n\n /**\n * ID of the affected resource\n */\n @field({ indexed: true })\n resourceId: string = '';\n\n /** Indexed retention/read timestamp independent of framework revision time. */\n @field({ indexed: true, default: 'current_timestamp' })\n occurredAt: Date = new Date();\n\n /**\n * Source of the action\n */\n source: AuditSource = 'web';\n\n /**\n * Additional context (CI run ID, request ID, etc.)\n */\n metadata: Record<string, unknown> = {};\n\n /**\n * For pass-through identity in CI - the actual person who triggered\n */\n @foreignKey('Profile', { nullable: true })\n onBehalfOfId?: string | null;\n\n constructor(options: AuditLogOptions = {}) {\n super(options);\n if (options.profileId) this.profileId = options.profileId;\n if (options.action) this.action = options.action;\n if (options.reason !== undefined) this.reason = options.reason;\n if (options.changes !== undefined) this.changes = options.changes;\n if (options.resourceType) this.resourceType = options.resourceType;\n if (options.resourceId) this.resourceId = options.resourceId;\n if (options.source) this.source = options.source;\n if (options.metadata) this.metadata = options.metadata;\n if (options.onBehalfOfId !== undefined)\n this.onBehalfOfId = options.onBehalfOfId;\n }\n\n /**\n * Get the profile who performed the action\n */\n async getProfile(): Promise<Profile | null> {\n return (await this.getRelated('profileId')) as Profile | null;\n }\n\n /**\n * Get the profile on whose behalf the action was performed (if any)\n */\n async getOnBehalfOf(): Promise<Profile | null> {\n if (!this.onBehalfOfId) return null;\n return (await this.getRelated('onBehalfOfId')) as Profile | null;\n }\n\n /**\n * Get the effective actor (onBehalfOf if set, otherwise profile)\n */\n async getEffectiveActor(): Promise<Profile | null> {\n const onBehalfOf = await this.getOnBehalfOf();\n if (onBehalfOf) return onBehalfOf;\n return await this.getProfile();\n }\n\n /**\n * Create an audit log entry\n */\n static async record(\n options: AuditLogOptions & {\n profile: Profile;\n onBehalfOf?: Profile | null;\n },\n ): Promise<AuditLog> {\n const log = new AuditLog({\n ...options,\n profileId: options.profile.id as string,\n onBehalfOfId: options.onBehalfOf?.id as string | undefined,\n });\n await log.initialize();\n await log.save();\n return log;\n }\n}\n","/**\n * AuditLogCollection - Collection for querying audit logs\n */\n\nimport { type AuditChange, SmrtCollection } from '@happyvertical/smrt-core';\nimport { AuditLog, type AuditSource } from '../models/AuditLog';\nimport type { Profile } from '../models/Profile';\n\nexport class AuditLogCollection extends SmrtCollection<AuditLog> {\n static readonly _itemClass = AuditLog;\n\n /**\n * Find logs for a profile (actions they performed)\n */\n async findByProfile(profileId: string): Promise<AuditLog[]> {\n return await this.list({\n where: { profileId },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs for a resource\n */\n async findByResource(\n resourceType: string,\n resourceId: string,\n ): Promise<AuditLog[]> {\n return await this.list({\n where: { resourceType, resourceId },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs by action type\n */\n async findByAction(action: string): Promise<AuditLog[]> {\n return await this.list({\n where: { action },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs by source\n */\n async findBySource(source: AuditSource): Promise<AuditLog[]> {\n return await this.list({\n where: { source },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Find logs where actions were performed on behalf of someone\n */\n async findOnBehalfOf(profileId: string): Promise<AuditLog[]> {\n return await this.list({\n where: { onBehalfOfId: profileId },\n orderBy: 'createdAt DESC',\n });\n }\n\n /**\n * Record a new audit log entry\n */\n async record(options: {\n profile: Profile;\n action: string;\n resourceType: string;\n resourceId: string;\n source?: AuditSource;\n metadata?: Record<string, unknown>;\n onBehalfOf?: Profile | null;\n reason?: string;\n changes?: Record<string, AuditChange>;\n }): Promise<AuditLog> {\n const log = new AuditLog({\n ...this.options,\n profileId: options.profile.id as string,\n action: options.action,\n reason: options.reason,\n changes: options.changes,\n resourceType: options.resourceType,\n resourceId: options.resourceId,\n source: options.source || 'web',\n metadata: options.metadata || {},\n onBehalfOfId: options.onBehalfOf?.id as string | undefined,\n });\n await log.initialize();\n await log.save();\n return log;\n }\n\n /**\n * Get recent activity for a profile\n */\n async getRecentActivity(\n profileId: string,\n limit: number = 50,\n ): Promise<AuditLog[]> {\n return await this.list({\n where: { profileId },\n orderBy: 'createdAt DESC',\n limit,\n });\n }\n\n /**\n * Get activity timeline for a resource\n */\n async getResourceTimeline(\n resourceType: string,\n resourceId: string,\n ): Promise<AuditLog[]> {\n return await this.list({\n where: { resourceType, resourceId },\n orderBy: 'createdAt ASC',\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCO,IAAM,WAAN,cAAuB,WAAW;CAEvC,WAA0B;CAM1B;;;;CAKA,SAAiB;;CAGjB,SAAiB;;CAGjB,UAAuC,CAAC;CAMxC,eAAuB;CAMvB,aAAqB;CAIrB,6BAAmB,IAAI,KAAK;;;;CAK5B,SAAsB;;;;CAKtB,WAAoC,CAAC;CAMrC;CAEA,YAAY,UAA2B,CAAC,GAAG;EACzC,MAAM,OAAO;EACb,IAAI,QAAQ,WAAW,KAAK,YAAY,QAAQ;EAChD,IAAI,QAAQ,QAAQ,KAAK,SAAS,QAAQ;EAC1C,IAAI,QAAQ,WAAW,KAAA,GAAW,KAAK,SAAS,QAAQ;EACxD,IAAI,QAAQ,YAAY,KAAA,GAAW,KAAK,UAAU,QAAQ;EAC1D,IAAI,QAAQ,cAAc,KAAK,eAAe,QAAQ;EACtD,IAAI,QAAQ,YAAY,KAAK,aAAa,QAAQ;EAClD,IAAI,QAAQ,QAAQ,KAAK,SAAS,QAAQ;EAC1C,IAAI,QAAQ,UAAU,KAAK,WAAW,QAAQ;EAC9C,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B;EACrB,OAAO,MAAM,KAAK,KAAK;GACrB,OAAO;IAAE;IAAc;GAAW;GAClC,SAAS;EACX,CAAC;CACH;AACF"}
@@ -1292,10 +1292,17 @@ function validateObject(object, fields = {}, optFields = {}, title = "object") {
1292
1292
  * @module
1293
1293
  */
1294
1294
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1295
- var _0n$4 = /* @__PURE__ */ BigInt(0), _1n$2 = /* @__PURE__ */ BigInt(1), _2n$2 = /* @__PURE__ */ BigInt(2);
1296
- var _3n$1 = /* @__PURE__ */ BigInt(3), _4n$2 = /* @__PURE__ */ BigInt(4), _5n = /* @__PURE__ */ BigInt(5);
1297
- var _7n = /* @__PURE__ */ BigInt(7), _8n = /* @__PURE__ */ BigInt(8), _9n = /* @__PURE__ */ BigInt(9);
1298
- var _15n = /* @__PURE__ */ BigInt(15), _16n = /* @__PURE__ */ BigInt(16);
1295
+ var _0n$4 = /* @__PURE__ */ BigInt(0);
1296
+ var _1n$2 = /* @__PURE__ */ BigInt(1);
1297
+ var _2n$2 = /* @__PURE__ */ BigInt(2);
1298
+ var _3n$1 = /* @__PURE__ */ BigInt(3);
1299
+ var _4n$2 = /* @__PURE__ */ BigInt(4);
1300
+ var _5n = /* @__PURE__ */ BigInt(5);
1301
+ var _7n = /* @__PURE__ */ BigInt(7);
1302
+ var _8n = /* @__PURE__ */ BigInt(8);
1303
+ var _9n = /* @__PURE__ */ BigInt(9);
1304
+ var _15n = /* @__PURE__ */ BigInt(15);
1305
+ var _16n = /* @__PURE__ */ BigInt(16);
1299
1306
  var POW_WINDOWED_MIN = /* @__PURE__ */ BigInt("0x10000000000000000");
1300
1307
  /**
1301
1308
  * @param a - Dividend value.
@@ -2749,7 +2756,11 @@ function validateSigOpts(opts, def) {
2749
2756
  if (optsn.format !== void 0) validateSigFormat(optsn.format);
2750
2757
  return optsn;
2751
2758
  }
2752
- var _0n$1 = /* @__PURE__ */ BigInt(0), _1n = /* @__PURE__ */ BigInt(1), _2n$1 = /* @__PURE__ */ BigInt(2), _3n = /* @__PURE__ */ BigInt(3), _4n = /* @__PURE__ */ BigInt(4);
2759
+ var _0n$1 = /* @__PURE__ */ BigInt(0);
2760
+ var _1n = /* @__PURE__ */ BigInt(1);
2761
+ var _2n$1 = /* @__PURE__ */ BigInt(2);
2762
+ var _3n = /* @__PURE__ */ BigInt(3);
2763
+ var _4n = /* @__PURE__ */ BigInt(4);
2753
2764
  /**
2754
2765
  * Creates weierstrass Point constructor, based on specified curve options.
2755
2766
  *
@@ -4192,21 +4203,21 @@ var NostrIdentity = class extends SmrtObject {
4192
4203
  * Find identity by public key
4193
4204
  */
4194
4205
  static async findByPubkey(pubkey, options = {}) {
4195
- const { NostrIdentityCollection } = await import("./NostrIdentityCollection-CctlECpX.js").then((n) => n.n);
4206
+ const { NostrIdentityCollection } = await import("./NostrIdentityCollection-BPNgPOBE.js").then((n) => n.n);
4196
4207
  return await (await NostrIdentityCollection.create(options)).findOne({ where: { pubkey } });
4197
4208
  }
4198
4209
  /**
4199
4210
  * Find identity by email
4200
4211
  */
4201
4212
  static async findByEmail(email, options = {}) {
4202
- const { NostrIdentityCollection } = await import("./NostrIdentityCollection-CctlECpX.js").then((n) => n.n);
4213
+ const { NostrIdentityCollection } = await import("./NostrIdentityCollection-BPNgPOBE.js").then((n) => n.n);
4203
4214
  return await (await NostrIdentityCollection.create(options)).findOne({ where: { email: email.toLowerCase() } });
4204
4215
  }
4205
4216
  /**
4206
4217
  * Find identity by NIP-05 username
4207
4218
  */
4208
4219
  static async findByNip05(username, options = {}) {
4209
- const { NostrIdentityCollection } = await import("./NostrIdentityCollection-CctlECpX.js").then((n) => n.n);
4220
+ const { NostrIdentityCollection } = await import("./NostrIdentityCollection-BPNgPOBE.js").then((n) => n.n);
4210
4221
  return await (await NostrIdentityCollection.create(options)).findOne({ where: { nip05Username: username.toLowerCase() } });
4211
4222
  }
4212
4223
  /**
@@ -4284,4 +4295,4 @@ NostrIdentity = __decorateClass([smrt({
4284
4295
  //#endregion
4285
4296
  export { verifyAuthEvent as _, decryptPrivkey as a, generateNostrKeypair as c, isValidPubkey as d, npubToPubkey as f, signEvent as g, pubkeyToNpub as h, createAuthEvent as i, getPublicKey as l, privkeyToNsec as m, NostrIdentity_exports as n, deriveEncryptionKey as o, nsecToPrivkey as p, computeEventId as r, encryptPrivkey as s, NostrIdentity as t, isValidPrivkey as u, verifyNostrSignature as v, __exportAll as y };
4286
4297
 
4287
- //# sourceMappingURL=NostrIdentity-AC8fAdxe.js.map
4298
+ //# sourceMappingURL=NostrIdentity-RJaATTCt.js.map