@happyvertical/smrt-profiles 0.61.3 → 0.61.5
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/dist/audit-trail.d.ts +1 -1
- package/dist/audit-trail.d.ts.map +1 -1
- package/dist/auth/magicLinkService.d.ts +1 -1
- package/dist/auth/magicLinkService.d.ts.map +1 -1
- package/dist/auth/oidcProvisioningPrimitives.d.ts.map +1 -1
- package/dist/auth/resolveIdentity.d.ts.map +1 -1
- package/dist/chunks/{ApiKey-9YuYcpWy.js → ApiKey-BhseCX_J.js} +9 -6
- package/dist/chunks/ApiKey-BhseCX_J.js.map +1 -0
- package/dist/chunks/{ApiKeyCollection-BrJT9vo_.js → ApiKeyCollection-BK2Wn-wa.js} +3 -3
- package/dist/chunks/{ApiKeyCollection-BrJT9vo_.js.map → ApiKeyCollection-BK2Wn-wa.js.map} +1 -1
- package/dist/chunks/{AuditLogCollection-BBbvr8Qc.js → AuditLogCollection-NYUFFPni.js} +9 -9
- package/dist/chunks/AuditLogCollection-NYUFFPni.js.map +1 -0
- package/dist/chunks/{NostrIdentity-RJaATTCt.js → NostrIdentity-joAS5ZlD.js} +8 -5
- package/dist/chunks/{NostrIdentity-RJaATTCt.js.map → NostrIdentity-joAS5ZlD.js.map} +1 -1
- package/dist/chunks/{NostrIdentityCollection-BPNgPOBE.js → NostrIdentityCollection-B9G_vrWL.js} +4 -10
- package/dist/chunks/{NostrIdentityCollection-BPNgPOBE.js.map → NostrIdentityCollection-B9G_vrWL.js.map} +1 -1
- package/dist/chunks/{OidcIdentity-CFsyI8H1.js → OidcIdentity-uX-K-vHR.js} +7 -4
- package/dist/chunks/OidcIdentity-uX-K-vHR.js.map +1 -0
- package/dist/chunks/{OidcIdentityCollection-SMH6SHxF.js → OidcIdentityCollection-CwgUAk_O.js} +3 -3
- package/dist/chunks/{OidcIdentityCollection-SMH6SHxF.js.map → OidcIdentityCollection-CwgUAk_O.js.map} +1 -1
- package/dist/chunks/{ProfileAssetCollection-2Jhy3vhC.js → ProfileAssetCollection-CkzuPlWl.js} +5 -3
- package/dist/chunks/ProfileAssetCollection-CkzuPlWl.js.map +1 -0
- package/dist/chunks/{ProfileCollection-5UJJmUW5.js → ProfileCollection-5Ams2c-J.js} +36 -31
- package/dist/chunks/ProfileCollection-5Ams2c-J.js.map +1 -0
- package/dist/chunks/{ProfileLinkCollection-D9rfzly5.js → ProfileLinkCollection-Cl9rY_U_.js} +5 -3
- package/dist/chunks/ProfileLinkCollection-Cl9rY_U_.js.map +1 -0
- package/dist/chunks/{ProfileMetadataCollection-CAgJyjze.js → ProfileMetadataCollection-BStSVlUX.js} +11 -5
- package/dist/chunks/ProfileMetadataCollection-BStSVlUX.js.map +1 -0
- package/dist/chunks/{ProfileMetafieldCollection-19ae6Lpf.js → ProfileMetafieldCollection-DCZi2Ba1.js} +3 -3
- package/dist/chunks/ProfileMetafieldCollection-DCZi2Ba1.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipCollection-BFSlTQ7J.js → ProfileRelationshipCollection-Cat8A3R3.js} +17 -8
- package/dist/chunks/ProfileRelationshipCollection-Cat8A3R3.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipTermCollection-OluL8BGP.js → ProfileRelationshipTermCollection-CInZSL7B.js} +6 -3
- package/dist/chunks/ProfileRelationshipTermCollection-CInZSL7B.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipType-Cevy-vaF.js → ProfileRelationshipType-tp6iZQVQ.js} +3 -3
- package/dist/chunks/ProfileRelationshipType-tp6iZQVQ.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipTypeCollection-BRBpX00F.js → ProfileRelationshipTypeCollection-Dkb0nsnt.js} +3 -3
- package/dist/chunks/{ProfileRelationshipTypeCollection-BRBpX00F.js.map → ProfileRelationshipTypeCollection-Dkb0nsnt.js.map} +1 -1
- package/dist/chunks/{ProfileTypeCollection-DYA74l6-.js → ProfileTypeCollection-2fjo--pR.js} +3 -3
- package/dist/chunks/{ProfileTypeCollection-DYA74l6-.js.map → ProfileTypeCollection-2fjo--pR.js.map} +1 -1
- package/dist/chunks/{oidcProvisioningPrimitives-iQUIWC7F.js → oidcProvisioningPrimitives-ChynZ3aX.js} +8 -8
- package/dist/chunks/oidcProvisioningPrimitives-ChynZ3aX.js.map +1 -0
- package/dist/chunks/{resolveIdentity-CT1tK-Kn.js → resolveIdentity-Bsjd2yDj.js} +20 -20
- package/dist/chunks/resolveIdentity-Bsjd2yDj.js.map +1 -0
- package/dist/collections/AuditLogCollection.d.ts.map +1 -1
- package/dist/collections/NostrIdentityCollection.d.ts.map +1 -1
- package/dist/collections/ProfileCollection.d.ts.map +1 -1
- package/dist/index.js +33 -30
- package/dist/index.js.map +1 -1
- package/dist/internal/oidc-provisioning.js +2 -2
- package/dist/manifest.json +905 -342
- package/dist/models/ApiKey.d.ts.map +1 -1
- package/dist/models/AuditLog.d.ts.map +1 -1
- package/dist/models/MagicLinkToken.d.ts.map +1 -1
- package/dist/models/OidcProfileEmailReservation.d.ts.map +1 -1
- package/dist/models/ProfileAsset.d.ts.map +1 -1
- package/dist/models/ProfileLink.d.ts.map +1 -1
- package/dist/models/ProfileRelationship.d.ts.map +1 -1
- package/dist/models/ProfileRelationshipTerm.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +11 -11
- package/dist/utils.js +4 -4
- package/package.json +11 -11
- package/dist/chunks/ApiKey-9YuYcpWy.js.map +0 -1
- package/dist/chunks/AuditLogCollection-BBbvr8Qc.js.map +0 -1
- package/dist/chunks/OidcIdentity-CFsyI8H1.js.map +0 -1
- package/dist/chunks/ProfileAssetCollection-2Jhy3vhC.js.map +0 -1
- package/dist/chunks/ProfileCollection-5UJJmUW5.js.map +0 -1
- package/dist/chunks/ProfileLinkCollection-D9rfzly5.js.map +0 -1
- package/dist/chunks/ProfileMetadataCollection-CAgJyjze.js.map +0 -1
- package/dist/chunks/ProfileMetafieldCollection-19ae6Lpf.js.map +0 -1
- package/dist/chunks/ProfileRelationshipCollection-BFSlTQ7J.js.map +0 -1
- package/dist/chunks/ProfileRelationshipTermCollection-OluL8BGP.js.map +0 -1
- package/dist/chunks/ProfileRelationshipType-Cevy-vaF.js.map +0 -1
- package/dist/chunks/oidcProvisioningPrimitives-iQUIWC7F.js.map +0 -1
- package/dist/chunks/resolveIdentity-CT1tK-Kn.js.map +0 -1
package/dist/audit-trail.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AuditWriter } from '@happyvertical/smrt-core';
|
|
2
2
|
import type { AuditLogCollection } from './collections/AuditLogCollection.js';
|
|
3
3
|
import { AuditLog } from './models/AuditLog.js';
|
|
4
4
|
/** Profiles owns audit persistence; core only owns the mutation contract. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-trail.d.ts","sourceRoot":"","sources":["../src/audit-trail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"audit-trail.d.ts","sourceRoot":"","sources":["../src/audit-trail.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,6EAA6E;AAC7E,wBAAgB,iBAAiB,IAAI,WAAW,CAiB/C;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,QAAQ,KACZ,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,mFAAmF;AACnF,wBAAsB,cAAc,CAClC,IAAI,EAAE,kBAAkB,EACxB,SAAS,EAAE,kBAAkB,EAC7B,MAAM,GAAE,WAAgB,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAsCrB;AAED,wFAAwF;AACxF,wBAAsB,eAAe,CACnC,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9D,OAAO,CAAC,MAAM,CAAC,CA0BjB"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Token verification
|
|
8
8
|
* - Rate limiting checks
|
|
9
9
|
*/
|
|
10
|
-
import type
|
|
10
|
+
import { type SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
11
11
|
import type { NostrIdentity } from "../models/NostrIdentity.js";
|
|
12
12
|
import type { Profile } from "../models/Profile.js";
|
|
13
13
|
export interface MagicLinkConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magicLinkService.d.ts","sourceRoot":"","sources":["../../src/auth/magicLinkService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"magicLinkService.d.ts","sourceRoot":"","sources":["../../src/auth/magicLinkService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAGjD,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,C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gB;IAC/B;;OAEG;IACH,QAAQ,CACN,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QACR,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GACA,OAAO,CAAC,cAAc,CAAC,CAAC;IAE3B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,eAAe,GACtB,gBAAgB,CA2OlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidcProvisioningPrimitives.d.ts","sourceRoot":"","sources":["../../src/auth/oidcProvisioningPrimitives.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oidcProvisioningPrimitives.d.ts","sourceRoot":"","sources":["../../src/auth/oidcProvisioningPrimitives.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAIjD,KAAK,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC;AAEjE,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,gFAAgF;AAChF,wBAAsB,4BAA4B,CAChD,EAAE,EAAE,iBAAiB,EACrB,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,OAAO,CAAC,CA8BlB;AAED,qEAAqE;AACrE,wBAAsB,8BAA8B,CAClD,EAAE,EAAE,iBAAiB,EACrB,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,YAAY,CAAC,CAcvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveIdentity.d.ts","sourceRoot":"","sources":["../../src/auth/resolveIdentity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"resolveIdentity.d.ts","sourceRoot":"","sources":["../../src/auth/resolveIdentity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AAEjD,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,kBAAe,CAAC;AAUjE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE;QACZ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,IAAI,CAAC;IAET;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE;QACV,4CAA4C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EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,EACD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC,CAiD3E;AA0MD;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,MAAM,EACb,SAAS,EAAE;IACT,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,EACD,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAyED"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { y as __exportAll } from "./NostrIdentity-
|
|
2
|
-
import { SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
1
|
+
import { y as __exportAll } from "./NostrIdentity-joAS5ZlD.js";
|
|
2
|
+
import { ObjectRegistry, SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
3
3
|
import { createHash, randomBytes } from "node:crypto";
|
|
4
4
|
//#region src/models/ApiKey.ts
|
|
5
5
|
var ApiKey_exports = /* @__PURE__ */ __exportAll({ ApiKey: () => ApiKey });
|
|
@@ -108,7 +108,7 @@ var ApiKey = class extends SmrtObject {
|
|
|
108
108
|
const key = `sk_live_${randomBytes(32).toString("hex")}`;
|
|
109
109
|
const keyPrefix = key.substring(0, 16);
|
|
110
110
|
const keyHash = ApiKey.hashKey(key);
|
|
111
|
-
const apiKey = new ApiKey({
|
|
111
|
+
const apiKey = new (ObjectRegistry.resolveEffectiveConstructor(ApiKey))({
|
|
112
112
|
db: options.db || profile.options?.db,
|
|
113
113
|
profileId: profile.id,
|
|
114
114
|
name: options.name,
|
|
@@ -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-
|
|
132
|
+
const { ApiKeyCollection } = await import("./ApiKeyCollection-BK2Wn-wa.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;
|
|
@@ -139,7 +139,10 @@ var ApiKey = class extends SmrtObject {
|
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
__publicField(ApiKey, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
142
|
-
__decorateClass([foreignKey("Profile", {
|
|
142
|
+
__decorateClass([foreignKey("Profile", {
|
|
143
|
+
required: true,
|
|
144
|
+
requiredFor: "identity"
|
|
145
|
+
})], ApiKey.prototype, "profileId", 2);
|
|
143
146
|
__decorateClass([field({ indexed: true })], ApiKey.prototype, "keyHash", 2);
|
|
144
147
|
ApiKey = __decorateClass([smrt({
|
|
145
148
|
tableName: "api_keys",
|
|
@@ -159,4 +162,4 @@ ApiKey = __decorateClass([smrt({
|
|
|
159
162
|
//#endregion
|
|
160
163
|
export { ApiKey_exports as n, ApiKey as t };
|
|
161
164
|
|
|
162
|
-
//# sourceMappingURL=ApiKey-
|
|
165
|
+
//# sourceMappingURL=ApiKey-BhseCX_J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiKey-BhseCX_J.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 ObjectRegistry,\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, requiredFor: 'identity' })\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 (ObjectRegistry.resolveEffectiveConstructor(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":";;;;;;;;;;;;;;;;;;;;AAwCO,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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,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;CAAE,UAAU;CAAM,aAAa;AAAW,CAAC,CAAA,GAJvD,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,5 +1,5 @@
|
|
|
1
|
-
import { y as __exportAll } from "./NostrIdentity-
|
|
2
|
-
import { t as ApiKey } from "./ApiKey-
|
|
1
|
+
import { y as __exportAll } from "./NostrIdentity-joAS5ZlD.js";
|
|
2
|
+
import { t as ApiKey } from "./ApiKey-BhseCX_J.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-
|
|
84
|
+
//# sourceMappingURL=ApiKeyCollection-BK2Wn-wa.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiKeyCollection-
|
|
1
|
+
{"version":3,"file":"ApiKeyCollection-BK2Wn-wa.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,5 +1,5 @@
|
|
|
1
|
-
import { y as __exportAll } from "./NostrIdentity-
|
|
2
|
-
import { SmrtCollection, SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
1
|
+
import { y as __exportAll } from "./NostrIdentity-joAS5ZlD.js";
|
|
2
|
+
import { ObjectRegistry, 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
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -77,7 +77,7 @@ var AuditLog = class extends SmrtObject {
|
|
|
77
77
|
* Create an audit log entry
|
|
78
78
|
*/
|
|
79
79
|
static async record(options) {
|
|
80
|
-
const log = new AuditLog({
|
|
80
|
+
const log = new (ObjectRegistry.resolveEffectiveConstructor(AuditLog))({
|
|
81
81
|
...options,
|
|
82
82
|
profileId: options.profile.id,
|
|
83
83
|
onBehalfOfId: options.onBehalfOf?.id
|
|
@@ -89,7 +89,10 @@ var AuditLog = class extends SmrtObject {
|
|
|
89
89
|
};
|
|
90
90
|
__publicField(AuditLog, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
91
91
|
__decorateClass([tenantId({ nullable: true })], AuditLog.prototype, "tenantId", 2);
|
|
92
|
-
__decorateClass([foreignKey("Profile", {
|
|
92
|
+
__decorateClass([foreignKey("Profile", {
|
|
93
|
+
required: true,
|
|
94
|
+
requiredFor: "identity"
|
|
95
|
+
})], AuditLog.prototype, "profileId", 2);
|
|
93
96
|
__decorateClass([field({ indexed: true })], AuditLog.prototype, "resourceType", 2);
|
|
94
97
|
__decorateClass([field({ indexed: true })], AuditLog.prototype, "resourceId", 2);
|
|
95
98
|
__decorateClass([field({
|
|
@@ -164,7 +167,7 @@ var AuditLogCollection = class extends SmrtCollection {
|
|
|
164
167
|
* Record a new audit log entry
|
|
165
168
|
*/
|
|
166
169
|
async record(options) {
|
|
167
|
-
|
|
170
|
+
return await this.create({
|
|
168
171
|
...this.options,
|
|
169
172
|
profileId: options.profile.id,
|
|
170
173
|
action: options.action,
|
|
@@ -176,9 +179,6 @@ var AuditLogCollection = class extends SmrtCollection {
|
|
|
176
179
|
metadata: options.metadata || {},
|
|
177
180
|
onBehalfOfId: options.onBehalfOf?.id
|
|
178
181
|
});
|
|
179
|
-
await log.initialize();
|
|
180
|
-
await log.save();
|
|
181
|
-
return log;
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
184
184
|
* Get recent activity for a profile
|
|
@@ -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-
|
|
209
|
+
//# sourceMappingURL=AuditLogCollection-NYUFFPni.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuditLogCollection-NYUFFPni.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 ObjectRegistry,\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, requiredFor: 'identity' })\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 (ObjectRegistry.resolveEffectiveConstructor(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 = await this.create({\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 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":";;;;;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AAM,KAAK,KAAK;GACrB,OAAO,EAAE,OAAO;GAChB,SAAS;EACX,CAAC;CACH;;;;CAKA,MAAM,eAAe,WAAwC;EAC3D,OAAO,MAAM,KAAK,KAAK;GACrB,OAAO,EAAE,cAAc,UAAU;GACjC,SAAS;EACX,CAAC;CACH;;;;CAKA,MAAM,OAAO,SAUS;EAapB,OAAO,MAZW,KAAK,OAAO;GAC5B,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;CAEH;;;;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"}
|
|
@@ -4203,21 +4203,21 @@ var NostrIdentity = class extends SmrtObject {
|
|
|
4203
4203
|
* Find identity by public key
|
|
4204
4204
|
*/
|
|
4205
4205
|
static async findByPubkey(pubkey, options = {}) {
|
|
4206
|
-
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-
|
|
4206
|
+
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-B9G_vrWL.js").then((n) => n.n);
|
|
4207
4207
|
return await (await NostrIdentityCollection.create(options)).findOne({ where: { pubkey } });
|
|
4208
4208
|
}
|
|
4209
4209
|
/**
|
|
4210
4210
|
* Find identity by email
|
|
4211
4211
|
*/
|
|
4212
4212
|
static async findByEmail(email, options = {}) {
|
|
4213
|
-
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-
|
|
4213
|
+
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-B9G_vrWL.js").then((n) => n.n);
|
|
4214
4214
|
return await (await NostrIdentityCollection.create(options)).findOne({ where: { email: email.toLowerCase() } });
|
|
4215
4215
|
}
|
|
4216
4216
|
/**
|
|
4217
4217
|
* Find identity by NIP-05 username
|
|
4218
4218
|
*/
|
|
4219
4219
|
static async findByNip05(username, options = {}) {
|
|
4220
|
-
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-
|
|
4220
|
+
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-B9G_vrWL.js").then((n) => n.n);
|
|
4221
4221
|
return await (await NostrIdentityCollection.create(options)).findOne({ where: { nip05Username: username.toLowerCase() } });
|
|
4222
4222
|
}
|
|
4223
4223
|
/**
|
|
@@ -4283,7 +4283,10 @@ var NostrIdentity = class extends SmrtObject {
|
|
|
4283
4283
|
}
|
|
4284
4284
|
};
|
|
4285
4285
|
__publicField(NostrIdentity, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
4286
|
-
__decorateClass([foreignKey("Profile", {
|
|
4286
|
+
__decorateClass([foreignKey("Profile", {
|
|
4287
|
+
required: true,
|
|
4288
|
+
requiredFor: "identity"
|
|
4289
|
+
})], NostrIdentity.prototype, "profileId", 2);
|
|
4287
4290
|
__decorateClass([field({ indexed: true })], NostrIdentity.prototype, "pubkey", 2);
|
|
4288
4291
|
NostrIdentity = __decorateClass([smrt({
|
|
4289
4292
|
tableName: "nostr_identities",
|
|
@@ -4295,4 +4298,4 @@ NostrIdentity = __decorateClass([smrt({
|
|
|
4295
4298
|
//#endregion
|
|
4296
4299
|
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 };
|
|
4297
4300
|
|
|
4298
|
-
//# sourceMappingURL=NostrIdentity-
|
|
4301
|
+
//# sourceMappingURL=NostrIdentity-joAS5ZlD.js.map
|