@chatarmin/os 1.5.8 → 1.7.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 +36 -122
- package/dist/companies/client.d.ts +8 -0
- package/dist/companies/client.d.ts.map +1 -0
- package/dist/companies/client.js +8 -0
- package/dist/companies/index.d.ts +3 -0
- package/dist/companies/index.d.ts.map +1 -0
- package/dist/companies/index.js +1 -0
- package/dist/companies/types.d.ts +66 -0
- package/dist/companies/types.d.ts.map +1 -0
- package/dist/index.d.ts +348 -245
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +194 -133
- package/dist/webhooks/constants.d.ts +5 -0
- package/dist/webhooks/constants.d.ts.map +1 -0
- package/dist/webhooks/constants.js +4 -0
- package/dist/webhooks/construct-event.d.ts +3 -0
- package/dist/webhooks/construct-event.d.ts.map +1 -0
- package/dist/webhooks/construct-event.js +64 -0
- package/dist/webhooks/errors.d.ts +4 -0
- package/dist/webhooks/errors.d.ts.map +1 -0
- package/dist/webhooks/errors.js +6 -0
- package/dist/webhooks/generate-test-headers.d.ts +3 -0
- package/dist/webhooks/generate-test-headers.d.ts.map +1 -0
- package/dist/webhooks/generate-test-headers.js +11 -0
- package/dist/webhooks/index.d.ts +16 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +14 -0
- package/dist/webhooks/read-header.d.ts +3 -0
- package/dist/webhooks/read-header.d.ts.map +1 -0
- package/dist/webhooks/read-header.js +16 -0
- package/dist/webhooks/signing.d.ts +4 -0
- package/dist/webhooks/signing.d.ts.map +1 -0
- package/dist/webhooks/signing.js +16 -0
- package/dist/webhooks/types.d.ts +30 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/package.json +10 -5
- package/CHANGELOG.md +0 -21
- package/dist/billing-get-dashboard-context.d.ts +0 -16
- package/dist/billing-get-dashboard-context.d.ts.map +0 -1
- package/dist/billing-get-dashboard-context.js +0 -7
- package/dist/chatarmin-os-billing-namespace.d.ts +0 -122
- package/dist/chatarmin-os-billing-namespace.d.ts.map +0 -1
- package/dist/chatarmin-os-billing-namespace.js +0 -24
- package/dist/features-list-for-product.d.ts +0 -26
- package/dist/features-list-for-product.d.ts.map +0 -1
- package/dist/features-list-for-product.js +0 -17
- package/dist/types/billing-dashboard-context.d.ts +0 -33
- package/dist/types/billing-dashboard-context.d.ts.map +0 -1
- package/dist/types/chatarmin-os-billing-inputs.d.ts +0 -90
- package/dist/types/chatarmin-os-billing-inputs.d.ts.map +0 -1
- package/dist/types/feature-access-list-item.d.ts +0 -7
- package/dist/types/feature-access-list-item.d.ts.map +0 -1
- package/dist/types/feature-access-list-item.js +0 -1
- package/dist/types/product-feature-catalog.d.ts +0 -24
- package/dist/types/product-feature-catalog.d.ts.map +0 -1
- package/dist/types/product-feature-catalog.js +0 -1
- /package/dist/{types/billing-dashboard-context.js → companies/types.js} +0 -0
- /package/dist/{types/chatarmin-os-billing-inputs.js → webhooks/types.js} +0 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,QAAQ,EACR,4BAA4B,EAC5B,0BAA0B,EAC1B,mCAAmC,EACnC,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,mCAAmC,EACnC,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,eAAe,EACf,eAAe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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6BG;2BACgB,MAAM,WAAW,cAAc;;;;;QASlD;;;;;;;;;;;;;;;;;;;WAmBG;;;;;;;;;;;;;;;;;;;;QAMH;;;;;;;;;;;;;;;;;;;;;;;WAuBG;4BACiB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAK7B;IAMD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,KAAK;QAIL;;;;;;;;;;;WAWG;;;;;;;;;;;;;;;;;;;;QAMH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAsCG;wBACa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAKtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8BG;0BACe,MAAM,WAAW,cAAc;;;;;MASpD;IAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyFG;IACG,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CA8E3D;AAGD,YAAY,EAAE,SAAS,EAAE,CAAA;AAGzB,eAAe,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TRPCClientError, createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
2
2
|
import superjson from "superjson";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createCompaniesClient, } from "./companies";
|
|
4
|
+
import { webhooks } from "./webhooks";
|
|
5
|
+
export { webhooks, constructProductWebhookEvent, generateTestWebhookHeaders, OsWebhookSignatureVerificationError, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, } from "./webhooks";
|
|
5
6
|
const INSPECT_SYMBOL = Symbol.for("nodejs.util.inspect.custom");
|
|
6
7
|
export class ChatarminOSError extends Error {
|
|
7
8
|
details;
|
|
@@ -118,6 +119,7 @@ function toChatarminOSError(operation, error) {
|
|
|
118
119
|
* @see https://os.chatarmin.com/docs for full documentation
|
|
119
120
|
*/
|
|
120
121
|
export class ChatarminOS {
|
|
122
|
+
static webhooks = webhooks;
|
|
121
123
|
client;
|
|
122
124
|
async call(operation, action) {
|
|
123
125
|
try {
|
|
@@ -172,10 +174,13 @@ export class ChatarminOS {
|
|
|
172
174
|
* @example
|
|
173
175
|
* ```typescript
|
|
174
176
|
* // Look up a company by your org ID
|
|
175
|
-
* const company = await os.companies.
|
|
177
|
+
* const company = await os.companies.get({
|
|
176
178
|
* externalOrgId: 'org_abc123'
|
|
177
179
|
* })
|
|
178
180
|
*
|
|
181
|
+
* // Route support mail to the assigned CSM
|
|
182
|
+
* const csmEmail = company?.assignees.csm?.email
|
|
183
|
+
*
|
|
179
184
|
* // Create a new company
|
|
180
185
|
* const newCompany = await os.companies.create({
|
|
181
186
|
* name: 'Acme Inc',
|
|
@@ -186,118 +191,7 @@ export class ChatarminOS {
|
|
|
186
191
|
* ```
|
|
187
192
|
*/
|
|
188
193
|
get companies() {
|
|
189
|
-
|
|
190
|
-
const call = this.call.bind(this);
|
|
191
|
-
return {
|
|
192
|
-
/**
|
|
193
|
-
* List companies linked to your product.
|
|
194
|
-
*
|
|
195
|
-
* Use cursor pagination to iterate through all linked companies.
|
|
196
|
-
*/
|
|
197
|
-
listLinked: (input) => call("companies.listLinked", () => client.companies.listLinked.query(input ?? {})),
|
|
198
|
-
/**
|
|
199
|
-
* Look up a company by their external organization ID in your product.
|
|
200
|
-
*
|
|
201
|
-
* Use this to resolve your product's org ID to a ChatarminOS company.
|
|
202
|
-
* Returns `null` if no company is linked with this external ID.
|
|
203
|
-
*
|
|
204
|
-
* @param input - The lookup parameters
|
|
205
|
-
* @param input.externalOrgId - Your product's organization ID
|
|
206
|
-
* @returns The company if found, or `null`
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```typescript
|
|
210
|
-
* const company = await os.companies.getByProductLink({
|
|
211
|
-
* externalOrgId: 'org_abc123'
|
|
212
|
-
* })
|
|
213
|
-
*
|
|
214
|
-
* if (company) {
|
|
215
|
-
* console.log(`Found: ${company.name}`)
|
|
216
|
-
* } else {
|
|
217
|
-
* console.log('Company not linked yet')
|
|
218
|
-
* }
|
|
219
|
-
* ```
|
|
220
|
-
*/
|
|
221
|
-
getByProductLink: (input) => call("companies.getByProductLink", () => client.companies.getByProductLink.query(input)),
|
|
222
|
-
/**
|
|
223
|
-
* Create a new company and link it to your product.
|
|
224
|
-
*
|
|
225
|
-
* This creates a company in ChatarminOS and automatically links it
|
|
226
|
-
* to your product using the provided external organization ID.
|
|
227
|
-
*
|
|
228
|
-
* @param input - Company creation parameters
|
|
229
|
-
* @returns The created company with ID and short ID
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```typescript
|
|
233
|
-
* const company = await os.companies.create({
|
|
234
|
-
* name: 'Acme Inc',
|
|
235
|
-
* domain: 'acme.com',
|
|
236
|
-
* externalOrgId: 'org_abc123',
|
|
237
|
-
* contactEmail: 'admin@acme.com',
|
|
238
|
-
* contactName: 'John Doe'
|
|
239
|
-
* })
|
|
240
|
-
*
|
|
241
|
-
* console.log(company.id) // UUID
|
|
242
|
-
* console.log(company.shortId) // e.g., "acme-inc"
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
create: (input) => call("companies.create", () => client.companies.createWithLink.mutate(input)),
|
|
246
|
-
/**
|
|
247
|
-
* Update company metadata.
|
|
248
|
-
*
|
|
249
|
-
* Used for backfilling data like historical created_at dates.
|
|
250
|
-
*
|
|
251
|
-
* @param input - Update parameters
|
|
252
|
-
* @returns Whether the update was applied
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```typescript
|
|
256
|
-
* await os.companies.update({
|
|
257
|
-
* companyId: 'uuid-here',
|
|
258
|
-
* createdAt: '2023-01-15T10:30:00.000Z'
|
|
259
|
-
* })
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
update: (input) => call("companies.update", () => client.companies.updateCompany.mutate(input)),
|
|
263
|
-
/**
|
|
264
|
-
* Smart link - intelligently find and link a company using hints.
|
|
265
|
-
*
|
|
266
|
-
* This method attempts to find an existing company in ChatarminOS
|
|
267
|
-
* that matches the provided hints (domain, name, emails). If found
|
|
268
|
-
* with sufficient confidence, it automatically creates a link.
|
|
269
|
-
*
|
|
270
|
-
* **Matching priority:**
|
|
271
|
-
* 1. Domain match (95% confidence)
|
|
272
|
-
* 2. Name match (up to 80% confidence)
|
|
273
|
-
* 3. Email domain match (70% confidence)
|
|
274
|
-
*
|
|
275
|
-
* @param input - Smart link parameters
|
|
276
|
-
* @returns Result with status and company info if linked
|
|
277
|
-
*
|
|
278
|
-
* @example
|
|
279
|
-
* ```typescript
|
|
280
|
-
* const result = await os.companies.smartLink({
|
|
281
|
-
* externalOrgId: 'org_abc123',
|
|
282
|
-
* hints: {
|
|
283
|
-
* companyName: 'Acme Inc',
|
|
284
|
-
* domain: 'acme.com',
|
|
285
|
-
* emails: ['john@acme.com']
|
|
286
|
-
* },
|
|
287
|
-
* minConfidence: 0.7
|
|
288
|
-
* })
|
|
289
|
-
*
|
|
290
|
-
* if (result.status === 'linked') {
|
|
291
|
-
* console.log(`Linked to ${result.customerName}`)
|
|
292
|
-
* } else if (result.status === 'suggestions') {
|
|
293
|
-
* console.log('Possible matches:', result.suggestions)
|
|
294
|
-
* }
|
|
295
|
-
* ```
|
|
296
|
-
*
|
|
297
|
-
* @experimental This API may change in future versions
|
|
298
|
-
*/
|
|
299
|
-
smartLink: (input) => call("companies.smartLink", () => client.companies.smartLink.mutate(input)),
|
|
300
|
-
};
|
|
194
|
+
return createCompaniesClient(this.client, this.call.bind(this));
|
|
301
195
|
}
|
|
302
196
|
// ==========================================================================
|
|
303
197
|
// Contacts
|
|
@@ -407,7 +301,29 @@ export class ChatarminOS {
|
|
|
407
301
|
// ==========================================================================
|
|
408
302
|
// Features
|
|
409
303
|
// ==========================================================================
|
|
410
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* Feature access and entitlement operations.
|
|
306
|
+
*
|
|
307
|
+
* Check what features a company has access to and their current usage.
|
|
308
|
+
* Features are defined in ChatarminOS and assigned via subscription tiers.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* // Check if company can use a feature
|
|
313
|
+
* const access = await os.features.check({
|
|
314
|
+
* companyId: company.id,
|
|
315
|
+
* featureCode: 'ai_credit'
|
|
316
|
+
* })
|
|
317
|
+
*
|
|
318
|
+
* if (access.canUse) {
|
|
319
|
+
* // Feature is available
|
|
320
|
+
* console.log(`Remaining: ${access.remaining}`)
|
|
321
|
+
* } else {
|
|
322
|
+
* // Feature is disabled or limit reached
|
|
323
|
+
* console.log('Upgrade required')
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
411
327
|
get features() {
|
|
412
328
|
const client = this.client;
|
|
413
329
|
const call = this.call.bind(this);
|
|
@@ -487,7 +403,6 @@ export class ChatarminOS {
|
|
|
487
403
|
const params = typeof input === "string" ? { companyId: input } : input;
|
|
488
404
|
return client.features.getAccess.query(params);
|
|
489
405
|
}),
|
|
490
|
-
listForProduct: bindFeaturesListForProduct(call, client),
|
|
491
406
|
/**
|
|
492
407
|
* Update feature access for a company with partial config merge.
|
|
493
408
|
*
|
|
@@ -618,7 +533,164 @@ export class ChatarminOS {
|
|
|
618
533
|
* ```
|
|
619
534
|
*/
|
|
620
535
|
get billing() {
|
|
621
|
-
|
|
536
|
+
const client = this.client;
|
|
537
|
+
const call = this.call.bind(this);
|
|
538
|
+
return {
|
|
539
|
+
/**
|
|
540
|
+
* Set usage to an absolute value.
|
|
541
|
+
*
|
|
542
|
+
* Use this for corrections when you know what the total usage SHOULD be.
|
|
543
|
+
* Creates a snapshot for audit trail. The delta (difference) is calculated
|
|
544
|
+
* automatically and synced to Stripe.
|
|
545
|
+
*
|
|
546
|
+
* @param input - Set usage parameters
|
|
547
|
+
* @returns Result with previous and new usage values
|
|
548
|
+
*
|
|
549
|
+
* @example Correct usage to 100 (was 150)
|
|
550
|
+
* ```typescript
|
|
551
|
+
* const result = await os.billing.setUsage({
|
|
552
|
+
* companyId: 'comp_xxx',
|
|
553
|
+
* featureCode: 'ai_credit',
|
|
554
|
+
* absoluteValue: 100,
|
|
555
|
+
* reason: 'Corrected after customer support review',
|
|
556
|
+
* performedBy: 'admin@company.com'
|
|
557
|
+
* })
|
|
558
|
+
*
|
|
559
|
+
* console.log({
|
|
560
|
+
* previousUsage: result.previousUsage, // 150
|
|
561
|
+
* currentUsage: result.currentUsage, // 100
|
|
562
|
+
* delta: result.delta // -50
|
|
563
|
+
* })
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
setUsage: (input) => call("billing.setUsage", () => client.billing.setUsage.mutate({
|
|
567
|
+
...input,
|
|
568
|
+
source: "api",
|
|
569
|
+
})),
|
|
570
|
+
/**
|
|
571
|
+
* Get usage event history for a feature.
|
|
572
|
+
*
|
|
573
|
+
* Returns the history of usage events including increments, sets,
|
|
574
|
+
* and adjustments. Useful for auditing and debugging.
|
|
575
|
+
*
|
|
576
|
+
* @param companyId - Company ID
|
|
577
|
+
* @param featureCode - Feature code to get history for
|
|
578
|
+
* @param options - Query options
|
|
579
|
+
* @returns Array of usage events
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* ```typescript
|
|
583
|
+
* const history = await os.billing.getUsageHistory(
|
|
584
|
+
* 'comp_xxx',
|
|
585
|
+
* 'ai_credit',
|
|
586
|
+
* { limit: 20, eventType: 'adjustment' }
|
|
587
|
+
* )
|
|
588
|
+
*
|
|
589
|
+
* for (const event of history) {
|
|
590
|
+
* console.log(`${event.event_type}: ${event.quantity} at ${event.event_time}`)
|
|
591
|
+
* if (event.adjustment_reason) {
|
|
592
|
+
* console.log(` Reason: ${event.adjustment_reason}`)
|
|
593
|
+
* }
|
|
594
|
+
* }
|
|
595
|
+
* ```
|
|
596
|
+
*/
|
|
597
|
+
getUsageHistory: (companyId, featureCode, options) => call("billing.getUsageHistory", () => client.billing.getUsageHistory.query({
|
|
598
|
+
companyId,
|
|
599
|
+
featureCode,
|
|
600
|
+
...options,
|
|
601
|
+
})),
|
|
602
|
+
/**
|
|
603
|
+
* Claim a subscription from a completed Stripe Checkout Session.
|
|
604
|
+
*
|
|
605
|
+
* Use this after a user completes Stripe checkout in your product.
|
|
606
|
+
* This links the subscription and customer to the company in OS.
|
|
607
|
+
*
|
|
608
|
+
* @param input - Claim parameters
|
|
609
|
+
* @returns Result with subscription ID and claim status
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* // In your Stripe checkout success handler:
|
|
614
|
+
* const result = await os.billing.claimCheckout({
|
|
615
|
+
* companyId: company.id,
|
|
616
|
+
* checkoutSessionId: session.id // From Stripe callback
|
|
617
|
+
* })
|
|
618
|
+
*
|
|
619
|
+
* if (result.alreadyClaimed) {
|
|
620
|
+
* console.log('Subscription was already claimed')
|
|
621
|
+
* } else {
|
|
622
|
+
* console.log(`Claimed subscription: ${result.subscriptionId}`)
|
|
623
|
+
* }
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
claimCheckout: (input) => call("billing.claimCheckout", () => client.billing.claimCheckout.mutate(input)),
|
|
627
|
+
/**
|
|
628
|
+
* Link an existing Stripe subscription to a company.
|
|
629
|
+
*
|
|
630
|
+
* Use this when you create subscriptions on your product's Stripe
|
|
631
|
+
* account and want OS to track them. Optionally applies tier features.
|
|
632
|
+
*
|
|
633
|
+
* @param input - Link parameters
|
|
634
|
+
* @returns Result with subscription ID, link status, and features applied
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* ```typescript
|
|
638
|
+
* // After creating subscription on your Stripe account:
|
|
639
|
+
* const result = await os.billing.linkSubscription({
|
|
640
|
+
* companyId: company.id,
|
|
641
|
+
* stripeSubscriptionId: 'sub_xxx',
|
|
642
|
+
* stripeCustomerId: 'cus_xxx', // Optional
|
|
643
|
+
* tierCode: 'pro', // Apply tier features
|
|
644
|
+
* displayName: 'Pro Plan'
|
|
645
|
+
* })
|
|
646
|
+
*
|
|
647
|
+
* console.log({
|
|
648
|
+
* subscriptionId: result.subscriptionId,
|
|
649
|
+
* isNew: !result.alreadyLinked,
|
|
650
|
+
* featuresApplied: result.featuresApplied
|
|
651
|
+
* })
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
linkSubscription: (input) => call("billing.linkSubscription", () => client.billing.linkSubscription.mutate(input)),
|
|
655
|
+
/**
|
|
656
|
+
* Get billing status for a company.
|
|
657
|
+
*
|
|
658
|
+
* Quick check for subscription status, active features, and
|
|
659
|
+
* billing profile information.
|
|
660
|
+
*
|
|
661
|
+
* @param companyId - Company ID to check
|
|
662
|
+
* @returns Billing status overview
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* ```typescript
|
|
666
|
+
* const status = await os.billing.getStatus(company.id)
|
|
667
|
+
*
|
|
668
|
+
* console.log({
|
|
669
|
+
* hasBilling: status.hasBillingProfile,
|
|
670
|
+
* subscriptions: status.activeSubscriptions.length,
|
|
671
|
+
* features: status.enabledFeaturesCount
|
|
672
|
+
* })
|
|
673
|
+
*
|
|
674
|
+
* // Check active tier
|
|
675
|
+
* if (status.activeSubscriptions[0]?.tier) {
|
|
676
|
+
* console.log(`Current tier: ${status.activeSubscriptions[0].tier.name}`)
|
|
677
|
+
* }
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
getStatus: (companyId) => call("billing.getStatus", () => client.billing.getStatus.query({ companyId })),
|
|
681
|
+
/**
|
|
682
|
+
* Sync billing profile, subscriptions, and feature access from Stripe.
|
|
683
|
+
*/
|
|
684
|
+
syncCompanyFromStripe: (input) => call("billing.syncCompanyFromStripe", () => client.billing.syncCompanyFromStripe.mutate(input)),
|
|
685
|
+
/**
|
|
686
|
+
* Relink billing profile to a new Stripe customer (destructive).
|
|
687
|
+
*/
|
|
688
|
+
relinkBillingProfile: (input) => call("billing.relinkBillingProfile", () => client.billing.relinkBillingProfile.mutate(input)),
|
|
689
|
+
/**
|
|
690
|
+
* Ensure a feature is linked to an active Stripe subscription item.
|
|
691
|
+
*/
|
|
692
|
+
ensureFeatureSubscription: (input) => call("billing.ensureFeatureSubscription", () => client.billing.ensureFeatureSubscription.mutate(input)),
|
|
693
|
+
};
|
|
622
694
|
}
|
|
623
695
|
// ==========================================================================
|
|
624
696
|
// Links
|
|
@@ -1027,35 +1099,24 @@ export class ChatarminOS {
|
|
|
1027
1099
|
*
|
|
1028
1100
|
* if (result.linkStatus === 'already_linked') {
|
|
1029
1101
|
* console.log('Welcome back!')
|
|
1030
|
-
* } else if (result.linkStatus === 'linked') {
|
|
1031
|
-
* console.log('Found existing company, linked!')
|
|
1032
1102
|
* } else {
|
|
1033
1103
|
* console.log('New company created!')
|
|
1034
1104
|
* }
|
|
1035
1105
|
* ```
|
|
1036
1106
|
*/
|
|
1037
1107
|
async onboard(input) {
|
|
1038
|
-
// Step 1: Smart link or create company
|
|
1039
1108
|
let companyId;
|
|
1040
1109
|
let companyName;
|
|
1041
1110
|
let linkStatus;
|
|
1042
|
-
const
|
|
1111
|
+
const existing = await this.companies.get({
|
|
1043
1112
|
externalOrgId: input.externalOrgId,
|
|
1044
|
-
label: input.label,
|
|
1045
|
-
hints: input.hints ?? {},
|
|
1046
1113
|
});
|
|
1047
|
-
if (
|
|
1048
|
-
companyId =
|
|
1049
|
-
companyName =
|
|
1114
|
+
if (existing) {
|
|
1115
|
+
companyId = existing.id;
|
|
1116
|
+
companyName = existing.name;
|
|
1050
1117
|
linkStatus = "already_linked";
|
|
1051
1118
|
}
|
|
1052
|
-
else if (smartLinkResult.status === "linked") {
|
|
1053
|
-
companyId = smartLinkResult.customerId;
|
|
1054
|
-
companyName = smartLinkResult.customerName;
|
|
1055
|
-
linkStatus = "linked";
|
|
1056
|
-
}
|
|
1057
1119
|
else {
|
|
1058
|
-
// No match found - create new company
|
|
1059
1120
|
const newCompany = await this.companies.create({
|
|
1060
1121
|
name: input.hints?.companyName ?? `Company ${input.externalOrgId}`,
|
|
1061
1122
|
domain: input.hints?.domain,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const WEBHOOK_SIGNATURE_HEADER = "X-OS-Webhook-Signature";
|
|
2
|
+
export declare const WEBHOOK_TIMESTAMP_HEADER = "X-OS-Webhook-Timestamp";
|
|
3
|
+
export declare const WEBHOOK_ID_HEADER = "X-OS-Webhook-Id";
|
|
4
|
+
export declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
5
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/webhooks/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,2BAA2B,CAAA;AAChE,eAAO,MAAM,wBAAwB,2BAA2B,CAAA;AAChE,eAAO,MAAM,iBAAiB,oBAAoB,CAAA;AAElD,eAAO,MAAM,iCAAiC,MAAM,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ConstructProductWebhookEventOptions, ProductWebhookHeaders, VerifiedProductWebhookEvent } from './types.js';
|
|
2
|
+
export declare function constructProductWebhookEvent(rawBody: string, headers: ProductWebhookHeaders, secret: string, options?: ConstructProductWebhookEventOptions): VerifiedProductWebhookEvent;
|
|
3
|
+
//# sourceMappingURL=construct-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct-event.d.ts","sourceRoot":"","sources":["../../src/webhooks/construct-event.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,mCAAmC,EAEnC,qBAAqB,EACrB,2BAA2B,EAC5B,MAAM,YAAY,CAAA;AA0DnB,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,mCAAmC,GAC5C,2BAA2B,CAsC7B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DEFAULT_WEBHOOK_TOLERANCE_SECONDS, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, } from './constants.js';
|
|
2
|
+
import { OsWebhookSignatureVerificationError } from './errors.js';
|
|
3
|
+
import { readWebhookHeader } from './read-header.js';
|
|
4
|
+
import { verifyWebhookSignature } from './signing.js';
|
|
5
|
+
function assertNonEmpty(value, message) {
|
|
6
|
+
const trimmed = value?.trim();
|
|
7
|
+
if (!trimmed) {
|
|
8
|
+
throw new OsWebhookSignatureVerificationError(message);
|
|
9
|
+
}
|
|
10
|
+
return trimmed;
|
|
11
|
+
}
|
|
12
|
+
function assertTimestampWithinTolerance(timestamp, tolerance, now) {
|
|
13
|
+
if (tolerance <= 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const timestampMs = Number(timestamp);
|
|
17
|
+
if (!Number.isFinite(timestampMs)) {
|
|
18
|
+
throw new OsWebhookSignatureVerificationError('Invalid webhook timestamp');
|
|
19
|
+
}
|
|
20
|
+
const ageSeconds = Math.abs(now.getTime() - timestampMs) / 1000;
|
|
21
|
+
if (ageSeconds > tolerance) {
|
|
22
|
+
throw new OsWebhookSignatureVerificationError('Webhook timestamp outside the tolerance window');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function parseWebhookPayload(rawBody) {
|
|
26
|
+
try {
|
|
27
|
+
const parsed = JSON.parse(rawBody);
|
|
28
|
+
if (typeof parsed !== 'object' ||
|
|
29
|
+
parsed === null ||
|
|
30
|
+
typeof parsed.type !== 'string' ||
|
|
31
|
+
typeof parsed.action !== 'string' ||
|
|
32
|
+
typeof parsed.idempotency_key !== 'string' ||
|
|
33
|
+
typeof parsed.data !== 'object' ||
|
|
34
|
+
parsed.data === null) {
|
|
35
|
+
throw new OsWebhookSignatureVerificationError('Invalid webhook payload shape');
|
|
36
|
+
}
|
|
37
|
+
return parsed;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof OsWebhookSignatureVerificationError) {
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
throw new OsWebhookSignatureVerificationError('Invalid JSON payload');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function constructProductWebhookEvent(rawBody, headers, secret, options) {
|
|
47
|
+
const signingSecret = secret;
|
|
48
|
+
if (!signingSecret) {
|
|
49
|
+
throw new OsWebhookSignatureVerificationError('Webhook signing secret is required');
|
|
50
|
+
}
|
|
51
|
+
const signature = assertNonEmpty(readWebhookHeader(headers, WEBHOOK_SIGNATURE_HEADER), `Missing ${WEBHOOK_SIGNATURE_HEADER} header`);
|
|
52
|
+
const timestamp = assertNonEmpty(readWebhookHeader(headers, WEBHOOK_TIMESTAMP_HEADER), `Missing ${WEBHOOK_TIMESTAMP_HEADER} header`);
|
|
53
|
+
const webhookId = assertNonEmpty(readWebhookHeader(headers, WEBHOOK_ID_HEADER), `Missing ${WEBHOOK_ID_HEADER} header`);
|
|
54
|
+
assertTimestampWithinTolerance(timestamp, options?.tolerance ?? DEFAULT_WEBHOOK_TOLERANCE_SECONDS, options?.now ?? new Date());
|
|
55
|
+
if (!verifyWebhookSignature(signingSecret, timestamp, rawBody, signature)) {
|
|
56
|
+
throw new OsWebhookSignatureVerificationError('Webhook signature verification failed');
|
|
57
|
+
}
|
|
58
|
+
const event = parseWebhookPayload(rawBody);
|
|
59
|
+
return {
|
|
60
|
+
...event,
|
|
61
|
+
webhookId,
|
|
62
|
+
timestamp,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/webhooks/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,mCAAoC,SAAQ,KAAK;gBAChD,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-test-headers.d.ts","sourceRoot":"","sources":["../../src/webhooks/generate-test-headers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAEjE,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,+BAA+B,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAaxB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, } from './constants.js';
|
|
2
|
+
import { buildWebhookSignature } from './signing.js';
|
|
3
|
+
export function generateTestWebhookHeaders(input) {
|
|
4
|
+
const timestamp = (input.timestamp ?? Date.now()).toString();
|
|
5
|
+
const webhookId = input.webhookId ?? 'test_webhook_id';
|
|
6
|
+
return {
|
|
7
|
+
[WEBHOOK_SIGNATURE_HEADER]: buildWebhookSignature(input.secret, timestamp, input.payload),
|
|
8
|
+
[WEBHOOK_TIMESTAMP_HEADER]: timestamp,
|
|
9
|
+
[WEBHOOK_ID_HEADER]: webhookId,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { constructProductWebhookEvent } from './construct-event.js';
|
|
2
|
+
import { generateTestWebhookHeaders } from './generate-test-headers.js';
|
|
3
|
+
export { DEFAULT_WEBHOOK_TOLERANCE_SECONDS, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, } from './constants.js';
|
|
4
|
+
export { constructProductWebhookEvent } from './construct-event.js';
|
|
5
|
+
export { OsWebhookSignatureVerificationError } from './errors.js';
|
|
6
|
+
export { generateTestWebhookHeaders } from './generate-test-headers.js';
|
|
7
|
+
export { buildWebhookSignature, buildWebhookSignatureMaterial, verifyWebhookSignature, } from './signing.js';
|
|
8
|
+
export type { ConstructProductWebhookEventOptions, GenerateTestWebhookHeadersInput, ProductWebhookEventPayload, ProductWebhookHeaders, VerifiedProductWebhookEvent, } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Verify inbound OS product webhooks.
|
|
11
|
+
*/
|
|
12
|
+
export declare const webhooks: {
|
|
13
|
+
constructEvent: typeof constructProductWebhookEvent;
|
|
14
|
+
generateTestHeaders: typeof generateTestWebhookHeaders;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webhooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AAEvE,OAAO,EACL,iCAAiC,EACjC,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,EAAE,mCAAmC,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,mCAAmC,EACnC,+BAA+B,EAC/B,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,YAAY,CAAA;AAEnB;;GAEG;AACH,eAAO,MAAM,QAAQ;;;CAGpB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { constructProductWebhookEvent } from './construct-event.js';
|
|
2
|
+
import { generateTestWebhookHeaders } from './generate-test-headers.js';
|
|
3
|
+
export { DEFAULT_WEBHOOK_TOLERANCE_SECONDS, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, } from './constants.js';
|
|
4
|
+
export { constructProductWebhookEvent } from './construct-event.js';
|
|
5
|
+
export { OsWebhookSignatureVerificationError } from './errors.js';
|
|
6
|
+
export { generateTestWebhookHeaders } from './generate-test-headers.js';
|
|
7
|
+
export { buildWebhookSignature, buildWebhookSignatureMaterial, verifyWebhookSignature, } from './signing.js';
|
|
8
|
+
/**
|
|
9
|
+
* Verify inbound OS product webhooks.
|
|
10
|
+
*/
|
|
11
|
+
export const webhooks = {
|
|
12
|
+
constructEvent: constructProductWebhookEvent,
|
|
13
|
+
generateTestHeaders: generateTestWebhookHeaders,
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-header.d.ts","sourceRoot":"","sources":["../../src/webhooks/read-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAoBf"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function readWebhookHeader(headers, name) {
|
|
2
|
+
if (headers instanceof Headers) {
|
|
3
|
+
return headers.get(name);
|
|
4
|
+
}
|
|
5
|
+
const lowerName = name.toLowerCase();
|
|
6
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
7
|
+
if (key.toLowerCase() !== lowerName || value == null) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
return value[0] ?? null;
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function buildWebhookSignatureMaterial(timestamp: string, rawBody: string): string;
|
|
2
|
+
export declare function buildWebhookSignature(secret: string, timestamp: string, rawBody: string): string;
|
|
3
|
+
export declare function verifyWebhookSignature(secret: string, timestamp: string, rawBody: string, signature: string): boolean;
|
|
4
|
+
//# sourceMappingURL=signing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../src/webhooks/signing.ts"],"names":[],"mappings":"AAEA,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,MAAM,CAIR;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAWT"}
|