@voltro/plugin-economy 0.0.0-stage → 0.88.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 +24492 -0
- package/LICENSE +61 -0
- package/README.md +2719 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +9841 -0
- package/dist/amount.js +20 -0
- package/dist/appleIap.server.js +262 -0
- package/dist/appleIapNotifications.server.js +162 -0
- package/dist/appleIapTrust.server.js +30 -0
- package/dist/bundleValue.server.js +112 -0
- package/dist/canonicalDataJson.js +10 -0
- package/dist/capture.js +53 -0
- package/dist/codePort.fixture.js +123 -0
- package/dist/codeStore.server.js +439 -0
- package/dist/codeTables.entity.js +43 -0
- package/dist/codes.d.ts +150 -0
- package/dist/codes.js +82 -0
- package/dist/components.d.ts +397 -0
- package/dist/components.js +283 -0
- package/dist/consistency.server.js +115 -0
- package/dist/containerStore.server.js +687 -0
- package/dist/containerStore.testFixtures.js +75 -0
- package/dist/containerTables.entity.js +45 -0
- package/dist/containers.d.ts +311 -0
- package/dist/containers.fixture.js +128 -0
- package/dist/containers.js +214 -0
- package/dist/containers.server.js +39 -0
- package/dist/containersPort.fixture.js +74 -0
- package/dist/currency.js +32 -0
- package/dist/declarationFixtures.js +61 -0
- package/dist/economy-app/events/economy.refundReversed.event.ts +1 -0
- package/dist/economy-app/events/economy.refunded.event.ts +1 -0
- package/dist/economyPort.fixture.js +124 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +21 -0
- package/dist/events.d.ts +46 -0
- package/dist/events.js +1 -0
- package/dist/googleIap.server.js +391 -0
- package/dist/googleIapNotifications.server.js +130 -0
- package/dist/googleIapSubscription.server.js +183 -0
- package/dist/iap.d.ts +309 -0
- package/dist/iap.js +303 -0
- package/dist/iap.testFixtures.js +144 -0
- package/dist/iapAccountTables.entity.js +39 -0
- package/dist/iapAccounts.server.js +200 -0
- package/dist/iapBinding.server.js +523 -0
- package/dist/iapCheckout.server.js +97 -0
- package/dist/iapCompletion.server.js +55 -0
- package/dist/iapCurrentState.server.js +107 -0
- package/dist/iapCurrentState.testFixtures.js +22 -0
- package/dist/iapCurrentStatePort.fixture.js +63 -0
- package/dist/iapEntitlements.d.ts +79 -0
- package/dist/iapEntitlements.js +57 -0
- package/dist/iapEntitlements.server.js +48 -0
- package/dist/iapEntitlementsBinding.server.js +105 -0
- package/dist/iapEntitlementsPort.fixture.js +80 -0
- package/dist/iapInstalledEntitlements.testFixtures.js +75 -0
- package/dist/iapInstalledNotifications.testFixtures.js +93 -0
- package/dist/iapInventoryRefunds.server.js +261 -0
- package/dist/iapNotificationCustodyPort.fixture.js +67 -0
- package/dist/iapNotificationPort.fixture.js +73 -0
- package/dist/iapNotificationProcessor.server.js +134 -0
- package/dist/iapNotificationProcessor.testFixtures.js +63 -0
- package/dist/iapNotificationProcessorPort.fixture.js +55 -0
- package/dist/iapNotificationSchedule.server.js +69 -0
- package/dist/iapNotificationStore.server.js +352 -0
- package/dist/iapNotificationStore.testFixtures.js +31 -0
- package/dist/iapNotificationTables.entity.js +48 -0
- package/dist/iapNotificationTarget.server.js +36 -0
- package/dist/iapNotificationTarget.testFixtures.js +29 -0
- package/dist/iapNotifications.d.ts +644 -0
- package/dist/iapNotifications.js +6 -0
- package/dist/iapNotifications.server.js +95 -0
- package/dist/iapNotificationsBinding.server.js +232 -0
- package/dist/iapNotificationsSystemPort.fixture.js +50 -0
- package/dist/iapPlugin.testFixtures.js +59 -0
- package/dist/iapPort.fixture.js +74 -0
- package/dist/iapProviderCapture.server.js +17 -0
- package/dist/iapRecovery.d.ts +146 -0
- package/dist/iapRecovery.js +89 -0
- package/dist/iapRefundEventDelivery.server.js +82 -0
- package/dist/iapRefundEvents.js +44 -0
- package/dist/iapRefundEventsPort.fixture.js +59 -0
- package/dist/iapRefundPort.fixture.js +54 -0
- package/dist/iapRefundTables.entity.js +55 -0
- package/dist/iapRefunds.d.ts +755 -0
- package/dist/iapRefunds.js +6 -0
- package/dist/iapRefunds.server.js +553 -0
- package/dist/iapRefunds.testFixtures.js +64 -0
- package/dist/iapSpendAdmission.server.js +98 -0
- package/dist/iapStore.server.js +740 -0
- package/dist/iapStore.testFixtures.js +127 -0
- package/dist/iapTables.entity.js +80 -0
- package/dist/iapVerification.server.js +120 -0
- package/dist/index.d.ts +2984 -0
- package/dist/index.js +15 -0
- package/dist/intentionRecovery.js +133 -0
- package/dist/ledger.js +77 -0
- package/dist/loyalty.d.ts +274 -0
- package/dist/loyalty.fixture.js +92 -0
- package/dist/loyalty.js +311 -0
- package/dist/loyaltyBinding.server.js +203 -0
- package/dist/loyaltyPort.fixture.js +86 -0
- package/dist/loyaltyShopSource.server.js +90 -0
- package/dist/loyaltyStore.server.js +552 -0
- package/dist/loyaltyStore.testFixtures.js +82 -0
- package/dist/loyaltyTables.entity.js +49 -0
- package/dist/offerMerchandising.fixture.js +114 -0
- package/dist/offerMerchandising.js +282 -0
- package/dist/offerPolicies.d.ts +441 -0
- package/dist/offerPolicies.fixture.js +53 -0
- package/dist/offerPolicies.js +267 -0
- package/dist/piggyBanks.d.ts +272 -0
- package/dist/piggyBanks.fixture.js +70 -0
- package/dist/piggyBanks.js +200 -0
- package/dist/piggyBinding.server.js +204 -0
- package/dist/piggyPort.fixture.js +72 -0
- package/dist/piggyStore.server.js +610 -0
- package/dist/piggyStore.testFixtures.js +97 -0
- package/dist/piggyTables.entity.js +40 -0
- package/dist/plugin.js +1047 -0
- package/dist/port.js +12 -0
- package/dist/price.d.ts +99 -0
- package/dist/price.js +143 -0
- package/dist/purchaseRecovery.js +55 -0
- package/dist/reports.server.js +114 -0
- package/dist/rpc.d.ts +3201 -0
- package/dist/rpc.js +1200 -0
- package/dist/sanctionsTradeAuthority.server.js +79 -0
- package/dist/server.d.ts +3856 -0
- package/dist/server.js +43 -0
- package/dist/shop.d.ts +279 -0
- package/dist/shop.js +195 -0
- package/dist/shop.testFixtures.js +113 -0
- package/dist/shopPort.fixture.js +71 -0
- package/dist/shopPresentation.js +67 -0
- package/dist/shopStore.server.js +623 -0
- package/dist/shopTables.entity.js +62 -0
- package/dist/shopUiCopy.js +56 -0
- package/dist/spendLimits.d.ts +140 -0
- package/dist/spendLimits.fixture.js +52 -0
- package/dist/spendLimits.js +154 -0
- package/dist/spendLimitsPort.fixture.js +119 -0
- package/dist/subscriptionBinding.server.js +210 -0
- package/dist/subscriptionStore.server.js +642 -0
- package/dist/subscriptionStore.testFixtures.js +71 -0
- package/dist/subscriptionTables.entity.js +36 -0
- package/dist/subscriptions.d.ts +394 -0
- package/dist/subscriptions.fixture.js +96 -0
- package/dist/subscriptions.js +212 -0
- package/dist/subscriptionsPort.fixture.js +75 -0
- package/dist/systemFixtures.js +88 -0
- package/dist/tables.entity.js +82 -0
- package/dist/testing.d.ts +4615 -0
- package/dist/testing.js +29 -0
- package/dist/tradeAuthority.server.js +171 -0
- package/dist/tradeBinding.server.js +200 -0
- package/dist/tradeComponents.js +341 -0
- package/dist/tradeEscrow.server.js +231 -0
- package/dist/tradeEscrow.testFixtures.js +132 -0
- package/dist/tradeExpiry.server.js +42 -0
- package/dist/tradeRecovery.js +47 -0
- package/dist/tradeStore.server.js +749 -0
- package/dist/tradeStore.testFixtures.js +72 -0
- package/dist/tradeTables.entity.js +65 -0
- package/dist/tradeUiCopy.js +78 -0
- package/dist/trades.d.ts +246 -0
- package/dist/trades.fixture.js +102 -0
- package/dist/trades.js +288 -0
- package/dist/tradesPort.fixture.js +93 -0
- package/dist/walletEscrow.js +105 -0
- package/dist/walletEscrow.server.js +375 -0
- package/dist/walletKeys.server.js +4 -0
- package/dist/walletStore.js +570 -0
- package/dist/web.d.ts +2257 -0
- package/dist/web.js +8 -0
- package/package.json +161 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { economyError as e } from "./errors.js";
|
|
2
|
+
import { economyTables as t } from "./tables.entity.js";
|
|
3
|
+
import { dataStoreEconomy as n } from "./walletStore.js";
|
|
4
|
+
import { iapAccountTables as r } from "./iapAccountTables.entity.js";
|
|
5
|
+
import { dataStoreIapAccounts as i } from "./iapAccounts.server.js";
|
|
6
|
+
import { iapVerificationPort as a } from "./iapVerification.server.js";
|
|
7
|
+
import { iapTables as o } from "./iapTables.entity.js";
|
|
8
|
+
import { dataStoreIap as s } from "./iapStore.server.js";
|
|
9
|
+
import { iapTestFixture as c } from "./iap.testFixtures.js";
|
|
10
|
+
import { Effect as l } from "effect";
|
|
11
|
+
import { systemSubject as u } from "@voltro/protocol";
|
|
12
|
+
import { randomBytes as d, randomUUID as f } from "node:crypto";
|
|
13
|
+
import { boolean as p, ensureTableRegistered as m, eq as h, id as g, integer as _, queryFor as v, table as y, text as b } from "@voltro/database";
|
|
14
|
+
import { prepareSqlMutation as x } from "@voltro/database/sql";
|
|
15
|
+
import { dataStoreCatalog as S, dataStoreInventory as C, inventoryTables as w } from "@voltro/plugin-inventory/server";
|
|
16
|
+
import { inventoryFixture as T } from "@voltro/plugin-inventory/testing";
|
|
17
|
+
// src/iapStore.testFixtures.ts
|
|
18
|
+
var E = y("_voltro_test_iap_policy", {
|
|
19
|
+
id: g({ prefix: "tip" }),
|
|
20
|
+
tenantId: b().maxLength(120).externalId(),
|
|
21
|
+
allowed: p(),
|
|
22
|
+
admission: _()
|
|
23
|
+
}).index(["tenantId"]), D = [
|
|
24
|
+
...t,
|
|
25
|
+
...w,
|
|
26
|
+
...o,
|
|
27
|
+
...r,
|
|
28
|
+
E
|
|
29
|
+
], O = async (t, r = "test.tenant", o = 4096, p = {}) => {
|
|
30
|
+
D.forEach(m);
|
|
31
|
+
let g = c(), _ = f(), { item: y, content: b } = T(), w = u("iap.fixture"), O = S(t, {
|
|
32
|
+
items: [y],
|
|
33
|
+
now: () => g.at
|
|
34
|
+
});
|
|
35
|
+
await l.runPromise(O.importSnapshot(w, {
|
|
36
|
+
tenantId: r,
|
|
37
|
+
channel: "live",
|
|
38
|
+
locale: "en",
|
|
39
|
+
revision: "iap.fixture.r1",
|
|
40
|
+
items: [b]
|
|
41
|
+
}));
|
|
42
|
+
let k = C(t, {
|
|
43
|
+
items: [y],
|
|
44
|
+
catalogSource: O,
|
|
45
|
+
channel: "live",
|
|
46
|
+
locale: "en",
|
|
47
|
+
maxInstances: o,
|
|
48
|
+
now: () => g.at
|
|
49
|
+
}), A = n(t, {
|
|
50
|
+
currencies: g.currencies,
|
|
51
|
+
now: () => g.at
|
|
52
|
+
}), j = {
|
|
53
|
+
...g.definition,
|
|
54
|
+
offer: {
|
|
55
|
+
...g.definition.offer,
|
|
56
|
+
items: [{
|
|
57
|
+
itemId: y.id,
|
|
58
|
+
qty: 2
|
|
59
|
+
}]
|
|
60
|
+
}
|
|
61
|
+
}, M = 0, N = i(t, {
|
|
62
|
+
realMoney: !0,
|
|
63
|
+
applicationId: g.options.applicationId,
|
|
64
|
+
channel: "ios",
|
|
65
|
+
environment: "sandbox"
|
|
66
|
+
}), P = {
|
|
67
|
+
...g.options,
|
|
68
|
+
products: [j],
|
|
69
|
+
accounts: N
|
|
70
|
+
}, F = a(P, {
|
|
71
|
+
initialize: () => l.void,
|
|
72
|
+
verify: () => (M++, l.succeed({
|
|
73
|
+
...g.facts,
|
|
74
|
+
transactionId: _
|
|
75
|
+
}))
|
|
76
|
+
}), I = "tip_" + d(16).toString("hex");
|
|
77
|
+
await t.insert(E.tableName, {
|
|
78
|
+
id: I,
|
|
79
|
+
tenantId: r,
|
|
80
|
+
allowed: !0,
|
|
81
|
+
admission: 0
|
|
82
|
+
});
|
|
83
|
+
let L = {
|
|
84
|
+
realMoney: !0,
|
|
85
|
+
namespace: r,
|
|
86
|
+
currencies: g.currencies,
|
|
87
|
+
verification: F,
|
|
88
|
+
admission: { prepare: () => l.succeed(x(t, async (t) => {
|
|
89
|
+
if (await t.updateMany(E.tableName, { admission: 0 }, { where: h("id", I) }) !== 1) throw e("forbidden");
|
|
90
|
+
let n = (await t.query(v(E).where(h("id", I)).limit(1).descriptor))[0];
|
|
91
|
+
if (!n || n.tenantId !== r || n.allowed !== !0) throw e("forbidden");
|
|
92
|
+
return null;
|
|
93
|
+
})) },
|
|
94
|
+
economy: A,
|
|
95
|
+
inventory: k,
|
|
96
|
+
systemAccount: "test.iap",
|
|
97
|
+
now: () => g.at,
|
|
98
|
+
...p
|
|
99
|
+
}, R = (e = "test.player", t = r) => ({
|
|
100
|
+
type: "user",
|
|
101
|
+
kind: "guest",
|
|
102
|
+
id: e,
|
|
103
|
+
tenantId: t
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
...g,
|
|
107
|
+
scope: {
|
|
108
|
+
tenantId: r,
|
|
109
|
+
ownerId: "test.player"
|
|
110
|
+
},
|
|
111
|
+
transactionId: _,
|
|
112
|
+
definition: j,
|
|
113
|
+
catalog: O,
|
|
114
|
+
inventory: k,
|
|
115
|
+
economy: A,
|
|
116
|
+
accounts: N,
|
|
117
|
+
options: L,
|
|
118
|
+
verificationOptions: P,
|
|
119
|
+
iap: s(t, L),
|
|
120
|
+
user: R,
|
|
121
|
+
machine: w,
|
|
122
|
+
policyId: I,
|
|
123
|
+
item: y,
|
|
124
|
+
verificationCalls: () => M
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export { E as iapPolicyFixtureTable, O as iapStoreFixture, D as iapStoreFixtureTables };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { boolean as e, id as t, integer as n, json as r, table as i, text as a, timestamp as o } from "@voltro/database";
|
|
2
|
+
// src/iapTables.entity.ts
|
|
3
|
+
var s = () => a().maxLength(120).externalId().sensitive("pii"), c = () => a().maxLength(120).serverOnly(), l = i("_voltro_eco_iap_namespaces", {
|
|
4
|
+
id: t({ prefix: "ein" }),
|
|
5
|
+
namespace: c(),
|
|
6
|
+
admission: n().serverOnly(),
|
|
7
|
+
ordersCount: n().serverOnly(),
|
|
8
|
+
receiptsCount: n().serverOnly()
|
|
9
|
+
}), u = i("_voltro_eco_iap_subjects", {
|
|
10
|
+
id: t({ prefix: "eis" }),
|
|
11
|
+
namespace: c(),
|
|
12
|
+
tenantId: s(),
|
|
13
|
+
ownerId: a().maxLength(120).nullable().externalId().sensitive("pii"),
|
|
14
|
+
erased: e().serverOnly(),
|
|
15
|
+
admission: n().serverOnly(),
|
|
16
|
+
ordersCount: n().serverOnly()
|
|
17
|
+
}).index([
|
|
18
|
+
"namespace",
|
|
19
|
+
"tenantId",
|
|
20
|
+
"ownerId"
|
|
21
|
+
]), d = i("_voltro_eco_iap_orders", {
|
|
22
|
+
id: t({ prefix: "eio" }),
|
|
23
|
+
namespace: c(),
|
|
24
|
+
tenantId: s(),
|
|
25
|
+
ownerId: a().maxLength(120).nullable().externalId().sensitive("pii"),
|
|
26
|
+
ownerKey: a().maxLength(64).serverOnly(),
|
|
27
|
+
state: a().maxLength(16).oneOf([
|
|
28
|
+
"pending",
|
|
29
|
+
"fulfilled",
|
|
30
|
+
"erased"
|
|
31
|
+
]).serverOnly(),
|
|
32
|
+
accepted: e().serverOnly(),
|
|
33
|
+
offerId: a().maxLength(120).serverOnly(),
|
|
34
|
+
acceptedQuantity: n().nullable().serverOnly(),
|
|
35
|
+
acceptedDay: n().nullable().serverOnly(),
|
|
36
|
+
offerVersion: a().maxLength(120).serverOnly(),
|
|
37
|
+
channel: a().maxLength(16).oneOf([
|
|
38
|
+
"ios",
|
|
39
|
+
"android",
|
|
40
|
+
"steam",
|
|
41
|
+
"web"
|
|
42
|
+
]).serverOnly(),
|
|
43
|
+
configurationDigest: a().maxLength(64).serverOnly(),
|
|
44
|
+
intentDigest: a().maxLength(64).nullable().serverOnly(),
|
|
45
|
+
receiptKey: a().maxLength(64).nullable().serverOnly(),
|
|
46
|
+
snapshot: r().nullable().serverOnly(),
|
|
47
|
+
receipt: r().nullable().serverOnly(),
|
|
48
|
+
createdAt: o().serverOnly(),
|
|
49
|
+
fulfilledAt: o().nullable().serverOnly()
|
|
50
|
+
}).index([
|
|
51
|
+
"namespace",
|
|
52
|
+
"tenantId",
|
|
53
|
+
"ownerKey"
|
|
54
|
+
]), f = i("_voltro_eco_iap_receipts", {
|
|
55
|
+
id: t({ prefix: "eir" }),
|
|
56
|
+
namespace: c(),
|
|
57
|
+
tenantId: s(),
|
|
58
|
+
ownerKey: a().maxLength(64).serverOnly(),
|
|
59
|
+
orderKey: a().maxLength(64).serverOnly(),
|
|
60
|
+
identity: a().maxLength(64).serverOnly(),
|
|
61
|
+
state: a().maxLength(16).oneOf([
|
|
62
|
+
"pending",
|
|
63
|
+
"fulfilled",
|
|
64
|
+
"erased"
|
|
65
|
+
]).serverOnly(),
|
|
66
|
+
accepted: e().serverOnly(),
|
|
67
|
+
factsDigest: a().maxLength(64).serverOnly(),
|
|
68
|
+
createdAt: o().serverOnly(),
|
|
69
|
+
fulfilledAt: o().nullable().serverOnly()
|
|
70
|
+
}).index(["namespace"]).index([
|
|
71
|
+
"namespace",
|
|
72
|
+
"tenantId",
|
|
73
|
+
"ownerKey"
|
|
74
|
+
]), p = [
|
|
75
|
+
l,
|
|
76
|
+
u,
|
|
77
|
+
d,
|
|
78
|
+
f
|
|
79
|
+
];
|
|
80
|
+
export { l as iapNamespacesTable, d as iapOrdersTable, f as iapReceiptsTable, u as iapSubjectsTable, p as iapTables };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { EconomyError as e, economyError as t } from "./errors.js";
|
|
2
|
+
import { captureBoundMethods as n, dataObject as r, identifier as i } from "./capture.js";
|
|
3
|
+
import { captureCurrencies as a } from "./currency.js";
|
|
4
|
+
import { shopInteger as o } from "./shop.js";
|
|
5
|
+
import { captureIapPaidAmount as s, captureIapScope as c, defineIapCatalog as l, iapChannel as u, iapEnvironment as d, iapProductKind as f, iapReceiptIntent as p, iapTimestamp as m } from "./iap.js";
|
|
6
|
+
import { Context as h, Effect as g } from "effect";
|
|
7
|
+
import { createHash as _ } from "node:crypto";
|
|
8
|
+
// src/iapVerification.server.ts
|
|
9
|
+
var v = class extends h.Service()("@voltro/IapVerificationPort") {}, y = /* @__PURE__ */ new WeakMap(), b = (e, n) => {
|
|
10
|
+
if (typeof e != "string" || e.length === 0 || e.length > n || /[\u0000-\u0020\u007f]/.test(e)) throw t("invalid_record");
|
|
11
|
+
return e;
|
|
12
|
+
}, x = (e) => {
|
|
13
|
+
let n = r(e, [
|
|
14
|
+
"channel",
|
|
15
|
+
"environment",
|
|
16
|
+
"applicationId",
|
|
17
|
+
"transactionId",
|
|
18
|
+
"originalTransactionId",
|
|
19
|
+
"storeProductId",
|
|
20
|
+
"kind",
|
|
21
|
+
"quantity",
|
|
22
|
+
"purchasedAt",
|
|
23
|
+
"expiresAt",
|
|
24
|
+
"paid",
|
|
25
|
+
"acknowledgement",
|
|
26
|
+
"consumption"
|
|
27
|
+
], "invalid_record"), a = m(n.purchasedAt), c = n.expiresAt === null ? null : m(n.expiresAt), l = f(n.kind);
|
|
28
|
+
if ((l === "subscription" ? c === null || c <= a : c !== null) || l === "subscription" && (n.quantity !== 1 || n.consumption !== "none")) throw t("invalid_record");
|
|
29
|
+
let p = s(n.paid);
|
|
30
|
+
if (n.acknowledgement !== "none" && n.acknowledgement !== "pending" && n.acknowledgement !== "acknowledged" || n.consumption !== "none" && n.consumption !== "available" && n.consumption !== "consumed") throw t("invalid_record");
|
|
31
|
+
return Object.freeze({
|
|
32
|
+
channel: u(n.channel),
|
|
33
|
+
environment: d(n.environment),
|
|
34
|
+
applicationId: i(n.applicationId),
|
|
35
|
+
transactionId: b(n.transactionId, 512),
|
|
36
|
+
originalTransactionId: n.originalTransactionId === null ? null : b(n.originalTransactionId, 512),
|
|
37
|
+
storeProductId: i(n.storeProductId),
|
|
38
|
+
kind: l,
|
|
39
|
+
quantity: o(n.quantity, 1, 1e3),
|
|
40
|
+
purchasedAt: a,
|
|
41
|
+
expiresAt: c,
|
|
42
|
+
paid: p,
|
|
43
|
+
acknowledgement: n.acknowledgement,
|
|
44
|
+
consumption: n.consumption
|
|
45
|
+
});
|
|
46
|
+
}, S = (e) => {
|
|
47
|
+
let n = typeof e == "object" && e ? y.get(e) : void 0;
|
|
48
|
+
if (!n) throw t("forbidden");
|
|
49
|
+
return n;
|
|
50
|
+
}, C = (o, s) => {
|
|
51
|
+
let f = r(o, [
|
|
52
|
+
"realMoney",
|
|
53
|
+
"channel",
|
|
54
|
+
"environment",
|
|
55
|
+
"applicationId",
|
|
56
|
+
"products",
|
|
57
|
+
"currencies",
|
|
58
|
+
"accounts",
|
|
59
|
+
"now"
|
|
60
|
+
]);
|
|
61
|
+
if (f.realMoney !== !0) throw t(f.realMoney === !1 ? "real_money_disabled" : "invalid_input");
|
|
62
|
+
let h = u(f.channel), v = d(f.environment), S = i(f.applicationId), C = a(f.currencies), w = l(f.products, C, !0);
|
|
63
|
+
if (w.length === 0 || w.some((e) => e.channel !== h)) throw t("invalid_input");
|
|
64
|
+
let T = n(f.accounts, ["read", "prepareBinding"]), E = n(s, ["initialize", "verify"]), D = f.now ?? Date.now;
|
|
65
|
+
if (typeof D != "function") throw t("invalid_input");
|
|
66
|
+
return Object.freeze({
|
|
67
|
+
initialize: () => g.suspend(() => E.initialize()).pipe(g.catchDefect(() => g.fail(t("unavailable")))),
|
|
68
|
+
verify: (n, r) => {
|
|
69
|
+
try {
|
|
70
|
+
let i = c(n), a = p(r), o = w.find((e) => e.channel === a.channel && e.offer.id === a.offerId && e.offer.version === a.offerVersion);
|
|
71
|
+
return !o || a.channel !== h ? g.fail(t("forbidden")) : g.suspend(() => {
|
|
72
|
+
let n = m(D());
|
|
73
|
+
return T.read(i, h, v).pipe(g.flatMap((e) => {
|
|
74
|
+
let t = b(e, 128);
|
|
75
|
+
return E.verify(Object.freeze({
|
|
76
|
+
scope: i,
|
|
77
|
+
intent: a,
|
|
78
|
+
product: o,
|
|
79
|
+
accountToken: t,
|
|
80
|
+
at: n
|
|
81
|
+
})).pipe(g.map((e) => ({
|
|
82
|
+
facts: e,
|
|
83
|
+
accountToken: t
|
|
84
|
+
})));
|
|
85
|
+
}), g.flatMap((r) => g.try({
|
|
86
|
+
try: () => {
|
|
87
|
+
let e = x(r.facts);
|
|
88
|
+
if (e.channel !== h || e.environment !== v || e.applicationId !== S || e.storeProductId !== o.storeProductId || e.kind !== o.kind || e.quantity > o.offer.maxQuantity || e.purchasedAt > n || e.expiresAt !== null && e.expiresAt <= n) throw t("forbidden");
|
|
89
|
+
let s = _("sha256").update(JSON.stringify([
|
|
90
|
+
h,
|
|
91
|
+
v,
|
|
92
|
+
S,
|
|
93
|
+
e.transactionId
|
|
94
|
+
])).digest("hex"), c = Object.freeze({
|
|
95
|
+
scope: i,
|
|
96
|
+
offerId: a.offerId,
|
|
97
|
+
offerVersion: a.offerVersion,
|
|
98
|
+
requestId: a.requestId,
|
|
99
|
+
verifiedAt: n,
|
|
100
|
+
identity: s,
|
|
101
|
+
facts: e
|
|
102
|
+
});
|
|
103
|
+
return y.set(c, Object.freeze({
|
|
104
|
+
...c,
|
|
105
|
+
product: o,
|
|
106
|
+
currencies: C,
|
|
107
|
+
accounts: T,
|
|
108
|
+
accountToken: r.accountToken
|
|
109
|
+
})), c;
|
|
110
|
+
},
|
|
111
|
+
catch: (n) => n instanceof e ? n : t("invalid_record")
|
|
112
|
+
})));
|
|
113
|
+
}).pipe(g.catchDefect(() => g.fail(t("unavailable"))));
|
|
114
|
+
} catch (n) {
|
|
115
|
+
return g.fail(n instanceof e ? n : t("invalid_input"));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
export { v as IapVerificationPort, x as captureIapTransactionFacts, C as iapVerificationPort, S as readVerifiedIapPurchase };
|