@alytegen/sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/BROWSER.md ADDED
@@ -0,0 +1,83 @@
1
+ # Buyer purchases inside your chat
2
+
3
+ Available in SDK 0.4.0 with Alyte's Model 1 browser endpoints. The merchant token
4
+ stays on your backend. Your chat receives a short-lived bounded buyer bearer;
5
+ creating or widening permission requires email verification inside Alyte's iframe.
6
+ The full verification bearer stays there. No raw agent credential reaches your chat.
7
+
8
+ ## Register and attest
9
+
10
+ Register your exact HTTPS chat origin in the shop's `embedOrigin` (multiple origins
11
+ are comma-separated). This controls both framing and buyer CORS. New registrations
12
+ can take up to 30 seconds to reach preflight caches. Local HTTP development is supported.
13
+ On your backend, authenticate your own user, derive their email from that session,
14
+ then call `merchant.buyerSessions.mint({ merchantId, email })`. Return only the `token`
15
+ query value extracted from `new URL(session.redeemPath, ALYTE_URL)` to that user's
16
+ browser. Do not navigate the redeem link too: either consumer uses the token once.
17
+ The mint endpoint must not accept an arbitrary browser-supplied email as identity.
18
+
19
+ ## Connect and open consent
20
+
21
+ ```ts
22
+ import { exchangeBuyerSession, createBuyerClient, openConsent } from '@alytegen/sdk/browser';
23
+
24
+ const connection = await exchangeBuyerSession({ baseUrl: ALYTE_URL, token });
25
+ const buyer = createBuyerClient({ baseUrl: ALYTE_URL, bearer: connection.bearer });
26
+ const controller = new AbortController(); // abort when your chat/modal closes
27
+ const { agentId, mandateId } = await openConsent({
28
+ baseUrl: ALYTE_URL, merchantId, bearer: connection.bearer,
29
+ container: document.querySelector<HTMLElement>('#alyte-consent')!,
30
+ signal: controller.signal, lang: 'en',
31
+ theme: { accent: '#006466', font: 'sans', radius: 8, scheme: 'light' },
32
+ });
33
+ ```
34
+
35
+ Keep the connection in memory. It expires after 30 minutes (`expiresAt`). On expiry
36
+ or a `401 unauthorized`, ask your backend for a fresh mint and exchange it; a replayed
37
+ or expired mint returns `401 link_invalid`. Create a new client with the new bearer.
38
+ Cookie login endpoints are not available to the parent chat.
39
+
40
+ The iframe lets the buyer choose an existing usable Alyte agent/permission or
41
+ create one. Selecting an existing permission needs no new email verification.
42
+ Creating authority does. Completion returns IDs only and removes the iframe.
43
+ Cancellation/abort rejects with `AlyteConsentError.code = 'consent_cancelled'`;
44
+ an initial handshake timeout uses `consent_unavailable`. Server errors retain their
45
+ code. `readyTimeoutMs` defaults to 15 seconds and never limits code-entry time.
46
+
47
+ Optional `returnUrl` must belong to the chat origin. `onNavigate(url)` decides how
48
+ your chat handles the Back link. The SDK does not navigate the host automatically.
49
+ Themes accept only `accent`, `background`, `surface`, `text`, `font`, `radius`, `scheme`.
50
+ Colours are opaque hex; font is system/sans/serif, radius is 0–16, scheme light/dark.
51
+ If contrast fails, all four colours fall back to scheme defaults; they are not
52
+ adjusted. Permission terms, errors and disabled controls keep fixed readable colours.
53
+ Provider card inputs keep their provider styling.
54
+
55
+ ## Buy, watch and revoke
56
+
57
+ ```ts
58
+ const attempt = { agentId, tierId, quantity: 1, attemptId: crypto.randomUUID() };
59
+ // Persist BEFORE sending. Use your app's durable purchase-attempt store; retain it
60
+ // across reloads and reconnects. Namespace it to this buyer/shop/cart.
61
+ await attempts.save(attempt);
62
+ const purchase = await buyer.buy(attempt);
63
+ if (purchase.status === 'pending') {
64
+ const receipt = await buyer.payment(purchase.intentId); // refresh later if pending
65
+ }
66
+ ```
67
+
68
+ The UUID is required; the SDK never invents one or retries requests automatically.
69
+ After a network failure, resume with the **same saved attempt**, including agent,
70
+ tier, quantity and ID. Never create a fresh attempt to retry an uncertain charge.
71
+ `settled` is success; `pending` remains unresolved. `sca_required` is an authentication
72
+ continuation requirement; browser SCA resume is not yet available. Do not treat it
73
+ as success or dispatch a new purchase. Non-2xx responses throw `AlyteApiError` with
74
+ `status`, `code` and `details`; purchase `402` outcome bodies are in `details`.
75
+
76
+ Other methods: `me()`, `catalog()`, `agents()`, `instruments()`, `instrumentCaps()`,
77
+ `watches()`, `watch({ agentId, tierId, quantity, expiresInDays? })`,
78
+ `cancelWatch(id)`, `revokeMandate(id)`. Revocation is immediate and server-enforced.
79
+ Every buy/watch still depends on the buyer's current mandate, card evidence and
80
+ live availability. A bounded bearer cannot create or widen spending authority.
81
+
82
+ Your backend still fulfills from verified settlement webhooks, idempotently.
83
+ Browser completion messages are presentation state, not fulfillment evidence.
package/QUICKSTART.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # @alytegen/sdk — quickstart
2
2
 
