@raideno/convex-stripe 0.1.6 → 0.1.8

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.
@@ -11,12 +11,10 @@ export interface ReturnPayload<T> {
11
11
  exp: number;
12
12
  targetUrl: string;
13
13
  }
14
- export declare const DEFAULT_TTL_MS: number;
15
- export declare function buildSignedReturnUrl<O extends ReturnOrigin>({ configuration, origin, targetUrl, ttlMs, data, }: {
14
+ export declare function buildSignedReturnUrl<O extends ReturnOrigin>({ configuration, origin, targetUrl, data, }: {
16
15
  configuration: InternalConfiguration;
17
16
  origin: O;
18
17
  targetUrl: string;
19
- ttlMs?: number;
20
18
  data: ReturnDataMap[O];
21
19
  }): Promise<string>;
22
20
  export declare function decodeSignedPayload<O extends ReturnOrigin>({ secret, data, signature, }: {
@@ -6,13 +6,14 @@ export interface InternalConfiguration {
6
6
  secret_key: string;
7
7
  webhook_secret: string;
8
8
  };
9
+ redirectTtlMs: number;
9
10
  sync: Partial<Record<keyof typeof stripeTables, boolean>>;
10
11
  debug: boolean;
11
12
  logger: Logger;
12
13
  base: string;
13
14
  }
14
15
  export type WithOptional<T, K extends keyof T = never> = Omit<T, K> & Partial<Pick<T, K>>;
15
- export type InputConfiguration = WithOptional<InternalConfiguration, "base" | "debug" | "logger" | "sync">;
16
+ export type InputConfiguration = WithOptional<InternalConfiguration, "base" | "debug" | "logger" | "sync" | "redirectTtlMs">;
16
17
  export type ArgSchema = Record<string, Validator<any, "optional" | "required", any>>;
17
18
  export type InferArgs<S extends ArgSchema> = {
18
19
  [K in keyof S as S[K] extends Validator<any, "required", any> ? K : never]: Infer<S[K]>;
package/dist/server.js CHANGED
@@ -2234,6 +2234,7 @@ class Logger {
2234
2234
  const normalizeConfiguration = (config) => {
2235
2235
  return {
2236
2236
  ...config,
2237
+ redirectTtlMs: 15 * 60 * 1e3,
2237
2238
  sync: {
2238
2239
  stripe_coupons: true,
2239
2240
  stripe_customers: true,
@@ -2413,9 +2414,9 @@ const SetupImplementation = defineActionImplementation({
2413
2414
  context,
2414
2415
  configuration
2415
2416
  );
2416
- let customerId = stripeCustomer?.doc.customerId || null;
2417
+ let customerId = stripeCustomer?.doc?.customerId || null;
2417
2418
  if (customerId) {
2418
- return { customerId: stripeCustomer.doc.stripe.id };
2419
+ return { customerId };
2419
2420
  } else {
2420
2421
  const customer = await stripe.customers.create({
2421
2422
  email: args.email ? args.email : void 0,
@@ -2669,19 +2670,17 @@ async function timingSafeEqual(a, b) {
2669
2670
  }
2670
2671
  return result === 0;
2671
2672
  }
2672
- const DEFAULT_TTL_MS = 15 * 60 * 1e3;
2673
2673
  async function buildSignedReturnUrl({
2674
2674
  configuration,
2675
2675
  origin,
2676
2676
  targetUrl,
2677
- ttlMs = DEFAULT_TTL_MS,
2678
2677
  data
2679
2678
  }) {
2680
2679
  const payload = {
2681
2680
  origin,
2682
2681
  data,
2683
2682
  targetUrl,
2684
- exp: Date.now() + ttlMs
2683
+ exp: Date.now() + configuration.redirectTtlMs
2685
2684
  };
2686
2685
  const data_ = toBase64Url(JSON.stringify(payload));
2687
2686
  const expected = await signData(configuration.stripe.webhook_secret, data_);
@@ -2759,13 +2758,18 @@ const buildRedirectImplementation = (configuration) => httpActionGeneric(async (
2759
2758
  }
2760
2759
  for (const handler of REDIRECT_HANDLERS) {
2761
2760
  if (handler.origins.includes(origin)) {
2762
- await handler.handle(
2763
- origin,
2764
- context,
2765
- // TODO: fix the any
2766
- decoded.data,
2767
- configuration
2768
- );
2761
+ try {
2762
+ await handler.handle(
2763
+ origin,
2764
+ context,
2765
+ decoded.data,
2766
+ configuration
2767
+ );
2768
+ } catch (error) {
2769
+ configuration.logger.error(
2770
+ `[STRIPE RETURN ${origin}](Error): ${error}`
2771
+ );
2772
+ }
2769
2773
  return new Response(null, {
2770
2774
  status: 302,
2771
2775
  headers: { Location: decoded.targetUrl }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raideno/convex-stripe",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Easy stripe billing for convex apps.",
5
5
  "keywords": [
6
6
  "billing",
@@ -53,6 +53,7 @@
53
53
  "typescript": "^5.9.2",
54
54
  "typescript-eslint": "^8.41.0",
55
55
  "vite": "^7.1.5",
56
+ "vite-plugin-compile-time": "^0.4.6",
56
57
  "vite-plugin-dts": "^4.5.4",
57
58
  "vite-tsconfig-paths": "^5.1.4"
58
59
  }