@happyvertical/smrt-profiles 0.51.32 → 0.51.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/__smrt-register__.d.ts +2 -0
  2. package/dist/__smrt-register__.d.ts.map +1 -0
  3. package/dist/agent-profile.d.ts +71 -0
  4. package/dist/agent-profile.d.ts.map +1 -0
  5. package/dist/auth/index.d.ts +12 -0
  6. package/dist/auth/index.d.ts.map +1 -0
  7. package/dist/auth/magicLinkService.d.ts +79 -0
  8. package/dist/auth/magicLinkService.d.ts.map +1 -0
  9. package/dist/auth/nip05Handler.d.ts +73 -0
  10. package/dist/auth/nip05Handler.d.ts.map +1 -0
  11. package/dist/auth/normalizeIdentityEmail.d.ts +8 -0
  12. package/dist/auth/normalizeIdentityEmail.d.ts.map +1 -0
  13. package/dist/auth/nostrCrypto.d.ts +111 -0
  14. package/dist/auth/nostrCrypto.d.ts.map +1 -0
  15. package/dist/auth/oidcProvisioningCoordinator.d.ts +58 -0
  16. package/dist/auth/oidcProvisioningCoordinator.d.ts.map +1 -0
  17. package/dist/auth/oidcProvisioningPrimitives.d.ts +23 -0
  18. package/dist/auth/oidcProvisioningPrimitives.d.ts.map +1 -0
  19. package/dist/auth/resolveIdentity.d.ts +188 -0
  20. package/dist/auth/resolveIdentity.d.ts.map +1 -0
  21. package/dist/collections/ApiKeyCollection.d.ts +46 -0
  22. package/dist/collections/ApiKeyCollection.d.ts.map +1 -0
  23. package/dist/collections/AuditLogCollection.d.ts +50 -0
  24. package/dist/collections/AuditLogCollection.d.ts.map +1 -0
  25. package/dist/collections/MagicLinkTokenCollection.d.ts +58 -0
  26. package/dist/collections/MagicLinkTokenCollection.d.ts.map +1 -0
  27. package/dist/collections/NostrIdentityCollection.d.ts +66 -0
  28. package/dist/collections/NostrIdentityCollection.d.ts.map +1 -0
  29. package/dist/collections/OidcIdentityCollection.d.ts +45 -0
  30. package/dist/collections/OidcIdentityCollection.d.ts.map +1 -0
  31. package/dist/collections/OidcProfileEmailReservationCollection.d.ts +7 -0
  32. package/dist/collections/OidcProfileEmailReservationCollection.d.ts.map +1 -0
  33. package/dist/collections/ProfileAssetCollection.d.ts +17 -0
  34. package/dist/collections/ProfileAssetCollection.d.ts.map +1 -0
  35. package/dist/collections/ProfileCollection.d.ts +130 -0
  36. package/dist/collections/ProfileCollection.d.ts.map +1 -0
  37. package/dist/collections/ProfileMetadataCollection.d.ts +33 -0
  38. package/dist/collections/ProfileMetadataCollection.d.ts.map +1 -0
  39. package/dist/collections/ProfileMetafieldCollection.d.ts +31 -0
  40. package/dist/collections/ProfileMetafieldCollection.d.ts.map +1 -0
  41. package/dist/collections/ProfileRelationshipCollection.d.ts +44 -0
  42. package/dist/collections/ProfileRelationshipCollection.d.ts.map +1 -0
  43. package/dist/collections/ProfileRelationshipTermCollection.d.ts +32 -0
  44. package/dist/collections/ProfileRelationshipTermCollection.d.ts.map +1 -0
  45. package/dist/collections/ProfileRelationshipTypeCollection.d.ts +41 -0
  46. package/dist/collections/ProfileRelationshipTypeCollection.d.ts.map +1 -0
  47. package/dist/collections/ProfileTypeCollection.d.ts +40 -0
  48. package/dist/collections/ProfileTypeCollection.d.ts.map +1 -0
  49. package/dist/collections/index.d.ts +18 -0
  50. package/dist/collections/index.d.ts.map +1 -0
  51. package/dist/index.d.ts +55 -2059
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +1 -1
  54. package/dist/internal/oidc-provisioning.d.ts +14 -119
  55. package/dist/internal/oidc-provisioning.d.ts.map +1 -0
  56. package/dist/manifest.json +1 -1
  57. package/dist/migrations/backfillProfileEmailKeys.d.ts +16 -0
  58. package/dist/migrations/backfillProfileEmailKeys.d.ts.map +1 -0
  59. package/dist/models/ApiKey.d.ts +94 -0
  60. package/dist/models/ApiKey.d.ts.map +1 -0
  61. package/dist/models/AuditLog.d.ts +71 -0
  62. package/dist/models/AuditLog.d.ts.map +1 -0
  63. package/dist/models/MagicLinkToken.d.ts +104 -0
  64. package/dist/models/MagicLinkToken.d.ts.map +1 -0
  65. package/dist/models/NostrIdentity.d.ts +112 -0
  66. package/dist/models/NostrIdentity.d.ts.map +1 -0
  67. package/dist/models/OidcIdentity.d.ts +82 -0
  68. package/dist/models/OidcIdentity.d.ts.map +1 -0
  69. package/dist/models/OidcProfileEmailReservation.d.ts +12 -0
  70. package/dist/models/OidcProfileEmailReservation.d.ts.map +1 -0
  71. package/dist/models/Profile.d.ts +243 -0
  72. package/dist/models/Profile.d.ts.map +1 -0
  73. package/dist/models/ProfileAsset.d.ts +18 -0
  74. package/dist/models/ProfileAsset.d.ts.map +1 -0
  75. package/dist/models/ProfileMetadata.d.ts +33 -0
  76. package/dist/models/ProfileMetadata.d.ts.map +1 -0
  77. package/dist/models/ProfileMetafield.d.ts +62 -0
  78. package/dist/models/ProfileMetafield.d.ts.map +1 -0
  79. package/dist/models/ProfileRelationship.d.ts +56 -0
  80. package/dist/models/ProfileRelationship.d.ts.map +1 -0
  81. package/dist/models/ProfileRelationshipTerm.d.ts +37 -0
  82. package/dist/models/ProfileRelationshipTerm.d.ts.map +1 -0
  83. package/dist/models/ProfileRelationshipType.d.ts +59 -0
  84. package/dist/models/ProfileRelationshipType.d.ts.map +1 -0
  85. package/dist/models/ProfileType.d.ts +27 -0
  86. package/dist/models/ProfileType.d.ts.map +1 -0
  87. package/dist/models/ProfileTypes.d.ts +32 -0
  88. package/dist/models/ProfileTypes.d.ts.map +1 -0
  89. package/dist/models/index.d.ts +18 -0
  90. package/dist/models/index.d.ts.map +1 -0
  91. package/dist/prompts.d.ts +17 -0
  92. package/dist/prompts.d.ts.map +1 -0
  93. package/dist/smrt-knowledge.json +4 -4
  94. package/dist/testing/oidcProvisioningDecisionMatrix.d.ts +1168 -0
  95. package/dist/testing/oidcProvisioningDecisionMatrix.d.ts.map +1 -0
  96. package/dist/types.d.ts +33 -732
  97. package/dist/types.d.ts.map +1 -0
  98. package/dist/utils.d.ts +52 -817
  99. package/dist/utils.d.ts.map +1 -0
  100. package/package.json +7 -7