3
- Two clients, two credentials:
3
+ Choose the credential for the runtime:
4
4
 
5
5
  | Client | Credential | Runs | Does |
6
6
  |---|---|---|---|
7
7
  | `AlyteMerchant` | API token (console → API keys, `merchant:read`/`merchant:write`) | **your server only** | catalog CRUD, PSP links, payments visibility, buyer-session mint |
8
8
  | `AlyteAgent` | agent JWT | your agent runtime | discover → quote → hold → confirm |
9
+ | `@alytegen/sdk/browser` | bounded buyer bearer | your chat page | embedded consent and purchases using the buyer's Alyte agent |
9
10
 
10
11
  ```bash
11
12
  npm install @alytegen/sdk # zero dependencies, Node ≥18 (built-in fetch)
@@ -37,10 +38,17 @@ When a signed-in user wants an AI agent shopping for them, **your server attests
37
38
  them** and you redirect:
38
39
 
39
40
  ```ts
40
- const s = await alyte.buyerSessions.mint({ merchantId: merchant.id, email: user.email });
41
+ const s = await alyte.buyerSessions.mint({
42
+ merchantId: merchant.id, email: user.email,
43
+ lang: user.locale, // optional: Alyte's pages open in the language of YOUR site
44
+ });
41
45
  res.redirect(ALYTE_URL + s.redeemPath); // single-use, 15-min TTL
42
46
  ```
43
47
 
48
+ Embedding in a chat? Follow [BROWSER.md](./BROWSER.md) to exchange the single-use
49
+ token and launch consent without third-party cookies. Directly framing the full
50
+ authorize page is also supported, but its cookie session depends on browser policy.
51
+
44
52
  They land authenticated on the shop's authorize page: pick or bring an agent,
45
53
  set a spending cap and scope — all enforced server-side by Alyte on every
46
54
  purchase. `buyerId` is deterministic per email, so the same user arriving later
package/README.md CHANGED
@@ -14,13 +14,17 @@ between the buyer and the merchant's Stripe or Adyen account.
14
14
  npm install @alytegen/sdk
15
15
  ```
16
16
 
17
- ## Three entry points
17
+ ## Entry points
18
18
 
19
19
  | Export | Credential | Runs where | Does |
20
20
  |---|---|---|---|
21
21
  | `AlyteMerchant` | API token (console → API keys) | your server only | shops, events, tiers, PSP links, buyer-session mint, payments visibility |
