@h-ai/iam 0.1.0-alpha.19 → 0.1.0-alpha.20
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/index.js +18 -36
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -753,6 +753,20 @@ var DbApiKeyRepository = class extends BaseReldbCrudRepository {
|
|
|
753
753
|
);
|
|
754
754
|
}
|
|
755
755
|
};
|
|
756
|
+
|
|
757
|
+
// src/iam-agreement.ts
|
|
758
|
+
function buildAgreementDisplay(config, enabled) {
|
|
759
|
+
if (!enabled)
|
|
760
|
+
return void 0;
|
|
761
|
+
if (!config.userAgreementUrl && !config.privacyPolicyUrl)
|
|
762
|
+
return void 0;
|
|
763
|
+
return {
|
|
764
|
+
userAgreementUrl: config.userAgreementUrl,
|
|
765
|
+
privacyPolicyUrl: config.privacyPolicyUrl,
|
|
766
|
+
showOnRegister: config.showOnRegister,
|
|
767
|
+
showOnLogin: config.showOnLogin
|
|
768
|
+
};
|
|
769
|
+
}
|
|
756
770
|
var TABLE_NAME2 = "hai_iam_users";
|
|
757
771
|
var USER_FIELDS = [
|
|
758
772
|
{
|
|
@@ -1503,9 +1517,6 @@ function createOtpStrategy(config) {
|
|
|
1503
1517
|
const registerConfig = config.registerConfig;
|
|
1504
1518
|
const allowAutoRegister = registerConfig?.enabled ?? config.autoRegister ?? false;
|
|
1505
1519
|
const defaultEnabled = registerConfig?.defaultEnabled ?? true;
|
|
1506
|
-
function buildChallengeResult(expiresAt) {
|
|
1507
|
-
return { expiresAt };
|
|
1508
|
-
}
|
|
1509
1520
|
const strategy = {
|
|
1510
1521
|
type: "otp",
|
|
1511
1522
|
name: "otp-strategy",
|
|
@@ -1633,7 +1644,7 @@ function createOtpStrategy(config) {
|
|
|
1633
1644
|
iamM("iam_identifierTypeNotSupported")
|
|
1634
1645
|
);
|
|
1635
1646
|
}
|
|
1636
|
-
const result =
|
|
1647
|
+
const result = { expiresAt };
|
|
1637
1648
|
logger3.debug("OTP challenge sent", { identifier, expiresAt });
|
|
1638
1649
|
return ok(result);
|
|
1639
1650
|
}
|
|
@@ -1870,20 +1881,6 @@ function buildAuthnOperations(deps) {
|
|
|
1870
1881
|
} = deps;
|
|
1871
1882
|
const loginConfig = LoginConfigSchema.parse(config.login ?? {});
|
|
1872
1883
|
const agreementConfig = AgreementConfigSchema.parse(config.agreements ?? {});
|
|
1873
|
-
function buildAgreementDisplay() {
|
|
1874
|
-
if (!agreementConfig.showOnLogin) {
|
|
1875
|
-
return void 0;
|
|
1876
|
-
}
|
|
1877
|
-
if (!agreementConfig.userAgreementUrl && !agreementConfig.privacyPolicyUrl) {
|
|
1878
|
-
return void 0;
|
|
1879
|
-
}
|
|
1880
|
-
return {
|
|
1881
|
-
userAgreementUrl: agreementConfig.userAgreementUrl,
|
|
1882
|
-
privacyPolicyUrl: agreementConfig.privacyPolicyUrl,
|
|
1883
|
-
showOnRegister: agreementConfig.showOnRegister,
|
|
1884
|
-
showOnLogin: agreementConfig.showOnLogin
|
|
1885
|
-
};
|
|
1886
|
-
}
|
|
1887
1884
|
function loginDisabled(type) {
|
|
1888
1885
|
if (!loginConfig[type]) {
|
|
1889
1886
|
return err(
|
|
@@ -1960,7 +1957,7 @@ function buildAuthnOperations(deps) {
|
|
|
1960
1957
|
tokens: tokenPair,
|
|
1961
1958
|
roles: roleCodesResult.data,
|
|
1962
1959
|
permissions: permCodesResult.data,
|
|
1963
|
-
agreements: buildAgreementDisplay()
|
|
1960
|
+
agreements: buildAgreementDisplay(agreementConfig, agreementConfig.showOnLogin)
|
|
1964
1961
|
});
|
|
1965
1962
|
}
|
|
1966
1963
|
async function loginWithStrategy(type, credentials, strategy) {
|
|
@@ -4297,18 +4294,6 @@ function buildRegistrationOps(ctx) {
|
|
|
4297
4294
|
}
|
|
4298
4295
|
return ok(void 0);
|
|
4299
4296
|
}
|
|
4300
|
-
function buildAgreementDisplay() {
|
|
4301
|
-
if (!agreementConfig.showOnRegister)
|
|
4302
|
-
return void 0;
|
|
4303
|
-
if (!agreementConfig.userAgreementUrl && !agreementConfig.privacyPolicyUrl)
|
|
4304
|
-
return void 0;
|
|
4305
|
-
return {
|
|
4306
|
-
userAgreementUrl: agreementConfig.userAgreementUrl,
|
|
4307
|
-
privacyPolicyUrl: agreementConfig.privacyPolicyUrl,
|
|
4308
|
-
showOnRegister: agreementConfig.showOnRegister,
|
|
4309
|
-
showOnLogin: agreementConfig.showOnLogin
|
|
4310
|
-
};
|
|
4311
|
-
}
|
|
4312
4297
|
async function assignDefaultRole(userId) {
|
|
4313
4298
|
if (!config.rbac?.defaultRole)
|
|
4314
4299
|
return;
|
|
@@ -4363,7 +4348,7 @@ function buildRegistrationOps(ctx) {
|
|
|
4363
4348
|
logger9.info("User registered", { userId: createdUser.id, username: options.username });
|
|
4364
4349
|
return ok({
|
|
4365
4350
|
user: toUser(createdUser),
|
|
4366
|
-
agreements: buildAgreementDisplay()
|
|
4351
|
+
agreements: buildAgreementDisplay(agreementConfig, agreementConfig.showOnRegister)
|
|
4367
4352
|
});
|
|
4368
4353
|
},
|
|
4369
4354
|
validatePassword(password) {
|
|
@@ -4798,9 +4783,6 @@ function buildUserFunctions(deps) {
|
|
|
4798
4783
|
|
|
4799
4784
|
// src/iam-main.ts
|
|
4800
4785
|
var logger10 = core.logger.child({ module: "iam", scope: "main" });
|
|
4801
|
-
function sanitizeIamConfig(config) {
|
|
4802
|
-
return core.sanitize.sanitizeSensitiveFields(config);
|
|
4803
|
-
}
|
|
4804
4786
|
var initInProgress = false;
|
|
4805
4787
|
var currentConfig = null;
|
|
4806
4788
|
var currentAuth = null;
|
|
@@ -4953,7 +4935,7 @@ var iam = {
|
|
|
4953
4935
|
return currentApiKey ?? notInitializedApiKey;
|
|
4954
4936
|
},
|
|
4955
4937
|
get config() {
|
|
4956
|
-
return currentConfig ?
|
|
4938
|
+
return currentConfig ? core.sanitize.sanitizeSensitiveFields(currentConfig) : null;
|
|
4957
4939
|
},
|
|
4958
4940
|
get isInitialized() {
|
|
4959
4941
|
return currentConfig !== null;
|