@happyvertical/smrt-profiles 0.54.2 → 0.54.4
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/AGENTS.md +1 -1
- package/dist/agent-profile.d.ts +2 -2
- package/dist/agent-profile.d.ts.map +1 -1
- package/dist/audit-trail.d.ts +24 -0
- package/dist/audit-trail.d.ts.map +1 -0
- package/dist/auth/index.d.ts +5 -5
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/magicLinkService.d.ts +2 -2
- package/dist/auth/magicLinkService.d.ts.map +1 -1
- package/dist/auth/nip05Handler.d.ts +1 -1
- package/dist/auth/nip05Handler.d.ts.map +1 -1
- package/dist/auth/oidcProvisioningPrimitives.d.ts +2 -2
- package/dist/auth/oidcProvisioningPrimitives.d.ts.map +1 -1
- package/dist/auth/resolveIdentity.d.ts +5 -5
- package/dist/auth/resolveIdentity.d.ts.map +1 -1
- package/dist/chunks/{ApiKey-BZmbOTnL.js → ApiKey-CVmlf3V6.js} +11 -3
- package/dist/chunks/ApiKey-CVmlf3V6.js.map +1 -0
- package/dist/chunks/{ApiKeyCollection-Bfb_nw81.js → ApiKeyCollection-CiiDNFdD.js} +3 -3
- package/dist/chunks/{ApiKeyCollection-Bfb_nw81.js.map → ApiKeyCollection-CiiDNFdD.js.map} +1 -1
- package/dist/chunks/{AuditLogCollection-B1YonCAP.js → AuditLogCollection-WDHL-_AF.js} +30 -12
- package/dist/chunks/AuditLogCollection-WDHL-_AF.js.map +1 -0
- package/dist/chunks/{NostrIdentity-n70E0vck.js → NostrIdentity-AC8fAdxe.js} +12 -4
- package/dist/chunks/{NostrIdentity-n70E0vck.js.map → NostrIdentity-AC8fAdxe.js.map} +1 -1
- package/dist/chunks/{NostrIdentityCollection-Ca74dkaL.js → NostrIdentityCollection-CctlECpX.js} +2 -2
- package/dist/chunks/{NostrIdentityCollection-Ca74dkaL.js.map → NostrIdentityCollection-CctlECpX.js.map} +1 -1
- package/dist/chunks/{OidcIdentity-Cb1bxreM.js → OidcIdentity-BjRu3n1g.js} +11 -3
- package/dist/chunks/OidcIdentity-BjRu3n1g.js.map +1 -0
- package/dist/chunks/{OidcIdentityCollection-TV8VdK69.js → OidcIdentityCollection-B4jYh36_.js} +3 -3
- package/dist/chunks/{OidcIdentityCollection-TV8VdK69.js.map → OidcIdentityCollection-B4jYh36_.js.map} +1 -1
- package/dist/chunks/{ProfileAssetCollection-B9hacUJa.js → ProfileAssetCollection-HeMtjBc0.js} +12 -3
- package/dist/chunks/ProfileAssetCollection-HeMtjBc0.js.map +1 -0
- package/dist/chunks/{ProfileCollection-DuJT7Mum.js → ProfileCollection-Bt6IJK49.js} +49 -25
- package/dist/chunks/ProfileCollection-Bt6IJK49.js.map +1 -0
- package/dist/chunks/{ProfileLinkCollection-4uNURz32.js → ProfileLinkCollection-u1hhzKTm.js} +11 -3
- package/dist/chunks/ProfileLinkCollection-u1hhzKTm.js.map +1 -0
- package/dist/chunks/{ProfileMetadataCollection-DQhbfEfa.js → ProfileMetadataCollection-BIYKy4Y3.js} +10 -2
- package/dist/chunks/ProfileMetadataCollection-BIYKy4Y3.js.map +1 -0
- package/dist/chunks/{ProfileMetafieldCollection-CoBuM_5G.js → ProfileMetafieldCollection-Buz7gzag.js} +10 -2
- package/dist/chunks/ProfileMetafieldCollection-Buz7gzag.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipCollection-DUVgaIqf.js → ProfileRelationshipCollection-C4g_QLI4.js} +13 -5
- package/dist/chunks/ProfileRelationshipCollection-C4g_QLI4.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipTermCollection-DtA9OM23.js → ProfileRelationshipTermCollection-C9J7mC7P.js} +10 -2
- package/dist/chunks/ProfileRelationshipTermCollection-C9J7mC7P.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipType-BRiRka6t.js → ProfileRelationshipType-U7IwF6Wf.js} +10 -2
- package/dist/chunks/ProfileRelationshipType-U7IwF6Wf.js.map +1 -0
- package/dist/chunks/{ProfileRelationshipTypeCollection-BdXwd7Kf.js → ProfileRelationshipTypeCollection-_n22WqTb.js} +3 -3
- package/dist/chunks/{ProfileRelationshipTypeCollection-BdXwd7Kf.js.map → ProfileRelationshipTypeCollection-_n22WqTb.js.map} +1 -1
- package/dist/chunks/{oidcProvisioningPrimitives-D9OYu5-F.js → oidcProvisioningPrimitives-CYood-2M.js} +14 -4
- package/dist/chunks/{oidcProvisioningPrimitives-D9OYu5-F.js.map → oidcProvisioningPrimitives-CYood-2M.js.map} +1 -1
- package/dist/chunks/{resolveIdentity-B-PK6RwU.js → resolveIdentity-CvGDegU6.js} +16 -16
- package/dist/chunks/{resolveIdentity-B-PK6RwU.js.map → resolveIdentity-CvGDegU6.js.map} +1 -1
- package/dist/collections/ApiKeyCollection.d.ts +2 -2
- package/dist/collections/ApiKeyCollection.d.ts.map +1 -1
- package/dist/collections/AuditLogCollection.d.ts +5 -3
- package/dist/collections/AuditLogCollection.d.ts.map +1 -1
- package/dist/collections/MagicLinkTokenCollection.d.ts +1 -1
- package/dist/collections/MagicLinkTokenCollection.d.ts.map +1 -1
- package/dist/collections/NostrIdentityCollection.d.ts +2 -2
- package/dist/collections/NostrIdentityCollection.d.ts.map +1 -1
- package/dist/collections/OidcIdentityCollection.d.ts +2 -2
- package/dist/collections/OidcIdentityCollection.d.ts.map +1 -1
- package/dist/collections/OidcProfileEmailReservationCollection.d.ts +1 -1
- package/dist/collections/OidcProfileEmailReservationCollection.d.ts.map +1 -1
- package/dist/collections/ProfileAssetCollection.d.ts +1 -1
- package/dist/collections/ProfileAssetCollection.d.ts.map +1 -1
- package/dist/collections/ProfileCollection.d.ts +1 -1
- package/dist/collections/ProfileCollection.d.ts.map +1 -1
- package/dist/collections/ProfileLinkCollection.d.ts +1 -1
- package/dist/collections/ProfileLinkCollection.d.ts.map +1 -1
- package/dist/collections/ProfileMetadataCollection.d.ts +1 -1
- package/dist/collections/ProfileMetadataCollection.d.ts.map +1 -1
- package/dist/collections/ProfileMetafieldCollection.d.ts +2 -2
- package/dist/collections/ProfileMetafieldCollection.d.ts.map +1 -1
- package/dist/collections/ProfileRelationshipCollection.d.ts +1 -1
- package/dist/collections/ProfileRelationshipCollection.d.ts.map +1 -1
- package/dist/collections/ProfileRelationshipTermCollection.d.ts +1 -1
- package/dist/collections/ProfileRelationshipTermCollection.d.ts.map +1 -1
- package/dist/collections/ProfileRelationshipTypeCollection.d.ts +1 -1
- package/dist/collections/ProfileRelationshipTypeCollection.d.ts.map +1 -1
- package/dist/collections/ProfileTypeCollection.d.ts +1 -1
- package/dist/collections/ProfileTypeCollection.d.ts.map +1 -1
- package/dist/collections/index.d.ts +15 -15
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/index.d.ts +51 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -24
- package/dist/index.js.map +1 -1
- package/dist/internal/oidc-provisioning.d.ts +1 -1
- package/dist/internal/oidc-provisioning.d.ts.map +1 -1
- package/dist/internal/oidc-provisioning.js +2 -2
- package/dist/manifest.json +126 -33
- package/dist/models/ApiKey.d.ts +1 -1
- package/dist/models/ApiKey.d.ts.map +1 -1
- package/dist/models/AuditLog.d.ts +10 -2
- package/dist/models/AuditLog.d.ts.map +1 -1
- package/dist/models/MagicLinkToken.d.ts +1 -1
- package/dist/models/MagicLinkToken.d.ts.map +1 -1
- package/dist/models/NostrIdentity.d.ts +1 -1
- package/dist/models/NostrIdentity.d.ts.map +1 -1
- package/dist/models/OidcIdentity.d.ts +1 -1
- package/dist/models/OidcIdentity.d.ts.map +1 -1
- package/dist/models/Profile.d.ts +10 -8
- package/dist/models/Profile.d.ts.map +1 -1
- package/dist/models/ProfileMetafield.d.ts +1 -1
- package/dist/models/ProfileMetafield.d.ts.map +1 -1
- package/dist/models/ProfileRelationship.d.ts +1 -1
- package/dist/models/ProfileRelationship.d.ts.map +1 -1
- package/dist/models/ProfileRelationshipType.d.ts +1 -1
- package/dist/models/ProfileRelationshipType.d.ts.map +1 -1
- package/dist/models/ProfileTypes.d.ts +1 -1
- package/dist/models/ProfileTypes.d.ts.map +1 -1
- package/dist/models/index.d.ts +15 -15
- package/dist/models/index.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +62 -366
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -4
- package/package.json +12 -12
- package/dist/chunks/ApiKey-BZmbOTnL.js.map +0 -1
- package/dist/chunks/AuditLogCollection-B1YonCAP.js.map +0 -1
- package/dist/chunks/OidcIdentity-Cb1bxreM.js.map +0 -1
- package/dist/chunks/ProfileAssetCollection-B9hacUJa.js.map +0 -1
- package/dist/chunks/ProfileCollection-DuJT7Mum.js.map +0 -1
- package/dist/chunks/ProfileLinkCollection-4uNURz32.js.map +0 -1
- package/dist/chunks/ProfileMetadataCollection-DQhbfEfa.js.map +0 -1
- package/dist/chunks/ProfileMetafieldCollection-CoBuM_5G.js.map +0 -1
- package/dist/chunks/ProfileRelationshipCollection-DUVgaIqf.js.map +0 -1
- package/dist/chunks/ProfileRelationshipTermCollection-DtA9OM23.js.map +0 -1
- package/dist/chunks/ProfileRelationshipType-BRiRka6t.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -10,7 +10,7 @@ Central identity system with multi-auth, relationships, controlled metadata, and
|
|
|
10
10
|
- **Profile.isPublic**: optional public-figure flag (boolean, default false). Records the fact only; consumers decide visibility.
|
|
11
11
|
- **ProfileRelationship**: bidirectional — creating one auto-creates reciprocal inverse. `contextProfileId` for tertiary relationships. `ProfileRelationshipTerm` tracks start/end dates.
|
|
12
12
|
- **ProfileMetafield**: controlled vocabulary with `validationSchema`. **ProfileMetadata**: per-profile values linked to metafields. `addMetadata()` stamps new rows with the profile's `tenantId` (never rely on auto-population, which super-admin/system context skips, #3235) and resolves the metafield as profile-tenant first, then global, never another tenant's.
|
|
13
|
-
- **AuditLog**: action, resourceType/Id,
|
|
13
|
+
- **AuditLog**: sensitive audit persistence with actor, action, reason, before/after `changes`, indexed `occurredAt`, resourceType/Id, source, and delegated identity. No generated read routes. `createAuditWriter`, consumer-authorized `readAuditTrail`, and bounded `pruneAuditTrail` live in `src/audit-trail.ts`; see [audit contract](../../docs/content/audit-trail.md).
|
|
14
14
|
|
|
15
15
|
## Auth Methods
|
|
16
16
|
|
package/dist/agent-profile.d.ts
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @module
|
|
24
24
|
*/
|
|
25
|
-
import type { ProfileCollection } from
|
|
26
|
-
import type { Profile } from
|
|
25
|
+
import type { ProfileCollection } from "./collections/ProfileCollection.js";
|
|
26
|
+
import type { Profile } from "./models/Profile.js";
|
|
27
27
|
/**
|
|
28
28
|
* Reserved slug context for agent-owned profiles.
|
|
29
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-profile.d.ts","sourceRoot":"","sources":["../src/agent-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"agent-profile.d.ts","sourceRoot":"","sources":["../src/agent-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAiC,CAAC;AAEzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAkB,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,QAAQ,CAAC;AAE7C,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,OAAO,CAAC,CAgDlB;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,MAAM,CAAC,CASjB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AuditWriter } from '@happyvertical/smrt-core';
|
|
2
|
+
import type { AuditLogCollection } from './collections/AuditLogCollection.js';
|
|
3
|
+
import { AuditLog } from './models/AuditLog.js';
|
|
4
|
+
/** Profiles owns audit persistence; core only owns the mutation contract. */
|
|
5
|
+
export declare function createAuditWriter(): AuditWriter;
|
|
6
|
+
export interface AuditFilter {
|
|
7
|
+
profileId?: string;
|
|
8
|
+
resourceType?: string;
|
|
9
|
+
resourceId?: string;
|
|
10
|
+
from?: Date;
|
|
11
|
+
to?: Date;
|
|
12
|
+
limit?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Consumer checks both audit permission and access to the referenced resource. */
|
|
15
|
+
export type AuthorizeAuditRead = (entry: AuditLog) => boolean | Promise<boolean>;
|
|
16
|
+
/** No generated read routes: consumers expose this fail-closed permission seam. */
|
|
17
|
+
export declare function readAuditTrail(logs: AuditLogCollection, authorize: AuthorizeAuditRead, filter?: AuditFilter): Promise<AuditLog[]>;
|
|
18
|
+
/** Explicit maintenance API. Scheduling and retention window belong to the consumer. */
|
|
19
|
+
export declare function pruneAuditTrail(logs: AuditLogCollection, options: {
|
|
20
|
+
maxAgeDays: number;
|
|
21
|
+
now?: Date;
|
|
22
|
+
batchSize?: number;
|
|
23
|
+
}): Promise<number>;
|
|
24
|
+
//# sourceMappingURL=audit-trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-trail.d.ts","sourceRoot":"","sources":["../src/audit-trail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAExE,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"}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Provides identity resolution and authentication primitives.
|
|
5
5
|
* Apps configure auth (OIDC providers, Nostr), modules receive resolved profiles.
|
|
6
6
|
*/
|
|
7
|
-
export { createMagicLinkService, type InitiateResult, type MagicLinkConfig, type MagicLinkService, type VerifyResult, } from
|
|
8
|
-
export { createNip05Handler, isValidNip05Identifier, type Nip05HandlerConfig, type Nip05HandlerResult, type Nip05Request, parseNip05Identifier, } from
|
|
9
|
-
export { normalizeIdentityEmail } from
|
|
10
|
-
export { computeEventId, createAuthEvent, decryptPrivkey, deriveEncryptionKey, type EncryptedKey, encryptPrivkey, generateNostrKeypair, getPublicKey, isValidPrivkey, isValidPubkey, type NostrEvent, type NostrKeypair, npubToPubkey, nsecToPrivkey, privkeyToNsec, pubkeyToNpub, signEvent, verifyAuthEvent, verifyNostrSignature, } from
|
|
11
|
-
export { type AuthContext, createProfileFromNostr, createProfileFromOidc, type ResolveIdentityResult, resolveIdentity, } from
|
|
7
|
+
export { createMagicLinkService, type InitiateResult, type MagicLinkConfig, type MagicLinkService, type VerifyResult, } from "./magicLinkService.js";
|
|
8
|
+
export { createNip05Handler, isValidNip05Identifier, type Nip05HandlerConfig, type Nip05HandlerResult, type Nip05Request, parseNip05Identifier, } from "./nip05Handler.js";
|
|
9
|
+
export { normalizeIdentityEmail } from "./normalizeIdentityEmail.js";
|
|
10
|
+
export { computeEventId, createAuthEvent, decryptPrivkey, deriveEncryptionKey, type EncryptedKey, encryptPrivkey, generateNostrKeypair, getPublicKey, isValidPrivkey, isValidPubkey, type NostrEvent, type NostrKeypair, npubToPubkey, nsecToPrivkey, privkeyToNsec, pubkeyToNpub, signEvent, verifyAuthEvent, verifyNostrSignature, } from "./nostrCrypto.js";
|
|
11
|
+
export { type AuthContext, createProfileFromNostr, createProfileFromOidc, type ResolveIdentityResult, resolveIdentity, } from "./resolveIdentity.js";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,uBAAoB,CAAC;AAE5B,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,oBAAoB,GACrB,MAAM,mBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAElE,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,KAAK,YAAY,EACjB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAe,CAAC;AAEvB,OAAO,EACL,KAAK,WAAW,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,eAAe,GAChB,MAAM,sBAAmB,CAAC"}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* - Rate limiting checks
|
|
9
9
|
*/
|
|
10
10
|
import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
11
|
-
import type { NostrIdentity } from
|
|
12
|
-
import type { Profile } from
|
|
11
|
+
import type { NostrIdentity } from "../models/NostrIdentity.js";
|
|
12
|
+
import type { Profile } from "../models/Profile.js";
|
|
13
13
|
export interface MagicLinkConfig {
|
|
14
14
|
/** Base URL for magic links (e.g., "https://example.com") */
|
|
15
15
|
baseUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magicLinkService.d.ts","sourceRoot":"","sources":["../../src/auth/magicLinkService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"magicLinkService.d.ts","sourceRoot":"","sources":["../../src/auth/magicLinkService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,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,CAAC;IACpB,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qDAAqD;IACrD,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,mDAAmD;IACnD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,uBAAuB;IACvB,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,SAAS,CAAC,EAAE,oBAAoB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;CAC5E;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yBAAyB;IACzB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,8CAA8C;IAC9C,OAAO,CAAC,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,SAAS,CAAC,EAAE,eAAe,GAAG,eAAe,GAAG,YAAY,GAAG,WAAW,CAAC;CAC5E;AAED,MAAM,WAAW,gBAAgB;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,CAuOlB"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://github.com/nostr-protocol/nips/blob/master/05.md
|
|
8
8
|
*/
|
|
9
9
|
import type { SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
10
|
-
import { type Nip05Response } from
|
|
10
|
+
import { type Nip05Response } from "../collections/NostrIdentityCollection.js";
|
|
11
11
|
export interface Nip05HandlerConfig {
|
|
12
12
|
/** Database options */
|
|
13
13
|
db: SmrtObjectOptions['db'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nip05Handler.d.ts","sourceRoot":"","sources":["../../src/auth/nip05Handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,
|
|
1
|
+
{"version":3,"file":"nip05Handler.d.ts","sourceRoot":"","sources":["../../src/auth/nip05Handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,2CAAwC,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,uBAAuB;IACvB,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC5B,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,IAIzD,SAAS,YAAY,KACpB,OAAO,CAAC,kBAAkB,CAAC,CAqC/B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAoBlE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,IAAI,CAOP"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { getDatabase } from '@happyvertical/sql';
|
|
2
|
-
import { OidcIdentity } from
|
|
3
|
-
import type { Profile } from
|
|
2
|
+
import { OidcIdentity } from "../models/OidcIdentity.js";
|
|
3
|
+
import type { Profile } from "../models/Profile.js";
|
|
4
4
|
type DatabaseInterface = Awaited<ReturnType<typeof getDatabase>>;
|
|
5
5
|
export interface OidcProvisioningPersonInput {
|
|
6
6
|
email?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidcProvisioningPrimitives.d.ts","sourceRoot":"","sources":["../../src/auth/oidcProvisioningPrimitives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"oidcProvisioningPrimitives.d.ts","sourceRoot":"","sources":["../../src/auth/oidcProvisioningPrimitives.ts"],"names":[],"mappings":"AAAA,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,CA4BlB;AAED,qEAAqE;AACrE,wBAAsB,8BAA8B,CAClD,EAAE,EAAE,iBAAiB,EACrB,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC,YAAY,CAAC,CAYvB"}
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
* 4. Actor header (CI pass-through) → Profile lookup
|
|
12
12
|
*/
|
|
13
13
|
import { type SmrtObjectOptions } from '@happyvertical/smrt-core';
|
|
14
|
-
import { ApiKey } from
|
|
15
|
-
import { NostrIdentity } from
|
|
16
|
-
import { OidcIdentity } from
|
|
17
|
-
import type { Profile } from
|
|
18
|
-
import { type NostrEvent } from
|
|
14
|
+
import { ApiKey } from "../models/ApiKey.js";
|
|
15
|
+
import { NostrIdentity } from "../models/NostrIdentity.js";
|
|
16
|
+
import { OidcIdentity } from "../models/OidcIdentity.js";
|
|
17
|
+
import type { Profile } from "../models/Profile.js";
|
|
18
|
+
import { type NostrEvent } from "./nostrCrypto.js";
|
|
19
19
|
/**
|
|
20
20
|
* Context provided to resolveIdentity
|
|
21
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveIdentity.d.ts","sourceRoot":"","sources":["../../src/auth/resolveIdentity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resolveIdentity.d.ts","sourceRoot":"","sources":["../../src/auth/resolve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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,CAuED"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { y as __exportAll } from "./NostrIdentity-
|
|
1
|
+
import { y as __exportAll } from "./NostrIdentity-AC8fAdxe.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
|
|
5
5
|
var ApiKey_exports = /* @__PURE__ */ __exportAll({ ApiKey: () => ApiKey });
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value
|
|
13
|
+
}) : obj[key] = value;
|
|
8
14
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
9
15
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
10
16
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
17
|
if (kind && result) __defProp(target, key, result);
|
|
12
18
|
return result;
|
|
13
19
|
};
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
14
21
|
var ApiKey = class extends SmrtObject {
|
|
15
22
|
profileId;
|
|
16
23
|
keyHash = "";
|
|
@@ -122,7 +129,7 @@ var ApiKey = class extends SmrtObject {
|
|
|
122
129
|
*/
|
|
123
130
|
static async verify(key, options = {}) {
|
|
124
131
|
const keyHash = ApiKey.hashKey(key);
|
|
125
|
-
const { ApiKeyCollection } = await import("./ApiKeyCollection-
|
|
132
|
+
const { ApiKeyCollection } = await import("./ApiKeyCollection-CiiDNFdD.js").then((n) => n.n);
|
|
126
133
|
const apiKey = await (await ApiKeyCollection.create(options)).findOne({ where: { keyHash } });
|
|
127
134
|
if (!apiKey) return null;
|
|
128
135
|
if (!apiKey.isValid()) return null;
|
|
@@ -131,6 +138,7 @@ var ApiKey = class extends SmrtObject {
|
|
|
131
138
|
return apiKey;
|
|
132
139
|
}
|
|
133
140
|
};
|
|
141
|
+
__publicField(ApiKey, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
134
142
|
__decorateClass([foreignKey("Profile", { required: true })], ApiKey.prototype, "profileId", 2);
|
|
135
143
|
__decorateClass([field({ indexed: true })], ApiKey.prototype, "keyHash", 2);
|
|
136
144
|
ApiKey = __decorateClass([smrt({
|
|
@@ -151,4 +159,4 @@ ApiKey = __decorateClass([smrt({
|
|
|
151
159
|
//#endregion
|
|
152
160
|
export { ApiKey_exports as n, ApiKey as t };
|
|
153
161
|
|
|
154
|
-
//# sourceMappingURL=ApiKey-
|
|
162
|
+
//# sourceMappingURL=ApiKey-CVmlf3V6.js.map
|
|
@@ -0,0 +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;;;;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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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-AC8fAdxe.js";
|
|
2
|
+
import { t as ApiKey } from "./ApiKey-CVmlf3V6.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-CiiDNFdD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiKeyCollection-
|
|
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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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,15 +1,22 @@
|
|
|
1
|
-
import { y as __exportAll } from "./NostrIdentity-
|
|
2
|
-
import { SmrtCollection, SmrtObject, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
1
|
+
import { y as __exportAll } from "./NostrIdentity-AC8fAdxe.js";
|
|
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
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value
|
|
12
|
+
}) : obj[key] = value;
|
|
7
13
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
8
14
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
9
15
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
10
16
|
if (kind && result) __defProp(target, key, result);
|
|
11
17
|
return result;
|
|
12
18
|
};
|
|
19
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
13
20
|
var AuditLog = class extends SmrtObject {
|
|
14
21
|
tenantId = null;
|
|
15
22
|
profileId;
|
|
@@ -17,14 +24,13 @@ var AuditLog = class extends SmrtObject {
|
|
|
17
24
|
* Action performed (e.g., 'issue.update', 'feedback.incorporate')
|
|
18
25
|
*/
|
|
19
26
|
action = "";
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
*/
|
|
27
|
+
/** Optional explanation supplied by the caller. */
|
|
28
|
+
reason = "";
|
|
29
|
+
/** Public field changes only; sensitive values must never be supplied. */
|
|
30
|
+
changes = {};
|
|
23
31
|
resourceType = "";
|
|
24
|
-
/**
|
|
25
|
-
* ID of the affected resource
|
|
26
|
-
*/
|
|
27
32
|
resourceId = "";
|
|
33
|
+
occurredAt = /* @__PURE__ */ new Date();
|
|
28
34
|
/**
|
|
29
35
|
* Source of the action
|
|
30
36
|
*/
|
|
@@ -38,6 +44,8 @@ var AuditLog = class extends SmrtObject {
|
|
|
38
44
|
super(options);
|
|
39
45
|
if (options.profileId) this.profileId = options.profileId;
|
|
40
46
|
if (options.action) this.action = options.action;
|
|
47
|
+
if (options.reason !== void 0) this.reason = options.reason;
|
|
48
|
+
if (options.changes !== void 0) this.changes = options.changes;
|
|
41
49
|
if (options.resourceType) this.resourceType = options.resourceType;
|
|
42
50
|
if (options.resourceId) this.resourceId = options.resourceId;
|
|
43
51
|
if (options.source) this.source = options.source;
|
|
@@ -79,17 +87,25 @@ var AuditLog = class extends SmrtObject {
|
|
|
79
87
|
return log;
|
|
80
88
|
}
|
|
81
89
|
};
|
|
90
|
+
__publicField(AuditLog, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
82
91
|
__decorateClass([tenantId({ nullable: true })], AuditLog.prototype, "tenantId", 2);
|
|
83
92
|
__decorateClass([foreignKey("Profile", { required: true })], AuditLog.prototype, "profileId", 2);
|
|
93
|
+
__decorateClass([field({ indexed: true })], AuditLog.prototype, "resourceType", 2);
|
|
94
|
+
__decorateClass([field({ indexed: true })], AuditLog.prototype, "resourceId", 2);
|
|
95
|
+
__decorateClass([field({
|
|
96
|
+
indexed: true,
|
|
97
|
+
default: "current_timestamp"
|
|
98
|
+
})], AuditLog.prototype, "occurredAt", 2);
|
|
84
99
|
__decorateClass([foreignKey("Profile", { nullable: true })], AuditLog.prototype, "onBehalfOfId", 2);
|
|
85
100
|
AuditLog = __decorateClass([TenantScoped({
|
|
86
101
|
mode: "optional",
|
|
87
102
|
allowSuperAdminBypass: true
|
|
88
103
|
}), smrt({
|
|
89
104
|
tableName: "audit_logs",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
sensitive: true,
|
|
106
|
+
api: false,
|
|
107
|
+
mcp: false,
|
|
108
|
+
cli: false
|
|
93
109
|
})], AuditLog);
|
|
94
110
|
//#endregion
|
|
95
111
|
//#region src/collections/AuditLogCollection.ts
|
|
@@ -152,6 +168,8 @@ var AuditLogCollection = class extends SmrtCollection {
|
|
|
152
168
|
...this.options,
|
|
153
169
|
profileId: options.profile.id,
|
|
154
170
|
action: options.action,
|
|
171
|
+
reason: options.reason,
|
|
172
|
+
changes: options.changes,
|
|
155
173
|
resourceType: options.resourceType,
|
|
156
174
|
resourceId: options.resourceId,
|
|
157
175
|
source: options.source || "web",
|
|
@@ -188,4 +206,4 @@ var AuditLogCollection = class extends SmrtCollection {
|
|
|
188
206
|
//#endregion
|
|
189
207
|
export { AuditLogCollection_exports as n, AuditLog as r, AuditLogCollection as t };
|
|
190
208
|
|
|
191
|
-
//# sourceMappingURL=AuditLogCollection-
|
|
209
|
+
//# sourceMappingURL=AuditLogCollection-WDHL-_AF.js.map
|
|
@@ -0,0 +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,WAAoC,CAAC;CAMrC;CAEA,YAAY,UAA2B,CAAC,GAAG;EACzC,MAAM,OAAO;EACb,IAAI,QAAQ,WAAW,KAAK,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AAQ;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"}
|
|
@@ -4126,12 +4126,19 @@ function isValidPrivkey(privkey) {
|
|
|
4126
4126
|
var NostrIdentity_exports = /* @__PURE__ */ __exportAll({ NostrIdentity: () => NostrIdentity });
|
|
4127
4127
|
var __defProp = Object.defineProperty;
|
|
4128
4128
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4129
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
4130
|
+
enumerable: true,
|
|
4131
|
+
configurable: true,
|
|
4132
|
+
writable: true,
|
|
4133
|
+
value
|
|
4134
|
+
}) : obj[key] = value;
|
|
4129
4135
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
4130
4136
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
4131
4137
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
4132
4138
|
if (kind && result) __defProp(target, key, result);
|
|
4133
4139
|
return result;
|
|
4134
4140
|
};
|
|
4141
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4135
4142
|
var NostrIdentity = class extends SmrtObject {
|
|
4136
4143
|
profileId;
|
|
4137
4144
|
pubkey = "";
|
|
@@ -4185,21 +4192,21 @@ var NostrIdentity = class extends SmrtObject {
|
|
|
4185
4192
|
* Find identity by public key
|
|
4186
4193
|
*/
|
|
4187
4194
|
static async findByPubkey(pubkey, options = {}) {
|
|
4188
|
-
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-
|
|
4195
|
+
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-CctlECpX.js").then((n) => n.n);
|
|
4189
4196
|
return await (await NostrIdentityCollection.create(options)).findOne({ where: { pubkey } });
|
|
4190
4197
|
}
|
|
4191
4198
|
/**
|
|
4192
4199
|
* Find identity by email
|
|
4193
4200
|
*/
|
|
4194
4201
|
static async findByEmail(email, options = {}) {
|
|
4195
|
-
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-
|
|
4202
|
+
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-CctlECpX.js").then((n) => n.n);
|
|
4196
4203
|
return await (await NostrIdentityCollection.create(options)).findOne({ where: { email: email.toLowerCase() } });
|
|
4197
4204
|
}
|
|
4198
4205
|
/**
|
|
4199
4206
|
* Find identity by NIP-05 username
|
|
4200
4207
|
*/
|
|
4201
4208
|
static async findByNip05(username, options = {}) {
|
|
4202
|
-
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-
|
|
4209
|
+
const { NostrIdentityCollection } = await import("./NostrIdentityCollection-CctlECpX.js").then((n) => n.n);
|
|
4203
4210
|
return await (await NostrIdentityCollection.create(options)).findOne({ where: { nip05Username: username.toLowerCase() } });
|
|
4204
4211
|
}
|
|
4205
4212
|
/**
|
|
@@ -4264,6 +4271,7 @@ var NostrIdentity = class extends SmrtObject {
|
|
|
4264
4271
|
return `${this.nip05Username || this.email.split("@")[0]}@${domain}`;
|
|
4265
4272
|
}
|
|
4266
4273
|
};
|
|
4274
|
+
__publicField(NostrIdentity, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
4267
4275
|
__decorateClass([foreignKey("Profile", { required: true })], NostrIdentity.prototype, "profileId", 2);
|
|
4268
4276
|
__decorateClass([field({ indexed: true })], NostrIdentity.prototype, "pubkey", 2);
|
|
4269
4277
|
NostrIdentity = __decorateClass([smrt({
|
|
@@ -4276,4 +4284,4 @@ NostrIdentity = __decorateClass([smrt({
|
|
|
4276
4284
|
//#endregion
|
|
4277
4285
|
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 };
|
|
4278
4286
|
|
|
4279
|
-
//# sourceMappingURL=NostrIdentity-
|
|
4287
|
+
//# sourceMappingURL=NostrIdentity-AC8fAdxe.js.map
|