geo-engine-node 2.0.0 → 3.0.0-rc.1
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/CHANGELOG.md +35 -0
- package/LICENSE +21 -0
- package/README.es.md +397 -0
- package/Readme.md +261 -100
- package/dist/chunk-425YTEGY.js +1231 -0
- package/dist/chunk-425YTEGY.js.map +1 -0
- package/dist/chunk-A6RGK4MA.cjs +1231 -0
- package/dist/chunk-A6RGK4MA.cjs.map +1 -0
- package/dist/errors-C5S_d0Ca.d.cts +473 -0
- package/dist/errors-C5S_d0Ca.d.ts +473 -0
- package/dist/identity.cjs +196 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.d.cts +10 -0
- package/dist/identity.d.ts +10 -0
- package/dist/identity.js +196 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.cjs +465 -455
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +275 -134
- package/dist/index.d.ts +275 -134
- package/dist/index.js +375 -310
- package/dist/index.js.map +1 -1
- package/package.json +38 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["chunk-A6RGK4MA.cjs","../src/errors.ts","../src/crypto.ts","../src/version.ts","../src/http.ts","../src/identity/errors.ts","../src/identity/runtime.ts","../src/identity/evaluate.ts"],"names":[],"mappings":"AAAA;ACaO,IAAM,eAAA,EAAN,MAAA,QAA6B,MAAM;AAAA,EACxC,WAAA,CAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,KAAA,EAAO,gBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF,CAAA;AAMO,IAAM,kBAAA,EAAN,MAAA,QAAgC,eAAe;AAAA,EACpD,WAAA,CAAY,QAAA,EAAU,6BAAA,EAA+B;AACnD,IAAA,KAAA,CAAM,OAAO,C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ACjB,QAAA;AACoB,MAAA;AAC0B,QAAA;AACvC,UAAA;AACR,QAAA;AAE0D,QAAA;AACvB,UAAA;AACoB,YAAA;AACnD,YAAA;AACQ,YAAA;AACQ,YAAA;AACjB,UAAA;AACH,QAAA;AAE8C,QAAA;AACnC,UAAA;AACT,UAAA;AACQ,UAAA;AACQ,UAAA;AACjB,QAAA;AAEiB,QAAA;AACV,UAAA;AACR,QAAA;AAEyD,QAAA;AACpC,QAAA;AACb,UAAA;AACR,QAAA;AAE0D,QAAA;AAC9C,QAAA;AACuB,UAAA;AACtB,YAAA;AACT,YAAA;AACQ,YAAA;AACQ,YAAA;AACjB,UAAA;AACH,QAAA;AACA,MAAA;AACsB,QAAA;AACkB,QAAA;AACM,UAAA;AAC9C,QAAA;AACF,MAAA;AACF,IAAA;AAEiC,IAAA;AAC6B,MAAA;AAC5D,MAAA;AACQ,MAAA;AACQ,MAAA;AACjB,IAAA;AACH,EAAA;AACF;APsdkE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"chunk-A6RGK4MA.cjs","sourcesContent":[null,"/**\n * Detailed error metadata returned by GeoEngine api-service.\n */\nexport interface SpatialErrorDetail {\n '@type'?: string;\n reason?: string;\n domain?: string;\n metadata?: Record<string, string>;\n}\n\n/**\n * Base error class for all GeoEngine SDK exceptions.\n */\nexport class GeoEngineError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'GeoEngineError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Error thrown when an operation is attempted on a closed client instance.\n * Equivalent to Go's ErrClientClosed.\n */\nexport class ClientClosedError extends GeoEngineError {\n constructor(message = 'geoengine: client is closed') {\n super(message);\n this.name = 'ClientClosedError';\n }\n}\n\n/**\n * Error thrown when a client-side parameter validation fails.\n */\nexport class ValidationError extends GeoEngineError {\n constructor(message: string) {\n super(message);\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Error thrown when device_id is missing or empty.\n * Equivalent to Go's ErrDeviceIDRequired.\n */\nexport class DeviceIDRequiredError extends ValidationError {\n constructor(message = 'geoengine: device_id is required') {\n super(message);\n this.name = 'DeviceIDRequiredError';\n }\n}\n\n/**\n * Error thrown when a geofence_id is missing or empty.\n * Equivalent to Go's ErrGeofenceIDRequired.\n */\nexport class GeofenceIDRequiredError extends ValidationError {\n constructor(message = 'geoengine: geofence_id is required') {\n super(message);\n this.name = 'GeofenceIDRequiredError';\n }\n}\n\n/**\n * Error thrown when latitude falls outside the valid range [-90, 90].\n * Equivalent to Go's ErrInvalidLatitude.\n */\nexport class InvalidLatitudeError extends ValidationError {\n constructor(message = 'geoengine: latitude must be between -90 and 90 degrees') {\n super(message);\n this.name = 'InvalidLatitudeError';\n }\n}\n\n/**\n * Error thrown when longitude falls outside the valid range [-180, 180].\n * Equivalent to Go's ErrInvalidLongitude.\n */\nexport class InvalidLongitudeError extends ValidationError {\n constructor(message = 'geoengine: longitude must be between -180 and 180 degrees') {\n super(message);\n this.name = 'InvalidLongitudeError';\n }\n}\n\n/**\n * Error thrown when coordinate polygon validation fails.\n * Equivalent to Go's ErrInvalidCoordinates.\n */\nexport class InvalidCoordinatesError extends ValidationError {\n constructor(message = 'geoengine: at least 3 coordinate pairs are required for a polygon') {\n super(message);\n this.name = 'InvalidCoordinatesError';\n }\n}\n\n/**\n * Represents an HTTP error returned by the GeoEngine REST or Management API.\n * Equivalent to Go's APIError.\n */\nexport class APIError extends GeoEngineError {\n readonly statusCode: number;\n\n constructor(statusCode: number, message: string) {\n super(`geoengine: API error (status ${statusCode}): ${message}`);\n this.name = 'APIError';\n this.statusCode = statusCode;\n }\n}\n\n/**\n * Represents a structured error returned by GeoEngine api-service.\n * Equivalent to Go's SpatialAPIError.\n */\nexport class SpatialAPIError extends APIError {\n readonly code: string;\n readonly statusText?: string;\n readonly details: SpatialErrorDetail[];\n\n constructor(\n statusCode: number,\n code: string,\n message: string,\n statusText?: string,\n details: SpatialErrorDetail[] = []\n ) {\n const formattedMessage = code\n ? `geoengine: spatial API error (status ${statusCode}, code ${code}): ${message}`\n : `geoengine: spatial API error (status ${statusCode}): ${message}`;\n super(statusCode, formattedMessage);\n this.name = 'SpatialAPIError';\n this.code = code;\n this.statusText = statusText;\n this.details = details;\n }\n\n /**\n * Returns true if the error indicates the geofence or resource was not found.\n */\n isNotFound(): boolean {\n return (\n this.statusCode === 204 ||\n this.statusCode === 404 ||\n this.code === 'NOT_FOUND'\n );\n }\n\n /**\n * Returns true if the error indicates quota limit was hit.\n */\n isQuotaExceeded(): boolean {\n return (\n this.statusCode === 402 ||\n this.code === 'QUOTA_EXCEEDED'\n );\n }\n\n /**\n * Returns true if authentication failed.\n */\n isUnauthorized(): boolean {\n return (\n this.statusCode === 401 ||\n this.code === 'UNAUTHORIZED' ||\n this.code === 'MISSING_API_KEY' ||\n this.code === 'MISSING_ORGANIZATION'\n );\n }\n\n /**\n * Returns true if access to the requested resource is forbidden.\n */\n isForbidden(): boolean {\n return (\n this.statusCode === 403 ||\n this.code === 'FORBIDDEN'\n );\n }\n}\n\n/**\n * Specific error thrown when a geofence is not found (204 or 404).\n * Equivalent to Go's ErrGeofenceNotFound.\n */\nexport class GeofenceNotFoundError extends SpatialAPIError {\n constructor(message = 'geofence not found', statusCode = 204, details: SpatialErrorDetail[] = []) {\n super(statusCode, 'NOT_FOUND', message, 'Not Found', details);\n this.name = 'GeofenceNotFoundError';\n }\n}\n\n/**\n * Specific error thrown when request quota limit is exceeded (HTTP 402 or 429).\n * Equivalent to Go's ErrQuotaExceeded.\n */\nexport class QuotaExceededError extends SpatialAPIError {\n constructor(message = 'request quota exceeded', statusCode = 402, details: SpatialErrorDetail[] = []) {\n super(statusCode, 'QUOTA_EXCEEDED', message, 'Payment Required', details);\n this.name = 'QuotaExceededError';\n }\n}\n\n/**\n * Specific error thrown when API authentication fails (HTTP 401).\n * Equivalent to Go's ErrUnauthorized.\n */\nexport class AuthenticationError extends SpatialAPIError {\n constructor(message = 'unauthorized API request', statusCode = 401, details: SpatialErrorDetail[] = []) {\n super(statusCode, 'UNAUTHORIZED', message, 'Unauthorized', details);\n this.name = 'AuthenticationError';\n }\n}\n\n/**\n * Specific error thrown when access is forbidden (HTTP 403).\n * Equivalent to Go's ErrForbidden.\n */\nexport class ForbiddenError extends SpatialAPIError {\n constructor(message = 'access forbidden', statusCode = 403, details: SpatialErrorDetail[] = []) {\n super(statusCode, 'FORBIDDEN', message, 'Forbidden', details);\n this.name = 'ForbiddenError';\n }\n}\n\n/**\n * Error thrown when a network request exceeds its deadline or timeout limit.\n */\nexport class TimeoutError extends GeoEngineError {\n constructor(timeoutMs: number) {\n super(`geoengine: request exceeded the timeout limit of ${timeoutMs}ms`);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Error thrown when a user ID is missing or empty.\n * Equivalent to Go's ErrUserIDRequired.\n */\nexport class UserIDRequiredError extends ValidationError {\n constructor(message = 'geoengine: user_id is required') {\n super(message);\n this.name = 'UserIDRequiredError';\n }\n}\n\n/**\n * Error thrown when a GeoIdentity rule ID is missing or empty.\n * Equivalent to Go's ErrRuleIDRequired.\n */\nexport class RuleIDRequiredError extends ValidationError {\n constructor(message = 'geoengine: rule_id is required') {\n super(message);\n this.name = 'RuleIDRequiredError';\n }\n}\n\n/**\n * Error thrown when a GeoIdentity rule name is missing or empty.\n * Equivalent to Go's ErrRuleNameRequired.\n */\nexport class RuleNameRequiredError extends ValidationError {\n constructor(message = 'geoengine: rule name is required') {\n super(message);\n this.name = 'RuleNameRequiredError';\n }\n}\n\n/**\n * Error thrown when an invitation email is missing or empty.\n * Equivalent to Go's ErrEmailRequired.\n */\nexport class EmailRequiredError extends ValidationError {\n constructor(message = 'geoengine: email is required') {\n super(message);\n this.name = 'EmailRequiredError';\n }\n}\n\n/**\n * Error thrown when a role is missing or empty.\n * Equivalent to Go's ErrRoleRequired.\n */\nexport class RoleRequiredError extends ValidationError {\n constructor(message = 'geoengine: role is required') {\n super(message);\n this.name = 'RoleRequiredError';\n }\n}\n\n/**\n * Structured error returned by the api-service Users and GeoIdentity endpoints.\n * Equivalent to Go's APIServiceError. Branch on the subclasses (for example\n * UserNotFoundError) or on `code`.\n */\nexport class APIServiceError extends APIError {\n /** Machine-readable reason, e.g. \"USER_NOT_FOUND\". Empty when the API sent none. */\n readonly code: string;\n /** Message returned by the API, without the SDK prefix. */\n readonly apiMessage: string;\n readonly details: SpatialErrorDetail[];\n\n constructor(\n statusCode: number,\n code: string,\n message: string,\n details: SpatialErrorDetail[] = []\n ) {\n super(statusCode, message);\n this.message = code\n ? `geoengine: api-service error (status ${statusCode}, code ${code}): ${message}`\n : `geoengine: api-service error (status ${statusCode}): ${message}`;\n this.name = 'APIServiceError';\n this.code = code;\n this.apiMessage = message;\n this.details = details;\n }\n}\n\n/**\n * The user does not exist in the organization (or its access was revoked).\n * Equivalent to Go's ErrUserNotFound.\n */\nexport class UserNotFoundError extends APIServiceError {\n constructor(message = 'user not found in organization', statusCode = 404, code = 'USER_NOT_FOUND', details: SpatialErrorDetail[] = []) {\n super(statusCode, code, message, details);\n this.name = 'UserNotFoundError';\n }\n}\n\n/**\n * The GeoIdentity rule does not exist.\n * Equivalent to Go's ErrRuleNotFound.\n */\nexport class RuleNotFoundError extends APIServiceError {\n constructor(message = 'geoidentity rule not found', statusCode = 404, code = 'RULE_NOT_FOUND', details: SpatialErrorDetail[] = []) {\n super(statusCode, code, message, details);\n this.name = 'RuleNotFoundError';\n }\n}\n\n/**\n * The invited email already belongs to the organization.\n * Equivalent to Go's ErrUserAlreadyExists.\n */\nexport class UserAlreadyExistsError extends APIServiceError {\n constructor(message = 'user already belongs to the organization', statusCode = 409, code = 'USER_ALREADY_EXISTS', details: SpatialErrorDetail[] = []) {\n super(statusCode, code, message, details);\n this.name = 'UserAlreadyExistsError';\n }\n}\n\n/**\n * A pending invitation already exists for the email.\n * Equivalent to Go's ErrInvitationPending.\n */\nexport class InvitationPendingError extends APIServiceError {\n constructor(message = 'a pending invitation already exists for this email', statusCode = 409, code = 'INVITATION_PENDING', details: SpatialErrorDetail[] = []) {\n super(statusCode, code, message, details);\n this.name = 'InvitationPendingError';\n }\n}\n\n/**\n * The operation would leave the organization without an admin.\n * Equivalent to Go's ErrLastAdmin.\n */\nexport class LastAdminError extends APIServiceError {\n constructor(message = 'organization must keep at least one admin', statusCode = 409, code = 'LAST_ADMIN', details: SpatialErrorDetail[] = []) {\n super(statusCode, code, message, details);\n this.name = 'LastAdminError';\n }\n}\n\n/**\n * The operation would leave a rule without assigned subjects.\n * Equivalent to Go's ErrLastSubject.\n */\nexport class LastSubjectError extends APIServiceError {\n constructor(message = 'rule must keep at least one assigned subject', statusCode = 409, code = 'LAST_SUBJECT', details: SpatialErrorDetail[] = []) {\n super(statusCode, code, message, details);\n this.name = 'LastSubjectError';\n }\n}\n","import { createHmac } from 'node:crypto';\n\n/**\n * Generates an HMAC-SHA256 signature from the API key and timestamp (in milliseconds).\n * Matches the Go SDK Client.generateHMACSignature implementation.\n *\n * @param key The API secret key used as the HMAC secret\n * @param timestamp Epoch timestamp in milliseconds\n * @returns 64-character lowercase hexadecimal hash\n */\nexport function generateHMACSignature(key: string, timestamp: number): string {\n if (!key) {\n return '';\n }\n return createHmac('sha256', key)\n .update(timestamp.toString())\n .digest('hex');\n}\n","declare const __SDK_VERSION__: string | undefined;\n\n/**\n * SDK version, injected from package.json at build time (tsup/vitest `define`).\n * Single source of truth: package.json.\n */\nexport const SDK_VERSION: string =\n typeof __SDK_VERSION__ === 'string' ? __SDK_VERSION__ : 'unknown';\n","import { generateHMACSignature } from './crypto.js';\nimport {\n APIError,\n APIServiceError,\n AuthenticationError,\n ForbiddenError,\n GeofenceNotFoundError,\n InvitationPendingError,\n LastAdminError,\n LastSubjectError,\n QuotaExceededError,\n RuleNotFoundError,\n SpatialAPIError,\n SpatialErrorDetail,\n TimeoutError,\n UserAlreadyExistsError,\n UserNotFoundError,\n ValidationError,\n} from './errors.js';\nimport type { GeoEngineOptions } from './models.js';\nimport { SDK_VERSION } from './version.js';\n\nexport const USER_AGENT = `GeoEngineNodeSDK/${SDK_VERSION}`;\n\nexport interface RequestOptions {\n method?: string;\n endpoint: string;\n body?: unknown;\n timeout?: number;\n isSpatial?: boolean;\n /**\n * Marks a Users / GeoIdentity call: the `{ success, data }` envelope is unwrapped,\n * errors are parsed into APIServiceError subclasses, and only GET requests are\n * retried automatically (writes such as invitations must not be sent twice).\n */\n isApiService?: boolean;\n}\n\n/**\n * Parses raw error responses into typed GeoEngine errors matching Go SDK parseSpatialError.\n */\nexport function parseHttpError(\n statusCode: number,\n bodyText: string,\n isSpatial = false\n): APIError {\n let parsedErrorContainer: {\n error?: {\n code?: number;\n message?: string;\n status?: string;\n details?: SpatialErrorDetail[];\n };\n message?: string;\n } | null = null;\n\n try {\n parsedErrorContainer = JSON.parse(bodyText);\n } catch {\n // Non-JSON response body\n }\n\n const container = parsedErrorContainer?.error;\n let code = container?.status ?? '';\n let message = container?.message ?? parsedErrorContainer?.message ?? bodyText.trim();\n const details = container?.details ?? [];\n\n if (container?.details && container.details.length > 0) {\n for (const detail of container.details) {\n if (detail.reason) {\n code = detail.reason;\n break;\n }\n }\n }\n\n if (!code) {\n switch (statusCode) {\n case 204:\n case 404:\n code = 'NOT_FOUND';\n break;\n case 402:\n code = 'QUOTA_EXCEEDED';\n break;\n case 401:\n code = 'UNAUTHORIZED';\n break;\n case 403:\n code = 'FORBIDDEN';\n break;\n default:\n code = '';\n }\n }\n\n if (!message) {\n message = `HTTP ${statusCode}`;\n }\n\n // Map to specific semantic subclasses\n if (statusCode === 204 || statusCode === 404 || code === 'NOT_FOUND') {\n return new GeofenceNotFoundError(message, statusCode, details);\n }\n if (statusCode === 402 || code === 'QUOTA_EXCEEDED') {\n return new QuotaExceededError(message, statusCode, details);\n }\n if (statusCode === 401 || code === 'UNAUTHORIZED' || code === 'MISSING_API_KEY' || code === 'MISSING_ORGANIZATION') {\n return new AuthenticationError(message, statusCode, details);\n }\n if (statusCode === 403 || code === 'FORBIDDEN') {\n return new ForbiddenError(message, statusCode, details);\n }\n\n if (isSpatial) {\n return new SpatialAPIError(statusCode, code, message, undefined, details);\n }\n\n return new APIError(statusCode, message);\n}\n\n/**\n * Parses an api-service error body (Users and GeoIdentity endpoints) into a typed error.\n * Equivalent to Go's parseAPIServiceError + APIServiceError.sentinel.\n */\nexport function parseApiServiceError(statusCode: number, bodyText: string): APIError {\n let parsed: {\n error?: { message?: string; status?: string; details?: SpatialErrorDetail[] };\n } | null = null;\n\n try {\n parsed = JSON.parse(bodyText);\n } catch {\n // Non-JSON response body\n }\n\n const container = parsed && typeof parsed === 'object' ? parsed.error : undefined;\n const details = Array.isArray(container?.details) ? container.details : [];\n let code = '';\n let message = '';\n\n if (container && typeof container === 'object') {\n code = container.status ?? '';\n message = container.message ?? '';\n const withReason = details.find(d => d?.reason);\n if (withReason?.reason) {\n code = withReason.reason;\n }\n } else {\n message = bodyText.trim();\n }\n\n if (!message) {\n message = `HTTP ${statusCode}`;\n }\n\n switch (code) {\n case 'USER_NOT_FOUND':\n case 'USER_REVOKED':\n return new UserNotFoundError(message, statusCode, code, details);\n case 'RULE_NOT_FOUND':\n return new RuleNotFoundError(message, statusCode, code, details);\n case 'USER_ALREADY_EXISTS':\n return new UserAlreadyExistsError(message, statusCode, code, details);\n case 'INVITATION_PENDING':\n return new InvitationPendingError(message, statusCode, code, details);\n case 'LAST_ADMIN':\n return new LastAdminError(message, statusCode, code, details);\n case 'LAST_SUBJECT':\n return new LastSubjectError(message, statusCode, code, details);\n case 'QUOTA_EXCEEDED':\n return new QuotaExceededError(message, statusCode, details);\n case 'MISSING_API_KEY':\n case 'MISSING_ORGANIZATION':\n return new AuthenticationError(message, statusCode, details);\n }\n\n switch (statusCode) {\n case 401:\n return new AuthenticationError(message, statusCode, details);\n case 403:\n return new ForbiddenError(message, statusCode, details);\n case 402:\n return new QuotaExceededError(message, statusCode, details);\n }\n\n return new APIServiceError(statusCode, code, message, details);\n}\n\nexport interface HttpClientConfig {\n jwtToken?: string;\n environment: string;\n managementUrl: string;\n ingestUrl: string;\n apiServiceUrl: string;\n timeout: number;\n identityTimeoutMs: number;\n maxRetries: number;\n batchSize: number;\n flushInterval: number;\n bufferSize: number;\n fetch: (...args: any[]) => Promise<any>;\n}\n\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);\n\n/**\n * Ensures a configured service URL is safe to send credentials to:\n * https, or http only for loopback hosts. Throws before any request is made.\n */\nexport function assertSecureServiceUrl(name: string, value: string): void {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n throw new ValidationError(`GeoEngine: ${name} no es una URL válida.`);\n }\n if (parsed.protocol === 'https:') {\n return;\n }\n if (parsed.protocol === 'http:' && LOOPBACK_HOSTS.has(parsed.hostname)) {\n return;\n }\n throw new ValidationError(\n `GeoEngine: ${name} debe usar https (http solo se permite para localhost, 127.0.0.1 o ::1).`\n );\n}\n\n/**\n * Robust HTTP client handling authentication headers, HMAC generation,\n * timeouts via AbortController, and exponential backoff retries.\n */\nexport class HttpClient {\n #apiKey: string;\n private readonly config: HttpClientConfig;\n\n constructor(options: GeoEngineOptions = {}) {\n const defaultManagement = 'https://management.geoengine.dev';\n const defaultIngest = 'https://ingest.geoengine.dev';\n const defaultApiService = 'https://api.geoengine.dev';\n\n this.#apiKey = options.apiKey ?? '';\n const resolvedUrls = {\n managementUrl: options.baseUrl ?? options.managementUrl ?? defaultManagement,\n ingestUrl: options.baseUrl ?? options.ingestUrl ?? defaultIngest,\n apiServiceUrl: options.baseUrl ?? options.apiServiceUrl ?? defaultApiService,\n };\n const urlLabels: Record<keyof typeof resolvedUrls, string> = {\n managementUrl: options.baseUrl !== undefined ? 'baseUrl' : 'managementUrl',\n ingestUrl: options.baseUrl !== undefined ? 'baseUrl' : 'ingestUrl',\n apiServiceUrl: options.baseUrl !== undefined ? 'baseUrl' : 'apiServiceUrl',\n };\n for (const key of Object.keys(resolvedUrls) as Array<keyof typeof resolvedUrls>) {\n assertSecureServiceUrl(urlLabels[key], resolvedUrls[key]);\n }\n this.config = {\n jwtToken: options.jwtToken,\n environment: options.environment ?? 'live',\n ...resolvedUrls,\n timeout: options.timeout ?? 10000,\n identityTimeoutMs: options.identityTimeoutMs ?? 500,\n maxRetries: options.maxRetries ?? 2,\n batchSize: options.batchSize ?? 100,\n flushInterval: options.flushInterval ?? 500,\n bufferSize: options.bufferSize ?? 5000,\n fetch: options.fetch ?? (globalThis as typeof globalThis & { fetch: HttpClientConfig['fetch'] }).fetch,\n };\n }\n\n /** Removes the API key and JWT from text that may be echoed into error messages. */\n #redact(text: string): string {\n let out = text;\n for (const secret of [this.#apiKey, this.config.jwtToken]) {\n if (secret && secret.trim() !== '') {\n out = out.split(secret).join('[REDACTED]');\n const trimmed = secret.trim();\n if (trimmed !== secret) {\n out = out.split(trimmed).join('[REDACTED]');\n }\n }\n }\n return out;\n }\n\n get options(): Readonly<HttpClientConfig> {\n return this.config;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n apiKey: '[REDACTED]',\n ...(this.config.jwtToken ? { jwtToken: '[REDACTED]' } : {}),\n environment: this.config.environment,\n managementUrl: this.config.managementUrl,\n ingestUrl: this.config.ingestUrl,\n apiServiceUrl: this.config.apiServiceUrl,\n timeout: this.config.timeout,\n identityTimeoutMs: this.config.identityTimeoutMs,\n maxRetries: this.config.maxRetries,\n batchSize: this.config.batchSize,\n flushInterval: this.config.flushInterval,\n bufferSize: this.config.bufferSize,\n };\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {\n return this.toJSON();\n }\n\n /**\n * Executes an HTTP request with timeout, authentication headers and exponential backoff retry.\n */\n async request<T>(opts: RequestOptions): Promise<T> {\n const method = opts.method ?? 'POST';\n const timeoutMs = opts.timeout ?? this.config.timeout;\n const maxRetries =\n opts.isApiService && method !== 'GET' ? 0 : this.config.maxRetries;\n\n let attempt = 0;\n while (true) {\n attempt++;\n const controller = new (globalThis as typeof globalThis & {\n AbortController: new () => { signal: unknown; abort: () => void };\n }).AbortController();\n const timeoutId = (globalThis as typeof globalThis & {\n setTimeout: (handler: () => void, timeout?: number) => unknown;\n }).setTimeout(() => controller.abort(), timeoutMs);\n\n const now = Date.now();\n const headers: Record<string, string> = {\n ...(opts.isApiService\n ? { Accept: 'application/json' }\n : { 'Content-Type': 'application/json' }),\n 'X-API-Key': this.#apiKey,\n 'X-Geo-Environment': this.config.environment,\n 'X-Request-Time': now.toString(),\n 'X-Signature': generateHMACSignature(this.#apiKey, now),\n 'User-Agent': USER_AGENT,\n };\n\n if (opts.isApiService && opts.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n }\n\n if (this.config.jwtToken) {\n headers['Authorization'] = `Bearer ${this.config.jwtToken}`;\n }\n\n try {\n const response = await this.config.fetch(opts.endpoint, {\n method,\n headers,\n body: opts.body !== undefined ? JSON.stringify(opts.body) : undefined,\n signal: controller.signal,\n // Never follow redirects: custom headers (X-API-Key, X-Signature) are not\n // stripped by fetch on cross-origin redirects.\n redirect: 'manual',\n });\n\n (globalThis as typeof globalThis & {\n clearTimeout: (timeoutId: unknown) => void;\n }).clearTimeout(timeoutId);\n\n // Handle 204 No Content\n if (response.status === 204) {\n if (opts.isSpatial) {\n throw new GeofenceNotFoundError('geofence not found', 204);\n }\n return null as T;\n }\n\n // Retry on 429 (rate limit) or 5xx server errors\n if ((response.status === 429 || response.status >= 500) && attempt <= maxRetries) {\n const delay = Math.min(100 * Math.pow(2, attempt) + Math.random() * 50, 2000);\n await new Promise<void>(resolve =>\n (globalThis as typeof globalThis & {\n setTimeout: (handler: () => void, timeout?: number) => unknown;\n }).setTimeout(() => resolve(), delay)\n );\n continue;\n }\n\n const responseText = this.#redact(await response.text());\n\n if (!response.ok) {\n throw opts.isApiService\n ? parseApiServiceError(response.status, responseText)\n : parseHttpError(response.status, responseText, opts.isSpatial);\n }\n\n if (!responseText || responseText.trim() === '') {\n return null as T;\n }\n\n const json = JSON.parse(responseText);\n\n // api-service responses are wrapped in { success: boolean, data: T }\n if ((opts.isSpatial || opts.isApiService) && typeof json === 'object' && json !== null && 'success' in json) {\n if (!json.success) {\n throw opts.isApiService\n ? parseApiServiceError(response.status, responseText)\n : parseHttpError(response.status, responseText, true);\n }\n return json.data as T;\n }\n\n return json as T;\n } catch (err: unknown) {\n (globalThis as typeof globalThis & {\n clearTimeout: (timeoutId: unknown) => void;\n }).clearTimeout(timeoutId);\n\n if (err instanceof Error && err.name === 'AbortError') {\n throw new TimeoutError(timeoutMs);\n }\n\n // If it's already an API error (from response handling), rethrow without retrying\n if (err instanceof APIError) {\n throw err;\n }\n\n // Network error (fetch failure): retry if attempts remain\n if (attempt <= maxRetries) {\n const delay = Math.min(100 * Math.pow(2, attempt) + Math.random() * 50, 2000);\n await new Promise<void>(resolve =>\n (globalThis as typeof globalThis & {\n setTimeout: (handler: () => void, timeout?: number) => unknown;\n }).setTimeout(() => resolve(), delay)\n );\n continue;\n }\n\n throw err;\n }\n }\n }\n}\n","import { GeoEngineError } from '../errors.js';\nimport type { IdentityIntegrationReason, IdentityTransientReason } from './types.js';\n\nconst TRANSIENT_BRAND = Symbol.for('geo-engine-node.IdentityTransientError');\nconst INTEGRATION_BRAND = Symbol.for('geo-engine-node.IdentityIntegrationError');\n\nexport interface IdentityErrorFields<R extends string> {\n message: string;\n status?: number;\n type?: string;\n title?: string;\n detail?: string;\n requestId?: string;\n reason: R;\n apiKeyToRedact?: string;\n}\n\nfunction redactSecret(value: string | undefined, secret?: string): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n let sanitized = value;\n if (secret) {\n sanitized = sanitized.split(secret).join('[REDACTED]');\n const trimmed = secret.trim();\n if (trimmed && trimmed !== secret) {\n sanitized = sanitized.split(trimmed).join('[REDACTED]');\n }\n }\n return sanitized;\n}\n\nfunction buildSafeErrorPayload(\n name: string,\n message: string,\n fields: {\n code?: string;\n status?: number;\n type?: string;\n title?: string;\n detail?: string;\n requestId?: string;\n reason: string;\n }\n): Record<string, unknown> {\n return {\n name,\n code: (fields as { code?: string }).code,\n message,\n status: fields.status,\n type: fields.type,\n title: fields.title,\n detail: fields.detail,\n requestId: fields.requestId,\n reason: fields.reason,\n };\n}\n\n/**\n * Transient evaluation error (network, timeout, 5xx, 429, or non-JSON 5xx).\n * `identityGuard` applies the configured `failOpen` policy for this error class.\n */\nexport class IdentityTransientError extends GeoEngineError {\n readonly status?: number;\n readonly type?: string;\n readonly title?: string;\n readonly detail?: string;\n readonly requestId?: string;\n readonly reason: IdentityTransientReason;\n /** Stable machine-readable code; the contract between ESM and CJS builds. */\n readonly code = 'IDENTITY_TRANSIENT' as const;\n\n readonly [TRANSIENT_BRAND] = true;\n\n static [Symbol.hasInstance](instance: unknown): boolean {\n return (\n typeof instance === 'object' &&\n instance !== null &&\n TRANSIENT_BRAND in instance\n );\n }\n\n constructor(fields: IdentityErrorFields<IdentityTransientReason>) {\n const safeMessage = redactSecret(fields.message, fields.apiKeyToRedact) ?? 'GeoIdentity transient error';\n super(safeMessage);\n this.name = 'IdentityTransientError';\n this.status = fields.status;\n this.type = redactSecret(fields.type, fields.apiKeyToRedact);\n this.title = redactSecret(fields.title, fields.apiKeyToRedact);\n this.detail = redactSecret(fields.detail, fields.apiKeyToRedact);\n this.requestId = redactSecret(fields.requestId, fields.apiKeyToRedact);\n this.reason = fields.reason;\n }\n\n toJSON(): Record<string, unknown> {\n return buildSafeErrorPayload(this.name, this.message, this);\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {\n return this.toJSON();\n }\n}\n\n/**\n * Integration or client configuration error (400, 401, 403, 404, 422, edge 403,\n * unexpected 200 payload, or invalid input). `identityGuard` NEVER applies `failOpen`.\n */\nexport class IdentityIntegrationError extends GeoEngineError {\n readonly status?: number;\n readonly type?: string;\n readonly title?: string;\n readonly detail?: string;\n readonly requestId?: string;\n readonly reason: IdentityIntegrationReason;\n /** Stable machine-readable code; the contract between ESM and CJS builds. */\n readonly code = 'IDENTITY_INTEGRATION' as const;\n\n readonly [INTEGRATION_BRAND] = true;\n\n static [Symbol.hasInstance](instance: unknown): boolean {\n return (\n typeof instance === 'object' &&\n instance !== null &&\n INTEGRATION_BRAND in instance\n );\n }\n\n constructor(fields: IdentityErrorFields<IdentityIntegrationReason>) {\n const safeMessage = redactSecret(fields.message, fields.apiKeyToRedact) ?? 'GeoIdentity integration error';\n super(safeMessage);\n this.name = 'IdentityIntegrationError';\n this.status = fields.status;\n this.type = redactSecret(fields.type, fields.apiKeyToRedact);\n this.title = redactSecret(fields.title, fields.apiKeyToRedact);\n this.detail = redactSecret(fields.detail, fields.apiKeyToRedact);\n this.requestId = redactSecret(fields.requestId, fields.apiKeyToRedact);\n this.reason = fields.reason;\n }\n\n toJSON(): Record<string, unknown> {\n return buildSafeErrorPayload(this.name, this.message, this);\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {\n return this.toJSON();\n }\n}\n\n/**\n * Type guard that identifies transient GeoIdentity errors across ESM/CJS entrypoints.\n */\nexport function isTransient(err: unknown): err is IdentityTransientError {\n return (\n typeof err === 'object' &&\n err !== null &&\n TRANSIENT_BRAND in err\n );\n}\n","import { GeoEngineError } from '../errors.js';\n\n/**\n * Ensures GeoIdentity /v1 evaluation APIs run only in server runtimes.\n * /v1 requires a secret API key in Authorization: Bearer and does not allow browser CORS requests.\n */\nexport function assertServerEnvironment(): void {\n if (typeof (globalThis as { window?: unknown }).window !== 'undefined') {\n throw new GeoEngineError(\n 'geoengine/identity: /v1 es solo de servidor y no puede usarse en un navegador porque la API key es secreta y /v1 no admite peticiones desde navegador (CORS).'\n );\n }\n}\n","import { randomUUID } from 'node:crypto';\nimport { ClientClosedError } from '../errors.js';\nimport { USER_AGENT } from '../http.js';\nimport { IdentityIntegrationError, IdentityTransientError } from './errors.js';\nimport { assertServerEnvironment } from './runtime.js';\nimport type {\n Challenge,\n EvaluateMeta,\n EvaluateOptions,\n EvaluateRequest,\n EvaluateResponse,\n IdentityIntegrationReason,\n RuleRef,\n ShadowMatch,\n} from './types.js';\n\nconst DEFAULT_IDENTITY_TIMEOUT_MS = 500;\nconst MIN_RETRY_BUDGET_MS = 10;\nconst RETRY_SAFETY_MARGIN_MS = 5;\n\nexport interface IdentityServiceConfig {\n getBaseUrl: () => string;\n getApiKey: () => string;\n getTimeoutMs: () => number;\n getFetch: () => (...args: any[]) => Promise<any>;\n isClosed: () => boolean;\n}\n\ninterface ParsedProblem {\n type?: string;\n title?: string;\n status?: number;\n detail?: string;\n request_id?: string;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0;\n}\n\nfunction parseProblemJson(contentType: string, rawBody: string): ParsedProblem | null {\n const mediaType = (contentType.split(';', 1)[0] ?? '').trim().toLowerCase();\n if (mediaType !== 'application/problem+json') {\n return null;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(rawBody);\n } catch {\n return null;\n }\n\n if (!isPlainObject(parsed)) {\n return null;\n }\n\n const result: ParsedProblem = {};\n if (typeof parsed.type === 'string') {\n result.type = parsed.type;\n }\n if (typeof parsed.title === 'string') {\n result.title = parsed.title;\n }\n if (typeof parsed.status === 'number' && Number.isInteger(parsed.status)) {\n result.status = parsed.status;\n }\n if (typeof parsed.detail === 'string') {\n result.detail = parsed.detail;\n }\n if (typeof parsed.request_id === 'string') {\n result.request_id = parsed.request_id;\n }\n return result;\n}\n\nfunction parseRuleRef(value: unknown): RuleRef | null {\n if (!isPlainObject(value)) {\n return null;\n }\n if (\n typeof value.id !== 'string' ||\n typeof value.name !== 'string' ||\n typeof value.priority !== 'number' ||\n !Number.isFinite(value.priority)\n ) {\n return null;\n }\n return {\n id: value.id,\n name: value.name,\n priority: value.priority,\n };\n}\n\nfunction parseShadowMatches(value: unknown): ShadowMatch[] | null {\n if (!Array.isArray(value)) {\n return null;\n }\n const matches: ShadowMatch[] = [];\n for (const entry of value) {\n if (!isPlainObject(entry)) {\n return null;\n }\n const rule = parseRuleRef(entry.rule);\n if (!rule || typeof entry.would_decide !== 'string') {\n return null;\n }\n const shadowMatch: ShadowMatch = {\n rule,\n would_decide: entry.would_decide,\n };\n if (entry.signals !== undefined) {\n if (!Array.isArray(entry.signals) || !entry.signals.every((s) => typeof s === 'string')) {\n return null;\n }\n shadowMatch.signals = [...entry.signals];\n }\n matches.push(shadowMatch);\n }\n return matches;\n}\n\nfunction parseEvaluateMeta(value: unknown): EvaluateMeta | null {\n if (!isPlainObject(value)) {\n return null;\n }\n if (\n typeof value.config_version !== 'number' ||\n !Number.isFinite(value.config_version) ||\n typeof value.stale !== 'boolean' ||\n typeof value.config_age_s !== 'number' ||\n !Number.isFinite(value.config_age_s) ||\n typeof value.source !== 'string' ||\n typeof value.evaluated_at !== 'string'\n ) {\n return null;\n }\n\n const meta: EvaluateMeta = {\n config_version: value.config_version,\n stale: value.stale,\n config_age_s: value.config_age_s,\n source: value.source,\n evaluated_at: value.evaluated_at,\n };\n\n if (typeof value.request_id === 'string') {\n meta.request_id = value.request_id;\n }\n if (typeof value.reputation === 'string') {\n meta.reputation = value.reputation;\n }\n\n return meta;\n}\n\nfunction parseEvaluateResponse(rawBody: string): EvaluateResponse | null {\n let parsed: unknown;\n try {\n parsed = JSON.parse(rawBody);\n } catch {\n return null;\n }\n\n if (!isPlainObject(parsed)) {\n return null;\n }\n\n if (typeof parsed.decision !== 'string' || parsed.decision.length === 0) {\n return null;\n }\n\n let matchedRule: RuleRef | null = null;\n if (parsed.matched_rule !== null) {\n matchedRule = parseRuleRef(parsed.matched_rule);\n if (!matchedRule) {\n return null;\n }\n }\n\n if (typeof parsed.default_applied !== 'boolean' || typeof parsed.reason !== 'string') {\n return null;\n }\n\n if (!Array.isArray(parsed.signals) || !parsed.signals.every((s) => typeof s === 'string')) {\n return null;\n }\n\n const shadowMatches = parseShadowMatches(parsed.shadow_matches);\n if (!shadowMatches) {\n return null;\n }\n\n const meta = parseEvaluateMeta(parsed.meta);\n if (!meta) {\n return null;\n }\n\n let challenge: Challenge | undefined;\n if (parsed.challenge !== undefined && parsed.challenge !== null) {\n if (!isPlainObject(parsed.challenge)) {\n return null;\n }\n challenge = {};\n if (typeof parsed.challenge.hint === 'string') {\n challenge.hint = parsed.challenge.hint;\n }\n }\n\n const result: EvaluateResponse = {\n decision: parsed.decision,\n matched_rule: matchedRule,\n default_applied: parsed.default_applied,\n reason: parsed.reason,\n signals: [...parsed.signals],\n shadow_matches: shadowMatches,\n meta,\n };\n\n if (challenge !== undefined) {\n result.challenge = challenge;\n }\n\n return result;\n}\n\nfunction buildRequestPayload(request: EvaluateRequest): Record<string, unknown> {\n const subjectPayload: Record<string, unknown> = {};\n if (request.subject.user_id !== undefined) {\n subjectPayload.user_id = request.subject.user_id;\n }\n if (request.subject.device_id !== undefined) {\n subjectPayload.device_id = request.subject.device_id;\n }\n if (request.subject.roles !== undefined) {\n subjectPayload.roles = request.subject.roles;\n }\n\n const payload: Record<string, unknown> = {\n scope: request.scope,\n subject: subjectPayload,\n };\n\n if (request.context !== undefined && request.context !== null) {\n const contextPayload: Record<string, unknown> = {};\n if (request.context.ip !== undefined) {\n contextPayload.ip = request.context.ip;\n }\n if (request.context.location !== undefined && request.context.location !== null) {\n const loc = request.context.location;\n const locationPayload: Record<string, unknown> = {\n lat: loc.lat,\n lng: loc.lng,\n };\n if (loc.accuracy_m !== undefined) {\n locationPayload.accuracy_m = loc.accuracy_m;\n }\n if (loc.source !== undefined) {\n locationPayload.source = loc.source;\n }\n if (loc.captured_at !== undefined) {\n locationPayload.captured_at = loc.captured_at;\n }\n contextPayload.location = locationPayload;\n }\n payload.context = contextPayload;\n }\n\n return payload;\n}\n\nfunction mapIntegrationReason(status: number, problemType?: string): IdentityIntegrationReason {\n if (problemType) {\n const prefix = 'urn:geoengine:problem:';\n const slug = problemType.startsWith(prefix) ? problemType.slice(prefix.length) : problemType;\n switch (slug) {\n case 'unauthorized':\n return 'unauthorized';\n case 'malformed-request':\n return 'malformed_request';\n case 'invalid-request':\n return 'invalid_request';\n case 'scope-not-found':\n return 'scope_not_found';\n default:\n break;\n }\n }\n\n switch (status) {\n case 400:\n return 'malformed_request';\n case 401:\n return 'unauthorized';\n case 403:\n return 'forbidden';\n case 404:\n return 'not_found';\n case 422:\n return 'invalid_request';\n default:\n return status >= 400 && status < 500 ? 'client_error' : 'unexpected_response';\n }\n}\n\nfunction parseRetryAfterMs(headerValue: string | null): number | null {\n if (headerValue === null) {\n return null;\n }\n const trimmed = headerValue.trim();\n if (trimmed === '') {\n return null;\n }\n\n if (/^\\d+$/.test(trimmed)) {\n const seconds = Number(trimmed);\n return Number.isFinite(seconds) ? seconds * 1000 : null;\n }\n\n const targetTime = Date.parse(trimmed);\n if (Number.isNaN(targetTime)) {\n return null;\n }\n\n return Math.max(0, targetTime - Date.now());\n}\n\nfunction computeJitterDelayMs(remainingMs: number): number | null {\n if (remainingMs <= MIN_RETRY_BUDGET_MS) {\n return null;\n }\n const rawJitter = 10 + Math.random() * 40;\n const maxAllowed = Math.max(0, Math.floor(remainingMs / 3));\n const delay = Math.min(rawJitter, maxAllowed);\n return remainingMs - delay >= MIN_RETRY_BUDGET_MS ? Math.floor(delay) : null;\n}\n\nfunction sleepAbortable(ms: number, signal?: AbortSignal): Promise<boolean> {\n if (signal?.aborted) {\n return Promise.resolve(false);\n }\n if (ms <= 0) {\n return Promise.resolve(true);\n }\n return new Promise<boolean>((resolve) => {\n const onAbort = () => {\n clearTimeout(timer);\n resolve(false);\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve(true);\n }, ms);\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n\nasync function readTextWithAbort(\n response: { text: () => Promise<string> },\n signal: AbortSignal\n): Promise<string> {\n if (signal.aborted) {\n const abortErr = new Error('The operation was aborted.');\n abortErr.name = 'AbortError';\n throw abortErr;\n }\n\n return new Promise<string>((resolve, reject) => {\n let settled = false;\n const onAbort = () => {\n if (settled) {\n return;\n }\n settled = true;\n const abortErr = new Error('The operation was aborted.');\n abortErr.name = 'AbortError';\n reject(abortErr);\n };\n\n signal.addEventListener('abort', onAbort, { once: true });\n\n Promise.resolve(response.text()).then(\n (text) => {\n if (settled) {\n return;\n }\n settled = true;\n signal.removeEventListener('abort', onAbort);\n resolve(text);\n },\n (err: unknown) => {\n if (settled) {\n return;\n }\n settled = true;\n signal.removeEventListener('abort', onAbort);\n reject(err);\n }\n );\n });\n}\n\n/**\n * Evaluates contextual access policies via `POST /v1/evaluate` (server-only).\n */\nexport class IdentityService {\n #getBaseUrl: () => string;\n #getApiKey: () => string;\n #getTimeoutMs: () => number;\n #getFetch: () => (...args: any[]) => Promise<any>;\n #isClosed: () => boolean;\n\n constructor(config: IdentityServiceConfig) {\n this.#getBaseUrl = config.getBaseUrl;\n this.#getApiKey = config.getApiKey;\n this.#getTimeoutMs = config.getTimeoutMs;\n this.#getFetch = config.getFetch;\n this.#isClosed = config.isClosed;\n }\n\n toJSON(): Record<string, unknown> {\n return {\n service: 'IdentityService',\n apiKey: '[REDACTED]',\n };\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): Record<string, unknown> {\n return this.toJSON();\n }\n\n /**\n * Calls `POST /v1/evaluate` with Bearer authentication, X-Request-Id tracking,\n * a total deadline (default 500ms), and at most one retry for transient failures.\n * Never applies `failOpen` directly; throws typed transient or integration errors.\n */\n async evaluate(request: EvaluateRequest, options?: EvaluateOptions): Promise<EvaluateResponse> {\n assertServerEnvironment();\n\n if (this.#isClosed()) {\n throw new ClientClosedError();\n }\n\n const apiKey = this.#getApiKey();\n\n if (!isPlainObject(request) || !isNonEmptyString(request.scope)) {\n throw new IdentityIntegrationError({\n message: 'GeoIdentity: scope es requerido y debe ser una cadena no vacía',\n reason: 'invalid_request',\n apiKeyToRedact: apiKey,\n });\n }\n\n if (\n !isPlainObject(request.subject) ||\n (!isNonEmptyString(request.subject.user_id) && !isNonEmptyString(request.subject.device_id))\n ) {\n throw new IdentityIntegrationError({\n message: 'GeoIdentity: subject requiere al menos user_id o device_id',\n reason: 'invalid_request',\n apiKeyToRedact: apiKey,\n });\n }\n\n const timeoutMs = options?.timeoutMs ?? this.#getTimeoutMs() ?? DEFAULT_IDENTITY_TIMEOUT_MS;\n if (typeof timeoutMs !== 'number' || !Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new IdentityIntegrationError({\n message: 'GeoIdentity: timeoutMs debe ser un número finito mayor a 0',\n reason: 'configuration_error',\n apiKeyToRedact: apiKey,\n });\n }\n\n if (options?.requestId !== undefined && typeof options.requestId !== 'string') {\n throw new IdentityIntegrationError({\n message: 'GeoIdentity: requestId debe ser una cadena de texto',\n reason: 'invalid_request',\n apiKeyToRedact: apiKey,\n });\n }\n\n const requestId = options?.requestId ?? randomUUID();\n const endpoint = `${this.#getBaseUrl().replace(/\\/+$/, '')}/v1/evaluate`;\n const bodyJson = JSON.stringify(buildRequestPayload(request));\n const fetchFn = this.#getFetch();\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n Accept: 'application/json, application/problem+json',\n 'X-Request-Id': requestId,\n 'User-Agent': USER_AGENT,\n };\n\n const deadline = Date.now() + timeoutMs;\n\n for (let attempt = 1; attempt <= 2; attempt++) {\n if (options?.signal?.aborted) {\n throw new IdentityTransientError({\n message: 'GeoIdentity: evaluación cancelada por AbortSignal',\n requestId,\n reason: 'timeout',\n apiKeyToRedact: apiKey,\n });\n }\n\n const remainingMs = deadline - Date.now();\n if (remainingMs <= 0) {\n throw new IdentityTransientError({\n message: `GeoIdentity: tiempo de espera agotado (${timeoutMs}ms)`,\n requestId,\n reason: 'timeout',\n apiKeyToRedact: apiKey,\n });\n }\n\n const controller = new AbortController();\n let onExternalAbort: (() => void) | undefined;\n if (options?.signal) {\n onExternalAbort = () => controller.abort();\n options.signal.addEventListener('abort', onExternalAbort, { once: true });\n }\n\n const timeoutId = setTimeout(() => controller.abort(), remainingMs);\n\n try {\n const response = await fetchFn(endpoint, {\n method: 'POST',\n headers,\n body: bodyJson,\n signal: controller.signal,\n redirect: 'manual',\n });\n\n const rawBody = await readTextWithAbort(response, controller.signal);\n\n const contentType = response.headers?.get('content-type') ?? '';\n const echoedRequestId = response.headers?.get('x-request-id') || undefined;\n const problem = parseProblemJson(contentType, rawBody);\n const effectiveRequestId = problem?.request_id || echoedRequestId || requestId;\n\n if (response.status === 200) {\n const parsed = parseEvaluateResponse(rawBody);\n if (!parsed) {\n throw new IdentityIntegrationError({\n message: 'GeoIdentity: forma de respuesta inesperada en HTTP 200',\n status: 200,\n requestId: echoedRequestId ?? requestId,\n reason: 'unexpected_response',\n apiKeyToRedact: apiKey,\n });\n }\n return parsed;\n }\n\n if (response.status === 429) {\n const retryAfterHeader = response.headers?.get('retry-after') ?? null;\n const rateLimitErr = new IdentityTransientError({\n message:\n problem?.detail ||\n problem?.title ||\n 'GeoIdentity: límite de peticiones excedido (HTTP 429)',\n status: 429,\n type: problem?.type,\n title: problem?.title,\n detail: problem?.detail,\n requestId: effectiveRequestId,\n reason: 'rate_limited',\n apiKeyToRedact: apiKey,\n });\n\n if (attempt >= 2) {\n throw rateLimitErr;\n }\n\n const nowRemaining = deadline - Date.now();\n let waitMs: number | null;\n if (retryAfterHeader !== null && retryAfterHeader.trim() !== '') {\n const parsedRetryAfter = parseRetryAfterMs(retryAfterHeader);\n if (\n parsedRetryAfter === null ||\n parsedRetryAfter + RETRY_SAFETY_MARGIN_MS >= nowRemaining\n ) {\n throw rateLimitErr;\n }\n waitMs = parsedRetryAfter;\n } else {\n waitMs = computeJitterDelayMs(nowRemaining);\n if (waitMs === null) {\n throw rateLimitErr;\n }\n }\n\n const slept = await sleepAbortable(waitMs, options?.signal);\n if (!slept) {\n throw new IdentityTransientError({\n message: 'GeoIdentity: evaluación cancelada durante espera de reintento',\n requestId: effectiveRequestId,\n reason: 'timeout',\n apiKeyToRedact: apiKey,\n });\n }\n continue;\n }\n\n if (response.status >= 500) {\n const serverErr = new IdentityTransientError({\n message:\n problem?.detail ||\n problem?.title ||\n `GeoIdentity: error transitorio del servidor (HTTP ${response.status})`,\n status: response.status,\n type: problem?.type,\n title: problem?.title,\n detail: problem?.detail,\n requestId: effectiveRequestId,\n reason: 'server_error',\n apiKeyToRedact: apiKey,\n });\n\n if (attempt >= 2) {\n throw serverErr;\n }\n\n const waitMs = computeJitterDelayMs(deadline - Date.now());\n if (waitMs === null) {\n throw serverErr;\n }\n\n const slept = await sleepAbortable(waitMs, options?.signal);\n if (!slept) {\n throw new IdentityTransientError({\n message: 'GeoIdentity: evaluación cancelada durante espera de reintento',\n requestId: effectiveRequestId,\n reason: 'timeout',\n apiKeyToRedact: apiKey,\n });\n }\n continue;\n }\n\n if (response.status === 403 && !problem) {\n throw new IdentityIntegrationError({\n message: 'GeoIdentity: bloqueado en el borde (HTTP 403)',\n status: 403,\n requestId: echoedRequestId ?? requestId,\n reason: 'edge_forbidden',\n apiKeyToRedact: apiKey,\n });\n }\n\n throw new IdentityIntegrationError({\n message:\n problem?.detail ||\n problem?.title ||\n `GeoIdentity: error de integración (HTTP ${response.status})`,\n status: response.status,\n type: problem?.type,\n title: problem?.title,\n detail: problem?.detail,\n requestId: effectiveRequestId,\n reason: mapIntegrationReason(response.status, problem?.type),\n apiKeyToRedact: apiKey,\n });\n } catch (err: unknown) {\n if (err instanceof IdentityIntegrationError || err instanceof IdentityTransientError) {\n throw err;\n }\n\n if (controller.signal.aborted || (err instanceof Error && err.name === 'AbortError')) {\n throw new IdentityTransientError({\n message: `GeoIdentity: tiempo de espera agotado (${timeoutMs}ms)`,\n requestId,\n reason: 'timeout',\n apiKeyToRedact: apiKey,\n });\n }\n\n const networkErr = new IdentityTransientError({\n message: 'GeoIdentity: error de red al evaluar la identidad',\n requestId,\n reason: 'network',\n apiKeyToRedact: apiKey,\n });\n\n if (attempt >= 2) {\n throw networkErr;\n }\n\n const waitMs = computeJitterDelayMs(deadline - Date.now());\n if (waitMs === null) {\n throw networkErr;\n }\n\n const slept = await sleepAbortable(waitMs, options?.signal);\n if (!slept) {\n throw new IdentityTransientError({\n message: 'GeoIdentity: evaluación cancelada durante espera de reintento',\n requestId,\n reason: 'timeout',\n apiKeyToRedact: apiKey,\n });\n }\n } finally {\n clearTimeout(timeoutId);\n if (options?.signal && onExternalAbort) {\n options.signal.removeEventListener('abort', onExternalAbort);\n }\n }\n }\n\n throw new IdentityTransientError({\n message: `GeoIdentity: tiempo de espera agotado (${timeoutMs}ms)`,\n requestId,\n reason: 'timeout',\n apiKeyToRedact: apiKey,\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source used to capture the device location signal.
|
|
3
|
+
*/
|
|
4
|
+
type LocationSource = 'device' | 'ip' | 'wifi' | 'cell' | 'manual' | (string & {});
|
|
5
|
+
/**
|
|
6
|
+
* Geographic location signal sent in the evaluation context.
|
|
7
|
+
*/
|
|
8
|
+
interface IdentityLocation {
|
|
9
|
+
lat: number;
|
|
10
|
+
lng: number;
|
|
11
|
+
accuracy_m?: number;
|
|
12
|
+
source?: LocationSource;
|
|
13
|
+
captured_at?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Request context signals evaluated against the scope rules.
|
|
17
|
+
*/
|
|
18
|
+
interface IdentityContext {
|
|
19
|
+
ip?: string;
|
|
20
|
+
location?: IdentityLocation;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Subject attempting access. All identifiers are opaque client-defined strings.
|
|
24
|
+
* At least one of `user_id` or `device_id` is required.
|
|
25
|
+
*/
|
|
26
|
+
type IdentitySubject = {
|
|
27
|
+
user_id: string;
|
|
28
|
+
device_id?: string;
|
|
29
|
+
roles?: string[];
|
|
30
|
+
} | {
|
|
31
|
+
user_id?: string;
|
|
32
|
+
device_id: string;
|
|
33
|
+
roles?: string[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Request body for POST /v1/evaluate.
|
|
37
|
+
*/
|
|
38
|
+
interface EvaluateRequest {
|
|
39
|
+
scope: string;
|
|
40
|
+
subject: IdentitySubject;
|
|
41
|
+
context?: IdentityContext;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Per-call options for `client.identity.evaluate`.
|
|
45
|
+
*/
|
|
46
|
+
interface EvaluateOptions {
|
|
47
|
+
/** Total deadline in milliseconds for this evaluation, including any retry. Default: 500ms. */
|
|
48
|
+
timeoutMs?: number;
|
|
49
|
+
/** Optional correlation ID sent as X-Request-Id (max 128 chars, no control chars). */
|
|
50
|
+
requestId?: string;
|
|
51
|
+
/** Optional external AbortSignal to cancel the evaluation. */
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
}
|
|
54
|
+
type KnownDecision = 'ALLOW' | 'BLOCK' | 'CHALLENGE';
|
|
55
|
+
type Decision = KnownDecision | (string & {});
|
|
56
|
+
type EvaluateReason = 'RULE_MATCH' | 'DEFAULT_ACTION' | (string & {});
|
|
57
|
+
type KnownSignal = 'outside_geo_limit' | 'location_missing' | 'ip_blocklist' | 'ip_not_allowlist' | 'datacenter_ip' | 'tor_exit';
|
|
58
|
+
/**
|
|
59
|
+
* Open set of signals returned by /v1/evaluate.
|
|
60
|
+
*/
|
|
61
|
+
type EvaluateSignal = KnownSignal | (string & {});
|
|
62
|
+
interface RuleRef {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
priority: number;
|
|
66
|
+
}
|
|
67
|
+
interface ShadowMatch {
|
|
68
|
+
rule: RuleRef;
|
|
69
|
+
would_decide: Decision;
|
|
70
|
+
signals?: EvaluateSignal[];
|
|
71
|
+
}
|
|
72
|
+
interface Challenge {
|
|
73
|
+
hint?: 'step_up' | (string & {});
|
|
74
|
+
}
|
|
75
|
+
type MetaSource = 'postgres' | 'redis' | 'memory' | 'snapshot' | 'fallback' | 'sdk_fallback' | (string & {});
|
|
76
|
+
type ReputationStatus = 'not_needed' | 'ok' | 'unavailable' | (string & {});
|
|
77
|
+
interface EvaluateMeta {
|
|
78
|
+
config_version: number;
|
|
79
|
+
stale: boolean;
|
|
80
|
+
config_age_s: number;
|
|
81
|
+
source: MetaSource;
|
|
82
|
+
evaluated_at: string;
|
|
83
|
+
request_id?: string;
|
|
84
|
+
reputation?: ReputationStatus;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Response from POST /v1/evaluate.
|
|
88
|
+
*/
|
|
89
|
+
interface EvaluateResponse {
|
|
90
|
+
decision: Decision;
|
|
91
|
+
matched_rule: RuleRef | null;
|
|
92
|
+
default_applied: boolean;
|
|
93
|
+
reason: EvaluateReason;
|
|
94
|
+
signals: EvaluateSignal[];
|
|
95
|
+
shadow_matches: ShadowMatch[];
|
|
96
|
+
challenge?: Challenge;
|
|
97
|
+
meta: EvaluateMeta;
|
|
98
|
+
}
|
|
99
|
+
type IdentityTransientReason = 'timeout' | 'network' | 'server_error' | 'rate_limited';
|
|
100
|
+
type FallbackReason = IdentityTransientReason | 'unknown_decision';
|
|
101
|
+
type IdentityIntegrationReason = 'invalid_request' | 'malformed_request' | 'unauthorized' | 'edge_forbidden' | 'forbidden' | 'not_found' | 'scope_not_found' | 'client_error' | 'unexpected_response' | 'configuration_error';
|
|
102
|
+
/**
|
|
103
|
+
* Synthetic decision produced locally by `identityGuard` when a transient failure
|
|
104
|
+
* or unknown decision triggers the `failOpen` fallback policy.
|
|
105
|
+
*/
|
|
106
|
+
interface FallbackDecision {
|
|
107
|
+
decision: 'ALLOW' | 'BLOCK';
|
|
108
|
+
matched_rule: null;
|
|
109
|
+
default_applied: false;
|
|
110
|
+
reason: 'SDK_FALLBACK';
|
|
111
|
+
signals: EvaluateSignal[];
|
|
112
|
+
shadow_matches: ShadowMatch[];
|
|
113
|
+
fallback: true;
|
|
114
|
+
fallback_reason: FallbackReason;
|
|
115
|
+
meta: EvaluateMeta & {
|
|
116
|
+
source: 'sdk_fallback';
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
type IdentityDecision = EvaluateResponse | FallbackDecision;
|
|
120
|
+
interface GuardRequest {
|
|
121
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
122
|
+
ip?: string;
|
|
123
|
+
socket?: {
|
|
124
|
+
remoteAddress?: string;
|
|
125
|
+
};
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
}
|
|
128
|
+
interface GuardResponse {
|
|
129
|
+
headersSent?: boolean;
|
|
130
|
+
writableEnded?: boolean;
|
|
131
|
+
statusCode: number;
|
|
132
|
+
status?: (code: number) => {
|
|
133
|
+
json?: (body: unknown) => unknown;
|
|
134
|
+
end?: (chunk?: string) => unknown;
|
|
135
|
+
};
|
|
136
|
+
json?: (body: unknown) => unknown;
|
|
137
|
+
setHeader?: (name: string, value: string) => unknown;
|
|
138
|
+
end?: (chunk?: string) => unknown;
|
|
139
|
+
[key: string]: unknown;
|
|
140
|
+
}
|
|
141
|
+
type NextFunction = (err?: unknown) => void;
|
|
142
|
+
type IdentityGuardClient = {
|
|
143
|
+
identity: {
|
|
144
|
+
evaluate(request: EvaluateRequest, options?: EvaluateOptions): Promise<EvaluateResponse>;
|
|
145
|
+
};
|
|
146
|
+
} | {
|
|
147
|
+
evaluate(request: EvaluateRequest, options?: EvaluateOptions): Promise<EvaluateResponse>;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Configuration options for `identityGuard`.
|
|
151
|
+
* `failOpen` is mandatory and has no default value.
|
|
152
|
+
*/
|
|
153
|
+
interface IdentityGuardOptions<Req extends GuardRequest = GuardRequest, Res extends GuardResponse = GuardResponse> {
|
|
154
|
+
client: IdentityGuardClient;
|
|
155
|
+
scope: string;
|
|
156
|
+
getSubject: (req: Req) => IdentitySubject | Promise<IdentitySubject>;
|
|
157
|
+
/**
|
|
158
|
+
* Provides request context (`ip`, `location`). If the scope has geographic rules and
|
|
159
|
+
* `location` is omitted, the engine returns HTTP 200 with signal `location_missing`
|
|
160
|
+
* (which may result in BLOCK depending on the rule).
|
|
161
|
+
*/
|
|
162
|
+
getContext?: (req: Req) => IdentityContext | undefined | Promise<IdentityContext | undefined>;
|
|
163
|
+
/**
|
|
164
|
+
* Mandatory local fallback policy on transient errors or unknown decisions.
|
|
165
|
+
* `true` allows access on transient failure; `false` blocks (HTTP 403).
|
|
166
|
+
* Integration errors NEVER apply `failOpen`.
|
|
167
|
+
*/
|
|
168
|
+
failOpen: boolean;
|
|
169
|
+
timeoutMs?: number;
|
|
170
|
+
onChallenge?: (decision: EvaluateResponse, req: Req, res: Res, next: NextFunction) => void | Promise<void>;
|
|
171
|
+
onBlock?: (decision: IdentityDecision, req: Req, res: Res, next: NextFunction) => void | Promise<void>;
|
|
172
|
+
onDecision?: (decision: IdentityDecision, req: Req) => void | Promise<void>;
|
|
173
|
+
onIntegrationError?: (error: unknown, req: Req, res: Res, next: NextFunction) => void | Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface IdentityServiceConfig {
|
|
177
|
+
getBaseUrl: () => string;
|
|
178
|
+
getApiKey: () => string;
|
|
179
|
+
getTimeoutMs: () => number;
|
|
180
|
+
getFetch: () => (...args: any[]) => Promise<any>;
|
|
181
|
+
isClosed: () => boolean;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Evaluates contextual access policies via `POST /v1/evaluate` (server-only).
|
|
185
|
+
*/
|
|
186
|
+
declare class IdentityService {
|
|
187
|
+
#private;
|
|
188
|
+
constructor(config: IdentityServiceConfig);
|
|
189
|
+
toJSON(): Record<string, unknown>;
|
|
190
|
+
/**
|
|
191
|
+
* Calls `POST /v1/evaluate` with Bearer authentication, X-Request-Id tracking,
|
|
192
|
+
* a total deadline (default 500ms), and at most one retry for transient failures.
|
|
193
|
+
* Never applies `failOpen` directly; throws typed transient or integration errors.
|
|
194
|
+
*/
|
|
195
|
+
evaluate(request: EvaluateRequest, options?: EvaluateOptions): Promise<EvaluateResponse>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Detailed error metadata returned by GeoEngine api-service.
|
|
200
|
+
*/
|
|
201
|
+
interface SpatialErrorDetail {
|
|
202
|
+
'@type'?: string;
|
|
203
|
+
reason?: string;
|
|
204
|
+
domain?: string;
|
|
205
|
+
metadata?: Record<string, string>;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Base error class for all GeoEngine SDK exceptions.
|
|
209
|
+
*/
|
|
210
|
+
declare class GeoEngineError extends Error {
|
|
211
|
+
constructor(message: string);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Error thrown when an operation is attempted on a closed client instance.
|
|
215
|
+
* Equivalent to Go's ErrClientClosed.
|
|
216
|
+
*/
|
|
217
|
+
declare class ClientClosedError extends GeoEngineError {
|
|
218
|
+
constructor(message?: string);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Error thrown when a client-side parameter validation fails.
|
|
222
|
+
*/
|
|
223
|
+
declare class ValidationError extends GeoEngineError {
|
|
224
|
+
constructor(message: string);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Error thrown when device_id is missing or empty.
|
|
228
|
+
* Equivalent to Go's ErrDeviceIDRequired.
|
|
229
|
+
*/
|
|
230
|
+
declare class DeviceIDRequiredError extends ValidationError {
|
|
231
|
+
constructor(message?: string);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Error thrown when a geofence_id is missing or empty.
|
|
235
|
+
* Equivalent to Go's ErrGeofenceIDRequired.
|
|
236
|
+
*/
|
|
237
|
+
declare class GeofenceIDRequiredError extends ValidationError {
|
|
238
|
+
constructor(message?: string);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Error thrown when latitude falls outside the valid range [-90, 90].
|
|
242
|
+
* Equivalent to Go's ErrInvalidLatitude.
|
|
243
|
+
*/
|
|
244
|
+
declare class InvalidLatitudeError extends ValidationError {
|
|
245
|
+
constructor(message?: string);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Error thrown when longitude falls outside the valid range [-180, 180].
|
|
249
|
+
* Equivalent to Go's ErrInvalidLongitude.
|
|
250
|
+
*/
|
|
251
|
+
declare class InvalidLongitudeError extends ValidationError {
|
|
252
|
+
constructor(message?: string);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Error thrown when coordinate polygon validation fails.
|
|
256
|
+
* Equivalent to Go's ErrInvalidCoordinates.
|
|
257
|
+
*/
|
|
258
|
+
declare class InvalidCoordinatesError extends ValidationError {
|
|
259
|
+
constructor(message?: string);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Represents an HTTP error returned by the GeoEngine REST or Management API.
|
|
263
|
+
* Equivalent to Go's APIError.
|
|
264
|
+
*/
|
|
265
|
+
declare class APIError extends GeoEngineError {
|
|
266
|
+
readonly statusCode: number;
|
|
267
|
+
constructor(statusCode: number, message: string);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Represents a structured error returned by GeoEngine api-service.
|
|
271
|
+
* Equivalent to Go's SpatialAPIError.
|
|
272
|
+
*/
|
|
273
|
+
declare class SpatialAPIError extends APIError {
|
|
274
|
+
readonly code: string;
|
|
275
|
+
readonly statusText?: string;
|
|
276
|
+
readonly details: SpatialErrorDetail[];
|
|
277
|
+
constructor(statusCode: number, code: string, message: string, statusText?: string, details?: SpatialErrorDetail[]);
|
|
278
|
+
/**
|
|
279
|
+
* Returns true if the error indicates the geofence or resource was not found.
|
|
280
|
+
*/
|
|
281
|
+
isNotFound(): boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Returns true if the error indicates quota limit was hit.
|
|
284
|
+
*/
|
|
285
|
+
isQuotaExceeded(): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Returns true if authentication failed.
|
|
288
|
+
*/
|
|
289
|
+
isUnauthorized(): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Returns true if access to the requested resource is forbidden.
|
|
292
|
+
*/
|
|
293
|
+
isForbidden(): boolean;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Specific error thrown when a geofence is not found (204 or 404).
|
|
297
|
+
* Equivalent to Go's ErrGeofenceNotFound.
|
|
298
|
+
*/
|
|
299
|
+
declare class GeofenceNotFoundError extends SpatialAPIError {
|
|
300
|
+
constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Specific error thrown when request quota limit is exceeded (HTTP 402 or 429).
|
|
304
|
+
* Equivalent to Go's ErrQuotaExceeded.
|
|
305
|
+
*/
|
|
306
|
+
declare class QuotaExceededError extends SpatialAPIError {
|
|
307
|
+
constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Specific error thrown when API authentication fails (HTTP 401).
|
|
311
|
+
* Equivalent to Go's ErrUnauthorized.
|
|
312
|
+
*/
|
|
313
|
+
declare class AuthenticationError extends SpatialAPIError {
|
|
314
|
+
constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Specific error thrown when access is forbidden (HTTP 403).
|
|
318
|
+
* Equivalent to Go's ErrForbidden.
|
|
319
|
+
*/
|
|
320
|
+
declare class ForbiddenError extends SpatialAPIError {
|
|
321
|
+
constructor(message?: string, statusCode?: number, details?: SpatialErrorDetail[]);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Error thrown when a network request exceeds its deadline or timeout limit.
|
|
325
|
+
*/
|
|
326
|
+
declare class TimeoutError extends GeoEngineError {
|
|
327
|
+
constructor(timeoutMs: number);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Error thrown when a user ID is missing or empty.
|
|
331
|
+
* Equivalent to Go's ErrUserIDRequired.
|
|
332
|
+
*/
|
|
333
|
+
declare class UserIDRequiredError extends ValidationError {
|
|
334
|
+
constructor(message?: string);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Error thrown when a GeoIdentity rule ID is missing or empty.
|
|
338
|
+
* Equivalent to Go's ErrRuleIDRequired.
|
|
339
|
+
*/
|
|
340
|
+
declare class RuleIDRequiredError extends ValidationError {
|
|
341
|
+
constructor(message?: string);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Error thrown when a GeoIdentity rule name is missing or empty.
|
|
345
|
+
* Equivalent to Go's ErrRuleNameRequired.
|
|
346
|
+
*/
|
|
347
|
+
declare class RuleNameRequiredError extends ValidationError {
|
|
348
|
+
constructor(message?: string);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Error thrown when an invitation email is missing or empty.
|
|
352
|
+
* Equivalent to Go's ErrEmailRequired.
|
|
353
|
+
*/
|
|
354
|
+
declare class EmailRequiredError extends ValidationError {
|
|
355
|
+
constructor(message?: string);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Error thrown when a role is missing or empty.
|
|
359
|
+
* Equivalent to Go's ErrRoleRequired.
|
|
360
|
+
*/
|
|
361
|
+
declare class RoleRequiredError extends ValidationError {
|
|
362
|
+
constructor(message?: string);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Structured error returned by the api-service Users and GeoIdentity endpoints.
|
|
366
|
+
* Equivalent to Go's APIServiceError. Branch on the subclasses (for example
|
|
367
|
+
* UserNotFoundError) or on `code`.
|
|
368
|
+
*/
|
|
369
|
+
declare class APIServiceError extends APIError {
|
|
370
|
+
/** Machine-readable reason, e.g. "USER_NOT_FOUND". Empty when the API sent none. */
|
|
371
|
+
readonly code: string;
|
|
372
|
+
/** Message returned by the API, without the SDK prefix. */
|
|
373
|
+
readonly apiMessage: string;
|
|
374
|
+
readonly details: SpatialErrorDetail[];
|
|
375
|
+
constructor(statusCode: number, code: string, message: string, details?: SpatialErrorDetail[]);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* The user does not exist in the organization (or its access was revoked).
|
|
379
|
+
* Equivalent to Go's ErrUserNotFound.
|
|
380
|
+
*/
|
|
381
|
+
declare class UserNotFoundError extends APIServiceError {
|
|
382
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* The GeoIdentity rule does not exist.
|
|
386
|
+
* Equivalent to Go's ErrRuleNotFound.
|
|
387
|
+
*/
|
|
388
|
+
declare class RuleNotFoundError extends APIServiceError {
|
|
389
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The invited email already belongs to the organization.
|
|
393
|
+
* Equivalent to Go's ErrUserAlreadyExists.
|
|
394
|
+
*/
|
|
395
|
+
declare class UserAlreadyExistsError extends APIServiceError {
|
|
396
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* A pending invitation already exists for the email.
|
|
400
|
+
* Equivalent to Go's ErrInvitationPending.
|
|
401
|
+
*/
|
|
402
|
+
declare class InvitationPendingError extends APIServiceError {
|
|
403
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* The operation would leave the organization without an admin.
|
|
407
|
+
* Equivalent to Go's ErrLastAdmin.
|
|
408
|
+
*/
|
|
409
|
+
declare class LastAdminError extends APIServiceError {
|
|
410
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* The operation would leave a rule without assigned subjects.
|
|
414
|
+
* Equivalent to Go's ErrLastSubject.
|
|
415
|
+
*/
|
|
416
|
+
declare class LastSubjectError extends APIServiceError {
|
|
417
|
+
constructor(message?: string, statusCode?: number, code?: string, details?: SpatialErrorDetail[]);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
declare const TRANSIENT_BRAND: unique symbol;
|
|
421
|
+
declare const INTEGRATION_BRAND: unique symbol;
|
|
422
|
+
interface IdentityErrorFields<R extends string> {
|
|
423
|
+
message: string;
|
|
424
|
+
status?: number;
|
|
425
|
+
type?: string;
|
|
426
|
+
title?: string;
|
|
427
|
+
detail?: string;
|
|
428
|
+
requestId?: string;
|
|
429
|
+
reason: R;
|
|
430
|
+
apiKeyToRedact?: string;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Transient evaluation error (network, timeout, 5xx, 429, or non-JSON 5xx).
|
|
434
|
+
* `identityGuard` applies the configured `failOpen` policy for this error class.
|
|
435
|
+
*/
|
|
436
|
+
declare class IdentityTransientError extends GeoEngineError {
|
|
437
|
+
readonly status?: number;
|
|
438
|
+
readonly type?: string;
|
|
439
|
+
readonly title?: string;
|
|
440
|
+
readonly detail?: string;
|
|
441
|
+
readonly requestId?: string;
|
|
442
|
+
readonly reason: IdentityTransientReason;
|
|
443
|
+
/** Stable machine-readable code; the contract between ESM and CJS builds. */
|
|
444
|
+
readonly code: "IDENTITY_TRANSIENT";
|
|
445
|
+
readonly [TRANSIENT_BRAND] = true;
|
|
446
|
+
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
447
|
+
constructor(fields: IdentityErrorFields<IdentityTransientReason>);
|
|
448
|
+
toJSON(): Record<string, unknown>;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Integration or client configuration error (400, 401, 403, 404, 422, edge 403,
|
|
452
|
+
* unexpected 200 payload, or invalid input). `identityGuard` NEVER applies `failOpen`.
|
|
453
|
+
*/
|
|
454
|
+
declare class IdentityIntegrationError extends GeoEngineError {
|
|
455
|
+
readonly status?: number;
|
|
456
|
+
readonly type?: string;
|
|
457
|
+
readonly title?: string;
|
|
458
|
+
readonly detail?: string;
|
|
459
|
+
readonly requestId?: string;
|
|
460
|
+
readonly reason: IdentityIntegrationReason;
|
|
461
|
+
/** Stable machine-readable code; the contract between ESM and CJS builds. */
|
|
462
|
+
readonly code: "IDENTITY_INTEGRATION";
|
|
463
|
+
readonly [INTEGRATION_BRAND] = true;
|
|
464
|
+
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
465
|
+
constructor(fields: IdentityErrorFields<IdentityIntegrationReason>);
|
|
466
|
+
toJSON(): Record<string, unknown>;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Type guard that identifies transient GeoIdentity errors across ESM/CJS entrypoints.
|
|
470
|
+
*/
|
|
471
|
+
declare function isTransient(err: unknown): err is IdentityTransientError;
|
|
472
|
+
|
|
473
|
+
export { RuleNameRequiredError as $, APIError as A, EmailRequiredError as B, type Challenge as C, type Decision as D, type EvaluateMeta as E, type FallbackDecision as F, type GuardRequest as G, ForbiddenError as H, type IdentityGuardOptions as I, GeoEngineError as J, type KnownDecision as K, type LocationSource as L, type MetaSource as M, type NextFunction as N, GeofenceIDRequiredError as O, GeofenceNotFoundError as P, InvalidCoordinatesError as Q, type ReputationStatus as R, type ShadowMatch as S, InvalidLatitudeError as T, InvalidLongitudeError as U, InvitationPendingError as V, LastAdminError as W, LastSubjectError as X, QuotaExceededError as Y, RoleRequiredError as Z, RuleIDRequiredError as _, type GuardResponse as a, RuleNotFoundError as a0, SpatialAPIError as a1, type SpatialErrorDetail as a2, TimeoutError as a3, UserAlreadyExistsError as a4, UserIDRequiredError as a5, UserNotFoundError as a6, ValidationError as a7, type EvaluateOptions as b, type EvaluateReason as c, type EvaluateRequest as d, type EvaluateResponse as e, type EvaluateSignal as f, type FallbackReason as g, type IdentityContext as h, type IdentityDecision as i, type IdentityErrorFields as j, type IdentityGuardClient as k, IdentityIntegrationError as l, type IdentityIntegrationReason as m, type IdentityLocation as n, IdentityService as o, type IdentityServiceConfig as p, type IdentitySubject as q, IdentityTransientError as r, type IdentityTransientReason as s, type KnownSignal as t, type RuleRef as u, isTransient as v, APIServiceError as w, AuthenticationError as x, ClientClosedError as y, DeviceIDRequiredError as z };
|