Skip to main content
Version: Guardian v0.5.0

Error Codes

SDK Errors (SurtError)​

ErrorWhen
notInitializedverify() called before initialize()
invalidJwtJWT missing, malformed, or rejected by the backend. Mint a fresh JWT per verify().
networkErrorTimeout or no connection
serverError5xx from backend
attestationFailedA device integrity check failed — most often a reused JWT. Mint a fresh JWT for each verify().

Native platforms surface these as .notInitialized / .invalidJwt / etc. The React Native bridge surfaces string codes: not_initialized, invalid_jwt, attestation_failed, network_error.

Web SDK errors

The Web SDK (@surtai/guardian-web) uses a separate GuardianError with the codes CRYPTO_UNAVAILABLE, ENCRYPTION_FAILED, and INVALID_OPTIONS. See NPM Package.

Result diagnostics​

Every verify() and collect() result includes a diagnostics object so you can see what the SDK observed during the transaction. You read it straight off the result you already get back — it is additive, so existing code is unaffected. The shape is identical on Web, iOS, Android, and React Native.

// React Native (verify) — diagnostics is on the result you already receive
const result = await GuardianSDK.verify(jwt);
console.log(result.diagnostics?.location); // e.g. "denied"
console.log(result.diagnostics?.warnings); // e.g. [{ code: "LOCATION_PERMISSION_DENIED", signal: "location" }]

// Web (collect) — diagnostics sits alongside the payload
const { payload, diagnostics } = await collect({ collectLocation: true });
console.log(diagnostics.location);
// iOS (Swift) — on the VerificationResult / CollectResult
let result = try await GuardianSDK.shared.verify(jwt: jwt)
print(result.diagnostics.location ?? "n/a")
// Android (Kotlin) — on the VerificationResult / CollectResult
val result = GuardianSDK.getInstance().verifySuspend(jwt).getOrThrow()
Log.d("Guardian", result.diagnostics.location ?: "n/a")
FieldValuesMeaning
locationcollected · denied · unavailable · timeout · not_requestedWhether device location was captured, or why not (e.g. the user denied permission).
networkIntelcollected · unavailable · not_requestedWhether the supplementary network-intelligence signal was available for this transaction.
warningsarray of { code, signal, detail? }Structured, non-fatal notes you can log or surface to support (e.g. LOCATION_PERMISSION_DENIED).
{
"diagnostics": {
"location": "denied",
"networkIntel": "collected",
"warnings": [{ "code": "LOCATION_PERMISSION_DENIED", "signal": "location" }]
}
}
tip

Use diagnostics to explain outcomes to your users or support team — for example, prompting the user to enable location when location is denied.

HTTP Status Codes​

CodeMeaning
200Success
400Malformed JSON or missing required field
401Invalid or missing Bearer JWT
403Valid key but missing permission
5xxServer error