@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.
Files changed (32) hide show
  1. package/README.md +1010 -960
  2. package/dist/{FFIDCookieLink-Bwr0FBrV.d.cts → FFIDCookieLink-yt5SUr-W.d.cts} +47 -3
  3. package/dist/{FFIDCookieLink-Bwr0FBrV.d.ts → FFIDCookieLink-yt5SUr-W.d.ts} +47 -3
  4. package/dist/{chunk-CPXTIRB6.cjs → chunk-2LU2F3F2.cjs} +283 -11
  5. package/dist/{chunk-P5A6C5SK.js → chunk-OXW6QSTO.js} +270 -12
  6. package/dist/{chunk-XELXXL2F.cjs → chunk-RZCQ22GH.cjs} +29 -9
  7. package/dist/{chunk-RHBZHSRD.js → chunk-S2AEBJRX.js} +29 -9
  8. package/dist/components/index.cjs +8 -8
  9. package/dist/components/index.d.cts +1 -1
  10. package/dist/components/index.d.ts +1 -1
  11. package/dist/components/index.js +1 -1
  12. package/dist/consent/index.cjs +63 -63
  13. package/dist/consent/index.d.cts +2 -2
  14. package/dist/consent/index.d.ts +2 -2
  15. package/dist/consent/index.js +1 -1
  16. package/dist/{ffid-client-B0cORHac.d.ts → ffid-client-5uxXRgIO.d.ts} +686 -376
  17. package/dist/{ffid-client-6aLs9Fqc.d.cts → ffid-client-CumygXXz.d.cts} +686 -376
  18. package/dist/{index-BG7g99pK.d.ts → index-KjewcNn1.d.cts} +813 -2
  19. package/dist/{index-BG7g99pK.d.cts → index-KjewcNn1.d.ts} +813 -2
  20. package/dist/index.cjs +151 -95
  21. package/dist/index.d.cts +116 -505
  22. package/dist/index.d.ts +116 -505
  23. package/dist/index.js +3 -3
  24. package/dist/server/index.cjs +253 -11
  25. package/dist/server/index.d.cts +2 -2
  26. package/dist/server/index.d.ts +2 -2
  27. package/dist/server/index.js +253 -11
  28. package/dist/server/test/index.d.cts +1 -1
  29. package/dist/server/test/index.d.ts +1 -1
  30. package/dist/webhooks/index.d.cts +112 -7
  31. package/dist/webhooks/index.d.ts +112 -7
  32. package/package.json +131 -131
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { useFFIDContext, useSubscription } from './chunk-P5A6C5SK.js';
2
- 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, clearAgencyInviteToken, cleanupStateStorage as clearState, 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, useSubscription, validatePublishedCatalog, withSubscription } from './chunk-P5A6C5SK.js';
3
- export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, CONSENT_DISMISSAL_TIMESTAMP_KEY, COOKIE_VERSION, DEFAULT_CONSENT_ERROR_MESSAGES, FFIDAnalyticsProvider, FFIDConsentError, FFIDCookieBanner, FFIDCookieLink, FFIDCookieSettings, FFID_CONSENT_ERROR_CODES, clearConsentDismissalTimestamp, decodeConsentCookie, encodeConsentCookie, readConsentCookie, readConsentDismissalTimestamp, useFFIDConsent, useFFIDConsentPreferences, writeConsentCookie, writeConsentDismissalTimestamp } from './chunk-RHBZHSRD.js';
1
+ import { useFFIDContext, useSubscription } from './chunk-OXW6QSTO.js';
2
+ 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, clearAgencyInviteToken, cleanupStateStorage as clearState, 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, useSubscription, validatePublishedCatalog, withSubscription } from './chunk-OXW6QSTO.js';
3
+ export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, CONSENT_DISMISSAL_TIMESTAMP_KEY, COOKIE_VERSION, DEFAULT_CONSENT_ERROR_MESSAGES, FFIDAnalyticsProvider, FFIDConsentError, FFIDCookieBanner, FFIDCookieLink, FFIDCookieSettings, FFID_CONSENT_ERROR_CODES, clearConsentDismissalTimestamp, decodeConsentCookie, encodeConsentCookie, readConsentCookie, readConsentDismissalTimestamp, useFFIDConsent, useFFIDConsentPreferences, writeConsentCookie, writeConsentDismissalTimestamp } from './chunk-S2AEBJRX.js';
4
4
  import { useEffect, useRef } from 'react';
5
5
  import { jsx, Fragment } from 'react/jsx-runtime';
6
6
 
@@ -223,18 +223,16 @@ function mapUserinfoSubscriptionToSession(userinfo, serviceCode) {
223
223
  ];
