Added webhook support stuff
Some checks failed
Publish to Private NPM Registry / publish (push) Failing after 48s

This commit is contained in:
Alan Bridgeman 2026-01-24 10:06:47 -06:00
parent 522f7590b3
commit 9024547028
4 changed files with 71 additions and 0 deletions

View file

@ -1,6 +1,8 @@
import { OAuthApp } from './OAuthApp.js'; import { OAuthApp } from './OAuthApp.js';
import type { BridgemanAccessibleAppClaims } from './types/BridgemanAccessibleAppClaims.js'; import type { BridgemanAccessibleAppClaims } from './types/BridgemanAccessibleAppClaims.js';
import type { AppSubscriptionTier } from './types/AppSubscriptionTier.js'; import type { AppSubscriptionTier } from './types/AppSubscriptionTier.js';
import type { Webhook } from './types/Webhook.js';
import { WebhookPurpose } from './types/WebhookPurpose.js';
import type { Addon } from './types/addons/Addon.js'; import type { Addon } from './types/addons/Addon.js';
import { AddonType } from './types/addons/AddonType.js'; import { AddonType } from './types/addons/AddonType.js';
import { BillingCadence as AddonBillingCadence } from './types/addons/BillingCadence.js'; import { BillingCadence as AddonBillingCadence } from './types/addons/BillingCadence.js';
@ -11,6 +13,8 @@ export {
OAuthApp, OAuthApp,
BridgemanAccessibleAppClaims, BridgemanAccessibleAppClaims,
AppSubscriptionTier, AppSubscriptionTier,
Webhook,
WebhookPurpose,
Addon, Addon,
AddonType, AddonType,
AddonBillingCadence, AddonBillingCadence,

View file

@ -1,6 +1,7 @@
import { ClientCustomClaims } from '@BridgemanAccessible/ba-auth/server'; import { ClientCustomClaims } from '@BridgemanAccessible/ba-auth/server';
import { AppSubscriptionTier } from './AppSubscriptionTier.js'; import { AppSubscriptionTier } from './AppSubscriptionTier.js';
import { Webhook } from './Webhook.js';
import { Addon } from './addons/Addon.js'; import { Addon } from './addons/Addon.js';
@ -28,6 +29,9 @@ export interface BridgemanAccessibleAppClaims extends ClientCustomClaims {
*/ */
client_abbreviation: string; client_abbreviation: string;
/** The webhooks registered for this app */
webhooks: Webhook[];
/** Whether a paid subscription is mandatory to use the app */ /** Whether a paid subscription is mandatory to use the app */
subscription_required: boolean; subscription_required: boolean;

View file

@ -0,0 +1,9 @@
import { WebhookPurpose } from './WebhookPurpose.js';
export interface Webhook {
/** The URL to which the webhook payloads will be sent */
url: string;
/** The purpose(s) for which this webhook is registered */
purpose: WebhookPurpose[];
}

View file

@ -0,0 +1,54 @@
export enum WebhookPurpose {
/**
* When a user who hasn't had a subscription before gets one
* Note, if this isn't specified, but a SUBSCRIPTION_CHANGED is,
* the SUBSCRIPTION_CHANGED will be sent instead
* Because this allows for more specific handling but is less commonly needed
*/
SUBSCRIPTION_ADDED = 'SUBSCRIPTION_ADDED',
/**
* When a user's subscription changes in any way.
* If implementing any of the SUBSCRIPTION_* webhooks,
* this should be the one implemented to cover all bases
*/
SUBSCRIPTION_CHANGED = 'SUBSCRIPTION_CHANGED',
/**
* When a user's subscription is canceled
* Note, if this isn't specified, but a SUBSCRIPTION_CHANGED is,
* the SUBSCRIPTION_CHANGED will be sent instead
* Because this allows for more specific handling but is less commonly needed
*/
SUBSCRIPTION_CANCELED = 'SUBSCRIPTION_CANCELED',
/** When a user purchases an add-on */
ADDON_PURCHASED = 'ADDON_PURCHASED',
/**
* When a user removes an add-on
*
* This is usually for subscription type addons that aren't renewed.
* One-time addons can't really be removed.
*/
ADDON_REMOVED = 'ADDON_REMOVED',
/**
* When an add-on's settings are changed.
*
* This is usually for subscription type addons that have configurable options.
* One-time addons can't really have configurable settings.
*/
ADDON_CHANGED = 'ADDON_CHANGED',
/**
* When a user's permissions are changed.
*
* This is usually an account level change that applies to the user (ex. an admin changes their role or policies).
* But this isn't restricted to that just any time the user's permissions change this webhook will be sent.
*/
PERMISSION_CHANGED = 'PERMISSION_CHANGED',
/** When a user is deleted. */
USER_DELETED = 'USER_DELETED'
}