@feelflow/ffid-sdk 9.0.0 → 10.1.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useFFIDContext, useSubscription } from './chunk-TUXIJEEZ.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-TUXIJEEZ.js';
1
+ import { useFFIDContext, useSubscription } from './chunk-ITSQIAO5.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_OAUTH_DENIAL_REASONS, 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, getFFIDAuthorizationError, handleRedirectCallback, hasAccessFromUserinfo, hashCanonicalJson, isBlockedFromUserinfo, isFFIDInquiryAcquisitionSource, isFFIDInquiryCategorySite2026, isFFIDOAuthDenialReason, normalizeRedirectUri, readAgencyInviteCookie, readAgencyInviteToken, redactAgencyInviteToken, retrieveCodeVerifier, retrieveState, sha256Hex, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useSubscription, validatePublishedCatalog, withSubscription } from './chunk-ITSQIAO5.js';
3
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';
@@ -1371,7 +1371,7 @@ var FFID_ORGANIZATION_PROFILE_ERROR_CODES = {
1371
1371
  };
1372
1372
 
1373
1373
  // src/client/version-check.ts
1374
- var SDK_VERSION = "9.0.0";
1374
+ var SDK_VERSION = "10.1.0";
1375
1375
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
1376
1376
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
1377
1377
  function sdkHeaders() {
@@ -1727,8 +1727,11 @@ function createProvisioningMethods(deps) {
1727
1727
  }
1728
1728
 
1729
1729
  // src/client/seat-methods.ts
1730
+ function seatSummaryEndpoint(subscriptionId) {
1731
+ return `/api/v1/subscriptions/ext/${encodeURIComponent(subscriptionId)}/seats`;
1732
+ }
1730
1733
  function seatsEndpoint(subscriptionId) {
1731
- return `/api/v1/subscriptions/ext/${encodeURIComponent(subscriptionId)}/seats/assignments`;
1734
+ return `${seatSummaryEndpoint(subscriptionId)}/assignments`;
1732
1735
  }
1733
1736
  function createSeatMethods(deps) {
1734
1737
  const { fetchWithAuth, createError } = deps;
@@ -1738,6 +1741,12 @@ function createSeatMethods(deps) {
1738
1741
  }
1739
1742
  return fetchWithAuth(seatsEndpoint(params.subscriptionId));
1740
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
+ }
1741
1750
  async function assignSeats(params) {
1742
1751
  if (!params.subscriptionId) {
1743
1752
  return { error: createError("VALIDATION_ERROR", "subscriptionId \u306F\u5FC5\u9808\u3067\u3059") };
@@ -1762,7 +1771,7 @@ function createSeatMethods(deps) {
1762
1771
  { method: "DELETE" }
1763
1772
  );
1764
1773
  }
1765
- return { listSeatAssignments, assignSeats, unassignSeat };
1774
+ return { listSeatAssignments, getSeats, assignSeats, unassignSeat };
1766
1775
  }
1767
1776
 
1768
1777
  // src/client/profile-methods.ts
@@ -3489,6 +3498,222 @@ function createInquiryMethods(deps) {
3489
3498
  return { create };
3490
3499
  }
3491
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
+
3492
3717
  // src/subscriptions/userinfo-helpers.ts
3493
3718
  var ACCESS_GRANTING_EFFECTIVE_STATUSES = [
3494
3719
  "active",
@@ -3547,7 +3772,12 @@ function toServiceAccessDecision(response, allowGrace) {
3547
3772
  planCode: response.planCode,
3548
3773
  currentPeriodEnd: response.currentPeriodEnd,
3549
3774
  gracePeriodEndsAt: response.gracePeriodEndsAt ?? null,
3550
- 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 } : {}
3551
3781
  };
3552
3782
  }
3553
3783
  function failClosedServiceAccessDecision(params, error) {
@@ -3909,7 +4139,7 @@ function createFFIDClient(config) {
3909
4139
  fetchWithAuth,
3910
4140
  createError
3911
4141
  });
