@feelflow/ffid-sdk 8.1.0 → 10.0.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 +1010 -960
- package/dist/{FFIDCookieLink-Bwr0FBrV.d.cts → FFIDCookieLink-yt5SUr-W.d.cts} +47 -3
- package/dist/{FFIDCookieLink-Bwr0FBrV.d.ts → FFIDCookieLink-yt5SUr-W.d.ts} +47 -3
- package/dist/{chunk-CPXTIRB6.cjs → chunk-2LU2F3F2.cjs} +283 -11
- package/dist/{chunk-P5A6C5SK.js → chunk-OXW6QSTO.js} +270 -12
- package/dist/{chunk-XELXXL2F.cjs → chunk-RZCQ22GH.cjs} +29 -9
- package/dist/{chunk-RHBZHSRD.js → chunk-S2AEBJRX.js} +29 -9
- package/dist/components/index.cjs +8 -8
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/consent/index.cjs +63 -63
- package/dist/consent/index.d.cts +2 -2
- package/dist/consent/index.d.ts +2 -2
- package/dist/consent/index.js +1 -1
- package/dist/{ffid-client-B0cORHac.d.ts → ffid-client-5uxXRgIO.d.ts} +686 -376
- package/dist/{ffid-client-6aLs9Fqc.d.cts → ffid-client-CumygXXz.d.cts} +686 -376
- package/dist/{index-BG7g99pK.d.ts → index-KjewcNn1.d.cts} +813 -2
- package/dist/{index-BG7g99pK.d.cts → index-KjewcNn1.d.ts} +813 -2
- package/dist/index.cjs +151 -95
- package/dist/index.d.cts +116 -505
- package/dist/index.d.ts +116 -505
- package/dist/index.js +3 -3
- package/dist/server/index.cjs +253 -11
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +253 -11
- package/dist/server/test/index.d.cts +1 -1
- package/dist/server/test/index.d.ts +1 -1
- package/dist/webhooks/index.d.cts +112 -7
- package/dist/webhooks/index.d.ts +112 -7
- package/package.json +131 -131
|
@@ -226,18 +226,16 @@ function mapUserinfoSubscriptionToSession(userinfo, serviceCode) {
|
|
|
226
226
|
];
|
|
227
227
|
}
|
|
228
228
|
var JWKS_ENDPOINT = "/.well-known/jwks.json";
|
|
229
|
-
var LEGACY_JWT_ISSUER = "https://id.feelflow.net";
|
|
230
229
|
var JWT_ALGORITHM = "ES256";
|
|
231
230
|
var JWT_CLOCK_TOLERANCE_SECONDS = 30;
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
return deployedOrigin === LEGACY_JWT_ISSUER ? [LEGACY_JWT_ISSUER] : [deployedOrigin, LEGACY_JWT_ISSUER];
|
|
231
|
+
function resolveAcceptedIssuer(baseUrl) {
|
|
232
|
+
return new URL(baseUrl).origin;
|
|
235
233
|
}
|
|
236
234
|
function createJwtVerifier(deps) {
|
|
237
235
|
const { baseUrl, serviceCode, logger, createError, errorCodes } = deps;
|
|
238
236
|
const jwksUrl = new URL(JWKS_ENDPOINT, baseUrl);
|
|
239
237
|
const jwks = createRemoteJWKSet(jwksUrl);
|
|
240
|
-
const
|
|
238
|
+
const acceptedIssuer = resolveAcceptedIssuer(baseUrl);
|
|
241
239
|
async function verifyJwt(accessToken) {
|
|
242
240
|
if (!accessToken || !accessToken.trim()) {
|
|
243
241
|
return {
|
|
@@ -250,7 +248,7 @@ function createJwtVerifier(deps) {
|
|
|
250
248
|
try {
|
|
251
249
|
const { payload } = await jwtVerify(accessToken, jwks, {
|
|
252
250
|
algorithms: [JWT_ALGORITHM],
|
|
253
|
-
issuer:
|
|
251
|
+
issuer: acceptedIssuer,
|
|
254
252
|
audience: serviceCode,
|
|
255
253
|
clockTolerance: JWT_CLOCK_TOLERANCE_SECONDS
|
|
256
254
|
});
|
|
@@ -1376,7 +1374,7 @@ var FFID_ORGANIZATION_PROFILE_ERROR_CODES = {
|
|
|
1376
1374
|
};
|
|
1377
1375
|
|
|
1378
1376
|
// src/client/version-check.ts
|
|
1379
|
-
var SDK_VERSION = "
|
|
1377
|
+
var SDK_VERSION = "10.0.0";
|
|
1380
1378
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1381
1379
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1382
1380
|
function sdkHeaders() {
|
|
@@ -1732,8 +1730,11 @@ function createProvisioningMethods(deps) {
|
|
|
1732
1730
|
}
|
|
1733
1731
|
|
|
1734
1732
|
// src/client/seat-methods.ts
|
|
1733
|
+
function seatSummaryEndpoint(subscriptionId) {
|
|
1734
|
+
return `/api/v1/subscriptions/ext/${encodeURIComponent(subscriptionId)}/seats`;
|
|
1735
|
+
}
|
|
1735
1736
|
function seatsEndpoint(subscriptionId) {
|
|
1736
|
-
return
|
|
1737
|
+
return `${seatSummaryEndpoint(subscriptionId)}/assignments`;
|
|
1737
1738
|
}
|
|
1738
1739
|
function createSeatMethods(deps) {
|
|
1739
1740
|
const { fetchWithAuth, createError } = deps;
|
|
@@ -1743,6 +1744,12 @@ function createSeatMethods(deps) {
|
|
|
1743
1744
|
}
|
|
1744
1745
|
return fetchWithAuth(seatsEndpoint(params.subscriptionId));
|
|
1745
1746
|
}
|
|
1747
|
+
async function getSeats(subscriptionId) {
|
|
1748
|
+
if (!subscriptionId || !subscriptionId.trim()) {
|
|
1749
|
+
return { error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059") };
|
|
1750
|
+
}
|
|
1751
|
+
return fetchWithAuth(seatSummaryEndpoint(subscriptionId));
|
|
1752
|
+
}
|
|
1746
1753
|
async function assignSeats(params) {
|
|
1747
1754
|
if (!params.subscriptionId) {
|
|
1748
1755
|
return { error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059") };
|
|
@@ -1767,7 +1774,7 @@ function createSeatMethods(deps) {
|
|
|
1767
1774
|
{ method: "DELETE" }
|
|
1768
1775
|
);
|
|
1769
1776
|
}
|
|
1770
|
-
return { listSeatAssignments, assignSeats, unassignSeat };
|
|
1777
|
+
return { listSeatAssignments, getSeats, assignSeats, unassignSeat };
|
|
1771
1778
|
}
|
|
1772
1779
|
|
|
1773
1780
|
// src/client/profile-methods.ts
|
|
@@ -3632,6 +3639,225 @@ function createInquiryMethods(deps) {
|
|
|
3632
3639
|
return { create };
|
|
3633
3640
|
}
|
|
3634
3641
|
|
|
3642
|
+
// src/types/credits.ts
|
|
3643
|
+
var FFID_CREDITS_LOW_THRESHOLD_PERCENT = 20;
|
|
3644
|
+
var FFID_CREDITS_CONSUME_MIN_AMOUNT = 1;
|
|
3645
|
+
var FFID_CREDITS_CONSUME_MAX_AMOUNT = 1e6;
|
|
3646
|
+
var FFID_CREDITS_METADATA_MAX_BYTES = 4096;
|
|
3647
|
+
var FFID_CREDITS_HISTORY_MIN_LIMIT = 1;
|
|
3648
|
+
var FFID_CREDITS_HISTORY_MAX_LIMIT = 100;
|
|
3649
|
+
var FFID_CREDITS_HISTORY_DEFAULT_LIMIT = 20;
|
|
3650
|
+
var FFID_CREDIT_PACK_MIN_QUANTITY = 1;
|
|
3651
|
+
var FFID_CREDIT_PACK_MAX_QUANTITY = 10;
|
|
3652
|
+
var FFID_CREDITS_IDEMPOTENCY_KEY_PATTERN = /^[A-Za-z0-9._:-]{8,128}$/;
|
|
3653
|
+
var FFID_CREDITS_FEATURE_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
|
3654
|
+
var FFID_CREDIT_HISTORY_TYPES = ["grant", "consumption", "revocation"];
|
|
3655
|
+
var FFID_CREDIT_GRANT_KINDS = ["monthly", "manual", "pack"];
|
|
3656
|
+
|
|
3657
|
+
// src/client/credits-methods.ts
|
|
3658
|
+
var EXT_SUBSCRIPTIONS_PATH = "/api/v1/subscriptions/ext";
|
|
3659
|
+
var CREDIT_PACKS_ENDPOINT = `${EXT_SUBSCRIPTIONS_PATH}/credits/packs`;
|
|
3660
|
+
var CREDIT_PACK_CHECKOUT_ENDPOINT = `${CREDIT_PACKS_ENDPOINT}/checkout`;
|
|
3661
|
+
var PORTAL_SUBSCRIPTION_PATH = "/subscriptions";
|
|
3662
|
+
var BUY_CREDITS_QUERY = { key: "purchase", value: "credits" };
|
|
3663
|
+
var ORG_QUERY_KEY = "org";
|
|
3664
|
+
var FFID_CONTRACT_ID_PREFIX = "ffid:";
|
|
3665
|
+
var STRIPE_SUBSCRIPTION_ID_PREFIX = "sub_";
|
|
3666
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3667
|
+
var VALIDATION_ERROR = "VALIDATION_ERROR";
|
|
3668
|
+
var FORBIDDEN = "FORBIDDEN";
|
|
3669
|
+
var utf8Encoder = new TextEncoder();
|
|
3670
|
+
function creditsEndpoint(subscriptionId, action) {
|
|
3671
|
+
return `${EXT_SUBSCRIPTIONS_PATH}/${encodeURIComponent(subscriptionId)}/credits/${action}`;
|
|
3672
|
+
}
|
|
3673
|
+
function isPlainObject2(value) {
|
|
3674
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3675
|
+
}
|
|
3676
|
+
function isIntegerInRange(value, min, max) {
|
|
3677
|
+
return typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
3678
|
+
}
|
|
3679
|
+
function createCreditsMethods(deps) {
|
|
3680
|
+
const { fetchWithAuth, createError, authMode, baseUrl, serviceCode, logger } = deps;
|
|
3681
|
+
function validationError(field, message) {
|
|
3682
|
+
return { error: { ...createError(VALIDATION_ERROR, message), details: { field } } };
|
|
3683
|
+
}
|
|
3684
|
+
function forbidden(reason, message) {
|
|
3685
|
+
return { error: { ...createError(FORBIDDEN, message), details: { reason } } };
|
|
3686
|
+
}
|
|
3687
|
+
function missingSubscriptionId(subscriptionId) {
|
|
3688
|
+
return subscriptionId && subscriptionId.trim() ? null : validationError("subscriptionId", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059");
|
|
3689
|
+
}
|
|
3690
|
+
async function getBalance(subscriptionId) {
|
|
3691
|
+
const invalid = missingSubscriptionId(subscriptionId);
|
|
3692
|
+
if (invalid) return invalid;
|
|
3693
|
+
return fetchWithAuth(creditsEndpoint(subscriptionId, "balance"));
|
|
3694
|
+
}
|
|
3695
|
+
async function listHistory(subscriptionId, options = {}) {
|
|
3696
|
+
const invalid = missingSubscriptionId(subscriptionId);
|
|
3697
|
+
if (invalid) return invalid;
|
|
3698
|
+
const query = new URLSearchParams();
|
|
3699
|
+
if (options.cursor !== void 0) query.set("cursor", options.cursor);
|
|
3700
|
+
if (options.limit !== void 0) {
|
|
3701
|
+
if (!isIntegerInRange(options.limit, FFID_CREDITS_HISTORY_MIN_LIMIT, FFID_CREDITS_HISTORY_MAX_LIMIT)) {
|
|
3702
|
+
return validationError(
|
|
3703
|
+
"limit",
|
|
3704
|
+
`limit \u306F ${FFID_CREDITS_HISTORY_MIN_LIMIT}\u301C${FFID_CREDITS_HISTORY_MAX_LIMIT} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`
|
|
3705
|
+
);
|
|
3706
|
+
}
|
|
3707
|
+
query.set("limit", String(options.limit));
|
|
3708
|
+
}
|
|
3709
|
+
if (options.type !== void 0) {
|
|
3710
|
+
if (!FFID_CREDIT_HISTORY_TYPES.includes(options.type)) {
|
|
3711
|
+
return validationError("type", `type \u306F ${FFID_CREDIT_HISTORY_TYPES.join(" / ")} \u306E\u3044\u305A\u308C\u304B\u3067\u3059`);
|
|
3712
|
+
}
|
|
3713
|
+
query.set("type", options.type);
|
|
3714
|
+
}
|
|
3715
|
+
const qs = query.toString();
|
|
3716
|
+
return fetchWithAuth(
|
|
3717
|
+
`${creditsEndpoint(subscriptionId, "history")}${qs ? `?${qs}` : ""}`
|
|
3718
|
+
);
|
|
3719
|
+
}
|
|
3720
|
+
async function listPacks(packServiceCode) {
|
|
3721
|
+
const resolved = packServiceCode ?? (authMode === "service-key" ? void 0 : serviceCode);
|
|
3722
|
+
if (resolved !== void 0 && !resolved.trim()) {
|
|
3723
|
+
return validationError("serviceCode", "serviceCode \u3092\u6307\u5B9A\u3059\u308B\u5834\u5408\u3001\u7A7A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093");
|
|
3724
|
+
}
|
|
3725
|
+
const qs = resolved === void 0 ? "" : `?${new URLSearchParams({ serviceCode: resolved }).toString()}`;
|
|
3726
|
+
return fetchWithAuth(`${CREDIT_PACKS_ENDPOINT}${qs}`);
|
|
3727
|
+
}
|
|
3728
|
+
async function createPackCheckout(params) {
|
|
3729
|
+
if (authMode !== "token") {
|
|
3730
|
+
return forbidden(
|
|
3731
|
+
"bearer_required",
|
|
3732
|
+
"createPackCheckout \u306F token \u30E2\u30FC\u30C9\uFF08Bearer\uFF09\u3067\u306E\u307F\u5229\u7528\u3067\u304D\u307E\u3059\u3002\u8CFC\u5165\u8005\u306E\u8A18\u9332\u306B\u5B9F\u30E6\u30FC\u30B6\u30FC\u304C\u5FC5\u8981\u306A\u305F\u3081\u3067\u3059"
|
|
3733
|
+
);
|
|
3734
|
+
}
|
|
3735
|
+
const invalid = missingSubscriptionId(params.subscriptionId);
|
|
3736
|
+
if (invalid) return invalid;
|
|
3737
|
+
for (const field of ["packCode", "successUrl", "cancelUrl"]) {
|
|
3738
|
+
if (!params[field] || !params[field].trim()) {
|
|
3739
|
+
return validationError(field, `${field} \u306F\u5FC5\u9808\u3067\u3059`);
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
if (params.quantity !== void 0 && !isIntegerInRange(params.quantity, FFID_CREDIT_PACK_MIN_QUANTITY, FFID_CREDIT_PACK_MAX_QUANTITY)) {
|
|
3743
|
+
return validationError(
|
|
3744
|
+
"quantity",
|
|
3745
|
+
`quantity \u306F ${FFID_CREDIT_PACK_MIN_QUANTITY}\u301C${FFID_CREDIT_PACK_MAX_QUANTITY} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`
|
|
3746
|
+
);
|
|
3747
|
+
}
|
|
3748
|
+
const body = {
|
|
3749
|
+
subscriptionId: params.subscriptionId,
|
|
3750
|
+
packCode: params.packCode,
|
|
3751
|
+
successUrl: params.successUrl,
|
|
3752
|
+
cancelUrl: params.cancelUrl
|
|
3753
|
+
};
|
|
3754
|
+
if (params.quantity !== void 0) body.quantity = params.quantity;
|
|
3755
|
+
return fetchWithAuth(CREDIT_PACK_CHECKOUT_ENDPOINT, {
|
|
3756
|
+
method: "POST",
|
|
3757
|
+
body: JSON.stringify(body)
|
|
3758
|
+
});
|
|
3759
|
+
}
|
|
3760
|
+
function validateConsume(params) {
|
|
3761
|
+
const invalid = missingSubscriptionId(params.subscriptionId);
|
|
3762
|
+
if (invalid) return invalid;
|
|
3763
|
+
if (!isIntegerInRange(params.amount, FFID_CREDITS_CONSUME_MIN_AMOUNT, FFID_CREDITS_CONSUME_MAX_AMOUNT)) {
|
|
3764
|
+
return validationError(
|
|
3765
|
+
"amount",
|
|
3766
|
+
`amount \u306F ${FFID_CREDITS_CONSUME_MIN_AMOUNT}\u301C${FFID_CREDITS_CONSUME_MAX_AMOUNT} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`
|
|
3767
|
+
);
|
|
3768
|
+
}
|
|
3769
|
+
if (typeof params.idempotencyKey !== "string" || !FFID_CREDITS_IDEMPOTENCY_KEY_PATTERN.test(params.idempotencyKey)) {
|
|
3770
|
+
return validationError(
|
|
3771
|
+
"idempotencyKey",
|
|
3772
|
+
"idempotencyKey \u306E\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059\uFF08\u82F1\u6570\u5B57\u3068 . _ : - \u306E 8\u301C128 \u6587\u5B57\u3002\u63A8\u5968\u306F feature:requestId\uFF09"
|
|
3773
|
+
);
|
|
3774
|
+
}
|
|
3775
|
+
if (typeof params.feature !== "string" || !FFID_CREDITS_FEATURE_PATTERN.test(params.feature)) {
|
|
3776
|
+
return validationError("feature", "feature \u306E\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059\uFF08\u5C0F\u6587\u5B57\u82F1\u6570\u5B57\u3067\u59CB\u307E\u308B\u3001\u5C0F\u6587\u5B57\u82F1\u6570\u5B57\u3068 . _ - \u306E 1\u301C64 \u6587\u5B57\uFF09");
|
|
3777
|
+
}
|
|
3778
|
+
if (params.metadata !== void 0) {
|
|
3779
|
+
if (!isPlainObject2(params.metadata)) {
|
|
3780
|
+
return validationError("metadata", "metadata \u306F JSON \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059");
|
|
3781
|
+
}
|
|
3782
|
+
let serialized;
|
|
3783
|
+
try {
|
|
3784
|
+
serialized = JSON.stringify(params.metadata);
|
|
3785
|
+
} catch {
|
|
3786
|
+
return validationError("metadata", "metadata \u306F JSON \u306B\u5909\u63DB\u3067\u304D\u308B\u5024\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08BigInt\u30FB\u5FAA\u74B0\u53C2\u7167\u306F\u4E0D\u53EF\uFF09");
|
|
3787
|
+
}
|
|
3788
|
+
if (utf8Encoder.encode(serialized).byteLength > FFID_CREDITS_METADATA_MAX_BYTES) {
|
|
3789
|
+
return validationError("metadata", `metadata \u306F ${FFID_CREDITS_METADATA_MAX_BYTES} \u30D0\u30A4\u30C8\u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`);
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
if (params.userId !== void 0 && !UUID_PATTERN.test(params.userId)) {
|
|
3793
|
+
return validationError("userId", "userId \u306F\u6709\u52B9\u306AUUID\u5F62\u5F0F\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059");
|
|
3794
|
+
}
|
|
3795
|
+
return null;
|
|
3796
|
+
}
|
|
3797
|
+
async function consume(params) {
|
|
3798
|
+
if (authMode !== "service-key") {
|
|
3799
|
+
return forbidden(
|
|
3800
|
+
"api_key_required",
|
|
3801
|
+
"credits.consume \u306F service-key \u8A8D\u8A3C\uFF08X-Service-Api-Key\uFF09\u3067\u306E\u307F\u5229\u7528\u3067\u304D\u307E\u3059\u3002\u6D88\u8CBB\u306E\u5831\u544A\u306F\u30B5\u30FC\u30D3\u30B9\u306E\u30D0\u30C3\u30AF\u30A8\u30F3\u30C9\u304B\u3089\u884C\u3063\u3066\u304F\u3060\u3055\u3044"
|
|
3802
|
+
);
|
|
3803
|
+
}
|
|
3804
|
+
const invalid = validateConsume(params);
|
|
3805
|
+
if (invalid) return invalid;
|
|
3806
|
+
const body = {
|
|
3807
|
+
amount: params.amount,
|
|
3808
|
+
idempotencyKey: params.idempotencyKey,
|
|
3809
|
+
feature: params.feature
|
|
3810
|
+
};
|
|
3811
|
+
if (params.metadata !== void 0) body.metadata = params.metadata;
|
|
3812
|
+
if (params.userId !== void 0) body.userId = params.userId;
|
|
3813
|
+
return fetchWithAuth(creditsEndpoint(params.subscriptionId, "consume"), {
|
|
3814
|
+
method: "POST",
|
|
3815
|
+
body: JSON.stringify(body)
|
|
3816
|
+
});
|
|
3817
|
+
}
|
|
3818
|
+
function getBuyCreditsUrl(params) {
|
|
3819
|
+
const raw = params.subscriptionId?.trim() ?? "";
|
|
3820
|
+
if (raw.startsWith(STRIPE_SUBSCRIPTION_ID_PREFIX)) {
|
|
3821
|
+
return validationError(
|
|
3822
|
+
"subscriptionId",
|
|
3823
|
+
"getBuyCreditsUrl \u306B\u306F\u5951\u7D04\u306E UUID\uFF08\u307E\u305F\u306F ffid:<uuid>\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002Stripe \u306E sub_... \u306F\u4F7F\u3048\u307E\u305B\u3093"
|
|
3824
|
+
);
|
|
3825
|
+
}
|
|
3826
|
+
const uuid = raw.startsWith(FFID_CONTRACT_ID_PREFIX) ? raw.slice(FFID_CONTRACT_ID_PREFIX.length) : raw;
|
|
3827
|
+
if (!UUID_PATTERN.test(uuid)) {
|
|
3828
|
+
return validationError("subscriptionId", "subscriptionId \u306F\u5951\u7D04\u306E UUID\uFF08\u307E\u305F\u306F ffid:<uuid>\uFF09\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059");
|
|
3829
|
+
}
|
|
3830
|
+
const query = new URLSearchParams({ [BUY_CREDITS_QUERY.key]: BUY_CREDITS_QUERY.value });
|
|
3831
|
+
if (params.orgId !== void 0 && params.orgId.trim()) {
|
|
3832
|
+
query.set(ORG_QUERY_KEY, params.orgId);
|
|
3833
|
+
}
|
|
3834
|
+
return { data: `${baseUrl}${PORTAL_SUBSCRIPTION_PATH}/${encodeURIComponent(uuid)}?${query.toString()}` };
|
|
3835
|
+
}
|
|
3836
|
+
function redirectToBuyCredits(params) {
|
|
3837
|
+
const result = getBuyCreditsUrl(params);
|
|
3838
|
+
if (result.error) {
|
|
3839
|
+
logger.warn("redirectToBuyCredits:", result.error.message);
|
|
3840
|
+
return { success: false, error: result.error.message };
|
|
3841
|
+
}
|
|
3842
|
+
if (typeof window === "undefined") {
|
|
3843
|
+
logger.warn("SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093");
|
|
3844
|
+
return { success: false, error: "SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093" };
|
|
3845
|
+
}
|
|
3846
|
+
logger.debug("Redirecting to buy credits:", result.data);
|
|
3847
|
+
window.location.href = result.data;
|
|
3848
|
+
return { success: true };
|
|
3849
|
+
}
|
|
3850
|
+
return {
|
|
3851
|
+
getBalance,
|
|
3852
|
+
listHistory,
|
|
3853
|
+
listPacks,
|
|
3854
|
+
createPackCheckout,
|
|
3855
|
+
consume,
|
|
3856
|
+
getBuyCreditsUrl,
|
|
3857
|
+
redirectToBuyCredits
|
|
3858
|
+
};
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3635
3861
|
// src/subscriptions/types.ts
|
|
3636
3862
|
var EFFECTIVE_SUBSCRIPTION_STATUSES = [
|
|
3637
3863
|
"active",
|
|
@@ -3765,7 +3991,12 @@ function toServiceAccessDecision(response, allowGrace) {
|
|
|
3765
3991
|
planCode: response.planCode,
|
|
3766
3992
|
currentPeriodEnd: response.currentPeriodEnd,
|
|
3767
3993
|
gracePeriodEndsAt: response.gracePeriodEndsAt ?? null,
|
|
3768
|
-
reactivatable: response.reactivatable ?? false
|
|
3994
|
+
reactivatable: response.reactivatable ?? false,
|
|
3995
|
+
// Informational pass-through (10.0.0). Deliberately not part of hasAccess /
|
|
3996
|
+
// denialReason: credits and the member limit never gate access (CREDITS_API §1-5).
|
|
3997
|
+
...response.pricingModel !== void 0 ? { pricingModel: response.pricingModel } : {},
|
|
3998
|
+
...response.credits !== void 0 ? { credits: response.credits } : {},
|
|
3999
|
+
...response.memberLimitReached !== void 0 ? { memberLimitReached: response.memberLimitReached } : {}
|
|
3769
4000
|
};
|
|
3770
4001
|
}
|
|
3771
4002
|
function failClosedServiceAccessDecision(params, error) {
|
|
@@ -3812,6 +4043,19 @@ var FFID_SUBSCRIPTION_ERROR_CODES = {
|
|
|
3812
4043
|
FREE_DOWNGRADE_NOT_ALLOWED: "FREE_DOWNGRADE_NOT_ALLOWED",
|
|
3813
4044
|
PAYMENT_METHOD_REQUIRED: "PAYMENT_METHOD_REQUIRED"
|
|
3814
4045
|
};
|
|
4046
|
+
var FFID_CREDITS_ERROR_CODES = {
|
|
4047
|
+
CREDITS_INSUFFICIENT: "CREDITS_INSUFFICIENT",
|
|
4048
|
+
CREDITS_IDEMPOTENCY_CONFLICT: "CREDITS_IDEMPOTENCY_CONFLICT",
|
|
4049
|
+
CREDITS_NOT_APPLICABLE: "CREDITS_NOT_APPLICABLE",
|
|
4050
|
+
CREDITS_BALANCE_CAP_EXCEEDED: "CREDITS_BALANCE_CAP_EXCEEDED",
|
|
4051
|
+
SEAT_BILLING_NOT_APPLICABLE: "SEAT_BILLING_NOT_APPLICABLE",
|
|
4052
|
+
MEMBER_LIMIT_REACHED: "MEMBER_LIMIT_REACHED",
|
|
4053
|
+
CREDIT_PACK_NOT_FOUND: "CREDIT_PACK_NOT_FOUND",
|
|
4054
|
+
CREDIT_PACK_REGION_NOT_SUPPORTED: "CREDIT_PACK_REGION_NOT_SUPPORTED",
|
|
4055
|
+
CREDIT_PACK_STRIPE_NOT_SYNCED: "CREDIT_PACK_STRIPE_NOT_SYNCED",
|
|
4056
|
+
CREDIT_PACK_STRIPE_OUT_OF_SYNC: "CREDIT_PACK_STRIPE_OUT_OF_SYNC",
|
|
4057
|
+
CREDIT_PACK_CHANGED: "CREDIT_PACK_CHANGED"
|
|
4058
|
+
};
|
|
3815
4059
|
|
|
3816
4060
|
// src/client/ffid-client.ts
|
|
3817
4061
|
var UNAUTHORIZED_STATUS2 = 401;
|
|
@@ -4139,7 +4383,7 @@ function createFFIDClient(config) {
|
|
|
4139
4383
|
fetchWithAuth,
|
|
4140
4384
|
createError
|
|
4141
4385
|
});
|
|
4142
|
-
const { listSeatAssignments, assignSeats, unassignSeat } = createSeatMethods({
|
|
4386
|
+
const { listSeatAssignments, getSeats, assignSeats, unassignSeat } = createSeatMethods({
|
|
4143
4387
|
fetchWithAuth,
|
|
4144
4388
|
createError
|
|
4145
4389
|
});
|
|
@@ -4246,6 +4490,14 @@ function createFFIDClient(config) {
|
|
|
4246
4490
|
fetchWithAuth,
|
|
4247
4491
|
createError
|
|
4248
4492
|
});
|
|
4493
|
+
const credits = createCreditsMethods({
|
|
4494
|
+
fetchWithAuth,
|
|
4495
|
+
createError,
|
|
4496
|
+
authMode,
|
|
4497
|
+
baseUrl,
|
|
4498
|
+
serviceCode: config.serviceCode,
|
|
4499
|
+
logger
|
|
4500
|
+
});
|
|
4249
4501
|
const verifyAccessToken = createVerifyAccessToken({
|
|
4250
4502
|
authMode,
|
|
4251
4503
|
baseUrl,
|
|
@@ -4301,6 +4553,7 @@ function createFFIDClient(config) {
|
|
|
4301
4553
|
getInvoice,
|
|
4302
4554
|
retryPayment,
|
|
4303
4555
|
listSeatAssignments,
|
|
4556
|
+
getSeats,
|
|
4304
4557
|
assignSeats,
|
|
4305
4558
|
unassignSeat,
|
|
4306
4559
|
listPlans,
|
|
@@ -4311,13 +4564,16 @@ function createFFIDClient(config) {
|
|
|
4311
4564
|
cancelSubscription,
|
|
4312
4565
|
cancelPendingDowngrade,
|
|
4313
4566
|
previewPlanChange,
|
|
4567
|
+
/** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
|
|
4314
4568
|
previewSeatChange,
|
|
4315
4569
|
verifyAccessToken,
|
|
4316
4570
|
getSubscribeUrl,
|
|
4317
4571
|
redirectToSubscribe,
|
|
4318
4572
|
getChangePlanUrl,
|
|
4319
4573
|
redirectToChangePlan,
|
|
4574
|
+
/** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
|
|
4320
4575
|
getChangeSeatsUrl,
|
|
4576
|
+
/** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
|
|
4321
4577
|
redirectToChangeSeats,
|
|
4322
4578
|
getRecoverPaymentUrl,
|
|
4323
4579
|
redirectToRecoverPayment,
|
|
@@ -4333,6 +4589,8 @@ function createFFIDClient(config) {
|
|
|
4333
4589
|
newsletter,
|
|
4334
4590
|
/** Inquiry methods (create) */
|
|
4335
4591
|
inquiry,
|
|
4592
|
+
/** Credits methods for flat plans (consume / balance / history / packs) */
|
|
4593
|
+
credits,
|
|
4336
4594
|
/** Token store (token mode only) */
|
|
4337
4595
|
tokenStore,
|
|
4338
4596
|
/**
|
|
@@ -6479,4 +6737,4 @@ function FFIDInquiryForm({
|
|
|
6479
6737
|
);
|
|
6480
6738
|
}
|
|
6481
6739
|
|
|
6482
|
-
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, AGENCY_INVITE_COOKIE_MAX_AGE_SEC, AGENCY_INVITE_COOKIE_NAME, AGENCY_INVITE_TOKEN_PARAM, AGENCY_INVITE_TOKEN_REDACTION, BLOCKING_EFFECTIVE_STATUSES, CATALOG_HASH_PATTERN, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EFFECTIVE_SUBSCRIPTION_STATUSES, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDCatalogHashError, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ALLOWED_ORGANIZATION_LOGO_MIME_TYPES, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_CATALOG_ENVIRONMENTS, FFID_CATALOG_PUBLICATION_STATUSES, FFID_COMPANY_SIZE_CODES, FFID_ERROR_CODES, FFID_INDUSTRY_CODES, FFID_INQUIRY_ACQUISITION_SOURCES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES, FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB, FFID_ORGANIZATION_PROFILE_ERROR_CODES, FFID_SUBSCRIPTION_ERROR_CODES, canonicalizeCatalogValue, captureAgencyInviteToken, cleanupStateStorage, clearAgencyInviteToken, computeEffectiveStatusFromSession, computeFFIDCheckoutCopyHash, computeLegalDisclosureHash, computePaymentConfigurationHash, computePraxisCopyHash, computeScopeHash, computeTaxConfigurationHash, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, hashCanonicalJson, isBlockedFromUserinfo, isFFIDInquiryAcquisitionSource, isFFIDInquiryCategorySite2026, normalizeRedirectUri, readAgencyInviteCookie, readAgencyInviteToken, redactAgencyInviteToken, retrieveCodeVerifier, retrieveState, sha256Hex, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useFFIDContext, useSubscription, validatePublishedCatalog, withSubscription };
|
|
6740
|
+
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, AGENCY_INVITE_COOKIE_MAX_AGE_SEC, AGENCY_INVITE_COOKIE_NAME, AGENCY_INVITE_TOKEN_PARAM, AGENCY_INVITE_TOKEN_REDACTION, BLOCKING_EFFECTIVE_STATUSES, CATALOG_HASH_PATTERN, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EFFECTIVE_SUBSCRIPTION_STATUSES, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDCatalogHashError, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ALLOWED_ORGANIZATION_LOGO_MIME_TYPES, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_CATALOG_ENVIRONMENTS, FFID_CATALOG_PUBLICATION_STATUSES, FFID_COMPANY_SIZE_CODES, FFID_CREDITS_CONSUME_MAX_AMOUNT, FFID_CREDITS_CONSUME_MIN_AMOUNT, FFID_CREDITS_ERROR_CODES, FFID_CREDITS_FEATURE_PATTERN, FFID_CREDITS_HISTORY_DEFAULT_LIMIT, FFID_CREDITS_HISTORY_MAX_LIMIT, FFID_CREDITS_HISTORY_MIN_LIMIT, FFID_CREDITS_IDEMPOTENCY_KEY_PATTERN, FFID_CREDITS_LOW_THRESHOLD_PERCENT, FFID_CREDITS_METADATA_MAX_BYTES, FFID_CREDIT_GRANT_KINDS, FFID_CREDIT_HISTORY_TYPES, FFID_CREDIT_PACK_MAX_QUANTITY, FFID_CREDIT_PACK_MIN_QUANTITY, FFID_ERROR_CODES, FFID_INDUSTRY_CODES, FFID_INQUIRY_ACQUISITION_SOURCES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES, FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB, FFID_ORGANIZATION_PROFILE_ERROR_CODES, FFID_SUBSCRIPTION_ERROR_CODES, canonicalizeCatalogValue, captureAgencyInviteToken, cleanupStateStorage, clearAgencyInviteToken, computeEffectiveStatusFromSession, computeFFIDCheckoutCopyHash, computeLegalDisclosureHash, computePaymentConfigurationHash, computePraxisCopyHash, computeScopeHash, computeTaxConfigurationHash, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, hashCanonicalJson, isBlockedFromUserinfo, isFFIDInquiryAcquisitionSource, isFFIDInquiryCategorySite2026, normalizeRedirectUri, readAgencyInviteCookie, readAgencyInviteToken, redactAgencyInviteToken, retrieveCodeVerifier, retrieveState, sha256Hex, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useFFIDContext, useSubscription, validatePublishedCatalog, withSubscription };
|
|
@@ -1476,6 +1476,8 @@ function useFFIDConsentPreferences() {
|
|
|
1476
1476
|
withdraw: ctx.withdraw
|
|
1477
1477
|
};
|
|
1478
1478
|
}
|
|
1479
|
+
var DEFAULT_BANNER_ARIA_LABEL = "Cookie \u540C\u610F";
|
|
1480
|
+
var DEFAULT_PREFERENCES_LOADING_LABEL = "\u8AAD\u307F\u8FBC\u307F\u4E2D...";
|
|
1479
1481
|
var DEFAULT_STYLE = {
|
|
1480
1482
|
position: "fixed",
|
|
1481
1483
|
bottom: 0,
|
|
@@ -1519,6 +1521,8 @@ function FFIDCookieBanner({
|
|
|
1519
1521
|
necessaryOnlyLabel,
|
|
1520
1522
|
preferencesLabel,
|
|
1521
1523
|
closeLabel,
|
|
1524
|
+
ariaLabel,
|
|
1525
|
+
preferencesLoadingLabel,
|
|
1522
1526
|
style
|
|
1523
1527
|
}) {
|
|
1524
1528
|
const {
|
|
@@ -1560,7 +1564,7 @@ function FFIDCookieBanner({
|
|
|
1560
1564
|
{
|
|
1561
1565
|
role: "dialog",
|
|
1562
1566
|
"aria-modal": "false",
|
|
1563
|
-
"aria-label":
|
|
1567
|
+
"aria-label": ariaLabel ?? DEFAULT_BANNER_ARIA_LABEL,
|
|
1564
1568
|
"aria-busy": isOpeningPreferences,
|
|
1565
1569
|
className: className ?? classNames?.root,
|
|
1566
1570
|
style: style ?? DEFAULT_STYLE,
|
|
@@ -1632,7 +1636,7 @@ function FFIDCookieBanner({
|
|
|
1632
1636
|
void handleOpenPreferences();
|
|
1633
1637
|
},
|
|
1634
1638
|
"data-testid": "ffid-cookie-banner-preferences",
|
|
1635
|
-
children: pendingAction === "preferences" ?
|
|
1639
|
+
children: pendingAction === "preferences" ? preferencesLoadingLabel ?? DEFAULT_PREFERENCES_LOADING_LABEL : preferencesLabel ?? "\u8A73\u7D30\u8A2D\u5B9A"
|
|
1636
1640
|
}
|
|
1637
1641
|
),
|
|
1638
1642
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1661,6 +1665,13 @@ function FFIDCookieBanner({
|
|
|
1661
1665
|
);
|
|
1662
1666
|
}
|
|
1663
1667
|
var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1668
|
+
var DEFAULT_SETTINGS_TITLE = "Cookie \u8A2D\u5B9A";
|
|
1669
|
+
var DEFAULT_SETTINGS_BUTTON_LABELS = {
|
|
1670
|
+
save: "\u5909\u66F4\u3092\u4FDD\u5B58",
|
|
1671
|
+
saving: "\u4FDD\u5B58\u4E2D...",
|
|
1672
|
+
withdraw: "\u3059\u3079\u3066\u64A4\u56DE",
|
|
1673
|
+
withdrawing: "\u64A4\u56DE\u4E2D..."
|
|
1674
|
+
};
|
|
1664
1675
|
var DEFAULT_BACKDROP_STYLE = {
|
|
1665
1676
|
position: "fixed",
|
|
1666
1677
|
inset: 0,
|
|
@@ -1694,7 +1705,15 @@ function FFIDCookieSettings({
|
|
|
1694
1705
|
className,
|
|
1695
1706
|
classNames,
|
|
1696
1707
|
open,
|
|
1697
|
-
showWithdrawButton = true
|
|
1708
|
+
showWithdrawButton = true,
|
|
1709
|
+
title,
|
|
1710
|
+
ariaLabel,
|
|
1711
|
+
saveLabel,
|
|
1712
|
+
savingLabel,
|
|
1713
|
+
withdrawLabel,
|
|
1714
|
+
withdrawingLabel,
|
|
1715
|
+
categoryLabels,
|
|
1716
|
+
categoryDescriptions
|
|
1698
1717
|
}) {
|
|
1699
1718
|
const { isPreferencesOpen, closePreferences, error } = useFFIDConsent();
|
|
1700
1719
|
const { state, categoryMetadata, save, withdraw } = useFFIDConsentPreferences();
|
|
@@ -1789,6 +1808,7 @@ function FFIDCookieSettings({
|
|
|
1789
1808
|
};
|
|
1790
1809
|
}, [visible, closePreferences]);
|
|
1791
1810
|
if (!visible) return null;
|
|
1811
|
+
const heading = title ?? DEFAULT_SETTINGS_TITLE;
|
|
1792
1812
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1793
1813
|
"div",
|
|
1794
1814
|
{
|
|
@@ -1805,14 +1825,14 @@ function FFIDCookieSettings({
|
|
|
1805
1825
|
{
|
|
1806
1826
|
role: "dialog",
|
|
1807
1827
|
"aria-modal": "true",
|
|
1808
|
-
"aria-label":
|
|
1828
|
+
"aria-label": ariaLabel ?? heading,
|
|
1809
1829
|
"aria-busy": isSubmitting,
|
|
1810
1830
|
className: className ?? classNames?.root,
|
|
1811
1831
|
style: DEFAULT_MODAL_STYLE,
|
|
1812
1832
|
"data-testid": "ffid-cookie-settings",
|
|
1813
1833
|
ref: modalRef,
|
|
1814
1834
|
children: [
|
|
1815
|
-
/* @__PURE__ */ jsxRuntime.jsx("header", { className: classNames?.header, children: /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { margin: 0, fontSize: "18px" }, children:
|
|
1835
|
+
/* @__PURE__ */ jsxRuntime.jsx("header", { className: classNames?.header, children: /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { margin: 0, fontSize: "18px" }, children: heading }) }),
|
|
1816
1836
|
/* @__PURE__ */ jsxRuntime.jsx("div", { children: (categoryMetadata ?? FALLBACK_CATEGORIES).map((cat) => {
|
|
1817
1837
|
const checked = cat.code === "necessary" ? true : draft[cat.code] ?? false;
|
|
1818
1838
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1822,8 +1842,8 @@ function FFIDCookieSettings({
|
|
|
1822
1842
|
style: ROW_STYLE,
|
|
1823
1843
|
children: [
|
|
1824
1844
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1 }, children: [
|
|
1825
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 600, fontSize: "14px" }, children: cat.label }),
|
|
1826
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#6b7280", fontSize: "13px" }, children: cat.description })
|
|
1845
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { fontWeight: 600, fontSize: "14px" }, children: categoryLabels?.[cat.code] ?? cat.label }),
|
|
1846
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { color: "#6b7280", fontSize: "13px" }, children: categoryDescriptions?.[cat.code] ?? cat.description })
|
|
1827
1847
|
] }),
|
|
1828
1848
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1829
1849
|
"input",
|
|
@@ -1879,7 +1899,7 @@ function FFIDCookieSettings({
|
|
|
1879
1899
|
cursor: isSubmitting ? "wait" : "pointer"
|
|
1880
1900
|
},
|
|
1881
1901
|
"data-testid": "ffid-cookie-settings-withdraw",
|
|
1882
|
-
children: pendingAction === "withdraw" ?
|
|
1902
|
+
children: pendingAction === "withdraw" ? withdrawingLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.withdrawing : withdrawLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.withdraw
|
|
1883
1903
|
}
|
|
1884
1904
|
) : null,
|
|
1885
1905
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1901,7 +1921,7 @@ function FFIDCookieSettings({
|
|
|
1901
1921
|
cursor: isSubmitting ? "wait" : "pointer"
|
|
1902
1922
|
},
|
|
1903
1923
|
"data-testid": "ffid-cookie-settings-save",
|
|
1904
|
-
children: pendingAction === "save" ?
|
|
1924
|
+
children: pendingAction === "save" ? savingLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.saving : saveLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.save
|
|
1905
1925
|
}
|
|
1906
1926
|
)
|
|
1907
1927
|
]
|
|
@@ -1474,6 +1474,8 @@ function useFFIDConsentPreferences() {
|
|
|
1474
1474
|
withdraw: ctx.withdraw
|
|
1475
1475
|
};
|
|
1476
1476
|
}
|
|
1477
|
+
var DEFAULT_BANNER_ARIA_LABEL = "Cookie \u540C\u610F";
|
|
1478
|
+
var DEFAULT_PREFERENCES_LOADING_LABEL = "\u8AAD\u307F\u8FBC\u307F\u4E2D...";
|
|
1477
1479
|
var DEFAULT_STYLE = {
|
|
1478
1480
|
position: "fixed",
|
|
1479
1481
|
bottom: 0,
|
|
@@ -1517,6 +1519,8 @@ function FFIDCookieBanner({
|
|
|
1517
1519
|
necessaryOnlyLabel,
|
|
1518
1520
|
preferencesLabel,
|
|
1519
1521
|
closeLabel,
|
|
1522
|
+
ariaLabel,
|
|
1523
|
+
preferencesLoadingLabel,
|
|
1520
1524
|
style
|
|
1521
1525
|
}) {
|
|
1522
1526
|
const {
|
|
@@ -1558,7 +1562,7 @@ function FFIDCookieBanner({
|
|
|
1558
1562
|
{
|
|
1559
1563
|
role: "dialog",
|
|
1560
1564
|
"aria-modal": "false",
|
|
1561
|
-
"aria-label":
|
|
1565
|
+
"aria-label": ariaLabel ?? DEFAULT_BANNER_ARIA_LABEL,
|
|
1562
1566
|
"aria-busy": isOpeningPreferences,
|
|
1563
1567
|
className: className ?? classNames?.root,
|
|
1564
1568
|
style: style ?? DEFAULT_STYLE,
|
|
@@ -1630,7 +1634,7 @@ function FFIDCookieBanner({
|
|
|
1630
1634
|
void handleOpenPreferences();
|
|
1631
1635
|
},
|
|
1632
1636
|
"data-testid": "ffid-cookie-banner-preferences",
|
|
1633
|
-
children: pendingAction === "preferences" ?
|
|
1637
|
+
children: pendingAction === "preferences" ? preferencesLoadingLabel ?? DEFAULT_PREFERENCES_LOADING_LABEL : preferencesLabel ?? "\u8A73\u7D30\u8A2D\u5B9A"
|
|
1634
1638
|
}
|
|
1635
1639
|
),
|
|
1636
1640
|
/* @__PURE__ */ jsx(
|
|
@@ -1659,6 +1663,13 @@ function FFIDCookieBanner({
|
|
|
1659
1663
|
);
|
|
1660
1664
|
}
|
|
1661
1665
|
var FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1666
|
+
var DEFAULT_SETTINGS_TITLE = "Cookie \u8A2D\u5B9A";
|
|
1667
|
+
var DEFAULT_SETTINGS_BUTTON_LABELS = {
|
|
1668
|
+
save: "\u5909\u66F4\u3092\u4FDD\u5B58",
|
|
1669
|
+
saving: "\u4FDD\u5B58\u4E2D...",
|
|
1670
|
+
withdraw: "\u3059\u3079\u3066\u64A4\u56DE",
|
|
1671
|
+
withdrawing: "\u64A4\u56DE\u4E2D..."
|
|
1672
|
+
};
|
|
1662
1673
|
var DEFAULT_BACKDROP_STYLE = {
|
|
1663
1674
|
position: "fixed",
|
|
1664
1675
|
inset: 0,
|
|
@@ -1692,7 +1703,15 @@ function FFIDCookieSettings({
|
|
|
1692
1703
|
className,
|
|
1693
1704
|
classNames,
|
|
1694
1705
|
open,
|
|
1695
|
-
showWithdrawButton = true
|
|
1706
|
+
showWithdrawButton = true,
|
|
1707
|
+
title,
|
|
1708
|
+
ariaLabel,
|
|
1709
|
+
saveLabel,
|
|
1710
|
+
savingLabel,
|
|
1711
|
+
withdrawLabel,
|
|
1712
|
+
withdrawingLabel,
|
|
1713
|
+
categoryLabels,
|
|
1714
|
+
categoryDescriptions
|
|
1696
1715
|
}) {
|
|
1697
1716
|
const { isPreferencesOpen, closePreferences, error } = useFFIDConsent();
|
|
1698
1717
|
const { state, categoryMetadata, save, withdraw } = useFFIDConsentPreferences();
|
|
@@ -1787,6 +1806,7 @@ function FFIDCookieSettings({
|
|
|
1787
1806
|
};
|
|
1788
1807
|
}, [visible, closePreferences]);
|
|
1789
1808
|
if (!visible) return null;
|
|
1809
|
+
const heading = title ?? DEFAULT_SETTINGS_TITLE;
|
|
1790
1810
|
return /* @__PURE__ */ jsx(
|
|
1791
1811
|
"div",
|
|
1792
1812
|
{
|
|
@@ -1803,14 +1823,14 @@ function FFIDCookieSettings({
|
|
|
1803
1823
|
{
|
|
1804
1824
|
role: "dialog",
|
|
1805
1825
|
"aria-modal": "true",
|
|
1806
|
-
"aria-label":
|
|
1826
|
+
"aria-label": ariaLabel ?? heading,
|
|
1807
1827
|
"aria-busy": isSubmitting,
|
|
1808
1828
|
className: className ?? classNames?.root,
|
|
1809
1829
|
style: DEFAULT_MODAL_STYLE,
|
|
1810
1830
|
"data-testid": "ffid-cookie-settings",
|
|
1811
1831
|
ref: modalRef,
|
|
1812
1832
|
children: [
|
|
1813
|
-
/* @__PURE__ */ jsx("header", { className: classNames?.header, children: /* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: "18px" }, children:
|
|
1833
|
+
/* @__PURE__ */ jsx("header", { className: classNames?.header, children: /* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: "18px" }, children: heading }) }),
|
|
1814
1834
|
/* @__PURE__ */ jsx("div", { children: (categoryMetadata ?? FALLBACK_CATEGORIES).map((cat) => {
|
|
1815
1835
|
const checked = cat.code === "necessary" ? true : draft[cat.code] ?? false;
|
|
1816
1836
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1820,8 +1840,8 @@ function FFIDCookieSettings({
|
|
|
1820
1840
|
style: ROW_STYLE,
|
|
1821
1841
|
children: [
|
|
1822
1842
|
/* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
|
|
1823
|
-
/* @__PURE__ */ jsx("div", { style: { fontWeight: 600, fontSize: "14px" }, children: cat.label }),
|
|
1824
|
-
/* @__PURE__ */ jsx("div", { style: { color: "#6b7280", fontSize: "13px" }, children: cat.description })
|
|
1843
|
+
/* @__PURE__ */ jsx("div", { style: { fontWeight: 600, fontSize: "14px" }, children: categoryLabels?.[cat.code] ?? cat.label }),
|
|
1844
|
+
/* @__PURE__ */ jsx("div", { style: { color: "#6b7280", fontSize: "13px" }, children: categoryDescriptions?.[cat.code] ?? cat.description })
|
|
1825
1845
|
] }),
|
|
1826
1846
|
/* @__PURE__ */ jsx(
|
|
1827
1847
|
"input",
|
|
@@ -1877,7 +1897,7 @@ function FFIDCookieSettings({
|
|
|
1877
1897
|
cursor: isSubmitting ? "wait" : "pointer"
|
|
1878
1898
|
},
|
|
1879
1899
|
"data-testid": "ffid-cookie-settings-withdraw",
|
|
1880
|
-
children: pendingAction === "withdraw" ?
|
|
1900
|
+
children: pendingAction === "withdraw" ? withdrawingLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.withdrawing : withdrawLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.withdraw
|
|
1881
1901
|
}
|
|
1882
1902
|
) : null,
|
|
1883
1903
|
/* @__PURE__ */ jsx(
|
|
@@ -1899,7 +1919,7 @@ function FFIDCookieSettings({
|
|
|
1899
1919
|
cursor: isSubmitting ? "wait" : "pointer"
|
|
1900
1920
|
},
|
|
1901
1921
|
"data-testid": "ffid-cookie-settings-save",
|
|
1902
|
-
children: pendingAction === "save" ?
|
|
1922
|
+
children: pendingAction === "save" ? savingLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.saving : saveLabel ?? DEFAULT_SETTINGS_BUTTON_LABELS.save
|
|
1903
1923
|
}
|
|
1904
1924
|
)
|
|
1905
1925
|
]
|