better-auth-streampay 3.4.0 → 3.5.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/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/index.cjs +385 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +385 -47
- package/dist/index.js.map +1 -1
- package/dist/{streampay-CzZfiZvE.d.cts → streampay-CKPv2wFz.d.cts} +288 -157
- package/dist/{streampay-CzZfiZvE.d.ts → streampay-CKPv2wFz.d.ts} +288 -157
- package/docs/integration.md +51 -0
- package/docs/staging-validation.md +1 -0
- package/docs/state-machines.md +15 -2
- package/package.json +1 -1
|
@@ -55,6 +55,11 @@ declare const $ERROR_CODES: {
|
|
|
55
55
|
type StreamPayErrorCode = keyof typeof $ERROR_CODES;
|
|
56
56
|
declare function mapToErrorCode(rawCode: string | undefined, status: number | undefined): StreamPayErrorCode;
|
|
57
57
|
|
|
58
|
+
declare const SUBSCRIPTION_STATUSES: readonly ["incomplete", "incomplete_expired", "trial_pending", "trialing", "active", "inactive", "expired", "canceled", "frozen", "past_due"];
|
|
59
|
+
type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];
|
|
60
|
+
type StreamPaySubscriptionStatus = NonNullable<SubscriptionDetailed["status"]>;
|
|
61
|
+
declare const DEFAULT_ACCESS_STATUSES: readonly ["active", "trialing", "frozen", "past_due"];
|
|
62
|
+
|
|
58
63
|
interface StreamPaySessionUser {
|
|
59
64
|
id: string;
|
|
60
65
|
email?: string;
|
|
@@ -63,73 +68,6 @@ interface StreamPaySessionUser {
|
|
|
63
68
|
streampayConsumerId?: string | null;
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
interface PluginAdapter {
|
|
67
|
-
create: <T = unknown, D extends object = Record<string, unknown>>(args: {
|
|
68
|
-
model: string;
|
|
69
|
-
data: D;
|
|
70
|
-
}) => Promise<T>;
|
|
71
|
-
update: <T = unknown, D extends object = Record<string, unknown>>(args: {
|
|
72
|
-
model: string;
|
|
73
|
-
update: D;
|
|
74
|
-
where: Array<{
|
|
75
|
-
field: string;
|
|
76
|
-
value: unknown;
|
|
77
|
-
}>;
|
|
78
|
-
}) => Promise<T | null>;
|
|
79
|
-
findOne: <T = unknown>(args: {
|
|
80
|
-
model: string;
|
|
81
|
-
where: Array<{
|
|
82
|
-
field: string;
|
|
83
|
-
value: unknown;
|
|
84
|
-
}>;
|
|
85
|
-
}) => Promise<T | null>;
|
|
86
|
-
findMany: <T = unknown>(args: {
|
|
87
|
-
model: string;
|
|
88
|
-
where?: Array<{
|
|
89
|
-
field: string;
|
|
90
|
-
value: unknown;
|
|
91
|
-
operator?: "lt" | "lte";
|
|
92
|
-
}>;
|
|
93
|
-
limit?: number;
|
|
94
|
-
offset?: number;
|
|
95
|
-
sortBy?: {
|
|
96
|
-
field: string;
|
|
97
|
-
direction: "asc" | "desc";
|
|
98
|
-
};
|
|
99
|
-
}) => Promise<T[]>;
|
|
100
|
-
delete: (args: {
|
|
101
|
-
model: string;
|
|
102
|
-
where: Array<{
|
|
103
|
-
field: string;
|
|
104
|
-
value: unknown;
|
|
105
|
-
}>;
|
|
106
|
-
}) => Promise<void>;
|
|
107
|
-
count: (args: {
|
|
108
|
-
model: string;
|
|
109
|
-
where?: Array<{
|
|
110
|
-
field: string;
|
|
111
|
-
value: unknown;
|
|
112
|
-
}>;
|
|
113
|
-
}) => Promise<number>;
|
|
114
|
-
}
|
|
115
|
-
interface SyncContext {
|
|
116
|
-
context: {
|
|
117
|
-
adapter: PluginAdapter;
|
|
118
|
-
logger: {
|
|
119
|
-
error: (msg: string) => void;
|
|
120
|
-
warn: (msg: string) => void;
|
|
121
|
-
info: (msg: string) => void;
|
|
122
|
-
debug: (msg: string) => void;
|
|
123
|
-
};
|
|
124
|
-
session?: {
|
|
125
|
-
user?: unknown;
|
|
126
|
-
};
|
|
127
|
-
internalAdapter?: {
|
|
128
|
-
findUserById?: (userId: string) => Promise<unknown>;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
71
|
type StreamPayEntityType = "PAYMENT" | "INVOICE" | "SUBSCRIPTION" | "PAYMENT_LINK";
|
|
134
72
|
declare const STREAMPAY_EVENT_ENTITY_TYPES: {
|
|
135
73
|
readonly PAYMENT_SUCCEEDED: "PAYMENT";
|
|
@@ -218,84 +156,6 @@ type StreamPayWebhookPayload<TEvent extends StreamPayEventType = StreamPayEventT
|
|
|
218
156
|
entity_type: TEntity;
|
|
219
157
|
}>;
|
|
220
158
|
|
|
221
|
-
type WebhookEventStatus = "pending" | "completed" | "dead_letter";
|
|
222
|
-
interface WebhookEventRow {
|
|
223
|
-
id: string;
|
|
224
|
-
eventId: string;
|
|
225
|
-
eventType: string;
|
|
226
|
-
status: WebhookEventStatus;
|
|
227
|
-
attemptCount: number;
|
|
228
|
-
receivedAt: Date;
|
|
229
|
-
lastAttemptAt: Date | null;
|
|
230
|
-
nextAttemptAt: Date | null;
|
|
231
|
-
completedAt: Date | null;
|
|
232
|
-
deadLetteredAt: Date | null;
|
|
233
|
-
lockedAt: Date | null;
|
|
234
|
-
lockedBy: string | null;
|
|
235
|
-
rawPayload: string | null;
|
|
236
|
-
signatureHeader: string | null;
|
|
237
|
-
lastError: string | null;
|
|
238
|
-
lastErrorCode: string | null;
|
|
239
|
-
}
|
|
240
|
-
/** What a scope learns about the attempt it is running. */
|
|
241
|
-
interface WebhookInboxAttempt {
|
|
242
|
-
previousError: string | null;
|
|
243
|
-
previousErrorCode: string | null;
|
|
244
|
-
}
|
|
245
|
-
type WebhookEventRunner = (ctx: SyncContext, attempt: WebhookInboxAttempt) => Promise<void>;
|
|
246
|
-
/**
|
|
247
|
-
* One kind of work the inbox runs for a StreamPay event. Subscription sync and generic handlers are
|
|
248
|
-
* the two scopes; each keeps its own inbox row per event, distinguished by `eventIdPrefix`.
|
|
249
|
-
*/
|
|
250
|
-
interface WebhookInboxScope {
|
|
251
|
-
/** `null` keeps the unprefixed event IDs that subscription sync has always stored. */
|
|
252
|
-
eventIdPrefix: string | null;
|
|
253
|
-
maxAttempts: number;
|
|
254
|
-
/** Returns the work for an event this scope handles, or `null` to leave the event alone. */
|
|
255
|
-
prepare: (payload: StreamPayWebhookEnvelope) => WebhookEventRunner | null;
|
|
256
|
-
isPermanentFailure: (err: unknown) => boolean;
|
|
257
|
-
/** Releases scope-owned state that waits on the event before an operator discards it. */
|
|
258
|
-
onDiscard?: (ctx: SyncContext, row: WebhookEventRow) => Promise<void>;
|
|
259
|
-
}
|
|
260
|
-
interface ProcessDueWebhookEventsResult {
|
|
261
|
-
succeeded: string[];
|
|
262
|
-
failed: Array<{
|
|
263
|
-
eventId: string;
|
|
264
|
-
error: string;
|
|
265
|
-
}>;
|
|
266
|
-
}
|
|
267
|
-
interface WebhookInbox {
|
|
268
|
-
/**
|
|
269
|
-
* Adds a scope. A scope that is not `replayable` keeps its discard hook for rows it stored
|
|
270
|
-
* earlier, but its events are neither replayed nor retried.
|
|
271
|
-
*
|
|
272
|
-
* @throws TypeError for a prefix other than `null` or `HANDLERS_EVENT_ID_PREFIX`, which replay
|
|
273
|
-
* could not route.
|
|
274
|
-
*/
|
|
275
|
-
register: (scope: WebhookInboxScope, options?: {
|
|
276
|
-
replayable?: boolean;
|
|
277
|
-
}) => void;
|
|
278
|
-
isEnabled: () => boolean;
|
|
279
|
-
/** With `dueAttemptCount`, replays only while the event is still that pending, due attempt. */
|
|
280
|
-
replay: (ctx: SyncContext, eventId: string, options?: {
|
|
281
|
-
dueAttemptCount?: number;
|
|
282
|
-
}) => Promise<{
|
|
283
|
-
replayed: true;
|
|
284
|
-
eventId: string;
|
|
285
|
-
}>;
|
|
286
|
-
/** @throws APIError `CONFLICT` while a worker holds the event or claims it during the discard. */
|
|
287
|
-
discard: (ctx: SyncContext, eventId: string) => Promise<{
|
|
288
|
-
discarded: true;
|
|
289
|
-
eventId: string;
|
|
290
|
-
}>;
|
|
291
|
-
processDue: (ctx: SyncContext, limit: number) => Promise<ProcessDueWebhookEventsResult>;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
declare const SUBSCRIPTION_STATUSES: readonly ["incomplete", "incomplete_expired", "trial_pending", "trialing", "active", "inactive", "expired", "canceled", "frozen", "past_due"];
|
|
295
|
-
type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];
|
|
296
|
-
type StreamPaySubscriptionStatus = NonNullable<SubscriptionDetailed["status"]>;
|
|
297
|
-
declare const DEFAULT_ACCESS_STATUSES: readonly ["active", "trialing", "frozen", "past_due"];
|
|
298
|
-
|
|
299
159
|
type SubscriptionRecurringInterval = NonNullable<SubscriptionDetailed["recurring_interval"]>;
|
|
300
160
|
type SubscriptionBillingStatus = "current" | "past_due";
|
|
301
161
|
type SubscriptionReferenceType = "user" | "organization" | "custom";
|
|
@@ -418,6 +278,29 @@ interface TrialEligibilityContext {
|
|
|
418
278
|
/** False after a trial is recorded for the same reference and plan group. */
|
|
419
279
|
defaultEligible: boolean;
|
|
420
280
|
}
|
|
281
|
+
/** Organization or custom reference recovered from checkout metadata without a local reservation. */
|
|
282
|
+
interface SubscriptionReferenceContext {
|
|
283
|
+
referenceType: "organization" | "custom";
|
|
284
|
+
referenceId: string;
|
|
285
|
+
plan: StreamPayPlanLike;
|
|
286
|
+
subscription: SubscriptionDetailed;
|
|
287
|
+
}
|
|
288
|
+
/** A StreamPay subscription with no plugin checkout metadata, for example one created in the dashboard. */
|
|
289
|
+
interface UnlinkedSubscriptionContext {
|
|
290
|
+
subscription: SubscriptionDetailed;
|
|
291
|
+
/** Local user whose StreamPay consumer matches. A lookup hint, not proof that this app sold it. */
|
|
292
|
+
consumerUser: StreamPaySessionUser | null;
|
|
293
|
+
/** Custom metadata of the subscription's checkout link, when it has one. */
|
|
294
|
+
linkMetadata: Record<string, unknown> | null;
|
|
295
|
+
/** Configured plan whose product StreamPay bills, or null when no configured product matches. */
|
|
296
|
+
inferredPlan: StreamPayPlanLike | null;
|
|
297
|
+
}
|
|
298
|
+
interface UnlinkedSubscriptionResolution {
|
|
299
|
+
referenceType: SubscriptionReferenceType;
|
|
300
|
+
referenceId: string;
|
|
301
|
+
/** Defaults to the inferred plan. Must match the product StreamPay bills. */
|
|
302
|
+
plan?: string;
|
|
303
|
+
}
|
|
421
304
|
declare function subscriptionSlotKey(referenceType: SubscriptionReferenceType, referenceId: string, group: string | null | undefined): string;
|
|
422
305
|
interface SubscriptionsOptionsBase extends SubscriptionCallbacks {
|
|
423
306
|
plans: PlansInput;
|
|
@@ -436,12 +319,170 @@ interface SubscriptionsOptionsBase extends SubscriptionCallbacks {
|
|
|
436
319
|
accessStatuses?: readonly SubscriptionStatus[];
|
|
437
320
|
/** Disabling this removes persisted webhook deduplication and replay. */
|
|
438
321
|
enableWebhookEventTable?: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Identifies this deployment on checkout links. Give each deployment its own value when several
|
|
324
|
+
* apps or environments share one StreamPay organization: recovery never adopts a checkout link
|
|
325
|
+
* stamped with another value.
|
|
326
|
+
*/
|
|
327
|
+
appId?: string;
|
|
328
|
+
/**
|
|
329
|
+
* Confirms that an organization or custom reference recovered from checkout metadata, without a
|
|
330
|
+
* local reservation, belongs to this app. Without it, renewal recovery skips those references.
|
|
331
|
+
*/
|
|
332
|
+
resolveSubscriptionReference?: (data: SubscriptionReferenceContext) => boolean | Promise<boolean>;
|
|
333
|
+
/**
|
|
334
|
+
* Maps a subscription without plugin checkout metadata to a local reference, or returns null to
|
|
335
|
+
* leave it unlinked. Called for each such creation and renewal event, so it must be idempotent.
|
|
336
|
+
* A thrown error is retried.
|
|
337
|
+
*/
|
|
338
|
+
resolveUnlinkedSubscription?: (data: UnlinkedSubscriptionContext) => UnlinkedSubscriptionResolution | null | Promise<UnlinkedSubscriptionResolution | null>;
|
|
439
339
|
}
|
|
440
340
|
type SubscriptionsOptions = SubscriptionsOptionsBase;
|
|
441
341
|
declare const PLAN_NAME_METADATA_KEY = "streampay_plugin_plan_name";
|
|
442
342
|
declare const REFERENCE_ID_METADATA_KEY = "streampay_plugin_reference_id";
|
|
443
343
|
declare const REFERENCE_TYPE_METADATA_KEY = "streampay_plugin_reference_type";
|
|
444
344
|
declare const SUBSCRIPTION_ROW_ID_METADATA_KEY = "streampay_plugin_subscription_row_id";
|
|
345
|
+
declare const APP_ID_METADATA_KEY = "streampay_plugin_app_id";
|
|
346
|
+
|
|
347
|
+
interface PluginAdapter {
|
|
348
|
+
create: <T = unknown, D extends object = Record<string, unknown>>(args: {
|
|
349
|
+
model: string;
|
|
350
|
+
data: D;
|
|
351
|
+
}) => Promise<T>;
|
|
352
|
+
update: <T = unknown, D extends object = Record<string, unknown>>(args: {
|
|
353
|
+
model: string;
|
|
354
|
+
update: D;
|
|
355
|
+
where: Array<{
|
|
356
|
+
field: string;
|
|
357
|
+
value: unknown;
|
|
358
|
+
}>;
|
|
359
|
+
}) => Promise<T | null>;
|
|
360
|
+
findOne: <T = unknown>(args: {
|
|
361
|
+
model: string;
|
|
362
|
+
where: Array<{
|
|
363
|
+
field: string;
|
|
364
|
+
value: unknown;
|
|
365
|
+
}>;
|
|
366
|
+
}) => Promise<T | null>;
|
|
367
|
+
findMany: <T = unknown>(args: {
|
|
368
|
+
model: string;
|
|
369
|
+
where?: Array<{
|
|
370
|
+
field: string;
|
|
371
|
+
value: unknown;
|
|
372
|
+
operator?: "lt" | "lte";
|
|
373
|
+
}>;
|
|
374
|
+
limit?: number;
|
|
375
|
+
offset?: number;
|
|
376
|
+
sortBy?: {
|
|
377
|
+
field: string;
|
|
378
|
+
direction: "asc" | "desc";
|
|
379
|
+
};
|
|
380
|
+
}) => Promise<T[]>;
|
|
381
|
+
delete: (args: {
|
|
382
|
+
model: string;
|
|
383
|
+
where: Array<{
|
|
384
|
+
field: string;
|
|
385
|
+
value: unknown;
|
|
386
|
+
}>;
|
|
387
|
+
}) => Promise<void>;
|
|
388
|
+
count: (args: {
|
|
389
|
+
model: string;
|
|
390
|
+
where?: Array<{
|
|
391
|
+
field: string;
|
|
392
|
+
value: unknown;
|
|
393
|
+
}>;
|
|
394
|
+
}) => Promise<number>;
|
|
395
|
+
}
|
|
396
|
+
interface SyncContext {
|
|
397
|
+
context: {
|
|
398
|
+
adapter: PluginAdapter;
|
|
399
|
+
logger: {
|
|
400
|
+
error: (msg: string) => void;
|
|
401
|
+
warn: (msg: string) => void;
|
|
402
|
+
info: (msg: string) => void;
|
|
403
|
+
debug: (msg: string) => void;
|
|
404
|
+
};
|
|
405
|
+
session?: {
|
|
406
|
+
user?: unknown;
|
|
407
|
+
};
|
|
408
|
+
internalAdapter?: {
|
|
409
|
+
findUserById?: (userId: string) => Promise<unknown>;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
type WebhookEventStatus = "pending" | "completed" | "dead_letter";
|
|
415
|
+
interface WebhookEventRow {
|
|
416
|
+
id: string;
|
|
417
|
+
eventId: string;
|
|
418
|
+
eventType: string;
|
|
419
|
+
status: WebhookEventStatus;
|
|
420
|
+
attemptCount: number;
|
|
421
|
+
receivedAt: Date;
|
|
422
|
+
lastAttemptAt: Date | null;
|
|
423
|
+
nextAttemptAt: Date | null;
|
|
424
|
+
completedAt: Date | null;
|
|
425
|
+
deadLetteredAt: Date | null;
|
|
426
|
+
lockedAt: Date | null;
|
|
427
|
+
lockedBy: string | null;
|
|
428
|
+
rawPayload: string | null;
|
|
429
|
+
signatureHeader: string | null;
|
|
430
|
+
lastError: string | null;
|
|
431
|
+
lastErrorCode: string | null;
|
|
432
|
+
}
|
|
433
|
+
/** What a scope learns about the attempt it is running. */
|
|
434
|
+
interface WebhookInboxAttempt {
|
|
435
|
+
previousError: string | null;
|
|
436
|
+
previousErrorCode: string | null;
|
|
437
|
+
}
|
|
438
|
+
type WebhookEventRunner = (ctx: SyncContext, attempt: WebhookInboxAttempt) => Promise<void>;
|
|
439
|
+
/**
|
|
440
|
+
* One kind of work the inbox runs for a StreamPay event. Subscription sync and generic handlers are
|
|
441
|
+
* the two scopes; each keeps its own inbox row per event, distinguished by `eventIdPrefix`.
|
|
442
|
+
*/
|
|
443
|
+
interface WebhookInboxScope {
|
|
444
|
+
/** `null` keeps the unprefixed event IDs that subscription sync has always stored. */
|
|
445
|
+
eventIdPrefix: string | null;
|
|
446
|
+
maxAttempts: number;
|
|
447
|
+
/** Returns the work for an event this scope handles, or `null` to leave the event alone. */
|
|
448
|
+
prepare: (payload: StreamPayWebhookEnvelope) => WebhookEventRunner | null;
|
|
449
|
+
isPermanentFailure: (err: unknown) => boolean;
|
|
450
|
+
/** Releases scope-owned state that waits on the event before an operator discards it. */
|
|
451
|
+
onDiscard?: (ctx: SyncContext, row: WebhookEventRow) => Promise<void>;
|
|
452
|
+
}
|
|
453
|
+
interface ProcessDueWebhookEventsResult {
|
|
454
|
+
succeeded: string[];
|
|
455
|
+
failed: Array<{
|
|
456
|
+
eventId: string;
|
|
457
|
+
error: string;
|
|
458
|
+
}>;
|
|
459
|
+
}
|
|
460
|
+
interface WebhookInbox {
|
|
461
|
+
/**
|
|
462
|
+
* Adds a scope. A scope that is not `replayable` keeps its discard hook for rows it stored
|
|
463
|
+
* earlier, but its events are neither replayed nor retried.
|
|
464
|
+
*
|
|
465
|
+
* @throws TypeError for a prefix other than `null` or `HANDLERS_EVENT_ID_PREFIX`, which replay
|
|
466
|
+
* could not route.
|
|
467
|
+
*/
|
|
468
|
+
register: (scope: WebhookInboxScope, options?: {
|
|
469
|
+
replayable?: boolean;
|
|
470
|
+
}) => void;
|
|
471
|
+
isEnabled: () => boolean;
|
|
472
|
+
/** With `dueAttemptCount`, replays only while the event is still that pending, due attempt. */
|
|
473
|
+
replay: (ctx: SyncContext, eventId: string, options?: {
|
|
474
|
+
dueAttemptCount?: number;
|
|
475
|
+
}) => Promise<{
|
|
476
|
+
replayed: true;
|
|
477
|
+
eventId: string;
|
|
478
|
+
}>;
|
|
479
|
+
/** @throws APIError `CONFLICT` while a worker holds the event or claims it during the discard. */
|
|
480
|
+
discard: (ctx: SyncContext, eventId: string) => Promise<{
|
|
481
|
+
discarded: true;
|
|
482
|
+
eventId: string;
|
|
483
|
+
}>;
|
|
484
|
+
processDue: (ctx: SyncContext, limit: number) => Promise<ProcessDueWebhookEventsResult>;
|
|
485
|
+
}
|
|
445
486
|
|
|
446
487
|
interface ResolvedPlans {
|
|
447
488
|
list: readonly StreamPayPlanLike[];
|
|
@@ -468,7 +509,8 @@ interface WebhookReplayOptions {
|
|
|
468
509
|
*/
|
|
469
510
|
dueAttemptCount?: number;
|
|
470
511
|
}
|
|
471
|
-
|
|
512
|
+
type LinkOptions = Pick<SubscriptionsOptions, "appId" | "resolveSubscriptionReference" | "resolveUnlinkedSubscription">;
|
|
513
|
+
declare function syncWebhookPayload(ctx: SyncContext, payload: StreamPayWebhookPayload, client: StreamPayClient, plans: ResolvedPlans, callbacks: SubscriptionCallbacks & LinkOptions, options?: {
|
|
472
514
|
dedupe?: boolean;
|
|
473
515
|
rawBody?: string | null;
|
|
474
516
|
signatureHeader?: string | null;
|
|
@@ -478,6 +520,13 @@ declare function syncWebhookPayload(ctx: SyncContext, payload: StreamPayWebhookP
|
|
|
478
520
|
/** The inbox table exists. Defaults to `dedupe`; replay processes without dedupe but has an inbox. */
|
|
479
521
|
inboxEnabled?: boolean;
|
|
480
522
|
}): Promise<void>;
|
|
523
|
+
interface SubscriptionLinkRequest {
|
|
524
|
+
streampaySubscriptionId: string;
|
|
525
|
+
referenceType: SubscriptionReferenceType;
|
|
526
|
+
referenceId: string;
|
|
527
|
+
/** Defaults to the configured plan whose product StreamPay bills. */
|
|
528
|
+
plan?: string;
|
|
529
|
+
}
|
|
481
530
|
type WebhookSyncFailure = "PERMANENT" | "TRANSIENT";
|
|
482
531
|
declare function classifyWebhookFailure(err: unknown): WebhookSyncFailure;
|
|
483
532
|
|
|
@@ -504,6 +553,10 @@ interface StreamPayPluginRegistry {
|
|
|
504
553
|
}>;
|
|
505
554
|
/** @deprecated Use `replayWebhookEvent`; both replay any inbox event. */
|
|
506
555
|
replayWebhookHandler?: NonNullable<StreamPayPluginRegistry["replayWebhookEvent"]>;
|
|
556
|
+
linkSubscription?: (ctx: GenericEndpointContext, request: SubscriptionLinkRequest) => Promise<{
|
|
557
|
+
row: Subscription;
|
|
558
|
+
reused: boolean;
|
|
559
|
+
}>;
|
|
507
560
|
}
|
|
508
561
|
declare function subscriptions(subsOptions: SubscriptionsOptions): (options: StreamPayOptions, registry?: StreamPayPluginRegistry) => {
|
|
509
562
|
endpoints: {
|
|
@@ -514,9 +567,9 @@ declare function subscriptions(subsOptions: SubscriptionsOptions): (options: Str
|
|
|
514
567
|
seats: zod.ZodOptional<zod.ZodNumber>;
|
|
515
568
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
516
569
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
517
|
-
custom: "custom";
|
|
518
570
|
user: "user";
|
|
519
571
|
organization: "organization";
|
|
572
|
+
custom: "custom";
|
|
520
573
|
}>>;
|
|
521
574
|
successUrl: zod.ZodOptional<zod.ZodString>;
|
|
522
575
|
failureUrl: zod.ZodOptional<zod.ZodString>;
|
|
@@ -2366,9 +2419,9 @@ declare function subscriptions(subsOptions: SubscriptionsOptions): (options: Str
|
|
|
2366
2419
|
query: zod.ZodOptional<zod.ZodObject<{
|
|
2367
2420
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
2368
2421
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
2369
|
-
custom: "custom";
|
|
2370
2422
|
user: "user";
|
|
2371
2423
|
organization: "organization";
|
|
2424
|
+
custom: "custom";
|
|
2372
2425
|
}>>;
|
|
2373
2426
|
}, zod_v4_core.$strip>>;
|
|
2374
2427
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -2446,9 +2499,9 @@ declare function subscriptions(subsOptions: SubscriptionsOptions): (options: Str
|
|
|
2446
2499
|
group: zod.ZodOptional<zod.ZodString>;
|
|
2447
2500
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
2448
2501
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
2449
|
-
custom: "custom";
|
|
2450
2502
|
user: "user";
|
|
2451
2503
|
organization: "organization";
|
|
2504
|
+
custom: "custom";
|
|
2452
2505
|
}>>;
|
|
2453
2506
|
}, zod_v4_core.$strip>>;
|
|
2454
2507
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -2527,9 +2580,9 @@ declare function subscriptions(subsOptions: SubscriptionsOptions): (options: Str
|
|
|
2527
2580
|
group: zod.ZodOptional<zod.ZodString>;
|
|
2528
2581
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
2529
2582
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
2530
|
-
custom: "custom";
|
|
2531
2583
|
user: "user";
|
|
2532
2584
|
organization: "organization";
|
|
2585
|
+
custom: "custom";
|
|
2533
2586
|
}>>;
|
|
2534
2587
|
}, zod_v4_core.$strip>;
|
|
2535
2588
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -2566,9 +2619,9 @@ declare function subscriptions(subsOptions: SubscriptionsOptions): (options: Str
|
|
|
2566
2619
|
group: zod.ZodOptional<zod.ZodString>;
|
|
2567
2620
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
2568
2621
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
2569
|
-
custom: "custom";
|
|
2570
2622
|
user: "user";
|
|
2571
2623
|
organization: "organization";
|
|
2624
|
+
custom: "custom";
|
|
2572
2625
|
}>>;
|
|
2573
2626
|
}, zod_v4_core.$strip>;
|
|
2574
2627
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -2903,6 +2956,45 @@ interface AdminOptions {
|
|
|
2903
2956
|
}
|
|
2904
2957
|
declare const admin: (adminOptions?: AdminOptions) => (options: StreamPayOptions, registry?: StreamPayPluginRegistry) => {
|
|
2905
2958
|
endpoints: {
|
|
2959
|
+
adminLinkSubscription: better_auth.StrictEndpoint<"/admin/streampay/subscriptions/:id/link", {
|
|
2960
|
+
method: "POST";
|
|
2961
|
+
body: z.ZodObject<{
|
|
2962
|
+
referenceType: z.ZodEnum<{
|
|
2963
|
+
user: "user";
|
|
2964
|
+
organization: "organization";
|
|
2965
|
+
custom: "custom";
|
|
2966
|
+
}>;
|
|
2967
|
+
referenceId: z.ZodString;
|
|
2968
|
+
plan: z.ZodOptional<z.ZodString>;
|
|
2969
|
+
}, z.core.$strict>;
|
|
2970
|
+
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
2971
|
+
session: {
|
|
2972
|
+
session: Record<string, any> & {
|
|
2973
|
+
id: string;
|
|
2974
|
+
createdAt: Date;
|
|
2975
|
+
updatedAt: Date;
|
|
2976
|
+
userId: string;
|
|
2977
|
+
expiresAt: Date;
|
|
2978
|
+
token: string;
|
|
2979
|
+
ipAddress?: string | null | undefined;
|
|
2980
|
+
userAgent?: string | null | undefined;
|
|
2981
|
+
};
|
|
2982
|
+
user: Record<string, any> & {
|
|
2983
|
+
id: string;
|
|
2984
|
+
createdAt: Date;
|
|
2985
|
+
updatedAt: Date;
|
|
2986
|
+
email: string;
|
|
2987
|
+
emailVerified: boolean;
|
|
2988
|
+
name: string;
|
|
2989
|
+
image?: string | null | undefined;
|
|
2990
|
+
};
|
|
2991
|
+
};
|
|
2992
|
+
}>>[];
|
|
2993
|
+
}, {
|
|
2994
|
+
linked: boolean;
|
|
2995
|
+
reused: boolean;
|
|
2996
|
+
subscription: Subscription;
|
|
2997
|
+
}>;
|
|
2906
2998
|
adminListWebhookEvents: better_auth.StrictEndpoint<"/admin/streampay/webhook-events", {
|
|
2907
2999
|
method: "GET";
|
|
2908
3000
|
query: z.ZodObject<{
|
|
@@ -7183,6 +7275,45 @@ declare const streampay: <O extends StreamPayOptions>(options: O) => {
|
|
|
7183
7275
|
id: "streampay";
|
|
7184
7276
|
version: string;
|
|
7185
7277
|
endpoints: {
|
|
7278
|
+
adminLinkSubscription: better_auth.StrictEndpoint<"/admin/streampay/subscriptions/:id/link", {
|
|
7279
|
+
method: "POST";
|
|
7280
|
+
body: zod.ZodObject<{
|
|
7281
|
+
referenceType: zod.ZodEnum<{
|
|
7282
|
+
user: "user";
|
|
7283
|
+
organization: "organization";
|
|
7284
|
+
custom: "custom";
|
|
7285
|
+
}>;
|
|
7286
|
+
referenceId: zod.ZodString;
|
|
7287
|
+
plan: zod.ZodOptional<zod.ZodString>;
|
|
7288
|
+
}, zod_v4_core.$strict>;
|
|
7289
|
+
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
7290
|
+
session: {
|
|
7291
|
+
session: Record<string, any> & {
|
|
7292
|
+
id: string;
|
|
7293
|
+
createdAt: Date;
|
|
7294
|
+
updatedAt: Date;
|
|
7295
|
+
userId: string;
|
|
7296
|
+
expiresAt: Date;
|
|
7297
|
+
token: string;
|
|
7298
|
+
ipAddress?: string | null | undefined;
|
|
7299
|
+
userAgent?: string | null | undefined;
|
|
7300
|
+
};
|
|
7301
|
+
user: Record<string, any> & {
|
|
7302
|
+
id: string;
|
|
7303
|
+
createdAt: Date;
|
|
7304
|
+
updatedAt: Date;
|
|
7305
|
+
email: string;
|
|
7306
|
+
emailVerified: boolean;
|
|
7307
|
+
name: string;
|
|
7308
|
+
image?: string | null | undefined;
|
|
7309
|
+
};
|
|
7310
|
+
};
|
|
7311
|
+
}>>[];
|
|
7312
|
+
}, {
|
|
7313
|
+
linked: boolean;
|
|
7314
|
+
reused: boolean;
|
|
7315
|
+
subscription: Subscription;
|
|
7316
|
+
}>;
|
|
7186
7317
|
adminListWebhookEvents: better_auth.StrictEndpoint<"/admin/streampay/webhook-events", {
|
|
7187
7318
|
method: "GET";
|
|
7188
7319
|
query: zod.ZodObject<{
|
|
@@ -11158,9 +11289,9 @@ declare const streampay: <O extends StreamPayOptions>(options: O) => {
|
|
|
11158
11289
|
seats: zod.ZodOptional<zod.ZodNumber>;
|
|
11159
11290
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
11160
11291
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
11161
|
-
custom: "custom";
|
|
11162
11292
|
user: "user";
|
|
11163
11293
|
organization: "organization";
|
|
11294
|
+
custom: "custom";
|
|
11164
11295
|
}>>;
|
|
11165
11296
|
successUrl: zod.ZodOptional<zod.ZodString>;
|
|
11166
11297
|
failureUrl: zod.ZodOptional<zod.ZodString>;
|
|
@@ -13010,9 +13141,9 @@ declare const streampay: <O extends StreamPayOptions>(options: O) => {
|
|
|
13010
13141
|
query: zod.ZodOptional<zod.ZodObject<{
|
|
13011
13142
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
13012
13143
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
13013
|
-
custom: "custom";
|
|
13014
13144
|
user: "user";
|
|
13015
13145
|
organization: "organization";
|
|
13146
|
+
custom: "custom";
|
|
13016
13147
|
}>>;
|
|
13017
13148
|
}, zod_v4_core.$strip>>;
|
|
13018
13149
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -13090,9 +13221,9 @@ declare const streampay: <O extends StreamPayOptions>(options: O) => {
|
|
|
13090
13221
|
group: zod.ZodOptional<zod.ZodString>;
|
|
13091
13222
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
13092
13223
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
13093
|
-
custom: "custom";
|
|
13094
13224
|
user: "user";
|
|
13095
13225
|
organization: "organization";
|
|
13226
|
+
custom: "custom";
|
|
13096
13227
|
}>>;
|
|
13097
13228
|
}, zod_v4_core.$strip>>;
|
|
13098
13229
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -13171,9 +13302,9 @@ declare const streampay: <O extends StreamPayOptions>(options: O) => {
|
|
|
13171
13302
|
group: zod.ZodOptional<zod.ZodString>;
|
|
13172
13303
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
13173
13304
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
13174
|
-
custom: "custom";
|
|
13175
13305
|
user: "user";
|
|
13176
13306
|
organization: "organization";
|
|
13307
|
+
custom: "custom";
|
|
13177
13308
|
}>>;
|
|
13178
13309
|
}, zod_v4_core.$strip>;
|
|
13179
13310
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -13210,9 +13341,9 @@ declare const streampay: <O extends StreamPayOptions>(options: O) => {
|
|
|
13210
13341
|
group: zod.ZodOptional<zod.ZodString>;
|
|
13211
13342
|
referenceId: zod.ZodOptional<zod.ZodString>;
|
|
13212
13343
|
referenceType: zod.ZodOptional<zod.ZodEnum<{
|
|
13213
|
-
custom: "custom";
|
|
13214
13344
|
user: "user";
|
|
13215
13345
|
organization: "organization";
|
|
13346
|
+
custom: "custom";
|
|
13216
13347
|
}>>;
|
|
13217
13348
|
}, zod_v4_core.$strip>;
|
|
13218
13349
|
use: better_auth.Middleware<better_auth.MiddlewareOptions, (inputContext: better_auth.MiddlewareInputContext<better_auth.MiddlewareOptions>) => Promise<{
|
|
@@ -13305,4 +13436,4 @@ declare const streampay: <O extends StreamPayOptions>(options: O) => {
|
|
|
13305
13436
|
};
|
|
13306
13437
|
};
|
|
13307
13438
|
|
|
13308
|
-
export { $ERROR_CODES as $,
|
|
13439
|
+
export { $ERROR_CODES as $, APP_ID_METADATA_KEY as A, type StreamPayEventType as B, CheckoutBody as C, DEFAULT_ACCESS_STATUSES as D, type ErrorCodeEntry as E, type FeatureKey as F, type StreamPayHookContext as G, type StreamPayInvoiceEventType as H, type StreamPayOptions as I, type StreamPayPaymentEventType as J, type StreamPayPaymentLinkEventType as K, type LimitCheckResult as L, type StreamPayPlan as M, type StreamPayPlanLike as N, type StreamPayPlugin as O, PLAN_NAME_METADATA_KEY as P, type StreamPayPluginRegistry as Q, REFERENCE_ID_METADATA_KEY as R, type StreamPayErrorCode as S, type StreamPayPlugins as T, type StreamPayProduct as U, type StreamPaySeatBilling as V, type StreamPaySubscriptionEventType as W, type StreamPayWebhookData as X, type StreamPayWebhookEnvelope as Y, type StreamPayWebhookPayload as Z, type Subscription as _, type StreamPayClient as a, type SubscriptionBillingStatus as a0, type SubscriptionCallback as a1, type SubscriptionCallbackData as a2, type SubscriptionCallbacks as a3, type SubscriptionReferenceContext as a4, type SubscriptionReferenceType as a5, type SubscriptionStatus as a6, type SubscriptionsOptions as a7, type SyncContext as a8, type TrialEligibilityContext as a9, type UnlinkedSubscriptionContext as aa, type UnlinkedSubscriptionResolution as ab, type WebhookEnvelopeHandler as ac, type WebhookHandler as ad, type WebhookHandlers as ae, type WebhookSyncFailure as af, type WebhooksOptions as ag, admin as ah, checkLimit as ai, checkout as aj, classifyWebhookFailure as ak, dispatchWebhook as al, hasFeature as am, hasSubscriptionAccess as an, isKnownStreamPayWebhookPayload as ao, isStreamPayWebhookEnvelope as ap, mapToErrorCode as aq, portal as ar, subscriptionSlotKey as as, subscriptions as at, syncWebhookPayload as au, webhooks as av, type AdminOptions as b, type AuthorizeReferenceContext as c, type CheckoutCreatedContext as d, type CheckoutOptions as e, type CheckoutOverrides as f, type CheckoutParams as g, type CheckoutResolutionContext as h, type ClaimExistingConsumerBy as i, type ClaimExistingConsumerIdentifier as j, type ConsumerCreateOverrides as k, type PluginAdapter as l, type PortalOptions as m, REFERENCE_TYPE_METADATA_KEY as n, type ResolvedPlans as o, STREAMPAY_EVENT_TYPES as p, STREAMPAY_INVOICE_EVENT_TYPES as q, STREAMPAY_PAYMENT_EVENT_TYPES as r, streampay as s, STREAMPAY_PAYMENT_LINK_EVENT_TYPES as t, STREAMPAY_SUBSCRIPTION_EVENT_TYPES as u, SUBSCRIPTION_ROW_ID_METADATA_KEY as v, type StreamPayCustomFieldDefinition as w, type StreamPayCustomFieldsSchema as x, type StreamPayEndpoints as y, type StreamPayEntityType as z };
|