@feelflow/ffid-sdk 5.24.3 → 5.27.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/{chunk-O3HGRALD.js → chunk-JZB2IM7Y.js} +433 -37
- package/dist/{chunk-AMVL7J2G.cjs → chunk-R4KUHR4S.cjs} +446 -36
- 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/{ffid-client-BjZphrz9.d.cts → ffid-client-BlVuH6ja.d.cts} +178 -41
- package/dist/{ffid-client-B-xjtrCb.d.ts → ffid-client-BqnzUmG7.d.ts} +178 -41
- package/dist/{index-BRMn6xT0.d.cts → index-D3S_Pkkv.d.cts} +26 -92
- package/dist/{index-BRMn6xT0.d.ts → index-D3S_Pkkv.d.ts} +26 -92
- package/dist/index.cjs +98 -42
- package/dist/index.d.cts +393 -3
- package/dist/index.d.ts +393 -3
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +281 -36
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +281 -36
- package/dist/server/test/index.d.cts +1 -1
- package/dist/server/test/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -114,6 +114,24 @@ function isSessionEligibleSubscriptionStatus(value) {
|
|
|
114
114
|
function hasOwnKey(value, key) {
|
|
115
115
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
116
116
|
}
|
|
117
|
+
function normalizeEntitlements(raw) {
|
|
118
|
+
if (!Array.isArray(raw)) return [];
|
|
119
|
+
return raw.flatMap((code) => {
|
|
120
|
+
if (typeof code !== "string") return [];
|
|
121
|
+
const trimmed = code.trim();
|
|
122
|
+
return trimmed.length > 0 ? [trimmed] : [];
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function normalizeSeatAssignmentClaim(raw, organizationId, subscriptionId) {
|
|
126
|
+
if (!raw || typeof raw !== "object") return null;
|
|
127
|
+
const { organization_id, subscription_id, status } = raw;
|
|
128
|
+
if (typeof organization_id !== "string" || typeof subscription_id !== "string" || typeof status !== "string" || !["active", "revoking", "revoked"].includes(status) || organization_id !== organizationId || subscription_id !== subscriptionId) return null;
|
|
129
|
+
return {
|
|
130
|
+
organizationId: organization_id,
|
|
131
|
+
subscriptionId: subscription_id,
|
|
132
|
+
status
|
|
133
|
+
};
|
|
134
|
+
}
|
|
117
135
|
function normalizeUserinfo(raw) {
|
|
118
136
|
const hasOrganizationId = hasOwnKey(raw, "organization_id");
|
|
119
137
|
const hasOrganizationName = hasOwnKey(raw, "organization_name");
|
|
@@ -147,6 +165,11 @@ function normalizeUserinfo(raw) {
|
|
|
147
165
|
organizationId: raw.subscription.organization_id ?? null,
|
|
148
166
|
organizationName: hasOwnKey(raw.subscription, "organization_name") ? raw.subscription.organization_name ?? null : null,
|
|
149
167
|
hasSeatAssignment: raw.subscription.has_seat_assignment ?? false,
|
|
168
|
+
seatAssignment: hasOwnKey(raw.subscription, "seat_assignment") ? normalizeSeatAssignmentClaim(
|
|
169
|
+
raw.subscription.seat_assignment,
|
|
170
|
+
raw.subscription.organization_id ?? null,
|
|
171
|
+
raw.subscription.subscription_id ?? null
|
|
172
|
+
) : void 0,
|
|
150
173
|
// #3464: legacy FFID (< this issue) omits the field on the wire.
|
|
151
174
|
// The "unknown" axis is unused — no consumer differentiates "server
|
|
152
175
|
// didn't tell us" from "definitely not scheduled" because the
|
|
@@ -154,7 +177,10 @@ function normalizeUserinfo(raw) {
|
|
|
154
177
|
// `'active_canceling'`) for legacy backends. Defaulting to `false`
|
|
155
178
|
// here keeps the downstream contract a plain boolean.
|
|
156
179
|
cancelAtPeriodEnd: raw.subscription.cancel_at_period_end ?? false,
|
|
157
|
-
currentPeriodEnd: raw.subscription.current_period_end ?? null
|
|
180
|
+
currentPeriodEnd: raw.subscription.current_period_end ?? null,
|
|
181
|
+
// #4333: legacy FFID (< this issue) omits the field on the wire; the
|
|
182
|
+
// guard defaults to `[]` so consumers always get a plain string[].
|
|
183
|
+
entitlements: normalizeEntitlements(raw.subscription.entitlements)
|
|
158
184
|
} : void 0
|
|
159
185
|
};
|
|
160
186
|
}
|
|
@@ -441,7 +467,12 @@ function createVerifyAccessToken(deps) {
|
|
|
441
467
|
member_role: introspectResponse.subscription.member_role,
|
|
442
468
|
organization_id: introspectResponse.subscription.organization_id,
|
|
443
469
|
organization_name: introspectResponse.subscription.organization_name ?? null,
|
|
444
|
-
has_seat_assignment: introspectResponse.subscription.has_seat_assignment ?? false
|
|
470
|
+
has_seat_assignment: introspectResponse.subscription.has_seat_assignment ?? false,
|
|
471
|
+
...Object.prototype.hasOwnProperty.call(introspectResponse.subscription, "seat_assignment") ? { seat_assignment: introspectResponse.subscription.seat_assignment } : {},
|
|
472
|
+
// #4333: forward pack entitlement codes through the introspect →
|
|
473
|
+
// userinfo normalization boundary. normalizeUserinfo guards the
|
|
474
|
+
// value, so an older FFID that omits it degrades to `[]`.
|
|
475
|
+
entitlements: introspectResponse.subscription.entitlements
|
|
445
476
|
}
|
|
446
477
|
} : base;
|
|
447
478
|
const userinfo = normalizeUserinfo(raw);
|
|
@@ -812,6 +843,364 @@ function createSubscriptionMethods(deps) {
|
|
|
812
843
|
};
|
|
813
844
|
}
|
|
814
845
|
|
|
846
|
+
// src/types/published-catalog.ts
|
|
847
|
+
var FFID_CATALOG_ENVIRONMENTS = ["staging", "production"];
|
|
848
|
+
var FFID_CATALOG_PUBLICATION_STATUSES = [
|
|
849
|
+
"approved",
|
|
850
|
+
"superseded",
|
|
851
|
+
"revoking",
|
|
852
|
+
"revoked"
|
|
853
|
+
];
|
|
854
|
+
|
|
855
|
+
// src/shared/catalog-hash.ts
|
|
856
|
+
var CATALOG_HASH_PATTERN = /^[0-9a-f]{64}$/;
|
|
857
|
+
var HEX_RADIX = 16;
|
|
858
|
+
var HEX_DIGITS_PER_BYTE = 2;
|
|
859
|
+
var FFIDCatalogHashError = class extends Error {
|
|
860
|
+
constructor(message) {
|
|
861
|
+
super(message);
|
|
862
|
+
this.name = "FFIDCatalogHashError";
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
function isPlainObject(value) {
|
|
866
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
867
|
+
return false;
|
|
868
|
+
}
|
|
869
|
+
const proto = Object.getPrototypeOf(value);
|
|
870
|
+
return proto === Object.prototype || proto === null;
|
|
871
|
+
}
|
|
872
|
+
function canonicalize(value, path) {
|
|
873
|
+
if (value === null) return "null";
|
|
874
|
+
switch (typeof value) {
|
|
875
|
+
case "string":
|
|
876
|
+
return JSON.stringify(value);
|
|
877
|
+
case "boolean":
|
|
878
|
+
return value ? "true" : "false";
|
|
879
|
+
case "number":
|
|
880
|
+
if (!Number.isFinite(value)) {
|
|
881
|
+
throw new FFIDCatalogHashError(
|
|
882
|
+
`canonicalize: non-finite number at ${path} \u2014 hashes require finite numbers`
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
return JSON.stringify(value);
|
|
886
|
+
case "undefined":
|
|
887
|
+
throw new FFIDCatalogHashError(
|
|
888
|
+
`canonicalize: undefined at ${path} \u2014 omit the key entirely or use null`
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
if (Array.isArray(value)) {
|
|
892
|
+
const items = value.map((item, index) => canonicalize(item, `${path}[${index}]`));
|
|
893
|
+
return `[${items.join(",")}]`;
|
|
894
|
+
}
|
|
895
|
+
if (isPlainObject(value)) {
|
|
896
|
+
const keys = Object.keys(value).sort();
|
|
897
|
+
const entries = [];
|
|
898
|
+
for (const key of keys) {
|
|
899
|
+
const child = value[key];
|
|
900
|
+
if (child === void 0) {
|
|
901
|
+
throw new FFIDCatalogHashError(
|
|
902
|
+
`canonicalize: undefined at ${path}.${key} \u2014 omit the key entirely or use null`
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
entries.push(`${JSON.stringify(key)}:${canonicalize(child, `${path}.${key}`)}`);
|
|
906
|
+
}
|
|
907
|
+
return `{${entries.join(",")}}`;
|
|
908
|
+
}
|
|
909
|
+
throw new FFIDCatalogHashError(
|
|
910
|
+
`canonicalize: unsupported value type (${typeof value}${typeof value === "object" ? `: ${Object.prototype.toString.call(value)}` : ""}) at ${path} \u2014 only JSON-plain values are hashable`
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
function canonicalizeCatalogValue(value) {
|
|
914
|
+
return canonicalize(value, "$");
|
|
915
|
+
}
|
|
916
|
+
async function sha256Hex(text) {
|
|
917
|
+
const subtle = globalThis.crypto?.subtle;
|
|
918
|
+
if (!subtle) {
|
|
919
|
+
throw new FFIDCatalogHashError(
|
|
920
|
+
"sha256Hex: Web Crypto (crypto.subtle) is not available in this runtime"
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
const digest = await subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
924
|
+
return Array.from(new Uint8Array(digest)).map((byte) => byte.toString(HEX_RADIX).padStart(HEX_DIGITS_PER_BYTE, "0")).join("");
|
|
925
|
+
}
|
|
926
|
+
async function hashCanonicalJson(value) {
|
|
927
|
+
return sha256Hex(canonicalizeCatalogValue(value));
|
|
928
|
+
}
|
|
929
|
+
function assertHashFormat(hash, field) {
|
|
930
|
+
if (!CATALOG_HASH_PATTERN.test(hash)) {
|
|
931
|
+
throw new FFIDCatalogHashError(
|
|
932
|
+
`${field} must be lowercase SHA-256 hex (64 chars), got: ${JSON.stringify(hash)}`
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
function normalizeStringSet(values) {
|
|
937
|
+
return [...new Set(values)].sort();
|
|
938
|
+
}
|
|
939
|
+
function compareByCodeUnits(a, b) {
|
|
940
|
+
if (a.code < b.code) return -1;
|
|
941
|
+
if (a.code > b.code) return 1;
|
|
942
|
+
return 0;
|
|
943
|
+
}
|
|
944
|
+
async function computePraxisCopyHash(presentation) {
|
|
945
|
+
return hashCanonicalJson(presentation);
|
|
946
|
+
}
|
|
947
|
+
async function computeFFIDCheckoutCopyHash(checkoutCopy) {
|
|
948
|
+
return hashCanonicalJson(checkoutCopy);
|
|
949
|
+
}
|
|
950
|
+
async function computeLegalDisclosureHash(canonicalText) {
|
|
951
|
+
return sha256Hex(canonicalText.replace(/\r\n?/g, "\n"));
|
|
952
|
+
}
|
|
953
|
+
async function computeTaxConfigurationHash(config) {
|
|
954
|
+
return hashCanonicalJson({
|
|
955
|
+
allowedCountries: normalizeStringSet(config.allowedCountries),
|
|
956
|
+
stripeTaxRegistrations: normalizeStringSet(config.stripeTaxRegistrations),
|
|
957
|
+
billingAddressRequired: config.billingAddressRequired,
|
|
958
|
+
planTaxCodes: config.planTaxCodes,
|
|
959
|
+
planTaxBehaviors: config.planTaxBehaviors
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
async function computePaymentConfigurationHash(config) {
|
|
963
|
+
return hashCanonicalJson({
|
|
964
|
+
environment: config.environment,
|
|
965
|
+
currency: config.currency,
|
|
966
|
+
paymentMethodTypes: normalizeStringSet(config.paymentMethodTypes),
|
|
967
|
+
dynamicPaymentMethodsEnabled: config.dynamicPaymentMethodsEnabled,
|
|
968
|
+
manualInvoiceAllowed: config.manualInvoiceAllowed,
|
|
969
|
+
customerBalanceAllowed: config.customerBalanceAllowed,
|
|
970
|
+
delayedPaymentMethodsAllowed: config.delayedPaymentMethodsAllowed,
|
|
971
|
+
customerInvoiceBalanceRequired: config.customerInvoiceBalanceRequired
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
async function computeScopeHash(input) {
|
|
975
|
+
assertHashFormat(input.praxisCopyHash, "praxisCopyHash");
|
|
976
|
+
assertHashFormat(input.ffidCheckoutCopyHash, "ffidCheckoutCopyHash");
|
|
977
|
+
assertHashFormat(input.legalDisclosureHash, "legalDisclosureHash");
|
|
978
|
+
assertHashFormat(input.taxConfigurationHash, "taxConfigurationHash");
|
|
979
|
+
assertHashFormat(input.paymentConfigurationHash, "paymentConfigurationHash");
|
|
980
|
+
const seenCodes = /* @__PURE__ */ new Set();
|
|
981
|
+
for (const plan of input.plans) {
|
|
982
|
+
if (seenCodes.has(plan.code)) {
|
|
983
|
+
throw new FFIDCatalogHashError(
|
|
984
|
+
`computeScopeHash: duplicate plan code ${JSON.stringify(plan.code)}`
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
seenCodes.add(plan.code);
|
|
988
|
+
}
|
|
989
|
+
const plans = [...input.plans].sort(compareByCodeUnits).map((plan) => ({
|
|
990
|
+
code: plan.code,
|
|
991
|
+
priceMonthly: plan.priceMonthly,
|
|
992
|
+
priceYearly: plan.priceYearly,
|
|
993
|
+
currency: plan.currency,
|
|
994
|
+
// Set semantics — interval order must not flip the digest.
|
|
995
|
+
billingIntervals: normalizeStringSet(plan.billingIntervals),
|
|
996
|
+
taxBehavior: plan.taxBehavior,
|
|
997
|
+
minSeats: plan.minSeats
|
|
998
|
+
}));
|
|
999
|
+
return hashCanonicalJson({
|
|
1000
|
+
plans,
|
|
1001
|
+
praxisCopyHash: input.praxisCopyHash,
|
|
1002
|
+
ffidCheckoutCopyHash: input.ffidCheckoutCopyHash,
|
|
1003
|
+
legalDisclosureHash: input.legalDisclosureHash,
|
|
1004
|
+
taxConfigurationHash: input.taxConfigurationHash,
|
|
1005
|
+
paymentConfigurationHash: input.paymentConfigurationHash
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// src/client/catalog-methods.ts
|
|
1010
|
+
var EXT_CATALOG_ENDPOINT = "/api/v1/subscriptions/ext/catalog";
|
|
1011
|
+
var MALFORMED_CATALOG_CODE = "MALFORMED_PUBLISHED_CATALOG";
|
|
1012
|
+
var PUBLICATION_STATUSES = new Set(
|
|
1013
|
+
FFID_CATALOG_PUBLICATION_STATUSES
|
|
1014
|
+
);
|
|
1015
|
+
var CATALOG_ENVIRONMENTS = new Set(FFID_CATALOG_ENVIRONMENTS);
|
|
1016
|
+
var BILLING_INTERVALS = /* @__PURE__ */ new Set(["monthly", "yearly"]);
|
|
1017
|
+
var TAX_BEHAVIORS = /* @__PURE__ */ new Set(["inclusive", "exclusive"]);
|
|
1018
|
+
var PUBLICATION_HASH_FIELDS = [
|
|
1019
|
+
"praxisCopyHash",
|
|
1020
|
+
"ffidCheckoutCopyHash",
|
|
1021
|
+
"legalDisclosureHash",
|
|
1022
|
+
"taxConfigurationHash",
|
|
1023
|
+
"paymentConfigurationHash",
|
|
1024
|
+
"scopeHash"
|
|
1025
|
+
];
|
|
1026
|
+
var PUBLICATION_REQUIRED_TIMESTAMP_FIELDS = ["reviewedAt", "effectiveAt"];
|
|
1027
|
+
var PUBLICATION_NULLABLE_TIMESTAMP_FIELDS = [
|
|
1028
|
+
"supersededAt",
|
|
1029
|
+
"sellThroughUntil",
|
|
1030
|
+
"revocationEffectiveAt"
|
|
1031
|
+
];
|
|
1032
|
+
function malformed(detail) {
|
|
1033
|
+
return new FFIDSDKError(
|
|
1034
|
+
MALFORMED_CATALOG_CODE,
|
|
1035
|
+
`SDK: server returned malformed PublishedCatalog \u2014 ${detail}`
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
function isNullableIsoString(value) {
|
|
1039
|
+
return value === null || typeof value === "string" && value.trim() !== "";
|
|
1040
|
+
}
|
|
1041
|
+
function isNonNegativeIntOrNull(value) {
|
|
1042
|
+
return value === null || typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
1043
|
+
}
|
|
1044
|
+
function validatePublishedPlan(plan, index) {
|
|
1045
|
+
if (plan === null || typeof plan !== "object") {
|
|
1046
|
+
throw malformed(`plans[${index}] must be an object`);
|
|
1047
|
+
}
|
|
1048
|
+
const record = plan;
|
|
1049
|
+
for (const key of Object.keys(record)) {
|
|
1050
|
+
if (/stripe/i.test(key)) {
|
|
1051
|
+
throw malformed(
|
|
1052
|
+
`plans[${index}] contains a Stripe identifier field (${JSON.stringify(key)}) \u2014 published catalogs must never expose Stripe IDs`
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
if (isBlankString(record.code)) {
|
|
1057
|
+
throw malformed(`plans[${index}].code must be a non-empty string`);
|
|
1058
|
+
}
|
|
1059
|
+
if (isBlankString(record.name)) {
|
|
1060
|
+
throw malformed(`plans[${index}].name must be a non-empty string`);
|
|
1061
|
+
}
|
|
1062
|
+
if (record.description !== null && typeof record.description !== "string") {
|
|
1063
|
+
throw malformed(`plans[${index}].description must be string or null`);
|
|
1064
|
+
}
|
|
1065
|
+
if (isBlankString(record.currency)) {
|
|
1066
|
+
throw malformed(`plans[${index}].currency must be a non-empty string`);
|
|
1067
|
+
}
|
|
1068
|
+
if (!isNonNegativeIntOrNull(record.priceMonthly)) {
|
|
1069
|
+
throw malformed(`plans[${index}].priceMonthly must be a non-negative integer or null`);
|
|
1070
|
+
}
|
|
1071
|
+
if (!isNonNegativeIntOrNull(record.priceYearly)) {
|
|
1072
|
+
throw malformed(`plans[${index}].priceYearly must be a non-negative integer or null`);
|
|
1073
|
+
}
|
|
1074
|
+
if (typeof record.taxBehavior !== "string" || !TAX_BEHAVIORS.has(record.taxBehavior)) {
|
|
1075
|
+
throw malformed(
|
|
1076
|
+
`plans[${index}].taxBehavior must be inclusive | exclusive (got ${JSON.stringify(record.taxBehavior)})`
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
const intervals = record.billingIntervals;
|
|
1080
|
+
if (!Array.isArray(intervals) || intervals.length === 0 || intervals.some((interval) => typeof interval !== "string" || !BILLING_INTERVALS.has(interval))) {
|
|
1081
|
+
throw malformed(
|
|
1082
|
+
`plans[${index}].billingIntervals must be a non-empty array of monthly | yearly`
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
if (intervals.includes("monthly") && record.priceMonthly === null) {
|
|
1086
|
+
throw malformed(`plans[${index}] offers monthly billing but priceMonthly is null`);
|
|
1087
|
+
}
|
|
1088
|
+
if (intervals.includes("yearly") && record.priceYearly === null) {
|
|
1089
|
+
throw malformed(`plans[${index}] offers yearly billing but priceYearly is null`);
|
|
1090
|
+
}
|
|
1091
|
+
if (typeof record.minSeats !== "number" || !Number.isInteger(record.minSeats) || record.minSeats < 1) {
|
|
1092
|
+
throw malformed(`plans[${index}].minSeats must be a positive integer`);
|
|
1093
|
+
}
|
|
1094
|
+
if (record.maxSeats !== null && (typeof record.maxSeats !== "number" || !Number.isInteger(record.maxSeats) || record.maxSeats < 1)) {
|
|
1095
|
+
throw malformed(`plans[${index}].maxSeats must be a positive integer or null`);
|
|
1096
|
+
}
|
|
1097
|
+
if (record.maxSeats !== null && record.maxSeats < record.minSeats) {
|
|
1098
|
+
throw malformed(`plans[${index}].maxSeats must be >= minSeats`);
|
|
1099
|
+
}
|
|
1100
|
+
if (typeof record.displayOrder !== "number" || !Number.isInteger(record.displayOrder)) {
|
|
1101
|
+
throw malformed(`plans[${index}].displayOrder must be an integer`);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
function validatePublishedCatalog(catalog) {
|
|
1105
|
+
if (catalog === null || typeof catalog !== "object") {
|
|
1106
|
+
throw malformed(
|
|
1107
|
+
`expected object, got ${catalog === null ? "null" : typeof catalog}`
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
const c = catalog;
|
|
1111
|
+
const service = c.service;
|
|
1112
|
+
if (service === null || typeof service !== "object") {
|
|
1113
|
+
throw malformed("service must be an object");
|
|
1114
|
+
}
|
|
1115
|
+
const s = service;
|
|
1116
|
+
if (isBlankString(s.code)) {
|
|
1117
|
+
throw malformed("service.code must be a non-empty string");
|
|
1118
|
+
}
|
|
1119
|
+
if (isBlankString(s.name)) {
|
|
1120
|
+
throw malformed("service.name must be a non-empty string");
|
|
1121
|
+
}
|
|
1122
|
+
if (isBlankString(c.catalogVersion)) {
|
|
1123
|
+
throw malformed("catalogVersion must be a non-empty string");
|
|
1124
|
+
}
|
|
1125
|
+
const publication = c.publication;
|
|
1126
|
+
if (publication === null || typeof publication !== "object") {
|
|
1127
|
+
throw malformed("publication must be an object");
|
|
1128
|
+
}
|
|
1129
|
+
const p = publication;
|
|
1130
|
+
if (isBlankString(p.serviceCode)) {
|
|
1131
|
+
throw malformed("publication.serviceCode must be a non-empty string");
|
|
1132
|
+
}
|
|
1133
|
+
if (typeof p.environment !== "string" || !CATALOG_ENVIRONMENTS.has(p.environment)) {
|
|
1134
|
+
throw malformed(
|
|
1135
|
+
`publication.environment must be staging | production (got ${JSON.stringify(p.environment)})`
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
if (p.catalogVersion !== c.catalogVersion) {
|
|
1139
|
+
throw malformed(
|
|
1140
|
+
`publication.catalogVersion (${JSON.stringify(p.catalogVersion)}) does not match top-level catalogVersion (${JSON.stringify(c.catalogVersion)})`
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
if (typeof p.status !== "string" || !PUBLICATION_STATUSES.has(p.status)) {
|
|
1144
|
+
throw malformed(
|
|
1145
|
+
`publication.status must be one of approved | superseded | revoking | revoked (got ${JSON.stringify(p.status)})`
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1148
|
+
for (const field of PUBLICATION_HASH_FIELDS) {
|
|
1149
|
+
const value = p[field];
|
|
1150
|
+
if (typeof value !== "string" || !CATALOG_HASH_PATTERN.test(value)) {
|
|
1151
|
+
throw malformed(`publication.${field} must be lowercase SHA-256 hex (64 chars)`);
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
if (typeof p.salesEpoch !== "number" || !Number.isInteger(p.salesEpoch) || p.salesEpoch < 1) {
|
|
1155
|
+
throw malformed(
|
|
1156
|
+
`publication.salesEpoch must be a positive integer (got ${JSON.stringify(p.salesEpoch)})`
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
if (isBlankString(p.approvalId)) {
|
|
1160
|
+
throw malformed("publication.approvalId must be a non-empty string");
|
|
1161
|
+
}
|
|
1162
|
+
for (const field of PUBLICATION_REQUIRED_TIMESTAMP_FIELDS) {
|
|
1163
|
+
if (isBlankString(p[field])) {
|
|
1164
|
+
throw malformed(`publication.${field} must be a non-empty ISO 8601 string`);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
for (const field of PUBLICATION_NULLABLE_TIMESTAMP_FIELDS) {
|
|
1168
|
+
if (!isNullableIsoString(p[field])) {
|
|
1169
|
+
throw malformed(`publication.${field} must be a non-empty ISO 8601 string or null`);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (!Array.isArray(c.plans)) {
|
|
1173
|
+
throw malformed(`plans must be an array (got ${typeof c.plans})`);
|
|
1174
|
+
}
|
|
1175
|
+
for (const [index, plan] of c.plans.entries()) {
|
|
1176
|
+
validatePublishedPlan(plan, index);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
function createCatalogMethods(deps) {
|
|
1180
|
+
const { fetchWithAuth, createError } = deps;
|
|
1181
|
+
async function getPublishedCatalog(serviceCode) {
|
|
1182
|
+
if (isBlankString(serviceCode)) {
|
|
1183
|
+
return {
|
|
1184
|
+
error: createError("VALIDATION_ERROR", "serviceCode \u306F\u5FC5\u9808\u3067\u3059")
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
const requestedCode = serviceCode.trim();
|
|
1188
|
+
const response = await fetchWithAuth(
|
|
1189
|
+
`${EXT_CATALOG_ENDPOINT}/${encodeURIComponent(requestedCode)}`
|
|
1190
|
+
);
|
|
1191
|
+
if (response.data !== void 0) {
|
|
1192
|
+
validatePublishedCatalog(response.data);
|
|
1193
|
+
if (response.data.service.code !== requestedCode || response.data.publication.serviceCode !== requestedCode) {
|
|
1194
|
+
throw malformed(
|
|
1195
|
+
`response is for service ${JSON.stringify(response.data.service.code)} (publication: ${JSON.stringify(response.data.publication.serviceCode)}) but ${JSON.stringify(requestedCode)} was requested`
|
|
1196
|
+
);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return response;
|
|
1200
|
+
}
|
|
1201
|
+
return { getPublishedCatalog };
|
|
1202
|
+
}
|
|
1203
|
+
|
|
815
1204
|
// src/client/members-methods.ts
|
|
816
1205
|
var EXT_MEMBERS_ENDPOINT = "/api/v1/organizations/ext/members";
|
|
817
1206
|
function createMembersMethods(deps) {
|
|
@@ -1254,7 +1643,7 @@ function validateTokenResponse(tokenResponse) {
|
|
|
1254
1643
|
}
|
|
1255
1644
|
|
|
1256
1645
|
// src/client/version-check.ts
|
|
1257
|
-
var SDK_VERSION = "5.
|
|
1646
|
+
var SDK_VERSION = "5.27.0";
|
|
1258
1647
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
1259
1648
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
1260
1649
|
function sdkHeaders() {
|
|
@@ -2868,39 +3257,7 @@ function isBlockedFromUserinfo(sub) {
|
|
|
2868
3257
|
return BLOCKING_EFFECTIVE_STATUSES.includes(effectiveStatus);
|
|
2869
3258
|
}
|
|
2870
3259
|
|
|
2871
|
-
// src/client/
|
|
2872
|
-
var FFID_ERROR_CODES = {
|
|
2873
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
2874
|
-
PARSE_ERROR: "PARSE_ERROR",
|
|
2875
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
2876
|
-
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
2877
|
-
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
2878
|
-
NO_TOKENS: "NO_TOKENS",
|
|
2879
|
-
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
2880
|
-
TOKEN_EXPIRED: "TOKEN_EXPIRED",
|
|
2881
|
-
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
2882
|
-
};
|
|
2883
|
-
|
|
2884
|
-
// src/client/ffid-client.ts
|
|
2885
|
-
var UNAUTHORIZED_STATUS2 = 401;
|
|
2886
|
-
var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
2887
|
-
var noopLogger = {
|
|
2888
|
-
debug: () => {
|
|
2889
|
-
},
|
|
2890
|
-
info: () => {
|
|
2891
|
-
},
|
|
2892
|
-
warn: () => {
|
|
2893
|
-
},
|
|
2894
|
-
error: () => {
|
|
2895
|
-
}
|
|
2896
|
-
};
|
|
2897
|
-
var consoleLogger = {
|
|
2898
|
-
debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
|
|
2899
|
-
info: (...args) => console.info(SDK_LOG_PREFIX, ...args),
|
|
2900
|
-
warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
|
|
2901
|
-
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
2902
|
-
};
|
|
2903
|
-
var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
|
|
3260
|
+
// src/client/service-access-decision.ts
|
|
2904
3261
|
var DEFAULT_ALLOW_GRACE = true;
|
|
2905
3262
|
var DEFAULT_SERVICE_ACCESS_FAIL_POLICY = "failClosed";
|
|
2906
3263
|
var SERVICE_ACCESS_DENIED_CODE = "SERVICE_ACCESS_DENIED";
|
|
@@ -2967,6 +3324,40 @@ function failClosedServiceAccessDecision(params, error) {
|
|
|
2967
3324
|
error
|
|
2968
3325
|
};
|
|
2969
3326
|
}
|
|
3327
|
+
|
|
3328
|
+
// src/client/error-codes.ts
|
|
3329
|
+
var FFID_ERROR_CODES = {
|
|
3330
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
3331
|
+
PARSE_ERROR: "PARSE_ERROR",
|
|
3332
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
3333
|
+
TOKEN_EXCHANGE_ERROR: "TOKEN_EXCHANGE_ERROR",
|
|
3334
|
+
TOKEN_REFRESH_ERROR: "TOKEN_REFRESH_ERROR",
|
|
3335
|
+
NO_TOKENS: "NO_TOKENS",
|
|
3336
|
+
TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR",
|
|
3337
|
+
TOKEN_EXPIRED: "TOKEN_EXPIRED",
|
|
3338
|
+
STATE_MISMATCH_ERROR: "STATE_MISMATCH_ERROR"
|
|
3339
|
+
};
|
|
3340
|
+
|
|
3341
|
+
// src/client/ffid-client.ts
|
|
3342
|
+
var UNAUTHORIZED_STATUS2 = 401;
|
|
3343
|
+
var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
3344
|
+
var noopLogger = {
|
|
3345
|
+
debug: () => {
|
|
3346
|
+
},
|
|
3347
|
+
info: () => {
|
|
3348
|
+
},
|
|
3349
|
+
warn: () => {
|
|
3350
|
+
},
|
|
3351
|
+
error: () => {
|
|
3352
|
+
}
|
|
3353
|
+
};
|
|
3354
|
+
var consoleLogger = {
|
|
3355
|
+
debug: (...args) => console.debug(SDK_LOG_PREFIX, ...args),
|
|
3356
|
+
info: (...args) => console.info(SDK_LOG_PREFIX, ...args),
|
|
3357
|
+
warn: (...args) => console.warn(SDK_LOG_PREFIX, ...args),
|
|
3358
|
+
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
3359
|
+
};
|
|
3360
|
+
var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
|
|
2970
3361
|
function resolveRedirectUri(raw, logger) {
|
|
2971
3362
|
if (raw === null) return null;
|
|
2972
3363
|
try {
|
|
@@ -3284,6 +3675,10 @@ function createFFIDClient(config) {
|
|
|
3284
3675
|
fetchWithAuth,
|
|
3285
3676
|
createError
|
|
3286
3677
|
});
|
|
3678
|
+
const { getPublishedCatalog } = createCatalogMethods({
|
|
3679
|
+
fetchWithAuth,
|
|
3680
|
+
createError
|
|
3681
|
+
});
|
|
3287
3682
|
const { listMembers, addMember, updateMemberRole, removeMember } = createMembersMethods({
|
|
3288
3683
|
fetchWithAuth,
|
|
3289
3684
|
createError,
|
|
@@ -3410,6 +3805,7 @@ function createFFIDClient(config) {
|
|
|
3410
3805
|
assignSeats,
|
|
3411
3806
|
unassignSeat,
|
|
3412
3807
|
listPlans,
|
|
3808
|
+
getPublishedCatalog,
|
|
3413
3809
|
getSubscription,
|
|
3414
3810
|
subscribe,
|
|
3415
3811
|
changePlan,
|
|
@@ -5558,4 +5954,4 @@ function FFIDInquiryForm({
|
|
|
5558
5954
|
);
|
|
5559
5955
|
}
|
|
5560
5956
|
|
|
5561
|
-
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, BLOCKING_EFFECTIVE_STATUSES, DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES, EFFECTIVE_SUBSCRIPTION_STATUSES, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDInquiryForm, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSDKError, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, FFID_ERROR_CODES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, cleanupStateStorage, computeEffectiveStatusFromSession, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, isBlockedFromUserinfo, isFFIDInquiryCategorySite2026, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useFFIDContext, useSubscription, withSubscription };
|
|
5957
|
+
export { ACCESS_GRANTING_EFFECTIVE_STATUSES, 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_ANNOUNCEMENTS_ERROR_CODES, FFID_CATALOG_ENVIRONMENTS, FFID_CATALOG_PUBLICATION_STATUSES, FFID_ERROR_CODES, FFID_INQUIRY_CATEGORIES, FFID_INQUIRY_CATEGORIES_SITE_2026, canonicalizeCatalogValue, cleanupStateStorage, computeEffectiveStatusFromSession, computeFFIDCheckoutCopyHash, computeLegalDisclosureHash, computePaymentConfigurationHash, computePraxisCopyHash, computeScopeHash, computeTaxConfigurationHash, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, handleRedirectCallback, hasAccessFromUserinfo, hashCanonicalJson, isBlockedFromUserinfo, isFFIDInquiryCategorySite2026, normalizeRedirectUri, retrieveCodeVerifier, retrieveState, sha256Hex, storeCodeVerifier, storeState, useFFID, useFFIDAnnouncements, useFFIDContext, useSubscription, validatePublishedCatalog, withSubscription };
|