Skip to content
trinsic-idPublic

About

This repository contains the samples for all major languages and frameworks. It also contains our UI SDKs to launch verification flows using the Trinsic widget.

Topics

Resources

Stars

8 stars

Watchers

3 watching

Forks

Repository files navigation

Trinsic SDKs

This repository is the home of Trinsic's API (backend) and UI (frontend) libraries.

You can find our platform's documentation at docs.trinsic.id

Getting started

Tip

Each backend sample wraps the /ui-web/samples/ sample as the frontend, including Hosted and Direct sessions.

  1. Retrieve your auth token and a verification profile ID from the Trinsic Dashboard
  2. Configure localhost:3000 as an approved redirect url in your app's settings in the dashboard.
  3. Configure it either as environment variable (TRINSIC_ACCESS_TOKEN and TRINSIC_VERIFICATION_PROFILE_ID) or in your backend stack's sample .env file.
  4. Go to your preferred backend stack's sample (/language/samples/server) and run the backend using start.sh. Note this assumes you have the toolchain working locally, inspect the start.sh file to see the required steps.
  5. Explore the API and it's capabilities by navigating to localhost:3000.

API Libraries

Use these libraries in your backend to communicate with the Trinsic API.

Language Version Build status
C# C# Version C# Status
Go Go package version Go Status
Java Java Version Java Status
Python Python Version Python Status
Ruby Ruby Version Ruby Status
Typescript TypeScript Version TypeScript Status

UI Libraries

Use these libraries in your frontend (web or mobile app) to launch the Trinsic Flow on your user's device after creating a Session using an API Library.

Platform Version Build status
Android Android Version Android Build Status
Expo Expo Version Expo Build Status
Flutter Flutter Version Flutter Build Status
Swift Swift UI Version Swift Build Status
Web Web Version Web Build Status

SDK Versioning

Our SDKs follow the Semantic Versioning ("SemVer") scheme.

For example, the version number 1.13.0 has a major version of 1, a minor version of 13, and a patch version of 0.

Breaking changes are only introduced alongside a new major version.

API SDK identification

Every generated API SDK automatically sends X-Trinsic-SDK: <language>/<version> with its requests, for example X-Trinsic-SDK: python/3.2.1. Language identifiers are csharp, go, java, python, ruby, and typescript. The version is the SDK package version from versions.json, including any prerelease suffix. No client configuration is required, and existing authentication and application headers are preserved.

helpers/generate-client.sh applies the request additions using helpers/inject-sdk-header.mjs after generation, so they survive every rebuild. The patches target the generator libraries and package layouts configured in api-*/build-sdk.sh and fail the build if an expected injection point is missing. When upgrading OpenAPI Generator or changing those configurations, check the injection points against its generated request code. This applies to the six generated API SDKs; the UI libraries have a separate build process.

After building an SDK, run SDK_LANGUAGE=python npm run test:sdk-headers (substitute its language identifier). With all six SDKs built and their toolchains installed, npm run test:sdk-headers runs the full suite. These tests send requests only to a local HTTP server and verify SDK identity alongside authentication and custom headers. Each API build workflow runs its language's tests before publishing.

Generated SDK regression tests

This repository keeps the regression tests for generated SDKs in helpers/tests. The API build workflows run those checks before publishing.

Named model construction

The next major API SDK release prevents schema changes from silently rebinding positional model fields. C# uses object initializers with required writable properties; Go uses keyed structs or named setters; Java uses no-argument constructors and named setters, with private Jackson constructors for read-only fields. Python keyword models and Ruby attribute hashes retain their existing behavior. TypeScript models remain interfaces, and endpoint calls now take one object containing named endpoint parameters.

These are breaking source changes. Package versions have not been advanced for release yet. See each API SDK's README for migration examples and the template notes for the generator overrides. Client configuration constructors and endpoint methods outside TypeScript retain their existing calling conventions.

Template changes are maintained as patches against the checksum-pinned generator. npm run templates:check detects drift; the template notes describe staging and reviewing upgrades with templates:upgrade and templates:accept.

After building an API SDK, run SDK_LANGUAGE=csharp npm run test:sdk-construction (or go, java, python, ruby, typescript). With all six built, npm run test:sdk-construction runs them together. The checks compile or run valid consumers, require unsafe calls to fail, and verify JSON behavior without calling the Trinsic API. Each API build workflow runs its checks.

Wire formats

TypeScript date-only fields use UTC midnight when read and UTC calendar components when written. Python request serialization encodes raw bytes as standard base64 and leaves existing base64 strings unchanged. Ruby and Java support verification-profile multipart requests without a logo or provider list. Ruby model timestamps serialize as ISO 8601 with nanosecond precision.

After building the SDKs, run npm run test:sdk-wire, or select one with SDK_LANGUAGE=ruby npm run test:sdk-wire. The tests check date handling across timezones, binary request bodies, optional multipart fields, and fractional timestamps. HTTP checks use only a local server. The Java, Python, Ruby, and TypeScript API builds run these checks before publishing.

Unknown enum values

The API can add enum values after an SDK version is released. API SDKs read a value they do not know instead of failing the whole response. C#, Go, Java, Python, and Ruby are generated with enumUnknownDefaultCase=true, which adds a fallback member with the wire value unknown_default_open_api to every enum, and read unknown values as that member. Go, Java, and Ruby get this from the generator; C# and Python need template patches because their generators add the member without using it. TypeScript needs neither: its models already return an unknown value as the original string.

The fallback member is for reading only; the API does not accept it in requests. Where an SDK converts strings to enums, such as Java's fromValue or Python model fields, a misspelled value now also becomes the fallback member instead of raising an error.

After building an API SDK, run SDK_LANGUAGE=csharp npm run test:sdk-unknown-enums (or go, java, python, ruby, typescript). The checks read responses holding unknown values without calling the Trinsic API, and each API build workflow runs them. Only enums declared as their own schema are covered, which is every enum in the API today. The C#, Python, and Ruby checks fail if an enum is ever declared inside a model property, because the code generated for those has no fallback.

Support

Any issues, inquiries, and feature requests can be sent to support@trinsic.id, or feel free to open a GitHub issue here.

More Information

About

This repository contains the samples for all major languages and frameworks. It also contains our UI SDKs to launch verification flows using the Trinsic widget.

Topics

Resources

Stars

8 stars

Watchers

3 watching

Forks

Packages

Used by

Contributors

Languages