Building with AI assistants
Give your AI coding assistant the context it needs to build a correct Hub integration.
An AI coding assistant can get your Hub integration running quickly. Hub is standard OpenID Connect, with a few specifics an assistant can't guess on its own. Give it the rules on this page and it can get them right first time.
How to use this page
- Add the rules below to your assistant's context. Put them in your project's instructions file for the assistant, or paste them at the start of your conversation.
- Give it the pages for what you're building. See Pages to share.
- Check what it produces against the review checklist.
Keep secrets out of the conversation. Never paste your private key or real user data into an assistant. The rules and examples here use placeholder values only.
The rules
# Interac Hub integration rules
Hub is an OpenID Connect provider for identity verification. Follow these rules.
If something isn't covered here or in the Hub integration guide, ask me.
Don't guess parameter names, claim names or error values.
Index of every guide page: https://documents.hub-verify.innovation.interac.ca/llms.txt
## Endpoints
- Read every endpoint from {hub_base_url}/.well-known/openid-configuration. Don't hardcode them.
## Signing
- There is no client secret. Authenticate with JWTs signed RS256 with our RSA private key.
- Every JWT header includes `kid`, matching a key published at our JWKS URL.
- `exp`, `iat` and `nbf` are numbers (Unix seconds), never strings.
- Leave out `iat` unless needed. If present, it must not be ahead of Hub's clock.
- The private key stays on the server. Never put it in browser or mobile code.
## Starting a verification
- Signed request object claims: `iss` = client ID, `aud` = the discovery `issuer`
exactly (including its trailing slash), `client_id`, `response_type` = "code",
`scope` = "openid <our scope>" (openid first), `redirect_uri` (exactly as registered),
`state`, `nonce`. Optional: `ui_locales` ("en-CA" or "fr-CA").
- Generate a new random `state` for every verification and store it against the user's session.
- Send the signed JWT as `request`. Repeat `response_type`, `client_id`, `scope`,
`state` and `redirect_uri` as plain parameters with identical values.
- Use GET /auth by default. Use POST /auth/par when subject matching is enabled.
With PAR, redirect the user to `user_href` immediately and treat `request_uri` as opaque.
- PKCE is optional. If used, use S256 and generate the pair with a PKCE library.
## Handling the redirect
- Check `state` against the stored session before anything else. If there's no match, stop.
- Log `state` for every verification, successful or not. Interac support uses it to find transactions.
- On error: URL-decode `error_description` and branch on it, not on `error`.
Handle `error=session_expired` as its own case.
- Exchange the `code` on the server within 10 minutes. Codes are single-use.
## Token exchange
- POST to the token endpoint: `grant_type=authorization_code`, `code`, `client_id`,
`redirect_uri` (identical to the request), `client_assertion_type` =
"urn:ietf:params:oauth:client-assertion-type:jwt-bearer", `client_assertion`.
- Client assertion claims: `iss` and `sub` = client ID, `aud` = the token endpoint URL
(NOT the issuer), `exp`, and a unique `jti` every time.
## Userinfo
- GET the userinfo endpoint with `Authorization: Bearer <access_token>`.
- The response shape depends on the verification method. Follow the guide page for ours.
- Use full claim names, including dotted prefixes such as `com.securekey.vids.job_id`.
- Don't assume every claim is present. Bank verification: optional claims may be "",
"N/A" or absent. Document verification: "N/A" when the document doesn't carry it.
Verified credentials: null.
- Document verification: use the details only when `scan_result` is "CLEAR".
- Verified credentials: check `issuance.issue_expiry`.
- Store the transaction ID for seven years: `com.securekey.verified.me.license_id` (bank),
`com.securekey.vids.job_id` (document) or `job_id` (verified credentials).
## Detailed error reporting (only if enabled for our client)
- Decoded `error_description` format: `err:<value>$details:<value>$stage:<value>`.
- Branch on `err`. `details` and `stage` are optional extra context.
- Always include a default branch. New values can appear.
- Log `cid` alongside `state`.Replace {hub_base_url} with the base URL for your environment. See Environments.
Pages to share
Give your assistant the pages for the part you're working on, as well as the rules.
Every page has a plain-text version that assistants read easily: add .md to the page address, for example https://documents.hub-verify.innovation.interac.ca/docs/quick-start-guide.md. Paste its content into the conversation, or give the assistant the link if it can read web pages.
If your assistant can read web pages, you can also give it the index of every page: https://documents.hub-verify.innovation.interac.ca/llms.txt. It lists each page with a one-line summary, so the assistant can find the ones it needs.
| You're building | Share these pages |
|---|---|
| The core flow | Quick Start, Step 1 — Discovery, Step 2 — Starting a verification, Step 3 — Handling the redirect, Step 4 — Token exchange, Step 5 — Retrieving claims |
| Signing keys | Signing keys and JWKS |
| Handling the response | The page for your method: Bank verification, Document verification, Verified credentials, Select mode, Dual mode or Subject matching. Add the Claims dictionary. |
| Error handling | How Hub reports errors, Error reference, and Detailed error reference if your client has detailed error reporting |
Fewer, more relevant pages work best. An assistant given only the pages for the task at hand tends to stay closer to them than one given the whole guide.
Review checklist
Before you run the generated code, check that:
- Endpoints come from discovery, not hardcoded URLs
audis theissuerin the request object, and the token endpoint URL in the client assertionexp,iatandnbfare numbers- Every JWT header has
kid stateis new for each verification, checked first on the redirect, and logged- The code exchange and userinfo call happen on your server
- Errors branch on the decoded
error_description, with a default branch - Missing, empty and
"N/A"claims are handled - The transaction ID is stored
Then test the paths users take: complete a verification, cancel it, and let a session time out. See How Hub reports errors.
Updated about 5 hours ago