@fire-spark/core 0.12.0 → 0.12.2
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/dist/index.d.ts +13 -3
- package/dist/index.js +21 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Money, PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentStorage, PaymentUI, RedeemLike, RedeemSource, isRealPaymentMethod, orderRedeems } from "@fire-spark/payments";
|
|
1
|
+
import { Money, PaymentAdapter, PaymentCollectAt, PaymentContext, PaymentResult, PaymentReversal, PaymentStorage, PaymentUI, RedeemLike, RedeemSource, isRealPaymentMethod, orderRedeems } from "@fire-spark/payments";
|
|
2
2
|
import { AndConditions, CheckoutMode, CheckoutResolved, CmsBlock, Condition, Customer, CustomerIdentifyInput, CustomerRegisterInput, CustomerUpdateInput, Fulfillment, FulfillmentListInput, GroupDisplayType, KioskDeviceConfig, KioskDeviceOverrides, KioskHealthBatchInput, KioskHealthBatchResult, KioskHeartbeatInput, KioskHeartbeatResult, KioskRealtimeToken, MatchResult, MatchableRule, Menu, Menu as Menu$1, MenuLookup, MenuLookup as MenuLookup$1, MerchantPayment, ModifierControlType, ModifierGroup, OrConditions, Order as Order$1, Order as Order$2, OrderCancelInput, OrderCancelInput as OrderCancelInput$1, OrderCancelType, OrderCancelType as OrderCancelType$1, OrderDeviceListInput, OrderDeviceListResult, OrderFulfillment, OrderInsertInput, OrderLine, OrderListInput, OrderRecordPaymentInput, OrderRedeem, OrderRedemptionStep, OrderReorderInput, OrderTotals, OrderUpdateInput, OrderValidateInput, OrderValidateOutput, PaymentCollectAt as PaymentCollectAt$1, PaymentIntentPutInput, PaymentMethod, PaymentProvider, PaymentTender, PaymentTenderInput, PlaceOrderResult, PosCatalog, PosFloorInput, PosFloorOccupancy, PosFloorPlan, PosFloorRealtimeToken, PosHealthBatchInput, PosHealthBatchResult, PosHeartbeatInput, PosHeartbeatResult, PosKioskOrder, PosKioskSettleInput, PosKioskSettleResult, PosOrderInput, PosOrderResult, PosTableAttachOrderInput, PosTableCloseInput, PosTableJoinInput, PosTableSeatInput, PosTableSeatReservationInput, PosTableSplitInput, PricingModifier, Product, Product as Product$1, Recommendation, RecurringDateCronResult, RecurringDateCronValues, RulesEngineOrderLine, RulesEngineParams, RulesEngineRuntime, Schedule, SdkLogContext, SdkLogErrorInfo, SdkLogLevel, SdkLogOptions, Store, StoreGetInput, StoreListInput, StoreNearbyInput, StorefrontAvailability, StorefrontMenu, StorefrontMenuScope, StorefrontMenuStreamOptions, StorefrontPaymentsListInput, StorefrontPreferences, TenderRefundInput, TenderReplaceInput, TenderVoidInput, Variant, VariantGroup } from "@fire-spark/types";
|
|
3
3
|
import { Big } from "big.js";
|
|
4
4
|
//#region src/productCustomization/catalog.utils.d.ts
|
|
@@ -167,6 +167,11 @@ type AuthConfigureBase = {
|
|
|
167
167
|
/** Default: exchange an IdP id_token (Firebase, …) for a storefront token. */
|
|
168
168
|
type AuthConfigureSubjectOptions = AuthConfigureBase & {
|
|
169
169
|
getSubjectToken: () => Promise<string>;
|
|
170
|
+
/**
|
|
171
|
+
* OAuth app alias (RFC 8693 `audience`). Required when several merchants
|
|
172
|
+
* share the identity provider (same issuer and audience).
|
|
173
|
+
*/
|
|
174
|
+
audience?: string;
|
|
170
175
|
getAccessToken?: never;
|
|
171
176
|
};
|
|
172
177
|
/**
|
|
@@ -176,11 +181,14 @@ type AuthConfigureSubjectOptions = AuthConfigureBase & {
|
|
|
176
181
|
type AuthConfigureAccessTokenOptions = AuthConfigureBase & {
|
|
177
182
|
getAccessToken: () => Promise<StorefrontAccessToken>;
|
|
178
183
|
getSubjectToken?: never;
|
|
184
|
+
audience?: never;
|
|
179
185
|
};
|
|
180
186
|
type AuthConfigureOptions = AuthConfigureSubjectOptions | AuthConfigureAccessTokenOptions;
|
|
181
187
|
type ExchangeOptions = {
|
|
182
188
|
baseUrl?: string;
|
|
183
189
|
fetchImpl?: typeof fetch;
|
|
190
|
+
/** OAuth app alias (RFC 8693 `audience`) when the provider is shared. */
|
|
191
|
+
audience?: string;
|
|
184
192
|
};
|
|
185
193
|
//#endregion
|
|
186
194
|
//#region src/auth/auth.d.ts
|
|
@@ -313,7 +321,7 @@ type PaymentRunOptions = {
|
|
|
313
321
|
*/
|
|
314
322
|
declare const runPaymentAttempt: (adapter: PaymentAdapter, ctx: PaymentContext, options?: PaymentRunOptions) => Promise<PaymentResult>;
|
|
315
323
|
type ReversalOutcome = {
|
|
316
|
-
kind:
|
|
324
|
+
kind: PaymentReversal;
|
|
317
325
|
result: PaymentResult;
|
|
318
326
|
};
|
|
319
327
|
/** Undo a charge after a failed injection or an incomplete split payment. */
|
|
@@ -422,7 +430,7 @@ type OrderCancelResult = {
|
|
|
422
430
|
path: "cancel" | "refund";
|
|
423
431
|
/** What the device did with each charge it voided. */
|
|
424
432
|
outcomes: ReversalOutcome[];
|
|
425
|
-
/** Tender ids the device
|
|
433
|
+
/** Tender ids neither the device nor the server reversed yet. */
|
|
426
434
|
pending: string[];
|
|
427
435
|
};
|
|
428
436
|
//#endregion
|
|
@@ -1129,6 +1137,8 @@ type DeunaOrderStatus = {
|
|
|
1129
1137
|
order_token: string;
|
|
1130
1138
|
status: string;
|
|
1131
1139
|
transaction_id: string | null;
|
|
1140
|
+
/** Processor DEUNA charged with, when it reports one. */
|
|
1141
|
+
processor?: string | null;
|
|
1132
1142
|
error: {
|
|
1133
1143
|
code: string | null;
|
|
1134
1144
|
message: string | null;
|
package/dist/index.js
CHANGED
|
@@ -1888,7 +1888,8 @@ const exchangeSubjectToken = async (subjectToken, options = {}) => {
|
|
|
1888
1888
|
body: JSON.stringify({
|
|
1889
1889
|
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
|
|
1890
1890
|
subject_token: subjectToken,
|
|
1891
|
-
subject_token_type: "urn:ietf:params:oauth:token-type:id_token"
|
|
1891
|
+
subject_token_type: "urn:ietf:params:oauth:token-type:id_token",
|
|
1892
|
+
...options.audience ? { audience: options.audience } : {}
|
|
1892
1893
|
})
|
|
1893
1894
|
});
|
|
1894
1895
|
if (!response.ok) {
|
|
@@ -1907,6 +1908,7 @@ const configure = (options) => {
|
|
|
1907
1908
|
state = {
|
|
1908
1909
|
getSubjectToken: options.getSubjectToken ?? null,
|
|
1909
1910
|
getDirectToken: options.getAccessToken ?? null,
|
|
1911
|
+
audience: options.audience,
|
|
1910
1912
|
baseUrl: resolveBaseUrl(options.baseUrl),
|
|
1911
1913
|
fetchImpl: options.fetchImpl ?? fetch,
|
|
1912
1914
|
tokenSkewMs: options.tokenSkewMs ?? DEFAULT_TOKEN_SKEW_MS,
|
|
@@ -1928,7 +1930,8 @@ const issueToken = async (current) => {
|
|
|
1928
1930
|
if (!current.getSubjectToken) throw new Error("auth.configure() needs getSubjectToken or getAccessToken");
|
|
1929
1931
|
return exchangeSubjectToken(await current.getSubjectToken(), {
|
|
1930
1932
|
baseUrl: current.baseUrl,
|
|
1931
|
-
fetchImpl: current.fetchImpl
|
|
1933
|
+
fetchImpl: current.fetchImpl,
|
|
1934
|
+
audience: current.audience
|
|
1932
1935
|
});
|
|
1933
1936
|
};
|
|
1934
1937
|
const getAccessToken = async () => {
|
|
@@ -3390,6 +3393,14 @@ const REVERSED_RESULTS = ["REFUNDED", "CANCELLED"];
|
|
|
3390
3393
|
const isDeviceReversed = (reversal) => {
|
|
3391
3394
|
return REVERSED_RESULTS.includes(reversal.outcome.result.status);
|
|
3392
3395
|
};
|
|
3396
|
+
/**
|
|
3397
|
+
* The server ended the tender (`CANCELLED` / `REFUNDED`) in its answer:
|
|
3398
|
+
* a charge it reversed itself (`server` kind) is not pending.
|
|
3399
|
+
*/
|
|
3400
|
+
const isTenderSettled$1 = (order, tenderId) => {
|
|
3401
|
+
const tender = liveTenders(currentIntent(order.payment_intents)).find((item) => item.id === tenderId);
|
|
3402
|
+
return Boolean(tender && REVERSED_RESULTS.includes(tender.status));
|
|
3403
|
+
};
|
|
3393
3404
|
/** Body `tenders` entry for one device reversal. */
|
|
3394
3405
|
const toReportedTender = (reversal) => {
|
|
3395
3406
|
const { tender, outcome } = reversal;
|
|
@@ -4232,6 +4243,10 @@ const reversePayment = async (adapter, ctx, result, options = {}) => {
|
|
|
4232
4243
|
const clock = options.clock ?? defaultClock;
|
|
4233
4244
|
const now = options.now ?? new Date(clock.now());
|
|
4234
4245
|
let kind = (adapter.reversalFor ?? defaultReversalFor)(result, now);
|
|
4246
|
+
if (kind === "server") return {
|
|
4247
|
+
kind,
|
|
4248
|
+
result
|
|
4249
|
+
};
|
|
4235
4250
|
const operation = kind === "cancel" ? adapter.cancel : adapter.refund;
|
|
4236
4251
|
if (kind !== "manual" && !operation) kind = "manual";
|
|
4237
4252
|
if (kind === "manual" || !operation) {
|
|
@@ -6306,7 +6321,10 @@ var Order = class Order {
|
|
|
6306
6321
|
this.deleted = true;
|
|
6307
6322
|
this.notify();
|
|
6308
6323
|
const outcomes = reversals.map((reversal) => reversal.outcome);
|
|
6309
|
-
const pending = reversals.filter((reversal) =>
|
|
6324
|
+
const pending = reversals.filter((reversal) => {
|
|
6325
|
+
if (isDeviceReversed(reversal)) return false;
|
|
6326
|
+
return !isTenderSettled$1(next, reversal.tender.id);
|
|
6327
|
+
}).map((reversal) => reversal.tender.id);
|
|
6310
6328
|
return {
|
|
6311
6329
|
order: this.getOrder(),
|
|
6312
6330
|
type,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fire-spark/core",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Fire Spark headless SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"big.js": "6.2.1",
|
|
21
21
|
"dayjs": "1.11.9",
|
|
22
22
|
"@types/big.js": "6.2.2",
|
|
23
|
-
"@fire-spark/payments": "^0.12.
|
|
24
|
-
"@fire-spark/types": "^0.12.
|
|
23
|
+
"@fire-spark/payments": "^0.12.2",
|
|
24
|
+
"@fire-spark/types": "^0.12.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.22.14",
|