22
22
  | `AlyteAgent` | agent JWT | your agent runtime | discover → quote → hold → confirm |
23
23
  | `createWebhookHandler` / `verifyWebhookSignature` | webhook secret | your server | signed, at-least-once purchase events with typed dispatch |
24
+ | `exchangeBuyerSession` / `createBuyerClient` / `openConsent` from `@alytegen/sdk/browser` | bounded buyer bearer | partner browser/chat | isolated consent, then buy/watch/list/revoke within existing authority |
25
+
26
+ The browser entry is new in 0.4.0. See [the chat integration](./BROWSER.md) for setup,
27
+ cookie-independent consent, reconnecting and handling uncertain purchases.
24
28
 
25
29
  ## Merchant: onboard in four calls
26
30
 
@@ -0,0 +1,183 @@
1
+ import type { DiscoveredEvent, Scheme } from './types.js';
2
+ export { AlyteApiError } from './http.js';
3
+ export interface BuyerConnection {
4
+ bearer: string;
5
+ buyerId: string;
6
+ expiresAt: string;
7
+ }
8
+ export interface BuyerIdentity {
9
+ tenantId: string;
10
+ buyerId: string;
11
+ email: string;
12
+ merchantId: string;
13
+ merchantName?: string;
14
+ currency?: string;
15
+ geo?: string;
16
+ tier: 'bounded' | 'full';
17
+ }
18
+ export interface BuyerMandate {
19
+ id: string;
20
+ agentId: string;
21
+ capMinor: number;
22
+ currency: string;
23
+ spentMinor?: number;
24
+ expiresAt?: string;
25
+ status: 'active' | 'amended' | 'revoked';
26
+ recurring: boolean;
27
+ maxTransactions?: number;
28
+ cadence?: string;
29
+ scope: {
30
+ merchants?: string[];
31
+ events?: string[];
32
+ tierKinds?: ('general' | 'seated')[];
33
+ quantity?: {
34
+ min?: number;
35
+ max?: number;
36
+ step?: number;
37
+ };
38
+ };
39
+ }
40
+ export interface BuyerAgent {
41
+ id: string;
42
+ name: string;
43
+ kind: 'alyte' | 'byoa';
44
+ spendCapMinor: number;
45
+ scheme: Scheme;
46
+ quantity: number;
47
+ instrumentToken?: string;
48
+ instrumentStatus?: 'ok' | 'missing';
49
+ mandates: BuyerMandate[];
50
+ }
51
+ export interface BuyerWatch {
52
+ id: string;
53
+ agentId: string;
54
+ merchantId: string;
55
+ tierId: string;
56
+ quantity: number;
57
+ status: 'queued' | 'firing' | 'fired' | 'failed' | 'cancelled' | 'expired';
58
+ result?: Record<string, unknown>;
59
+ expiresAt?: string;
60
+ createdAt: string;
61
+ firedAt?: string;
62
+ }
63
+ export type BuyerPurchase = {
64
+ status: 'settled' | 'pending';
65
+ intentId: string;
66
+ chargeMinor: number;
67
+ currency: string;
68
+ paymentState?: string;
69
+ agentName?: string;
70
+ } | {
71
+ status: 'sca_required';
72
+ } | {
73
+ status: 'refused' | 'error';
74
+ outcome: unknown;
75
+ };
76
+ export interface BuyerReceipt {
77
+ intentId: string;
78
+ status: 'settled' | 'pending' | 'refused';
79
+ chargeMinor: number;
80
+ currency: string;
81
+ paymentState?: string;
82
+ }
83
+ export interface BuyerClientOptions {
84
+ baseUrl: string;
85
+ bearer: string;
86
+ fetch?: typeof globalThis.fetch;
87
+ }
88
+ /** Pass only the token from the merchant-minted redeemPath. Keep the result in memory. */
89
+ export declare function exchangeBuyerSession(opts: {
90
+ baseUrl: string;
91
+ token: string;
92
+ fetch?: typeof globalThis.fetch;
93
+ }): Promise<BuyerConnection>;
94
+ /** Existing-authority actions only. Setup and permission changes belong in openConsent. */
95
+ export declare function createBuyerClient(opts: BuyerClientOptions): {
96
+ me: () => Promise<BuyerIdentity>;
97
+ catalog: () => Promise<{
98
+ events: DiscoveredEvent[];
99
+ }>;
100
+ agents: () => Promise<{
101
+ agents: BuyerAgent[];
102
+ }>;
103
+ instruments: () => Promise<{
104
+ instruments: Array<{
105
+ token: string;
106
+ scheme: Scheme;
107
+ last4: string;
108
+ mine: boolean;
109
+ }>;
110
+ }>;
111
+ instrumentCaps: () => Promise<{
112
+ caps: Array<{
113
+ instrumentToken: string;
114
+ capMinor: number;
115
+ currency: string;
116
+ grantedMinor: number;
117
+ }>;
118
+ }>;
119
+ watches: () => Promise<{
120
+ watches: BuyerWatch[];
121
+ }>;
122
+ /** Save attemptId BEFORE dispatch and reuse it after an uncertain response. Never retry with a new ID. */
123
+ buy: (input: {
124
+ agentId: string;
125
+ tierId: string;
126
+ quantity: number;
127
+ attemptId: string;
128
+ }) => Promise<BuyerPurchase>;
129
+ payment: (intentId: string) => Promise<BuyerReceipt>;
130
+ watch: (input: {
131
+ agentId: string;
132
+ tierId: string;
133
+ quantity: number;
134
+ expiresInDays?: number;
135
+ }) => Promise<{
136
+ watch: BuyerWatch;
137
+ }>;
138
+ cancelWatch: (watchId: string) => Promise<{
139
+ watch: BuyerWatch;
140
+ }>;
141
+ revokeMandate: (mandateId: string) => Promise<{
142
+ ok: true;
143
+ id: string;
144
+ status: "revoked";
145
+ }>;
146
+ };
147
+ export type BuyerClient = ReturnType<typeof createBuyerClient>;
148
+ export interface ConsentTheme {
149
+ accent?: string;
150
+ background?: string;
151
+ surface?: string;
152
+ text?: string;
153
+ font?: 'system' | 'sans' | 'serif';
154
+ radius?: number;
155
+ scheme?: 'light' | 'dark';
156
+ }
157
+ export interface ConsentResult {
158
+ agentId: string;
159
+ mandateId: string;
160
+ }
161
+ export interface ConsentOptions {
162
+ baseUrl: string;
163
+ merchantId: string;
164
+ bearer: string;
165
+ container: HTMLElement;
166
+ theme?: ConsentTheme;
167
+ tierId?: string;
168
+ quantity?: number;
169
+ lang?: string;
170
+ /** Optional back link. Restricted to this host origin; the callback decides navigation. */
171
+ returnUrl?: string;
172
+ onNavigate?: (url: string) => void;
173
+ /** Abort when your modal closes; removes the iframe and rejects with consent_cancelled. */
174
+ signal?: AbortSignal;
175
+ /** Bounds the initial ready handshake, not the buyer's time entering a code. Default 15s. */
176
+ readyTimeoutMs?: number;
177
+ }
178
+ export declare class AlyteConsentError extends Error {
179
+ readonly code: string;
180
+ constructor(code: string);
181
+ }
182
+ /** Mount Alyte's isolated consent surface; the full verification credential never leaves it. */
183
+ export declare function openConsent(opts: ConsentOptions): Promise<ConsentResult>;
@@ -0,0 +1,159 @@
1
+ /** Browser-only buyer connection. No merchant key or raw agent credential belongs here. */
2
+ import { AlyteApiError } from './http.js';
3
+ export { AlyteApiError } from './http.js';
4
+ function baseOrigin(value) {
5
+ const url = new URL(value);
6
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.pathname !== '/' || url.search || url.hash)
7
+ throw new TypeError('baseUrl must be an HTTP(S) origin');
8
+ if (url.protocol !== 'https:' && !['localhost', '127.0.0.1', '[::1]'].includes(url.hostname))
9
+ throw new TypeError('baseUrl must use HTTPS outside local development');
10
+ return url.origin;
11
+ }
12
+ /** HTTP errors retain the server taxonomy; no request is automatically retried. */
13
+ async function request(fetcher, base, path, method, bearer, body) {
14
+ const res = await fetcher(base + path, { method, credentials: 'omit', redirect: 'error', cache: 'no-store',
15
+ headers: { ...(bearer ? { authorization: `Bearer ${bearer}` } : {}), ...(body !== undefined ? { 'content-type': 'application/json' } : {}) },
16
+ body: body === undefined ? undefined : JSON.stringify(body),
17
+ });
18
+ const json = await res.json().catch(() => undefined);
19
+ if (!res.ok) {
20
+ const error = json?.error;
21
+ throw new AlyteApiError(res.status, error?.code ?? `http_${res.status}`, error?.message ?? `Alyte API error (HTTP ${res.status})`, error?.details ?? json);
22
+ }
23
+ return json;
24
+ }
25
+ /** Pass only the token from the merchant-minted redeemPath. Keep the result in memory. */
26
+ export function exchangeBuyerSession(opts) {
27
+ if (typeof opts.token !== 'string' || !opts.token)
28
+ throw new TypeError('token is required');
29
+ return request(opts.fetch ?? globalThis.fetch, baseOrigin(opts.baseUrl), '/v1/buyer/session-token', 'POST', undefined, { token: opts.token });
30
+ }
31
+ /** Existing-authority actions only. Setup and permission changes belong in openConsent. */
32
+ export function createBuyerClient(opts) {
33
+ const base = baseOrigin(opts.baseUrl), fetcher = opts.fetch ?? globalThis.fetch;
34
+ if (typeof opts.bearer !== 'string' || !opts.bearer)
35
+ throw new TypeError('bearer is required');
36
+ const call = (method, path, body) => request(fetcher, base, '/v1/buyer' + path, method, opts.bearer, body);
37
+ return {
38
+ me: () => call('GET', '/me'),
39
+ catalog: () => call('GET', '/catalog'),
40
+ agents: () => call('GET', '/agents'),
41
+ instruments: () => call('GET', '/instruments'),
42
+ instrumentCaps: () => call('GET', '/instruments/caps'),
43
+ watches: () => call('GET', '/watches'),
44
+ /** Save attemptId BEFORE dispatch and reuse it after an uncertain response. Never retry with a new ID. */
45
+ buy: (input) => {
46
+ if (typeof input.attemptId !== 'string' || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(input.attemptId))
47
+ throw new TypeError('A saved UUID attemptId is required');
48
+ return call('POST', `/agents/${encodeURIComponent(input.agentId)}/buy`, { tierId: input.tierId, quantity: input.quantity, attemptId: input.attemptId });
49
+ },
50
+ payment: (intentId) => call('GET', `/payments/${encodeURIComponent(intentId)}`),
51
+ watch: (input) => call('POST', '/watches', input),
52
+ cancelWatch: (watchId) => call('DELETE', `/watches/${encodeURIComponent(watchId)}`),
53
+ revokeMandate: (mandateId) => call('DELETE', `/mandates/${encodeURIComponent(mandateId)}`),
54
+ };
55
+ }
56
+ export class AlyteConsentError extends Error {
57
+ code;
58
+ constructor(code) {
59
+ super(`Alyte consent: ${code}`);
60
+ this.code = code;
61
+ this.name = 'AlyteConsentError';
62
+ }
63
+ }
64
+ /** Mount Alyte's isolated consent surface; the full verification credential never leaves it. */
65
+ export function openConsent(opts) {
66
+ const base = baseOrigin(opts.baseUrl);
67
+ if (!opts.merchantId || !opts.bearer)
68
+ throw new TypeError('merchantId and bearer are required');
69
+ const doc = opts.container.ownerDocument, host = doc.defaultView;
70
+ if (!host)
71
+ throw new TypeError('container must belong to a browser document');
72
+ if (opts.readyTimeoutMs !== undefined && (!Number.isFinite(opts.readyTimeoutMs) || opts.readyTimeoutMs <= 0))
73
+ throw new TypeError('readyTimeoutMs must be positive');
74
+ const url = new URL(`/shop/${encodeURIComponent(opts.merchantId)}/authorize`, base);
75
+ url.searchParams.set('view', 'consent');
76
+ url.searchParams.set('embed', '1');
77
+ if (opts.tierId)
78
+ url.searchParams.set('tier', opts.tierId);
79
+ if (opts.quantity !== undefined) {
80
+ if (!Number.isInteger(opts.quantity) || opts.quantity < 1 || opts.quantity > 10)
81
+ throw new TypeError('quantity must be 1–10');
82
+ url.searchParams.set('qty', String(opts.quantity));
83
+ }
84
+ if (opts.lang)
85
+ url.searchParams.set('lang', opts.lang);
86
+ if (opts.returnUrl) {
87
+ const back = new URL(opts.returnUrl);
88
+ if (back.origin !== host.location.origin)
89
+ throw new TypeError('returnUrl must belong to the host origin');
90
+ url.searchParams.set('return', back.href);
91
+ }
92
+ for (const key of ['accent', 'background', 'surface', 'text', 'font', 'radius', 'scheme']) {
93
+ const value = opts.theme?.[key];
94
+ if ((typeof value === 'string' || typeof value === 'number') && String(value).length <= 64)
95
+ url.searchParams.set(key, String(value));
96
+ }
97
+ return new Promise((resolve, reject) => {
98
+ const iframe = doc.createElement('iframe');
99
+ iframe.title = 'Alyte consent';
100
+ iframe.src = url.href;
101
+ iframe.referrerPolicy = 'no-referrer';
102
+ iframe.style.width = '100%';
103
+ iframe.style.height = '640px';
104
+ iframe.style.border = '0';
105
+ let done = false, ready = false;
106
+ let timer;
107
+ const cleanup = () => { clearTimeout(timer); host.removeEventListener('message', receive); opts.signal?.removeEventListener('abort', abort); iframe.remove(); };
108
+ const fail = (code) => { if (!done) {
109
+ done = true;
110
+ cleanup();
111
+ reject(new AlyteConsentError(code));
112
+ } };
113
+ const abort = () => fail('consent_cancelled');
114
+ const receive = (event) => {
115
+ if (done || event.origin !== base || event.source !== iframe.contentWindow)
116
+ return;
117
+ const data = event.data;
118
+ if (!data || data.type !== 'alyte:consent' || data.merchantId !== opts.merchantId)
119
+ return;
120
+ if (data.event === 'ready') {
121
+ // Language changes reload this same trusted frame. Each fresh document
122
+ // needs bootstrap; the Alyte page accepts it only once per document.
123
+ ready = true;
124
+ clearTimeout(timer);
125
+ iframe.contentWindow?.postMessage({ type: 'alyte:consent', event: 'bootstrap', bearer: opts.bearer }, base);
126
+ }
127
+ else if (data.event === 'granted' && ready) {
128
+ if (typeof data.agentId !== 'string' || !data.agentId || typeof data.mandateId !== 'string' || !data.mandateId)
129
+ return;
130
+ done = true;
131
+ cleanup();
132
+ resolve({ agentId: data.agentId, mandateId: data.mandateId });
133
+ }
134
+ else if (data.event === 'cancelled')
135
+ abort();
136
+ else if (data.event === 'error' && typeof data.code === 'string')
137
+ fail(data.code);
138
+ else if (data.event === 'resize' && Number.isFinite(data.height))
139
+ iframe.style.height = `${Math.max(240, Math.min(1200, Math.ceil(data.height)))}px`;
140
+ else if (data.event === 'navigate' && typeof data.url === 'string') {
141
+ try {
142
+ const back = new URL(data.url);
143
+ if (back.origin === host.location.origin)
144
+ opts.onNavigate?.(back.href);
145
+ }
146
+ catch { /* Ignore malformed navigation messages. */ }
147
+ }
148
+ };
149
+ if (opts.signal?.aborted) {
150
+ abort();
151
+ return;
152
+ }
153
+ host.addEventListener('message', receive);
154
+ opts.signal?.addEventListener('abort', abort, { once: true });
155
+ timer = setTimeout(() => fail('consent_unavailable'), opts.readyTimeoutMs ?? 15_000);
156
+ iframe.addEventListener('error', () => fail('consent_unavailable'), { once: true });
157
+ opts.container.append(iframe);
158
+ });
159
+ }
@@ -58,6 +58,12 @@ export declare class AlyteMerchant {
58
58
  currency: string;
59
59
  kind: TierKind;
60
60
  availableCount?: number;
61
+ maxQtyPerPurchase?: number | null;
62
+ sellable?: boolean;
63
+ onSaleStart?: string | null;
64
+ onSaleEnd?: string | null;
65
+ allowedGeos?: string[] | null;
66
+ allowedSchemes?: Scheme[] | null;
61
67
  }): Promise<{
62
68
  tier: Tier;
63
69
  }>;
