@owlmeans/server-payment 0.1.18-rc.2 → 0.1.18-rc.21
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 +109 -25
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-payment/SKILL.md +475 -52
- package/build/actions/index.d.ts +1 -0
- package/build/actions/index.d.ts.map +1 -1
- package/build/actions/index.js +1 -0
- package/build/actions/index.js.map +1 -1
- package/build/actions/resync-subscriptions.d.ts +3 -0
- package/build/actions/resync-subscriptions.d.ts.map +1 -0
- package/build/actions/resync-subscriptions.js +7 -0
- package/build/actions/resync-subscriptions.js.map +1 -0
- package/build/actions/resync.d.ts +1 -0
- package/build/actions/resync.d.ts.map +1 -1
- package/build/actions/resync.js +7 -3
- package/build/actions/resync.js.map +1 -1
- package/build/actions/webhook.d.ts.map +1 -1
- package/build/actions/webhook.js +6 -3
- package/build/actions/webhook.js.map +1 -1
- package/build/config.d.ts +60 -5
- package/build/config.d.ts.map +1 -1
- package/build/config.js +237 -5
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +75 -3
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +94 -5
- package/build/consts.js.map +1 -1
- package/build/consumer/capture.d.ts +74 -0
- package/build/consumer/capture.d.ts.map +1 -0
- package/build/consumer/capture.js +291 -0
- package/build/consumer/capture.js.map +1 -0
- package/build/consumer/format.d.ts +27 -0
- package/build/consumer/format.d.ts.map +1 -0
- package/build/consumer/format.js +81 -0
- package/build/consumer/format.js.map +1 -0
- package/build/consumer/handlers.d.ts +28 -0
- package/build/consumer/handlers.d.ts.map +1 -0
- package/build/consumer/handlers.js +173 -0
- package/build/consumer/handlers.js.map +1 -0
- package/build/consumer/index.d.ts +7 -0
- package/build/consumer/index.d.ts.map +1 -0
- package/build/consumer/index.js +6 -0
- package/build/consumer/index.js.map +1 -0
- package/build/consumer/mail.d.ts +27 -0
- package/build/consumer/mail.d.ts.map +1 -0
- package/build/consumer/mail.js +314 -0
- package/build/consumer/mail.js.map +1 -0
- package/build/consumer/origin.d.ts +14 -0
- package/build/consumer/origin.d.ts.map +1 -0
- package/build/consumer/origin.js +47 -0
- package/build/consumer/origin.js.map +1 -0
- package/build/consumer/reconcile.d.ts +12 -0
- package/build/consumer/reconcile.d.ts.map +1 -0
- package/build/consumer/reconcile.js +317 -0
- package/build/consumer/reconcile.js.map +1 -0
- package/build/consumer/records.d.ts +78 -0
- package/build/consumer/records.d.ts.map +1 -0
- package/build/consumer/records.js +296 -0
- package/build/consumer/records.js.map +1 -0
- package/build/consumer/service.d.ts +51 -0
- package/build/consumer/service.d.ts.map +1 -0
- package/build/consumer/service.js +760 -0
- package/build/consumer/service.js.map +1 -0
- package/build/consumer/withdrawal.d.ts +57 -0
- package/build/consumer/withdrawal.d.ts.map +1 -0
- package/build/consumer/withdrawal.js +247 -0
- package/build/consumer/withdrawal.js.map +1 -0
- package/build/entitlement.d.ts +10 -0
- package/build/entitlement.d.ts.map +1 -0
- package/build/entitlement.js +69 -0
- package/build/entitlement.js.map +1 -0
- package/build/entrypoints.d.ts +1 -1
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +2 -1
- package/build/entrypoints.js.map +1 -1
- package/build/gate.d.ts +32 -4
- package/build/gate.d.ts.map +1 -1
- package/build/gate.js +59 -19
- package/build/gate.js.map +1 -1
- package/build/index.d.ts +18 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +15 -3
- package/build/index.js.map +1 -1
- package/build/limit.d.ts +13 -0
- package/build/limit.d.ts.map +1 -0
- package/build/limit.js +47 -0
- package/build/limit.js.map +1 -0
- package/build/model.d.ts +10 -1
- package/build/model.d.ts.map +1 -1
- package/build/model.js +215 -17
- package/build/model.js.map +1 -1
- package/build/observer.d.ts +9 -0
- package/build/observer.d.ts.map +1 -1
- package/build/observer.js +38 -12
- package/build/observer.js.map +1 -1
- package/build/plan.d.ts +22 -0
- package/build/plan.d.ts.map +1 -0
- package/build/plan.js +72 -0
- package/build/plan.js.map +1 -0
- package/build/plugins/checkout-plugins.d.ts +49 -0
- package/build/plugins/checkout-plugins.d.ts.map +1 -0
- package/build/plugins/checkout-plugins.js +124 -0
- package/build/plugins/checkout-plugins.js.map +1 -0
- package/build/plugins/estimate.d.ts +43 -0
- package/build/plugins/estimate.d.ts.map +1 -0
- package/build/plugins/estimate.js +268 -0
- package/build/plugins/estimate.js.map +1 -0
- package/build/plugins/events.d.ts +45 -10
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +605 -136
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx.d.ts +31 -0
- package/build/plugins/fx.d.ts.map +1 -0
- package/build/plugins/fx.js +81 -0
- package/build/plugins/fx.js.map +1 -0
- package/build/plugins/portal.d.ts +37 -0
- package/build/plugins/portal.d.ts.map +1 -0
- package/build/plugins/portal.js +265 -0
- package/build/plugins/portal.js.map +1 -0
- package/build/plugins/refunds.d.ts +33 -0
- package/build/plugins/refunds.d.ts.map +1 -0
- package/build/plugins/refunds.js +80 -0
- package/build/plugins/refunds.js.map +1 -0
- package/build/plugins/stripe.d.ts +36 -4
- package/build/plugins/stripe.d.ts.map +1 -1
- package/build/plugins/stripe.js +492 -97
- package/build/plugins/stripe.js.map +1 -1
- package/build/plugins/webhook-manager.d.ts +46 -0
- package/build/plugins/webhook-manager.d.ts.map +1 -0
- package/build/plugins/webhook-manager.js +231 -0
- package/build/plugins/webhook-manager.js.map +1 -0
- package/build/reconcile.d.ts +15 -0
- package/build/reconcile.d.ts.map +1 -0
- package/build/reconcile.js +88 -0
- package/build/reconcile.js.map +1 -0
- package/build/resource.d.ts +12 -1
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +97 -6
- package/build/resource.js.map +1 -1
- package/build/service.d.ts +28 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +146 -19
- package/build/service.js.map +1 -1
- package/build/subscription.d.ts +48 -0
- package/build/subscription.d.ts.map +1 -0
- package/build/subscription.js +176 -0
- package/build/subscription.js.map +1 -0
- package/build/sync.d.ts +28 -1
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +208 -31
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +1115 -36
- package/build/types.d.ts.map +1 -1
- package/build/usage.d.ts +63 -0
- package/build/usage.d.ts.map +1 -0
- package/build/usage.js +363 -0
- package/build/usage.js.map +1 -0
- package/build/utils.d.ts +52 -1
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +69 -7
- package/build/utils.js.map +1 -1
- package/package.json +17 -13
- package/src/actions/index.ts +1 -0
- package/src/actions/resync-subscriptions.ts +10 -0
- package/src/actions/resync.ts +6 -3
- package/src/actions/webhook.ts +5 -3
- package/src/config.ts +264 -8
- package/src/consts.ts +114 -6
- package/src/consumer/capture.ts +362 -0
- package/src/consumer/format.ts +90 -0
- package/src/consumer/handlers.ts +211 -0
- package/src/consumer/index.ts +6 -0
- package/src/consumer/mail.ts +368 -0
- package/src/consumer/origin.ts +63 -0
- package/src/consumer/reconcile.ts +329 -0
- package/src/consumer/records.ts +374 -0
- package/src/consumer/service.ts +868 -0
- package/src/consumer/withdrawal.ts +302 -0
- package/src/entitlement.ts +84 -0
- package/src/entrypoints.ts +2 -1
- package/src/gate.ts +88 -21
- package/src/index.ts +24 -3
- package/src/limit.ts +57 -0
- package/src/model.ts +237 -18
- package/src/observer.ts +44 -11
- package/src/plan.ts +89 -0
- package/src/plugins/checkout-plugins.ts +155 -0
- package/src/plugins/estimate.ts +339 -0
- package/src/plugins/events.ts +677 -121
- package/src/plugins/fx.ts +122 -0
- package/src/plugins/portal.ts +306 -0
- package/src/plugins/refunds.ts +108 -0
- package/src/plugins/stripe.ts +581 -96
- package/src/plugins/webhook-manager.ts +270 -0
- package/src/reconcile.ts +103 -0
- package/src/resource.ts +152 -7
- package/src/service.ts +174 -18
- package/src/subscription.ts +231 -0
- package/src/sync.ts +249 -29
- package/src/types.ts +1227 -32
- package/src/usage.ts +453 -0
- package/src/utils.ts +127 -10
- package/tests/checkout-consumer.spec.ts +348 -0
- package/tests/checkout-plugins.spec.ts +164 -0
- package/tests/checkout.spec.ts +184 -83
- package/tests/consumer-events.spec.ts +218 -0
- package/tests/consumer-fixtures.ts +132 -0
- package/tests/consumer-ops.spec.ts +351 -0
- package/tests/consumer-rights.integration.spec.ts +150 -0
- package/tests/consumer-rights.spec.ts +501 -0
- package/tests/context.ts +109 -0
- package/tests/entitlement.spec.ts +103 -0
- package/tests/estimate.spec.ts +240 -0
- package/tests/events.spec.ts +356 -0
- package/tests/fake-stripe.ts +972 -0
- package/tests/gate.spec.ts +62 -72
- package/tests/limit-gate.spec.ts +68 -0
- package/tests/portal.spec.ts +200 -0
- package/tests/protocol.spec.ts +23 -6
- package/tests/sync.spec.ts +114 -0
- package/tests/usage.integration.spec.ts +101 -0
- package/tests/usage.spec.ts +171 -0
- package/tests/webhook-manager.spec.ts +152 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { STRIPE_PAYGATE_ALIAS } from '../consts.js';
|
|
2
|
+
import { fulfillments, idOf, isMissingObject, subscriptions } from '../utils.js';
|
|
3
|
+
/** A charge by id, or `null` when the paygate has none. */
|
|
4
|
+
export const retrieveCharge = async (stripe, chargeId) => {
|
|
5
|
+
try {
|
|
6
|
+
return await stripe.charges.retrieve(chargeId);
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
if (isMissingObject(error)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const subscriptionOfInvoice = async (ctx, stripe, invoiceId) => {
|
|
16
|
+
const latest = await subscriptions(ctx).load({ paygate: STRIPE_PAYGATE_ALIAS, latestInvoiceId: invoiceId });
|
|
17
|
+
if (latest != null) {
|
|
18
|
+
return latest;
|
|
19
|
+
}
|
|
20
|
+
let invoice;
|
|
21
|
+
try {
|
|
22
|
+
invoice = await stripe.invoices.retrieve(invoiceId);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (isMissingObject(error)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
// `invoice.subscription` is top-level on the API version the client is pinned to.
|
|
31
|
+
const subscriptionId = idOf(invoice.subscription);
|
|
32
|
+
return subscriptionId != null
|
|
33
|
+
? await subscriptions(ctx).byExternalId(subscriptionId, STRIPE_PAYGATE_ALIAS)
|
|
34
|
+
: null;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a refund or a dispute to the record it is about: by payment intent to a fulfillment;
|
|
38
|
+
* by charge to a fulfillment (stored charge, else the charge's payment intent — whose charge id is
|
|
39
|
+
* then remembered), else the charge's invoice; by invoice to the subscription whose latest invoice
|
|
40
|
+
* it is, else the invoice's subscription. `null` when nothing here paid for it.
|
|
41
|
+
*/
|
|
42
|
+
export const resolvePaymentTarget = async (ctx, stripe, ref) => {
|
|
43
|
+
const ledger = fulfillments(ctx);
|
|
44
|
+
let charge = ref.charge ?? null;
|
|
45
|
+
let paymentIntentId = ref.paymentIntentId;
|
|
46
|
+
const chargeId = ref.chargeId ?? charge?.id;
|
|
47
|
+
if (paymentIntentId != null) {
|
|
48
|
+
const record = await ledger.load({ paygate: STRIPE_PAYGATE_ALIAS, paymentIntentId });
|
|
49
|
+
if (record != null) {
|
|
50
|
+
return { kind: 'fulfillment', record, charge, paymentIntentId };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
let invoiceId = ref.invoiceId;
|
|
54
|
+
if (chargeId != null) {
|
|
55
|
+
const record = await ledger.load({ paygate: STRIPE_PAYGATE_ALIAS, chargeId });
|
|
56
|
+
if (record != null) {
|
|
57
|
+
return { kind: 'fulfillment', record, charge, paymentIntentId: paymentIntentId ?? record.paymentIntentId };
|
|
58
|
+
}
|
|
59
|
+
charge = charge ?? await retrieveCharge(stripe, chargeId);
|
|
60
|
+
const chargeIntent = idOf(charge?.payment_intent);
|
|
61
|
+
if (chargeIntent != null && chargeIntent !== paymentIntentId) {
|
|
62
|
+
paymentIntentId = chargeIntent;
|
|
63
|
+
const byIntent = await ledger.load({ paygate: STRIPE_PAYGATE_ALIAS, paymentIntentId: chargeIntent });
|
|
64
|
+
if (byIntent != null) {
|
|
65
|
+
const record = byIntent.chargeId == null ? await ledger.update({ ...byIntent, chargeId }) : byIntent;
|
|
66
|
+
return { kind: 'fulfillment', record, charge, paymentIntentId: chargeIntent };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// `charge.invoice` is top-level on the API version the client is pinned to.
|
|
70
|
+
invoiceId = invoiceId ?? idOf(charge?.invoice);
|
|
71
|
+
}
|
|
72
|
+
if (invoiceId != null) {
|
|
73
|
+
const record = await subscriptionOfInvoice(ctx, stripe, invoiceId);
|
|
74
|
+
if (record != null) {
|
|
75
|
+
return { kind: 'subscription', record, charge, paymentIntentId, invoiceId };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=refunds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refunds.js","sourceRoot":"","sources":["../../src/plugins/refunds.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAmBhF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,MAAc,EAAE,QAAgB,EAAiC,EAAE;IACtG,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAA;QACb,CAAC;QACD,MAA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AAC,CAAC,CAAC,CAAC,QAAQ,CAAA;gBACpG,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,CAAA;YAC/E,CAAC;QACH,CAAC;QACD,4EAA4E;QAC5E,SAAS,GAAG,SAAS,IAAI,IAAI,CAAE,MAA0E,EAAE,OAAO,CAAC,CAAA;IACrH,CAAC;IAED,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;QAClE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,CAAA;QAC7E,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import Stripe from 'stripe';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import type Stripe from 'stripe';
|
|
2
|
+
import { TaxBehavior } from '@owlmeans/payment';
|
|
3
|
+
import type { Context as ApiContext } from '@owlmeans/server-api';
|
|
4
|
+
import type { CheckoutPlugin, CreateLinkParams, PaymentPlan, PaymentProduct } from '../types.js';
|
|
5
|
+
export declare const amountCheckoutLineItem: (product: PaymentProduct, plan: PaymentPlan, amountMinor: number, behavior?: TaxBehavior) => {
|
|
4
6
|
lineItem: Stripe.Checkout.SessionCreateParams.LineItem;
|
|
5
7
|
chargeMinor: number;
|
|
6
8
|
currency: string;
|
|
@@ -10,5 +12,35 @@ export declare const quantityCheckoutLineItem: (price: Stripe.Price, policy: {
|
|
|
10
12
|
maximum: number;
|
|
11
13
|
default: number;
|
|
12
14
|
}) => Stripe.Checkout.SessionCreateParams.LineItem;
|
|
13
|
-
|
|
15
|
+
/** The plan an amount/quantity checkout of a consumable product sells: the named one, else the first. */
|
|
16
|
+
export declare const consumablePlanOf: (ctx: ApiContext, productSku: string, planSku?: string) => Promise<{
|
|
17
|
+
product: PaymentProduct;
|
|
18
|
+
plan: PaymentPlan;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Stripe refuses `consent_collection.terms_of_service` while the account has no terms-of-service URL
|
|
22
|
+
* in its Dashboard (Settings → Public details): an `invalid_request_error` on the param
|
|
23
|
+
* `consent_collection[terms_of_service]` saying "You cannot collect consent to your terms of service
|
|
24
|
+
* unless a URL is set in the Stripe Dashboard …". Matched on the param with a terms message, or on
|
|
25
|
+
* the message alone; any other error type never matches.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isMissingTermsUrl: (error: unknown) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* A Stripe Checkout URL: an amount or quantity purchase of a consumable product, or a subscription
|
|
30
|
+
* to `planSku` (else the product's first recurring plan). A free plan is never checked out.
|
|
31
|
+
*
|
|
32
|
+
* With a consumer-rights policy: a locked billing country overrides the declared one (another is
|
|
33
|
+
* `BillingCountryLocked`); the charge currency is the profile's, else the region's; an amount
|
|
34
|
+
* checkout is narrowed by the checkout plugins (`CheckoutLimitExceeded`) and charged without FX
|
|
35
|
+
* when its policy currency is the charge currency; a subscription needs a fresh start request
|
|
36
|
+
* bound to its plan; the terms checkbox and the legal submit texts come from the copy.
|
|
37
|
+
*/
|
|
38
|
+
export declare const createCheckoutLink: (ctx: ApiContext, stripe: Stripe, params: CreateLinkParams, plugins?: readonly CheckoutPlugin[]) => Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Verify a Stripe webhook against the configured override secret, then the managed endpoint's
|
|
41
|
+
* stored one, and dispatch it.
|
|
42
|
+
*
|
|
43
|
+
* @throws PaygateError('signature') | WebhookSetupError('secret')
|
|
44
|
+
*/
|
|
45
|
+
export declare const handleStripeWebhook: (ctx: ApiContext, stripe: Stripe, request: unknown) => Promise<void>;
|
|
14
46
|
//# sourceMappingURL=stripe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/plugins/stripe.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/plugins/stripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAG8C,WAAW,EAC/D,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAejE,OAAO,KAAK,EACO,cAAc,EAAuB,gBAAgB,EAAE,WAAW,EAAE,cAAc,EACpG,MAAM,aAAa,CAAA;AAqGpB,eAAO,MAAM,sBAAsB,YACxB,cAAc,QAAQ,WAAW,eAAe,MAAM,aAAY,WAAW,KACrF;IAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAejG,CAAA;AAED,eAAO,MAAM,wBAAwB,UAC5B,MAAM,CAAC,KAAK,UAAU;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KACjF,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,QAIrC,CAAA;AAEF,yGAAyG;AACzG,eAAO,MAAM,gBAAgB,QACtB,UAAU,cAAc,MAAM,YAAY,MAAM,KACpD,OAAO,CAAC;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAWxD,CAAA;AAuJD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,OAelD,CAAA;AA+GD;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,Q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