224
224
  }
225
225
  var JWKS_ENDPOINT = "/.well-known/jwks.json";
226
- var LEGACY_JWT_ISSUER = "https://id.feelflow.net";
227
226
  var JWT_ALGORITHM = "ES256";
228
227
  var JWT_CLOCK_TOLERANCE_SECONDS = 30;
229
- function resolveAcceptedIssuers(baseUrl) {
230
- const deployedOrigin = new URL(baseUrl).origin;
231
- return deployedOrigin === LEGACY_JWT_ISSUER ? [LEGACY_JWT_ISSUER] : [deployedOrigin, LEGACY_JWT_ISSUER];
228
+ function resolveAcceptedIssuer(baseUrl) {
229
+ return new URL(baseUrl).origin;
232
230
  }
233
231
  function createJwtVerifier(deps) {
234
232
  const { baseUrl, serviceCode, logger, createError, errorCodes } = deps;
235
233
  const jwksUrl = new URL(JWKS_ENDPOINT, baseUrl);
236
234
  const jwks = jose.createRemoteJWKSet(jwksUrl);
237
- const acceptedIssuers = resolveAcceptedIssuers(baseUrl);
235
+ const acceptedIssuer = resolveAcceptedIssuer(baseUrl);
238
236
  async function verifyJwt(accessToken) {
239
237
  if (!accessToken || !accessToken.trim()) {
240
238
  return {
@@ -247,7 +245,7 @@ function createJwtVerifier(deps) {
247
245
  try {
248
246
  const { payload } = await jose.jwtVerify(accessToken, jwks, {
249
247
  algorithms: [JWT_ALGORITHM],
250
- issuer: acceptedIssuers,
248
+ issuer: acceptedIssuer,
251
249
  audience: serviceCode,
252
250
  clockTolerance: JWT_CLOCK_TOLERANCE_SECONDS
253
251
  });
@@ -1373,7 +1371,7 @@ var FFID_ORGANIZATION_PROFILE_ERROR_CODES = {
1373
1371
  };
1374
1372
 
1375
1373
  // src/client/version-check.ts
1376
- var SDK_VERSION = "8.1.0";
1374
+ var SDK_VERSION = "10.0.0";
1377
1375
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
1378
1376
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
1379
1377
  function sdkHeaders() {
@@ -1729,8 +1727,11 @@ function createProvisioningMethods(deps) {
1729
1727
  }
1730
1728
 
1731
1729
  // src/client/seat-methods.ts
1730
+ function seatSummaryEndpoint(subscriptionId) {
1731
+ return `/api/v1/subscriptions/ext/${encodeURIComponent(subscriptionId)}/seats`;
1732
+ }
1732
1733
  function seatsEndpoint(subscriptionId) {
1733
- return `/api/v1/subscriptions/ext/${encodeURIComponent(subscriptionId)}/seats/assignments`;
1734
+ return `${seatSummaryEndpoint(subscriptionId)}/assignments`;
1734
1735
  }
1735
1736
  function createSeatMethods(deps) {
1736
1737
  const { fetchWithAuth, createError } = deps;
@@ -1740,6 +1741,12 @@ function createSeatMethods(deps) {
1740
1741
  }
1741
1742
  return fetchWithAuth(seatsEndpoint(params.subscriptionId));
1742
1743
  }
1744
+ async function getSeats(subscriptionId) {
1745
+ if (!subscriptionId || !subscriptionId.trim()) {
1746
+ return { error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059") };
1747
+ }
1748
+ return fetchWithAuth(seatSummaryEndpoint(subscriptionId));
1749
+ }
1743
1750
  async function assignSeats(params) {
1744
1751
  if (!params.subscriptionId) {
1745
1752
  return { error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059") };
@@ -1764,7 +1771,7 @@ function createSeatMethods(deps) {
1764
1771
  { method: "DELETE" }
1765
1772
  );
1766
1773
  }
1767
- return { listSeatAssignments, assignSeats, unassignSeat };
1774
+ return { listSeatAssignments, getSeats, assignSeats, unassignSeat };
1768
1775
  }
1769
1776
 
1770
1777
  // src/client/profile-methods.ts
@@ -3491,6 +3498,222 @@ function createInquiryMethods(deps) {
3491
3498
  return { create };
3492
3499
  }
3493
3500
 
3501
+ // src/types/credits.ts
3502
+ var FFID_CREDITS_CONSUME_MIN_AMOUNT = 1;
3503
+ var FFID_CREDITS_CONSUME_MAX_AMOUNT = 1e6;
3504
+ var FFID_CREDITS_METADATA_MAX_BYTES = 4096;
3505
+ var FFID_CREDITS_HISTORY_MIN_LIMIT = 1;
3506
+ var FFID_CREDITS_HISTORY_MAX_LIMIT = 100;
3507
+ var FFID_CREDIT_PACK_MIN_QUANTITY = 1;
3508
+ var FFID_CREDIT_PACK_MAX_QUANTITY = 10;
3509
+ var FFID_CREDITS_IDEMPOTENCY_KEY_PATTERN = /^[A-Za-z0-9._:-]{8,128}$/;
3510
+ var FFID_CREDITS_FEATURE_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;
3511
+ var FFID_CREDIT_HISTORY_TYPES = ["grant", "consumption", "revocation"];
3512
+
3513
+ // src/client/credits-methods.ts
3514
+ var EXT_SUBSCRIPTIONS_PATH = "/api/v1/subscriptions/ext";
3515
+ var CREDIT_PACKS_ENDPOINT = `${EXT_SUBSCRIPTIONS_PATH}/credits/packs`;
3516
+ var CREDIT_PACK_CHECKOUT_ENDPOINT = `${CREDIT_PACKS_ENDPOINT}/checkout`;
3517
+ var PORTAL_SUBSCRIPTION_PATH = "/subscriptions";
3518
+ var BUY_CREDITS_QUERY = { key: "purchase", value: "credits" };
3519
+ var ORG_QUERY_KEY = "org";
3520
+ var FFID_CONTRACT_ID_PREFIX = "ffid:";
3521
+ var STRIPE_SUBSCRIPTION_ID_PREFIX = "sub_";
3522
+ var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3523
+ var VALIDATION_ERROR = "VALIDATION_ERROR";
3524
+ var FORBIDDEN = "FORBIDDEN";
3525
+ var utf8Encoder = new TextEncoder();
3526
+ function creditsEndpoint(subscriptionId, action) {
3527
+ return `${EXT_SUBSCRIPTIONS_PATH}/${encodeURIComponent(subscriptionId)}/credits/${action}`;
3528
+ }
3529
+ function isPlainObject2(value) {
3530
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3531
+ }
3532
+ function isIntegerInRange(value, min, max) {
3533
+ return typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
3534
+ }
3535
+ function createCreditsMethods(deps) {
3536
+ const { fetchWithAuth, createError, authMode, baseUrl, serviceCode, logger } = deps;
3537
+ function validationError(field, message) {
3538
+ return { error: { ...createError(VALIDATION_ERROR, message), details: { field } } };
3539
+ }
3540
+ function forbidden(reason, message) {
3541
+ return { error: { ...createError(FORBIDDEN, message), details: { reason } } };
3542
+ }
3543
+ function missingSubscriptionId(subscriptionId) {
3544
+ return subscriptionId && subscriptionId.trim() ? null : validationError("subscriptionId", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059");
3545
+ }
3546
+ async function getBalance(subscriptionId) {
3547
+ const invalid = missingSubscriptionId(subscriptionId);
3548
+ if (invalid) return invalid;
3549
+ return fetchWithAuth(creditsEndpoint(subscriptionId, "balance"));
3550
+ }
3551
+ async function listHistory(subscriptionId, options = {}) {
3552
+ const invalid = missingSubscriptionId(subscriptionId);
3553
+ if (invalid) return invalid;
3554
+ const query = new URLSearchParams();
3555
+ if (options.cursor !== void 0) query.set("cursor", options.cursor);
3556
+ if (options.limit !== void 0) {
3557
+ if (!isIntegerInRange(options.limit, FFID_CREDITS_HISTORY_MIN_LIMIT, FFID_CREDITS_HISTORY_MAX_LIMIT)) {
3558
+ return validationError(
3559
+ "limit",
3560
+ `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`
3561
+ );
3562
+ }
3563
+ query.set("limit", String(options.limit));
3564
+ }
3565
+ if (options.type !== void 0) {
3566
+ if (!FFID_CREDIT_HISTORY_TYPES.includes(options.type)) {
3567
+ return validationError("type", `type \u306F ${FFID_CREDIT_HISTORY_TYPES.join(" / ")} \u306E\u3044\u305A\u308C\u304B\u3067\u3059`);
3568
+ }
3569
+ query.set("type", options.type);
3570
+ }
3571
+ const qs = query.toString();
3572
+ return fetchWithAuth(
3573
+ `${creditsEndpoint(subscriptionId, "history")}${qs ? `?${qs}` : ""}`
3574
+ );
3575
+ }
3576
+ async function listPacks(packServiceCode) {
3577
+ const resolved = packServiceCode ?? (authMode === "service-key" ? void 0 : serviceCode);
3578
+ if (resolved !== void 0 && !resolved.trim()) {
3579
+ return validationError("serviceCode", "serviceCode \u3092\u6307\u5B9A\u3059\u308B\u5834\u5408\u3001\u7A7A\u6587\u5B57\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093");
3580
+ }
3581
+ const qs = resolved === void 0 ? "" : `?${new URLSearchParams({ serviceCode: resolved }).toString()}`;
3582
+ return fetchWithAuth(`${CREDIT_PACKS_ENDPOINT}${qs}`);
3583
+ }
3584
+ async function createPackCheckout(params) {
3585
+ if (authMode !== "token") {
3586
+ return forbidden(
3587
+ "bearer_required",
3588
+ "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"
3589
+ );
3590
+ }
3591
+ const invalid = missingSubscriptionId(params.subscriptionId);
3592
+ if (invalid) return invalid;
3593
+ for (const field of ["packCode", "successUrl", "cancelUrl"]) {
3594
+ if (!params[field] || !params[field].trim()) {
3595
+ return validationError(field, `${field} \u306F\u5FC5\u9808\u3067\u3059`);
3596
+ }
3597
+ }
3598
+ if (params.quantity !== void 0 && !isIntegerInRange(params.quantity, FFID_CREDIT_PACK_MIN_QUANTITY, FFID_CREDIT_PACK_MAX_QUANTITY)) {
3599
+ return validationError(
3600
+ "quantity",
3601
+ `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`
3602
+ );
3603
+ }
3604
+ const body = {
3605
+ subscriptionId: params.subscriptionId,
3606
+ packCode: params.packCode,
3607
+ successUrl: params.successUrl,
3608
+ cancelUrl: params.cancelUrl
3609
+ };
3610
+ if (params.quantity !== void 0) body.quantity = params.quantity;
3611
+ return fetchWithAuth(CREDIT_PACK_CHECKOUT_ENDPOINT, {
3612
+ method: "POST",
3613
+ body: JSON.stringify(body)
3614
+ });
3615
+ }
3616
+ function validateConsume(params) {
3617
+ const invalid = missingSubscriptionId(params.subscriptionId);
3618
+ if (invalid) return invalid;
3619
+ if (!isIntegerInRange(params.amount, FFID_CREDITS_CONSUME_MIN_AMOUNT, FFID_CREDITS_CONSUME_MAX_AMOUNT)) {
3620
+ return validationError(
3621
+ "amount",
3622
+ `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`
3623
+ );
3624
+ }
3625
+ if (typeof params.idempotencyKey !== "string" || !FFID_CREDITS_IDEMPOTENCY_KEY_PATTERN.test(params.idempotencyKey)) {
3626
+ return validationError(
3627
+ "idempotencyKey",
3628
+ "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"
3629
+ );
3630
+ }
3631
+ if (typeof params.feature !== "string" || !FFID_CREDITS_FEATURE_PATTERN.test(params.feature)) {
3632
+ 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");
3633
+ }
3634
+ if (params.metadata !== void 0) {
3635
+ if (!isPlainObject2(params.metadata)) {
3636
+ return validationError("metadata", "metadata \u306F JSON \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059");
3637
+ }
3638
+ let serialized;
3639
+ try {
3640
+ serialized = JSON.stringify(params.metadata);
3641
+ } catch {
3642
+ 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");
3643
+ }
3644
+ if (utf8Encoder.encode(serialized).byteLength > FFID_CREDITS_METADATA_MAX_BYTES) {
3645
+ 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`);
3646
+ }
3647
+ }
3648
+ if (params.userId !== void 0 && !UUID_PATTERN.test(params.userId)) {
3649
+ return validationError("userId", "userId \u306F\u6709\u52B9\u306AUUID\u5F62\u5F0F\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059");
3650
+ }
3651
+ return null;
3652
+ }
3653
+ async function consume(params) {
3654
+ if (authMode !== "service-key") {
3655
+ return forbidden(
3656
+ "api_key_required",
3657
+ "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"
3658
+ );
3659
+ }
3660
+ const invalid = validateConsume(params);
3661
+ if (invalid) return invalid;
3662
+ const body = {
3663
+ amount: params.amount,
3664
+ idempotencyKey: params.idempotencyKey,
3665
+ feature: params.feature
3666
+ };
3667
+ if (params.metadata !== void 0) body.metadata = params.metadata;
3668
+ if (params.userId !== void 0) body.userId = params.userId;
3669
+ return fetchWithAuth(creditsEndpoint(params.subscriptionId, "consume"), {
3670
+ method: "POST",
3671
+ body: JSON.stringify(body)
3672
+ });
3673
+ }
3674
+ function getBuyCreditsUrl(params) {
3675
+ const raw = params.subscriptionId?.trim() ?? "";
3676
+ if (raw.startsWith(STRIPE_SUBSCRIPTION_ID_PREFIX)) {
3677
+ return validationError(
3678
+ "subscriptionId",
3679
+ "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"
3680
+ );
3681
+ }
3682
+ const uuid = raw.startsWith(FFID_CONTRACT_ID_PREFIX) ? raw.slice(FFID_CONTRACT_ID_PREFIX.length) : raw;
3683
+ if (!UUID_PATTERN.test(uuid)) {
3684
+ 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");
3685
+ }
3686
+ const query = new URLSearchParams({ [BUY_CREDITS_QUERY.key]: BUY_CREDITS_QUERY.value });
3687
+ if (params.orgId !== void 0 && params.orgId.trim()) {
3688
+ query.set(ORG_QUERY_KEY, params.orgId);
3689
+ }
3690
+ return { data: `${baseUrl}${PORTAL_SUBSCRIPTION_PATH}/${encodeURIComponent(uuid)}?${query.toString()}` };
3691
+ }
3692
+ function redirectToBuyCredits(params) {
3693
+ const result = getBuyCreditsUrl(params);
3694
+ if (result.error) {
3695
+ logger.warn("redirectToBuyCredits:", result.error.message);
3696
+ return { success: false, error: result.error.message };
3697
+ }
3698
+ if (typeof window === "undefined") {
3699
+ logger.warn("SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093");
3700
+ return { success: false, error: "SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093" };
3701
+ }
3702
+ logger.debug("Redirecting to buy credits:", result.data);
3703
+ window.location.href = result.data;
3704
+ return { success: true };
3705
+ }
3706
+ return {
3707
+ getBalance,
3708
+ listHistory,
3709
+ listPacks,
3710
+ createPackCheckout,
3711
+ consume,
3712
+ getBuyCreditsUrl,
3713
+ redirectToBuyCredits
3714
+ };
3715
+ }
3716
+
3494
3717
  // src/subscriptions/userinfo-helpers.ts
3495
3718
  var ACCESS_GRANTING_EFFECTIVE_STATUSES = [
3496
3719
  "active",
@@ -3549,7 +3772,12 @@ function toServiceAccessDecision(response, allowGrace) {
3549
3772
  planCode: response.planCode,
3550
3773
  currentPeriodEnd: response.currentPeriodEnd,
3551
3774
  gracePeriodEndsAt: response.gracePeriodEndsAt ?? null,
3552
- reactivatable: response.reactivatable ?? false
3775
+ reactivatable: response.reactivatable ?? false,
3776
+ // Informational pass-through (10.0.0). Deliberately not part of hasAccess /
3777
+ // denialReason: credits and the member limit never gate access (CREDITS_API §1-5).
3778
+ ...response.pricingModel !== void 0 ? { pricingModel: response.pricingModel } : {},
3779
+ ...response.credits !== void 0 ? { credits: response.credits } : {},
3780
+ ...response.memberLimitReached !== void 0 ? { memberLimitReached: response.memberLimitReached } : {}
3553
3781
  };
3554
3782
  }
3555
3783
  function failClosedServiceAccessDecision(params, error) {
@@ -3911,7 +4139,7 @@ function createFFIDClient(config) {
3911
4139
  fetchWithAuth,
3912
4140
  createError
3913
4141
  });
3914
- const { listSeatAssignments, assignSeats, unassignSeat } = createSeatMethods({
4142
+ const { listSeatAssignments, getSeats, assignSeats, unassignSeat } = createSeatMethods({
3915
4143
  fetchWithAuth,
3916
4144
  createError
3917
4145
  });
@@ -4018,6 +4246,14 @@ function createFFIDClient(config) {
4018
4246
  fetchWithAuth,
4019
4247
  createError
4020
4248
  });
4249
+ const credits = createCreditsMethods({
4250
+ fetchWithAuth,
4251
+ createError,
4252
+ authMode,
4253
+ baseUrl,
4254
+ serviceCode: config.serviceCode,
4255
+ logger
4256
+ });
4021
4257
  const verifyAccessToken = createVerifyAccessToken({
4022
4258
  authMode,
4023
4259
  baseUrl,
@@ -4073,6 +4309,7 @@ function createFFIDClient(config) {
4073
4309
  getInvoice,
4074
4310
  retryPayment,
4075
4311
  listSeatAssignments,
4312
+ getSeats,
4076
4313
  assignSeats,
4077
4314
  unassignSeat,
4078
4315
  listPlans,
@@ -4083,13 +4320,16 @@ function createFFIDClient(config) {
4083
4320
  cancelSubscription,
4084
4321
  cancelPendingDowngrade,
4085
4322
  previewPlanChange,
4323
+ /** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
4086
4324
  previewSeatChange,
4087
4325
  verifyAccessToken,
4088
4326
  getSubscribeUrl,
4089
4327
  redirectToSubscribe,
4090
4328
  getChangePlanUrl,
4091
4329
  redirectToChangePlan,
4330
+ /** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
4092
4331
  getChangeSeatsUrl,
4332
+ /** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
4093
4333
  redirectToChangeSeats,
4094
4334
  getRecoverPaymentUrl,
4095
4335
  redirectToRecoverPayment,
@@ -4105,6 +4345,8 @@ function createFFIDClient(config) {
4105
4345
  newsletter,
4106
4346
  /** Inquiry methods (create) */
4107
4347
  inquiry,
4348
+ /** Credits methods for flat plans (consume / balance / history / packs) */
4349
+ credits,
4108
4350
  /** Token store (token mode only) */
4109
4351
  tokenStore,
4110
4352
  /**
@@ -1,5 +1,5 @@
1
- import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo, f as FFIDCatalogEnvironment, g as FFIDBillingInterval, h as FFIDTaxBehavior, i as FFIDPublishedCatalog } from '../ffid-client-6aLs9Fqc.cjs';
2
- export { j as FFIDAddMemberParams, k as FFIDAddMemberRequest, l as FFIDAddMemberResponse, m as FFIDAllowedLogoMimeType, n as FFIDAssignableMemberRole, o as FFIDCacheConfig, p as FFIDCatalogPublication, q as FFIDCatalogPublicationStatus, r as FFIDClient, s as FFIDCompanySizeCode, t as FFIDConfig, u as FFIDIndustryCode, v as FFIDListMembersResponse, w as FFIDListingConsentInput, x as FFIDLogoWallEntry, y as FFIDLogoWallResponse, z as FFIDMemberRole, A as FFIDOrganization, B as FFIDOrganizationLogoUploadResponse, C as FFIDOrganizationMember, D as FFIDOrganizationProfile, E as FFIDOrganizationProfileErrorCode, G as FFIDOrganizationProfileResponse, H as FFIDOtpSendResponse, I as FFIDOtpVerifyResponse, J as FFIDPasswordResetConfirmResponse, K as FFIDPasswordResetResponse, L as FFIDPasswordResetVerifyResponse, M as FFIDProfileCallOptions, N as FFIDProvisionMemberPlan, O as FFIDProvisionMemberPlanStatus, P as FFIDProvisionMemberResult, Q as FFIDProvisionMemberStatus, R as FFIDProvisionOrganizationDryRun, S as FFIDProvisionOrganizationMemberInput, T as FFIDProvisionOrganizationOutcome, U as FFIDProvisionOrganizationParams, V as FFIDProvisionOrganizationResponse, W as FFIDProvisionUserDryRun, X as FFIDProvisionUserOutcome, Y as FFIDProvisionUserParams, Z as FFIDProvisionUserProfileInput, _ as FFIDProvisionUserResponse, $ as FFIDProvisionedOrganization, a0 as FFIDProvisionedUser, a1 as FFIDPublishedPlan, a2 as FFIDRemoveMemberResponse, a3 as FFIDResetSessionResponse, a4 as FFIDSubscription, a5 as FFIDUpdateMemberRoleResponse, a6 as FFIDUpdateUserProfileRequest, a7 as FFIDUploadOrganizationLogoParams, a8 as FFIDUpsertOrganizationProfileParams, a9 as FFIDUpsertOrganizationProfileRequest, aa as FFIDUser, ab as FFIDUserProfile, ac as FFID_ALLOWED_ORGANIZATION_LOGO_MIME_TYPES, ad as FFID_CATALOG_ENVIRONMENTS, ae as FFID_CATALOG_PUBLICATION_STATUSES, af as FFID_COMPANY_SIZE_CODES, ag as FFID_INDUSTRY_CODES, ah as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES, ai as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB, aj as FFID_ORGANIZATION_PROFILE_ERROR_CODES, ak as TokenData, al as TokenStore, am as createFFIDClient, an as createTokenStore } from '../ffid-client-6aLs9Fqc.cjs';
1
+ import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo, f as FFIDCatalogEnvironment, g as FFIDBillingInterval, h as FFIDTaxBehavior, i as FFIDPublishedCatalog } from '../ffid-client-CumygXXz.cjs';
2
+ export { j as FFIDAddMemberParams, k as FFIDAddMemberRequest, l as FFIDAddMemberResponse, m as FFIDAllowedLogoMimeType, n as FFIDAssignableMemberRole, o as FFIDCacheConfig, p as FFIDCatalogPublication, q as FFIDCatalogPublicationStatus, r as FFIDClient, s as FFIDCompanySizeCode, t as FFIDConfig, u as FFIDIndustryCode, v as FFIDListMembersResponse, w as FFIDListingConsentInput, x as FFIDLogoWallEntry, y as FFIDLogoWallResponse, z as FFIDMemberRole, A as FFIDOrganization, B as FFIDOrganizationLogoUploadResponse, C as FFIDOrganizationMember, D as FFIDOrganizationProfile, E as FFIDOrganizationProfileErrorCode, G as FFIDOrganizationProfileResponse, H as FFIDOtpSendResponse, I as FFIDOtpVerifyResponse, J as FFIDPasswordResetConfirmResponse, K as FFIDPasswordResetResponse, L as FFIDPasswordResetVerifyResponse, M as FFIDProfileCallOptions, N as FFIDProvisionMemberPlan, O as FFIDProvisionMemberPlanStatus, P as FFIDProvisionMemberResult, Q as FFIDProvisionMemberStatus, R as FFIDProvisionOrganizationDryRun, S as FFIDProvisionOrganizationMemberInput, T as FFIDProvisionOrganizationOutcome, U as FFIDProvisionOrganizationParams, V as FFIDProvisionOrganizationResponse, W as FFIDProvisionUserDryRun, X as FFIDProvisionUserOutcome, Y as FFIDProvisionUserParams, Z as FFIDProvisionUserProfileInput, _ as FFIDProvisionUserResponse, $ as FFIDProvisionedOrganization, a0 as FFIDProvisionedUser, a1 as FFIDPublishedPlan, a2 as FFIDRemoveMemberResponse, a3 as FFIDResetSessionResponse, a4 as FFIDSubscription, a5 as FFIDUpdateMemberRoleResponse, a6 as FFIDUpdateUserProfileRequest, a7 as FFIDUploadOrganizationLogoParams, a8 as FFIDUpsertOrganizationProfileParams, a9 as FFIDUpsertOrganizationProfileRequest, aa as FFIDUser, ab as FFIDUserProfile, ac as FFID_ALLOWED_ORGANIZATION_LOGO_MIME_TYPES, ad as FFID_CATALOG_ENVIRONMENTS, ae as FFID_CATALOG_PUBLICATION_STATUSES, af as FFID_COMPANY_SIZE_CODES, ag as FFID_INDUSTRY_CODES, ah as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES, ai as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB, aj as FFID_ORGANIZATION_PROFILE_ERROR_CODES, ak as TokenData, al as TokenStore, am as createFFIDClient, an as createTokenStore } from '../ffid-client-CumygXXz.cjs';
3
3
  export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constants-Ce2eXQtB.cjs';
4
4
  import { z } from 'zod';
5
5
  import '../types-Cjb9J0rL.cjs';
@@ -1,5 +1,5 @@
1
- import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo, f as FFIDCatalogEnvironment, g as FFIDBillingInterval, h as FFIDTaxBehavior, i as FFIDPublishedCatalog } from '../ffid-client-B0cORHac.js';
2
- export { j as FFIDAddMemberParams, k as FFIDAddMemberRequest, l as FFIDAddMemberResponse, m as FFIDAllowedLogoMimeType, n as FFIDAssignableMemberRole, o as FFIDCacheConfig, p as FFIDCatalogPublication, q as FFIDCatalogPublicationStatus, r as FFIDClient, s as FFIDCompanySizeCode, t as FFIDConfig, u as FFIDIndustryCode, v as FFIDListMembersResponse, w as FFIDListingConsentInput, x as FFIDLogoWallEntry, y as FFIDLogoWallResponse, z as FFIDMemberRole, A as FFIDOrganization, B as FFIDOrganizationLogoUploadResponse, C as FFIDOrganizationMember, D as FFIDOrganizationProfile, E as FFIDOrganizationProfileErrorCode, G as FFIDOrganizationProfileResponse, H as FFIDOtpSendResponse, I as FFIDOtpVerifyResponse, J as FFIDPasswordResetConfirmResponse, K as FFIDPasswordResetResponse, L as FFIDPasswordResetVerifyResponse, M as FFIDProfileCallOptions, N as FFIDProvisionMemberPlan, O as FFIDProvisionMemberPlanStatus, P as FFIDProvisionMemberResult, Q as FFIDProvisionMemberStatus, R as FFIDProvisionOrganizationDryRun, S as FFIDProvisionOrganizationMemberInput, T as FFIDProvisionOrganizationOutcome, U as FFIDProvisionOrganizationParams, V as FFIDProvisionOrganizationResponse, W as FFIDProvisionUserDryRun, X as FFIDProvisionUserOutcome, Y as FFIDProvisionUserParams, Z as FFIDProvisionUserProfileInput, _ as FFIDProvisionUserResponse, $ as FFIDProvisionedOrganization, a0 as FFIDProvisionedUser, a1 as FFIDPublishedPlan, a2 as FFIDRemoveMemberResponse, a3 as FFIDResetSessionResponse, a4 as FFIDSubscription, a5 as FFIDUpdateMemberRoleResponse, a6 as FFIDUpdateUserProfileRequest, a7 as FFIDUploadOrganizationLogoParams, a8 as FFIDUpsertOrganizationProfileParams, a9 as FFIDUpsertOrganizationProfileRequest, aa as FFIDUser, ab as FFIDUserProfile, ac as FFID_ALLOWED_ORGANIZATION_LOGO_MIME_TYPES, ad as FFID_CATALOG_ENVIRONMENTS, ae as FFID_CATALOG_PUBLICATION_STATUSES, af as FFID_COMPANY_SIZE_CODES, ag as FFID_INDUSTRY_CODES, ah as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES, ai as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB, aj as FFID_ORGANIZATION_PROFILE_ERROR_CODES, ak as TokenData, al as TokenStore, am as createFFIDClient, an as createTokenStore } from '../ffid-client-B0cORHac.js';
1
+ import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo, f as FFIDCatalogEnvironment, g as FFIDBillingInterval, h as FFIDTaxBehavior, i as FFIDPublishedCatalog } from '../ffid-client-5uxXRgIO.js';
2
+ export { j as FFIDAddMemberParams, k as FFIDAddMemberRequest, l as FFIDAddMemberResponse, m as FFIDAllowedLogoMimeType, n as FFIDAssignableMemberRole, o as FFIDCacheConfig, p as FFIDCatalogPublication, q as FFIDCatalogPublicationStatus, r as FFIDClient, s as FFIDCompanySizeCode, t as FFIDConfig, u as FFIDIndustryCode, v as FFIDListMembersResponse, w as FFIDListingConsentInput, x as FFIDLogoWallEntry, y as FFIDLogoWallResponse, z as FFIDMemberRole, A as FFIDOrganization, B as FFIDOrganizationLogoUploadResponse, C as FFIDOrganizationMember, D as FFIDOrganizationProfile, E as FFIDOrganizationProfileErrorCode, G as FFIDOrganizationProfileResponse, H as FFIDOtpSendResponse, I as FFIDOtpVerifyResponse, J as FFIDPasswordResetConfirmResponse, K as FFIDPasswordResetResponse, L as FFIDPasswordResetVerifyResponse, M as FFIDProfileCallOptions, N as FFIDProvisionMemberPlan, O as FFIDProvisionMemberPlanStatus, P as FFIDProvisionMemberResult, Q as FFIDProvisionMemberStatus, R as FFIDProvisionOrganizationDryRun, S as FFIDProvisionOrganizationMemberInput, T as FFIDProvisionOrganizationOutcome, U as FFIDProvisionOrganizationParams, V as FFIDProvisionOrganizationResponse, W as FFIDProvisionUserDryRun, X as FFIDProvisionUserOutcome, Y as FFIDProvisionUserParams, Z as FFIDProvisionUserProfileInput, _ as FFIDProvisionUserResponse, $ as FFIDProvisionedOrganization, a0 as FFIDProvisionedUser, a1 as FFIDPublishedPlan, a2 as FFIDRemoveMemberResponse, a3 as FFIDResetSessionResponse, a4 as FFIDSubscription, a5 as FFIDUpdateMemberRoleResponse, a6 as FFIDUpdateUserProfileRequest, a7 as FFIDUploadOrganizationLogoParams, a8 as FFIDUpsertOrganizationProfileParams, a9 as FFIDUpsertOrganizationProfileRequest, aa as FFIDUser, ab as FFIDUserProfile, ac as FFID_ALLOWED_ORGANIZATION_LOGO_MIME_TYPES, ad as FFID_CATALOG_ENVIRONMENTS, ae as FFID_CATALOG_PUBLICATION_STATUSES, af as FFID_COMPANY_SIZE_CODES, ag as FFID_INDUSTRY_CODES, ah as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES, ai as FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB, aj as FFID_ORGANIZATION_PROFILE_ERROR_CODES, ak as TokenData, al as TokenStore, am as createFFIDClient, an as createTokenStore } from '../ffid-client-5uxXRgIO.js';
3
3
  export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constants-Ce2eXQtB.js';
4
4
  import { z } from 'zod';
5
5
  import '../types-Cjb9J0rL.js';