@cimplify/sdk 0.106.1 → 0.106.2
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/advanced.js +20 -20
- package/dist/advanced.mjs +1 -1
- package/dist/{chunk-IWXVKW22.mjs → chunk-4VTFTLH7.mjs} +1 -1
- package/dist/{chunk-LJSQ7TUV.js → chunk-7O2BBPDM.js} +2 -2
- package/dist/{chunk-SFG2LMRD.js → chunk-B7JH5D3J.js} +36 -34
- package/dist/{chunk-QKL5L5IU.js → chunk-BCLGREHS.js} +87 -87
- package/dist/{chunk-ABAK4YVY.mjs → chunk-LJAZ7H4I.mjs} +1 -1
- package/dist/{chunk-YHR6LFQ7.mjs → chunk-T3MXI7JD.mjs} +36 -34
- package/dist/index.js +67 -67
- package/dist/index.mjs +3 -3
- package/dist/react.js +31 -31
- package/dist/react.mjs +2 -2
- package/dist/server.js +7 -7
- package/dist/server.mjs +2 -2
- package/dist/testing/suite.js +23 -23
- package/dist/testing/suite.mjs +3 -3
- package/dist/testing.js +115 -115
- package/dist/testing.mjs +4 -4
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBCLGREHS_js = require('./chunk-BCLGREHS.js');
|
|
4
4
|
require('./chunk-XREIZ56K.js');
|
|
5
|
-
var
|
|
5
|
+
var chunkB7JH5D3J_js = require('./chunk-B7JH5D3J.js');
|
|
6
6
|
require('./chunk-EV2EVOYS.js');
|
|
7
7
|
require('./chunk-UYFTOIFW.js');
|
|
8
8
|
var chunkAVXA4F6G_js = require('./chunk-AVXA4F6G.js');
|
|
@@ -28,7 +28,7 @@ function readEnv(...keys) {
|
|
|
28
28
|
var getServerClient = react.cache((opts = {}) => {
|
|
29
29
|
const baseUrl = opts.apiUrl ?? readEnv("CIMPLIFY_API_URL", "NEXT_PUBLIC_CIMPLIFY_API_URL") ?? defaultBaseUrl();
|
|
30
30
|
const publicKey = opts.secretKey ?? readEnv("CIMPLIFY_SECRET_KEY", "NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY") ?? "mock-dev";
|
|
31
|
-
const client =
|
|
31
|
+
const client = chunkBCLGREHS_js.createCimplifyClient({
|
|
32
32
|
baseUrl,
|
|
33
33
|
publicKey,
|
|
34
34
|
suppressPublicKeyWarning: true
|
|
@@ -252,7 +252,7 @@ var QUERY_AUTH_ERROR = "cimplify_auth_error";
|
|
|
252
252
|
var discoveryCache = /* @__PURE__ */ new Map();
|
|
253
253
|
var jwksCache = /* @__PURE__ */ new Map();
|
|
254
254
|
function issuerBase(cfg) {
|
|
255
|
-
return (cfg.issuer ?? cfg.authUrl ??
|
|
255
|
+
return (cfg.issuer ?? cfg.authUrl ?? chunkB7JH5D3J_js.DEFAULT_ISSUER).replace(/\/$/, "");
|
|
256
256
|
}
|
|
257
257
|
function cookieName(cfg) {
|
|
258
258
|
return cfg.cookieName ?? SESSION_COOKIE;
|
|
@@ -467,12 +467,12 @@ async function handleOidcCallback(req, opts) {
|
|
|
467
467
|
}
|
|
468
468
|
function readPkceCookie(cookieHeader) {
|
|
469
469
|
if (!cookieHeader) return null;
|
|
470
|
-
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${
|
|
470
|
+
const match = cookieHeader.split(/;\s*/).find((p) => p.startsWith(`${chunkB7JH5D3J_js.PKCE_COOKIE}=`));
|
|
471
471
|
if (!match) return null;
|
|
472
|
-
return
|
|
472
|
+
return chunkB7JH5D3J_js.decodePkceState(match.slice(chunkB7JH5D3J_js.PKCE_COOKIE.length + 1));
|
|
473
473
|
}
|
|
474
474
|
function buildPkceClearCookie() {
|
|
475
|
-
return `${
|
|
475
|
+
return `${chunkB7JH5D3J_js.PKCE_COOKIE}=; Path=${chunkB7JH5D3J_js.PKCE_COOKIE_PATH}; Max-Age=0; Secure; SameSite=Lax`;
|
|
476
476
|
}
|
|
477
477
|
function safeReturnPath(returnTo, fallback) {
|
|
478
478
|
if (returnTo && returnTo.startsWith("/") && !returnTo.startsWith("//")) return returnTo;
|
package/dist/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createCimplifyClient } from './chunk-
|
|
1
|
+
import { createCimplifyClient } from './chunk-LJAZ7H4I.mjs';
|
|
2
2
|
import './chunk-U4MW6PYU.mjs';
|
|
3
|
-
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-
|
|
3
|
+
import { PKCE_COOKIE, decodePkceState, PKCE_COOKIE_PATH, DEFAULT_ISSUER } from './chunk-T3MXI7JD.mjs';
|
|
4
4
|
import './chunk-33VCYWVL.mjs';
|
|
5
5
|
import './chunk-NYDVVNZI.mjs';
|
|
6
6
|
export { CimplifyError } from './chunk-NJYR6GGM.mjs';
|
package/dist/testing/suite.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk7O2BBPDM_js = require('../chunk-7O2BBPDM.js');
|
|
4
4
|
require('../chunk-NJK3THWT.js');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-BCLGREHS.js');
|
|
6
6
|
require('../chunk-XREIZ56K.js');
|
|
7
|
-
require('../chunk-
|
|
7
|
+
require('../chunk-B7JH5D3J.js');
|
|
8
8
|
require('../chunk-EV2EVOYS.js');
|
|
9
9
|
require('../chunk-UYFTOIFW.js');
|
|
10
10
|
require('../chunk-AVXA4F6G.js');
|
|
@@ -22,11 +22,11 @@ var PLACEHOLDER_PHRASES = [
|
|
|
22
22
|
function createBrandSuite(opts) {
|
|
23
23
|
vitest.describe(opts.label ?? "brand schema", () => {
|
|
24
24
|
vitest.it("conforms to the Cimplify brand contract", () => {
|
|
25
|
-
vitest.expect(() =>
|
|
25
|
+
vitest.expect(() => chunk7O2BBPDM_js.assertBrand(opts.brand)).not.toThrow();
|
|
26
26
|
});
|
|
27
27
|
vitest.it("declares a known mock seed", () => {
|
|
28
28
|
const b = opts.brand;
|
|
29
|
-
vitest.expect(
|
|
29
|
+
vitest.expect(chunk7O2BBPDM_js.SeedNameSchema.safeParse(b.mock?.seed).success).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
vitest.it("has no placeholder copy left in", () => {
|
|
32
32
|
const offenders = [];
|
|
@@ -58,7 +58,7 @@ ${msg}`);
|
|
|
58
58
|
vitest.expect(b.mock?.businessId).toMatch(/^bus_/);
|
|
59
59
|
});
|
|
60
60
|
vitest.it("zod-parses cleanly", () => {
|
|
61
|
-
const result =
|
|
61
|
+
const result = chunk7O2BBPDM_js.BrandSchema.safeParse(opts.brand);
|
|
62
62
|
if (!result.success) {
|
|
63
63
|
throw new Error(
|
|
64
64
|
"Brand schema violations:\n" + result.error.issues.map((i) => ` \u2022 brand.${i.path.join(".")}: ${i.message}`).join("\n")
|
|
@@ -73,23 +73,23 @@ function createCartFlowSuite(opts = {}) {
|
|
|
73
73
|
vitest.describe(opts.label ?? "cart flow against in-process mock", () => {
|
|
74
74
|
let h;
|
|
75
75
|
vitest.beforeEach(() => {
|
|
76
|
-
h =
|
|
76
|
+
h = chunk7O2BBPDM_js.createTestClient(opts);
|
|
77
77
|
});
|
|
78
78
|
vitest.afterEach(() => h.dispose());
|
|
79
79
|
vitest.it("starts with an empty cart matching the canonical shape", async () => {
|
|
80
80
|
const res = await h.client.cart.get();
|
|
81
81
|
vitest.expect(res.ok).toBe(true);
|
|
82
82
|
if (!res.ok) return;
|
|
83
|
-
vitest.expect(() =>
|
|
83
|
+
vitest.expect(() => chunk7O2BBPDM_js.assertCart(res.value)).not.toThrow();
|
|
84
84
|
vitest.expect(res.value.items).toHaveLength(0);
|
|
85
85
|
});
|
|
86
86
|
vitest.it("adds the first product, persists it, and returns a shape-valid cart", async () => {
|
|
87
|
-
const { product, variantId } = await
|
|
87
|
+
const { product, variantId } = await chunk7O2BBPDM_js.fixtures.addFirstProduct(h.client);
|
|
88
88
|
vitest.expect(product.id).toBeTruthy();
|
|
89
89
|
const get = await h.client.cart.get();
|
|
90
90
|
vitest.expect(get.ok).toBe(true);
|
|
91
91
|
if (!get.ok) return;
|
|
92
|
-
vitest.expect(() =>
|
|
92
|
+
vitest.expect(() => chunk7O2BBPDM_js.assertCart(get.value)).not.toThrow();
|
|
93
93
|
vitest.expect(get.value.items).toHaveLength(1);
|
|
94
94
|
vitest.expect(get.value.items[0]?.item_id).toBe(product.id);
|
|
95
95
|
if (variantId) {
|
|
@@ -100,8 +100,8 @@ function createCartFlowSuite(opts = {}) {
|
|
|
100
100
|
vitest.expect(parseFloat(String(get.value.pricing.subtotal))).toBeGreaterThan(0);
|
|
101
101
|
});
|
|
102
102
|
vitest.it("dedupes by line_key when adding the same product twice", async () => {
|
|
103
|
-
await
|
|
104
|
-
await
|
|
103
|
+
await chunk7O2BBPDM_js.fixtures.addFirstProduct(h.client);
|
|
104
|
+
await chunk7O2BBPDM_js.fixtures.addFirstProduct(h.client);
|
|
105
105
|
const res = await h.client.cart.get();
|
|
106
106
|
vitest.expect(res.ok).toBe(true);
|
|
107
107
|
if (!res.ok) return;
|
|
@@ -109,7 +109,7 @@ function createCartFlowSuite(opts = {}) {
|
|
|
109
109
|
vitest.expect(res.value.items[0]?.quantity).toBe(2);
|
|
110
110
|
});
|
|
111
111
|
vitest.it("removes items and zeroes the subtotal", async () => {
|
|
112
|
-
await
|
|
112
|
+
await chunk7O2BBPDM_js.fixtures.addFirstProduct(h.client);
|
|
113
113
|
const before = await h.client.cart.get();
|
|
114
114
|
if (!before.ok) throw before.error;
|
|
115
115
|
const itemId = before.value.items[0]?.id;
|
|
@@ -135,28 +135,28 @@ function createContractSuite(opts = {}) {
|
|
|
135
135
|
vitest.describe(opts.label ?? "SDK \u2194 mock contract", () => {
|
|
136
136
|
let h;
|
|
137
137
|
vitest.beforeEach(() => {
|
|
138
|
-
h =
|
|
138
|
+
h = chunk7O2BBPDM_js.createTestClient(opts);
|
|
139
139
|
});
|
|
140
140
|
vitest.afterEach(() => h.dispose());
|
|
141
141
|
vitest.it("AddItemPayload schema accepts a minimal valid body", () => {
|
|
142
|
-
const result =
|
|
142
|
+
const result = chunk7O2BBPDM_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: 1 });
|
|
143
143
|
vitest.expect(result.success).toBe(true);
|
|
144
144
|
});
|
|
145
145
|
vitest.it("AddItemPayload schema rejects negative quantity", () => {
|
|
146
|
-
const result =
|
|
146
|
+
const result = chunk7O2BBPDM_js.AddItemPayloadSchema.safeParse({ item_id: "prod_x", quantity: -1 });
|
|
147
147
|
vitest.expect(result.success).toBe(false);
|
|
148
148
|
});
|
|
149
149
|
vitest.it("AddItemPayload schema rejects empty item_id", () => {
|
|
150
|
-
const result =
|
|
150
|
+
const result = chunk7O2BBPDM_js.AddItemPayloadSchema.safeParse({ item_id: "", quantity: 1 });
|
|
151
151
|
vitest.expect(result.success).toBe(false);
|
|
152
152
|
});
|
|
153
153
|
vitest.it("Cart line items returned by the mock match CartItemSchema", async () => {
|
|
154
|
-
const { product } = await
|
|
154
|
+
const { product } = await chunk7O2BBPDM_js.fixtures.addFirstProduct(h.client);
|
|
155
155
|
const get = await h.client.cart.get();
|
|
156
156
|
if (!get.ok) throw get.error;
|
|
157
157
|
vitest.expect(get.value.items.length).toBeGreaterThan(0);
|
|
158
158
|
for (const item of get.value.items) {
|
|
159
|
-
const result =
|
|
159
|
+
const result = chunk7O2BBPDM_js.CartItemSchema.safeParse(item);
|
|
160
160
|
if (!result.success) {
|
|
161
161
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
162
162
|
throw new Error(`Cart item shape mismatch for ${product.name}:
|
|
@@ -166,20 +166,20 @@ ${issues}`);
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
vitest.it("CheckoutResponse projects purchase-intent authority without fabricating a bill token", async () => {
|
|
169
|
-
await
|
|
169
|
+
await chunk7O2BBPDM_js.fixtures.addFirstProduct(h.client);
|
|
170
170
|
const cartRes = await h.client.cart.get();
|
|
171
171
|
if (!cartRes.ok) throw cartRes.error;
|
|
172
172
|
const checkout = await h.client.checkout.process({
|
|
173
173
|
cart_id: cartRes.value.id,
|
|
174
|
-
customer:
|
|
174
|
+
customer: chunk7O2BBPDM_js.fixtures.customer(),
|
|
175
175
|
order_type: "delivery",
|
|
176
|
-
address_info:
|
|
176
|
+
address_info: chunk7O2BBPDM_js.fixtures.deliveryAddress(),
|
|
177
177
|
payment_method: "mobile_money",
|
|
178
178
|
mobile_money_details: { phone_number: "+233244000000", provider: "mtn" }
|
|
179
179
|
});
|
|
180
180
|
vitest.expect(checkout.ok).toBe(true);
|
|
181
181
|
if (!checkout.ok) return;
|
|
182
|
-
const result =
|
|
182
|
+
const result = chunk7O2BBPDM_js.CheckoutResponseSchema.safeParse(checkout.value);
|
|
183
183
|
if (!result.success) {
|
|
184
184
|
const issues = result.error.issues.map((i) => ` \u2022 ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
185
185
|
throw new Error(`CheckoutResponse shape mismatch:
|
package/dist/testing/suite.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-
|
|
1
|
+
import { assertBrand, SeedNameSchema, BrandSchema, createTestClient, assertCart, fixtures, AddItemPayloadSchema, CartItemSchema, CheckoutResponseSchema } from '../chunk-4VTFTLH7.mjs';
|
|
2
2
|
import '../chunk-L4XKIMUO.mjs';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-LJAZ7H4I.mjs';
|
|
4
4
|
import '../chunk-U4MW6PYU.mjs';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-T3MXI7JD.mjs';
|
|
6
6
|
import '../chunk-33VCYWVL.mjs';
|
|
7
7
|
import '../chunk-NYDVVNZI.mjs';
|
|
8
8
|
import '../chunk-NJYR6GGM.mjs';
|