@astram/guard 0.30.1 → 0.32.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/README.md +43 -0
- package/dist/agent/agent-provenance.d.ts +24 -0
- package/dist/agent/agent-provenance.d.ts.map +1 -0
- package/dist/agent/agent-provenance.js +40 -0
- package/dist/authz/manifest-operation-authority-adapter.d.ts +9 -1
- package/dist/authz/manifest-operation-authority-adapter.d.ts.map +1 -1
- package/dist/authz/manifest-operation-authority-adapter.js +17 -1
- package/dist/authz/operation-marker-check.d.ts +12 -1
- package/dist/authz/operation-marker-check.d.ts.map +1 -1
- package/dist/authz/operation-marker-check.js +13 -1
- package/dist/authz/wire-record-authorization.d.ts.map +1 -1
- package/dist/authz/wire-record-authorization.js +6 -4
- package/dist/config/app-config.d.ts +15 -3
- package/dist/config/app-config.d.ts.map +1 -1
- package/dist/config/app-config.js +12 -3
- package/dist/enforcement/enforcement.module.d.ts +8 -1
- package/dist/enforcement/enforcement.module.d.ts.map +1 -1
- package/dist/enforcement/enforcement.module.js +9 -0
- package/dist/enforcement/global-enforcement.guard.d.ts.map +1 -1
- package/dist/enforcement/global-enforcement.guard.js +7 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -5
- package/dist/internal.d.ts +12 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +17 -1
- package/dist/module/shield-tokens.d.ts +103 -0
- package/dist/module/shield-tokens.d.ts.map +1 -1
- package/dist/module/shield-tokens.js +13 -1
- package/dist/module/shield.module.d.ts +17 -1
- package/dist/module/shield.module.d.ts.map +1 -1
- package/dist/module/shield.module.js +2 -2
- package/dist/notifications/notification.service.d.ts +2 -0
- package/dist/notifications/notification.service.d.ts.map +1 -1
- package/dist/notifications/notification.service.js +8 -0
- package/dist/request-auth/request-principal-als.d.ts +65 -0
- package/dist/request-auth/request-principal-als.d.ts.map +1 -0
- package/dist/request-auth/request-principal-als.js +83 -0
- package/dist/storage/storage.providers.d.ts +36 -3
- package/dist/storage/storage.providers.d.ts.map +1 -1
- package/dist/storage/storage.providers.js +203 -3
- 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 = exports.maskEmail = exports.isEmailShaped = exports.canonicalEmail = exports.hmacSha1 = exports.resolveTotpVerifier = exports.makeDefaultTotpVerifier = void 0;
|
|
19
|
+
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.currentRequestPrincipal = 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.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_AGENT_TASK_CALLS = exports.SHIELD_PROPOSAL_READER = exports.SHIELD_PROPOSAL_PORT = exports.SHIELD_AGENT_FILE_READER = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.isDeniedAppContentType = exports.MAX_APP_FILE_PROFILES = exports.APP_CONTENT_TYPE_DENY_LIST = 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 = exports.resolveBootSecrets = void 0;
|
|
21
|
+
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 = exports.translateListScope = exports.SHIELD_LIST_SCOPE_PORT = exports.MariaDbListScopeAdapter = exports.SHIELD_POLICY_STORE = exports.MariaDbPolicyStore = exports.SHIELD_RECORD_RULE_PORT = exports.MariaDbRecordPermissionRuleAdapter = exports.accessBindingTtlMs = void 0;
|
|
22
|
+
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 = exports.DEFAULT_DB_CONFIG = exports.assertRefreshHmacKey = exports.loadRefreshHmacKey = exports.loadSessionLifetimes = exports.loadRedisConfig = exports.loadDbConfig = exports.SCHEMA_SVC_POOL_HARD_CAP = exports.DEFAULT_POOL_BUDGET = 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 = 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 = 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");
|
|
@@ -104,6 +104,12 @@ Object.defineProperty(exports, "MariaDbApiKeyStore", { enumerable: true, get: fu
|
|
|
104
104
|
var session_facts_als_js_1 = require("./request-auth/session-facts-als.js");
|
|
105
105
|
Object.defineProperty(exports, "SHIELD_SESSION_FACTS_ALS", { enumerable: true, get: function () { return session_facts_als_js_1.SHIELD_SESSION_FACTS_ALS; } });
|
|
106
106
|
Object.defineProperty(exports, "NO_SESSION_FACTS", { enumerable: true, get: function () { return session_facts_als_js_1.NO_SESSION_FACTS; } });
|
|
107
|
+
// The request principal (capability-outbound-audit SPEC v6 §5 G): a READ-ONLY view of the current
|
|
108
|
+
// request's frozen `{ tenantId, userId }`, written once by the global enforcement guard. `undefined`
|
|
109
|
+
// outside a request, on public routes and for refused requests. The ALS, its middleware and its
|
|
110
|
+
// writer stay private to guard: app code cannot enter or overwrite it.
|
|
111
|
+
var request_principal_als_js_1 = require("./request-auth/request-principal-als.js");
|
|
112
|
+
Object.defineProperty(exports, "currentRequestPrincipal", { enumerable: true, get: function () { return request_principal_als_js_1.currentRequestPrincipal; } });
|
|
107
113
|
// The global enforcement guard (framework-owned; exported so the enforcement
|
|
108
114
|
// point is inspectable/testable, not so consumers re-wire it).
|
|
109
115
|
//
|
|
@@ -186,10 +192,19 @@ var file_intake_interceptor_js_1 = require("./storage/file-intake.interceptor.js
|
|
|
186
192
|
Object.defineProperty(exports, "FileIntake", { enumerable: true, get: function () { return file_intake_interceptor_js_1.FileIntake; } });
|
|
187
193
|
Object.defineProperty(exports, "FILE_INTAKE_REQUEST_KEY", { enumerable: true, get: function () { return file_intake_interceptor_js_1.FILE_INTAKE_REQUEST_KEY; } });
|
|
188
194
|
Object.defineProperty(exports, "FILE_INTAKE_DEFAULT_MAX_BYTES", { enumerable: true, get: function () { return file_intake_interceptor_js_1.FILE_INTAKE_DEFAULT_MAX_BYTES; } });
|
|
195
|
+
// DP1 (app-file-profiles SPEC §10): the content types an app profile may never use.
|
|
196
|
+
var storage_providers_js_1 = require("./storage/storage.providers.js");
|
|
197
|
+
Object.defineProperty(exports, "APP_CONTENT_TYPE_DENY_LIST", { enumerable: true, get: function () { return storage_providers_js_1.APP_CONTENT_TYPE_DENY_LIST; } });
|
|
198
|
+
Object.defineProperty(exports, "MAX_APP_FILE_PROFILES", { enumerable: true, get: function () { return storage_providers_js_1.MAX_APP_FILE_PROFILES; } });
|
|
199
|
+
Object.defineProperty(exports, "isDeniedAppContentType", { enumerable: true, get: function () { return storage_providers_js_1.isDeniedAppContentType; } });
|
|
189
200
|
var shield_tokens_js_1 = require("./module/shield-tokens.js");
|
|
190
201
|
Object.defineProperty(exports, "SHIELD_OBJECT_STORE", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_OBJECT_STORE; } });
|
|
191
202
|
Object.defineProperty(exports, "SHIELD_FILE_INGEST", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_FILE_INGEST; } });
|
|
192
203
|
Object.defineProperty(exports, "SHIELD_AGENT_FILE_READER", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_AGENT_FILE_READER; } });
|
|
204
|
+
// agent-proposals SPEC v7 §5 F / §5 I, plan D-6.
|
|
205
|
+
Object.defineProperty(exports, "SHIELD_PROPOSAL_PORT", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_PROPOSAL_PORT; } });
|
|
206
|
+
Object.defineProperty(exports, "SHIELD_PROPOSAL_READER", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_PROPOSAL_READER; } });
|
|
207
|
+
Object.defineProperty(exports, "SHIELD_AGENT_TASK_CALLS", { enumerable: true, get: function () { return shield_tokens_js_1.SHIELD_AGENT_TASK_CALLS; } });
|
|
193
208
|
var app_config_js_1 = require("./config/app-config.js");
|
|
194
209
|
Object.defineProperty(exports, "loadObjectStorageConfig", { enumerable: true, get: function () { return app_config_js_1.loadObjectStorageConfig; } });
|
|
195
210
|
Object.defineProperty(exports, "DEFAULT_OBJECT_STORAGE_MAX_BYTES", { enumerable: true, get: function () { return app_config_js_1.DEFAULT_OBJECT_STORAGE_MAX_BYTES; } });
|
package/dist/internal.d.ts
CHANGED
|
@@ -70,6 +70,18 @@ export { RedisSessionLiveness, type SessionLiveness, type SessionLivenessState,
|
|
|
70
70
|
* caller fails closed. Recorded by the guard from what gate 5 reported; no read of its own.
|
|
71
71
|
*/
|
|
72
72
|
export { requestFactsVersion } from './enforcement/global-enforcement.guard.js';
|
|
73
|
+
/**
|
|
74
|
+
* For `@astram/agent` only (capability-outbound-audit SPEC v6 §5 G, QA P2-1): read-only, `true`
|
|
75
|
+
* inside a request that passed the framework middleware (with or without a principal). The audited
|
|
76
|
+
* fetch refuses a call made inside a request that has no principal (`@Public()` or refused).
|
|
77
|
+
*/
|
|
78
|
+
export { insideRequest } from './request-auth/request-principal-als.js';
|
|
79
|
+
/**
|
|
80
|
+
* For `@astram/agent` (mint) and `@astram/identity` (check) only (agent-proposals plan D-9):
|
|
81
|
+
* ⛔ UNFORGEABLE agent provenance. Only the agent executor mints; identity's proposal submit
|
|
82
|
+
* refuses `origin: 'agent'` unless the provenance is the minted object (`forbidden`).
|
|
83
|
+
*/
|
|
84
|
+
export { AGENT_PROVENANCE_ID_MAX, isMintedAgentProvenance, mintAgentProvenance, type AgentProvenance, } from './agent/agent-provenance.js';
|
|
73
85
|
/** For `@astram/agent` only (SPEC §5 `AgentModule` env): the runtime URL rule's loopback check. */
|
|
74
86
|
export { isLoopbackHost } from './config/loopback-host.js';
|
|
75
87
|
//# 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,EAA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AClB,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;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE;;;;GAIG;AACH,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,6BAA6B,CAAC;AACrC,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.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;
|
|
3
|
+
exports.isLoopbackHost = exports.mintAgentProvenance = exports.isMintedAgentProvenance = exports.AGENT_PROVENANCE_ID_MAX = exports.insideRequest = 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
|
*
|
|
@@ -91,6 +91,22 @@ Object.defineProperty(exports, "RedisSessionLiveness", { enumerable: true, get:
|
|
|
91
91
|
*/
|
|
92
92
|
var global_enforcement_guard_js_1 = require("./enforcement/global-enforcement.guard.js");
|
|
93
93
|
Object.defineProperty(exports, "requestFactsVersion", { enumerable: true, get: function () { return global_enforcement_guard_js_1.requestFactsVersion; } });
|
|
94
|
+
/**
|
|
95
|
+
* For `@astram/agent` only (capability-outbound-audit SPEC v6 §5 G, QA P2-1): read-only, `true`
|
|
96
|
+
* inside a request that passed the framework middleware (with or without a principal). The audited
|
|
97
|
+
* fetch refuses a call made inside a request that has no principal (`@Public()` or refused).
|
|
98
|
+
*/
|
|
99
|
+
var request_principal_als_js_1 = require("./request-auth/request-principal-als.js");
|
|
100
|
+
Object.defineProperty(exports, "insideRequest", { enumerable: true, get: function () { return request_principal_als_js_1.insideRequest; } });
|
|
101
|
+
/**
|
|
102
|
+
* For `@astram/agent` (mint) and `@astram/identity` (check) only (agent-proposals plan D-9):
|
|
103
|
+
* ⛔ UNFORGEABLE agent provenance. Only the agent executor mints; identity's proposal submit
|
|
104
|
+
* refuses `origin: 'agent'` unless the provenance is the minted object (`forbidden`).
|
|
105
|
+
*/
|
|
106
|
+
var agent_provenance_js_1 = require("./agent/agent-provenance.js");
|
|
107
|
+
Object.defineProperty(exports, "AGENT_PROVENANCE_ID_MAX", { enumerable: true, get: function () { return agent_provenance_js_1.AGENT_PROVENANCE_ID_MAX; } });
|
|
108
|
+
Object.defineProperty(exports, "isMintedAgentProvenance", { enumerable: true, get: function () { return agent_provenance_js_1.isMintedAgentProvenance; } });
|
|
109
|
+
Object.defineProperty(exports, "mintAgentProvenance", { enumerable: true, get: function () { return agent_provenance_js_1.mintAgentProvenance; } });
|
|
94
110
|
/** For `@astram/agent` only (SPEC §5 `AgentModule` env): the runtime URL rule's loopback check. */
|
|
95
111
|
var loopback_host_js_1 = require("./config/loopback-host.js");
|
|
96
112
|
Object.defineProperty(exports, "isLoopbackHost", { enumerable: true, get: function () { return loopback_host_js_1.isLoopbackHost; } });
|
|
@@ -66,4 +66,107 @@ export interface AgentFileReader {
|
|
|
66
66
|
* token is the seam. Unbound without identity.
|
|
67
67
|
*/
|
|
68
68
|
export declare const SHIELD_AGENT_FILE_READER: unique symbol;
|
|
69
|
+
/** A proposal as submitted (SPEC §5 B): the kind's payload plus plain-text title and metadata. */
|
|
70
|
+
export interface ProposalDraftLike {
|
|
71
|
+
readonly kind: string;
|
|
72
|
+
readonly payload: unknown;
|
|
73
|
+
readonly title: string;
|
|
74
|
+
readonly rationale?: string;
|
|
75
|
+
readonly metadata?: unknown;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Who proposed (SPEC §5 B): set by the framework, never by a payload or a request body.
|
|
79
|
+
* `origin: 'agent'` provenance is minted only by the agent executor (`mintAgentProvenance`,
|
|
80
|
+
* `@astram/guard/internal`); app code that submits with an agent origin is refused (`forbidden`).
|
|
81
|
+
*/
|
|
82
|
+
export type ProposalProvenanceLike = {
|
|
83
|
+
readonly origin: 'user';
|
|
84
|
+
} | {
|
|
85
|
+
readonly origin: 'agent';
|
|
86
|
+
readonly taskId: string;
|
|
87
|
+
readonly callId: string;
|
|
88
|
+
};
|
|
89
|
+
/** What a submit returns (SPEC §5 E): counts only, never the payload. */
|
|
90
|
+
export interface SubmittedProposalLike {
|
|
91
|
+
/** The proposal's uuid (the agent turns it into a task handle; never sent to the runtime). */
|
|
92
|
+
readonly uuid: string;
|
|
93
|
+
readonly kind: string;
|
|
94
|
+
readonly title: string;
|
|
95
|
+
readonly items: number;
|
|
96
|
+
readonly refused: number;
|
|
97
|
+
readonly annotated: number;
|
|
98
|
+
readonly state: 'pending';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The submit port (SPEC §5 F): `submit` only. Bound by `@astram/identity` per request (the request's
|
|
102
|
+
* user, `decide()` on every call); `@astram/agent` injects it for a `propose` capability.
|
|
103
|
+
*/
|
|
104
|
+
export interface ProposalPort {
|
|
105
|
+
submit(draft: ProposalDraftLike, provenance: ProposalProvenanceLike): Promise<SubmittedProposalLike>;
|
|
106
|
+
}
|
|
107
|
+
/** The states the proposals reader may list (SPEC §5 I, §10). */
|
|
108
|
+
export type ProposalReaderState = 'pending' | 'approved' | 'rejected';
|
|
109
|
+
/** One reader query (SPEC §5 I): one kind; tenant and user come from the session only. */
|
|
110
|
+
export interface ProposalReaderQuery {
|
|
111
|
+
readonly kind: string;
|
|
112
|
+
readonly state: ProposalReaderState;
|
|
113
|
+
readonly page: number;
|
|
114
|
+
readonly pageSize: number;
|
|
115
|
+
}
|
|
116
|
+
/** One reader row (SPEC §5 I, §10): no payload, no items, no requester id or name. */
|
|
117
|
+
export interface ProposalSummaryLike {
|
|
118
|
+
/** The proposal's uuid: `@astram/agent` swaps it for a task handle before anything leaves. */
|
|
119
|
+
readonly uuid: string;
|
|
120
|
+
readonly kind: string;
|
|
121
|
+
readonly kindLabel: string;
|
|
122
|
+
readonly title: string;
|
|
123
|
+
readonly state: string;
|
|
124
|
+
readonly origin: 'user' | 'agent';
|
|
125
|
+
readonly requestedByMe: boolean;
|
|
126
|
+
readonly counts: {
|
|
127
|
+
readonly create: number;
|
|
128
|
+
readonly update: number;
|
|
129
|
+
};
|
|
130
|
+
readonly selected: number;
|
|
131
|
+
readonly createdAt: string;
|
|
132
|
+
readonly expiresAt: string;
|
|
133
|
+
readonly decidedAt?: string;
|
|
134
|
+
}
|
|
135
|
+
/** A reader page (SPEC §5 I): `total` is a COUNT over the same WHERE. */
|
|
136
|
+
export interface ProposalSummaryPage {
|
|
137
|
+
readonly rows: readonly ProposalSummaryLike[];
|
|
138
|
+
readonly total: number;
|
|
139
|
+
readonly page: number;
|
|
140
|
+
readonly pageSize: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The read-only proposals reader (SPEC §5 F, §5 I): `kinds()` (the bound kind ids, read at agent
|
|
144
|
+
* boot) and `list()` (the same `ProposalService.list` as `GET /identity/proposals`, as the
|
|
145
|
+
* request's user). No write, decision or apply method.
|
|
146
|
+
*/
|
|
147
|
+
export interface ProposalReader {
|
|
148
|
+
kinds(): readonly string[];
|
|
149
|
+
list(query: ProposalReaderQuery): Promise<ProposalSummaryPage>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* `ProposalPort` (SPEC §5 F), bound by `@astram/identity`'s `IdentityFeatureModule` in a framework
|
|
153
|
+
* module (request-scoped), injected by `@astram/agent`. Unbound without identity.
|
|
154
|
+
*/
|
|
155
|
+
export declare const SHIELD_PROPOSAL_PORT: unique symbol;
|
|
156
|
+
/**
|
|
157
|
+
* `ProposalReader` (SPEC §5 F, §5 I), bound by `@astram/identity` next to the port, read-only.
|
|
158
|
+
* Unbound without identity.
|
|
159
|
+
*/
|
|
160
|
+
export declare const SHIELD_PROPOSAL_READER: unique symbol;
|
|
161
|
+
/**
|
|
162
|
+
* The read-only evidence seam (plan D-6, SPEC §5 B): the call ids of one agent task, read for the
|
|
163
|
+
* REQUEST'S tenant AND user only (another tenant's or another user's task ⇒ `[]`). Exactly one
|
|
164
|
+
* method. Bound by `@astram/agent`'s `AgentModule` (request-scoped), injected optionally by
|
|
165
|
+
* identity's `ProposalService`; unbound ⇒ every `agent_action` evidence ref is dropped and counted.
|
|
166
|
+
*/
|
|
167
|
+
export interface AgentTaskCalls {
|
|
168
|
+
callIdsOf(taskId: string): Promise<readonly string[]>;
|
|
169
|
+
}
|
|
170
|
+
/** Token of {@link AgentTaskCalls} (plan D-6). */
|
|
171
|
+
export declare const SHIELD_AGENT_TASK_CALLS: unique symbol;
|
|
69
172
|
//# sourceMappingURL=shield-tokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shield-tokens.d.ts","sourceRoot":"","sources":["../../src/module/shield-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,iGAAiG;AACjG,MAAM,WAAW,eAAe;IAC9B,qGAAqG;IACrG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC7C;AAED;;;;;;;;GAQ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HIELD_AGENT_FILE_READER = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.SHIELD_RECORD_AUTHORIZATION = exports.SHIELD_DECISION_AUTHORITY = void 0;
|
|
10
|
+
exports.SHIELD_AGENT_TASK_CALLS = exports.SHIELD_PROPOSAL_READER = exports.SHIELD_PROPOSAL_PORT = exports.SHIELD_AGENT_FILE_READER = exports.SHIELD_FILE_INGEST = exports.SHIELD_OBJECT_STORE = exports.SHIELD_RECORD_AUTHORIZATION = exports.SHIELD_DECISION_AUTHORITY = void 0;
|
|
11
11
|
/**
|
|
12
12
|
* The Core decision authority (`@astram/core`'s `DecisionAuthority`) — the single
|
|
13
13
|
* ADR-0001 decision entry both the global enforcement guard and the engine's
|
|
@@ -54,3 +54,15 @@ exports.SHIELD_FILE_INGEST = Symbol('SHIELD_FILE_INGEST');
|
|
|
54
54
|
* token is the seam. Unbound without identity.
|
|
55
55
|
*/
|
|
56
56
|
exports.SHIELD_AGENT_FILE_READER = Symbol('SHIELD_AGENT_FILE_READER');
|
|
57
|
+
/**
|
|
58
|
+
* `ProposalPort` (SPEC §5 F), bound by `@astram/identity`'s `IdentityFeatureModule` in a framework
|
|
59
|
+
* module (request-scoped), injected by `@astram/agent`. Unbound without identity.
|
|
60
|
+
*/
|
|
61
|
+
exports.SHIELD_PROPOSAL_PORT = Symbol('SHIELD_PROPOSAL_PORT');
|
|
62
|
+
/**
|
|
63
|
+
* `ProposalReader` (SPEC §5 F, §5 I), bound by `@astram/identity` next to the port, read-only.
|
|
64
|
+
* Unbound without identity.
|
|
65
|
+
*/
|
|
66
|
+
exports.SHIELD_PROPOSAL_READER = Symbol('SHIELD_PROPOSAL_READER');
|
|
67
|
+
/** Token of {@link AgentTaskCalls} (plan D-6). */
|
|
68
|
+
exports.SHIELD_AGENT_TASK_CALLS = Symbol('SHIELD_AGENT_TASK_CALLS');
|
|
@@ -18,7 +18,7 @@ import { type AppConfig } from '../config/app-config.js';
|
|
|
18
18
|
import { SHIELD_DECISION_AUTHORITY, SHIELD_RECORD_AUTHORIZATION } from './shield-tokens.js';
|
|
19
19
|
import type { SignInMethod } from '../authentication/sign-in-with.js';
|
|
20
20
|
export { SHIELD_DECISION_AUTHORITY, SHIELD_RECORD_AUTHORIZATION };
|
|
21
|
-
import { type ShieldStorageOption } from '../storage/storage.providers.js';
|
|
21
|
+
import { type AppFileProfile, 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
24
|
/**
|
|
@@ -247,6 +247,20 @@ export interface ShieldModuleOptions {
|
|
|
247
247
|
* profile's cap; otherwise each keeps its default (xlsx/csv/docx 10 MiB, pdf 20 MiB).
|
|
248
248
|
*/
|
|
249
249
|
readonly fileProfiles?: readonly ShippedFileProfileName[];
|
|
250
|
+
/**
|
|
251
|
+
* DP1 (app-file-profiles SPEC §5 A–B): up to 16 consumer-owned upload profiles registered on
|
|
252
|
+
* `SHIELD_FILE_INGEST` next to `fileProfiles`, each `{ name, profile }` (core `FileProfile` with
|
|
253
|
+
* its own `magic`). Checked at registration: name `^[a-z][a-z0-9_]{0,31}$` and not shipped;
|
|
254
|
+
* content types plain lower-case `type/subtype` (stricter than the SPEC, plan D-2), not denied
|
|
255
|
+
* (`isDeniedAppContentType`: html, octet-stream, xml and any `+xml`, php, wasm, shell/script,
|
|
256
|
+
* javascript variants; wider than the SPEC), never a shipped profile's (registered or not) or
|
|
257
|
+
* another app profile's; extensions `^\.[a-z0-9]{1,10}$`, not shared. A bad entry fails the boot
|
|
258
|
+
* naming its index and rule. An explicit `OBJECT_STORAGE_MAX_BYTES` can only LOWER an app
|
|
259
|
+
* profile's `maxBytes`, never raise it (stricter than the SPEC; shipped profiles keep the replace
|
|
260
|
+
* rule). A ZIP-based profile's `magic`
|
|
261
|
+
* MUST call core `zipWithinLimits` first. App types never reach the file analyser (DP2).
|
|
262
|
+
*/
|
|
263
|
+
readonly appFileProfiles?: readonly AppFileProfile[];
|
|
250
264
|
/**
|
|
251
265
|
* G-027 step 2 (notification-store SPEC §5C): the kinds app code may post notices under, each
|
|
252
266
|
* `{ kind, category: 'announcement' | 'personal' }`. Kind pattern
|
|
@@ -373,6 +387,8 @@ export interface ShieldModuleAsyncOptions {
|
|
|
373
387
|
readonly storage?: ShieldStorageOption;
|
|
374
388
|
/** See {@link ShieldModuleOptions.fileProfiles}. STATIC here (registration-time, like `storage`). */
|
|
375
389
|
readonly fileProfiles?: readonly ShippedFileProfileName[];
|
|
390
|
+
/** See {@link ShieldModuleOptions.appFileProfiles}. STATIC here (registration-time). */
|
|
391
|
+
readonly appFileProfiles?: readonly AppFileProfile[];
|
|
376
392
|
/** See {@link ShieldModuleOptions.notificationKinds}. STATIC here (registration-time). */
|
|
377
393
|
readonly notificationKinds?: readonly NotificationKindRegistration[];
|
|
378
394
|
}
|
|
@@ -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,EACV,kBAAkB,EAClB,cAAc,EAEd,sBAAsB,EACvB,MAAM,cAAc,CAAC;AAQtB,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;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;IAC1F,QAAQ,CAAC,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"}
|
|
@@ -336,7 +336,7 @@ let ShieldModule = class ShieldModule {
|
|
|
336
336
|
},
|
|
337
337
|
frameworkSchemasProvider,
|
|
338
338
|
migrationLedgerRegistryProvider,
|
|
339
|
-
...(0, storage_providers_js_1.storageProviders)(options.storage, options.fileProfiles),
|
|
339
|
+
...(0, storage_providers_js_1.storageProviders)(options.storage, options.fileProfiles, options.appFileProfiles),
|
|
340
340
|
],
|
|
341
341
|
// Re-export the composed AuthModule app-wide ONLY when auth is opted in — its
|
|
342
342
|
// own `exports` (SHIELD_AUTHENTICATOR / SHIELD_SESSION_AUTHORITY) then become
|
|
@@ -468,7 +468,7 @@ let ShieldModule = class ShieldModule {
|
|
|
468
468
|
authorityProvider,
|
|
469
469
|
frameworkSchemasProvider,
|
|
470
470
|
migrationLedgerRegistryProvider,
|
|
471
|
-
...(0, storage_providers_js_1.storageProviders)(options.storage, options.fileProfiles),
|
|
471
|
+
...(0, storage_providers_js_1.storageProviders)(options.storage, options.fileProfiles, options.appFileProfiles),
|
|
472
472
|
],
|
|
473
473
|
exports: [
|
|
474
474
|
config_module_js_1.APP_CONFIG,
|
|
@@ -11,6 +11,8 @@ export declare const FRAMEWORK_KIND_PREFIX = "shield.";
|
|
|
11
11
|
/**
|
|
12
12
|
* The framework's own kinds. G-027 step 3: `shield.access_changed` (identity's
|
|
13
13
|
* `AccessChangeNotifier`, a personal notice listing the recipient's gained / lost capabilities).
|
|
14
|
+
* G-036 M3 (agent-proposals SPEC §5 B, §10): `shield.proposal_pending` (identity's
|
|
15
|
+
* `ProposalService`, posted to the holders of a kind's `review` key when a proposal is submitted).
|
|
14
16
|
*/
|
|
15
17
|
export declare const FRAMEWORK_NOTIFICATION_KINDS: readonly NotificationKindRegistration[];
|
|
16
18
|
export interface NotificationPostInput {
|
|
@@ -1 +1 @@
|
|
|
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;AAchD,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C
|
|
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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IAAI,EAAE,OAAO,CAAC,EACzB,KAAK,EAAE,wBAAwB;IAChD,yFAAyF;IACzF,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,GAAE,0BAA+B;IAkB1C,uDAAuD;IACvD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,oBAAoB,GAAG,oBAAoB;IAM7E,IAAI,CACR,KAAK,EAAE,qBAAqB,EAC5B,IAAI,GAAE,wBAA6B,GAClC,OAAO,CAAC,sBAAsB,CAAC;IA8ClC,sFAAsF;YACxE,gBAAgB;CAwB/B"}
|
|
@@ -57,6 +57,8 @@ exports.FRAMEWORK_KIND_PREFIX = 'shield.';
|
|
|
57
57
|
/**
|
|
58
58
|
* The framework's own kinds. G-027 step 3: `shield.access_changed` (identity's
|
|
59
59
|
* `AccessChangeNotifier`, a personal notice listing the recipient's gained / lost capabilities).
|
|
60
|
+
* G-036 M3 (agent-proposals SPEC §5 B, §10): `shield.proposal_pending` (identity's
|
|
61
|
+
* `ProposalService`, posted to the holders of a kind's `review` key when a proposal is submitted).
|
|
60
62
|
*/
|
|
61
63
|
exports.FRAMEWORK_NOTIFICATION_KINDS = [
|
|
62
64
|
{
|
|
@@ -65,6 +67,12 @@ exports.FRAMEWORK_NOTIFICATION_KINDS = [
|
|
|
65
67
|
label: 'Access change',
|
|
66
68
|
severity: 'info',
|
|
67
69
|
},
|
|
70
|
+
{
|
|
71
|
+
kind: `${exports.FRAMEWORK_KIND_PREFIX}proposal_pending`,
|
|
72
|
+
category: 'personal',
|
|
73
|
+
label: 'Proposal to review',
|
|
74
|
+
severity: 'info',
|
|
75
|
+
},
|
|
68
76
|
];
|
|
69
77
|
/** Length in characters (code points), as `VARCHAR(n)` in utf8mb4 counts them. */
|
|
70
78
|
function codePoints(s) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-request **request principal** (capability-outbound-audit SPEC v6 §5 G, "Request principal").
|
|
3
|
+
*
|
|
4
|
+
* Framework code that runs inside a request (for example `@astram/agent`'s audited fetch) needs the
|
|
5
|
+
* caller's tenant and principal id without a `req` object in hand. This file holds them in a
|
|
6
|
+
* MODULE-PRIVATE `AsyncLocalStorage`:
|
|
7
|
+
*
|
|
8
|
+
* - {@link requestPrincipalMiddleware} (applied by `EnforcementModule` on every route) opens the
|
|
9
|
+
* scope for the whole request with an EMPTY holder;
|
|
10
|
+
* - {@link writeRequestPrincipal} fills the holder ONCE, frozen. Its only caller is the global
|
|
11
|
+
* enforcement guard, after successful authentication and an allow decision, from the principal
|
|
12
|
+
* the guard resolved from the bearer token (never from the body, headers or query; core #7);
|
|
13
|
+
* - {@link currentRequestPrincipal} reads it. It is the only name the guard barrel exports;
|
|
14
|
+
* - {@link insideRequest} (read-only, `@astram/guard/internal` only) tells whether a holder exists.
|
|
15
|
+
*
|
|
16
|
+
* The ALS instance, the holder, the middleware and the writer are NOT exported from the package, so
|
|
17
|
+
* app code can neither enter the scope nor overwrite the value. A request that did not pass the
|
|
18
|
+
* middleware has no holder: the guard's write is a no-op there and reads stay `undefined`.
|
|
19
|
+
*
|
|
20
|
+
* Pure in-memory scoping: no DB or Redis read is added to the request path (Shield #12).
|
|
21
|
+
*/
|
|
22
|
+
/** The request principal: the caller's tenant and principal id, as resolved by the guard. */
|
|
23
|
+
export interface RequestPrincipal {
|
|
24
|
+
/** The principal's tenant (the active scope node the session or API key is bound to). */
|
|
25
|
+
readonly tenantId: string;
|
|
26
|
+
/** The principal id: a user or a service account. */
|
|
27
|
+
readonly userId: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The current request's principal, or `undefined` when there is none: outside a request (a
|
|
31
|
+
* scheduled job), on a `@Public()` route, for a request the guard refused, or for a request that did
|
|
32
|
+
* not pass the framework middleware.
|
|
33
|
+
*
|
|
34
|
+
* The value is frozen and read-only. `userId` is the principal id: a user or a service account.
|
|
35
|
+
*
|
|
36
|
+
* Async resources created inside a request (timers, promises, queue drains started lazily by a
|
|
37
|
+
* handler) keep that request's context. Start background work at boot (`onApplicationBootstrap`),
|
|
38
|
+
* never lazily from inside a request.
|
|
39
|
+
*/
|
|
40
|
+
export declare function currentRequestPrincipal(): Readonly<RequestPrincipal> | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* INTERNAL (`@astram/guard/internal` only, never the barrel): `true` while running inside a request
|
|
43
|
+
* that passed the framework middleware (a holder exists), whether or not the guard wrote a
|
|
44
|
+
* principal into it. Read-only: it lets framework code (`@astram/agent`'s audited fetch) tell a
|
|
45
|
+
* `@Public()` or refused request (`true`, no principal) from work outside any request, such as a
|
|
46
|
+
* scheduled job (`false`). Async resources created inside a request keep that request's context,
|
|
47
|
+
* so background work must start at boot (`onApplicationBootstrap`), never lazily from a request.
|
|
48
|
+
*/
|
|
49
|
+
export declare function insideRequest(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* INTERNAL (not exported from the barrel). Framework middleware: runs the rest of the request
|
|
52
|
+
* inside a fresh, empty holder. A new holder per request, so nothing carries over between requests
|
|
53
|
+
* on a kept-alive connection.
|
|
54
|
+
*/
|
|
55
|
+
export declare function requestPrincipalMiddleware(_req: unknown, _res: unknown, next: () => void): void;
|
|
56
|
+
/**
|
|
57
|
+
* INTERNAL (not exported from the barrel); the global enforcement guard is the only caller. Writes
|
|
58
|
+
* the request principal into the current request's holder, frozen, exactly once.
|
|
59
|
+
*
|
|
60
|
+
* Returns `false` (and writes nothing) when there is no holder (the request did not pass the
|
|
61
|
+
* middleware, or this runs outside a request), when the holder was already written (a second write
|
|
62
|
+
* is refused), or when either value is not a non-empty string.
|
|
63
|
+
*/
|
|
64
|
+
export declare function writeRequestPrincipal(tenantId: string, userId: string): boolean;
|
|
65
|
+
//# sourceMappingURL=request-principal-als.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-principal-als.d.ts","sourceRoot":"","sources":["../../src/request-auth/request-principal-als.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,IAAI,QAAQ,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAEhF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAG/F;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAO/E"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The per-request **request principal** (capability-outbound-audit SPEC v6 §5 G, "Request principal").
|
|
4
|
+
*
|
|
5
|
+
* Framework code that runs inside a request (for example `@astram/agent`'s audited fetch) needs the
|
|
6
|
+
* caller's tenant and principal id without a `req` object in hand. This file holds them in a
|
|
7
|
+
* MODULE-PRIVATE `AsyncLocalStorage`:
|
|
8
|
+
*
|
|
9
|
+
* - {@link requestPrincipalMiddleware} (applied by `EnforcementModule` on every route) opens the
|
|
10
|
+
* scope for the whole request with an EMPTY holder;
|
|
11
|
+
* - {@link writeRequestPrincipal} fills the holder ONCE, frozen. Its only caller is the global
|
|
12
|
+
* enforcement guard, after successful authentication and an allow decision, from the principal
|
|
13
|
+
* the guard resolved from the bearer token (never from the body, headers or query; core #7);
|
|
14
|
+
* - {@link currentRequestPrincipal} reads it. It is the only name the guard barrel exports;
|
|
15
|
+
* - {@link insideRequest} (read-only, `@astram/guard/internal` only) tells whether a holder exists.
|
|
16
|
+
*
|
|
17
|
+
* The ALS instance, the holder, the middleware and the writer are NOT exported from the package, so
|
|
18
|
+
* app code can neither enter the scope nor overwrite the value. A request that did not pass the
|
|
19
|
+
* middleware has no holder: the guard's write is a no-op there and reads stay `undefined`.
|
|
20
|
+
*
|
|
21
|
+
* Pure in-memory scoping: no DB or Redis read is added to the request path (Shield #12).
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.currentRequestPrincipal = currentRequestPrincipal;
|
|
25
|
+
exports.insideRequest = insideRequest;
|
|
26
|
+
exports.requestPrincipalMiddleware = requestPrincipalMiddleware;
|
|
27
|
+
exports.writeRequestPrincipal = writeRequestPrincipal;
|
|
28
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
29
|
+
/** Module-private: never exported from this file's package entry points. */
|
|
30
|
+
const REQUEST_PRINCIPAL_ALS = new node_async_hooks_1.AsyncLocalStorage();
|
|
31
|
+
/**
|
|
32
|
+
* The current request's principal, or `undefined` when there is none: outside a request (a
|
|
33
|
+
* scheduled job), on a `@Public()` route, for a request the guard refused, or for a request that did
|
|
34
|
+
* not pass the framework middleware.
|
|
35
|
+
*
|
|
36
|
+
* The value is frozen and read-only. `userId` is the principal id: a user or a service account.
|
|
37
|
+
*
|
|
38
|
+
* Async resources created inside a request (timers, promises, queue drains started lazily by a
|
|
39
|
+
* handler) keep that request's context. Start background work at boot (`onApplicationBootstrap`),
|
|
40
|
+
* never lazily from inside a request.
|
|
41
|
+
*/
|
|
42
|
+
function currentRequestPrincipal() {
|
|
43
|
+
return REQUEST_PRINCIPAL_ALS.getStore()?.principal;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* INTERNAL (`@astram/guard/internal` only, never the barrel): `true` while running inside a request
|
|
47
|
+
* that passed the framework middleware (a holder exists), whether or not the guard wrote a
|
|
48
|
+
* principal into it. Read-only: it lets framework code (`@astram/agent`'s audited fetch) tell a
|
|
49
|
+
* `@Public()` or refused request (`true`, no principal) from work outside any request, such as a
|
|
50
|
+
* scheduled job (`false`). Async resources created inside a request keep that request's context,
|
|
51
|
+
* so background work must start at boot (`onApplicationBootstrap`), never lazily from a request.
|
|
52
|
+
*/
|
|
53
|
+
function insideRequest() {
|
|
54
|
+
return REQUEST_PRINCIPAL_ALS.getStore() !== undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* INTERNAL (not exported from the barrel). Framework middleware: runs the rest of the request
|
|
58
|
+
* inside a fresh, empty holder. A new holder per request, so nothing carries over between requests
|
|
59
|
+
* on a kept-alive connection.
|
|
60
|
+
*/
|
|
61
|
+
function requestPrincipalMiddleware(_req, _res, next) {
|
|
62
|
+
const holder = { principal: undefined };
|
|
63
|
+
REQUEST_PRINCIPAL_ALS.run(holder, next);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* INTERNAL (not exported from the barrel); the global enforcement guard is the only caller. Writes
|
|
67
|
+
* the request principal into the current request's holder, frozen, exactly once.
|
|
68
|
+
*
|
|
69
|
+
* Returns `false` (and writes nothing) when there is no holder (the request did not pass the
|
|
70
|
+
* middleware, or this runs outside a request), when the holder was already written (a second write
|
|
71
|
+
* is refused), or when either value is not a non-empty string.
|
|
72
|
+
*/
|
|
73
|
+
function writeRequestPrincipal(tenantId, userId) {
|
|
74
|
+
const holder = REQUEST_PRINCIPAL_ALS.getStore();
|
|
75
|
+
if (holder === undefined || holder.principal !== undefined)
|
|
76
|
+
return false;
|
|
77
|
+
if (typeof tenantId !== 'string' || tenantId.length === 0)
|
|
78
|
+
return false;
|
|
79
|
+
if (typeof userId !== 'string' || userId.length === 0)
|
|
80
|
+
return false;
|
|
81
|
+
holder.principal = Object.freeze({ tenantId, userId });
|
|
82
|
+
return true;
|
|
83
|
+
}
|