package/dist/types.d.ts CHANGED
@@ -1,738 +1,39 @@
1
- import { Asset } from '@happyvertical/smrt-assets';
2
- import { SmrtObject } from '@happyvertical/smrt-core';
3
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
4
-
5
- declare class ApiKey extends SmrtObject {
6
- /**
7
- * Link to the Profile (Person, Organization, Bot)
8
- */
9
- profileId?: string;
10
- /**
11
- * SHA-256 hash of the API key.
12
- *
13
- * Indexed: `verify()` looks keys up by this hash on every authenticated
14
- * request (#2364, epic #2382 finding A3).
15
- */
16
- keyHash: string;
17
- /**
18
- * First 8 characters of the key for identification (e.g., "sk_live_a1b2...")
19
- */
20
- keyPrefix: string;
21
- /**
22
- * Human-readable name for the key (e.g., "CI Bot", "Local CLI")
23
- */
24
- name: string;
25
- /**
26
- * Scopes/permissions for this key
27
- */
28
- scopes: string[];
29
- /**
30
- * Last time this key was used
31
- */
32
- lastUsedAt: Date | null;
33
- /**
34
- * When this key expires (null = never)
35
- */
36
- expiresAt: Date | null;
37
- /**
38
- * When this key was revoked (null = active)
39
- */
40
- revokedAt: Date | null;
41
- constructor(options?: ApiKeyOptions);
42
- /**
43
- * Get the linked Profile
44
- */
45
- getProfile(): Promise<Profile | null>;
46
- /**
47
- * Check if this key is valid (not expired, not revoked)
48
- */
49
- isValid(): boolean;
50
- /**
51
- * Check if this key has a specific scope
52
- */
53
- hasScope(scope: string): boolean;
54
- /**
55
- * Revoke this key
56
- */
57
- revoke(): Promise<void>;
58
- /**
59
- * Record usage of this key
60
- */
61
- recordUsage(): Promise<void>;
62
- /**
63
- * Hash an API key
64
- */
65
- static hashKey(key: string): string;
66
- /**
67
- * Generate a new API key for a profile
68
- */
69
- static generate(profile: Profile, options: {
70
- name: string;
71
- scopes?: string[];
72
- expiresAt?: Date | null;
73
- db?: SmrtObjectOptions['db'];
74
- }): Promise<GenerateKeyResult>;
75
- /**
76
- * Verify an API key and return the ApiKey record if valid
77
- */
78
- static verify(key: string, options?: SmrtObjectOptions): Promise<ApiKey | null>;
79
- }
80
-
81
- declare interface ApiKeyOptions extends SmrtObjectOptions {
82
- profileId?: string;
83
- name?: string;
84
- scopes?: string[];
85
- expiresAt?: Date | null;
86
- }
87
-
88
- declare class AuditLog extends SmrtObject {
89
- tenantId: string | null;
90
- /**
91
- * The profile who performed the action
92
- */
93
- profileId?: string;
94
- /**
95
- * Action performed (e.g., 'issue.update', 'feedback.incorporate')
96
- */
97
- action: string;
98
- /**
99
- * Type of resource affected (e.g., 'Issue', 'Repository')
100
- */
101
- resourceType: string;
102
- /**
103
- * ID of the affected resource
104
- */
105
- resourceId: string;
106
- /**
107
- * Source of the action
108
- */
109
- source: AuditSource;
110
- /**
111
- * Additional context (CI run ID, request ID, etc.)
112
- */
113
- metadata: Record<string, unknown>;
114
- /**
115
- * For pass-through identity in CI - the actual person who triggered
116
- */
117
- onBehalfOfId?: string | null;
118
- constructor(options?: AuditLogOptions);
119
- /**
120
- * Get the profile who performed the action
121
- */
122
- getProfile(): Promise<Profile | null>;
123
- /**
124
- * Get the profile on whose behalf the action was performed (if any)
125
- */
126
- getOnBehalfOf(): Promise<Profile | null>;
127
- /**
128
- * Get the effective actor (onBehalfOf if set, otherwise profile)
129
- */
130
- getEffectiveActor(): Promise<Profile | null>;
131
- /**
132
- * Create an audit log entry
133
- */
134
- static record(options: AuditLogOptions & {
135
- profile: Profile;
136
- onBehalfOf?: Profile | null;
137
- }): Promise<AuditLog>;
138
- }
139
-
140
- declare interface AuditLogOptions extends SmrtObjectOptions {
141
- profileId?: string;
142
- action?: string;
143
- resourceType?: string;
144
- resourceId?: string;
145
- source?: AuditSource;
146
- metadata?: Record<string, unknown>;
147
- onBehalfOfId?: string | null;
148
- tenantId?: string | null;
149
- }
150
-
151
- declare type AuditSource = 'web' | 'cli' | 'ci' | 'webhook' | 'mcp';
152
-
153
- declare interface GenerateKeyResult {
154
- key: string;
155
- apiKey: ApiKey;
156
- }
157
-
158
- declare class NostrIdentity extends SmrtObject {
159
- /**
160
- * Link to the Profile (Person, Organization, Bot)
161
- */
162
- profileId?: string;
163
- /**
164
- * Hex-encoded secp256k1 public key (64 characters).
165
- *
166
- * Indexed: `findByPubkey()` looks identities up by this column (#2364,
167
- * epic #2382 finding A3).
168
- */
169
- pubkey: string;
170
- /**
171
- * AES-256-GCM encrypted private key (base64-encoded ciphertext)
172
- */
173
- encryptedPrivkey: string;
174
- /**
175
- * Initialization vector for AES-GCM decryption (base64)
176
- */
177
- encryptionIv: string;
178
- /**
179
- * Authentication tag from AES-GCM (base64)
180
- */
181
- encryptionTag: string;
182
- /**
183
- * Email address associated with this identity
184
- */
185
- email: string;
186
- /**
187
- * Username for NIP-05 verification (e.g., "alice" for alice@domain.com)
188
- */
189
- nip05Username: string;
190
- /**
191
- * Last time this identity was used for authentication
192
- */
193
- lastUsedAt: Date | null;
194
- /**
195
- * When this identity was verified via magic link
196
- */
197
- verifiedAt: Date | null;
198
- constructor(options?: NostrIdentityOptions);
199
- /**
200
- * Get the linked Profile
201
- */
202
- getProfile(): Promise<Profile | null>;
203
- /**
204
- * Find identity by public key
205
- */
206
- static findByPubkey(pubkey: string, options?: SmrtObjectOptions): Promise<NostrIdentity | null>;
207
- /**
208
- * Find identity by email
209
- */
210
- static findByEmail(email: string, options?: SmrtObjectOptions): Promise<NostrIdentity | null>;
211
- /**
212
- * Find identity by NIP-05 username
213
- */
214
- static findByNip05(username: string, options?: SmrtObjectOptions): Promise<NostrIdentity | null>;
215
- /**
216
- * Decrypt the private key using the server master secret
217
- * @param masterSecret - SERVER_MASTER_SECRET from environment
218
- * @returns Hex-encoded private key
219
- */
220
- decryptPrivkey(masterSecret: string): string;
221
- /**
222
- * Get the full keypair (requires master secret)
223
- * @param masterSecret - SERVER_MASTER_SECRET from environment
224
- */
225
- getKeypair(masterSecret: string): {
226
- pubkey: string;
227
- privkey: string;
228
- npub: string;
229
- nsec: string;
230
- };
231
- /**
232
- * Record usage of this identity
233
- */
234
- recordUsage(): Promise<void>;
235
- /**
236
- * Mark this identity as verified
237
- */
238
- markVerified(): Promise<void>;
239
- /**
240
- * Check if this identity is verified
241
- */
242
- isVerified(): boolean;
243
- /**
244
- * Get the NIP-05 identifier (username@domain)
245
- * Note: Domain must be provided by the application
246
- */
247
- getNip05Identifier(domain: string): string;
248
- }
249
-
250
- declare interface NostrIdentityOptions extends SmrtObjectOptions {
251
- profileId?: string;
252
- pubkey?: string;
253
- encryptedPrivkey?: string;
254
- encryptionIv?: string;
255
- encryptionTag?: string;
256
- email?: string;
257
- nip05Username?: string;
258
- lastUsedAt?: Date | null;
259
- verifiedAt?: Date | null;
260
- }
261
-
262
- declare class OidcIdentity extends SmrtObject {
263
- /**
264
- * Link to the Profile (Person, Organization, Bot)
265
- */
266
- profileId?: string;
267
- /**
268
- * Provider name (e.g., 'keycloak', 'google', 'github')
269
- */
270
- provider: string;
271
- /**
272
- * OIDC issuer URL (e.g., https://keycloak.example.com/realms/bmp)
273
- */
274
- issuer: string;
275
- /**
276
- * OIDC subject claim - unique identifier from the provider
277
- */
278
- subject: string;
279
- /**
280
- * Stable issuer+subject key used as the database race arbiter.
281
- *
282
- * Nullable for legacy rows; every newly linked or reused identity backfills
283
- * it. A separate unique constraint makes concurrent first login fail with a
284
- * retryable conflict instead of creating two identities.
285
- */
286
- identityKey: string | null;
287
- /**
288
- * Cached email from the IdP (for display/lookup)
289
- */
290
- email: string;
291
- /**
292
- * Last time this identity was used for authentication
293
- */
294
- lastUsedAt: Date | null;
295
- constructor(options?: OidcIdentityOptions);
296
- /**
297
- * Get the linked Profile
298
- */
299
- getProfile(): Promise<Profile | null>;
300
- /**
301
- * Find identity by issuer and subject
302
- */
303
- static findBySubject(issuer: string, subject: string, options?: SmrtObjectOptions): Promise<OidcIdentity | null>;
304
- /** Build the collision-free natural key for one OIDC issuer subject. */
305
- static buildIdentityKey(issuer: string, subject: string): string;
306
- /** Keep the durable key derived from its natural-key source fields. */
307
- save(): Promise<this>;
308
- /**
309
- * Reuse an existing exact identity for its unchanged Profile.
310
- *
311
- * @deprecated Authentication links must be created through transactional
312
- * provisioning. This compatibility method only refreshes a unique mapping
313
- * that already belongs to the supplied Profile, including legacy Profile
314
- * types, and deliberately refuses to create or rebind authority.
315
- */
316
- static findOrCreate(profile: Profile, oidcData: {
317
- provider: string;
318
- issuer: string;
319
- subject: string;
320
- email?: string;
321
- }, options?: SmrtObjectOptions): Promise<OidcIdentity>;
322
- /**
323
- * Record usage of this identity
324
- */
325
- recordUsage(): Promise<void>;
326
- }
327
-
328
- declare interface OidcIdentityOptions extends SmrtObjectOptions {
329
- profileId?: string;
330
- provider?: string;
331
- issuer?: string;
332
- subject?: string;
333
- email?: string;
334
- lastUsedAt?: Date | null;
335
- }
336
-
337
- declare class Profile extends SmrtObject {
338
- tenantId: string | null;
339
- typeId?: string;
340
- email?: string;
341
- /** Adapter-independent identity lookup key derived from email on save. */
342
- emailKey: string | null;
343
- name: string;
344
- description?: string;
345
- metadata: ProfileMetadata[];
346
- relationshipsFrom: ProfileRelationship[];
347
- relationshipsTo: ProfileRelationship[];
348
- constructor(options?: ProfileOptions);
349
- /** Keep the durable identity key derived from the public email field. */
350
- save(): Promise<this>;
351
- /**
352
- * Get the profile type slug for this profile
353
- *
354
- * @returns The slug of the profile type
355
- */
356
- getTypeSlug(): Promise<string>;
357
- /**
358
- * Set the profile type by slug
359
- *
360
- * @param slug - The slug of the profile type
361
- * @throws Error if profile type not found
362
- */
363
- setTypeBySlug(slug: string): Promise<void>;
364
- /**
365
- * Add metadata to this profile
366
- *
367
- * @param metafieldSlug - The slug of the metafield
368
- * @param value - The value to set
369
- */
370
- addMetadata(metafieldSlug: string, value: unknown): Promise<void>;
371
- /**
372
- * Get all metadata for this profile as key-value object
373
- *
374
- * @returns Object with metafield slugs as keys
375
- */
376
- getMetadata(): Promise<Record<string, string>>;
377
- /**
378
- * Update multiple metadata values
379
- *
380
- * @param metadata - Object with metafield slugs as keys and values
381
- */
382
- updateMetadata(metadata: Record<string, unknown>): Promise<void>;
383
- /**
384
- * Remove metadata by metafield slug
385
- *
386
- * @param metafieldSlug - The slug of the metafield to remove
387
- */
388
- removeMetadata(metafieldSlug: string): Promise<void>;
389
- private getProfileAssetCollection;
390
- getAssets(relationship?: string): Promise<Asset[]>;
391
- addAsset(asset: Asset, relationship?: string, sortOrder?: number): Promise<void>;
392
- removeAsset(assetId: string, relationship?: string): Promise<void>;
393
- /**
394
- * Add a relationship to another profile
395
- *
396
- * @param toProfile - The target profile
397
- * @param relationshipSlug - The type of relationship
398
- * @param contextProfile - Optional context profile for tertiary relationships
399
- */
400
- addRelationship(toProfile: Profile, relationshipSlug: string, contextProfile?: Profile): Promise<void>;
401
- /**
402
- * Get all relationships for this profile
403
- *
404
- * @param options - Filter options (typeSlug, direction)
405
- * @returns Array of ProfileRelationship instances
406
- */
407
- getRelationships(options?: {
408
- typeSlug?: string;
409
- direction?: 'from' | 'to' | 'all';
410
- }): Promise<ProfileRelationship[]>;
411
- /**
412
- * Get related profiles
413
- *
414
- * @param relationshipSlug - Optional filter by relationship type slug
415
- * @returns Array of related Profile instances
416
- */
417
- getRelatedProfiles(relationshipSlug?: string): Promise<Profile[]>;
418
- /**
419
- * Remove a relationship to another profile
420
- *
421
- * @param toProfile - The target profile
422
- * @param relationshipSlug - The type of relationship to remove
423
- */
424
- removeRelationship(toProfile: Profile, relationshipSlug: string): Promise<void>;
425
- /**
426
- * AI-powered: Generate a professional bio for this profile
427
- *
428
- * Uses the `smrtProfiles.profile.generateBio` prompt registered via
429
- * `@happyvertical/smrt-prompts`, allowing tenant- or instance-level
430
- * overrides of the template, model, and parameters at runtime.
431
- *
432
- * @returns Generated bio text
433
- */
434
- generateBio(): Promise<string>;
435
- /**
436
- * AI-powered: Check if profile matches criteria
437
- *
438
- * @param criteria - Criteria to match against
439
- * @returns True if matches criteria
440
- */
441
- matches(criteria: string): Promise<boolean>;
442
- /**
443
- * Find profiles by metadata key-value pair
444
- *
445
- * @param metafieldSlug - The metafield slug to search
446
- * @param value - The value to match
447
- * @returns Array of matching profiles
448
- */
449
- static findByMetadata(_metafieldSlug: string, _value: unknown): Promise<Profile[]>;
450
- /**
451
- * Find profiles by type slug
452
- *
453
- * @param typeSlug - The profile type slug
454
- * @returns Array of matching profiles
455
- */
456
- static findByType(_typeSlug: string): Promise<Profile[]>;
457
- /**
458
- * Find related profiles for a given profile
459
- *
460
- * @param profileId - The profile UUID
461
- * @param relationshipSlug - Optional filter by relationship type
462
- * @returns Array of related profiles
463
- */
464
- static findRelated(_profileId: string, _relationshipSlug?: string): Promise<Profile[]>;
465
- /**
466
- * Search profiles by email
467
- *
468
- * @param email - The email to search for
469
- * @returns Profile or null if not found
470
- */
471
- static searchByEmail(_email: string): Promise<Profile | null>;
472
- /**
473
- * Get all API keys for this profile
474
- *
475
- * @returns Array of API keys
476
- */
477
- getApiKeys(): Promise<ApiKey[]>;
478
- /**
479
- * Get active (non-revoked, non-expired) API keys for this profile
480
- *
481
- * @returns Array of active API keys
482
- */
483
- getActiveApiKeys(): Promise<ApiKey[]>;
484
- /**
485
- * Generate a new API key for this profile
486
- *
487
- * @param options - Key options (name, scopes, expiration)
488
- * @returns The generated key (plaintext) and ApiKey record
489
- */
490
- generateApiKey(options: {
491
- name: string;
492
- scopes?: string[];
493
- expiresAt?: Date | null;
494
- }): Promise<GenerateKeyResult>;
495
- /**
496
- * Get all OIDC identities linked to this profile
497
- *
498
- * @returns Array of OIDC identity records
499
- */
500
- getOidcIdentities(): Promise<OidcIdentity[]>;
501
- /**
502
- * Reuse an existing exact OIDC identity for this unchanged Profile.
503
- *
504
- * @param oidcData - OIDC provider data
505
- * @returns The linked OIDC identity record
506
- * @deprecated New authentication links require owner-aware transactional
507
- * provisioning. This compatibility helper may refresh a legacy Profile
508
- * type, but refuses to create or rebind authority.
509
- */
510
- linkOidcIdentity(oidcData: {
511
- provider: string;
512
- issuer: string;
513
- subject: string;
514
- email?: string;
515
- }): Promise<OidcIdentity>;
516
- /**
517
- * Get all Nostr identities linked to this profile
518
- *
519
- * @returns Array of Nostr identity records
520
- */
521
- getNostrIdentities(): Promise<NostrIdentity[]>;
522
- /**
523
- * Link a new Nostr identity to this profile
524
- *
525
- * @param nostrData - Nostr identity data (encrypted keypair)
526
- * @returns The linked Nostr identity record
527
- */
528
- linkNostrIdentity(nostrData: {
529
- pubkey: string;
530
- encryptedPrivkey: string;
531
- encryptionIv: string;
532
- encryptionTag: string;
533
- email: string;
534
- nip05Username?: string;
535
- }): Promise<NostrIdentity>;
536
- /**
537
- * Get audit logs for actions performed by this profile
538
- *
539
- * @param limit - Maximum number of logs to return
540
- * @returns Array of audit log entries
541
- */
542
- getAuditLogs(limit?: number): Promise<AuditLog[]>;
543
- /**
544
- * Record an audit log entry for an action by this profile
545
- *
546
- * @param options - Audit log options
547
- * @returns The created audit log entry
548
- */
549
- recordAction(options: {
550
- action: string;
551
- resourceType: string;
552
- resourceId: string;
553
- source?: 'web' | 'cli' | 'ci' | 'webhook' | 'mcp';
554
- metadata?: Record<string, unknown>;
555
- onBehalfOf?: Profile | null;
556
- }): Promise<AuditLog>;
557
- }
558
-
559
- declare class ProfileMetadata extends SmrtObject {
560
- tenantId: string | null;
561
- profileId?: string;
562
- metafieldId?: string;
563
- value: string;
564
- constructor(options?: ProfileMetadataOptions);
565
- /**
566
- * Validate this metadata value against the metafield's validation schema
567
- *
568
- * @returns True if valid, throws error if invalid
569
- */
570
- validate(): Promise<boolean>;
571
- /**
572
- * Get the metafield slug for this metadata
573
- *
574
- * @returns The slug of the metafield
575
- */
576
- getMetafieldSlug(): Promise<string>;
577
- }
578
-
579
- declare interface ProfileMetadataOptions extends SmrtObjectOptions {
580
- profileId?: string;
581
- metafieldId?: string;
582
- value?: string;
583
- tenantId?: string | null;
584
- }
585
-
586
- declare interface ProfileOptions extends SmrtObjectOptions {
587
- typeId?: string;
588
- email?: string;
589
- name?: string;
590
- description?: string;
591
- tenantId?: string | null;
592
- }
593
-
594
- declare class ProfileRelationship extends SmrtObject {
595
- tenantId: string | null;
596
- fromProfileId?: string;
597
- toProfileId?: string;
598
- typeId?: string;
599
- contextProfileId?: string;
600
- terms: ProfileRelationshipTerm[];
601
- constructor(options?: ProfileRelationshipOptions);
602
- /**
603
- * Get the relationship type slug
604
- *
605
- * @returns The slug of the relationship type
606
- */
607
- getTypeSlug(): Promise<string>;
608
- /**
609
- * Add a term (time period) to this relationship
610
- *
611
- * @param startedAt - Start date of the term
612
- * @param endedAt - Optional end date of the term
613
- */
614
- addTerm(startedAt: Date, endedAt?: Date): Promise<void>;
615
- /**
616
- * End the current active term
617
- *
618
- * @param endedAt - End date for the term
619
- */
620
- endCurrentTerm(endedAt: Date): Promise<void>;
621
- /**
622
- * Get all terms for this relationship
623
- *
624
- * @returns Array of ProfileRelationshipTerm instances
625
- */
626
- getTerms(): Promise<ProfileRelationshipTerm[]>;
627
- /**
628
- * Get the active term (no end date)
629
- *
630
- * @returns Current term or null if none active
631
- */
632
- getActiveTerm(): Promise<ProfileRelationshipTerm | null>;
633
- }
634
-
635
- declare interface ProfileRelationshipOptions extends SmrtObjectOptions {
636
- fromProfileId?: string;
637
- toProfileId?: string;
638
- typeId?: string;
639
- contextProfileId?: string;
640
- tenantId?: string | null;
641
- }
642
-
643
- declare class ProfileRelationshipTerm extends SmrtObject {
644
- relationshipId?: string;
645
- startedAt: Date;
646
- endedAt?: Date;
647
- constructor(options?: ProfileRelationshipTermOptions);
648
- /**
649
- * Check if this term is currently active
650
- *
651
- * @returns True if active (no end date or end date in future)
652
- */
653
- isActive(): boolean;
654
- /**
655
- * End this term
656
- *
657
- * @param endedAt - End date for the term (defaults to now)
658
- */
659
- end(endedAt?: Date): Promise<void>;
660
- /**
661
- * Get the duration of this term in days
662
- *
663
- * @returns Duration in days
664
- */
665
- getDurationDays(): number;
666
- }
667
-
668
- declare interface ProfileRelationshipTermOptions extends SmrtObjectOptions {
669
- relationshipId?: string;
670
- startedAt?: Date;
671
- endedAt?: Date;
672
- }
673
-
674
- /**
675
- * Handler function interface for reciprocal relationships
676
- *
677
- * @param from - The profile initiating the relationship
678
- * @param to - The target profile
679
- * @param context - Optional context profile for tertiary relationships
680
- * @param options - Additional options for the handler
681
- */
682
- export declare type ReciprocalHandler = (from: Profile, to: Profile, context?: Profile, options?: Record<string, unknown>) => Promise<void>;
683
-
684
- /**
685
- * Validation schema structure for profile metadata fields
686
- */
687
- export declare interface ValidationSchema {
688
- /** Type constraint */
689
- type?: 'string' | 'number' | 'boolean' | 'date' | 'json';
690
- /** Regex pattern for string validation */
691
- pattern?: string;
692
- /** Minimum string length */
693
- minLength?: number;
694
- /** Maximum string length */
695
- maxLength?: number;
696
- /** Minimum numeric value */
697
- min?: number;
698
- /** Maximum numeric value */
699
- max?: number;
700
- /** Custom validator function name */
701
- custom?: string;
702
- /** Custom validation error message */
703
- message?: string;
704
- }
705
-
706
- /**
707
- * Custom validator function type
708
- */
709
- export declare type ValidatorFunction = (value: unknown) => boolean | Promise<boolean>;
710
-
711
- export { }
712
-
713
-
714
1
  /**
715
- * Extend globalThis to include reciprocal handlers registry.
716
- * Using globalThis ensures all module instances share the same handlers,
717
- * which is critical in monorepos where the same package can be loaded
718
- * from different paths (e.g., pnpm store vs workspace symlink).
719
- *
720
- * @see https://github.com/happyvertical/smrt/issues/543
2
+ * TypeScript type definitions for @have/profiles package
721
3
  */