@@ -145,10 +151,21 @@ export declare class AlyteMerchant {
145
151
  * Attest YOUR authenticated user → a single-use redeem link (15-min TTL).
146
152
  * Redirect the user to `baseUrl + redeemPath`; the buyer-session cookie and
147
153
  * the shop's authorize page take over from there.
154
+ * Unknown fields are rejected with 400 and error.details.fields.
148
155
  */
149
156
  mint: (input: {
150
157
  merchantId: string;
151
158
  email: string;
159
+ /** The tier the buyer chose — opens the authorize page as a checkout for it. */
160
+ tierId?: string;
161
+ /** Ticket count hint (1–10), requires tierId; permission and tier limits still govern. */
162
+ quantity?: number;
163
+ /** Back-to-shop link, not an automatic redirect. HTTPS (local HTTP allowed);
164
+ * restricted to registered embed origins when configured. */
165
+ returnUrl?: string;
166
+ /** The buyer's language on YOUR site (BCP-47, e.g. "de" or "de-AT"), so Alyte's
167
+ * pages open in the same language. Presentation only. */
168
+ lang?: string;
152
169
  }) => Promise<BuyerSessionMint>;
153
170
  };
154
171
  }
package/dist/merchant.js CHANGED
@@ -100,6 +100,7 @@ export class AlyteMerchant {
100
100
  * Attest YOUR authenticated user → a single-use redeem link (15-min TTL).
101
101
  * Redirect the user to `baseUrl + redeemPath`; the buyer-session cookie and
102
102
  * the shop's authorize page take over from there.
103
+ * Unknown fields are rejected with 400 and error.details.fields.
103
104
  */
104
105
  mint: (input) => this.t.request('POST', '/v1/integration/buyer-sessions', input),
105
106
  };
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@alytegen/sdk",
3
- "version": "0.3.0",
4
- "description": "Alyte client SDK — merchant integration (catalog, PSP links, buyer sessions, payments visibility) and the agent buy path (discover → quote → hold → confirm).",
3
+ "version": "0.4.0",
4
+ "description": "Alyte client SDK \u2014 merchant integration (catalog, PSP links, buyer sessions, payments visibility) and the agent buy path (discover \u2192 quote \u2192 hold \u2192 confirm).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
+ "./browser": {
10
+ "types": "./dist/browser.d.ts",
11
+ "import": "./dist/browser.js"
12
+ },
9
13
  ".": {
10
14
  "types": "./dist/index.d.ts",
11
15
  "import": "./dist/index.js"
@@ -14,6 +18,7 @@
14
18
  "files": [
15
19
  "dist",
16
20
  "QUICKSTART.md",
21
+ "BROWSER.md",
17
22
  "examples"
18
23
  ],
19
24
  "scripts": {