@happyvertical/smrt-cli 0.55.0 → 0.55.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AuditLogCollection-WDHL-_AF-DX3E2T8N.js → AuditLogCollection-WDHL-_AF-CICn3ykM.js} +1 -1
- package/dist/{OidcIdentity-BjRu3n1g-CDe9x3H4.js → OidcIdentity-BUblgQLs-tEgHhtuW.js} +3 -3
- package/dist/{OidcIdentityCollection-B4jYh36_-C1oRTUpg.js → OidcIdentityCollection-ClOyaHeF-DekKuRWf.js} +4 -4
- package/dist/{ProfileAssetCollection-HeMtjBc0-CgCD0JbD.js → ProfileAssetCollection-CRMcjLJ--BDBGju83.js} +6 -6
- package/dist/{ProfileCollection-Bt6IJK49-DBqiNPOC.js → ProfileCollection-C4INKh7Y-DFI7PkHq.js} +24 -19
- package/dist/{ProfileLinkCollection-u1hhzKTm-CpUpK0hy.js → ProfileLinkCollection-DFfZRsgv-DM1Fvdmp.js} +5 -5
- package/dist/{ProfileMetadataCollection-BIYKy4Y3-BxG7J_LE.js → ProfileMetadataCollection-BIYKy4Y3-Bms52D92.js} +1 -1
- package/dist/{ProfileMetafieldCollection-Buz7gzag-C6-M3UC5.js → ProfileMetafieldCollection-Buz7gzag-D114BiEu.js} +1 -1
- package/dist/{ProfileRelationshipCollection-C4g_QLI4-CBcKkX8B.js → ProfileRelationshipCollection-C4g_QLI4-D4BlqOng.js} +1 -1
- package/dist/ProfileTypeCollection-B7kwi1mU-DmJhE1J9.js +103 -0
- package/dist/{commands-CMSkayf7.js → commands-DKomWuM0.js} +2 -2
- package/dist/{dist-CZX3a2M0.js → dist-Bd7Vrmjk.js} +3 -3
- package/dist/{dist-CzyJ1JlI.js → dist-BtQYiFJl.js} +16 -15
- package/dist/{dist-BqPmty2V.js → dist-COLaRvbz.js} +12 -4
- package/dist/{dist-BohGxrxH.js → dist-D8UeHLmJ.js} +4 -4
- package/dist/dist-lQnuqeJb.js +21 -0
- package/dist/index.js +9 -9
- package/dist/oidcProvisioningPrimitives-DNP9EZlU-CV2h9ajo.js +93 -0
- package/dist/{resolveIdentity-CvGDegU6-BCmnlTTo.js → resolveIdentity-CkyqvctR-BESNBdig.js} +17 -17
- package/package.json +15 -15
- package/dist/dist-cID_nI8e.js +0 -20
- package/dist/oidcProvisioningPrimitives-CYood-2M-DBI73_rU.js +0 -171
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import {
|
|
2
|
+
import { u as withSystemContext } from "./dist-COLaRvbz.js";
|
|
3
3
|
import { n as __exportAll$1, t as NostrIdentity, u as verifyAuthEvent } from "./NostrIdentity-AC8fAdxe-DKxKyu_a.js";
|
|
4
4
|
import { t as ApiKey } from "./ApiKey-CVmlf3V6-BAeHuH48.js";
|
|
5
|
-
import { t as OidcIdentity } from "./OidcIdentity-
|
|
6
|
-
import { c as coordinateOidcProvisioning, l as isOidcProvisioningRaceConflict, u as normalizeIdentityEmail } from "./ProfileCollection-
|
|
7
|
-
import { a as
|
|
5
|
+
import { t as OidcIdentity } from "./OidcIdentity-BUblgQLs-tEgHhtuW.js";
|
|
6
|
+
import { c as coordinateOidcProvisioning, l as isOidcProvisioningRaceConflict, u as normalizeIdentityEmail } from "./ProfileCollection-C4INKh7Y-DFI7PkHq.js";
|
|
7
|
+
import { a as insertOidcProvisioningIdentity, i as createOidcProvisioningPerson } from "./oidcProvisioningPrimitives-DNP9EZlU-CV2h9ajo.js";
|
|
8
8
|
import { resolveDatabase } from "@happyvertical/smrt-core";
|
|
9
|
-
//#region ../profiles/dist/chunks/resolveIdentity-
|
|
10
|
-
var
|
|
9
|
+
//#region ../profiles/dist/chunks/resolveIdentity-CkyqvctR.js
|
|
10
|
+
var resolveIdentity_CkyqvctR_exports = /* @__PURE__ */ __exportAll({
|
|
11
11
|
i: () => resolveIdentity_exports,
|
|
12
12
|
n: () => createProfileFromOidc,
|
|
13
13
|
r: () => resolveIdentity,
|
|
@@ -72,13 +72,13 @@ async function resolveIdentity(context) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
async function findProfileByExternalId(provider, externalId, options) {
|
|
75
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-
|
|
75
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-ClOyaHeF-DekKuRWf.js").then((n) => n.r).then((n) => n.r);
|
|
76
76
|
const identities = await (await OidcIdentityCollection.create(options)).findByProvider(provider);
|
|
77
77
|
for (const identity of identities) if (identity.subject === externalId || identity.email?.includes(externalId)) {
|
|
78
78
|
const profile = await identity.getProfile();
|
|
79
79
|
if (profile) return profile;
|
|
80
80
|
}
|
|
81
|
-
const { ProfileCollection } = await import("./ProfileCollection-
|
|
81
|
+
const { ProfileCollection } = await import("./ProfileCollection-C4INKh7Y-DFI7PkHq.js").then((n) => n.o).then((n) => n.r);
|
|
82
82
|
const profiles = await (await ProfileCollection.create(options)).list({
|
|
83
83
|
where: { email: `${externalId}@users.noreply.github.com` },
|
|
84
84
|
limit: 1
|
|
@@ -99,7 +99,7 @@ async function reuseExistingOidcIdentityForProfile(profileId, claims, provider,
|
|
|
99
99
|
createConcurrencyError: (cause) => new Error("Concurrent exact OIDC identity reuse did not converge.", cause === void 0 ? void 0 : { cause }),
|
|
100
100
|
rebindRootResult: rebindOidcProfileResult,
|
|
101
101
|
provision: (tx) => withSystemContext(async () => {
|
|
102
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-
|
|
102
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-ClOyaHeF-DekKuRWf.js").then((n) => n.r).then((n) => n.r);
|
|
103
103
|
const identity = await (await OidcIdentityCollection.create({ db: tx })).findBySubject(normalizedClaims.iss, normalizedClaims.sub);
|
|
104
104
|
if (!identity) throw new Error("OidcIdentity.findOrCreate() no longer creates authentication links; use UserCollection.getOrCreateFromOidc() or createProfileFromOidc().");
|
|
105
105
|
if (identity.profileId !== profileId) throw new Error(`OIDC identity ${normalizedClaims.iss} subject ${normalizedClaims.sub} belongs to a different Profile.`);
|
|
@@ -133,7 +133,7 @@ async function coordinateProfileOidcProvisioning(claims, provider, options) {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
async function provisionOidcProfile(claims, provider, options) {
|
|
136
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-
|
|
136
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-ClOyaHeF-DekKuRWf.js").then((n) => n.r).then((n) => n.r);
|
|
137
137
|
const existingIdentity = await (await OidcIdentityCollection.create(options)).findBySubject(claims.iss, claims.sub);
|
|
138
138
|
if (existingIdentity) {
|
|
139
139
|
const profile2 = await existingIdentity.getProfile();
|
|
@@ -148,7 +148,7 @@ async function provisionOidcProfile(claims, provider, options) {
|
|
|
148
148
|
created: false
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
const { ProfileCollection } = await import("./ProfileCollection-
|
|
151
|
+
const { ProfileCollection } = await import("./ProfileCollection-C4INKh7Y-DFI7PkHq.js").then((n) => n.o).then((n) => n.r);
|
|
152
152
|
const profileCollection = await ProfileCollection.create(options);
|
|
153
153
|
if (claims.email) {
|
|
154
154
|
if (await profileCollection.findUniqueGlobalPersonByEmail(claims.email)) {
|
|
@@ -175,8 +175,8 @@ async function provisionOidcProfile(claims, provider, options) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
async function rebindOidcProfileResult(result, rootDb) {
|
|
178
|
-
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-
|
|
179
|
-
const { ProfileCollection } = await import("./ProfileCollection-
|
|
178
|
+
const { OidcIdentityCollection } = await import("./OidcIdentityCollection-ClOyaHeF-DekKuRWf.js").then((n) => n.r).then((n) => n.r);
|
|
179
|
+
const { ProfileCollection } = await import("./ProfileCollection-C4INKh7Y-DFI7PkHq.js").then((n) => n.o).then((n) => n.r);
|
|
180
180
|
const profileId = requireOidcProfileId(result.profile.id);
|
|
181
181
|
const identityId = requireOidcProfileId(result.oidcIdentity.id);
|
|
182
182
|
const [profile, oidcIdentity] = await withSystemContext(async () => {
|
|
@@ -225,11 +225,11 @@ async function createProfileFromNostr(email, nostrData, options) {
|
|
|
225
225
|
created: false
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
const { Person } = await import("./oidcProvisioningPrimitives-
|
|
229
|
-
const { ProfileTypeCollection } = await import("./
|
|
228
|
+
const { Person } = await import("./oidcProvisioningPrimitives-DNP9EZlU-CV2h9ajo.js").then((n) => n.o).then((n) => n.o);
|
|
229
|
+
const { ProfileTypeCollection } = await import("./ProfileTypeCollection-B7kwi1mU-DmJhE1J9.js").then((n) => n.n).then((n) => n.n);
|
|
230
230
|
let personType = await (await ProfileTypeCollection.create(options)).getBySlug("person");
|
|
231
231
|
if (!personType) {
|
|
232
|
-
const { ProfileType } = await import("./ProfileCollection-
|
|
232
|
+
const { ProfileType } = await import("./ProfileCollection-C4INKh7Y-DFI7PkHq.js").then((n) => n.o).then((n) => n.h);
|
|
233
233
|
personType = new ProfileType({
|
|
234
234
|
...options,
|
|
235
235
|
slug: "person",
|
|
@@ -266,4 +266,4 @@ async function createProfileFromNostr(email, nostrData, options) {
|
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
268
|
//#endregion
|
|
269
|
-
export {
|
|
269
|
+
export { resolveIdentity_CkyqvctR_exports as i, createProfileFromOidc as n, resolveIdentity as r, createProfileFromNostr as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-cli",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.2",
|
|
4
4
|
"description": "Developer CLI for SMRT framework - introspection, testing, and project management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@happyvertical/ai": "^0.102.
|
|
33
|
-
"@happyvertical/files": "^0.102.
|
|
34
|
-
"@happyvertical/logger": "^0.102.
|
|
35
|
-
"@happyvertical/smrt-agents": "0.55.
|
|
36
|
-
"@happyvertical/smrt-app-runtime": "0.55.
|
|
37
|
-
"@happyvertical/smrt-config": "0.55.
|
|
38
|
-
"@happyvertical/smrt-core": "0.55.
|
|
39
|
-
"@happyvertical/smrt-dev-mcp": "0.55.
|
|
40
|
-
"@happyvertical/smrt-ledgers": "0.55.
|
|
41
|
-
"@happyvertical/smrt-playground": "0.55.
|
|
42
|
-
"@happyvertical/smrt-types": "0.55.
|
|
43
|
-
"@happyvertical/smrt-users": "0.55.
|
|
44
|
-
"@happyvertical/sql": "^0.102.
|
|
45
|
-
"@happyvertical/utils": "^0.102.
|
|
32
|
+
"@happyvertical/ai": "^0.102.2",
|
|
33
|
+
"@happyvertical/files": "^0.102.2",
|
|
34
|
+
"@happyvertical/logger": "^0.102.2",
|
|
35
|
+
"@happyvertical/smrt-agents": "0.55.2",
|
|
36
|
+
"@happyvertical/smrt-app-runtime": "0.55.2",
|
|
37
|
+
"@happyvertical/smrt-config": "0.55.2",
|
|
38
|
+
"@happyvertical/smrt-core": "0.55.2",
|
|
39
|
+
"@happyvertical/smrt-dev-mcp": "0.55.2",
|
|
40
|
+
"@happyvertical/smrt-ledgers": "0.55.2",
|
|
41
|
+
"@happyvertical/smrt-playground": "0.55.2",
|
|
42
|
+
"@happyvertical/smrt-types": "0.55.2",
|
|
43
|
+
"@happyvertical/smrt-users": "0.55.2",
|
|
44
|
+
"@happyvertical/sql": "^0.102.2",
|
|
45
|
+
"@happyvertical/utils": "^0.102.2",
|
|
46
46
|
"acorn": "^8.18.0",
|
|
47
47
|
"fast-glob": "3.3.3",
|
|
48
48
|
"tar": "^7.5.22",
|
package/dist/dist-cID_nI8e.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import "./NostrIdentity-AC8fAdxe-DKxKyu_a.js";
|
|
2
|
-
import "./ApiKey-CVmlf3V6-BAeHuH48.js";
|
|
3
|
-
import "./ApiKeyCollection-CiiDNFdD-CMGF3_ul.js";
|
|
4
|
-
import "./AuditLogCollection-WDHL-_AF-DX3E2T8N.js";
|
|
5
|
-
import "./NostrIdentityCollection-CctlECpX-fkAPnK02.js";
|
|
6
|
-
import "./OidcIdentity-BjRu3n1g-CDe9x3H4.js";
|
|
7
|
-
import "./OidcIdentityCollection-B4jYh36_-C1oRTUpg.js";
|
|
8
|
-
import "./ProfileAssetCollection-HeMtjBc0-CgCD0JbD.js";
|
|
9
|
-
import { a as ProfileCollection } from "./ProfileCollection-Bt6IJK49-DBqiNPOC.js";
|
|
10
|
-
import "./ProfileLinkCollection-u1hhzKTm-CpUpK0hy.js";
|
|
11
|
-
import "./ProfileMetadataCollection-BIYKy4Y3-BxG7J_LE.js";
|
|
12
|
-
import "./ProfileMetafieldCollection-Buz7gzag-C6-M3UC5.js";
|
|
13
|
-
import "./ProfileRelationshipCollection-C4g_QLI4-CBcKkX8B.js";
|
|
14
|
-
import "./ProfileRelationshipTermCollection-C9J7mC7P-ChIFqjCg.js";
|
|
15
|
-
import "./ProfileRelationshipType-U7IwF6Wf-DNavf24e.js";
|
|
16
|
-
import "./ProfileRelationshipTypeCollection-_n22WqTb-DiZUWvev.js";
|
|
17
|
-
import "./oidcProvisioningPrimitives-CYood-2M-DBI73_rU.js";
|
|
18
|
-
import "./resolveIdentity-CvGDegU6-BCmnlTTo.js";
|
|
19
|
-
import "./dist-CzyJ1JlI.js";
|
|
20
|
-
export { ProfileCollection };
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { c as isSystemContext } from "./dist-BqPmty2V.js";
|
|
3
|
-
import { n as __exportAll$1 } from "./NostrIdentity-AC8fAdxe-DKxKyu_a.js";
|
|
4
|
-
import { t as OidcIdentity } from "./OidcIdentity-BjRu3n1g-CDe9x3H4.js";
|
|
5
|
-
import { a as ProfileCollection, f as saveOidcRaceArbiter, i as Profile, s as ProfileType } from "./ProfileCollection-Bt6IJK49-DBqiNPOC.js";
|
|
6
|
-
import { SmrtCollection, smrt } from "@happyvertical/smrt-core";
|
|
7
|
-
//#region ../profiles/dist/chunks/oidcProvisioningPrimitives-CYood-2M.js
|
|
8
|
-
var oidcProvisioningPrimitives_CYood_2M_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
a: () => Person,
|
|
10
|
-
c: () => ProfileTypeCollection_exports,
|
|
11
|
-
i: () => Organization,
|
|
12
|
-
n: () => insertOidcProvisioningIdentity,
|
|
13
|
-
o: () => ProfileTypes_exports,
|
|
14
|
-
r: () => Bot,
|
|
15
|
-
s: () => ProfileTypeCollection,
|
|
16
|
-
t: () => createOidcProvisioningPerson
|
|
17
|
-
});
|
|
18
|
-
var ProfileTypeCollection_exports = /* @__PURE__ */ __exportAll$1({ ProfileTypeCollection: () => ProfileTypeCollection });
|
|
19
|
-
function isPostgresUrl(url) {
|
|
20
|
-
return /^postgres(?:ql)?:/iu.test(url ?? "");
|
|
21
|
-
}
|
|
22
|
-
var ProfileTypeCollection = class extends SmrtCollection {
|
|
23
|
-
static _itemClass = ProfileType;
|
|
24
|
-
/**
|
|
25
|
-
* Get profile type by slug
|
|
26
|
-
*
|
|
27
|
-
* @param slug - The slug to search for
|
|
28
|
-
* @returns ProfileType instance or null
|
|
29
|
-
*/
|
|
30
|
-
async getBySlug(slug) {
|
|
31
|
-
return await this.get({ slug });
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get or create a profile type by slug
|
|
35
|
-
*
|
|
36
|
-
* @param slug - The slug to search for
|
|
37
|
-
* @param defaults - Default values if creating
|
|
38
|
-
* @returns ProfileType instance
|
|
39
|
-
*/
|
|
40
|
-
async getOrCreateBySlug(slug, defaults) {
|
|
41
|
-
const existing = await this.getBySlug(slug);
|
|
42
|
-
if (existing) return existing;
|
|
43
|
-
const profileType = await this.create({
|
|
44
|
-
slug,
|
|
45
|
-
...defaults
|
|
46
|
-
});
|
|
47
|
-
await profileType.save();
|
|
48
|
-
return profileType;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Atomically create or load a global ProfileType from trusted system code.
|
|
52
|
-
*
|
|
53
|
-
* This intentionally bypasses tenant auto-population and therefore refuses
|
|
54
|
-
* to run outside an explicit `withSystemContext()` boundary.
|
|
55
|
-
*/
|
|
56
|
-
async getOrCreateGlobalBySlug(slug, defaults) {
|
|
57
|
-
if (!isSystemContext()) throw new Error("Global ProfileType creation requires an explicit system context.");
|
|
58
|
-
const existing = await this.loadGlobalBySlug(slug);
|
|
59
|
-
if (existing) return existing;
|
|
60
|
-
const insertIfAbsent = async (db) => {
|
|
61
|
-
if (isPostgresUrl(db.url)) await db.query("SELECT pg_advisory_xact_lock(hashtext(?), hashtext(?))", "@happyvertical/smrt-profiles:profile_types:global", slug);
|
|
62
|
-
await db.query(`INSERT INTO profile_types
|
|
63
|
-
(id, slug, context, _meta_type, tenant_id, name, description)
|
|
64
|
-
SELECT ?, ?, '', '@happyvertical/smrt-profiles:ProfileType', NULL, ?, ?
|
|
65
|
-
WHERE NOT EXISTS (
|
|
66
|
-
SELECT 1 FROM profile_types
|
|
67
|
-
WHERE slug = ?
|
|
68
|
-
AND context = ''
|
|
69
|
-
AND _meta_type = '@happyvertical/smrt-profiles:ProfileType'
|
|
70
|
-
AND tenant_id IS NULL
|
|
71
|
-
)`, crypto.randomUUID(), slug, defaults.name, defaults.description ?? null, slug);
|
|
72
|
-
};
|
|
73
|
-
const isTransactionBound = typeof this.db.commit === "function";
|
|
74
|
-
if (isPostgresUrl(this.db.url) && !isTransactionBound && typeof this.db.transaction === "function") await this.db.transaction((tx) => insertIfAbsent(tx));
|
|
75
|
-
else await insertIfAbsent(this.db);
|
|
76
|
-
const profileType = await this.loadGlobalBySlug(slug);
|
|
77
|
-
if (!profileType) throw new Error(`Global ProfileType '${slug}' could not be created or loaded.`);
|
|
78
|
-
return profileType;
|
|
79
|
-
}
|
|
80
|
-
async loadGlobalBySlug(slug) {
|
|
81
|
-
const id = (await this.db.query(`SELECT CAST(id AS VARCHAR) AS id
|
|
82
|
-
FROM profile_types
|
|
83
|
-
WHERE slug = ?
|
|
84
|
-
AND context = ''
|
|
85
|
-
AND _meta_type = '@happyvertical/smrt-profiles:ProfileType'
|
|
86
|
-
AND tenant_id IS NULL
|
|
87
|
-
LIMIT 1`, slug)).rows[0]?.id;
|
|
88
|
-
if (typeof id !== "string") return null;
|
|
89
|
-
const profileType = await this.get({ id });
|
|
90
|
-
if (profileType) profileType.id = id;
|
|
91
|
-
return profileType;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var ProfileTypes_exports = /* @__PURE__ */ __exportAll$1({
|
|
95
|
-
Bot: () => Bot,
|
|
96
|
-
Organization: () => Organization,
|
|
97
|
-
Person: () => Person
|
|
98
|
-
});
|
|
99
|
-
var __defProp = Object.defineProperty;
|
|
100
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
101
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
configurable: true,
|
|
104
|
-
writable: true,
|
|
105
|
-
value
|
|
106
|
-
}) : obj[key] = value;
|
|
107
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
108
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
109
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
110
|
-
if (kind && result) __defProp(target, key, result);
|
|
111
|
-
return result;
|
|
112
|
-
};
|
|
113
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
114
|
-
var Person = class extends Profile {
|
|
115
|
-
constructor(options = {}) {
|
|
116
|
-
super(options);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
__publicField(Person, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
120
|
-
Person = __decorateClass([smrt({ tableStrategy: "sti" })], Person);
|
|
121
|
-
var Organization = class extends Profile {
|
|
122
|
-
constructor(options = {}) {
|
|
123
|
-
super(options);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
__publicField(Organization, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
127
|
-
Organization = __decorateClass([smrt({ tableStrategy: "sti" })], Organization);
|
|
128
|
-
var Bot = class extends Profile {
|
|
129
|
-
constructor(options = {}) {
|
|
130
|
-
super(options);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
__publicField(Bot, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
134
|
-
Bot = __decorateClass([smrt({ tableStrategy: "sti" })], Bot);
|
|
135
|
-
async function createOidcProvisioningPerson(db, input) {
|
|
136
|
-
const typeId = requireProvisioningId((await (await ProfileTypeCollection.create({ db })).getOrCreateGlobalBySlug("person", {
|
|
137
|
-
name: "Person",
|
|
138
|
-
description: "Individual person profile"
|
|
139
|
-
})).id, "Person ProfileType");
|
|
140
|
-
let profile = new Person({
|
|
141
|
-
db,
|
|
142
|
-
slug: `oidc-${crypto.randomUUID()}`,
|
|
143
|
-
tenantId: null,
|
|
144
|
-
typeId,
|
|
145
|
-
email: input.email ?? "",
|
|
146
|
-
name: input.name || input.preferredUsername || input.subject
|
|
147
|
-
});
|
|
148
|
-
await profile.initialize();
|
|
149
|
-
await saveOidcRaceArbiter(() => profile.save());
|
|
150
|
-
if (input.email) profile = await (await ProfileCollection.create({ db })).reserveCanonicalIdentityEmail(requireProvisioningId(profile.id, "Created Profile"), input.email);
|
|
151
|
-
return profile;
|
|
152
|
-
}
|
|
153
|
-
async function insertOidcProvisioningIdentity(db, input) {
|
|
154
|
-
const identity = new OidcIdentity({
|
|
155
|
-
db,
|
|
156
|
-
email: input.email ?? "",
|
|
157
|
-
issuer: input.issuer,
|
|
158
|
-
profileId: input.profileId,
|
|
159
|
-
provider: input.provider,
|
|
160
|
-
subject: input.subject
|
|
161
|
-
});
|
|
162
|
-
await identity.initialize();
|
|
163
|
-
await saveOidcRaceArbiter(() => identity.save());
|
|
164
|
-
return identity;
|
|
165
|
-
}
|
|
166
|
-
function requireProvisioningId(value, label) {
|
|
167
|
-
if (typeof value !== "string" || !value) throw new Error(`${label} did not produce an id.`);
|
|
168
|
-
return value;
|
|
169
|
-
}
|
|
170
|
-
//#endregion
|
|
171
|
-
export { createOidcProvisioningPerson as a, ProfileTypeCollection as i, Organization as n, insertOidcProvisioningIdentity as o, Person as r, oidcProvisioningPrimitives_CYood_2M_exports as s, Bot as t };
|