@odla-ai/chapter 0.31.2 → 0.31.3
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/index.cjs +11 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -20
- package/dist/index.d.ts +4 -20
- package/dist/index.js +9 -55
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +10 -56
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.js +10 -56
- package/dist/worker/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CrmConfig, Crm, FieldConditions, TypeDef, FieldDef, TypeSummary, CrmRecord } from '@odla-ai/crm';
|
|
2
|
+
import { StripeRequestResult } from '@odla-ai/stripe';
|
|
3
|
+
export { stripeForm, verifyStripeSignature } from '@odla-ai/stripe';
|
|
2
4
|
|
|
3
5
|
/** One membership tier a chapter offers. `priceCents: 0` means free. */
|
|
4
6
|
interface ChapterTier {
|
|
@@ -979,17 +981,6 @@ declare function canBook(status: string, p: ResolvedPipeline): boolean;
|
|
|
979
981
|
/** May an application be approved (→ member) from this status? */
|
|
980
982
|
declare function canApprove(status: string, p: ResolvedPipeline): boolean;
|
|
981
983
|
|
|
982
|
-
/**
|
|
983
|
-
* Verify a Stripe webhook signature (C3): HMAC-SHA256 over `` `${t}.${payload}` ``
|
|
984
|
-
* with the endpoint signing secret, a replay window (default 5 minutes), and a
|
|
985
|
-
* constant-time compare. Package-enforced — never left to a site. Returns `false`
|
|
986
|
-
* (never throws) on a malformed header, a non-numeric or stale timestamp, or a
|
|
987
|
-
* signature mismatch. `now`/`toleranceSec` are injectable for tests.
|
|
988
|
-
*/
|
|
989
|
-
declare function verifyStripeSignature(payload: string, header: string, secret: string, opts?: {
|
|
990
|
-
now?: number;
|
|
991
|
-
toleranceSec?: number;
|
|
992
|
-
}): Promise<boolean>;
|
|
993
984
|
/** A group row's payment configuration, as far as readiness cares. */
|
|
994
985
|
interface PaymentsGroup {
|
|
995
986
|
stripePublishableKey?: string | null;
|
|
@@ -999,9 +990,6 @@ interface PaymentsGroup {
|
|
|
999
990
|
* group row) AND a secret key (the vault). Anything missing drops the join
|
|
1000
991
|
* flow's payment step (paymentsReady:false) rather than half-charging. */
|
|
1001
992
|
declare function paymentsReady(group: PaymentsGroup, hasSecretKey: boolean): boolean;
|
|
1002
|
-
/** Form-encode params for Stripe's x-www-form-urlencoded API, expanding one level
|
|
1003
|
-
* of nested objects into bracket syntax (`metadata[applicationId]=...`). */
|
|
1004
|
-
declare function stripeForm(params: Record<string, unknown>): string;
|
|
1005
993
|
/** The Stripe idempotency key for creating an application's subscription — one
|
|
1006
994
|
* per application, so a client retry can't orphan a second subscription. */
|
|
1007
995
|
declare function subscriptionIdempotencyKey(applicationId: string): string;
|
|
@@ -1400,11 +1388,7 @@ declare function dashboardMetricData(points: Array<{
|
|
|
1400
1388
|
declare function subAnnualCents(sub: Record<string, unknown>): number;
|
|
1401
1389
|
|
|
1402
1390
|
/** The result of a Stripe Backend API call: ok + status + parsed JSON body. */
|
|
1403
|
-
type StripeResult =
|
|
1404
|
-
ok: boolean;
|
|
1405
|
-
status: number;
|
|
1406
|
-
body: Record<string, unknown>;
|
|
1407
|
-
};
|
|
1391
|
+
type StripeResult = StripeRequestResult<Record<string, unknown>>;
|
|
1408
1392
|
/** Call the Stripe Backend API (form-encoded, Bearer sk_). Exposed so the admin
|
|
1409
1393
|
* billing/dashboard reads and the refund route share one Stripe client instead
|
|
1410
1394
|
* of each re-deriving the auth + encoding. */
|
|
@@ -1863,4 +1847,4 @@ declare function loadTiers(db: ChapterDb, group: TierGroupRow): Promise<ChapterT
|
|
|
1863
1847
|
/** The tiers a join page may show: active, and joinable as configured. */
|
|
1864
1848
|
declare function loadOfferableTiers(db: ChapterDb, group: TierGroupRow, hasSecretKey: boolean): Promise<ChapterTier[]>;
|
|
1865
1849
|
|
|
1866
|
-
export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall,
|
|
1850
|
+
export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateScheduling, webhookMutationId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CrmConfig, Crm, FieldConditions, TypeDef, FieldDef, TypeSummary, CrmRecord } from '@odla-ai/crm';
|
|
2
|
+
import { StripeRequestResult } from '@odla-ai/stripe';
|
|
3
|
+
export { stripeForm, verifyStripeSignature } from '@odla-ai/stripe';
|
|
2
4
|
|
|
3
5
|
/** One membership tier a chapter offers. `priceCents: 0` means free. */
|
|
4
6
|
interface ChapterTier {
|
|
@@ -979,17 +981,6 @@ declare function canBook(status: string, p: ResolvedPipeline): boolean;
|
|
|
979
981
|
/** May an application be approved (→ member) from this status? */
|
|
980
982
|
declare function canApprove(status: string, p: ResolvedPipeline): boolean;
|
|
981
983
|
|
|
982
|
-
/**
|
|
983
|
-
* Verify a Stripe webhook signature (C3): HMAC-SHA256 over `` `${t}.${payload}` ``
|
|
984
|
-
* with the endpoint signing secret, a replay window (default 5 minutes), and a
|
|
985
|
-
* constant-time compare. Package-enforced — never left to a site. Returns `false`
|
|
986
|
-
* (never throws) on a malformed header, a non-numeric or stale timestamp, or a
|
|
987
|
-
* signature mismatch. `now`/`toleranceSec` are injectable for tests.
|
|
988
|
-
*/
|
|
989
|
-
declare function verifyStripeSignature(payload: string, header: string, secret: string, opts?: {
|
|
990
|
-
now?: number;
|
|
991
|
-
toleranceSec?: number;
|
|
992
|
-
}): Promise<boolean>;
|
|
993
984
|
/** A group row's payment configuration, as far as readiness cares. */
|
|
994
985
|
interface PaymentsGroup {
|
|
995
986
|
stripePublishableKey?: string | null;
|
|
@@ -999,9 +990,6 @@ interface PaymentsGroup {
|
|
|
999
990
|
* group row) AND a secret key (the vault). Anything missing drops the join
|
|
1000
991
|
* flow's payment step (paymentsReady:false) rather than half-charging. */
|
|
1001
992
|
declare function paymentsReady(group: PaymentsGroup, hasSecretKey: boolean): boolean;
|
|
1002
|
-
/** Form-encode params for Stripe's x-www-form-urlencoded API, expanding one level
|
|
1003
|
-
* of nested objects into bracket syntax (`metadata[applicationId]=...`). */
|
|
1004
|
-
declare function stripeForm(params: Record<string, unknown>): string;
|
|
1005
993
|
/** The Stripe idempotency key for creating an application's subscription — one
|
|
1006
994
|
* per application, so a client retry can't orphan a second subscription. */
|
|
1007
995
|
declare function subscriptionIdempotencyKey(applicationId: string): string;
|
|
@@ -1400,11 +1388,7 @@ declare function dashboardMetricData(points: Array<{
|
|
|
1400
1388
|
declare function subAnnualCents(sub: Record<string, unknown>): number;
|
|
1401
1389
|
|
|
1402
1390
|
/** The result of a Stripe Backend API call: ok + status + parsed JSON body. */
|
|
1403
|
-
type StripeResult =
|
|
1404
|
-
ok: boolean;
|
|
1405
|
-
status: number;
|
|
1406
|
-
body: Record<string, unknown>;
|
|
1407
|
-
};
|
|
1391
|
+
type StripeResult = StripeRequestResult<Record<string, unknown>>;
|
|
1408
1392
|
/** Call the Stripe Backend API (form-encoded, Bearer sk_). Exposed so the admin
|
|
1409
1393
|
* billing/dashboard reads and the refund route share one Stripe client instead
|
|
1410
1394
|
* of each re-deriving the auth + encoding. */
|
|
@@ -1863,4 +1847,4 @@ declare function loadTiers(db: ChapterDb, group: TierGroupRow): Promise<ChapterT
|
|
|
1863
1847
|
/** The tiers a join page may show: active, and joinable as configured. */
|
|
1864
1848
|
declare function loadOfferableTiers(db: ChapterDb, group: TierGroupRow, hasSecretKey: boolean): Promise<ChapterTier[]>;
|
|
1865
1849
|
|
|
1866
|
-
export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall,
|
|
1850
|
+
export { type AccountModel, type AdminNotificationTrigger, type Applicant, type ApplicationBookingPatch, type ApplicationRecord, type ApplicationSummary, type Attr, type AttrType, type Chapter, type ChapterApplication, type ChapterAuth, type ChapterBrand, type ChapterConfig, type ChapterCopy, type ChapterCopyInput, type ChapterDb, type ChapterEmails, type ChapterIntegrationDescriptor, type ChapterIntegrationOptions, type ChapterMode, type ChapterNetwork, type ChapterNetworkReader, type ChapterNetworkTarget, type ChapterOperations, type ChapterPipeline, type ChapterPolicy, type ChapterPrices, type ChapterRunbookHints, type ChapterScheduling, type ChapterSends, type ChapterTier, type ChapterTierConfig, type ClerkInviteInput, type ClerkMetadataInput, type ClerkResult, type ClerkUserInput, type ClerkUserRecord, type CompiledChapterBrandTokens, DEFAULT_CHAPTER_COPY, DEFAULT_SHARE_FIELDS, type DashboardMetricData, type DashboardMetricSeries, type DbOp, type DbRules, type DbSchema, type DeliveryDecision, type EmailGroup, type EmailTemplate, type EmailTemplateRow, type Entity, type ExistingMeeting, type GuardResult, type IntegrationDescriptor, type IntegrationProvision, type IntegrationSecret, type IntegrationSetting, type IntegrationSync, type JoinConfigGroup, type JoinConfigTier, type LeaderCrmOptions, type LeaderFormationConfig, type LiveEvent, type MailSender, type MeetingForReconcile, type MeetingRecord, type MeetingReschedulePatch, type MemberApplication, type MemberSession, type NetworkRecord, type NetworkRecordNote, type NetworkRecordPage, type NetworkRollup, type NetworkRollupTarget, type NetworkSharedNote, type NetworkSnapshot, type NewMeetingRow, type NotifyDeps, type NotifyInput, type NotifyResult, type PaymentsGroup, type ProjectionDeps, type ReconcileDecision, type ResolvedApplication, type ResolvedAuth, type ResolvedLeaderFormation, type ResolvedNetwork, type ResolvedNetworkReader, type ResolvedNetworkTarget, type ResolvedOperations, type ResolvedPipeline, type ResolvedScheduling, type ResolvedSends, type RoleChangeContext, type Rule, SCHEDULING_DEFAULTS, type SchedulingErrors, type SecretMode, type SecretStore, type SessionUser, type SharedBusiness, type SharedPerson, type SharedRecord, type SharedRecordV1, type SharedRecordV2, type StripeEvent, type StripeResult, type SubmitResult, type TierGroup, type TierGroupRow, type WebhookEvent, applicantProfile, applicationBookingUpdate, applicationSummary, backfillCrm, bookingDecision, brandTokens, bucketSeries, buildGroupSeed, buildTierSeeds, canApprove, canBook, canChangeRole, canTransition, canceledPatch, chapterBrandFromTokens, chapterDb, clampArray, clerkGetUser, clerkGetUserByEmail, clerkIntegration, clerkInviteRequest, clerkListUsers, clerkSetRole, clerkUserRequest, createChapterIntegration, createClerkInvitation, createClerkUser, dashboardMetricData, defaultCrm, defineChapter, emailGroupFrom, endForSlot, findApplicationRef, findTier, firstPaymentPatch, formatChapterCopy, formationFields, getVaultSecret, hasDisclaimerAck, introIdempotencyKey, isAdminRole, isAlreadySent, isReconcilable, isSlotAvailable, isValidEmail, joinConfig, joinConfigTiers, leaderCrmConfig, loadOfferableTiers, loadTiers, meetingCreateRow, meetingRescheduleUpdate, memberApplication, memberSession, networkSourceTag, normalizeSharedRecord, normalizeWebhookEvent, offerableTiers, paymentsReady, personInputFromApp, planDelivery, projectApplicant, projectSharedRecord, reconcileMeetings, refundedPatch, render, renderSummary, renderTemplateBody, renewalPatch, resolveApplication, resolveAuth, resolveChapterCopy, resolveLeaderFormation, resolvePipeline, resolveScheduling, resolveTiers, roleFromClaim, sendTemplated, sharedPersonInput, sharedRecordFromCrm, slotWindow, stageIndex, stripeCall, subAnnualCents, submitApplication, subscriptionIdempotencyKey, syncApplicationToCrm, tierIsFree, tierPayable, updateClerkUserMetadata, updateClerkUserMetadataByEmail, validateScheduling, webhookMutationId };
|
package/dist/index.js
CHANGED
|
@@ -1557,53 +1557,10 @@ function emailGroupFrom(row) {
|
|
|
1557
1557
|
}
|
|
1558
1558
|
|
|
1559
1559
|
// src/payments.ts
|
|
1560
|
-
|
|
1561
|
-
const parts = {};
|
|
1562
|
-
for (const p of header.split(",")) {
|
|
1563
|
-
const [k, v] = p.split("=", 2);
|
|
1564
|
-
if (k && v !== void 0) parts[k] = v;
|
|
1565
|
-
}
|
|
1566
|
-
return { t: parts.t, v1: parts.v1 };
|
|
1567
|
-
}
|
|
1568
|
-
function toHex(buf) {
|
|
1569
|
-
return [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1570
|
-
}
|
|
1571
|
-
function timingSafeEqual(a, b) {
|
|
1572
|
-
if (a.length !== b.length) return false;
|
|
1573
|
-
let diff = 0;
|
|
1574
|
-
for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
1575
|
-
return diff === 0;
|
|
1576
|
-
}
|
|
1577
|
-
async function verifyStripeSignature(payload, header, secret, opts = {}) {
|
|
1578
|
-
const { t, v1 } = parseSigHeader(header);
|
|
1579
|
-
if (!t || !v1) return false;
|
|
1580
|
-
const ts = Number(t);
|
|
1581
|
-
if (!Number.isFinite(ts)) return false;
|
|
1582
|
-
const nowSec = (opts.now ?? Date.now()) / 1e3;
|
|
1583
|
-
const tolerance = opts.toleranceSec ?? 300;
|
|
1584
|
-
if (Math.abs(nowSec - ts) > tolerance) return false;
|
|
1585
|
-
const enc = new TextEncoder();
|
|
1586
|
-
const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
1587
|
-
const mac = await crypto.subtle.sign("HMAC", key, enc.encode(`${t}.${payload}`));
|
|
1588
|
-
return timingSafeEqual(toHex(mac), v1);
|
|
1589
|
-
}
|
|
1560
|
+
import { stripeForm, verifyStripeSignature } from "@odla-ai/stripe";
|
|
1590
1561
|
function paymentsReady(group, hasSecretKey) {
|
|
1591
1562
|
return Boolean(group.stripePublishableKey && group.stripePriceId && hasSecretKey);
|
|
1592
1563
|
}
|
|
1593
|
-
function stripeForm(params) {
|
|
1594
|
-
const out = new URLSearchParams();
|
|
1595
|
-
for (const [k, v] of Object.entries(params)) {
|
|
1596
|
-
if (v === void 0 || v === null) continue;
|
|
1597
|
-
if (typeof v === "object") {
|
|
1598
|
-
for (const [k2, v2] of Object.entries(v)) {
|
|
1599
|
-
if (v2 !== void 0 && v2 !== null) out.append(`${k}[${k2}]`, String(v2));
|
|
1600
|
-
}
|
|
1601
|
-
} else {
|
|
1602
|
-
out.append(k, String(v));
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
return out.toString();
|
|
1606
|
-
}
|
|
1607
1564
|
function subscriptionIdempotencyKey(applicationId) {
|
|
1608
1565
|
return `sub:${applicationId}`;
|
|
1609
1566
|
}
|
|
@@ -1992,18 +1949,15 @@ function subAnnualCents(sub) {
|
|
|
1992
1949
|
}
|
|
1993
1950
|
|
|
1994
1951
|
// src/payments-stripe.ts
|
|
1952
|
+
import { stripeRequest, verifyStripeSignature as verifyStripeSignature2 } from "@odla-ai/stripe";
|
|
1995
1953
|
async function stripeCall(sk, method, path, params, idempotencyKey) {
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
}
|
|
2004
|
-
const res = await fetch(`https://api.stripe.com${path}${qs}`, init);
|
|
2005
|
-
const body = await res.json().catch(() => ({}));
|
|
2006
|
-
return { ok: res.ok, status: res.status, body };
|
|
1954
|
+
return stripeRequest(
|
|
1955
|
+
{ secretKey: sk },
|
|
1956
|
+
method,
|
|
1957
|
+
path,
|
|
1958
|
+
params,
|
|
1959
|
+
idempotencyKey ? { idempotencyKey } : {}
|
|
1960
|
+
);
|
|
2007
1961
|
}
|
|
2008
1962
|
|
|
2009
1963
|
// src/clerk.ts
|