# Changelog

## 2.0.0

Sharded base URLs: the SDK now resolves `checkoutApiBaseUrl` and `widgetsBaseUrl` per `Currency` from a bootstrap config fetched at init. Unblocks server-side merchant sharding (e.g. KSA-residency endpoints) without requiring SDK releases when shards are added or moved.

### Breaking changes

- `Tabby.setApiKey(apiKey, env)` is **renamed** to `Tabby.setup(apiKey, env)` and is now `async` (`Promise<void>`). Callers **must `await`** it. `setup` performs `POST {apiBaseUrl}/api/v1/sdk/config` (no `Authorization`; the bootstrap endpoint is merchant-agnostic) and caches the resulting endpoint map in memory.
- `Tabby.apiHost` and `Tabby.widgetsUrl` getters are removed. Internal callers now use the per-currency `SdkConfig.endpointsFor(currency)` resolver. There is no public currency-agnostic base URL.
- `Tabby.createSession(payload)` and `TabbyProductPageWidget` will throw `"TabbySDK did not setup. Call await Tabby.setup(...) before any other calls."` if invoked before a successful `setup`.
- Bootstrap failures (transport error, non-200 status, malformed JSON, missing `default` entry) cause `setup` to reject. There is **no retry** and **no fallback** to embedded URLs.

### Added

- New public types `SdkConfig`, `SdkEndpoints`, and `parseSdkConfig` exported from the package barrel for partners that want to introspect the loaded config.
- `Tabby.widgetsBaseUrlFor(currency)` accessor used by `TabbyProductPageWidget` to compose the snippet URL with the correct shard's widgets host.

### Behaviour

- Currency lookup is case-sensitive against the `Currency` union value (uppercase ISO codes, `'AED' | 'SAR' | 'KWD' | 'BHD' | 'QAR'`). When a currency is absent from the config response, the SDK falls back to the `default` entry.
- Currencies the SDK doesn't yet know (e.g. a future `EGP` shard) are retained in `SdkConfig.endpointsByKey` and surface to a future SDK release that extends the `Currency` union.
- `X-SDK-Version` header bumped to `RN/2.0.0` on both bootstrap and checkout calls.
