@memberjunction/core-entities-server 6.1.0-edge.2 → 6.1.0-edge.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/LICENSE +180 -4
- package/README.md +1 -1
- package/dist/custom/MJActionEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJActionEntityServer.server.js +4 -3
- package/dist/custom/MJActionEntityServer.server.js.map +1 -1
- package/dist/custom/MJCompanyIntegrationEntityServer.server.d.ts +36 -21
- package/dist/custom/MJCompanyIntegrationEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJCompanyIntegrationEntityServer.server.js +37 -51
- package/dist/custom/MJCompanyIntegrationEntityServer.server.js.map +1 -1
- package/dist/custom/MJMaterializedResultEntityServer.server.d.ts +23 -0
- package/dist/custom/MJMaterializedResultEntityServer.server.d.ts.map +1 -0
- package/dist/custom/MJMaterializedResultEntityServer.server.js +64 -0
- package/dist/custom/MJMaterializedResultEntityServer.server.js.map +1 -0
- package/dist/custom/MJVectorIndexEntityServer.server.d.ts +9 -2
- package/dist/custom/MJVectorIndexEntityServer.server.d.ts.map +1 -1
- package/dist/custom/MJVectorIndexEntityServer.server.js +25 -7
- package/dist/custom/MJVectorIndexEntityServer.server.js.map +1 -1
- package/dist/engines/IdentityClaimEngineServer.d.ts +147 -0
- package/dist/engines/IdentityClaimEngineServer.d.ts.map +1 -0
- package/dist/engines/IdentityClaimEngineServer.js +555 -0
- package/dist/engines/IdentityClaimEngineServer.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +29 -26
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseEntity, BaseEntityResult, LogError, RunView } from '@memberjunction/core';
|
|
8
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
9
|
+
import { MJMaterializedResultEntity } from '@memberjunction/core-entities';
|
|
10
|
+
/**
|
|
11
|
+
* Server-side `MJ: Materialized Results` entity. Removes the `MJ: Materialized Result Queries` join row(s)
|
|
12
|
+
* that reference this materialization BEFORE the row itself is deleted.
|
|
13
|
+
*
|
|
14
|
+
* The join FKs deliberately have NO `ON DELETE CASCADE` (the MaterializedResult↔Query cascade is kept at the
|
|
15
|
+
* application layer so a physical snapshot is never silently dropped by the DB engine). When a *Query* is
|
|
16
|
+
* deleted, the generated `spDeleteQuery` already cascades its join row; this override covers the REVERSE
|
|
17
|
+
* direction — deleting the MaterializedResult directly — which would otherwise surface a raw
|
|
18
|
+
* `FK_MaterializedResultQuery_MaterializedResult` violation. FK-cleanup-before-delete pattern
|
|
19
|
+
* (guides/BASE_ENTITY_SERVER_PATTERNS.md).
|
|
20
|
+
*
|
|
21
|
+
* Out of scope here (tracked as follow-ups): dropping the physical `materialized_vw<…>` snapshot table/view on
|
|
22
|
+
* delete, and whether deleting a source Query should cascade-delete or block on its materialization — both
|
|
23
|
+
* involve DDL on the delete path and a cascade-vs-block semantics decision.
|
|
24
|
+
*/
|
|
25
|
+
let MJMaterializedResultEntityServer = class MJMaterializedResultEntityServer extends MJMaterializedResultEntity {
|
|
26
|
+
async Delete(options) {
|
|
27
|
+
if (this.IsSaved) {
|
|
28
|
+
const md = this.ProviderToUse;
|
|
29
|
+
const rv = RunView.FromMetadataProvider(md);
|
|
30
|
+
const links = await rv.RunView({
|
|
31
|
+
EntityName: 'MJ: Materialized Result Queries',
|
|
32
|
+
ExtraFilter: `MaterializedResultID='${this.ID.replace(/'/g, "''")}'`,
|
|
33
|
+
ResultType: 'entity_object',
|
|
34
|
+
}, this.ContextCurrentUser);
|
|
35
|
+
if (!links.Success) {
|
|
36
|
+
return this.failDelete(`Failed to load linked MaterializedResultQuery rows: ${links.ErrorMessage ?? 'unknown error'}`);
|
|
37
|
+
}
|
|
38
|
+
for (const link of links.Results ?? []) {
|
|
39
|
+
const deleted = await link.Delete();
|
|
40
|
+
if (!deleted) {
|
|
41
|
+
return this.failDelete(`Failed to delete linked MaterializedResultQuery ${link.ID}: ${link.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return super.Delete(options);
|
|
46
|
+
}
|
|
47
|
+
/** Records a delete failure on the result history and returns false (Delete does not throw on a logical failure). */
|
|
48
|
+
failDelete(message) {
|
|
49
|
+
LogError(`MJMaterializedResultEntityServer.Delete: ${message}`);
|
|
50
|
+
const result = new BaseEntityResult();
|
|
51
|
+
result.StartedAt = new Date();
|
|
52
|
+
result.Success = false;
|
|
53
|
+
result.Type = 'delete';
|
|
54
|
+
result.Message = message;
|
|
55
|
+
result.EndedAt = new Date();
|
|
56
|
+
this.RegisterResultHistoryEntry(result);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
MJMaterializedResultEntityServer = __decorate([
|
|
61
|
+
RegisterClass(BaseEntity, 'MJ: Materialized Results')
|
|
62
|
+
], MJMaterializedResultEntityServer);
|
|
63
|
+
export { MJMaterializedResultEntityServer };
|
|
64
|
+
//# sourceMappingURL=MJMaterializedResultEntityServer.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MJMaterializedResultEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJMaterializedResultEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UA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C,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,qHAAqH;IAC7G,UAAU,CAAC,OAAe;QAC9B,QAAQ,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACtC,MAAM,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;QACvB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,MAAM,CAAC,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AAtCY,gCAAgC;IAD5C,aAAa,CAAC,UAAU,EAAE,0BAA0B,CAAC;GACzC,gCAAgC,CAsC5C"}
|
|
@@ -33,8 +33,15 @@ export declare class MJVectorIndexEntityServer extends MJVectorIndexEntity {
|
|
|
33
33
|
*/
|
|
34
34
|
private getVectorDBInstance;
|
|
35
35
|
/**
|
|
36
|
-
* Resolve embedding dimensions
|
|
37
|
-
*
|
|
36
|
+
* Resolve the embedding dimensions to create the provider index at.
|
|
37
|
+
*
|
|
38
|
+
* Prefers this index's own `Dimensions` column, which is where the operator states it and what the
|
|
39
|
+
* embedding call already honors. Falling straight through to 1536 ignored that column entirely, so
|
|
40
|
+
* an index for any other model was created at the wrong width — harmless with providers that don't
|
|
41
|
+
* enforce it, and fatal with ones that do: a colocated SQL Server index is a `VECTOR(n)` column, and
|
|
42
|
+
* inserting 384-dimension vectors into a `VECTOR(1536)` is rejected outright.
|
|
43
|
+
*
|
|
44
|
+
* 1536 (OpenAI text-embedding-3-small) remains the fallback for records that never set it.
|
|
38
45
|
*/
|
|
39
46
|
private resolveDimensions;
|
|
40
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJVectorIndexEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJVectorIndexEntityServer.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAI5F;;;;GAIG;AACH,qBACa,yBAA0B,SAAQ,mBAAmB;IAC9D;;OAEG;IACmB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAa9C;;OAEG;IACmB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAShD;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;OAEG;YACW,qBAAqB;IAuCnC;;OAEG;YACW,uBAAuB;IAkBrC;;;OAGG;YACW,mBAAmB;
|
|
1
|
+
{"version":3,"file":"MJVectorIndexEntityServer.server.d.ts","sourceRoot":"","sources":["../../src/custom/MJVectorIndexEntityServer.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAI5F;;;;GAIG;AACH,qBACa,yBAA0B,SAAQ,mBAAmB;IAC9D;;OAEG;IACmB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAa9C;;OAEG;IACmB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAShD;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;OAEG;YACW,qBAAqB;IAuCnC;;OAEG;YACW,uBAAuB;IAkBrC;;;OAGG;YACW,mBAAmB;IAgDjC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,iBAAiB;IAIzB;;;OAGG;YACW,oBAAoB;CAiCrC"}
|
|
@@ -143,21 +143,39 @@ let MJVectorIndexEntityServer = class MJVectorIndexEntityServer extends MJVector
|
|
|
143
143
|
LogError(`VectorDatabase "${vectorDB.Name}" has no ClassKey configured`);
|
|
144
144
|
return null;
|
|
145
145
|
}
|
|
146
|
+
// Instantiate BEFORE gating on the key, then wire the host connection. A colocated provider
|
|
147
|
+
// (SQLServerVectorDatabase, pgvector) stores vectors in this same database: it has no
|
|
148
|
+
// credentials to present, and it throws "requires a host connection" unless the active data
|
|
149
|
+
// provider is handed to it. Neither is knowable until the instance exists. Same ordering as
|
|
150
|
+
// the EntityDocument and ContentSource vectorization pipelines.
|
|
151
|
+
// The sentinel is required: `VectorDBBase`'s constructor rejects an empty key and colocated
|
|
152
|
+
// providers do not override it, so '' would throw for the very case this supports.
|
|
146
153
|
const apiKey = GetAIAPIKey(classKey);
|
|
147
|
-
|
|
154
|
+
const instance = MJGlobal.Instance.ClassFactory.CreateInstance(VectorDBBase, classKey, apiKey || 'colocated');
|
|
155
|
+
if (!instance) {
|
|
156
|
+
LogError(`Failed to create vector DB instance for "${classKey}"`);
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
instance.TryWireColocatedHost(this.ProviderToUse);
|
|
160
|
+
if (!instance.SupportsColocatedQuery && instance.RequiresAPIKey && !apiKey) {
|
|
148
161
|
LogError(`No API key found for vector DB provider "${classKey}"`);
|
|
149
162
|
return null;
|
|
150
163
|
}
|
|
151
|
-
return
|
|
164
|
+
return instance;
|
|
152
165
|
}
|
|
153
166
|
/**
|
|
154
|
-
* Resolve embedding dimensions
|
|
155
|
-
*
|
|
167
|
+
* Resolve the embedding dimensions to create the provider index at.
|
|
168
|
+
*
|
|
169
|
+
* Prefers this index's own `Dimensions` column, which is where the operator states it and what the
|
|
170
|
+
* embedding call already honors. Falling straight through to 1536 ignored that column entirely, so
|
|
171
|
+
* an index for any other model was created at the wrong width — harmless with providers that don't
|
|
172
|
+
* enforce it, and fatal with ones that do: a colocated SQL Server index is a `VECTOR(n)` column, and
|
|
173
|
+
* inserting 384-dimension vectors into a `VECTOR(1536)` is rejected outright.
|
|
174
|
+
*
|
|
175
|
+
* 1536 (OpenAI text-embedding-3-small) remains the fallback for records that never set it.
|
|
156
176
|
*/
|
|
157
177
|
resolveDimensions() {
|
|
158
|
-
|
|
159
|
-
// For now, default to 1536 which covers most common embedding models
|
|
160
|
-
return 1536;
|
|
178
|
+
return this.Dimensions ?? 1536;
|
|
161
179
|
}
|
|
162
180
|
/**
|
|
163
181
|
* After provider creates the index, save the returned metadata back to our record.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MJVectorIndexEntityServer.server.js","sourceRoot":"","sources":["../../src/custom/MJVectorIndexEntityServer.server.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAY,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,YAAY,EAA2C,MAAM,6BAA6B,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;GAIG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,mBAAmB;IAC9D;;OAEG;IACa,KAAK,CAAC,IAAI;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC;QACrC,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEtC,IAAI,UAAU,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACzC,QAAQ,CAAC,2BAA2B,IAAI,CAAC,IAAI,yBAAyB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAC9F,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;OAEG;IACa,KAAK,CAAC,MAAM;QACxB,oFAAoF;QACpF,MAAM,IAAI,CAAC,uBAAuB,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACjD,QAAQ,CAAC,2BAA2B,IAAI,CAAC,IA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;gBACtE,IAAI,QAAQ,IAAI,cAAc;oBAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;YAChF,CAAC;YACD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAE7C,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YACjC,IAAI,KAAK,EAAE,CAAC;gBACR,SAAS,CAAC,sCAAsC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;YAClE,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,+CAA+C,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,CAAC,CAAC;YACjH,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,QAAQ,CAAC,6CAA6C,IAAI,CAAC,IAAI,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC1F,CAAC;IACL,CAAC;CACJ,CAAA;AA7NY,yBAAyB;IADrC,aAAa,CAAC,UAAU,EAAE,oBAAoB,CAAC;GACnC,yBAAyB,CA6NrC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-side Identity Claim Engine
|
|
3
|
+
*
|
|
4
|
+
* Implements server-only identity claim lifecycle operations:
|
|
5
|
+
* - Claim creation and persistence
|
|
6
|
+
* - Automatic claimant email notification via MJ Communications Framework
|
|
7
|
+
* - Magic link verification and driver OnClaim execution
|
|
8
|
+
* - Claim revocation and expiration handling
|
|
9
|
+
*
|
|
10
|
+
* @module @memberjunction/core-entities-server/IdentityClaimEngineServer
|
|
11
|
+
*/
|
|
12
|
+
import { BaseSingleton } from '@memberjunction/global';
|
|
13
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
14
|
+
import { IdentityClaimEngine, BaseIdentityClaimDriver, ClaimResult, CreateClaimParams, IdentityClaimTypeConfiguration, MJIdentityClaimEntity, MJIdentityClaimTypeEntity } from '@memberjunction/core-entities';
|
|
15
|
+
export interface CreateClaimServerParams extends CreateClaimParams {
|
|
16
|
+
/** Optional raw verification token. If not provided and MagicLinkInviteID is null, one is securely generated. */
|
|
17
|
+
VerificationToken?: string;
|
|
18
|
+
/** Whether to send an email notification to claimant (defaults to true) */
|
|
19
|
+
SendEmail?: boolean;
|
|
20
|
+
/** Optional custom email subject */
|
|
21
|
+
EmailSubject?: string;
|
|
22
|
+
/** Optional custom email template ID (overrides ClaimType template) */
|
|
23
|
+
EmailTemplateID?: string;
|
|
24
|
+
/** Optional additional template data */
|
|
25
|
+
TemplateData?: Record<string, unknown>;
|
|
26
|
+
/** Optional Magic Link base URL for verification links */
|
|
27
|
+
ClaimBaseURL?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options that qualify a redemption attempt with facts only the transport layer knows.
|
|
31
|
+
*/
|
|
32
|
+
export interface RedeemClaimOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Whether the authenticated user's identity provider asserted their email as verified
|
|
35
|
+
* (the OIDC `email_verified` claim). Three-state by design:
|
|
36
|
+
* - `true` — the IdP vouched for the email; email-match redemption is allowed.
|
|
37
|
+
* - `false` — the IdP explicitly said the email is UNVERIFIED; the email-match path is
|
|
38
|
+
* refused (a token still redeems). Without this, any IdP that lets users register an
|
|
39
|
+
* arbitrary unverified email turns email-match redemption into account takeover.
|
|
40
|
+
* - `undefined` — the transport doesn't know (IdP omits the claim, or an internal caller);
|
|
41
|
+
* email-match stays allowed unless the claim type's Configuration sets
|
|
42
|
+
* `RequireVerifiedEmail`, which demands a positive `true`.
|
|
43
|
+
*/
|
|
44
|
+
EmailVerified?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Server-side Identity Claim engine — the ONLY place the claim lifecycle is implemented.
|
|
48
|
+
*
|
|
49
|
+
* Uses containment rather than inheritance, the same split as `AIEngine` / `AIEngineBase`: an
|
|
50
|
+
* instance of the client+server `IdentityClaimEngine` is held via {@link Base} and its cached
|
|
51
|
+
* members (claim types, lookups, driver resolution, email normalization) are proxied below, so
|
|
52
|
+
* `IdentityClaimEngineServer.Instance.X` reaches the whole surface. When a public member is added
|
|
53
|
+
* to `IdentityClaimEngine`, add a proxy here.
|
|
54
|
+
*
|
|
55
|
+
* Creation, redemption and revocation live here and nowhere else, because each depends on
|
|
56
|
+
* something a browser cannot do: `crypto.randomBytes` token generation and SHA-256 hashing,
|
|
57
|
+
* `timingSafeEqual` comparison, an atomic compare-and-swap issued as raw SQL, and email dispatch
|
|
58
|
+
* via MJ Communications.
|
|
59
|
+
*
|
|
60
|
+
* @description ONLY USE ON SERVER-SIDE. For claim-type metadata only, use `IdentityClaimEngine`,
|
|
61
|
+
* which is safe in any host.
|
|
62
|
+
*/
|
|
63
|
+
export declare class IdentityClaimEngineServer extends BaseSingleton<IdentityClaimEngineServer> {
|
|
64
|
+
protected constructor();
|
|
65
|
+
static get Instance(): IdentityClaimEngineServer;
|
|
66
|
+
/**
|
|
67
|
+
* The contained client+server engine that owns all cached claim-type metadata.
|
|
68
|
+
*/
|
|
69
|
+
protected get Base(): IdentityClaimEngine;
|
|
70
|
+
private _provider;
|
|
71
|
+
/**
|
|
72
|
+
* The metadata provider this engine operates under.
|
|
73
|
+
*
|
|
74
|
+
* This class is a process-wide singleton (`BaseSingleton` keys on class name), so it cannot
|
|
75
|
+
* own a provider the way a `BaseEngine` subclass does — one instance serves every connection
|
|
76
|
+
* in the process. Callers that have a request-scoped provider should pass it explicitly to
|
|
77
|
+
* the method they are calling; this settable accessor exists for hosts that bind one at
|
|
78
|
+
* startup, and falls back to the global default only when nothing has been supplied.
|
|
79
|
+
*
|
|
80
|
+
* Same shape as `AIEngine.Provider` — which `QueryEngineServer` and `ComponentMetadataEngineServer`
|
|
81
|
+
* both cite as the pattern to follow — and structurally exempt from the multi-provider
|
|
82
|
+
* compliance scanner, so it needs no `global-provider-ok` suppression.
|
|
83
|
+
*/
|
|
84
|
+
get Provider(): IMetadataProvider;
|
|
85
|
+
set Provider(value: IMetadataProvider);
|
|
86
|
+
/**
|
|
87
|
+
* Ensures metadata is configured and loaded
|
|
88
|
+
*/
|
|
89
|
+
Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
|
|
90
|
+
/** All loaded Identity Claim Types */
|
|
91
|
+
get ClaimTypes(): MJIdentityClaimTypeEntity[];
|
|
92
|
+
/** Finds a claim type by name (case-insensitive) */
|
|
93
|
+
GetClaimTypeByName(name: string): MJIdentityClaimTypeEntity | undefined;
|
|
94
|
+
/** Finds a claim type by ID */
|
|
95
|
+
GetClaimTypeByID(id: string): MJIdentityClaimTypeEntity | undefined;
|
|
96
|
+
/** Resolves the concrete BaseIdentityClaimDriver instance for a given claim type */
|
|
97
|
+
GetDriverInstance(claimType: MJIdentityClaimTypeEntity): BaseIdentityClaimDriver | null;
|
|
98
|
+
/** Normalizes email address (trimmed, lowercase) */
|
|
99
|
+
NormalizeEmail(email: string): string;
|
|
100
|
+
/** Parses a claim type's Configuration JSON into the engine-recognized shape */
|
|
101
|
+
GetClaimTypeConfiguration(claimType: MJIdentityClaimTypeEntity | undefined): IdentityClaimTypeConfiguration;
|
|
102
|
+
private escapeHtml;
|
|
103
|
+
/**
|
|
104
|
+
* Creates and saves an IdentityClaim record, sends an email notification via the MJ Communications
|
|
105
|
+
* framework if configured, and executes the driver's OnCreate lifecycle method.
|
|
106
|
+
*/
|
|
107
|
+
CreateClaim(params: CreateClaimServerParams, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<MJIdentityClaimEntity>;
|
|
108
|
+
/**
|
|
109
|
+
* Sends a claimant email notification using CommunicationEngine and TemplateEngineServer
|
|
110
|
+
*/
|
|
111
|
+
private sendClaimEmail;
|
|
112
|
+
/**
|
|
113
|
+
* Fetches all pending, unexpired claims for a normalized email address.
|
|
114
|
+
*/
|
|
115
|
+
GetPendingClaimsForEmail(email: string, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<MJIdentityClaimEntity[]>;
|
|
116
|
+
/**
|
|
117
|
+
* Redeems a claim for an authenticated user, running the driver's OnClaim implementation.
|
|
118
|
+
*
|
|
119
|
+
* Authorization is email match OR verified token. The email-match path is additionally
|
|
120
|
+
* gated by {@link RedeemClaimOptions.EmailVerified} and the claim type's
|
|
121
|
+
* `Configuration` (`RequireVerifiedEmail` / `RequireToken`) — see {@link RedeemClaimOptions}.
|
|
122
|
+
*/
|
|
123
|
+
RedeemClaim(claimID: string, contextUser: UserInfo, provider: IMetadataProvider, token?: string, options?: RedeemClaimOptions): Promise<ClaimResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Discovers every pending claim addressed to the authenticated user's email and redeems each
|
|
126
|
+
* one. This is workflow #2 from the entity's migration header — "Automatic Claim on Login".
|
|
127
|
+
*
|
|
128
|
+
* Server-only, and deliberately so: it runs through `RedeemClaim`, so each redemption still
|
|
129
|
+
* passes the full gate (email match or verified token, atomic CAS, driver exception handling).
|
|
130
|
+
* The email filter used to find the claims is a lookup convenience, not the security boundary.
|
|
131
|
+
*/
|
|
132
|
+
AutoClaimForUser(user: UserInfo, provider: IMetadataProvider, options?: RedeemClaimOptions): Promise<ClaimResult[]>;
|
|
133
|
+
/**
|
|
134
|
+
* Executes atomic single-use Compare-And-Swap (CAS) state transition on the IdentityClaim record
|
|
135
|
+
* from 'Pending' to 'Claimed'. Returns true iff this execution successfully transitioned the record.
|
|
136
|
+
*/
|
|
137
|
+
private consumeClaimAtomic;
|
|
138
|
+
/**
|
|
139
|
+
* Reverts an atomically consumed claim from 'Claimed' back to 'Pending' if driver execution fails.
|
|
140
|
+
*/
|
|
141
|
+
private revertClaimAtomic;
|
|
142
|
+
/**
|
|
143
|
+
* Revokes a pending claim and invokes the driver's OnRevoke lifecycle method.
|
|
144
|
+
*/
|
|
145
|
+
RevokeClaim(claimID: string, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=IdentityClaimEngineServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityClaimEngineServer.d.ts","sourceRoot":"","sources":["../../src/engines/IdentityClaimEngineServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAyC,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAA4D,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC7H,OAAO,EACH,mBAAmB,EACnB,uBAAuB,EAGvB,WAAW,EACX,iBAAiB,EACjB,8BAA8B,EAC9B,qBAAqB,EACrB,yBAAyB,EAE5B,MAAM,+BAA+B,CAAC;AAMvC,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAC9D,iHAAiH;IACjH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,yBAA0B,SAAQ,aAAa,CAAC,yBAAyB,CAAC;IACnF,SAAS;IAIT,WAAkB,QAAQ,IAAI,yBAAyB,CAEtD;IAMD;;OAEG;IACH,SAAS,KAAK,IAAI,IAAI,mBAAmB,CAExC;IAED,OAAO,CAAC,SAAS,CAAkC;IAEnD;;;;;;;;;;;;OAYG;IACH,IAAW,QAAQ,IAAI,iBAAiB,C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