3912
- const { listSeatAssignments, assignSeats, unassignSeat } = createSeatMethods({
4142
+ const { listSeatAssignments, getSeats, assignSeats, unassignSeat } = createSeatMethods({
3913
4143
  fetchWithAuth,
3914
4144
  createError
3915
4145
  });
@@ -4016,6 +4246,14 @@ function createFFIDClient(config) {
4016
4246
  fetchWithAuth,
4017
4247
  createError
4018
4248
  });
4249
+ const credits = createCreditsMethods({
4250
+ fetchWithAuth,
4251
+ createError,
4252
+ authMode,
4253
+ baseUrl,
4254
+ serviceCode: config.serviceCode,
4255
+ logger
4256
+ });
4019
4257
  const verifyAccessToken = createVerifyAccessToken({
4020
4258
  authMode,
4021
4259
  baseUrl,
@@ -4071,6 +4309,7 @@ function createFFIDClient(config) {
4071
4309
  getInvoice,
4072
4310
  retryPayment,
4073
4311
  listSeatAssignments,
4312
+ getSeats,
4074
4313
  assignSeats,
4075
4314
  unassignSeat,
4076
4315
  listPlans,
@@ -4081,13 +4320,16 @@ function createFFIDClient(config) {
4081
4320
  cancelSubscription,
4082
4321
  cancelPendingDowngrade,
4083
4322
  previewPlanChange,
4323
+ /** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
4084
4324
  previewSeatChange,
4085
4325
  verifyAccessToken,
4086
4326
  getSubscribeUrl,
4087
4327
  redirectToSubscribe,
4088
4328
  getChangePlanUrl,
4089
4329
  redirectToChangePlan,
4330
+ /** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
4090
4331
  getChangeSeatsUrl,
4332
+ /** @deprecated 10.0.0: per_seat (praxis) only; removed in 11.0.0 */
4091
4333
  redirectToChangeSeats,
4092
4334
  getRecoverPaymentUrl,
4093
4335
  redirectToRecoverPayment,
@@ -4103,6 +4345,8 @@ function createFFIDClient(config) {
4103
4345
  newsletter,
4104
4346
  /** Inquiry methods (create) */
4105
4347
  inquiry,
4348
+ /** Credits methods for flat plans (consume / balance / history / packs) */
4349
+ credits,
4106
4350
  /** Token store (token mode only) */
4107
4351
  tokenStore,
4108
4352
  /**
@@ -4121,6 +4365,50 @@ function createFFIDClient(config) {
4121
4365
  };
4122
4366
  }
4123
4367
 
4368
+ // src/client/authorization-error.ts
4369
+ var FFID_OAUTH_DENIAL_REASONS = [
4370
+ /** The user is not a member of the organization */
4371
+ "no_membership",
4372
+ /** The organization has no usable subscription for the service */
4373
+ "no_active_subscription",
4374
+ /** The organization has a subscription, but the user has no seat in it */
4375
+ "no_seat_assignment",
4376
+ /** The subscription has expired (canceled / past due beyond grace) */
4377
+ "subscription_expired",
4378
+ /** The flat plan's member limit is full, so no seat could be given */
4379
+ "member_limit_reached"
4380
+ ];
4381
+ function isFFIDOAuthDenialReason(value) {
4382
+ return typeof value === "string" && FFID_OAUTH_DENIAL_REASONS.includes(value);
4383
+ }
4384
+ var DEFAULT_AUTHORIZATION_ERROR_MESSAGE = "\u8A8D\u53EF\u30B5\u30FC\u30D0\u30FC\u304C\u30A8\u30E9\u30FC\u3092\u8FD4\u3057\u307E\u3057\u305F";
4385
+ function buildAuthorizationError(params) {
4386
+ const oauthError = params.get("error");
4387
+ if (!oauthError) return null;
4388
+ const rawReason = params.get("denial_reason");
4389
+ const errorDescription = params.get("error_description");
4390
+ const details = {
4391
+ source: "authorization",
4392
+ denialReason: isFFIDOAuthDenialReason(rawReason) ? rawReason : null,
4393
+ errorDescription
4394
+ };
4395
+ return {
4396
+ code: oauthError,
4397
+ message: errorDescription ?? DEFAULT_AUTHORIZATION_ERROR_MESSAGE,
4398
+ details: { ...details }
4399
+ };
4400
+ }
4401
+ function getFFIDAuthorizationError(error) {
4402
+ const details = error?.details;
4403
+ if (!error || !details || details.source !== "authorization") return null;
4404
+ const description = details.errorDescription;
4405
+ return {
4406
+ oauthError: error.code,
4407
+ denialReason: isFFIDOAuthDenialReason(details.denialReason) ? details.denialReason : null,
4408
+ errorDescription: typeof description === "string" ? description : null
4409
+ };
4410
+ }
4411
+
4124
4412
  // src/client/cache/memory-cache-adapter.ts
4125
4413
  var MS_PER_SECOND2 = 1e3;
4126
4414
  function createMemoryCacheAdapter() {
@@ -4411,14 +4699,9 @@ function createServerAuthClient(config) {
4411
4699
  }
4412
4700
  };
4413
4701
  }
4414
- const errorParam = url.searchParams.get("error");
4415
- if (errorParam) {
4416
- return {
4417
- error: {
4418
- code: errorParam,
4419
- message: url.searchParams.get("error_description") ?? "\u8A8D\u53EF\u30B5\u30FC\u30D0\u30FC\u304C\u30A8\u30E9\u30FC\u3092\u8FD4\u3057\u307E\u3057\u305F"
4420
- }
4421
- };
4702
+ const authorizationError = buildAuthorizationError(url.searchParams);
4703
+ if (authorizationError) {
4704
+ return { error: authorizationError };
4422
4705
  }
4423
4706
  const code = url.searchParams.get("code");
4424
4707
  if (!code) {
@@ -4530,6 +4813,7 @@ exports.FFID_ERROR_CODES = FFID_ERROR_CODES;
4530
4813
  exports.FFID_INDUSTRY_CODES = FFID_INDUSTRY_CODES;
4531
4814
  exports.FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES = FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_BYTES;
4532
4815
  exports.FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB = FFID_MAX_ORGANIZATION_LOGO_FILE_SIZE_MB;
4816
+ exports.FFID_OAUTH_DENIAL_REASONS = FFID_OAUTH_DENIAL_REASONS;
4533
4817
  exports.FFID_ORGANIZATION_PROFILE_ERROR_CODES = FFID_ORGANIZATION_PROFILE_ERROR_CODES;
4534
4818
  exports.FFID_SESSION_COOKIE_NAME = FFID_SESSION_COOKIE_NAME;
4535
4819
  exports.canonicalizeCatalogValue = canonicalizeCatalogValue;
@@ -4548,9 +4832,11 @@ exports.createVerifyAccessToken = createVerifyAccessToken;
4548
4832
  exports.decodeConsentCookie = decodeConsentCookie;
4549
4833
  exports.encodeConsentCookie = encodeConsentCookie;
4550
4834
  exports.generateServerState = generateServerState;
4835
+ exports.getFFIDAuthorizationError = getFFIDAuthorizationError;
4551
4836
  exports.getFFIDConsentFromCookieHeader = getFFIDConsentFromCookieHeader;
4552
4837
  exports.getFFIDConsentFromCookies = getFFIDConsentFromCookies;
4553
4838
  exports.hashCanonicalJson = hashCanonicalJson;
4839
+ exports.isFFIDOAuthDenialReason = isFFIDOAuthDenialReason;
4554
4840
  exports.sessionCookies = sessionCookies;
4555
4841
  exports.sha256Hex = sha256Hex;
4556
4842
  exports.validatePublishedCatalog = validatePublishedCatalog;
@@ -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 FFIDError, a as FFIDLogger, 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-qcfCWLfs.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-qcfCWLfs.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';
@@ -31,6 +31,77 @@ declare const FFID_ERROR_CODES: {
31
31
  */
32
32
  type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
33
33
 
34
+ /**
35
+ * OAuth authorization errors returned to the service's `redirect_uri` (#6523)
36
+ *
37
+ * When FFID's `/oauth/authorize` refuses a user, it redirects back with
38
+ * `error=<OAuth error>&error_description=...&state=...` (RFC 6749 §4.1.2.1). For
39
+ * subscription / seat denials it also adds the FFID extension `denial_reason`
40
+ * (#6498), so a service can tell "no seat in this organization" from "no
41
+ * subscription" without parsing `error_description`.
42
+ *
43
+ * Both callback paths build the same {@link FFIDError} from those params:
44
+ * - `handleRedirectCallback` / token-mode `FFIDProvider` (browser, PKCE)
45
+ * - `createServerAuthClient().handleCallback` (confidential / BFF)
46
+ *
47
+ * `error.code` is the OAuth `error` value verbatim (e.g. `access_denied`), and
48
+ * `error.details` is {@link FFIDAuthorizationErrorDetails}. Read it with
49
+ * {@link getFFIDAuthorizationError}.
50
+ *
51
+ * This module has no browser dependency so the server entry can share it.
52
+ */
53
+
54
+ /**
55
+ * Values of FFID's `denial_reason` (the authorize error redirect and the
56
+ * `/oauth/userinfo` 403; `/oauth/introspect` only answers `active: false`). Kept
57
+ * identical to the FFID server's `DENIAL_REASONS` by a test in the FFID repository.
58
+ *
59
+ * This is a different vocabulary from `FFIDServiceAccessDenialReason`
60
+ * (`checkServiceAccess()`), which is derived from the subscription status.
61
+ */
62
+ declare const FFID_OAUTH_DENIAL_REASONS: readonly ["no_membership", "no_active_subscription", "no_seat_assignment", "subscription_expired", "member_limit_reached"];
63
+ type FFIDOAuthDenialReason = (typeof FFID_OAUTH_DENIAL_REASONS)[number];
64
+ /** Runtime guard for {@link FFIDOAuthDenialReason}. Unknown values are `false`. */
65
+ declare function isFFIDOAuthDenialReason(value: unknown): value is FFIDOAuthDenialReason;
66
+ /** `FFIDError.details` of an authorization error */
67
+ interface FFIDAuthorizationErrorDetails {
68
+ /** Marks the error as an authorize redirect error (vs. token / network errors) */
69
+ source: 'authorization';
70
+ /**
71
+ * FFID's `denial_reason`. `null` when FFID did not send one (any OAuth error other
72
+ * than a subscription / seat denial) **or** sent a value this SDK version does not
73
+ * know — the error itself is still returned, only the reason is unknown.
74
+ */
75
+ denialReason: FFIDOAuthDenialReason | null;
76
+ /**
77
+ * `error_description` as sent — short ASCII English meant for logs. The same text
78
+ * is `error.message` (when FFID sent one), so show end users guidance chosen by
79
+ * `denialReason` rather than the message itself.
80
+ */
81
+ errorDescription: string | null;
82
+ }
83
+ /** An authorization error read back by {@link getFFIDAuthorizationError} */
84
+ interface FFIDAuthorizationError {
85
+ /** The OAuth `error` value, e.g. `access_denied`, `login_required` */
86
+ oauthError: string;
87
+ denialReason: FFIDOAuthDenialReason | null;
88
+ errorDescription: string | null;
89
+ }
90
+ /**
91
+ * Read an authorization error (and FFID's `denial_reason`) from an {@link FFIDError},
92
+ * e.g. `useFFID().error` or the result of `handleRedirectCallback` /
93
+ * `createServerAuthClient().handleCallback`. Returns `null` for any other error.
94
+ *
95
+ * ```ts
96
+ * const denial = getFFIDAuthorizationError(error)
97
+ * if (denial?.denialReason === 'no_seat_assignment') {
98
+ * // Ask an organization owner / admin to add the user. Do not call login() again:
99
+ * // FFID would refuse the same way.
100
+ * }
101
+ * ```
102
+ */
103
+ declare function getFFIDAuthorizationError(error: FFIDError | null | undefined): FFIDAuthorizationError | null;
104
+
34
105
  /** Token verification - verifyAccessToken() implementation */
35
106
 
36
107
  /** Dependencies required by verifyAccessToken */
@@ -566,4 +637,4 @@ declare function computeScopeHash(input: FFIDScopeHashInput): Promise<string>;
566
637
  */
567
638
  declare function validatePublishedCatalog(catalog: unknown): asserts catalog is FFIDPublishedCatalog;
568
639
 
569
- export { ALL_DENIED_EXCEPT_NECESSARY, type BuildAuthorizeUrlOptions, type BuildAuthorizeUrlResult, CATALOG_HASH_PATTERN, CONSENT_COOKIE_NAME, COOKIE_VERSION, type CookieOptions, FFIDCacheAdapter, type FFIDCanonicalJsonValue, FFIDCatalogEnvironment, FFIDCatalogHashError, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, FFIDOAuthUserInfo, type FFIDPaymentConfiguration, FFIDPublishedCatalog, type FFIDScopeHashInput, type FFIDScopeHashPlan, FFIDTaxBehavior, type FFIDTaxConfiguration, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, FFID_SESSION_COOKIE_NAME, type HandleCallbackInput, type KVNamespaceLike, type ServerAuthClient, type ServerAuthConfig, type ServerSessionTokens, type ServerTokenResult, canonicalizeCatalogValue, computeFFIDCheckoutCopyHash, computeLegalDisclosureHash, computePaymentConfigurationHash, computePraxisCopyHash, computeScopeHash, computeTaxConfigurationHash, createKVCacheAdapter, createMemoryCacheAdapter, createServerAuthClient, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, generateServerState, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies, hashCanonicalJson, sessionCookies, sha256Hex, validatePublishedCatalog };
640
+ export { ALL_DENIED_EXCEPT_NECESSARY, type BuildAuthorizeUrlOptions, type BuildAuthorizeUrlResult, CATALOG_HASH_PATTERN, CONSENT_COOKIE_NAME, COOKIE_VERSION, type CookieOptions, type FFIDAuthorizationError, type FFIDAuthorizationErrorDetails, FFIDCacheAdapter, type FFIDCanonicalJsonValue, FFIDCatalogEnvironment, FFIDCatalogHashError, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, type FFIDOAuthDenialReason, FFIDOAuthUserInfo, type FFIDPaymentConfiguration, FFIDPublishedCatalog, type FFIDScopeHashInput, type FFIDScopeHashPlan, FFIDTaxBehavior, type FFIDTaxConfiguration, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, FFID_OAUTH_DENIAL_REASONS, FFID_SESSION_COOKIE_NAME, type HandleCallbackInput, type KVNamespaceLike, type ServerAuthClient, type ServerAuthConfig, type ServerSessionTokens, type ServerTokenResult, canonicalizeCatalogValue, computeFFIDCheckoutCopyHash, computeLegalDisclosureHash, computePaymentConfigurationHash, computePraxisCopyHash, computeScopeHash, computeTaxConfigurationHash, createKVCacheAdapter, createMemoryCacheAdapter, createServerAuthClient, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, generateServerState, getFFIDAuthorizationError, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies, hashCanonicalJson, isFFIDOAuthDenialReason, sessionCookies, sha256Hex, validatePublishedCatalog };
@@ -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 FFIDError, a as FFIDLogger, 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-DUbQLYTN.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-DUbQLYTN.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';
@@ -31,6 +31,77 @@ declare const FFID_ERROR_CODES: {
31
31
  */
32
32
  type FFIDErrorCode = (typeof FFID_ERROR_CODES)[keyof typeof FFID_ERROR_CODES];
33
33
 
34
+ /**
35
+ * OAuth authorization errors returned to the service's `redirect_uri` (#6523)
36
+ *
37
+ * When FFID's `/oauth/authorize` refuses a user, it redirects back with
38
+ * `error=<OAuth error>&error_description=...&state=...` (RFC 6749 §4.1.2.1). For
39
+ * subscription / seat denials it also adds the FFID extension `denial_reason`
40
+ * (#6498), so a service can tell "no seat in this organization" from "no
41
+ * subscription" without parsing `error_description`.
42
+ *
43
+ * Both callback paths build the same {@link FFIDError} from those params:
44
+ * - `handleRedirectCallback` / token-mode `FFIDProvider` (browser, PKCE)
45
+ * - `createServerAuthClient().handleCallback` (confidential / BFF)
46
+ *
47
+ * `error.code` is the OAuth `error` value verbatim (e.g. `access_denied`), and
48
+ * `error.details` is {@link FFIDAuthorizationErrorDetails}. Read it with
49
+ * {@link getFFIDAuthorizationError}.
50
+ *
51
+ * This module has no browser dependency so the server entry can share it.
52
+ */
53
+
54
+ /**
55
+ * Values of FFID's `denial_reason` (the authorize error redirect and the
56
+ * `/oauth/userinfo` 403; `/oauth/introspect` only answers `active: false`). Kept
57
+ * identical to the FFID server's `DENIAL_REASONS` by a test in the FFID repository.
58
+ *
59
+ * This is a different vocabulary from `FFIDServiceAccessDenialReason`
60
+ * (`checkServiceAccess()`), which is derived from the subscription status.
61
+ */
62
+ declare const FFID_OAUTH_DENIAL_REASONS: readonly ["no_membership", "no_active_subscription", "no_seat_assignment", "subscription_expired", "member_limit_reached"];
63
+ type FFIDOAuthDenialReason = (typeof FFID_OAUTH_DENIAL_REASONS)[number];
64
+ /** Runtime guard for {@link FFIDOAuthDenialReason}. Unknown values are `false`. */
65
+ declare function isFFIDOAuthDenialReason(value: unknown): value is FFIDOAuthDenialReason;
66
+ /** `FFIDError.details` of an authorization error */
67
+ interface FFIDAuthorizationErrorDetails {
68
+ /** Marks the error as an authorize redirect error (vs. token / network errors) */
69
+ source: 'authorization';
70
+ /**
71
+ * FFID's `denial_reason`. `null` when FFID did not send one (any OAuth error other
72
+ * than a subscription / seat denial) **or** sent a value this SDK version does not
73
+ * know — the error itself is still returned, only the reason is unknown.
74
+ */
75
+ denialReason: FFIDOAuthDenialReason | null;
76
+ /**
77
+ * `error_description` as sent — short ASCII English meant for logs. The same text
78
+ * is `error.message` (when FFID sent one), so show end users guidance chosen by
79
+ * `denialReason` rather than the message itself.
80
+ */
81
+ errorDescription: string | null;
82
+ }
83
+ /** An authorization error read back by {@link getFFIDAuthorizationError} */
84
+ interface FFIDAuthorizationError {
85
+ /** The OAuth `error` value, e.g. `access_denied`, `login_required` */
86
+ oauthError: string;
87
+ denialReason: FFIDOAuthDenialReason | null;
88
+ errorDescription: string | null;
89
+ }
90
+ /**
91
+ * Read an authorization error (and FFID's `denial_reason`) from an {@link FFIDError},
92
+ * e.g. `useFFID().error` or the result of `handleRedirectCallback` /
93
+ * `createServerAuthClient().handleCallback`. Returns `null` for any other error.
94
+ *
95
+ * ```ts
96
+ * const denial = getFFIDAuthorizationError(error)
97
+ * if (denial?.denialReason === 'no_seat_assignment') {
98
+ * // Ask an organization owner / admin to add the user. Do not call login() again:
99
+ * // FFID would refuse the same way.
100
+ * }
101
+ * ```
102
+ */
103
+ declare function getFFIDAuthorizationError(error: FFIDError | null | undefined): FFIDAuthorizationError | null;
104
+
34
105
  /** Token verification - verifyAccessToken() implementation */
35
106
 
36
107
  /** Dependencies required by verifyAccessToken */
@@ -566,4 +637,4 @@ declare function computeScopeHash(input: FFIDScopeHashInput): Promise<string>;
566
637
  */
567
638
  declare function validatePublishedCatalog(catalog: unknown): asserts catalog is FFIDPublishedCatalog;
568
639
 
569
- export { ALL_DENIED_EXCEPT_NECESSARY, type BuildAuthorizeUrlOptions, type BuildAuthorizeUrlResult, CATALOG_HASH_PATTERN, CONSENT_COOKIE_NAME, COOKIE_VERSION, type CookieOptions, FFIDCacheAdapter, type FFIDCanonicalJsonValue, FFIDCatalogEnvironment, FFIDCatalogHashError, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, FFIDOAuthUserInfo, type FFIDPaymentConfiguration, FFIDPublishedCatalog, type FFIDScopeHashInput, type FFIDScopeHashPlan, FFIDTaxBehavior, type FFIDTaxConfiguration, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, FFID_SESSION_COOKIE_NAME, type HandleCallbackInput, type KVNamespaceLike, type ServerAuthClient, type ServerAuthConfig, type ServerSessionTokens, type ServerTokenResult, canonicalizeCatalogValue, computeFFIDCheckoutCopyHash, computeLegalDisclosureHash, computePaymentConfigurationHash, computePraxisCopyHash, computeScopeHash, computeTaxConfigurationHash, createKVCacheAdapter, createMemoryCacheAdapter, createServerAuthClient, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, generateServerState, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies, hashCanonicalJson, sessionCookies, sha256Hex, validatePublishedCatalog };
640
+ export { ALL_DENIED_EXCEPT_NECESSARY, type BuildAuthorizeUrlOptions, type BuildAuthorizeUrlResult, CATALOG_HASH_PATTERN, CONSENT_COOKIE_NAME, COOKIE_VERSION, type CookieOptions, type FFIDAuthorizationError, type FFIDAuthorizationErrorDetails, FFIDCacheAdapter, type FFIDCanonicalJsonValue, FFIDCatalogEnvironment, FFIDCatalogHashError, type FFIDConsentCategories, type FFIDConsentCategoryCode, type FFIDCookieStoreLike, type FFIDErrorCode, type FFIDOAuthDenialReason, FFIDOAuthUserInfo, type FFIDPaymentConfiguration, FFIDPublishedCatalog, type FFIDScopeHashInput, type FFIDScopeHashPlan, FFIDTaxBehavior, type FFIDTaxConfiguration, FFIDVerifyAccessTokenOptions, FFID_ERROR_CODES, FFID_OAUTH_DENIAL_REASONS, FFID_SESSION_COOKIE_NAME, type HandleCallbackInput, type KVNamespaceLike, type ServerAuthClient, type ServerAuthConfig, type ServerSessionTokens, type ServerTokenResult, canonicalizeCatalogValue, computeFFIDCheckoutCopyHash, computeLegalDisclosureHash, computePaymentConfigurationHash, computePraxisCopyHash, computeScopeHash, computeTaxConfigurationHash, createKVCacheAdapter, createMemoryCacheAdapter, createServerAuthClient, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, generateServerState, getFFIDAuthorizationError, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies, hashCanonicalJson, isFFIDOAuthDenialReason, sessionCookies, sha256Hex, validatePublishedCatalog };