@noviuz/kyc-contracts
v2.0.0
Published
Shared types, Zod schemas, and wire-message + theme contracts for the Noviuz Hosted KYC Flow. The trust boundary, in code.
Readme
@noviuz/kyc-contracts
The trust boundary, in code. Shared TypeScript types + Zod schemas + the versioned wire
protocol used by both the SDK (@noviuz/kyc-js) and the hosted page (@noviuz/web).
Every message is validated at runtime on both ends against these schemas.
What's inside
- Config —
partnerContextSchema,metadataSchema, the sensitive-field blocklist (SENSITIVE_KEYS,findSensitiveFields,isSensitiveKey,looksLikeBrazilianDocument). - Theme — two-tier theming:
themeInputSchema,appearanceSchema,resolveThemePayload,appearanceVariablesToCssVars,THEME_TOKEN_TO_CSS_VAR. - CSS sanitizers —
cssColorSchema,cssLengthSchema,fontFamilySchema(+isSafe*): allowlist validation that stops CSS injection via partner theme tokens. - Messages — every SDK↔host message schema, discriminated unions, and
validateHostToSdkMessage/validateSdkToHostMessage(shape + protocol-major + identity). - Result —
kycResultSchema(aliased asKycResultV2),kycSuccessResultSchema,redirectNotificationSchema(RedirectNotificationV2),kycErrorPayloadSchema— all.strict(), so nothing sensitive (or unlisted) can ride along. The v2 egress allowlist is exactlystatus, sessionId, referenceId?, euid?, noviuz_euid?— there is noeulen_payloadfield; it existed pre-v2 and was removed from the schema entirely (not deprecated-but-present). Seedocs/reference/kyc-v2-contract.md§1 for the normative contract. - Versioning —
PROTOCOL_VERSION,isCompatibleProtocolVersion(major-family compat). - Constants —
MESSAGE_NAMESPACE,SdkToHostType,HostToSdkType,HOSTED_PARAMS,REDIRECT_PARAMS,HOSTED_ROUTES,LIMITS.
Versioning rule
Message version is a major.minor string; compatibility is by major family. A host
running 1.x keeps accepting any older 1.x SDK (additive minors), so old SDKs keep working.
A major bump is an intentional break.
