@plasius/economy 0.9.0 → 0.11.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/README.md +27 -1
- package/dist/index.cjs +425 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -7
- package/dist/index.d.ts +109 -7
- package/dist/index.js +417 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,9 @@ __export(index_exports, {
|
|
|
40
40
|
ECONOMY_CONTRACT_VERSION: () => ECONOMY_CONTRACT_VERSION,
|
|
41
41
|
ECONOMY_RECOVERY_PROTOCOL_VERSION: () => ECONOMY_RECOVERY_PROTOCOL_VERSION,
|
|
42
42
|
EconomyError: () => EconomyError,
|
|
43
|
+
GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN: () => GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN,
|
|
44
|
+
GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN: () => GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
|
|
45
|
+
GOOGLE_REWARDED_WEB_PROVIDER: () => GOOGLE_REWARDED_WEB_PROVIDER,
|
|
43
46
|
MODULE_ALLOWANCE_PURPOSE: () => MODULE_ALLOWANCE_PURPOSE,
|
|
44
47
|
PRE_UTILITY_BACKER_COHORT: () => PRE_UTILITY_BACKER_COHORT,
|
|
45
48
|
TOKEN_SUBUNITS_MAX: () => TOKEN_SUBUNITS_MAX,
|
|
@@ -112,6 +115,10 @@ __export(index_exports, {
|
|
|
112
115
|
assertFlatTokenCatalog: () => assertFlatTokenCatalog,
|
|
113
116
|
assertFxSnapshot: () => assertFxSnapshot,
|
|
114
117
|
assertGameplayAllocation: () => assertGameplayAllocation,
|
|
118
|
+
assertGoogleRewardedWebGrantClaim: () => assertGoogleRewardedWebGrantClaim,
|
|
119
|
+
assertGoogleRewardedWebQuote: () => assertGoogleRewardedWebQuote,
|
|
120
|
+
assertGoogleRewardedWebReconciliation: () => assertGoogleRewardedWebReconciliation,
|
|
121
|
+
assertGoogleRewardedWebStateTransition: () => assertGoogleRewardedWebStateTransition,
|
|
115
122
|
assertJournalChainHead: () => assertJournalChainHead,
|
|
116
123
|
assertModuleAllowance: () => assertModuleAllowance,
|
|
117
124
|
assertModulePurchaseReceipt: () => assertModulePurchaseReceipt,
|
|
@@ -205,6 +212,7 @@ __export(index_exports, {
|
|
|
205
212
|
createEconomyRecoveryCommittedResult: () => createEconomyRecoveryCommittedResult,
|
|
206
213
|
createEconomyRegionalEvidenceReceipt: () => createEconomyRegionalEvidenceReceipt,
|
|
207
214
|
createGameplayAllocation: () => createGameplayAllocation,
|
|
215
|
+
createGoogleRewardedWebQuote: () => createGoogleRewardedWebQuote,
|
|
208
216
|
createInitialSourceLotSnapshot: () => createInitialSourceLotSnapshot,
|
|
209
217
|
createModuleAllowance: () => createModuleAllowance,
|
|
210
218
|
createModulePurchaseReceipt: () => createModulePurchaseReceipt,
|
|
@@ -2161,6 +2169,7 @@ var COMMAND_SOURCES = /* @__PURE__ */ new Set([
|
|
|
2161
2169
|
"shopify",
|
|
2162
2170
|
"ayet",
|
|
2163
2171
|
"bitlabs",
|
|
2172
|
+
"google-ad-manager",
|
|
2164
2173
|
"operator",
|
|
2165
2174
|
"system"
|
|
2166
2175
|
]);
|
|
@@ -2173,7 +2182,8 @@ var PRINCIPAL_TYPES = /* @__PURE__ */ new Set([
|
|
|
2173
2182
|
var PROVIDER_SOURCES = /* @__PURE__ */ new Set([
|
|
2174
2183
|
"shopify",
|
|
2175
2184
|
"ayet",
|
|
2176
|
-
"bitlabs"
|
|
2185
|
+
"bitlabs",
|
|
2186
|
+
"google-ad-manager"
|
|
2177
2187
|
]);
|
|
2178
2188
|
var CAUSATION_KINDS = /* @__PURE__ */ new Set([
|
|
2179
2189
|
"provider-event",
|
|
@@ -2185,10 +2195,12 @@ var CAUSATION_KINDS = /* @__PURE__ */ new Set([
|
|
|
2185
2195
|
var PROVIDERS = /* @__PURE__ */ new Set([
|
|
2186
2196
|
"shopify",
|
|
2187
2197
|
"ayet",
|
|
2188
|
-
"bitlabs"
|
|
2198
|
+
"bitlabs",
|
|
2199
|
+
"google-ad-manager"
|
|
2189
2200
|
]);
|
|
2190
2201
|
var FINGERPRINT_DOMAINS = /* @__PURE__ */ new Set([
|
|
2191
2202
|
"economy.idempotency-key.v1",
|
|
2203
|
+
"economy.google-reporting-key.v1",
|
|
2192
2204
|
"economy.provider-event-key.v1",
|
|
2193
2205
|
"economy.provider-object-key.v1",
|
|
2194
2206
|
"economy.provider-payload.v1",
|
|
@@ -2214,6 +2226,12 @@ var SOURCE_COMMAND_TYPES = {
|
|
|
2214
2226
|
]),
|
|
2215
2227
|
ayet: /* @__PURE__ */ new Set(["credit-reward", "hold", "release-hold", "reverse"]),
|
|
2216
2228
|
bitlabs: /* @__PURE__ */ new Set(["credit-reward", "hold", "release-hold", "reverse"]),
|
|
2229
|
+
"google-ad-manager": /* @__PURE__ */ new Set([
|
|
2230
|
+
"credit-reward",
|
|
2231
|
+
"hold",
|
|
2232
|
+
"release-hold",
|
|
2233
|
+
"reverse"
|
|
2234
|
+
]),
|
|
2217
2235
|
operator: /* @__PURE__ */ new Set(["adjust", "reverse", "hold", "release-hold"]),
|
|
2218
2236
|
system: /* @__PURE__ */ new Set([
|
|
2219
2237
|
"credit-event",
|
|
@@ -2487,6 +2505,9 @@ function assertEconomyProviderEvidenceHash(evidence) {
|
|
|
2487
2505
|
"reconciliationEvidenceFingerprint",
|
|
2488
2506
|
"signatureScheme",
|
|
2489
2507
|
"signatureVerifiedAt",
|
|
2508
|
+
"verificationMode",
|
|
2509
|
+
"authenticatedRetrievalScheme",
|
|
2510
|
+
"authenticatedRetrievedAt",
|
|
2490
2511
|
"providerOccurredAt",
|
|
2491
2512
|
"receivedAt",
|
|
2492
2513
|
"operationalHandleBindingId"
|
|
@@ -2521,9 +2542,27 @@ function assertEconomyProviderEvidenceHash(evidence) {
|
|
|
2521
2542
|
);
|
|
2522
2543
|
}
|
|
2523
2544
|
assertSafeClassifier(evidence.eventType, "Provider event type");
|
|
2524
|
-
assertSafeClassifier(evidence.signatureScheme, "Provider signature scheme");
|
|
2525
|
-
const signatureVerifiedAt = parseIsoTimestamp(evidence.signatureVerifiedAt);
|
|
2526
2545
|
const receivedAt = parseIsoTimestamp(evidence.receivedAt);
|
|
2546
|
+
const signatureFieldsPresent = evidence.signatureScheme !== void 0 && evidence.signatureVerifiedAt !== void 0;
|
|
2547
|
+
const retrievalFieldsPresent = evidence.authenticatedRetrievalScheme !== void 0 && evidence.authenticatedRetrievedAt !== void 0;
|
|
2548
|
+
const verificationMode = evidence.verificationMode ?? "provider-signature";
|
|
2549
|
+
economyAssert(
|
|
2550
|
+
verificationMode === "provider-signature" && evidence.provider !== "google-ad-manager" && signatureFieldsPresent && !retrievalFieldsPresent && evidence.authenticatedRetrievalScheme === void 0 && evidence.authenticatedRetrievedAt === void 0 || verificationMode === "authenticated-retrieval" && evidence.provider === "google-ad-manager" && retrievalFieldsPresent && evidence.signatureScheme === void 0 && evidence.signatureVerifiedAt === void 0,
|
|
2551
|
+
"INVALID_CONTRACT",
|
|
2552
|
+
"Provider evidence must use exactly one permitted verification method"
|
|
2553
|
+
);
|
|
2554
|
+
const verifiedAt = verificationMode === "provider-signature" ? evidence.signatureVerifiedAt : evidence.authenticatedRetrievedAt;
|
|
2555
|
+
if (verificationMode === "provider-signature") {
|
|
2556
|
+
assertSafeClassifier(
|
|
2557
|
+
evidence.signatureScheme,
|
|
2558
|
+
"Provider signature scheme"
|
|
2559
|
+
);
|
|
2560
|
+
} else {
|
|
2561
|
+
assertSafeClassifier(
|
|
2562
|
+
evidence.authenticatedRetrievalScheme,
|
|
2563
|
+
"Provider authenticated-retrieval scheme"
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2527
2566
|
if (evidence.providerOccurredAt !== void 0) {
|
|
2528
2567
|
economyAssert(
|
|
2529
2568
|
parseIsoTimestamp(evidence.providerOccurredAt) <= receivedAt,
|
|
@@ -2532,9 +2571,9 @@ function assertEconomyProviderEvidenceHash(evidence) {
|
|
|
2532
2571
|
);
|
|
2533
2572
|
}
|
|
2534
2573
|
economyAssert(
|
|
2535
|
-
receivedAt >=
|
|
2574
|
+
receivedAt >= parseIsoTimestamp(verifiedAt),
|
|
2536
2575
|
"INVALID_TIME_WINDOW",
|
|
2537
|
-
"Provider evidence cannot be received before
|
|
2576
|
+
"Provider evidence cannot be received before verification"
|
|
2538
2577
|
);
|
|
2539
2578
|
if (evidence.operationalHandleBindingId !== void 0) {
|
|
2540
2579
|
assertEconomyIdentifier(
|
|
@@ -2884,8 +2923,13 @@ function canonicalEconomyProviderEvidenceHashPayload(evidence) {
|
|
|
2884
2923
|
evidence.reconciliationEvidenceFingerprint
|
|
2885
2924
|
)
|
|
2886
2925
|
},
|
|
2887
|
-
|
|
2888
|
-
|
|
2926
|
+
...evidence.verificationMode === void 0 ? {} : { verificationMode: evidence.verificationMode },
|
|
2927
|
+
...evidence.signatureScheme === void 0 ? {} : { signatureScheme: evidence.signatureScheme },
|
|
2928
|
+
...evidence.signatureVerifiedAt === void 0 ? {} : { signatureVerifiedAt: evidence.signatureVerifiedAt },
|
|
2929
|
+
...evidence.authenticatedRetrievalScheme === void 0 ? {} : {
|
|
2930
|
+
authenticatedRetrievalScheme: evidence.authenticatedRetrievalScheme
|
|
2931
|
+
},
|
|
2932
|
+
...evidence.authenticatedRetrievedAt === void 0 ? {} : { authenticatedRetrievedAt: evidence.authenticatedRetrievedAt },
|
|
2889
2933
|
...evidence.providerOccurredAt === void 0 ? {} : { providerOccurredAt: evidence.providerOccurredAt },
|
|
2890
2934
|
receivedAt: evidence.receivedAt,
|
|
2891
2935
|
...evidence.operationalHandleBindingId === void 0 ? {} : {
|
|
@@ -3699,6 +3743,7 @@ var ACTIVITY_SOURCES2 = /* @__PURE__ */ new Set([
|
|
|
3699
3743
|
"shopify",
|
|
3700
3744
|
"ayet",
|
|
3701
3745
|
"bitlabs",
|
|
3746
|
+
"google-ad-manager",
|
|
3702
3747
|
"subscription",
|
|
3703
3748
|
"event",
|
|
3704
3749
|
"competition",
|
|
@@ -3938,6 +3983,15 @@ function assertReversalAvailable(originalTransactionId, existingTransactions) {
|
|
|
3938
3983
|
}
|
|
3939
3984
|
|
|
3940
3985
|
// src/audit-graph.ts
|
|
3986
|
+
var PROVIDER_COMMAND_SOURCES = /* @__PURE__ */ new Set([
|
|
3987
|
+
"shopify",
|
|
3988
|
+
"ayet",
|
|
3989
|
+
"bitlabs",
|
|
3990
|
+
"google-ad-manager"
|
|
3991
|
+
]);
|
|
3992
|
+
function isProviderCommandSource(source) {
|
|
3993
|
+
return PROVIDER_COMMAND_SOURCES.has(source);
|
|
3994
|
+
}
|
|
3941
3995
|
function assertCanonicalHash4(value, label) {
|
|
3942
3996
|
economyAssert(
|
|
3943
3997
|
typeof value === "string" && /^sha256:[a-f0-9]{64}$/u.test(value),
|
|
@@ -3965,7 +4019,7 @@ function assertCreatedReference(manifest, kind, id, contentHash) {
|
|
|
3965
4019
|
}
|
|
3966
4020
|
function assertProviderGraph(graph, hash, acceptanceCommit) {
|
|
3967
4021
|
const envelope = graph.commandEnvelope;
|
|
3968
|
-
const providerSource = envelope.commandSource
|
|
4022
|
+
const providerSource = isProviderCommandSource(envelope.commandSource);
|
|
3969
4023
|
if (!providerSource) {
|
|
3970
4024
|
economyAssert(
|
|
3971
4025
|
graph.providerEvidenceManifest === void 0 && graph.providerEvidence.length === 0 && graph.operationalHandleBindings.length === 0,
|
|
@@ -4112,7 +4166,7 @@ function expectedTransactionActivityTypes(envelope) {
|
|
|
4112
4166
|
}
|
|
4113
4167
|
if (envelope.commandType === "credit-reward") {
|
|
4114
4168
|
return /* @__PURE__ */ new Set([
|
|
4115
|
-
envelope.commandSource === "ayet" ? "rewarded-ad" : "offerwall"
|
|
4169
|
+
envelope.commandSource === "ayet" || envelope.commandSource === "google-ad-manager" ? "rewarded-ad" : "offerwall"
|
|
4116
4170
|
]);
|
|
4117
4171
|
}
|
|
4118
4172
|
if (envelope.commandType === "credit-event") {
|
|
@@ -4167,7 +4221,7 @@ function assertReceiptGraph(graph, commandEnvelopeHash, hash, acceptanceCommit,
|
|
|
4167
4221
|
accepted.receiptId,
|
|
4168
4222
|
acceptedHash
|
|
4169
4223
|
);
|
|
4170
|
-
const providerSource = envelope.commandSource
|
|
4224
|
+
const providerSource = isProviderCommandSource(envelope.commandSource);
|
|
4171
4225
|
if (graph.resultReceipt === void 0) {
|
|
4172
4226
|
economyAssert(
|
|
4173
4227
|
providerSource && graph.transaction === void 0 && resultCommit === void 0,
|
|
@@ -4287,7 +4341,9 @@ function assertAuthorityCommits(graph, hash) {
|
|
|
4287
4341
|
"INVALID_CONTRACT",
|
|
4288
4342
|
"Authority commits do not reconstruct the expected authority head"
|
|
4289
4343
|
);
|
|
4290
|
-
const providerSource =
|
|
4344
|
+
const providerSource = isProviderCommandSource(
|
|
4345
|
+
graph.commandEnvelope.commandSource
|
|
4346
|
+
);
|
|
4291
4347
|
const acceptanceKind = providerSource ? "provider-acceptance" : "first-party-command";
|
|
4292
4348
|
const acceptanceCommit = graph.commits.find(
|
|
4293
4349
|
(commit) => commit.manifest.commitKind === acceptanceKind
|
|
@@ -4492,6 +4548,324 @@ function evaluateEarlyBackerBySettlementV2(payerAccountId, receivingHouseholdId,
|
|
|
4492
4548
|
};
|
|
4493
4549
|
}
|
|
4494
4550
|
|
|
4551
|
+
// src/google-rewarded-web.ts
|
|
4552
|
+
var GOOGLE_REWARDED_WEB_PROVIDER = "google-ad-manager";
|
|
4553
|
+
var GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN = 100000n;
|
|
4554
|
+
var GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN = 125000n;
|
|
4555
|
+
var SIGNED_BIGINT_MAX = 2n ** 63n - 1n;
|
|
4556
|
+
var CANONICAL_UNSIGNED_INTEGER = /^(?:0|[1-9][0-9]*)$/u;
|
|
4557
|
+
var SHA256 = /^sha256:[a-f0-9]{64}$/u;
|
|
4558
|
+
function assertExactKeys4(value, allowed, label) {
|
|
4559
|
+
economyAssert(
|
|
4560
|
+
Object.keys(value).every((key) => allowed.has(key)) && [...allowed].every(
|
|
4561
|
+
(key) => key === "effectiveUntil" || Object.prototype.hasOwnProperty.call(value, key)
|
|
4562
|
+
),
|
|
4563
|
+
"INVALID_CONTRACT",
|
|
4564
|
+
`${label} contains missing or unsupported fields`
|
|
4565
|
+
);
|
|
4566
|
+
}
|
|
4567
|
+
function parseGbpMicros(value, label) {
|
|
4568
|
+
economyAssert(
|
|
4569
|
+
typeof value === "string" && CANONICAL_UNSIGNED_INTEGER.test(value),
|
|
4570
|
+
"INVALID_CONTRACT",
|
|
4571
|
+
`${label} must be canonical non-negative GBP micros`
|
|
4572
|
+
);
|
|
4573
|
+
const parsed = BigInt(value);
|
|
4574
|
+
economyAssert(
|
|
4575
|
+
parsed <= SIGNED_BIGINT_MAX,
|
|
4576
|
+
"AMOUNT_OUT_OF_RANGE",
|
|
4577
|
+
`${label} is outside the signed 64-bit range`
|
|
4578
|
+
);
|
|
4579
|
+
return parsed;
|
|
4580
|
+
}
|
|
4581
|
+
function assertRewardPayload(payload) {
|
|
4582
|
+
assertExactKeys4(payload, /* @__PURE__ */ new Set(["type", "amount"]), "Reward payload");
|
|
4583
|
+
economyAssert(
|
|
4584
|
+
payload.type === "plasius-token-progress" && payload.amount === 1,
|
|
4585
|
+
"INVALID_CONTRACT",
|
|
4586
|
+
"Reward payload must disclose exactly one Token of bundle progress"
|
|
4587
|
+
);
|
|
4588
|
+
}
|
|
4589
|
+
function assertBoundedCount(value, label) {
|
|
4590
|
+
economyAssert(
|
|
4591
|
+
Number.isSafeInteger(value) && value >= 0,
|
|
4592
|
+
"INVALID_CONTRACT",
|
|
4593
|
+
`${label} must be a non-negative safe integer`
|
|
4594
|
+
);
|
|
4595
|
+
}
|
|
4596
|
+
function createGoogleRewardedWebQuote(input) {
|
|
4597
|
+
const gross = parseGbpMicros(
|
|
4598
|
+
input.grossRevenueFloorMicros,
|
|
4599
|
+
"grossRevenueFloorMicros"
|
|
4600
|
+
);
|
|
4601
|
+
const providerFee = parseGbpMicros(
|
|
4602
|
+
input.providerFeeMicros,
|
|
4603
|
+
"providerFeeMicros"
|
|
4604
|
+
);
|
|
4605
|
+
const invalidTrafficHaircut = parseGbpMicros(
|
|
4606
|
+
input.invalidTrafficHaircutMicros,
|
|
4607
|
+
"invalidTrafficHaircutMicros"
|
|
4608
|
+
);
|
|
4609
|
+
const otherCost = parseGbpMicros(input.otherCostMicros, "otherCostMicros");
|
|
4610
|
+
const deductions = providerFee + invalidTrafficHaircut + otherCost;
|
|
4611
|
+
economyAssert(
|
|
4612
|
+
deductions <= gross,
|
|
4613
|
+
"INVALID_CONTRACT",
|
|
4614
|
+
"Rewarded-web costs cannot exceed the gross revenue floor"
|
|
4615
|
+
);
|
|
4616
|
+
const eligibleNet = gross - deductions;
|
|
4617
|
+
const retainedMargin = eligibleNet - GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN;
|
|
4618
|
+
const quote = {
|
|
4619
|
+
schemaVersion: ECONOMY_CONTRACT_VERSION,
|
|
4620
|
+
quoteVersion: input.quoteVersion,
|
|
4621
|
+
provider: GOOGLE_REWARDED_WEB_PROVIDER,
|
|
4622
|
+
currency: "GBP",
|
|
4623
|
+
bundleCompletions: input.bundleCompletions,
|
|
4624
|
+
rewardPayload: input.rewardPayload,
|
|
4625
|
+
grossRevenueFloorMicros: gross.toString(10),
|
|
4626
|
+
providerFeeMicros: providerFee.toString(10),
|
|
4627
|
+
invalidTrafficHaircutMicros: invalidTrafficHaircut.toString(10),
|
|
4628
|
+
otherCostMicros: otherCost.toString(10),
|
|
4629
|
+
eligibleNetRevenueMicros: eligibleNet.toString(10),
|
|
4630
|
+
tokenAmount: serializeTokenSubunits(TOKEN_SUBUNITS_PER_TOKEN),
|
|
4631
|
+
nominalLiabilityMicros: GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN.toString(10),
|
|
4632
|
+
retainedMarginMicros: retainedMargin.toString(10),
|
|
4633
|
+
effectiveFrom: input.effectiveFrom,
|
|
4634
|
+
...input.effectiveUntil === void 0 ? {} : { effectiveUntil: input.effectiveUntil }
|
|
4635
|
+
};
|
|
4636
|
+
assertGoogleRewardedWebQuote(quote);
|
|
4637
|
+
return Object.freeze(quote);
|
|
4638
|
+
}
|
|
4639
|
+
function assertGoogleRewardedWebQuote(quote) {
|
|
4640
|
+
assertExactKeys4(
|
|
4641
|
+
quote,
|
|
4642
|
+
/* @__PURE__ */ new Set([
|
|
4643
|
+
"schemaVersion",
|
|
4644
|
+
"quoteVersion",
|
|
4645
|
+
"provider",
|
|
4646
|
+
"currency",
|
|
4647
|
+
"bundleCompletions",
|
|
4648
|
+
"rewardPayload",
|
|
4649
|
+
"grossRevenueFloorMicros",
|
|
4650
|
+
"providerFeeMicros",
|
|
4651
|
+
"invalidTrafficHaircutMicros",
|
|
4652
|
+
"otherCostMicros",
|
|
4653
|
+
"eligibleNetRevenueMicros",
|
|
4654
|
+
"tokenAmount",
|
|
4655
|
+
"nominalLiabilityMicros",
|
|
4656
|
+
"retainedMarginMicros",
|
|
4657
|
+
"effectiveFrom",
|
|
4658
|
+
"effectiveUntil"
|
|
4659
|
+
]),
|
|
4660
|
+
"Google rewarded-web quote"
|
|
4661
|
+
);
|
|
4662
|
+
economyAssert(
|
|
4663
|
+
quote.schemaVersion === ECONOMY_CONTRACT_VERSION && quote.provider === GOOGLE_REWARDED_WEB_PROVIDER && quote.currency === "GBP",
|
|
4664
|
+
"INVALID_CONTRACT",
|
|
4665
|
+
"Unsupported Google rewarded-web quote contract"
|
|
4666
|
+
);
|
|
4667
|
+
assertEconomyIdentifier(quote.quoteVersion, "quoteVersion");
|
|
4668
|
+
economyAssert(
|
|
4669
|
+
Number.isSafeInteger(quote.bundleCompletions) && quote.bundleCompletions >= 1 && quote.bundleCompletions <= 1e3,
|
|
4670
|
+
"INVALID_CONTRACT",
|
|
4671
|
+
"Bundle completions must be between 1 and 1,000"
|
|
4672
|
+
);
|
|
4673
|
+
assertRewardPayload(quote.rewardPayload);
|
|
4674
|
+
const gross = parseGbpMicros(
|
|
4675
|
+
quote.grossRevenueFloorMicros,
|
|
4676
|
+
"grossRevenueFloorMicros"
|
|
4677
|
+
);
|
|
4678
|
+
const providerFee = parseGbpMicros(
|
|
4679
|
+
quote.providerFeeMicros,
|
|
4680
|
+
"providerFeeMicros"
|
|
4681
|
+
);
|
|
4682
|
+
const invalidTrafficHaircut = parseGbpMicros(
|
|
4683
|
+
quote.invalidTrafficHaircutMicros,
|
|
4684
|
+
"invalidTrafficHaircutMicros"
|
|
4685
|
+
);
|
|
4686
|
+
const otherCost = parseGbpMicros(quote.otherCostMicros, "otherCostMicros");
|
|
4687
|
+
const eligibleNet = parseGbpMicros(
|
|
4688
|
+
quote.eligibleNetRevenueMicros,
|
|
4689
|
+
"eligibleNetRevenueMicros"
|
|
4690
|
+
);
|
|
4691
|
+
const nominalLiability = parseGbpMicros(
|
|
4692
|
+
quote.nominalLiabilityMicros,
|
|
4693
|
+
"nominalLiabilityMicros"
|
|
4694
|
+
);
|
|
4695
|
+
const retainedMargin = parseGbpMicros(
|
|
4696
|
+
quote.retainedMarginMicros,
|
|
4697
|
+
"retainedMarginMicros"
|
|
4698
|
+
);
|
|
4699
|
+
economyAssert(
|
|
4700
|
+
gross === providerFee + invalidTrafficHaircut + otherCost + eligibleNet,
|
|
4701
|
+
"INVALID_CONTRACT",
|
|
4702
|
+
"Rewarded-web quote revenue arithmetic is inconsistent"
|
|
4703
|
+
);
|
|
4704
|
+
economyAssert(
|
|
4705
|
+
parseTokenSubunits(quote.tokenAmount) === TOKEN_SUBUNITS_PER_TOKEN && nominalLiability === GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
|
|
4706
|
+
"INVALID_CONTRACT",
|
|
4707
|
+
"Rewarded-web quote must issue exactly one whole Token"
|
|
4708
|
+
);
|
|
4709
|
+
economyAssert(
|
|
4710
|
+
eligibleNet >= GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN && retainedMargin === eligibleNet - nominalLiability && retainedMargin * 5n >= eligibleNet,
|
|
4711
|
+
"INVALID_CONTRACT",
|
|
4712
|
+
"Rewarded-web quote does not preserve the 20% contribution margin"
|
|
4713
|
+
);
|
|
4714
|
+
const effectiveFrom = parseIsoTimestamp(quote.effectiveFrom);
|
|
4715
|
+
if (quote.effectiveUntil !== void 0) {
|
|
4716
|
+
economyAssert(
|
|
4717
|
+
parseIsoTimestamp(quote.effectiveUntil) > effectiveFrom,
|
|
4718
|
+
"INVALID_TIME_WINDOW",
|
|
4719
|
+
"Rewarded-web quote expiry must follow its effective time"
|
|
4720
|
+
);
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
function assertGoogleRewardedWebGrantClaim(claim) {
|
|
4724
|
+
assertExactKeys4(
|
|
4725
|
+
claim,
|
|
4726
|
+
/* @__PURE__ */ new Set([
|
|
4727
|
+
"schemaVersion",
|
|
4728
|
+
"provider",
|
|
4729
|
+
"evidenceTrust",
|
|
4730
|
+
"claimId",
|
|
4731
|
+
"sessionId",
|
|
4732
|
+
"beneficiaryAccountId",
|
|
4733
|
+
"quoteVersion",
|
|
4734
|
+
"reportingKeyFingerprint",
|
|
4735
|
+
"rewardPayload",
|
|
4736
|
+
"claimedAt"
|
|
4737
|
+
]),
|
|
4738
|
+
"Google rewarded-web grant claim"
|
|
4739
|
+
);
|
|
4740
|
+
economyAssert(
|
|
4741
|
+
claim.schemaVersion === ECONOMY_CONTRACT_VERSION && claim.provider === GOOGLE_REWARDED_WEB_PROVIDER && claim.evidenceTrust === "client-claimed",
|
|
4742
|
+
"INVALID_CONTRACT",
|
|
4743
|
+
"Rewarded-web grant evidence must remain client-claimed"
|
|
4744
|
+
);
|
|
4745
|
+
assertEconomyIdentifier(claim.claimId, "claimId");
|
|
4746
|
+
assertEconomyIdentifier(claim.sessionId, "sessionId");
|
|
4747
|
+
assertEconomyIdentifier(claim.beneficiaryAccountId, "beneficiaryAccountId");
|
|
4748
|
+
assertEconomyIdentifier(claim.quoteVersion, "quoteVersion");
|
|
4749
|
+
assertEconomyHmacFingerprint(
|
|
4750
|
+
claim.reportingKeyFingerprint,
|
|
4751
|
+
"economy.google-reporting-key.v1"
|
|
4752
|
+
);
|
|
4753
|
+
assertRewardPayload(claim.rewardPayload);
|
|
4754
|
+
parseIsoTimestamp(claim.claimedAt);
|
|
4755
|
+
}
|
|
4756
|
+
function assertGoogleRewardedWebReconciliation(reconciliation, quote) {
|
|
4757
|
+
assertGoogleRewardedWebQuote(quote);
|
|
4758
|
+
assertExactKeys4(
|
|
4759
|
+
reconciliation,
|
|
4760
|
+
/* @__PURE__ */ new Set([
|
|
4761
|
+
"schemaVersion",
|
|
4762
|
+
"provider",
|
|
4763
|
+
"batchId",
|
|
4764
|
+
"quoteVersion",
|
|
4765
|
+
"state",
|
|
4766
|
+
"reportFinality",
|
|
4767
|
+
"reportFingerprint",
|
|
4768
|
+
"adUnitFingerprint",
|
|
4769
|
+
"periodStartedAt",
|
|
4770
|
+
"periodEndedAt",
|
|
4771
|
+
"acceptedClaimCount",
|
|
4772
|
+
"matchedPaidImpressionCount",
|
|
4773
|
+
"creditedBundleCount",
|
|
4774
|
+
"grossRevenueMicros",
|
|
4775
|
+
"eligibleNetRevenueMicros",
|
|
4776
|
+
"nominalLiabilityMicros",
|
|
4777
|
+
"reserveHeldMicros",
|
|
4778
|
+
"reconciledAt"
|
|
4779
|
+
]),
|
|
4780
|
+
"Google rewarded-web reconciliation"
|
|
4781
|
+
);
|
|
4782
|
+
economyAssert(
|
|
4783
|
+
reconciliation.schemaVersion === ECONOMY_CONTRACT_VERSION && reconciliation.provider === GOOGLE_REWARDED_WEB_PROVIDER && reconciliation.quoteVersion === quote.quoteVersion && ["report-matched", "financially-reconciled", "mismatch"].includes(
|
|
4784
|
+
reconciliation.state
|
|
4785
|
+
) && ["estimated", "final"].includes(reconciliation.reportFinality),
|
|
4786
|
+
"INVALID_CONTRACT",
|
|
4787
|
+
"Unsupported Google rewarded-web reconciliation contract"
|
|
4788
|
+
);
|
|
4789
|
+
assertEconomyIdentifier(reconciliation.batchId, "batchId");
|
|
4790
|
+
assertEconomyHmacFingerprint(
|
|
4791
|
+
reconciliation.reportFingerprint,
|
|
4792
|
+
"economy.provider-reconciliation.v1"
|
|
4793
|
+
);
|
|
4794
|
+
economyAssert(
|
|
4795
|
+
SHA256.test(reconciliation.adUnitFingerprint),
|
|
4796
|
+
"INVALID_CONTRACT",
|
|
4797
|
+
"Ad-unit fingerprint must be a canonical SHA-256 reference"
|
|
4798
|
+
);
|
|
4799
|
+
const periodStartedAt = parseIsoTimestamp(reconciliation.periodStartedAt);
|
|
4800
|
+
const periodEndedAt = parseIsoTimestamp(reconciliation.periodEndedAt);
|
|
4801
|
+
const reconciledAt = parseIsoTimestamp(reconciliation.reconciledAt);
|
|
4802
|
+
economyAssert(
|
|
4803
|
+
periodEndedAt > periodStartedAt && reconciledAt >= periodEndedAt,
|
|
4804
|
+
"INVALID_TIME_WINDOW",
|
|
4805
|
+
"Reconciliation period and completion times are inconsistent"
|
|
4806
|
+
);
|
|
4807
|
+
assertBoundedCount(reconciliation.acceptedClaimCount, "acceptedClaimCount");
|
|
4808
|
+
assertBoundedCount(
|
|
4809
|
+
reconciliation.matchedPaidImpressionCount,
|
|
4810
|
+
"matchedPaidImpressionCount"
|
|
4811
|
+
);
|
|
4812
|
+
assertBoundedCount(
|
|
4813
|
+
reconciliation.creditedBundleCount,
|
|
4814
|
+
"creditedBundleCount"
|
|
4815
|
+
);
|
|
4816
|
+
const gross = parseGbpMicros(
|
|
4817
|
+
reconciliation.grossRevenueMicros,
|
|
4818
|
+
"grossRevenueMicros"
|
|
4819
|
+
);
|
|
4820
|
+
const eligibleNet = parseGbpMicros(
|
|
4821
|
+
reconciliation.eligibleNetRevenueMicros,
|
|
4822
|
+
"eligibleNetRevenueMicros"
|
|
4823
|
+
);
|
|
4824
|
+
const nominalLiability = parseGbpMicros(
|
|
4825
|
+
reconciliation.nominalLiabilityMicros,
|
|
4826
|
+
"nominalLiabilityMicros"
|
|
4827
|
+
);
|
|
4828
|
+
const reserveHeld = parseGbpMicros(
|
|
4829
|
+
reconciliation.reserveHeldMicros,
|
|
4830
|
+
"reserveHeldMicros"
|
|
4831
|
+
);
|
|
4832
|
+
const expectedCompletions = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.bundleCompletions);
|
|
4833
|
+
const expectedEligibleNet = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.eligibleNetRevenueMicros);
|
|
4834
|
+
const expectedLiability = BigInt(reconciliation.creditedBundleCount) * BigInt(quote.nominalLiabilityMicros);
|
|
4835
|
+
economyAssert(
|
|
4836
|
+
gross >= eligibleNet && nominalLiability === expectedLiability && reserveHeld >= nominalLiability,
|
|
4837
|
+
"INVALID_CONTRACT",
|
|
4838
|
+
"Reconciliation liability or reserve arithmetic is inconsistent"
|
|
4839
|
+
);
|
|
4840
|
+
if (reconciliation.state === "financially-reconciled") {
|
|
4841
|
+
economyAssert(
|
|
4842
|
+
reconciliation.reportFinality === "final" && BigInt(reconciliation.acceptedClaimCount) >= expectedCompletions && BigInt(reconciliation.matchedPaidImpressionCount) >= expectedCompletions && eligibleNet >= expectedEligibleNet,
|
|
4843
|
+
"INVALID_CONTRACT",
|
|
4844
|
+
"Financial reconciliation requires final paid impressions and revenue coverage"
|
|
4845
|
+
);
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
var STATE_TRANSITIONS = {
|
|
4849
|
+
created: /* @__PURE__ */ new Set(["bootstrapped", "suspended", "expired"]),
|
|
4850
|
+
bootstrapped: /* @__PURE__ */ new Set(["client-claimed", "suspended", "expired"]),
|
|
4851
|
+
"client-claimed": /* @__PURE__ */ new Set(["report-matched", "suspended", "expired"]),
|
|
4852
|
+
"report-matched": /* @__PURE__ */ new Set([
|
|
4853
|
+
"financially-reconciled",
|
|
4854
|
+
"suspended",
|
|
4855
|
+
"expired"
|
|
4856
|
+
]),
|
|
4857
|
+
"financially-reconciled": /* @__PURE__ */ new Set(),
|
|
4858
|
+
suspended: /* @__PURE__ */ new Set(),
|
|
4859
|
+
expired: /* @__PURE__ */ new Set()
|
|
4860
|
+
};
|
|
4861
|
+
function assertGoogleRewardedWebStateTransition(from, to) {
|
|
4862
|
+
economyAssert(
|
|
4863
|
+
STATE_TRANSITIONS[from]?.has(to) === true,
|
|
4864
|
+
"INVALID_CONTRACT",
|
|
4865
|
+
"Rewarded-web session transition is not forward-safe"
|
|
4866
|
+
);
|
|
4867
|
+
}
|
|
4868
|
+
|
|
4495
4869
|
// src/integrity.ts
|
|
4496
4870
|
function assertCanonicalHash5(value, label) {
|
|
4497
4871
|
economyAssert(
|
|
@@ -4686,6 +5060,7 @@ function assertSourceLot(lot) {
|
|
|
4686
5060
|
"shopify",
|
|
4687
5061
|
"ayet",
|
|
4688
5062
|
"bitlabs",
|
|
5063
|
+
"google-ad-manager",
|
|
4689
5064
|
"subscription",
|
|
4690
5065
|
"event",
|
|
4691
5066
|
"competition",
|
|
@@ -4708,7 +5083,7 @@ function assertSourceLot(lot) {
|
|
|
4708
5083
|
"INVALID_CONTRACT",
|
|
4709
5084
|
"Source lot has an unsupported refund state"
|
|
4710
5085
|
);
|
|
4711
|
-
if (lot.source === "ayet" || lot.source === "bitlabs") {
|
|
5086
|
+
if (lot.source === "ayet" || lot.source === "bitlabs" || lot.source === "google-ad-manager") {
|
|
4712
5087
|
economyAssert(
|
|
4713
5088
|
lot.transferPolicy === "same-user-only" && lot.providerEventId !== void 0,
|
|
4714
5089
|
"SOURCE_LOT_RESTRICTED",
|
|
@@ -5802,7 +6177,7 @@ var DECISIONS = /* @__PURE__ */ new Set([
|
|
|
5802
6177
|
"approve",
|
|
5803
6178
|
"reject"
|
|
5804
6179
|
]);
|
|
5805
|
-
function
|
|
6180
|
+
function assertExactKeys5(value, allowed, label) {
|
|
5806
6181
|
economyAssert(
|
|
5807
6182
|
value !== null && typeof value === "object" && !Array.isArray(value),
|
|
5808
6183
|
"INVALID_CONTRACT",
|
|
@@ -5829,7 +6204,7 @@ function assertReasonCode(reasonCode) {
|
|
|
5829
6204
|
);
|
|
5830
6205
|
}
|
|
5831
6206
|
function assertOperatorAdjustmentPreview(preview) {
|
|
5832
|
-
|
|
6207
|
+
assertExactKeys5(preview, PREVIEW_KEYS, "Operator adjustment preview");
|
|
5833
6208
|
economyAssert(
|
|
5834
6209
|
preview.schemaVersion === ECONOMY_CONTRACT_VERSION && OPERATIONS.has(preview.operation) && TARGET_COMPONENTS.has(preview.targetComponent) && TRANSFER_POLICIES.has(preview.transferPolicy) && preview.refundPolicy === "not-refundable",
|
|
5835
6210
|
"INVALID_CONTRACT",
|
|
@@ -5908,7 +6283,7 @@ function canonicalOperatorAdjustmentPreviewPayload(preview) {
|
|
|
5908
6283
|
function assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash) {
|
|
5909
6284
|
assertOperatorAdjustmentPreview(preview);
|
|
5910
6285
|
assertCanonicalHash6(expectedPreviewHash, "expectedPreviewHash");
|
|
5911
|
-
|
|
6286
|
+
assertExactKeys5(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
|
|
5912
6287
|
economyAssert(
|
|
5913
6288
|
proposal.schemaVersion === ECONOMY_CONTRACT_VERSION && proposal.status === "pending-approval",
|
|
5914
6289
|
"INVALID_CONTRACT",
|
|
@@ -5935,7 +6310,7 @@ function assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash
|
|
|
5935
6310
|
);
|
|
5936
6311
|
}
|
|
5937
6312
|
function canonicalOperatorAdjustmentProposalPayload(proposal) {
|
|
5938
|
-
|
|
6313
|
+
assertExactKeys5(proposal, PROPOSAL_KEYS, "Operator adjustment proposal");
|
|
5939
6314
|
return JSON.stringify({
|
|
5940
6315
|
schemaVersion: proposal.schemaVersion,
|
|
5941
6316
|
proposalId: proposal.proposalId,
|
|
@@ -5950,7 +6325,7 @@ function canonicalOperatorAdjustmentProposalPayload(proposal) {
|
|
|
5950
6325
|
function assertOperatorAdjustmentDecision(decision, proposal, preview, expectedPreviewHash, expectedProposalHash) {
|
|
5951
6326
|
assertOperatorAdjustmentProposal(proposal, preview, expectedPreviewHash);
|
|
5952
6327
|
assertCanonicalHash6(expectedProposalHash, "expectedProposalHash");
|
|
5953
|
-
|
|
6328
|
+
assertExactKeys5(decision, DECISION_KEYS, "Operator adjustment decision");
|
|
5954
6329
|
economyAssert(
|
|
5955
6330
|
decision.schemaVersion === ECONOMY_CONTRACT_VERSION && DECISIONS.has(decision.decision),
|
|
5956
6331
|
"INVALID_CONTRACT",
|
|
@@ -5993,7 +6368,7 @@ function assertOperatorAdjustmentDecision(decision, proposal, preview, expectedP
|
|
|
5993
6368
|
);
|
|
5994
6369
|
}
|
|
5995
6370
|
function canonicalOperatorAdjustmentDecisionPayload(decision) {
|
|
5996
|
-
|
|
6371
|
+
assertExactKeys5(decision, DECISION_KEYS, "Operator adjustment decision");
|
|
5997
6372
|
return JSON.stringify({
|
|
5998
6373
|
schemaVersion: decision.schemaVersion,
|
|
5999
6374
|
decisionId: decision.decisionId,
|
|
@@ -6017,7 +6392,7 @@ function assertOperatorAdjustmentExecution(execution, preview, proposal, decisio
|
|
|
6017
6392
|
expectedProposalHash
|
|
6018
6393
|
);
|
|
6019
6394
|
assertCanonicalHash6(expectedDecisionHash, "expectedDecisionHash");
|
|
6020
|
-
|
|
6395
|
+
assertExactKeys5(execution, EXECUTION_KEYS, "Operator adjustment execution");
|
|
6021
6396
|
economyAssert(
|
|
6022
6397
|
execution.schemaVersion === ECONOMY_CONTRACT_VERSION,
|
|
6023
6398
|
"INVALID_CONTRACT",
|
|
@@ -6048,7 +6423,7 @@ function assertOperatorAdjustmentExecution(execution, preview, proposal, decisio
|
|
|
6048
6423
|
);
|
|
6049
6424
|
}
|
|
6050
6425
|
function canonicalOperatorAdjustmentExecutionPayload(execution) {
|
|
6051
|
-
|
|
6426
|
+
assertExactKeys5(execution, EXECUTION_KEYS, "Operator adjustment execution");
|
|
6052
6427
|
return JSON.stringify({
|
|
6053
6428
|
schemaVersion: execution.schemaVersion,
|
|
6054
6429
|
executionId: execution.executionId,
|
|
@@ -7121,6 +7496,7 @@ var ACTIVITY_SOURCES3 = /* @__PURE__ */ new Set([
|
|
|
7121
7496
|
"shopify",
|
|
7122
7497
|
"ayet",
|
|
7123
7498
|
"bitlabs",
|
|
7499
|
+
"google-ad-manager",
|
|
7124
7500
|
"subscription",
|
|
7125
7501
|
"event",
|
|
7126
7502
|
"competition",
|
|
@@ -8603,7 +8979,7 @@ var PORTABLE_KEYS = /* @__PURE__ */ new Set([
|
|
|
8603
8979
|
"signature",
|
|
8604
8980
|
...PORTABLE_BODY_KEYS
|
|
8605
8981
|
]);
|
|
8606
|
-
function
|
|
8982
|
+
function assertExactKeys6(value, allowedKeys, label) {
|
|
8607
8983
|
economyAssert(
|
|
8608
8984
|
value !== null && typeof value === "object" && !Array.isArray(value),
|
|
8609
8985
|
"INVALID_CONTRACT",
|
|
@@ -8692,7 +9068,7 @@ function canonicalSignatureMetadata(signature) {
|
|
|
8692
9068
|
};
|
|
8693
9069
|
}
|
|
8694
9070
|
function assertEconomySealedRecoveryPayload(payload) {
|
|
8695
|
-
|
|
9071
|
+
assertExactKeys6(
|
|
8696
9072
|
payload,
|
|
8697
9073
|
/* @__PURE__ */ new Set([
|
|
8698
9074
|
"schemaVersion",
|
|
@@ -8732,7 +9108,7 @@ function assertEconomySealedRecoveryPayload(payload) {
|
|
|
8732
9108
|
);
|
|
8733
9109
|
}
|
|
8734
9110
|
function assertAcceptanceBody(body) {
|
|
8735
|
-
|
|
9111
|
+
assertExactKeys6(
|
|
8736
9112
|
body,
|
|
8737
9113
|
"acceptanceEnvelopeId" in body ? ACCEPTANCE_KEYS : ACCEPTANCE_BODY_KEYS,
|
|
8738
9114
|
"Recovery acceptance body"
|
|
@@ -8801,7 +9177,7 @@ function createEconomyRecoveryAcceptanceEnvelope(body, hashCanonicalPayload2) {
|
|
|
8801
9177
|
};
|
|
8802
9178
|
}
|
|
8803
9179
|
function assertEconomyRecoveryAcceptanceEnvelope(envelope, hashCanonicalPayload2) {
|
|
8804
|
-
|
|
9180
|
+
assertExactKeys6(envelope, ACCEPTANCE_KEYS, "Recovery acceptance envelope");
|
|
8805
9181
|
assertAcceptanceBody(envelope);
|
|
8806
9182
|
assertEconomyIdentifier(
|
|
8807
9183
|
envelope.acceptanceEnvelopeId,
|
|
@@ -8842,7 +9218,7 @@ function canonicalEconomyRecoveryAcceptanceEnvelopePayload(envelope, hashCanonic
|
|
|
8842
9218
|
});
|
|
8843
9219
|
}
|
|
8844
9220
|
function assertCommittedResultBody(body) {
|
|
8845
|
-
|
|
9221
|
+
assertExactKeys6(
|
|
8846
9222
|
body,
|
|
8847
9223
|
"committedResultId" in body ? COMMITTED_RESULT_KEYS : COMMITTED_RESULT_BODY_KEYS,
|
|
8848
9224
|
"Recovery committed-result body"
|
|
@@ -8936,7 +9312,7 @@ function createEconomyRecoveryCommittedResult(body, hashCanonicalPayload2) {
|
|
|
8936
9312
|
};
|
|
8937
9313
|
}
|
|
8938
9314
|
function assertEconomyRecoveryCommittedResult(result, hashCanonicalPayload2) {
|
|
8939
|
-
|
|
9315
|
+
assertExactKeys6(
|
|
8940
9316
|
result,
|
|
8941
9317
|
COMMITTED_RESULT_KEYS,
|
|
8942
9318
|
"Recovery committed result"
|
|
@@ -8995,7 +9371,7 @@ function assertEconomyRecoveryResultLink(acceptance, result, hashCanonicalPayloa
|
|
|
8995
9371
|
);
|
|
8996
9372
|
}
|
|
8997
9373
|
function assertEconomyEvidenceSignatureMetadata(signature) {
|
|
8998
|
-
|
|
9374
|
+
assertExactKeys6(
|
|
8999
9375
|
signature,
|
|
9000
9376
|
/* @__PURE__ */ new Set([
|
|
9001
9377
|
"schemaVersion",
|
|
@@ -9015,7 +9391,7 @@ function assertEconomyEvidenceSignatureMetadata(signature) {
|
|
|
9015
9391
|
parseIsoTimestamp(signature.signedAt);
|
|
9016
9392
|
}
|
|
9017
9393
|
function assertEconomyEvidenceSignature(signature) {
|
|
9018
|
-
|
|
9394
|
+
assertExactKeys6(
|
|
9019
9395
|
signature,
|
|
9020
9396
|
/* @__PURE__ */ new Set([
|
|
9021
9397
|
"schemaVersion",
|
|
@@ -9037,7 +9413,7 @@ function assertEconomyEvidenceSignature(signature) {
|
|
|
9037
9413
|
assertBase64url(signature.value, "Evidence signature value", 32, 2048);
|
|
9038
9414
|
}
|
|
9039
9415
|
function assertRegionalEvidenceBody(body) {
|
|
9040
|
-
|
|
9416
|
+
assertExactKeys6(
|
|
9041
9417
|
body,
|
|
9042
9418
|
"evidenceReceiptId" in body ? REGIONAL_KEYS : REGIONAL_BODY_KEYS,
|
|
9043
9419
|
"Regional evidence-receipt body"
|
|
@@ -9129,7 +9505,7 @@ function createEconomyRegionalEvidenceReceipt(body, signature, hashCanonicalPayl
|
|
|
9129
9505
|
};
|
|
9130
9506
|
}
|
|
9131
9507
|
function assertEconomyRegionalEvidenceReceipt(receipt, hashCanonicalPayload2) {
|
|
9132
|
-
|
|
9508
|
+
assertExactKeys6(receipt, REGIONAL_KEYS, "Regional evidence receipt");
|
|
9133
9509
|
assertRegionalEvidenceBody(receipt);
|
|
9134
9510
|
assertEconomyIdentifier(receipt.evidenceReceiptId, "evidenceReceiptId");
|
|
9135
9511
|
assertEconomyEvidenceSignature(receipt.signature);
|
|
@@ -9331,7 +9707,7 @@ function assertEconomyRegionalEvidenceEquality(receipts, expectedRegions, hashCa
|
|
|
9331
9707
|
);
|
|
9332
9708
|
}
|
|
9333
9709
|
function assertEconomyMerkleInclusionProof(proof) {
|
|
9334
|
-
|
|
9710
|
+
assertExactKeys6(
|
|
9335
9711
|
proof,
|
|
9336
9712
|
/* @__PURE__ */ new Set([
|
|
9337
9713
|
"schemaVersion",
|
|
@@ -9362,7 +9738,7 @@ function assertEconomyMerkleInclusionProof(proof) {
|
|
|
9362
9738
|
"Merkle leaf position is outside its bounded tree"
|
|
9363
9739
|
);
|
|
9364
9740
|
for (const step of proof.siblings) {
|
|
9365
|
-
|
|
9741
|
+
assertExactKeys6(
|
|
9366
9742
|
step,
|
|
9367
9743
|
/* @__PURE__ */ new Set(["schemaVersion", "side", "hash"]),
|
|
9368
9744
|
"Merkle proof step"
|
|
@@ -9451,7 +9827,7 @@ function assertEconomyMerkleInclusion(proof, anchor, hashCanonicalPayload2) {
|
|
|
9451
9827
|
);
|
|
9452
9828
|
}
|
|
9453
9829
|
function assertPortableEvidenceReference(reference) {
|
|
9454
|
-
|
|
9830
|
+
assertExactKeys6(
|
|
9455
9831
|
reference,
|
|
9456
9832
|
/* @__PURE__ */ new Set([
|
|
9457
9833
|
"schemaVersion",
|
|
@@ -9488,7 +9864,7 @@ function canonicalPortableEvidenceReference(reference) {
|
|
|
9488
9864
|
};
|
|
9489
9865
|
}
|
|
9490
9866
|
function assertPortableBody(body) {
|
|
9491
|
-
|
|
9867
|
+
assertExactKeys6(
|
|
9492
9868
|
body,
|
|
9493
9869
|
"portableReceiptId" in body ? PORTABLE_KEYS : PORTABLE_BODY_KEYS,
|
|
9494
9870
|
"Portable customer-receipt body"
|
|
@@ -9612,7 +9988,7 @@ function createEconomyPortableCustomerReceipt(body, signature, hashCanonicalPayl
|
|
|
9612
9988
|
};
|
|
9613
9989
|
}
|
|
9614
9990
|
function assertEconomyPortableCustomerReceipt(receipt, hashCanonicalPayload2) {
|
|
9615
|
-
|
|
9991
|
+
assertExactKeys6(receipt, PORTABLE_KEYS, "Portable customer receipt");
|
|
9616
9992
|
assertPortableBody(receipt);
|
|
9617
9993
|
assertEconomyIdentifier(receipt.portableReceiptId, "portableReceiptId");
|
|
9618
9994
|
assertEconomyEvidenceSignature(receipt.signature);
|
|
@@ -9912,7 +10288,7 @@ var DOCUMENT_ID_KEYS = /* @__PURE__ */ new Set([
|
|
|
9912
10288
|
"lifetimeProjectionId",
|
|
9913
10289
|
"outboxEventId"
|
|
9914
10290
|
]);
|
|
9915
|
-
function
|
|
10291
|
+
function assertExactKeys7(value, allowed, label) {
|
|
9916
10292
|
economyAssert(
|
|
9917
10293
|
value !== null && typeof value === "object" && !Array.isArray(value),
|
|
9918
10294
|
"INVALID_CONTRACT",
|
|
@@ -9952,7 +10328,7 @@ function createPersonalWalletInitializationDocumentIds(subjectAccountId, hash) {
|
|
|
9952
10328
|
};
|
|
9953
10329
|
}
|
|
9954
10330
|
function assertPersonalWalletInitializationCommand(command) {
|
|
9955
|
-
|
|
10331
|
+
assertExactKeys7(command, COMMAND_KEYS, "Wallet initialization command");
|
|
9956
10332
|
economyAssert(
|
|
9957
10333
|
command.schemaVersion === ECONOMY_CONTRACT_VERSION && command.commandType === "initialize-wallet" && command.walletKind === "personal",
|
|
9958
10334
|
"INVALID_CONTRACT",
|
|
@@ -9976,7 +10352,7 @@ function canonicalPersonalWalletInitializationCommandPayload(command) {
|
|
|
9976
10352
|
});
|
|
9977
10353
|
}
|
|
9978
10354
|
function assertPersonalWalletInitializationOutboxIntent(intent) {
|
|
9979
|
-
|
|
10355
|
+
assertExactKeys7(intent, OUTBOX_KEYS, "Wallet initialization outbox intent");
|
|
9980
10356
|
economyAssert(
|
|
9981
10357
|
intent.schemaVersion === ECONOMY_CONTRACT_VERSION && intent.eventType === "wallet.initialized.v1",
|
|
9982
10358
|
"INVALID_CONTRACT",
|
|
@@ -10076,8 +10452,8 @@ function createPersonalWalletInitializationState(input, hash) {
|
|
|
10076
10452
|
return state;
|
|
10077
10453
|
}
|
|
10078
10454
|
function assertPersonalWalletInitializationState(state) {
|
|
10079
|
-
|
|
10080
|
-
|
|
10455
|
+
assertExactKeys7(state, STATE_KEYS, "Wallet initialization state");
|
|
10456
|
+
assertExactKeys7(
|
|
10081
10457
|
state.documentIds,
|
|
10082
10458
|
DOCUMENT_ID_KEYS,
|
|
10083
10459
|
"Wallet initialization document IDs"
|
|
@@ -10129,6 +10505,9 @@ function assertPersonalWalletInitializationState(state) {
|
|
|
10129
10505
|
ECONOMY_CONTRACT_VERSION,
|
|
10130
10506
|
ECONOMY_RECOVERY_PROTOCOL_VERSION,
|
|
10131
10507
|
EconomyError,
|
|
10508
|
+
GOOGLE_REWARDED_WEB_MINIMUM_NET_MICROS_PER_TOKEN,
|
|
10509
|
+
GOOGLE_REWARDED_WEB_NOMINAL_MICROS_PER_TOKEN,
|
|
10510
|
+
GOOGLE_REWARDED_WEB_PROVIDER,
|
|
10132
10511
|
MODULE_ALLOWANCE_PURPOSE,
|
|
10133
10512
|
PRE_UTILITY_BACKER_COHORT,
|
|
10134
10513
|
TOKEN_SUBUNITS_MAX,
|
|
@@ -10201,6 +10580,10 @@ function assertPersonalWalletInitializationState(state) {
|
|
|
10201
10580
|
assertFlatTokenCatalog,
|
|
10202
10581
|
assertFxSnapshot,
|
|
10203
10582
|
assertGameplayAllocation,
|
|
10583
|
+
assertGoogleRewardedWebGrantClaim,
|
|
10584
|
+
assertGoogleRewardedWebQuote,
|
|
10585
|
+
assertGoogleRewardedWebReconciliation,
|
|
10586
|
+
assertGoogleRewardedWebStateTransition,
|
|
10204
10587
|
assertJournalChainHead,
|
|
10205
10588
|
assertModuleAllowance,
|
|
10206
10589
|
assertModulePurchaseReceipt,
|
|
@@ -10294,6 +10677,7 @@ function assertPersonalWalletInitializationState(state) {
|
|
|
10294
10677
|
createEconomyRecoveryCommittedResult,
|
|
10295
10678
|
createEconomyRegionalEvidenceReceipt,
|
|
10296
10679
|
createGameplayAllocation,
|
|
10680
|
+
createGoogleRewardedWebQuote,
|
|
10297
10681
|
createInitialSourceLotSnapshot,
|
|
10298
10682
|
createModuleAllowance,
|
|
10299
10683
|
createModulePurchaseReceipt,
|