@octap/sdk 0.0.0-stage → 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ ### Added
6
+
7
+ - Voucher expiry webhooks (OCT-336): `voucher.expired` (a voucher's claim window closed while it was
8
+ live, paused or sold out; `VoucherLifecycleEventData`) and `voucher.member_expired` (a customer's
9
+ voucher reached its own deadline unused; `VoucherMemberExpiredEventData`). Each arrives once,
10
+ within about a minute of the deadline.
11
+ - Voucher batches (OCT-303): `createVouchers(items, { dryRun, name })` creates up to 100 vouchers
12
+ as one DRAFT batch (`dryRun` previews each item's result and writes nothing), then
13
+ `activateVoucherBatch`, `pauseVoucherBatch`, `resumeVoucherBatch` and `archiveVoucherBatch` act
14
+ on the whole batch and report each voucher's outcome. Read them with `listVoucherBatches` and
15
+ `getVoucherBatch`.
16
+ - `VoucherDto.batchId`: the batch a voucher was created or re-imported in, `null` otherwise.
17
+ - `parseVoucherCsv(text, { utcOffset })` reads a CSV in the Octap voucher template (the file the
18
+ console imports) into items for `createVouchers`, with the console's checks: each bad row is
19
+ reported with its line and column and left out. Also exported: `VOUCHER_CSV_TEMPLATE`,
20
+ `VOUCHER_CSV_TYPES`, `VOUCHER_BENEFIT_SCHEMA` and `suggestVoucherCode`.
21
+ - The reference documents the `octap.benefit.v1` shape of `terms` the console reads.
22
+ - `VoucherDto.createdBy`, `activatedBy` and `activatedAt` (OCT-324): who created a voucher, who took
23
+ it live (whoever activated it, or the Owner who approved it) and when publishing started. Each is
24
+ `{ type: 'USER' | 'API_CREDENTIAL', id }` or `null` when not recorded.
25
+ - `VoucherApprovalDto.id` and `snapshot`: the submission an Owner decides on, and its terms as
26
+ submitted, which is what approving publishes.
27
+
28
+ ### Changed
29
+
30
+ - `EXPIRED` is now actually written (OCT-336). A voucher past its claim window is `EXPIRED`, not
31
+ `ACTIVE`, and a customer's voucher past its deadline is `EXPIRED`, not `AVAILABLE`, in every read:
32
+ `listVouchers`, `getVoucher`, `listMemberVouchers`, `getClaim` and voucher batches. Pausing or
33
+ resuming an `EXPIRED` voucher is a 409; its supply and metadata stay editable.
34
+
35
+ - `VoucherStatus` has a new value, `ARCHIVED`: a voucher of an archived batch that never went
36
+ live. `listVouchers` and `getVoucher` can return it. It can't be edited, submitted or claimed;
37
+ importing its code in a new batch brings it back as `DRAFT`. Code that switches on `status`
38
+ should handle it.
39
+
40
+ ### Breaking changes
41
+
42
+ The `admin` API key scope is gone. Managing webhooks and the voucher refund policy moved to the
43
+ console, where only the organization's Owner can do it. These methods are removed, because no API
44
+ key can call their routes any more:
45
+
46
+ | Removed | Do it in the console instead |
47
+ | --- | --- |
48
+ | `registerWebhookEndpoint` | Webhooks → register an endpoint |
49
+ | `disableWebhookEndpoint`, `enableWebhookEndpoint` | Webhooks → disable / enable |
50
+ | `rotateWebhookSecret` | Webhooks → rotate the secret |
51
+ | `replayWebhookDelivery` | Webhooks → deliveries → replay |
52
+ | `setVoucherRefundPolicy` | Refund policy → publish |
53
+
54
+ ### Changed
55
+
56
+ - `listVoucherRefundPolicyHistory` needs only a `read` key (it needed `admin`).
57
+ - `reverseTransaction` can refund an expired or redeemed voucher with a `write` key when the refund
58
+ policy allows it. It used to need `admin`; now the policy is the only gate.
59
+ - `VoucherRefundPolicyDto` has a new `createdByUserId`, the Owner who published the version from the
60
+ console. `createdByCredentialId` is set only on versions published with an API key before 0.2.0.
61
+
62
+ `listWebhookEndpoints`, `listWebhookDeliveries`, `getVoucherRefundPolicy` and every other method are
63
+ unchanged.
64
+
65
+ ## 0.1.0
66
+
67
+ First public release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OctaPointees
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,92 @@
1
- # Temporary Holding Version
1
+ # Node merchant SDK
2
+ `src/client.ts` is the merchant client (points and vouchers) over the REST transport in
3
+ `src/transports/`. `src/errors/` holds `OctaSdkError` and `OctaApiError`. `src/webhooks.ts` is
4
+ the receiver side: `verifyWebhookSignature` checks `x-octap-signature`, and
5
+ `constructWebhookEvent` checks it and returns the typed `WebhookEvent` (discriminated on `type`).
6
+ Public DTOs come from the sibling contracts package. Do not import this package into browser code;
7
+ browser helpers have their own package.
2
8
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
9
+ ## Verifying a customer
10
+
11
+ Your frontend gets an id_token from the browser SDK and sends it to your backend. Check it before
12
+ acting for that customer, like Firebase Admin's `verifyIdToken`:
13
+
14
+ ```ts
15
+ const { suiAddress, memberId, active } = await client.verifyCustomer(idToken);
16
+ if (!memberId) {
17
+ // A valid Google sign-in that has not enrolled in your organization yet.
18
+ } else if (!active) {
19
+ // Enrolled, but blocked: reward operations for this member will be refused.
20
+ }
21
+ ```
22
+
23
+ An invalid or expired token throws `OctaApiError` with status 401. The call needs the `read` scope
24
+ and writes nothing. Every merchant shares one OctaP Google client ID, so a token a customer showed
25
+ to another merchant also verifies here: treat it as proof of who the customer is, not of consent to
26
+ anything, and keep spending behind the customer's signature.
27
+
28
+ ## Merchant methods
29
+
30
+ Keep the API key on a trusted Node server. Console/platform session routes and API credential
31
+ management are outside this client. Every method accepts `RequestOptions` with `organizationId`
32
+ and `signal`, including both balance overloads.
33
+
34
+ | Core routes | SDK methods |
35
+ | --- | --- |
36
+ | `POST /v1/credits/earn` | `earnPoints({ organizationEndUserId, purchaseAmount, idempotencyKey })` |
37
+ | `POST /v1/credits/redeem/reserve`, `/finalize` | `reservePosRedemption`, `finalizePosRedemption` |
38
+ | `POST /v1/credits/transactions/:id/reverse` | `reverseTransaction` |
39
+ | `GET /v1/credits/members/:id/balance`, `/transactions` | `getBalance`, `listTransactions` |
40
+ | `GET /v1/credits/budget` | `getIssuanceBudget` |
41
+ | `GET /v1/rewards/refund-policy`, `GET .../history` | `getVoucherRefundPolicy`, `listVoucherRefundPolicyHistory` |
42
+ | `POST/GET /v1/rewards/vouchers`, `GET/PATCH .../:id` | `createVoucher`, `listVouchers`, `getVoucher`, `updateVoucher` |
43
+ | `POST .../vouchers/:id/claim`, `GET .../claims/:id` | `claimVoucher`, `getVoucherClaim` |
44
+ | `POST .../vouchers/:id/grant` | `grantVoucher` |
45
+ | `POST .../vouchers/use`, `/use/finalize` | `prepareVoucherUse`, `finalizeVoucherUse` |
46
+ | `GET .../members/:id/vouchers` | `listMemberVouchers` |
47
+ | `GET /v1/webhooks/endpoints` | `listWebhookEndpoints` |
48
+ | `GET /v1/webhooks/deliveries` | `listWebhookDeliveries` |
49
+
50
+ `finalizeVoucherClaim` is an alias for the shared finalize route. Customer signatures authorize
51
+ finalization; no merchant credential is needed there. A `read` key is enough for every read here; a
52
+ `write` key for the rest. The Owner registers, disables, enables and rotates webhook endpoints, replays
53
+ deliveries and publishes the refund policy in the console, not with a key (removed from the SDK in
54
+ 0.2.0, see `CHANGELOG.md`). List responses never include a webhook secret.
55
+
56
+ ## Earn
57
+
58
+ ```ts
59
+ const accepted = await client.earnPoints({
60
+ organizationEndUserId: memberId,
61
+ purchaseAmount: 100000,
62
+ idempotencyKey: 'purchase-order-42',
63
+ });
64
+ // At 100 bps: estimatedPoints=1000, pointsEarned=null, status=PENDING.
65
+ // Read listTransactions or consume credits.earn.confirmed for the actual point result.
66
+ ```
67
+
68
+ A purchase too small to earn a point is rejected with 400, and an earn the issuance budget cannot cover with 422. An accepted earn that fails sends `credits.earn.failed`; its key stays used, so a retry needs a new key. History shows `pointsAmount: null` and a
69
+ separate `estimatedPoints` until the chain confirms. Core has no operation-status route: observe
70
+ transactions, balance, `getVoucherClaim` or webhooks. To debit points, use `reservePosRedemption`,
71
+ return the bytes to the customer to sign, then call `finalizePosRedemption`.
72
+ `getBalance(programId, memberId, options)` returns 404 for a program outside your organization.
73
+
74
+ ## Errors, cancellation and retries
75
+
76
+ `OctaApiError` exposes `statusCode`, `statusText`, `responseBody`, and `retryAfter` when Core sent
77
+ that header. `OctaNetworkError` preserves the original `cause`. `OctaRequestAbortedError` distinguishes
78
+ cancellation from server rejection. Do not log raw bodies, tokens, signatures or API keys.
79
+
80
+ ```ts
81
+ const controller = new AbortController();
82
+ await client.getBalance(memberId, { signal: controller.signal });
83
+ // controller.abort() cancels local waiting; it does not roll back Core or the chain.
84
+ ```
85
+
86
+ The SDK performs no automatic retries. Retry reads with bounded backoff, and wait `retryAfter` on a 429.
87
+ For earn, reserve, reversal and claim retries, keep the same idempotency key and the same request: a
88
+ retry returns the original transaction, and a changed request under a used key returns 409. After a timeout, cancellation,
89
+ network failure or 5xx, read persisted state first, because the request may have committed. Never switch
90
+ to a new key to recover an unknown outcome. Finalize must reuse the original signature and digest, or
91
+ read the existing claim. Voucher redemption has no idempotency key: read its ownership status before
92
+ retrying. Webhook registration and secret rotation are not idempotent, so do not blindly retry them.
@@ -0,0 +1,150 @@
1
+ import type { BalanceSnapshot, EarnPointsRequest, EarnPointsResponse, IssuanceBudgetDto, CreditBalanceSnapshot, LoyaltyTransactionPage, CreateVoucherRequest, UpdateVoucherRequest, VoucherDto, ClaimVoucherRequest, ClaimVoucherResponse, FinalizePosRedemptionRequest, FinalizePosRedemptionResponse, GrantVoucherRequest, PrepareVoucherUseRequest, PrepareVoucherUseResponse, FinalizeVoucherUseRequest, RedeemVoucherResponse, VoucherOwnershipDto, ListVoucherRefundPolicyHistoryRequest, VoucherRefundPolicyDto, VerifyCustomerResponse, ReservePosRedemptionRequest, ReservePosRedemptionResponse, ReverseTransactionRequest, ReverseTransactionResponse, WebhookEndpointDto, WebhookDeliveryDto, VoucherBatchActionResponse, CreateVoucherBatchResponse, ListVoucherBatchesRequest, VoucherBatchDetailDto, VoucherBatchDto, VoucherBatchItem } from '@octap/contracts';
2
+ import type { Transport } from './transports/transport.js';
3
+ export interface RequestOptions {
4
+ organizationId?: string;
5
+ signal?: AbortSignal;
6
+ }
7
+ export interface OctaPointClientOptions {
8
+ baseUrl?: string;
9
+ transport?: Transport;
10
+ credentials?: {
11
+ apiKey?: string;
12
+ };
13
+ organizationId?: string;
14
+ fetchFn?: typeof fetch;
15
+ }
16
+ export declare class OctaPointClient {
17
+ private readonly baseUrl;
18
+ private readonly apiKey?;
19
+ private readonly defaultOrganizationId?;
20
+ private readonly fetchFn;
21
+ constructor(options?: OctaPointClientOptions);
22
+ private request;
23
+ /**
24
+ * Checks the id_token your frontend got from the browser SDK's `getIdToken()`, like Firebase Admin
25
+ * `verifyIdToken`. Writes nothing. `memberId` is null until the customer enrolls in your
26
+ * organization, and `endUserId` is null if they have never signed in to OctaP.
27
+ */
28
+ verifyCustomer(idToken: string, options?: RequestOptions): Promise<VerifyCustomerResponse>;
29
+ /**
30
+ * Earn loyalty points for an organization member.
31
+ */
32
+ earnPoints(request: EarnPointsRequest, options?: RequestOptions): Promise<EarnPointsResponse>;
33
+ /**
34
+ * Get the credit balance snapshot for a member.
35
+ */
36
+ getBalance(memberId: string, options?: RequestOptions): Promise<CreditBalanceSnapshot>;
37
+ getBalance(programId: string, memberId: string, options?: RequestOptions): Promise<BalanceSnapshot>;
38
+ /** How many more points your program may issue, read live from the chain. */
39
+ getIssuanceBudget(options?: RequestOptions): Promise<IssuanceBudgetDto>;
40
+ /** Reserve POS points; return the bytes to the customer's signing session. */
41
+ reservePosRedemption(request: ReservePosRedemptionRequest, options?: RequestOptions): Promise<ReservePosRedemptionResponse>;
42
+ /** Submit the customer's signature. Cancellation does not undo a submitted transaction. */
43
+ finalizePosRedemption(request: FinalizePosRedemptionRequest, options?: RequestOptions): Promise<FinalizePosRedemptionResponse>;
44
+ reverseTransaction(request: ReverseTransactionRequest, options?: RequestOptions): Promise<ReverseTransactionResponse>;
45
+ /**
46
+ * One page of a member's loyalty transactions, newest first. `limit` 1–100 (default 25). Pass the
47
+ * returned `nextCursor` as `cursor` for the next page; it is `null` on the last page.
48
+ */
49
+ listTransactions(memberId: string, options?: RequestOptions & {
50
+ limit?: number;
51
+ cursor?: string;
52
+ }): Promise<LoyaltyTransactionPage>;
53
+ /** The policy the next published voucher takes. A published voucher keeps the one it was published with. */
54
+ getVoucherRefundPolicy(options?: RequestOptions): Promise<VoucherRefundPolicyDto>;
55
+ /**
56
+ * Lists immutable policy versions, newest first. The Owner publishes a new version from the console;
57
+ * no API key can.
58
+ */
59
+ listVoucherRefundPolicyHistory(query?: ListVoucherRefundPolicyHistoryRequest, options?: RequestOptions): Promise<VoucherRefundPolicyDto[]>;
60
+ /**
61
+ * Create a new voucher definition. A `code` already used in your organization is a 409: if a create
62
+ * timed out or its response was lost, the voucher may exist anyway, so find it with `listVouchers`
63
+ * instead of creating it again.
64
+ */
65
+ createVoucher(request: CreateVoucherRequest, options?: RequestOptions): Promise<VoucherDto>;
66
+ /** Edit a reward or set its status to DRAFT, ACTIVE or PAUSED. */
67
+ updateVoucher(voucherId: string, request: UpdateVoucherRequest, options?: RequestOptions): Promise<VoucherDto>;
68
+ /**
69
+ * List all vouchers for the organization.
70
+ */
71
+ listVouchers(options?: RequestOptions): Promise<VoucherDto[]>;
72
+ /**
73
+ * Get a specific voucher by its ID.
74
+ */
75
+ getVoucher(voucherId: string, options?: RequestOptions): Promise<VoucherDto>;
76
+ /**
77
+ * Creates up to `VOUCHER_BATCH_MAX_ITEMS` vouchers as one DRAFT batch (OCT-303). Each item is
78
+ * checked and written on its own, and `items[i]` of the response says what happened to `items[i]`:
79
+ * `created`, `unchanged` (already there with the same values, so sending the same list again is
80
+ * safe), `conflict` (that `code` holds other values and is kept), `replaced` (a draft of an archived
81
+ * batch now holds these values) or `error`. With `dryRun`, nothing is written: use it to preview.
82
+ * Nothing goes live until `activateVoucherBatch`. `name` labels the batch (up to 120 characters).
83
+ */
84
+ createVouchers(items: VoucherBatchItem[], batchOptions?: {
85
+ dryRun?: boolean;
86
+ name?: string;
87
+ }, options?: RequestOptions): Promise<CreateVoucherBatchResponse>;
88
+ /** Batches, newest first; archived ones only with `includeArchived`. */
89
+ listVoucherBatches(query?: ListVoucherBatchesRequest, options?: RequestOptions): Promise<VoucherBatchDto[]>;
90
+ /** A batch with its vouchers. */
91
+ getVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchDetailDto>;
92
+ /**
93
+ * Activates every DRAFT voucher of the batch: each one starts publishing on-chain, or waits for an
94
+ * Owner when the organization requires approval. A voucher that can't go live stays DRAFT, with a
95
+ * `reason`; one already published or waiting is `skipped`, so calling it again is safe. Publishing
96
+ * is done by a worker a few vouchers at a time, so a large batch takes minutes to be fully live.
97
+ */
98
+ activateVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
99
+ /**
100
+ * Pauses every voucher of the batch that is on-chain: members can't claim them any more, and the
101
+ * vouchers they hold stay usable. Drafts and vouchers waiting for approval are `skipped`. Archiving
102
+ * a batch doesn't stop claims; this does.
103
+ */
104
+ pauseVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
105
+ /** Resumes every paused voucher of the batch that is published. Resuming needs no approval. */
106
+ resumeVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
107
+ /**
108
+ * For a batch you won't use (a wrong file, a cancelled campaign). The batch is hidden and can't be
109
+ * activated again, and each of its vouchers that never went live becomes `ARCHIVED` (one waiting
110
+ * for approval is withdrawn): it can't be edited or go live any more. Live vouchers stay live;
111
+ * pause the batch to stop claims. Importing an archived voucher's code again brings it back as a
112
+ * DRAFT in the new batch. There is no un-archive.
113
+ */
114
+ archiveVoucherBatch(batchId: string, options?: RequestOptions): Promise<VoucherBatchActionResponse>;
115
+ /**
116
+ * Reserve a voucher; paid claims return customer-signable bytes and remain RESERVED until chain confirmation.
117
+ */
118
+ claimVoucher(voucherId: string, request: ClaimVoucherRequest, options?: RequestOptions): Promise<ClaimVoucherResponse>;
119
+ /** Read persisted claim state after finalize or asynchronous chain recovery. */
120
+ getVoucherClaim(ownershipId: string, options?: RequestOptions): Promise<ClaimVoucherResponse>;
121
+ /** The customer signs returned transactionBytes with their zkLogin session; no merchant key is needed by finalize. */
122
+ finalizeVoucherClaim(request: FinalizePosRedemptionRequest, options?: RequestOptions): Promise<FinalizePosRedemptionResponse>;
123
+ /**
124
+ * Give a customer a voucher without spending their points. It stays RESERVED until the chain
125
+ * records it; `voucher.granted` reports that.
126
+ */
127
+ grantVoucher(voucherId: string, request: GrantVoucherRequest, options?: RequestOptions): Promise<ClaimVoucherResponse>;
128
+ /**
129
+ * Ask the customer to use a voucher. Returns bytes for their device to sign: your API key cannot
130
+ * mark a voucher used. Deliver the benefit on the `voucher.redeemed` webhook.
131
+ */
132
+ prepareVoucherUse(request: PrepareVoucherUseRequest, options?: RequestOptions): Promise<PrepareVoucherUseResponse>;
133
+ /** The customer signs the returned bytes with their zkLogin session; finalize needs no merchant key. */
134
+ finalizeVoucherUse(request: FinalizeVoucherUseRequest, options?: RequestOptions): Promise<RedeemVoucherResponse>;
135
+ /**
136
+ * List all vouchers claimed/owned by a member.
137
+ */
138
+ listMemberVouchers(memberId: string, options?: RequestOptions): Promise<VoucherOwnershipDto[]>;
139
+ /**
140
+ * The organization's webhook endpoints, without their secrets. The Owner registers, disables,
141
+ * enables and rotates them from the console; no API key can.
142
+ */
143
+ listWebhookEndpoints(options?: RequestOptions): Promise<WebhookEndpointDto[]>;
144
+ /** Recent deliveries, newest first. The Owner replays a dead-lettered one from the console. */
145
+ listWebhookDeliveries(options?: RequestOptions): Promise<WebhookDeliveryDto[]>;
146
+ }
147
+ /**
148
+ * Convenience factory to instantiate the client.
149
+ */
150
+ export declare function createOctaPointClient(options?: OctaPointClientOptions): OctaPointClient;
package/dist/client.js ADDED
@@ -0,0 +1,297 @@
1
+ import { OctaApiError, OctaSdkError, OctaNetworkError, OctaRequestAbortedError } from './errors/index.js';
2
+ function toTransportError(err, signal) {
3
+ return signal?.aborted || (err instanceof Error && err.name === 'AbortError')
4
+ ? new OctaRequestAbortedError(err)
5
+ : new OctaNetworkError(err);
6
+ }
7
+ export class OctaPointClient {
8
+ baseUrl;
9
+ apiKey;
10
+ defaultOrganizationId;
11
+ fetchFn;
12
+ constructor(options = {}) {
13
+ let resolvedBaseUrl = options.baseUrl;
14
+ if (!resolvedBaseUrl && options.transport && options.transport.kind === 'rest') {
15
+ resolvedBaseUrl = options.transport.baseUrl;
16
+ }
17
+ this.baseUrl = (resolvedBaseUrl ?? 'http://localhost:3000').replace(/\/+$/, '');
18
+ this.apiKey = options.credentials?.apiKey;
19
+ this.defaultOrganizationId = options.organizationId;
20
+ if (options.fetchFn) {
21
+ this.fetchFn = options.fetchFn;
22
+ }
23
+ else if (options.transport && options.transport.kind === 'rest' && options.transport.fetchFn) {
24
+ this.fetchFn = options.transport.fetchFn;
25
+ }
26
+ else if (typeof fetch !== 'undefined') {
27
+ this.fetchFn = fetch;
28
+ }
29
+ else {
30
+ throw new OctaSdkError('Global fetch is not available in this runtime environment.');
31
+ }
32
+ }
33
+ async request(path, method = 'GET', body, options, queryParams) {
34
+ let url = `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;
35
+ if (queryParams) {
36
+ const searchParams = new URLSearchParams();
37
+ for (const [key, value] of Object.entries(queryParams)) {
38
+ if (value !== undefined) {
39
+ searchParams.append(key, String(value));
40
+ }
41
+ }
42
+ const qs = searchParams.toString();
43
+ if (qs) {
44
+ url += `${url.includes('?') ? '&' : '?'}${qs}`;
45
+ }
46
+ }
47
+ const headers = {
48
+ accept: 'application/json',
49
+ };
50
+ if (body !== undefined) {
51
+ headers['content-type'] = 'application/json';
52
+ }
53
+ if (this.apiKey) {
54
+ headers['authorization'] = `Bearer ${this.apiKey}`;
55
+ }
56
+ const orgId = options?.organizationId ?? this.defaultOrganizationId;
57
+ if (orgId) {
58
+ headers['x-organization-id'] = orgId;
59
+ }
60
+ let response;
61
+ try {
62
+ response = await this.fetchFn(url, {
63
+ method,
64
+ headers,
65
+ body: body !== undefined ? JSON.stringify(body) : undefined,
66
+ signal: options?.signal,
67
+ });
68
+ }
69
+ catch (err) {
70
+ throw toTransportError(err, options?.signal);
71
+ }
72
+ let responseData = null;
73
+ const contentType = response.headers.get('content-type') ?? '';
74
+ try {
75
+ responseData = contentType.includes('application/json') ? await response.json() : await response.text();
76
+ }
77
+ catch (err) {
78
+ if (!(err instanceof SyntaxError))
79
+ throw toTransportError(err, options?.signal);
80
+ }
81
+ if (!response.ok) {
82
+ throw new OctaApiError(response.status, response.statusText, responseData, undefined, response.headers.get('retry-after') ?? undefined);
83
+ }
84
+ return responseData;
85
+ }
86
+ // ==========================================
87
+ // IDENTITY API
88
+ // ==========================================
89
+ /**
90
+ * Checks the id_token your frontend got from the browser SDK's `getIdToken()`, like Firebase Admin
91
+ * `verifyIdToken`. Writes nothing. `memberId` is null until the customer enrolls in your
92
+ * organization, and `endUserId` is null if they have never signed in to OctaP.
93
+ */
94
+ async verifyCustomer(idToken, options) {
95
+ return this.request('/v1/identity/verify', 'POST', { idToken }, options);
96
+ }
97
+ // ==========================================
98
+ // POINTS & CREDITS API
99
+ // ==========================================
100
+ /**
101
+ * Earn loyalty points for an organization member.
102
+ */
103
+ async earnPoints(request, options) {
104
+ return this.request('/v1/credits/earn', 'POST', request, options);
105
+ }
106
+ async getBalance(arg1, arg2, options) {
107
+ const programId = typeof arg2 === 'string' ? arg1 : undefined;
108
+ const memberId = typeof arg2 === 'string' ? arg2 : arg1;
109
+ const snapshot = await this.request(`/v1/credits/members/${encodeURIComponent(memberId)}/balance`, 'GET', undefined, typeof arg2 === 'string' ? options : arg2, { programId });
110
+ if (programId === undefined)
111
+ return snapshot;
112
+ return {
113
+ confirmed_balance: String(snapshot.confirmedBalance),
114
+ pending_earn: String(snapshot.pendingEarn),
115
+ pending_redemption: String(snapshot.pendingRedemption),
116
+ as_of_checkpoint: snapshot.asOfCheckpoint ?? '0',
117
+ observed_at: snapshot.observedAt,
118
+ stale: snapshot.stale,
119
+ };
120
+ }
121
+ /** How many more points your program may issue, read live from the chain. */
122
+ async getIssuanceBudget(options) {
123
+ return this.request('/v1/credits/budget', 'GET', undefined, options);
124
+ }
125
+ /** Reserve POS points; return the bytes to the customer's signing session. */
126
+ async reservePosRedemption(request, options) {
127
+ return this.request('/v1/credits/redeem/reserve', 'POST', request, options);
128
+ }
129
+ /** Submit the customer's signature. Cancellation does not undo a submitted transaction. */
130
+ async finalizePosRedemption(request, options) {
131
+ return this.request('/v1/credits/redeem/finalize', 'POST', request, options);
132
+ }
133
+ async reverseTransaction(request, options) {
134
+ const { transactionId, ...body } = request;
135
+ return this.request(`/v1/credits/transactions/${encodeURIComponent(transactionId)}/reverse`, 'POST', body, options);
136
+ }
137
+ /**
138
+ * One page of a member's loyalty transactions, newest first. `limit` 1–100 (default 25). Pass the
139
+ * returned `nextCursor` as `cursor` for the next page; it is `null` on the last page.
140
+ */
141
+ async listTransactions(memberId, options) {
142
+ return this.request(`/v1/credits/members/${encodeURIComponent(memberId)}/transactions`, 'GET', undefined, options, { limit: options?.limit, cursor: options?.cursor });
143
+ }
144
+ // ==========================================
145
+ // REWARDS & VOUCHERS API
146
+ // ==========================================
147
+ /** The policy the next published voucher takes. A published voucher keeps the one it was published with. */
148
+ async getVoucherRefundPolicy(options) {
149
+ return this.request('/v1/rewards/refund-policy', 'GET', undefined, options);
150
+ }
151
+ /**
152
+ * Lists immutable policy versions, newest first. The Owner publishes a new version from the console;
153
+ * no API key can.
154
+ */
155
+ async listVoucherRefundPolicyHistory(query = {}, options) {
156
+ return this.request('/v1/rewards/refund-policy/history', 'GET', undefined, options, {
157
+ limit: query.limit,
158
+ beforeVersion: query.beforeVersion,
159
+ });
160
+ }
161
+ /**
162
+ * Create a new voucher definition. A `code` already used in your organization is a 409: if a create
163
+ * timed out or its response was lost, the voucher may exist anyway, so find it with `listVouchers`
164
+ * instead of creating it again.
165
+ */
166
+ async createVoucher(request, options) {
167
+ return this.request('/v1/rewards/vouchers', 'POST', request, options);
168
+ }
169
+ /** Edit a reward or set its status to DRAFT, ACTIVE or PAUSED. */
170
+ async updateVoucher(voucherId, request, options) {
171
+ return this.request(`/v1/rewards/vouchers/${encodeURIComponent(voucherId)}`, 'PATCH', request, options);
172
+ }
173
+ /**
174
+ * List all vouchers for the organization.
175
+ */
176
+ async listVouchers(options) {
177
+ return this.request('/v1/rewards/vouchers', 'GET', undefined, options);
178
+ }
179
+ /**
180
+ * Get a specific voucher by its ID.
181
+ */
182
+ async getVoucher(voucherId, options) {
183
+ return this.request(`/v1/rewards/vouchers/${encodeURIComponent(voucherId)}`, 'GET', undefined, options);
184
+ }
185
+ /**
186
+ * Creates up to `VOUCHER_BATCH_MAX_ITEMS` vouchers as one DRAFT batch (OCT-303). Each item is
187
+ * checked and written on its own, and `items[i]` of the response says what happened to `items[i]`:
188
+ * `created`, `unchanged` (already there with the same values, so sending the same list again is
189
+ * safe), `conflict` (that `code` holds other values and is kept), `replaced` (a draft of an archived
190
+ * batch now holds these values) or `error`. With `dryRun`, nothing is written: use it to preview.
191
+ * Nothing goes live until `activateVoucherBatch`. `name` labels the batch (up to 120 characters).
192
+ */
193
+ async createVouchers(items, batchOptions = {}, options) {
194
+ return this.request('/v1/rewards/voucher-batches', 'POST', {
195
+ items,
196
+ ...(batchOptions.dryRun !== undefined ? { dryRun: batchOptions.dryRun } : {}),
197
+ ...(batchOptions.name !== undefined ? { name: batchOptions.name } : {}),
198
+ }, options);
199
+ }
200
+ /** Batches, newest first; archived ones only with `includeArchived`. */
201
+ async listVoucherBatches(query = {}, options) {
202
+ return this.request('/v1/rewards/voucher-batches', 'GET', undefined, options, {
203
+ includeArchived: query.includeArchived === undefined ? undefined : String(query.includeArchived),
204
+ });
205
+ }
206
+ /** A batch with its vouchers. */
207
+ async getVoucherBatch(batchId, options) {
208
+ return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}`, 'GET', undefined, options);
209
+ }
210
+ /**
211
+ * Activates every DRAFT voucher of the batch: each one starts publishing on-chain, or waits for an
212
+ * Owner when the organization requires approval. A voucher that can't go live stays DRAFT, with a
213
+ * `reason`; one already published or waiting is `skipped`, so calling it again is safe. Publishing
214
+ * is done by a worker a few vouchers at a time, so a large batch takes minutes to be fully live.
215
+ */
216
+ async activateVoucherBatch(batchId, options) {
217
+ return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/activate`, 'POST', undefined, options);
218
+ }
219
+ /**
220
+ * Pauses every voucher of the batch that is on-chain: members can't claim them any more, and the
221
+ * vouchers they hold stay usable. Drafts and vouchers waiting for approval are `skipped`. Archiving
222
+ * a batch doesn't stop claims; this does.
223
+ */
224
+ async pauseVoucherBatch(batchId, options) {
225
+ return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/pause`, 'POST', undefined, options);
226
+ }
227
+ /** Resumes every paused voucher of the batch that is published. Resuming needs no approval. */
228
+ async resumeVoucherBatch(batchId, options) {
229
+ return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/resume`, 'POST', undefined, options);
230
+ }
231
+ /**
232
+ * For a batch you won't use (a wrong file, a cancelled campaign). The batch is hidden and can't be
233
+ * activated again, and each of its vouchers that never went live becomes `ARCHIVED` (one waiting
234
+ * for approval is withdrawn): it can't be edited or go live any more. Live vouchers stay live;
235
+ * pause the batch to stop claims. Importing an archived voucher's code again brings it back as a
236
+ * DRAFT in the new batch. There is no un-archive.
237
+ */
238
+ async archiveVoucherBatch(batchId, options) {
239
+ return this.request(`/v1/rewards/voucher-batches/${encodeURIComponent(batchId)}/archive`, 'POST', undefined, options);
240
+ }
241
+ /**
242
+ * Reserve a voucher; paid claims return customer-signable bytes and remain RESERVED until chain confirmation.
243
+ */
244
+ async claimVoucher(voucherId, request, options) {
245
+ return this.request(`/v1/rewards/vouchers/${encodeURIComponent(voucherId)}/claim`, 'POST', request, options);
246
+ }
247
+ /** Read persisted claim state after finalize or asynchronous chain recovery. */
248
+ async getVoucherClaim(ownershipId, options) {
249
+ return this.request(`/v1/rewards/claims/${encodeURIComponent(ownershipId)}`, 'GET', undefined, options);
250
+ }
251
+ /** The customer signs returned transactionBytes with their zkLogin session; no merchant key is needed by finalize. */
252
+ async finalizeVoucherClaim(request, options) {
253
+ return this.request('/v1/credits/redeem/finalize', 'POST', request, options);
254
+ }
255
+ /**
256
+ * Give a customer a voucher without spending their points. It stays RESERVED until the chain
257
+ * records it; `voucher.granted` reports that.
258
+ */
259
+ async grantVoucher(voucherId, request, options) {
260
+ return this.request(`/v1/rewards/vouchers/${encodeURIComponent(voucherId)}/grant`, 'POST', request, options);
261
+ }
262
+ /**
263
+ * Ask the customer to use a voucher. Returns bytes for their device to sign: your API key cannot
264
+ * mark a voucher used. Deliver the benefit on the `voucher.redeemed` webhook.
265
+ */
266
+ async prepareVoucherUse(request, options) {
267
+ return this.request('/v1/rewards/vouchers/use', 'POST', request, options);
268
+ }
269
+ /** The customer signs the returned bytes with their zkLogin session; finalize needs no merchant key. */
270
+ async finalizeVoucherUse(request, options) {
271
+ return this.request('/v1/rewards/vouchers/use/finalize', 'POST', request, options);
272
+ }
273
+ /**
274
+ * List all vouchers claimed/owned by a member.
275
+ */
276
+ async listMemberVouchers(memberId, options) {
277
+ return this.request(`/v1/rewards/members/${encodeURIComponent(memberId)}/vouchers`, 'GET', undefined, options);
278
+ }
279
+ /**
280
+ * The organization's webhook endpoints, without their secrets. The Owner registers, disables,
281
+ * enables and rotates them from the console; no API key can.
282
+ */
283
+ async listWebhookEndpoints(options) {
284
+ return this.request('/v1/webhooks/endpoints', 'GET', undefined, options);
285
+ }
286
+ /** Recent deliveries, newest first. The Owner replays a dead-lettered one from the console. */
287
+ async listWebhookDeliveries(options) {
288
+ return this.request('/v1/webhooks/deliveries', 'GET', undefined, options);
289
+ }
290
+ }
291
+ /**
292
+ * Convenience factory to instantiate the client.
293
+ */
294
+ export function createOctaPointClient(options = {}) {
295
+ return new OctaPointClient(options);
296
+ }
297
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE1G,SAAS,gBAAgB,CAAC,GAAY,EAAE,MAAoB;IAC1D,OAAO,MAAM,EAAE,OAAO,IAAI,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC;QAC3E,CAAC,CAAC,IAAI,uBAAuB,CAAC,GAAG,CAAC;QAClC,CAAC,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAiBD,MAAM,OAAO,eAAe;IACT,OAAO,CAAS;IAChB,MAAM,CAAU;IAChB,qBAAqB,CAAU;IAC/B,OAAO,CAAe;IAEvC,YAAY,UAAkC,EAAE;QAC9C,IAAI,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,eAAe,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,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