@shdan/submesh 0.1.0 → 1.0.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 +2 -2
- package/dist/contracts.d.ts +39 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/drizzle/ensure-schema.d.ts.map +1 -1
- package/dist/drizzle/ensure-schema.js +12 -0
- package/dist/drizzle/ensure-schema.js.map +1 -1
- package/dist/drizzle/schema.d.ts.map +1 -1
- package/dist/drizzle/schema.js +4 -1
- package/dist/drizzle/schema.js.map +1 -1
- package/dist/drizzle/subject-repository.d.ts.map +1 -1
- package/dist/drizzle/subject-repository.js +7 -3
- package/dist/drizzle/subject-repository.js.map +1 -1
- package/dist/drizzle/summary-repository.d.ts.map +1 -1
- package/dist/drizzle/summary-repository.js +16 -7
- package/dist/drizzle/summary-repository.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +27 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +61 -0
- package/dist/logger.js.map +1 -1
- package/dist/plugins/builtin-plugins.d.ts.map +1 -1
- package/dist/plugins/builtin-plugins.js +2 -1
- package/dist/plugins/builtin-plugins.js.map +1 -1
- package/dist/providers/stripe/plugin/stripe-plan-sync.d.ts +4 -0
- package/dist/providers/stripe/plugin/stripe-plan-sync.d.ts.map +1 -0
- package/dist/providers/stripe/plugin/stripe-plan-sync.js +83 -0
- package/dist/providers/stripe/plugin/stripe-plan-sync.js.map +1 -0
- package/dist/providers/stripe/plugin/stripe.d.ts +20 -0
- package/dist/providers/stripe/plugin/stripe.d.ts.map +1 -0
- package/dist/providers/stripe/plugin/stripe.js +238 -0
- package/dist/providers/stripe/plugin/stripe.js.map +1 -0
- package/dist/providers/stripe/security/stripe-signature-verification.d.ts +3 -0
- package/dist/providers/stripe/security/stripe-signature-verification.d.ts.map +1 -0
- package/dist/providers/stripe/security/stripe-signature-verification.js +162 -0
- package/dist/providers/stripe/security/stripe-signature-verification.js.map +1 -0
- package/dist/providers/stripe/services/stripe-subscription-verification-service.d.ts +3 -0
- package/dist/providers/stripe/services/stripe-subscription-verification-service.d.ts.map +1 -0
- package/dist/providers/stripe/services/stripe-subscription-verification-service.js +65 -0
- package/dist/providers/stripe/services/stripe-subscription-verification-service.js.map +1 -0
- package/dist/services/managed-subscription-service.d.ts +2 -1
- package/dist/services/managed-subscription-service.d.ts.map +1 -1
- package/dist/services/managed-subscription-service.js +7 -1
- package/dist/services/managed-subscription-service.js.map +1 -1
- package/dist/services/plan-provisioning-service.d.ts +2 -1
- package/dist/services/plan-provisioning-service.d.ts.map +1 -1
- package/dist/services/plan-provisioning-service.js +16 -1
- package/dist/services/plan-provisioning-service.js.map +1 -1
- package/dist/services/provider-subscription-sync-service.d.ts +2 -1
- package/dist/services/provider-subscription-sync-service.d.ts.map +1 -1
- package/dist/services/provider-subscription-sync-service.js +7 -1
- package/dist/services/provider-subscription-sync-service.js.map +1 -1
- package/dist/services/retry-event-replay.d.ts +4 -0
- package/dist/services/retry-event-replay.d.ts.map +1 -0
- package/dist/services/retry-event-replay.js +53 -0
- package/dist/services/retry-event-replay.js.map +1 -0
- package/dist/services/webhook-ingestion-service.d.ts.map +1 -1
- package/dist/services/webhook-ingestion-service.js +23 -7
- package/dist/services/webhook-ingestion-service.js.map +1 -1
- package/dist/submesh.d.ts +15 -1
- package/dist/submesh.d.ts.map +1 -1
- package/dist/submesh.js +117 -27
- package/dist/submesh.js.map +1 -1
- package/dist/utils/validation.d.ts +6 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +7 -1
- package/dist/utils/validation.js.map +1 -1
- package/drizzle/0001_steady_perf_indexes.sql +8 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +10 -10
- package/LICENSE +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-subscription-sync-service.d.ts","sourceRoot":"","sources":["../../src/services/provider-subscription-sync-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-subscription-sync-service.d.ts","sourceRoot":"","sources":["../../src/services/provider-subscription-sync-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAc,MAAM,cAAc,CAAC;AAGzD,wBAAsB,gCAAgC,CACpD,YAAY,EAAE,mBAAmB,EACjC,KAAK,EAAE,0BAA0B,EACjC,MAAM,GAAE,aAA0B,GACjC,OAAO,CAAC,YAAY,CAAC,CAsBvB"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { ConflictError } from "../errors.js";
|
|
2
|
+
import { noopLogger } from "../logger.js";
|
|
2
3
|
import { ingestCanonicalSubscription } from "./canonical-subscription-service.js";
|
|
3
|
-
export async function syncVerifiedProviderSubscription(repositories, input) {
|
|
4
|
+
export async function syncVerifiedProviderSubscription(repositories, input, logger = noopLogger) {
|
|
4
5
|
if (!input.subjectId) {
|
|
5
6
|
throw new Error("Verified provider subscription sync requires subjectId.");
|
|
6
7
|
}
|
|
8
|
+
logger.info("Syncing verified provider subscription", {
|
|
9
|
+
subjectId: input.subjectId,
|
|
10
|
+
pluginKey: input.pluginKey,
|
|
11
|
+
sourceRef: input.sourceRef,
|
|
12
|
+
});
|
|
7
13
|
const existing = await repositories.subscriptions.getBySource(input.pluginKey, input.sourceRef);
|
|
8
14
|
if (existing && existing.subjectId !== input.subjectId) {
|
|
9
15
|
throw new ConflictError(`Provider subscription ${input.pluginKey}:${input.sourceRef} is already linked to subject ${existing.subjectId}.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-subscription-sync-service.js","sourceRoot":"","sources":["../../src/services/provider-subscription-sync-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,YAAiC,EACjC,KAAiC;
|
|
1
|
+
{"version":3,"file":"provider-subscription-sync-service.js","sourceRoot":"","sources":["../../src/services/provider-subscription-sync-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAiB,UAAU,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,YAAiC,EACjC,KAAiC,EACjC,SAAwB,UAAU;IAElC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,wCAAwC,EAAE;QACpD,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,WAAW,CAC3D,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,SAAS,CAChB,CAAC;IACF,IAAI,QAAQ,IAAI,QAAQ,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,EAAE,CAAC;QACvD,MAAM,IAAI,aAAa,CACrB,yBAAyB,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,iCAAiC,QAAQ,CAAC,SAAS,GAAG,CAClH,CAAC;IACJ,CAAC;IAED,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,2BAA2B,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ParsedWebhookEvent } from "@shdan/submesh-core";
|
|
2
|
+
export declare function extractRetryBody(payload: Record<string, unknown>, eventId: string): unknown;
|
|
3
|
+
export declare function extractRetryParsedEvents(payload: Record<string, unknown>): ParsedWebhookEvent[];
|
|
4
|
+
//# sourceMappingURL=retry-event-replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-event-replay.d.ts","sourceRoot":"","sources":["../../src/services/retry-event-replay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAqD9D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAO3F;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,kBAAkB,EAAE,CAWtB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ValidationError } from "../errors.js";
|
|
2
|
+
function asRecord(value) {
|
|
3
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
function isParsedWebhookEvent(value) {
|
|
9
|
+
const record = asRecord(value);
|
|
10
|
+
if (!record) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return (typeof record.eventKey === "string" &&
|
|
14
|
+
typeof record.eventType === "string" &&
|
|
15
|
+
(record.sourceRef === undefined ||
|
|
16
|
+
record.sourceRef === null ||
|
|
17
|
+
typeof record.sourceRef === "string") &&
|
|
18
|
+
Array.isArray(record.records));
|
|
19
|
+
}
|
|
20
|
+
function unwrapStoredPayloadValue(value, eventId) {
|
|
21
|
+
const record = asRecord(value);
|
|
22
|
+
if (!record) {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
if (record._truncated) {
|
|
26
|
+
throw new ValidationError(`Event ${eventId} payload was truncated and cannot be replayed automatically. Request a fresh webhook delivery.`);
|
|
27
|
+
}
|
|
28
|
+
if (record._unserializable) {
|
|
29
|
+
throw new ValidationError(`Event ${eventId} payload was not serializable and cannot be replayed automatically.`);
|
|
30
|
+
}
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(record, "value")) {
|
|
32
|
+
return record.value;
|
|
33
|
+
}
|
|
34
|
+
return record;
|
|
35
|
+
}
|
|
36
|
+
export function extractRetryBody(payload, eventId) {
|
|
37
|
+
const request = asRecord(payload.request);
|
|
38
|
+
if (request) {
|
|
39
|
+
return unwrapStoredPayloadValue(request, eventId);
|
|
40
|
+
}
|
|
41
|
+
return unwrapStoredPayloadValue(payload, eventId);
|
|
42
|
+
}
|
|
43
|
+
export function extractRetryParsedEvents(payload) {
|
|
44
|
+
if (!Object.prototype.hasOwnProperty.call(payload, "parsedEvent")) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const parsed = asRecord(payload.parsedEvent);
|
|
48
|
+
if (!parsed || parsed._truncated || parsed._unserializable) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
return isParsedWebhookEvent(parsed) ? [parsed] : [];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=retry-event-replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-event-replay.js","sourceRoot":"","sources":["../../src/services/retry-event-replay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,CA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U,gBAAgB,CAAC,OAAgC,EAAE,OAAe;IAChF,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,OAAgC;IAEhC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC;QAClE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3D,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-ingestion-service.d.ts","sourceRoot":"","sources":["../../src/services/webhook-ingestion-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook-ingestion-service.d.ts","sourceRoot":"","sources":["../../src/services/webhook-ingestion-service.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,UAAU,uBAAuB;IAC/B,YAAY,EAAE,mBAAmB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;CACrB;AAmGD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,uBAAuB,EAChC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,EACtD,aAAa,GAAE,oBAAyB,GACvC,OAAO,CAAC,mBAAmB,CAAC,CAkH9B"}
|
|
@@ -39,6 +39,12 @@ function toStoredErrorMessage(error) {
|
|
|
39
39
|
const message = error instanceof Error ? error.message : "Unknown webhook ingestion error.";
|
|
40
40
|
return truncate(message, MAX_STORED_ERROR_MESSAGE_LENGTH);
|
|
41
41
|
}
|
|
42
|
+
function toPersistedEventEnvelope(requestBody, event) {
|
|
43
|
+
return {
|
|
44
|
+
request: toPersistedPayload(requestBody),
|
|
45
|
+
parsedEvent: toPersistedPayload(event),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
42
48
|
async function processParsedEvent(options, event, records) {
|
|
43
49
|
const transitions = [];
|
|
44
50
|
const subscriptions = await options.repositories.transaction(async (tx) => {
|
|
@@ -83,26 +89,36 @@ export async function ingestWebhookEvent(options, pluginKey, body, headers, inge
|
|
|
83
89
|
receivedAt,
|
|
84
90
|
rawBody: ingestOptions.rawBody,
|
|
85
91
|
};
|
|
86
|
-
if (
|
|
92
|
+
if (ingestOptions.skipVerification) {
|
|
93
|
+
options.logger.warn("Webhook verification skipped for ingestion request", {
|
|
94
|
+
pluginKey,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else if (plugin.verifyWebhook) {
|
|
87
98
|
const verification = await plugin.verifyWebhook(envelope, { config });
|
|
88
99
|
if (!verification.verified) {
|
|
89
100
|
throw new ValidationError(`Webhook verification failed for ${pluginKey}.`);
|
|
90
101
|
}
|
|
91
102
|
}
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
const events = ingestOptions.parsedEventsOverride
|
|
104
|
+
? ingestOptions.parsedEventsOverride
|
|
105
|
+
: (() => {
|
|
106
|
+
const parsed = plugin.parseWebhook({
|
|
107
|
+
...envelope,
|
|
108
|
+
});
|
|
109
|
+
return Promise.resolve(parsed).then((value) => Array.isArray(value) ? value : [value]);
|
|
110
|
+
})();
|
|
111
|
+
const parsedEvents = await events;
|
|
96
112
|
const subscriptions = [];
|
|
97
113
|
let processedEvents = 0;
|
|
98
114
|
let duplicateEvents = 0;
|
|
99
|
-
for (const event of
|
|
115
|
+
for (const event of parsedEvents) {
|
|
100
116
|
const received = await options.repositories.inboundEvents.markReceived({
|
|
101
117
|
pluginKey,
|
|
102
118
|
eventKey: event.eventKey,
|
|
103
119
|
eventType: event.eventType,
|
|
104
120
|
sourceRef: event.sourceRef,
|
|
105
|
-
payload:
|
|
121
|
+
payload: toPersistedEventEnvelope(body, event),
|
|
106
122
|
});
|
|
107
123
|
if (!received.claimed) {
|
|
108
124
|
duplicateEvents += 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-ingestion-service.js","sourceRoot":"","sources":["../../src/services/webhook-ingestion-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook-ingestion-service.js","sourceRoot":"","sources":["../../src/services/webhook-ingestion-service.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAWlF,MAAM,wBAAwB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC5C,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAE7C,SAAS,QAAQ,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CACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CACpE,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG;QACb,eAAe;QACf,eAAe;QACf,aAAa;KACd,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE;QACjD,SAAS;QACT,eAAe;QACf,eAAe;KAChB,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;QACrC,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAC9E,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAC9E,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/submesh.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntitlementEvaluationOptions, SubscriptionPlugin, type AccessDecision, type CanonicalSubscriptionInput, type CatalogMapping, type DashboardSummary, type InboundEvent, type Plan, type PluginInstallation, type Subject, type Subscription, type SubscriptionWithPlan } from "@shdan/submesh-core";
|
|
2
|
-
import type { CreateManagedSubscriptionInput, CreatePlanInput, IngestWebhookOptions, IngestWebhookResult, InstallPluginInput, LinkProviderIdentityInput, PluginListItem, SyncAppleAppStoreSubscriptionInput, SyncGooglePlaySubscriptionInput, SubmeshOptions, SyncedProviderSubscription, UpsertCatalogMappingInput, UpsertSubjectInput, VerifyAppleAppStoreSubscriptionInput, VerifyGooglePlaySubscriptionInput, UpdatePlanInput, UpdateSubscriptionInput, CancelSubscriptionOptions, VerifiedProviderSubscription } from "./contracts.js";
|
|
2
|
+
import type { CreateManagedSubscriptionInput, CreatePlanInput, IngestWebhookOptions, IngestWebhookResult, InstallPluginInput, LinkProviderIdentityInput, PluginListItem, SyncAppleAppStoreSubscriptionInput, SyncGooglePlaySubscriptionInput, SyncStripeSubscriptionInput, SubmeshOptions, SyncedProviderSubscription, UpsertCatalogMappingInput, UpsertSubjectInput, VerifyAppleAppStoreSubscriptionInput, VerifyGooglePlaySubscriptionInput, VerifyStripeSubscriptionInput, UpdatePlanInput, UpdateSubscriptionInput, CancelSubscriptionOptions, VerifiedProviderSubscription } from "./contracts.js";
|
|
3
3
|
/**
|
|
4
4
|
* Main Submesh SDK client.
|
|
5
5
|
*
|
|
@@ -241,6 +241,20 @@ export declare class Submesh {
|
|
|
241
241
|
* @returns Verified data plus the synchronized subscription record.
|
|
242
242
|
*/
|
|
243
243
|
syncGooglePlaySubscription(input: SyncGooglePlaySubscriptionInput): Promise<SyncedProviderSubscription>;
|
|
244
|
+
/**
|
|
245
|
+
* Verifies a Stripe subscription and returns canonical data.
|
|
246
|
+
*
|
|
247
|
+
* @param input Stripe verification payload.
|
|
248
|
+
* @returns Verified provider response with canonical subscription data.
|
|
249
|
+
*/
|
|
250
|
+
verifyStripeSubscription(input: VerifyStripeSubscriptionInput): Promise<VerifiedProviderSubscription>;
|
|
251
|
+
/**
|
|
252
|
+
* Verifies and syncs a Stripe subscription.
|
|
253
|
+
*
|
|
254
|
+
* @param input Stripe verification payload plus target subject.
|
|
255
|
+
* @returns Verified data plus the synchronized subscription record.
|
|
256
|
+
*/
|
|
257
|
+
syncStripeSubscription(input: SyncStripeSubscriptionInput): Promise<SyncedProviderSubscription>;
|
|
244
258
|
/**
|
|
245
259
|
* Verifies an Apple App Store transaction and returns canonical data.
|
|
246
260
|
*
|
package/dist/submesh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submesh.d.ts","sourceRoot":"","sources":["../src/submesh.ts"],"names":[],"mappings":"AAAA,OAA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A6B,CACjC,KAAK,EAAE,kCAAkC,GACxC,OAAO,CAAC,0BAA0B,CAAC;IAmBtC;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAe7B"}
|
package/dist/submesh.js
CHANGED
|
@@ -2,7 +2,7 @@ import { evaluateEntitlementAccess, } from "@shdan/submesh-core";
|
|
|
2
2
|
import { collectGrantedEntitlements } from "@shdan/submesh-core";
|
|
3
3
|
import { ConflictError, NotFoundError, ValidationError } from "./errors.js";
|
|
4
4
|
import { DrizzleSubmeshRepositories } from "./drizzle/index.js";
|
|
5
|
-
import { noopLogger } from "./logger.js";
|
|
5
|
+
import { noopLogger, ConsoleLogger } from "./logger.js";
|
|
6
6
|
import { getBuiltinPlugins } from "./plugins/builtin-plugins.js";
|
|
7
7
|
import { PluginRegistry } from "./plugins/plugin-registry.js";
|
|
8
8
|
import { ingestCanonicalSubscription } from "./services/canonical-subscription-service.js";
|
|
@@ -11,9 +11,11 @@ import { createManagedSubscription } from "./services/managed-subscription-servi
|
|
|
11
11
|
import { verifyGooglePlaySubscription } from "./providers/google/services/play-subscription-verification-service.js";
|
|
12
12
|
import { createPlanWithProvisioning } from "./services/plan-provisioning-service.js";
|
|
13
13
|
import { installPlugin } from "./services/plugin-installation-service.js";
|
|
14
|
+
import { extractRetryBody, extractRetryParsedEvents, } from "./services/retry-event-replay.js";
|
|
14
15
|
import { syncVerifiedProviderSubscription } from "./services/provider-subscription-sync-service.js";
|
|
15
16
|
import { ingestWebhookEvent } from "./services/webhook-ingestion-service.js";
|
|
16
|
-
import {
|
|
17
|
+
import { verifyStripeSubscription } from "./providers/stripe/services/stripe-subscription-verification-service.js";
|
|
18
|
+
import { assertMaxLength, MAX_ENTITLEMENT_LENGTH, MAX_EVENT_ID_LENGTH, MAX_EXTERNAL_ID_LENGTH, MAX_PLAN_CODE_LENGTH, MAX_PROVIDER_KEY_LENGTH, MAX_SUBJECT_ID_LENGTH, requireString, } from "./utils/validation.js";
|
|
17
19
|
/**
|
|
18
20
|
* Main Submesh SDK client.
|
|
19
21
|
*
|
|
@@ -64,7 +66,15 @@ export class Submesh {
|
|
|
64
66
|
else {
|
|
65
67
|
throw new ValidationError("Provide repositories, drizzle options, or a Postgres connectionString / DATABASE_URL.");
|
|
66
68
|
}
|
|
67
|
-
|
|
69
|
+
if (options.logger) {
|
|
70
|
+
this.logger = options.logger;
|
|
71
|
+
}
|
|
72
|
+
else if (process.env.NODE_ENV === "development") {
|
|
73
|
+
this.logger = new ConsoleLogger();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.logger = noopLogger;
|
|
77
|
+
}
|
|
68
78
|
this.hooks = options.hooks ?? {};
|
|
69
79
|
if (options.autoRegisterBuiltinPlugins !== false) {
|
|
70
80
|
for (const plugin of getBuiltinPlugins()) {
|
|
@@ -106,7 +116,9 @@ export class Submesh {
|
|
|
106
116
|
*/
|
|
107
117
|
async installPlugin(input) {
|
|
108
118
|
await this.ensureReady();
|
|
109
|
-
|
|
119
|
+
const result = await installPlugin(this.repositories, this.pluginRegistry, input);
|
|
120
|
+
this.logger.info("Plugin installed", { pluginKey: input.pluginKey });
|
|
121
|
+
return result;
|
|
110
122
|
}
|
|
111
123
|
/**
|
|
112
124
|
* Returns registered plugins with their current installation state.
|
|
@@ -133,6 +145,7 @@ export class Submesh {
|
|
|
133
145
|
displayName: plugin.displayName,
|
|
134
146
|
enabled: false,
|
|
135
147
|
});
|
|
148
|
+
this.logger.info("Plugin disabled", { pluginKey });
|
|
136
149
|
}
|
|
137
150
|
/**
|
|
138
151
|
* Returns all subjects.
|
|
@@ -152,7 +165,10 @@ export class Submesh {
|
|
|
152
165
|
async upsertSubject(input) {
|
|
153
166
|
await this.ensureReady();
|
|
154
167
|
requireString(input.id, "Subject id");
|
|
155
|
-
|
|
168
|
+
assertMaxLength(input.id, MAX_SUBJECT_ID_LENGTH, "Subject id");
|
|
169
|
+
const result = await this.repositories.subjects.upsert(input);
|
|
170
|
+
this.logger.debug("Subject upserted", { id: input.id });
|
|
171
|
+
return result;
|
|
156
172
|
}
|
|
157
173
|
/**
|
|
158
174
|
* Returns a subject by their ID.
|
|
@@ -163,7 +179,10 @@ export class Submesh {
|
|
|
163
179
|
async getSubject(id) {
|
|
164
180
|
await this.ensureReady();
|
|
165
181
|
requireString(id, "Subject id");
|
|
166
|
-
|
|
182
|
+
assertMaxLength(id, MAX_SUBJECT_ID_LENGTH, "Subject id");
|
|
183
|
+
const result = await this.repositories.subjects.getById(id);
|
|
184
|
+
this.logger.debug("Subject fetched", { id, found: !!result });
|
|
185
|
+
return result;
|
|
167
186
|
}
|
|
168
187
|
/**
|
|
169
188
|
* Links an external provider identity to a subject.
|
|
@@ -176,8 +195,16 @@ export class Submesh {
|
|
|
176
195
|
requireString(input.subjectId, "Subject id");
|
|
177
196
|
requireString(input.provider, "Provider");
|
|
178
197
|
requireString(input.externalId, "External id");
|
|
198
|
+
assertMaxLength(input.subjectId, MAX_SUBJECT_ID_LENGTH, "Subject id");
|
|
199
|
+
assertMaxLength(input.provider, MAX_PROVIDER_KEY_LENGTH, "Provider");
|
|
200
|
+
assertMaxLength(input.externalId, MAX_EXTERNAL_ID_LENGTH, "External id");
|
|
179
201
|
await this.repositories.subjects.upsert({ id: input.subjectId });
|
|
180
202
|
await this.repositories.subjects.upsertIdentity(input);
|
|
203
|
+
this.logger.info("Provider identity linked", {
|
|
204
|
+
subjectId: input.subjectId,
|
|
205
|
+
provider: input.provider,
|
|
206
|
+
externalId: input.externalId,
|
|
207
|
+
});
|
|
181
208
|
}
|
|
182
209
|
/**
|
|
183
210
|
* Returns all plans.
|
|
@@ -198,11 +225,12 @@ export class Submesh {
|
|
|
198
225
|
await this.ensureReady();
|
|
199
226
|
requireString(input.code, "Plan code");
|
|
200
227
|
requireString(input.name, "Plan name");
|
|
228
|
+
assertMaxLength(input.code, MAX_PLAN_CODE_LENGTH, "Plan code");
|
|
201
229
|
const existing = await this.repositories.plans.getByCode(input.code);
|
|
202
230
|
if (existing) {
|
|
203
231
|
throw new ConflictError(`Plan ${input.code} already exists.`);
|
|
204
232
|
}
|
|
205
|
-
return createPlanWithProvisioning(this.repositories, this.pluginRegistry, input);
|
|
233
|
+
return createPlanWithProvisioning(this.repositories, this.pluginRegistry, input, this.logger);
|
|
206
234
|
}
|
|
207
235
|
/**
|
|
208
236
|
* Updates a plan's details.
|
|
@@ -214,10 +242,12 @@ export class Submesh {
|
|
|
214
242
|
async updatePlan(code, input) {
|
|
215
243
|
await this.ensureReady();
|
|
216
244
|
requireString(code, "Plan code");
|
|
245
|
+
assertMaxLength(code, MAX_PLAN_CODE_LENGTH, "Plan code");
|
|
217
246
|
const updated = await this.repositories.plans.update(code, input);
|
|
218
247
|
if (!updated) {
|
|
219
248
|
throw new NotFoundError(`Plan ${code} was not found.`);
|
|
220
249
|
}
|
|
250
|
+
this.logger.info("Plan updated", { planCode: code });
|
|
221
251
|
return updated;
|
|
222
252
|
}
|
|
223
253
|
/**
|
|
@@ -228,10 +258,12 @@ export class Submesh {
|
|
|
228
258
|
async deletePlan(code) {
|
|
229
259
|
await this.ensureReady();
|
|
230
260
|
requireString(code, "Plan code");
|
|
261
|
+
assertMaxLength(code, MAX_PLAN_CODE_LENGTH, "Plan code");
|
|
231
262
|
const deleted = await this.repositories.plans.delete(code);
|
|
232
263
|
if (!deleted) {
|
|
233
264
|
throw new NotFoundError(`Plan ${code} was not found.`);
|
|
234
265
|
}
|
|
266
|
+
this.logger.info("Plan deleted", { planCode: code });
|
|
235
267
|
}
|
|
236
268
|
/**
|
|
237
269
|
* Returns catalog mappings from provider products to internal plan codes.
|
|
@@ -253,11 +285,20 @@ export class Submesh {
|
|
|
253
285
|
requireString(input.pluginKey, "Plugin key");
|
|
254
286
|
requireString(input.externalProductId, "External product id");
|
|
255
287
|
requireString(input.planCode, "Plan code");
|
|
288
|
+
assertMaxLength(input.pluginKey, MAX_PROVIDER_KEY_LENGTH, "Plugin key");
|
|
289
|
+
assertMaxLength(input.externalProductId, MAX_EXTERNAL_ID_LENGTH, "External product id");
|
|
290
|
+
assertMaxLength(input.planCode, MAX_PLAN_CODE_LENGTH, "Plan code");
|
|
256
291
|
const plan = await this.repositories.plans.getByCode(input.planCode);
|
|
257
292
|
if (!plan) {
|
|
258
293
|
throw new NotFoundError(`Plan ${input.planCode} was not found.`);
|
|
259
294
|
}
|
|
260
|
-
|
|
295
|
+
const result = await this.repositories.catalogMappings.upsert(input);
|
|
296
|
+
this.logger.info("Catalog mapping upserted", {
|
|
297
|
+
pluginKey: input.pluginKey,
|
|
298
|
+
externalProductId: input.externalProductId,
|
|
299
|
+
planCode: input.planCode,
|
|
300
|
+
});
|
|
301
|
+
return result;
|
|
261
302
|
}
|
|
262
303
|
/**
|
|
263
304
|
* Removes a catalog mapping.
|
|
@@ -269,10 +310,13 @@ export class Submesh {
|
|
|
269
310
|
await this.ensureReady();
|
|
270
311
|
requireString(pluginKey, "Plugin key");
|
|
271
312
|
requireString(externalProductId, "External product id");
|
|
313
|
+
assertMaxLength(pluginKey, MAX_PROVIDER_KEY_LENGTH, "Plugin key");
|
|
314
|
+
assertMaxLength(externalProductId, MAX_EXTERNAL_ID_LENGTH, "External product id");
|
|
272
315
|
const deleted = await this.repositories.catalogMappings.delete(pluginKey, externalProductId);
|
|
273
316
|
if (!deleted) {
|
|
274
317
|
throw new NotFoundError(`Mapping for ${pluginKey} / ${externalProductId} not found.`);
|
|
275
318
|
}
|
|
319
|
+
this.logger.info("Catalog mapping deleted", { pluginKey, externalProductId });
|
|
276
320
|
}
|
|
277
321
|
/**
|
|
278
322
|
* Returns subscriptions with resolved plan details.
|
|
@@ -291,7 +335,10 @@ export class Submesh {
|
|
|
291
335
|
async getSubscription(id) {
|
|
292
336
|
await this.ensureReady();
|
|
293
337
|
requireString(id, "Subscription id");
|
|
294
|
-
|
|
338
|
+
assertMaxLength(id, MAX_EXTERNAL_ID_LENGTH, "Subscription id");
|
|
339
|
+
const result = await this.repositories.subscriptions.getById(id);
|
|
340
|
+
this.logger.debug("Subscription fetched", { id, found: !!result });
|
|
341
|
+
return result;
|
|
295
342
|
}
|
|
296
343
|
/**
|
|
297
344
|
* Returns subscriptions for a specific subject.
|
|
@@ -301,6 +348,7 @@ export class Submesh {
|
|
|
301
348
|
async listSubscriptionsBySubject(subjectId) {
|
|
302
349
|
await this.ensureReady();
|
|
303
350
|
requireString(subjectId, "Subject id");
|
|
351
|
+
assertMaxLength(subjectId, MAX_SUBJECT_ID_LENGTH, "Subject id");
|
|
304
352
|
return this.repositories.subscriptions.listBySubjectId(subjectId);
|
|
305
353
|
}
|
|
306
354
|
/**
|
|
@@ -313,7 +361,9 @@ export class Submesh {
|
|
|
313
361
|
await this.ensureReady();
|
|
314
362
|
requireString(input.subjectId, "Subject id");
|
|
315
363
|
requireString(input.planCode, "Plan code");
|
|
316
|
-
|
|
364
|
+
assertMaxLength(input.subjectId, MAX_SUBJECT_ID_LENGTH, "Subject id");
|
|
365
|
+
assertMaxLength(input.planCode, MAX_PLAN_CODE_LENGTH, "Plan code");
|
|
366
|
+
const sub = await createManagedSubscription(this.repositories, input, this.logger);
|
|
317
367
|
this.logger.info("Subscription created", { id: sub.id, subjectId: sub.subjectId });
|
|
318
368
|
if (this.hooks.onSubscriptionChanged) {
|
|
319
369
|
await Promise.resolve(this.hooks.onSubscriptionChanged(sub, null)).catch((e) => this.logger.error("Error in onSubscriptionChanged hook", { error: e }));
|
|
@@ -329,6 +379,7 @@ export class Submesh {
|
|
|
329
379
|
async updateSubscription(id, input) {
|
|
330
380
|
await this.ensureReady();
|
|
331
381
|
requireString(id, "Subscription id");
|
|
382
|
+
assertMaxLength(id, MAX_EXTERNAL_ID_LENGTH, "Subscription id");
|
|
332
383
|
// We fetch it first to get existing status for hooks
|
|
333
384
|
const existing = await this.repositories.subscriptions.getById(id);
|
|
334
385
|
if (!existing) {
|
|
@@ -357,8 +408,12 @@ export class Submesh {
|
|
|
357
408
|
* @param options Cancellation options.
|
|
358
409
|
*/
|
|
359
410
|
async cancelSubscription(id, options = {}) {
|
|
411
|
+
if (!options.immediate && options.cancelAt === undefined) {
|
|
412
|
+
throw new ValidationError("cancelSubscription requires cancelAt when immediate is false.");
|
|
413
|
+
}
|
|
414
|
+
const effectiveCancelAt = options.immediate ? options.cancelAt ?? new Date().toISOString() : options.cancelAt;
|
|
360
415
|
return this.updateSubscription(id, {
|
|
361
|
-
cancelAt:
|
|
416
|
+
cancelAt: effectiveCancelAt,
|
|
362
417
|
status: options.immediate ? "canceled" : undefined,
|
|
363
418
|
});
|
|
364
419
|
}
|
|
@@ -373,6 +428,8 @@ export class Submesh {
|
|
|
373
428
|
await this.ensureReady();
|
|
374
429
|
requireString(subjectId, "Subject id");
|
|
375
430
|
requireString(entitlement, "Entitlement");
|
|
431
|
+
assertMaxLength(subjectId, MAX_SUBJECT_ID_LENGTH, "Subject id");
|
|
432
|
+
assertMaxLength(entitlement, MAX_ENTITLEMENT_LENGTH, "Entitlement");
|
|
376
433
|
const subject = await this.repositories.subjects.getById(subjectId);
|
|
377
434
|
if (!subject) {
|
|
378
435
|
return {
|
|
@@ -391,6 +448,7 @@ export class Submesh {
|
|
|
391
448
|
async listEntitlements(subjectId, options = {}) {
|
|
392
449
|
await this.ensureReady();
|
|
393
450
|
requireString(subjectId, "Subject id");
|
|
451
|
+
assertMaxLength(subjectId, MAX_SUBJECT_ID_LENGTH, "Subject id");
|
|
394
452
|
const subscriptions = await this.repositories.subscriptions.listBySubjectId(subjectId);
|
|
395
453
|
return collectGrantedEntitlements(subscriptions, options);
|
|
396
454
|
}
|
|
@@ -430,6 +488,7 @@ export class Submesh {
|
|
|
430
488
|
async retryEvent(eventId) {
|
|
431
489
|
await this.ensureReady();
|
|
432
490
|
requireString(eventId, "Event id");
|
|
491
|
+
assertMaxLength(eventId, MAX_EVENT_ID_LENGTH, "Event id");
|
|
433
492
|
const event = await this.repositories.inboundEvents.getById(eventId);
|
|
434
493
|
if (!event) {
|
|
435
494
|
throw new NotFoundError(`Event ${eventId} not found.`);
|
|
@@ -438,18 +497,12 @@ export class Submesh {
|
|
|
438
497
|
throw new ValidationError(`Event ${eventId} is not in a failed state (${event.status}).`);
|
|
439
498
|
}
|
|
440
499
|
this.logger.info("Retrying failed event", { eventId, pluginKey: event.pluginKey });
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
sourceRef: event.sourceRef,
|
|
447
|
-
payload: event.payload,
|
|
500
|
+
const retryBody = extractRetryBody(event.payload, eventId);
|
|
501
|
+
const parsedEventsOverride = extractRetryParsedEvents(event.payload);
|
|
502
|
+
return this.ingestWebhook(event.pluginKey, retryBody, {}, {
|
|
503
|
+
skipVerification: true,
|
|
504
|
+
parsedEventsOverride: parsedEventsOverride.length > 0 ? parsedEventsOverride : undefined,
|
|
448
505
|
});
|
|
449
|
-
// Re-ingest the payload through the standard processing pipeline via manual execution bypassing webhook source checks.
|
|
450
|
-
// For safety, this delegates to ingestWebhookEvent but since the event is already received, we reconstruct the payload.
|
|
451
|
-
// However, ingestWebhookEvent requires the raw payload. We assume event.payload is close enough to raw payload.
|
|
452
|
-
return this.ingestWebhook(event.pluginKey, event.payload.value ?? event.payload, {}, { rawBody: undefined });
|
|
453
506
|
}
|
|
454
507
|
/**
|
|
455
508
|
* Ingests a canonical subscription event.
|
|
@@ -459,7 +512,13 @@ export class Submesh {
|
|
|
459
512
|
*/
|
|
460
513
|
async ingestCanonicalEvent(input) {
|
|
461
514
|
await this.ensureReady();
|
|
462
|
-
|
|
515
|
+
const result = await this.repositories.transaction((tx) => ingestCanonicalSubscription(tx, input));
|
|
516
|
+
this.logger.info("Canonical event ingested", {
|
|
517
|
+
subjectId: input.subjectId,
|
|
518
|
+
pluginKey: input.pluginKey,
|
|
519
|
+
sourceRef: input.sourceRef,
|
|
520
|
+
});
|
|
521
|
+
return result;
|
|
463
522
|
}
|
|
464
523
|
/**
|
|
465
524
|
* Ingests a plugin webhook payload and applies subscription updates.
|
|
@@ -473,6 +532,7 @@ export class Submesh {
|
|
|
473
532
|
async ingestWebhook(pluginKey, body, headers = {}, options = {}) {
|
|
474
533
|
await this.ensureReady();
|
|
475
534
|
requireString(pluginKey, "Plugin key");
|
|
535
|
+
assertMaxLength(pluginKey, MAX_PROVIDER_KEY_LENGTH, "Plugin key");
|
|
476
536
|
return ingestWebhookEvent({
|
|
477
537
|
repositories: this.repositories,
|
|
478
538
|
pluginRegistry: this.pluginRegistry,
|
|
@@ -491,13 +551,14 @@ export class Submesh {
|
|
|
491
551
|
return async (req) => {
|
|
492
552
|
try {
|
|
493
553
|
const bodyBuffer = await req.arrayBuffer();
|
|
494
|
-
const rawBody =
|
|
554
|
+
const rawBody = new Uint8Array(bodyBuffer);
|
|
555
|
+
const decodedBody = new TextDecoder().decode(rawBody);
|
|
495
556
|
const headers = {};
|
|
496
557
|
req.headers.forEach((value, key) => {
|
|
497
558
|
headers[key] = value;
|
|
498
559
|
});
|
|
499
560
|
const contentType = req.headers.get("content-type") || "";
|
|
500
|
-
let body =
|
|
561
|
+
let body = decodedBody;
|
|
501
562
|
if (contentType.includes("application/json")) {
|
|
502
563
|
try {
|
|
503
564
|
body = JSON.parse(body);
|
|
@@ -548,7 +609,36 @@ export class Submesh {
|
|
|
548
609
|
return {
|
|
549
610
|
...verified,
|
|
550
611
|
canonical,
|
|
551
|
-
subscription: await syncVerifiedProviderSubscription(this.repositories, canonical),
|
|
612
|
+
subscription: await syncVerifiedProviderSubscription(this.repositories, canonical, this.logger),
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Verifies a Stripe subscription and returns canonical data.
|
|
617
|
+
*
|
|
618
|
+
* @param input Stripe verification payload.
|
|
619
|
+
* @returns Verified provider response with canonical subscription data.
|
|
620
|
+
*/
|
|
621
|
+
async verifyStripeSubscription(input) {
|
|
622
|
+
await this.ensureReady();
|
|
623
|
+
return verifyStripeSubscription(input, await this.getPluginConfig("stripe"));
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Verifies and syncs a Stripe subscription.
|
|
627
|
+
*
|
|
628
|
+
* @param input Stripe verification payload plus target subject.
|
|
629
|
+
* @returns Verified data plus the synchronized subscription record.
|
|
630
|
+
*/
|
|
631
|
+
async syncStripeSubscription(input) {
|
|
632
|
+
await this.ensureReady();
|
|
633
|
+
const verified = await this.verifyStripeSubscription(input);
|
|
634
|
+
const canonical = {
|
|
635
|
+
...verified.canonical,
|
|
636
|
+
subjectId: input.subjectId,
|
|
637
|
+
};
|
|
638
|
+
return {
|
|
639
|
+
...verified,
|
|
640
|
+
canonical,
|
|
641
|
+
subscription: await syncVerifiedProviderSubscription(this.repositories, canonical, this.logger),
|
|
552
642
|
};
|
|
553
643
|
}
|
|
554
644
|
/**
|
|
@@ -577,7 +667,7 @@ export class Submesh {
|
|
|
577
667
|
return {
|
|
578
668
|
...verified,
|
|
579
669
|
canonical,
|
|
580
|
-
subscription: await syncVerifiedProviderSubscription(this.repositories, canonical),
|
|
670
|
+
subscription: await syncVerifiedProviderSubscription(this.repositories, canonical, this.logger),
|
|
581
671
|
};
|
|
582
672
|
}
|
|
583
673
|
/**
|