@astram/guard 0.26.0 → 0.28.0
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/auth/auth.module.d.ts +4 -0
- package/dist/auth/auth.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +20 -1
- package/dist/auth/persistence.module.d.ts +4 -0
- package/dist/auth/persistence.module.d.ts.map +1 -1
- package/dist/auth/persistence.module.js +5 -1
- package/dist/auth/tokens.d.ts +8 -0
- package/dist/auth/tokens.d.ts.map +1 -1
- package/dist/auth/tokens.js +10 -2
- package/dist/boot/boot.module.d.ts +4 -0
- package/dist/boot/boot.module.d.ts.map +1 -1
- package/dist/boot/boot.module.js +3 -0
- package/dist/config/config.module.d.ts +4 -0
- package/dist/config/config.module.d.ts.map +1 -1
- package/dist/config/config.module.js +3 -0
- package/dist/enforcement/enforcement.module.d.ts +4 -0
- package/dist/enforcement/enforcement.module.d.ts.map +1 -1
- package/dist/enforcement/enforcement.module.js +3 -0
- package/dist/enforcement/global-enforcement.guard.d.ts +12 -0
- package/dist/enforcement/global-enforcement.guard.d.ts.map +1 -1
- package/dist/enforcement/global-enforcement.guard.js +42 -0
- package/dist/identity/identity-actions.d.ts +16 -0
- package/dist/identity/identity-actions.d.ts.map +1 -1
- package/dist/identity/identity-actions.js +15 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/internal.d.ts +14 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +19 -1
- package/dist/module/shield.module.d.ts +9 -0
- package/dist/module/shield.module.d.ts.map +1 -1
- package/dist/module/shield.module.js +11 -1
- package/dist/notifications/mariadb-notification-store.d.ts +26 -1
- package/dist/notifications/mariadb-notification-store.d.ts.map +1 -1
- package/dist/notifications/mariadb-notification-store.js +128 -3
- package/dist/notifications/notification.service.d.ts +40 -5
- package/dist/notifications/notification.service.d.ts.map +1 -1
- package/dist/notifications/notification.service.js +86 -4
- package/dist/notifications/notifications.controller.d.ts +43 -3
- package/dist/notifications/notifications.controller.d.ts.map +1 -1
- package/dist/notifications/notifications.controller.js +233 -6
- package/dist/notifications/ports.d.ts +52 -2
- package/dist/notifications/ports.d.ts.map +1 -1
- package/dist/notifications/ports.js +12 -2
- package/dist/session/session-liveness.d.ts +41 -0
- package/dist/session/session-liveness.d.ts.map +1 -0
- package/dist/session/session-liveness.js +63 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
* `@nestjs/core`, `reflect-metadata`, `rxjs` so the host owns one copy of each.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.ScopeUnknownParentError = exports.ScopeDepthError = exports.ScopeCycleError = exports.buildClosureRows = exports.ConfirmEmailController = exports.AccountController = exports.generateRecoveryCodes = exports.buildOtpauthUri = exports.generateTotpSecret = exports.SHIELD_LOGIN_TOTP_VERIFIER = exports.SHIELD_MFA_STEP_UP = exports.SHIELD_MFA_LIMITER = exports.challengeMatches = exports.credentialFingerprint = exports.CredentialMfaStepUp = exports.RedisPendingMfaStore = exports.PendingMfaStore = exports.AuthController = exports.SHIELD_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_SESSION_FACTS_PROJECTOR = exports.ProfileNameTakenError = exports.maskPhone = exports.MAX_MESSAGE_SEND_TIMEOUT_MS = exports.DEFAULT_MESSAGE_SEND_TIMEOUT_MS = exports.EMAIL_PROVIDER_VALUES = exports.loadMessageConfig = exports.MariaDbEmailAddressChanger = void 0;
|
|
19
|
+
exports.resolveBootSecrets = exports.EncryptedFileSecretsProvider = exports.LocalKekCrypto = exports.resolveAuthLinkBaseUrls = exports.CredentialExistsError = exports.isLockedHash = exports.lockedPasswordHash = exports.SHIELD_PASSWORD_HASHER = exports.argon2idHasherProvider = exports.Argon2idPasswordHasher = exports.stubDecisionAuthority = exports.GlobalEnforcementGuard = exports.NO_SESSION_FACTS = exports.SHIELD_SESSION_FACTS_ALS = exports.MariaDbApiKeyStore = exports.isApiKey = exports.extractBearerToken = exports.principalFromClaims = exports.resolveRequestAuth = exports.resolveRequestPrincipal = exports.SessionTokenBinder = exports.SHIELD_SERVICE_AUTHENTICATOR = exports.SHIELD_SESSION_TOKEN_BINDER = exports.CatalogGatabilityError = exports.CatalogReconciler = exports.OperationInventoryScanner = exports.uuidArrayField = exports.optionalUuidField = exports.uuidField = exports.UuidPipe = exports.normalizeClassification = exports.DEFAULT_CLASSIFIED_ACTION = exports.CLASSIFICATION_METADATA = exports.Classified = exports.Public = exports.SHIELD_RECORD_AUTHORIZATION = exports.SHIELD_DECISION_AUTHORITY = exports.ShieldModule = exports.actionsOf = exports.actionsFor = exports.AGENT_TENANT_MODES = exports.AGENT_ACTIONS = exports.SERVICE_ACCOUNT_ACTIONS = exports.RECORD_SHARE_ACTIONS = exports.CROSS_TENANT_GRANT_ACTIONS = exports.IDENTITY_ACTIONS = exports.MODULE_KEY = exports.permissionTextByKey = exports.buildIdentityModuleRegistry = exports.guardMigrationsDir = void 0;
|
|
20
|
+
exports.translateListScope = exports.SHIELD_LIST_SCOPE_PORT = exports.MariaDbListScopeAdapter = exports.SHIELD_POLICY_STORE = exports.MariaDbPolicyStore = exports.SHIELD_RECORD_RULE_PORT = exports.MariaDbRecordPermissionRuleAdapter = exports.accessBindingTtlMs = exports.ROTATE_GRACE_MS = exports.SHIELD_SESSION_LIFETIMES = exports.HotRevokingSessionRecordStore = exports.SHIELD_CLOCK = exports.SHIELD_REFRESH_HASHER = exports.SHIELD_TOKEN_GENERATOR = exports.systemClockProvider = exports.refreshHasherProvider = exports.cryptoTokenGeneratorProvider = exports.SystemClock = exports.Sha256RefreshTokenHasher = exports.CryptoTokenGenerator = exports.RedisRecentRotationStore = exports.SHIELD_HOT_SESSION_STORE = exports.RedisHotSessionStore = exports.SHIELD_SESSION_RECORD_STORE = exports.MariaDbSessionRecordStore = exports.DEFAULT_OBJECT_STORAGE_MAX_BYTES = exports.loadObjectStorageConfig = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.FILE_INTAKE_DEFAULT_MAX_BYTES = exports.FILE_INTAKE_REQUEST_KEY = exports.FileIntake = exports.ObjectStoreBootCheck = exports.SHIELD_NOTIFICATIONS = exports.loadNotificationConfig = exports.NotificationUnavailableError = exports.NotificationValidationError = exports.NotificationKindError = exports.NOTIFICATION_BULK_ACTIONS = exports.NOTIFICATION_STATUSES = exports.NOTIFICATION_SEVERITIES = exports.NOTIFICATION_CATEGORIES = exports.NotificationService = exports.loadAuditSealConfig = exports.NodeSha256Hash = exports.NodeSha256Digest = exports.S3ObjectStore = exports.wasResolvedFromSecretRef = exports.assertNoUnresolvedSecretRefs = exports.createSecretsProviderFromEnv = void 0;
|
|
21
|
+
exports.DEFAULT_DB_CONFIG = exports.assertRefreshHmacKey = exports.loadRefreshHmacKey = exports.loadSessionLifetimes = exports.loadRedisConfig = exports.loadDbConfig = exports.SCHEMA_SVC_POOL_HARD_CAP = exports.DEFAULT_POOL_BUDGET = exports.evaluatePoolBudget = exports.loadPoolBudget = exports.loadAppConfig = exports.frameworkSchemasOf = exports.FRAMEWORK_SCHEMAS = exports.APP_CONFIG = exports.resolveMigrationLedgerCheck = exports.resolveMigrationLedger = exports.frameworkMigrationIds = exports.assertFrameworkMigrationsApplied = exports.SHIELD_MIGRATION_LEDGER_REGISTRY = exports.MigrationLedgerRegistry = exports.FrameworkMigrationLedgerCheck = exports.frameworkDatabasesLogLine = exports.assertPoolBudget = exports.BootSequence = exports.buildListScopeFn = exports.MariaDbSessionRestrictionStore = exports.SHIELD_SESSION_RESTRICTIONS = exports.SHIELD_PERMISSION_VERSION_CACHE = exports.DEFAULT_PERMISSION_VERSION_TTL_MS = exports.PERMISSION_VERSION_KEY_PREFIX = exports.RedisPermissionVersionCache = exports.withRedisPermissionVersion = exports.buildRecordAuthorization = exports.SHIELD_OPERATION_AUTHORITY_PORT = exports.ManifestOperationAuthorityAdapter = exports.GrantStoreUnavailableError = exports.InvalidGrantError = exports.GrantNotPermittedError = exports.SHIELD_CROSS_TENANT_GRANT_WRITER = exports.CrossTenantGrantWriter = exports.SHIELD_CROSS_TENANT_GRANT_PORT = exports.MariaDbCrossTenantGrantAdapter = exports.makeShareDeleteCascade = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHIELD_RECORD_SHARE_WRITER = exports.RecordShareWriter = exports.SHIELD_RECORD_SHARE_PORT = exports.MariaDbRecordShareAdapter = exports.UnknownScopeFieldError = void 0;
|
|
22
|
+
exports.makeDefaultTotpVerifier = exports.AuthModule = exports.SHIELD_CAPTCHA_GATE = exports.RECAPTCHA_SITEVERIFY_URL = exports.RecaptchaVerifier = exports.TURNSTILE_SITEVERIFY_URL = exports.TurnstileVerifier = exports.MAX_CAPTCHA_TIMEOUT_MS = exports.DEFAULT_CAPTCHA_TIMEOUT_MS = exports.DEFAULT_CAPTCHA_MIN_SCORE = exports.DEFAULT_CAPTCHA_THRESHOLD = exports.CAPTCHA_FAIL_MODES = exports.CAPTCHA_MODES = exports.CAPTCHA_ENDPOINTS = exports.loadCaptchaConfig = exports.SHIELD_SIGN_IN_WITH = exports.DEFAULT_SIGN_IN_WITH = exports.resolveSignInWith = exports.MariaDbCredentialResolver = exports.SHIELD_TOTP_VERIFIER_OVERRIDE = exports.SHIELD_MFA_DEVICE_STORE = exports.SHIELD_AUDIT_SINK = exports.SHIELD_SESSION_SWEEPER = exports.SHIELD_PROFILE_WRITER = exports.SHIELD_RECOVERY_CODE_STORE = exports.SHIELD_MESSAGE_DISPATCHER = exports.SHIELD_EMAIL_SENDER = exports.SHIELD_EMAIL_CHANGE_TOKEN_STORE = exports.SHIELD_RESET_TOKEN_STORE = exports.SHIELD_CREDENTIAL_WRITER = exports.SHIELD_SESSION_AUTHORITY = exports.SHIELD_AUTHENTICATOR = exports.SHIELD_PROFILE_RESOLVER = exports.SHIELD_CREDENTIAL_RESOLVER = exports.SHIELD_REDIS = exports.withoutStatementTimeout = exports.mariadbPoolTuningOptions = exports.mariadbSslOption = exports.reservedOperationPrincipal = exports.RESERVED_OPERATION_PRINCIPALS = exports.assertNoReservedRootId = exports.ORG_BOOTSTRAP_PRINCIPAL_ID = exports.rootIdsFromEnv = exports.loadPoolTuning = exports.loadDbTlsConfig = exports.isDevOrTestNodeEnv = exports.DEFAULT_LOGIN_IP_LIMIT = exports.loadRefreshReplayWindowMs = exports.loadLoginIpLimit = exports.DEFAULT_REDIS_URL = void 0;
|
|
23
|
+
exports.ScopeUnknownParentError = exports.ScopeDepthError = exports.ScopeCycleError = exports.buildClosureRows = exports.ConfirmEmailController = exports.AccountController = exports.generateRecoveryCodes = exports.buildOtpauthUri = exports.generateTotpSecret = exports.SHIELD_LOGIN_TOTP_VERIFIER = exports.SHIELD_MFA_STEP_UP = exports.SHIELD_MFA_LIMITER = exports.challengeMatches = exports.credentialFingerprint = exports.CredentialMfaStepUp = exports.RedisPendingMfaStore = exports.PendingMfaStore = exports.AuthController = exports.SHIELD_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_SESSION_FACTS_PROJECTOR = exports.ProfileNameTakenError = exports.maskPhone = exports.MAX_MESSAGE_SEND_TIMEOUT_MS = exports.DEFAULT_MESSAGE_SEND_TIMEOUT_MS = exports.EMAIL_PROVIDER_VALUES = exports.loadMessageConfig = exports.MariaDbEmailAddressChanger = exports.maskEmail = exports.isEmailShaped = exports.canonicalEmail = exports.hmacSha1 = exports.resolveTotpVerifier = void 0;
|
|
24
24
|
// Framework authz migrations (shield_authz DDL — permission / role_permission /
|
|
25
25
|
// authz_permission_version). Absolute path a consumer's `@astram/migrate` setup merges in.
|
|
26
26
|
var migrations_dir_js_1 = require("./migrations-dir.js");
|
|
@@ -41,6 +41,8 @@ Object.defineProperty(exports, "IDENTITY_ACTIONS", { enumerable: true, get: func
|
|
|
41
41
|
Object.defineProperty(exports, "CROSS_TENANT_GRANT_ACTIONS", { enumerable: true, get: function () { return identity_actions_js_1.CROSS_TENANT_GRANT_ACTIONS; } });
|
|
42
42
|
Object.defineProperty(exports, "RECORD_SHARE_ACTIONS", { enumerable: true, get: function () { return identity_actions_js_1.RECORD_SHARE_ACTIONS; } });
|
|
43
43
|
Object.defineProperty(exports, "SERVICE_ACCOUNT_ACTIONS", { enumerable: true, get: function () { return identity_actions_js_1.SERVICE_ACCOUNT_ACTIONS; } });
|
|
44
|
+
Object.defineProperty(exports, "AGENT_ACTIONS", { enumerable: true, get: function () { return identity_actions_js_1.AGENT_ACTIONS; } });
|
|
45
|
+
Object.defineProperty(exports, "AGENT_TENANT_MODES", { enumerable: true, get: function () { return identity_actions_js_1.AGENT_TENANT_MODES; } });
|
|
44
46
|
Object.defineProperty(exports, "actionsFor", { enumerable: true, get: function () { return identity_actions_js_1.actionsFor; } });
|
|
45
47
|
Object.defineProperty(exports, "actionsOf", { enumerable: true, get: function () { return identity_actions_js_1.actionsOf; } });
|
|
46
48
|
// The single registration seam.
|
|
@@ -163,10 +165,14 @@ var audit_seal_config_js_1 = require("./audit/audit-seal-config.js");
|
|
|
163
165
|
Object.defineProperty(exports, "loadAuditSealConfig", { enumerable: true, get: function () { return audit_seal_config_js_1.loadAuditSealConfig; } });
|
|
164
166
|
// Notification store (G-027 step 2, notification-store SPEC §5B, §5C, §5F): post notices under
|
|
165
167
|
// kinds registered in `ShieldModule.forRoot({ notificationKinds })`; bound with `auth: true`.
|
|
168
|
+
// G-035 (notification-center SPEC §5A, §6): kind `label` / `severity` and `kindInfo`.
|
|
166
169
|
var notification_service_js_1 = require("./notifications/notification.service.js");
|
|
167
170
|
Object.defineProperty(exports, "NotificationService", { enumerable: true, get: function () { return notification_service_js_1.NotificationService; } });
|
|
168
171
|
var ports_js_1 = require("./notifications/ports.js");
|
|
169
172
|
Object.defineProperty(exports, "NOTIFICATION_CATEGORIES", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_CATEGORIES; } });
|
|
173
|
+
Object.defineProperty(exports, "NOTIFICATION_SEVERITIES", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_SEVERITIES; } });
|
|
174
|
+
Object.defineProperty(exports, "NOTIFICATION_STATUSES", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_STATUSES; } });
|
|
175
|
+
Object.defineProperty(exports, "NOTIFICATION_BULK_ACTIONS", { enumerable: true, get: function () { return ports_js_1.NOTIFICATION_BULK_ACTIONS; } });
|
|
170
176
|
Object.defineProperty(exports, "NotificationKindError", { enumerable: true, get: function () { return ports_js_1.NotificationKindError; } });
|
|
171
177
|
Object.defineProperty(exports, "NotificationValidationError", { enumerable: true, get: function () { return ports_js_1.NotificationValidationError; } });
|
|
172
178
|
Object.defineProperty(exports, "NotificationUnavailableError", { enumerable: true, get: function () { return ports_js_1.NotificationUnavailableError; } });
|
package/dist/internal.d.ts
CHANGED
|
@@ -58,4 +58,18 @@ export { SHIELD_ADMIN_STEP_UP, SHIELD_ACCOUNT_UNLOCKER } from './auth/tokens.js'
|
|
|
58
58
|
export { AdminControlUnavailableError, accountUnlockKeys, type AccountUnlocker, type AdminStepUp, type AdminStepUpOutcome, } from './auth/admin-signin-controls.js';
|
|
59
59
|
export { MariaDbMfaResetter, type MfaResetQuery, type MfaResetRequest, type MfaResetResult, type MfaResetter, } from './authentication/mariadb-mfa-resetter.js';
|
|
60
60
|
export type { MfaAdminStatus, MfaStatusBatchSource, MfaStatusSubject, } from './session/mfa-requirement-service.js';
|
|
61
|
+
/**
|
|
62
|
+
* For `@astram/agent` only (G-036 M1, agent-read-capabilities SPEC §5, §10): strict session
|
|
63
|
+
* liveness (one Redis GET, `'unavailable'` on any error) for the per-call freshness check.
|
|
64
|
+
*/
|
|
65
|
+
export { SHIELD_SESSION_LIVENESS } from './auth/tokens.js';
|
|
66
|
+
export { RedisSessionLiveness, type SessionLiveness, type SessionLivenessState, } from './session/session-liveness.js';
|
|
67
|
+
/**
|
|
68
|
+
* For `@astram/agent` only (SPEC §5 run-loop "Manifest"): the permission version the enforcement
|
|
69
|
+
* guard derived `req.principal` under (gate 5's reload, else its cached facts); `undefined` ⇒ the
|
|
70
|
+
* caller fails closed. Recorded by the guard from what gate 5 reported; no read of its own.
|
|
71
|
+
*/
|
|
72
|
+
export { requestFactsVersion } from './enforcement/global-enforcement.guard.js';
|
|
73
|
+
/** For `@astram/agent` only (SPEC §5 `AgentModule` env): the runtime URL rule's loopback check. */
|
|
74
|
+
export { isLoopbackHost } from './config/loopback-host.js';
|
|
61
75
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD;;;;GAIG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE;;;GAGG;AACH,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAClE;;;GAGG;AACH,OAAO,EAAE,qCAAqC,EAAE,MAAM,kBAAkB,CAAC;AACzE;;;GAGG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,sGAAsG;AACtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D;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OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D;;;;GAIG;AACH,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE;;;;GAIG;AACH,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,0CAA0C,CAAC;AAClD,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,sCAAsC,CAAC;AAC9C;;;GAGG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC1B,MAAM,+BAA+B,CAAC;AACvC;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,mGAAmG;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MariaDbMfaResetter = exports.accountUnlockKeys = exports.AdminControlUnavailableError = exports.SHIELD_ACCOUNT_UNLOCKER = exports.SHIELD_ADMIN_STEP_UP = exports.SHIELD_MFA_REQUIREMENT_SOURCE = exports.SHIELD_MFA_REQUIREMENT = exports.SHIELD_MFA_POLICY_FEATURE = exports.SHIELD_DEFAULT_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_DEFAULT_AUTH_AUDIT_SINK = exports.SHIELD_ATTEMPT_LIMITER_FACTORY = exports.SHIELD_REDIS = exports.AttemptLimiter = exports.MariaDbCredentialProvisioner = exports.SHIELD_AUDIT_SEALER_POOL = exports.SHIELD_DB_POOL = exports.PersistenceModule = void 0;
|
|
3
|
+
exports.isLoopbackHost = exports.requestFactsVersion = exports.RedisSessionLiveness = exports.SHIELD_SESSION_LIVENESS = exports.MariaDbMfaResetter = exports.accountUnlockKeys = exports.AdminControlUnavailableError = exports.SHIELD_ACCOUNT_UNLOCKER = exports.SHIELD_ADMIN_STEP_UP = exports.SHIELD_MFA_REQUIREMENT_SOURCE = exports.SHIELD_MFA_REQUIREMENT = exports.SHIELD_MFA_POLICY_FEATURE = exports.SHIELD_DEFAULT_SCOPE_SUBTREE_RESOLVER = exports.SHIELD_DEFAULT_AUTH_AUDIT_SINK = exports.SHIELD_ATTEMPT_LIMITER_FACTORY = exports.SHIELD_REDIS = exports.AttemptLimiter = exports.MariaDbCredentialProvisioner = exports.SHIELD_AUDIT_SEALER_POOL = exports.SHIELD_DB_POOL = exports.PersistenceModule = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @astram/guard/internal — framework-composition and test surface (Phase 8 #5).
|
|
6
6
|
*
|
|
@@ -76,3 +76,21 @@ Object.defineProperty(exports, "AdminControlUnavailableError", { enumerable: tru
|
|
|
76
76
|
Object.defineProperty(exports, "accountUnlockKeys", { enumerable: true, get: function () { return admin_signin_controls_js_1.accountUnlockKeys; } });
|
|
77
77
|
var mariadb_mfa_resetter_js_1 = require("./authentication/mariadb-mfa-resetter.js");
|
|
78
78
|
Object.defineProperty(exports, "MariaDbMfaResetter", { enumerable: true, get: function () { return mariadb_mfa_resetter_js_1.MariaDbMfaResetter; } });
|
|
79
|
+
/**
|
|
80
|
+
* For `@astram/agent` only (G-036 M1, agent-read-capabilities SPEC §5, §10): strict session
|
|
81
|
+
* liveness (one Redis GET, `'unavailable'` on any error) for the per-call freshness check.
|
|
82
|
+
*/
|
|
83
|
+
var tokens_js_11 = require("./auth/tokens.js");
|
|
84
|
+
Object.defineProperty(exports, "SHIELD_SESSION_LIVENESS", { enumerable: true, get: function () { return tokens_js_11.SHIELD_SESSION_LIVENESS; } });
|
|
85
|
+
var session_liveness_js_1 = require("./session/session-liveness.js");
|
|
86
|
+
Object.defineProperty(exports, "RedisSessionLiveness", { enumerable: true, get: function () { return session_liveness_js_1.RedisSessionLiveness; } });
|
|
87
|
+
/**
|
|
88
|
+
* For `@astram/agent` only (SPEC §5 run-loop "Manifest"): the permission version the enforcement
|
|
89
|
+
* guard derived `req.principal` under (gate 5's reload, else its cached facts); `undefined` ⇒ the
|
|
90
|
+
* caller fails closed. Recorded by the guard from what gate 5 reported; no read of its own.
|
|
91
|
+
*/
|
|
92
|
+
var global_enforcement_guard_js_1 = require("./enforcement/global-enforcement.guard.js");
|
|
93
|
+
Object.defineProperty(exports, "requestFactsVersion", { enumerable: true, get: function () { return global_enforcement_guard_js_1.requestFactsVersion; } });
|
|
94
|
+
/** For `@astram/agent` only (SPEC §5 `AgentModule` env): the runtime URL rule's loopback check. */
|
|
95
|
+
var loopback_host_js_1 = require("./config/loopback-host.js");
|
|
96
|
+
Object.defineProperty(exports, "isLoopbackHost", { enumerable: true, get: function () { return loopback_host_js_1.isLoopbackHost; } });
|
|
@@ -21,6 +21,14 @@ export { SHIELD_DECISION_AUTHORITY, SHIELD_RECORD_AUTHORIZATION };
|
|
|
21
21
|
import { type ShieldStorageOption } from '../storage/storage.providers.js';
|
|
22
22
|
import type { ShieldCaptchaOption } from '../captcha/captcha.providers.js';
|
|
23
23
|
import type { NotificationKindRegistration } from '../notifications/ports.js';
|
|
24
|
+
/**
|
|
25
|
+
* The framework-module marker (G-036 M1, agent-read-capabilities SPEC §5 A). Every `@Module` class of
|
|
26
|
+
* guard, identity, engine and agent carries it as a static key (`static readonly [key] = true`), so
|
|
27
|
+
* `@astram/agent`'s inject allow-list walk refuses a capability whose provider tree reaches a
|
|
28
|
+
* framework module. Built with `Symbol.for`, so no package imports another to read it; each package
|
|
29
|
+
* has a test that fails on an unmarked `@Module` class.
|
|
30
|
+
*/
|
|
31
|
+
declare const FRAMEWORK_MODULE: unique symbol;
|
|
24
32
|
export type { RecordAuthorizationInputs } from '../authz/wire-record-authorization.js';
|
|
25
33
|
/**
|
|
26
34
|
* Options for {@link ShieldModule.forRoot}. Intentionally minimal (ADR-0023 §7 —
|
|
@@ -382,6 +390,7 @@ export interface ShieldModuleAsyncOptions {
|
|
|
382
390
|
* `@Global()` so its exported tokens are visible app-wide without re-importing.
|
|
383
391
|
*/
|
|
384
392
|
export declare class ShieldModule {
|
|
393
|
+
static readonly [FRAMEWORK_MODULE] = true;
|
|
385
394
|
/** Register Shield with static options (the common path). */
|
|
386
395
|
static forRoot(options?: ShieldModuleOptions): DynamicModule;
|
|
387
396
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield.module.d.ts","sourceRoot":"","sources":["../../src/module/shield.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AAOnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAoB,MAAM,cAAc,CAAC;AAQzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,m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,iBAAiB,CAAC,EAAE,SAAS,4BAA4B,EAAE,CAAC;CACtE;AAYD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAEa,YAAY;IACvB,MAAM,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,QAAQ;IAE1C,6DAA6D;IAC7D,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,mBAAwB,GAAG,aAAa;IA4HhE;;;;;;;;;OASG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;CAsItE"}
|
|
@@ -88,6 +88,14 @@ Object.defineProperty(exports, "SHIELD_RECORD_AUTHORIZATION", { enumerable: true
|
|
|
88
88
|
// FILE_STORAGE SPEC §6: the `storage` option (S3 adapter loaded lazily inside the provider).
|
|
89
89
|
const storage_providers_js_1 = require("../storage/storage.providers.js");
|
|
90
90
|
const notification_service_js_1 = require("../notifications/notification.service.js");
|
|
91
|
+
/**
|
|
92
|
+
* The framework-module marker (G-036 M1, agent-read-capabilities SPEC §5 A). Every `@Module` class of
|
|
93
|
+
* guard, identity, engine and agent carries it as a static key (`static readonly [key] = true`), so
|
|
94
|
+
* `@astram/agent`'s inject allow-list walk refuses a capability whose provider tree reaches a
|
|
95
|
+
* framework module. Built with `Symbol.for`, so no package imports another to read it; each package
|
|
96
|
+
* has a test that fails on an unmarked `@Module` class.
|
|
97
|
+
*/
|
|
98
|
+
const FRAMEWORK_MODULE = Symbol.for('astram.framework-module');
|
|
91
99
|
/**
|
|
92
100
|
* A `Function`-wrapped dynamic `import()` that survives the CommonJS **build** — the same
|
|
93
101
|
* shim as auth.module.ts's `evalImport`. Under `module: commonjs`, `tsc` would rewrite a
|
|
@@ -225,7 +233,9 @@ function loadEnvAppConfig() {
|
|
|
225
233
|
*
|
|
226
234
|
* `@Global()` so its exported tokens are visible app-wide without re-importing.
|
|
227
235
|
*/
|
|
228
|
-
let ShieldModule =
|
|
236
|
+
let ShieldModule = class ShieldModule {
|
|
237
|
+
static { ShieldModule_1 = this; }
|
|
238
|
+
static [FRAMEWORK_MODULE] = true;
|
|
229
239
|
/** Register Shield with static options (the common path). */
|
|
230
240
|
static forRoot(options = {}) {
|
|
231
241
|
// G-009 N4: a reserved operation principal is never a root, however `rootIds` was built.
|
|
@@ -15,12 +15,30 @@
|
|
|
15
15
|
* `lib/config/connection-options.js`), so an ODKU row left unchanged reports 1, the same as an
|
|
16
16
|
* insert. Instead the store counts its own freshly generated `un_uuid`s right after the insert, on
|
|
17
17
|
* the same `query` (the caller's transaction when given, so it sees its own uncommitted rows).
|
|
18
|
+
*
|
|
19
|
+
* G-035 (notification-center SPEC §5B; column `un_archived_at_ms`, identity migration 110):
|
|
20
|
+
* - `list` filters by kind, status, creation range and a title/body search. The search is
|
|
21
|
+
* `LIKE ? ESCAPE '!'` with `!`, `%`, `_` escaped as `!!`, `!%`, `!_` ({@link likeContainsPattern}):
|
|
22
|
+
* never `ESCAPE '\\'`, whose meaning changes under `NO_BACKSLASH_ESCAPES`; a backslash in the term
|
|
23
|
+
* is an ordinary character. Case and accents follow the column collation (`utf8mb4_unicode_ci`).
|
|
24
|
+
* - Without a status, archived notices are left out; `unread` / `read` leave them out too.
|
|
25
|
+
* - `countUnread` and `markAllRead` skip archived rows; `archive` also sets the read time when
|
|
26
|
+
* unread, so an archived notice never holds the badge; `unarchive` brings it back as read.
|
|
27
|
+
* - Every single-notice update puts its "would change" condition in the WHERE, so `affectedRows`
|
|
28
|
+
* (matched rows, `CLIENT_FOUND_ROWS`) counts changes only; 0 ⇒ one scoped lookup tells an
|
|
29
|
+
* unchanged own notice (found) from a foreign or unknown one (not found).
|
|
30
|
+
* - `purge` is unchanged: archiving never extends retention.
|
|
18
31
|
*/
|
|
19
32
|
import type { Pool } from 'mariadb';
|
|
20
33
|
import { type FrameworkSchemaNames } from '../config/framework-schema-names.js';
|
|
21
|
-
import { type NotificationCategory, type NotificationInsert, type NotificationListQuery, type NotificationListResult, type NotificationRetentionPolicy, type NotificationStore, type NotificationUnreadCounts, type NotificationWriteOptions } from './ports.js';
|
|
34
|
+
import { type NotificationBulkAction, type NotificationCategory, type NotificationInsert, type NotificationKindSummary, type NotificationListQuery, type NotificationListResult, type NotificationRetentionPolicy, type NotificationStore, type NotificationUnreadCounts, type NotificationWriteOptions } from './ports.js';
|
|
22
35
|
/** Rows per `insertMany` statement (the `post` recipient cap, SPEC §10). */
|
|
23
36
|
export declare const NOTIFICATION_INSERT_MAX_ROWS = 1000;
|
|
37
|
+
/**
|
|
38
|
+
* `%term%` for `LIKE ? ESCAPE '!'`: `!` first, then `%` and `_`, each prefixed with `!`. A
|
|
39
|
+
* backslash stays an ordinary character (no `sql_mode` dependence).
|
|
40
|
+
*/
|
|
41
|
+
export declare function likeContainsPattern(term: string): string;
|
|
24
42
|
export declare class MariaDbNotificationStore implements NotificationStore {
|
|
25
43
|
private readonly pool;
|
|
26
44
|
/** `<identity>`.`user_notification`, resolved at construction. */
|
|
@@ -31,6 +49,13 @@ export declare class MariaDbNotificationStore implements NotificationStore {
|
|
|
31
49
|
list(userId: string, tenantId: string, query: NotificationListQuery): Promise<NotificationListResult>;
|
|
32
50
|
countUnread(userId: string, tenantId: string): Promise<NotificationUnreadCounts>;
|
|
33
51
|
markRead(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
52
|
+
listKinds(userId: string, tenantId: string): Promise<readonly NotificationKindSummary[]>;
|
|
53
|
+
markUnread(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
54
|
+
archive(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
55
|
+
unarchive(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
56
|
+
bulk(userId: string, tenantId: string, action: NotificationBulkAction, uuids: readonly string[], nowMs: number): Promise<number>;
|
|
57
|
+
/** One scoped single-notice update; 0 changed ⇒ a scoped lookup decides found / not found. */
|
|
58
|
+
private updateOne;
|
|
34
59
|
markAllRead(userId: string, tenantId: string, category: NotificationCategory | undefined, nowMs: number): Promise<number>;
|
|
35
60
|
insertMany(rows: readonly NotificationInsert[], opts?: NotificationWriteOptions): Promise<number>;
|
|
36
61
|
purge(nowMs: number, policy: NotificationRetentionPolicy, maxRows: number): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-notification-store.d.ts","sourceRoot":"","sources":["../../src/notifications/mariadb-notification-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mariadb-notification-store.d.ts","sourceRoot":"","sources":["../../src/notifications/mariadb-notification-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE3B,KAAK,2BAA2B,EAEhC,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AAIpB,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAoDjD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAqCD,qBAAa,wBAAyB,YAAW,iBAAiB;IAK9D,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,kEAAkE;IAClE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAGZ,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC;IAC1C,yFAAyF;IACzF,OAAO,CAAC,EAAE,oBAAoB;IAQ1B,IAAI,CACR,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE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;IAuDZ,KAAK,CACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;CAiBnB"}
|
|
@@ -1,15 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MariaDbNotificationStore = exports.NOTIFICATION_INSERT_MAX_ROWS = void 0;
|
|
4
|
+
exports.likeContainsPattern = likeContainsPattern;
|
|
4
5
|
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
5
6
|
const ports_js_1 = require("./ports.js");
|
|
6
7
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
7
8
|
/** Rows per `insertMany` statement (the `post` recipient cap, SPEC §10). */
|
|
8
9
|
exports.NOTIFICATION_INSERT_MAX_ROWS = 1000;
|
|
9
|
-
const SELECT_COLUMNS = 'un_uuid, un_category, un_kind, un_title, un_body, un_link, un_created_at_ms, un_read_at_ms'
|
|
10
|
+
const SELECT_COLUMNS = 'un_uuid, un_category, un_kind, un_title, un_body, un_link, un_created_at_ms, un_read_at_ms, ' +
|
|
11
|
+
'un_archived_at_ms';
|
|
12
|
+
/** Not archived (the default view, the badge and "mark all read"). */
|
|
13
|
+
const NOT_ARCHIVED = 'un_archived_at_ms IS NULL';
|
|
14
|
+
/**
|
|
15
|
+
* Per action: the SET clause, whether it takes `nowMs`, and the condition that makes the row
|
|
16
|
+
* change (in the WHERE, so the matched count is the changed count).
|
|
17
|
+
*/
|
|
18
|
+
const ACTIONS = {
|
|
19
|
+
read: { set: 'un_read_at_ms = ?', usesNow: 1, changes: 'un_read_at_ms IS NULL' },
|
|
20
|
+
// An archived notice stays read (status is one of unread / read / archived).
|
|
21
|
+
unread: {
|
|
22
|
+
set: 'un_read_at_ms = NULL',
|
|
23
|
+
usesNow: 0,
|
|
24
|
+
changes: `un_read_at_ms IS NOT NULL AND ${NOT_ARCHIVED}`,
|
|
25
|
+
},
|
|
26
|
+
// The first read time is kept; an unread notice is read from now on.
|
|
27
|
+
archive: {
|
|
28
|
+
set: 'un_archived_at_ms = ?, un_read_at_ms = COALESCE(un_read_at_ms, ?)',
|
|
29
|
+
usesNow: 2,
|
|
30
|
+
changes: NOT_ARCHIVED,
|
|
31
|
+
},
|
|
32
|
+
unarchive: {
|
|
33
|
+
set: 'un_archived_at_ms = NULL',
|
|
34
|
+
usesNow: 0,
|
|
35
|
+
changes: 'un_archived_at_ms IS NOT NULL',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
10
38
|
function isCategory(v) {
|
|
11
39
|
return ports_js_1.NOTIFICATION_CATEGORIES.includes(v);
|
|
12
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* `%term%` for `LIKE ? ESCAPE '!'`: `!` first, then `%` and `_`, each prefixed with `!`. A
|
|
43
|
+
* backslash stays an ordinary character (no `sql_mode` dependence).
|
|
44
|
+
*/
|
|
45
|
+
function likeContainsPattern(term) {
|
|
46
|
+
return `%${term.replace(/[!%_]/g, (c) => `!${c}`)}%`;
|
|
47
|
+
}
|
|
48
|
+
function assertEpochMs(name, v) {
|
|
49
|
+
if (!Number.isSafeInteger(v) || v < 0) {
|
|
50
|
+
throw new RangeError(`MariaDbNotificationStore: ${name} is out of range`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
13
53
|
/** BIGINT columns may arrive as bigint; the epoch-ms range fits a safe integer. */
|
|
14
54
|
const toRow = (r) => ({
|
|
15
55
|
uuid: String(r.un_uuid),
|
|
@@ -21,6 +61,7 @@ const toRow = (r) => ({
|
|
|
21
61
|
link: r.un_link ?? null,
|
|
22
62
|
createdAtMs: Number(r.un_created_at_ms),
|
|
23
63
|
readAtMs: r.un_read_at_ms == null ? null : Number(r.un_read_at_ms),
|
|
64
|
+
archivedAtMs: r.un_archived_at_ms == null ? null : Number(r.un_archived_at_ms),
|
|
24
65
|
});
|
|
25
66
|
function affected(res) {
|
|
26
67
|
return Number(res?.affectedRows ?? 0);
|
|
@@ -53,8 +94,51 @@ class MariaDbNotificationStore {
|
|
|
53
94
|
where.push('un_category = ?');
|
|
54
95
|
params.push(query.category);
|
|
55
96
|
}
|
|
97
|
+
if (query.kind !== undefined) {
|
|
98
|
+
if (typeof query.kind !== 'string') {
|
|
99
|
+
throw new RangeError('MariaDbNotificationStore: kind is out of range');
|
|
100
|
+
}
|
|
101
|
+
where.push('un_kind = ?');
|
|
102
|
+
params.push(query.kind);
|
|
103
|
+
}
|
|
104
|
+
switch (query.status) {
|
|
105
|
+
case undefined:
|
|
106
|
+
where.push(NOT_ARCHIVED);
|
|
107
|
+
break;
|
|
108
|
+
case 'unread':
|
|
109
|
+
where.push('un_read_at_ms IS NULL', NOT_ARCHIVED);
|
|
110
|
+
break;
|
|
111
|
+
case 'read':
|
|
112
|
+
where.push('un_read_at_ms IS NOT NULL', NOT_ARCHIVED);
|
|
113
|
+
break;
|
|
114
|
+
case 'archived':
|
|
115
|
+
where.push('un_archived_at_ms IS NOT NULL');
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
if (!ports_js_1.NOTIFICATION_STATUSES.includes(query.status)) {
|
|
119
|
+
throw new RangeError('MariaDbNotificationStore: status is out of range');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
56
122
|
if (query.unreadOnly)
|
|
57
123
|
where.push('un_read_at_ms IS NULL');
|
|
124
|
+
if (query.fromMs !== undefined) {
|
|
125
|
+
assertEpochMs('fromMs', query.fromMs);
|
|
126
|
+
where.push('un_created_at_ms >= ?');
|
|
127
|
+
params.push(query.fromMs);
|
|
128
|
+
}
|
|
129
|
+
if (query.toMs !== undefined) {
|
|
130
|
+
assertEpochMs('toMs', query.toMs);
|
|
131
|
+
where.push('un_created_at_ms <= ?');
|
|
132
|
+
params.push(query.toMs);
|
|
133
|
+
}
|
|
134
|
+
if (query.search !== undefined) {
|
|
135
|
+
if (typeof query.search !== 'string' || query.search.length === 0) {
|
|
136
|
+
throw new RangeError('MariaDbNotificationStore: search is out of range');
|
|
137
|
+
}
|
|
138
|
+
const pattern = likeContainsPattern(query.search);
|
|
139
|
+
where.push("(un_title LIKE ? ESCAPE '!' OR un_body LIKE ? ESCAPE '!')");
|
|
140
|
+
params.push(pattern, pattern);
|
|
141
|
+
}
|
|
58
142
|
const clause = where.join(' AND ');
|
|
59
143
|
const total = countOf(await this.pool.query(`SELECT COUNT(*) AS c FROM ${this.table} WHERE ${clause}`, params));
|
|
60
144
|
if (total === 0)
|
|
@@ -69,7 +153,7 @@ class MariaDbNotificationStore {
|
|
|
69
153
|
}
|
|
70
154
|
async countUnread(userId, tenantId) {
|
|
71
155
|
const rows = (await this.pool.query(`SELECT un_category, COUNT(*) AS c FROM ${this.table}
|
|
72
|
-
WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL
|
|
156
|
+
WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL AND ${NOT_ARCHIVED}
|
|
73
157
|
GROUP BY un_category`, [userId, tenantId]));
|
|
74
158
|
const counts = { announcement: 0, personal: 0 };
|
|
75
159
|
for (const r of rows) {
|
|
@@ -88,10 +172,51 @@ class MariaDbNotificationStore {
|
|
|
88
172
|
WHERE un_uuid = ? AND un_user_uuid = ? AND un_tenant_id = ? LIMIT 1`, [uuid, userId, tenantId]));
|
|
89
173
|
return rows.length > 0;
|
|
90
174
|
}
|
|
175
|
+
async listKinds(userId, tenantId) {
|
|
176
|
+
const rows = (await this.pool.query(`SELECT DISTINCT un_kind, un_category FROM ${this.table}
|
|
177
|
+
WHERE un_user_uuid = ? AND un_tenant_id = ?
|
|
178
|
+
ORDER BY un_kind, un_category`, [userId, tenantId]));
|
|
179
|
+
return rows
|
|
180
|
+
.filter((r) => isCategory(r.un_category))
|
|
181
|
+
.map((r) => ({ kind: String(r.un_kind), category: r.un_category }));
|
|
182
|
+
}
|
|
183
|
+
markUnread(userId, tenantId, uuid) {
|
|
184
|
+
return this.updateOne('unread', userId, tenantId, uuid, 0);
|
|
185
|
+
}
|
|
186
|
+
archive(userId, tenantId, uuid, nowMs) {
|
|
187
|
+
return this.updateOne('archive', userId, tenantId, uuid, nowMs);
|
|
188
|
+
}
|
|
189
|
+
unarchive(userId, tenantId, uuid) {
|
|
190
|
+
return this.updateOne('unarchive', userId, tenantId, uuid, 0);
|
|
191
|
+
}
|
|
192
|
+
async bulk(userId, tenantId, action, uuids, nowMs) {
|
|
193
|
+
if (!ports_js_1.NOTIFICATION_BULK_ACTIONS.includes(action)) {
|
|
194
|
+
throw new RangeError('MariaDbNotificationStore: action is out of range');
|
|
195
|
+
}
|
|
196
|
+
if (!Array.isArray(uuids) || uuids.length < 1 || uuids.length > ports_js_1.NOTIFICATION_BULK_MAX) {
|
|
197
|
+
throw new RangeError('MariaDbNotificationStore: uuids is out of range');
|
|
198
|
+
}
|
|
199
|
+
const a = ACTIONS[action];
|
|
200
|
+
const marks = uuids.map(() => '?').join(', ');
|
|
201
|
+
// Only the caller's own rows in this tenant can match; foreign or unknown uuids count 0.
|
|
202
|
+
return affected(await this.pool.query(`UPDATE ${this.table} SET ${a.set}
|
|
203
|
+
WHERE un_uuid IN (${marks}) AND un_user_uuid = ? AND un_tenant_id = ? AND ${a.changes}`, [...new Array(a.usesNow).fill(nowMs), ...uuids, userId, tenantId]));
|
|
204
|
+
}
|
|
205
|
+
/** One scoped single-notice update; 0 changed ⇒ a scoped lookup decides found / not found. */
|
|
206
|
+
async updateOne(action, userId, tenantId, uuid, nowMs) {
|
|
207
|
+
const a = ACTIONS[action];
|
|
208
|
+
const res = await this.pool.query(`UPDATE ${this.table} SET ${a.set}
|
|
209
|
+
WHERE un_uuid = ? AND un_user_uuid = ? AND un_tenant_id = ? AND ${a.changes}`, [...new Array(a.usesNow).fill(nowMs), uuid, userId, tenantId]);
|
|
210
|
+
if (affected(res) > 0)
|
|
211
|
+
return true;
|
|
212
|
+
const rows = (await this.pool.query(`SELECT 1 AS found FROM ${this.table}
|
|
213
|
+
WHERE un_uuid = ? AND un_user_uuid = ? AND un_tenant_id = ? LIMIT 1`, [uuid, userId, tenantId]));
|
|
214
|
+
return rows.length > 0;
|
|
215
|
+
}
|
|
91
216
|
async markAllRead(userId, tenantId, category, nowMs) {
|
|
92
217
|
const params = [nowMs, userId, tenantId];
|
|
93
218
|
let sql = `UPDATE ${this.table} SET un_read_at_ms = ?
|
|
94
|
-
WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL`;
|
|
219
|
+
WHERE un_user_uuid = ? AND un_tenant_id = ? AND un_read_at_ms IS NULL AND ${NOT_ARCHIVED}`;
|
|
95
220
|
if (category !== undefined) {
|
|
96
221
|
sql += ' AND un_category = ?';
|
|
97
222
|
params.push(category);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Pool } from 'mariadb';
|
|
2
2
|
import { type FrameworkSchemaNames } from '../config/framework-schema-names.js';
|
|
3
|
-
import { type NotificationCategory, type NotificationKindRegistration, type NotificationStore, type NotificationWriteOptions } from './ports.js';
|
|
3
|
+
import { type NotificationCategory, type NotificationKindRegistration, type NotificationSeverity, type NotificationStore, type NotificationWriteOptions } from './ports.js';
|
|
4
4
|
/** SPEC §10 limits. */
|
|
5
5
|
export declare const NOTIFICATION_TITLE_MAX = 160;
|
|
6
6
|
export declare const NOTIFICATION_BODY_MAX = 1000;
|
|
@@ -30,17 +30,46 @@ export interface NotificationPostResult {
|
|
|
30
30
|
readonly created: number;
|
|
31
31
|
readonly skipped: number;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
34
|
-
export
|
|
33
|
+
/** A kind's label, severity and category, as the API shows them (notification-center SPEC §5A). */
|
|
34
|
+
export interface NotificationKindInfo {
|
|
35
|
+
readonly label: string;
|
|
36
|
+
readonly severity: NotificationSeverity;
|
|
37
|
+
/**
|
|
38
|
+
* The registered category; for a kind no longer registered, the category the caller passed
|
|
39
|
+
* (the stored row's), else `undefined`.
|
|
40
|
+
*/
|
|
41
|
+
readonly category: NotificationCategory | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** One validated registration in the registry. */
|
|
44
|
+
export interface NotificationKindDefinition {
|
|
45
|
+
readonly category: NotificationCategory;
|
|
46
|
+
readonly label: string;
|
|
47
|
+
readonly severity: NotificationSeverity;
|
|
48
|
+
/** `true` when the app gave no label and it was generated from the kind (boot warning). */
|
|
49
|
+
readonly labelGenerated: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Validated kind registry: kind ⇒ category, label, severity. */
|
|
52
|
+
export type NotificationKindRegistry = ReadonlyMap<string, NotificationKindDefinition>;
|
|
53
|
+
/**
|
|
54
|
+
* The label generated from a kind's last segment (`app.task_assigned` ⇒ "Task assigned"): `_`
|
|
55
|
+
* becomes a space, the first letter upper-case; over 40 code points ⇒ the first 39 and "…".
|
|
56
|
+
* Total for any string (an old row's kind is shown, never thrown on).
|
|
57
|
+
*/
|
|
58
|
+
export declare function generatedKindLabel(kind: string): string;
|
|
59
|
+
/** The info of a kind the registry does not know (an old row): generated label, `info`. */
|
|
60
|
+
export declare function fallbackKindInfo(kind: string, storedCategory?: NotificationCategory): NotificationKindInfo;
|
|
35
61
|
/**
|
|
36
62
|
* Build the kind registry from the app's `notificationKinds` (validated at boot, SPEC §5C) and the
|
|
37
63
|
* framework's own kinds. Refuses a malformed or over-long kind, an unknown category, a duplicate,
|
|
38
|
-
*
|
|
64
|
+
* an app kind under the reserved `shield.` prefix, a bad label (not 1–40 characters of plain text)
|
|
65
|
+
* and an unknown severity; each error names the kind, never the label.
|
|
39
66
|
*/
|
|
40
67
|
export declare function resolveNotificationKinds(appKinds: readonly NotificationKindRegistration[] | undefined, frameworkKinds?: readonly NotificationKindRegistration[]): NotificationKindRegistry;
|
|
41
|
-
/** Logs counts only (Nest `Logger` shape). */
|
|
68
|
+
/** Logs counts and kind names only (Nest `Logger` shape). */
|
|
42
69
|
export interface NotificationServiceLogger {
|
|
43
70
|
debug(message: string): void;
|
|
71
|
+
/** The one boot warning naming kinds registered without a label (absent ⇒ not logged). */
|
|
72
|
+
warn?(message: string): void;
|
|
44
73
|
}
|
|
45
74
|
export interface NotificationServiceOptions {
|
|
46
75
|
/** Default `Date.now`. */
|
|
@@ -64,6 +93,12 @@ export declare class NotificationService {
|
|
|
64
93
|
schemas?: FrameworkSchemaNames, options?: NotificationServiceOptions);
|
|
65
94
|
/** Whether `kind` is registered (framework or app). */
|
|
66
95
|
hasKind(kind: string): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* The label, severity and category shown for `kind` (notification-center SPEC §5A). A kind no
|
|
98
|
+
* longer registered (old rows stay readable) ⇒ a label generated from the kind, `info`, and
|
|
99
|
+
* `storedCategory` (the row's) as the category.
|
|
100
|
+
*/
|
|
101
|
+
kindInfo(kind: string, storedCategory?: NotificationCategory): NotificationKindInfo;
|
|
67
102
|
post(input: NotificationPostInput, opts?: NotificationWriteOptions): Promise<NotificationPostResult>;
|
|
68
103
|
/** ONE parameterized SELECT: active users with an active membership in `tenantId`. */
|
|
69
104
|
private activeRecipients;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../src/notifications/notification.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../src/notifications/notification.service.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EASL,KAAK,oBAAoB,EAEzB,KAAK,4BAA4B,EAEjC,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC9B,MAAM,YAAY,CAAC;AAEpB,uBAAuB;AACvB,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,2BAA2B,OAAO,CAAC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