722
- declare global {
723
- var __smrtProfileRelationshipHandlers: Map<string, ReciprocalHandler> | undefined;
724
- var __smrtProfileRelationshipHandlersInitialized: boolean | undefined;
725
- }
726
-
727
-
4
+ import type { Profile } from './models/Profile';
728
5
  /**
729
- * Extend globalThis to include custom validators registry.
730
- * Using globalThis ensures all module instances share the same validators,
731
- * which is critical in monorepos where the same package can be loaded
732
- * from different paths (e.g., pnpm store vs workspace symlink).
6
+ * Handler function interface for reciprocal relationships
733
7
  *
734
- * @see https://github.com/happyvertical/smrt/issues/543
8
+ * @param from - The profile initiating the relationship
9
+ * @param to - The target profile
10
+ * @param context - Optional context profile for tertiary relationships
11
+ * @param options - Additional options for the handler
12
+ */
13
+ export type ReciprocalHandler = (from: Profile, to: Profile, context?: Profile, options?: Record<string, unknown>) => Promise<void>;
14
+ /**
15
+ * Validation schema structure for profile metadata fields
735
16
  */
736
- declare global {
737
- var __smrtProfileMetafieldValidators: Map<string, ValidatorFunction> | undefined;
17
+ export interface ValidationSchema {
18
+ /** Type constraint */
19
+ type?: 'string' | 'number' | 'boolean' | 'date' | 'json';
20
+ /** Regex pattern for string validation */
21
+ pattern?: string;
22
+ /** Minimum string length */
23
+ minLength?: number;
24
+ /** Maximum string length */
25
+ maxLength?: number;
26
+ /** Minimum numeric value */
27
+ min?: number;
28
+ /** Maximum numeric value */
29
+ max?: number;
30
+ /** Custom validator function name */
31
+ custom?: string;
32
+ /** Custom validation error message */
33
+ message?: string;
738
34
  }
35
+ /**
36
+ * Custom validator function type
37
+ */
38
+ export type ValidatorFunction = (value: unknown) => boolean | Promise<boolean>;
39
+ //# sourceMappingURL=types.d.ts.map