@feelflow/ffid-sdk 2.20.0 → 3.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 (39) hide show
  1. package/README.md +37 -0
  2. package/dist/agency/index.cjs +3 -3
  3. package/dist/agency/index.d.cts +1 -1
  4. package/dist/agency/index.d.ts +1 -1
  5. package/dist/agency/index.js +2 -2
  6. package/dist/announcements/index.cjs +2 -2
  7. package/dist/announcements/index.js +1 -1
  8. package/dist/chunk-JEVK2XUM.js +5 -0
  9. package/dist/{chunk-KNEZ5OUQ.cjs → chunk-JNR4AKL5.cjs} +133 -3
  10. package/dist/{chunk-YUIITYBE.cjs → chunk-MDHKSVLP.cjs} +2 -0
  11. package/dist/{chunk-GCUVFSB2.js → chunk-XWI4BFKW.js} +133 -4
  12. package/dist/components/index.cjs +8 -8
  13. package/dist/components/index.d.cts +1 -1
  14. package/dist/components/index.d.ts +1 -1
  15. package/dist/components/index.js +1 -1
  16. package/dist/constants-D61jqRIO.d.cts +35 -0
  17. package/dist/constants-D61jqRIO.d.ts +35 -0
  18. package/dist/{ffid-client-Cjm_TKUc.d.cts → ffid-client-B26jbUp5.d.cts} +72 -0
  19. package/dist/{ffid-client-Cjm_TKUc.d.ts → ffid-client-B26jbUp5.d.ts} +72 -0
  20. package/dist/{index-0D2vYSLq.d.cts → index-C3zyNa4j.d.cts} +37 -1
  21. package/dist/{index-0D2vYSLq.d.ts → index-C3zyNa4j.d.ts} +37 -1
  22. package/dist/index.cjs +37 -31
  23. package/dist/index.d.cts +68 -4
  24. package/dist/index.d.ts +68 -4
  25. package/dist/index.js +4 -3
  26. package/dist/legal/index.cjs +3 -3
  27. package/dist/legal/index.d.cts +1 -1
  28. package/dist/legal/index.d.ts +1 -1
  29. package/dist/legal/index.js +2 -2
  30. package/dist/server/index.cjs +135 -5
  31. package/dist/server/index.d.cts +3 -3
  32. package/dist/server/index.d.ts +3 -3
  33. package/dist/server/index.js +130 -4
  34. package/dist/server/test/index.d.cts +1 -1
  35. package/dist/server/test/index.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-QBRM2RRC.js +0 -4
  38. package/dist/constants-DvTGHPZn.d.cts +0 -10
  39. package/dist/constants-DvTGHPZn.d.ts +0 -10
@@ -1,5 +1,5 @@
1
- import { DEFAULT_API_BASE_URL } from '../chunk-QBRM2RRC.js';
2
- export { DEFAULT_API_BASE_URL } from '../chunk-QBRM2RRC.js';
1
+ import { DEFAULT_API_BASE_URL } from '../chunk-JEVK2XUM.js';
2
+ export { DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES } from '../chunk-JEVK2XUM.js';
3
3
  import { createRemoteJWKSet, jwtVerify } from 'jose';
4
4
 
5
5
  // src/auth/token-store.ts
@@ -802,7 +802,7 @@ function createProfileMethods(deps) {
802
802
  }
803
803
 
804
804
  // src/client/version-check.ts
805
- var SDK_VERSION = "2.20.0";
805
+ var SDK_VERSION = "3.0.0";
806
806
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
807
807
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
808
808
  function sdkHeaders() {
@@ -1418,6 +1418,7 @@ function createRedirectMethods(deps) {
1418
1418
  baseUrl,
1419
1419
  clientId,
1420
1420
  serviceCode,
1421
+ scope,
1421
1422
  resolvedRedirectUri,
1422
1423
  logger
1423
1424
  } = deps;
@@ -1426,6 +1427,24 @@ function createRedirectMethods(deps) {
1426
1427
  logger.warn("SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093");
1427
1428
  return { success: false, error: "SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093" };
1428
1429
  }
1430
+ if (authMode === "service-key") {
1431
+ logger.error(
1432
+ "[FFID SDK] service-key \u30E2\u30FC\u30C9\u3067\u306F redirectToAuthorize \u306F\u547C\u3073\u51FA\u305B\u307E\u305B\u3093 \u2014 server-to-server \u7528\u9014\u306E\u305F\u3081 OAuth \u30D6\u30E9\u30A6\u30B6 flow \u3092\u6301\u3061\u307E\u305B\u3093"
1433
+ );
1434
+ return {
1435
+ success: false,
1436
+ error: "service-key \u30E2\u30FC\u30C9\u3067\u306F OAuth \u8A8D\u53EF\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093"
1437
+ };
1438
+ }
1439
+ if (!scope || !scope.trim()) {
1440
+ logger.error(
1441
+ "[FFID SDK] scope \u304C\u672A\u8A2D\u5B9A\u306E\u305F\u3081 /oauth/authorize \u3092\u547C\u3073\u51FA\u305B\u307E\u305B\u3093 (#2674) \u2014 FFIDConfig.scope \u306B DEFAULT_OAUTH_SCOPES \u307E\u305F\u306F\u660E\u793A\u7684\u306A scope \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044"
1442
+ );
1443
+ return {
1444
+ success: false,
1445
+ error: "OAuth scope \u304C\u672A\u8A2D\u5B9A\u306E\u305F\u3081\u8A8D\u53EF\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3092\u5B9F\u884C\u3067\u304D\u307E\u305B\u3093"
1446
+ };
1447
+ }
1429
1448
  const authorizeKey = buildAuthorizeKey(baseUrl, clientId, options?.organizationId);
1430
1449
  const now = Date.now();
1431
1450
  const recentCount = getRecentRedirectCount(authorizeKey, now, logger);
@@ -1458,6 +1477,7 @@ function createRedirectMethods(deps) {
1458
1477
  const params = new URLSearchParams({
1459
1478
  response_type: "code",
1460
1479
  client_id: clientId,
1480
+ scope,
1461
1481
  redirect_uri: redirectUri,
1462
1482
  state,
1463
1483
  code_challenge: challenge,
@@ -1796,6 +1816,63 @@ function createOtpMethods(deps) {
1796
1816
  };
1797
1817
  }
1798
1818
 
1819
+ // src/client/analytics-methods.ts
1820
+ var EXT_ANALYTICS_CONFIG_ENDPOINT = "/api/v1/ext/analytics/config";
1821
+ function resolveAuthOverride2(options, createError) {
1822
+ if (!options || options.accessToken === void 0) {
1823
+ return {};
1824
+ }
1825
+ const token = options.accessToken;
1826
+ if (typeof token !== "string" || token.trim() === "") {
1827
+ return {
1828
+ error: createError(
1829
+ "VALIDATION_ERROR",
1830
+ "accessToken \u3092\u6307\u5B9A\u3059\u308B\u5834\u5408\u3001\u7A7A\u6587\u5B57\u5217\u3084\u7A7A\u767D\u306E\u307F\u306E\u5024\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"
1831
+ )
1832
+ };
1833
+ }
1834
+ return { override: { accessToken: token } };
1835
+ }
1836
+ var ANALYTICS_SERVICE_CODE_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
1837
+ function validateServiceCode(serviceCode, createError) {
1838
+ if (typeof serviceCode !== "string" || serviceCode.trim() === "") {
1839
+ return createError(
1840
+ "VALIDATION_ERROR",
1841
+ "serviceCode \u306F\u5FC5\u9808\u306E kebab-case \u6587\u5B57\u5217\u3067\u3059"
1842
+ );
1843
+ }
1844
+ if (!ANALYTICS_SERVICE_CODE_PATTERN.test(serviceCode)) {
1845
+ return createError(
1846
+ "VALIDATION_ERROR",
1847
+ "serviceCode \u306F kebab-case \u5F62\u5F0F (\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB\u30CF\u30A4\u30D5\u30F3) \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044"
1848
+ );
1849
+ }
1850
+ return null;
1851
+ }
1852
+ function createAnalyticsMethods(deps) {
1853
+ const { fetchWithAuth, createError } = deps;
1854
+ async function getAnalyticsConfig(serviceCode, options) {
1855
+ const validationError = validateServiceCode(serviceCode, createError);
1856
+ if (validationError) {
1857
+ return { error: validationError };
1858
+ }
1859
+ const { override, error: overrideError } = resolveAuthOverride2(
1860
+ options,
1861
+ createError
1862
+ );
1863
+ if (overrideError) {
1864
+ return { error: overrideError };
1865
+ }
1866
+ const endpoint = `${EXT_ANALYTICS_CONFIG_ENDPOINT}?service=${encodeURIComponent(serviceCode)}`;
1867
+ return fetchWithAuth(
1868
+ endpoint,
1869
+ { method: "GET" },
1870
+ override
1871
+ );
1872
+ }
1873
+ return { getAnalyticsConfig };
1874
+ }
1875
+
1799
1876
  // src/client/contract-wizard-methods.ts
1800
1877
  var CONTRACT_WIZARD_PATH = "/contract-wizard";
1801
1878
  function buildWizardUrl(baseUrl, flow, params) {
@@ -1883,6 +1960,7 @@ function createContractWizardMethods(deps) {
1883
1960
  var EXT_SUBSCRIBE_ENDPOINT2 = "/api/v1/ext/newsletter/subscribe";
1884
1961
  var CONFIRM_ENDPOINT = "/api/newsletter/confirm";
1885
1962
  var UNSUBSCRIBE_ENDPOINT = "/api/newsletter/unsubscribe";
1963
+ var DISPATCH_ENDPOINT = "/api/v1/newsletter/dispatch";
1886
1964
  function trimOrEmpty(s) {
1887
1965
  return typeof s === "string" ? s.trim() : "";
1888
1966
  }
@@ -1988,7 +2066,36 @@ function createNewsletterMethods(deps) {
1988
2066
  }
1989
2067
  );
1990
2068
  }
1991
- return { subscribe, confirm, unsubscribe };
2069
+ async function dispatch(params) {
2070
+ const subject = trimOrEmpty(params.subject);
2071
+ if (!subject) {
2072
+ return { error: createError("VALIDATION_ERROR", "subject \u306F\u5FC5\u9808\u3067\u3059") };
2073
+ }
2074
+ if (!params.body || typeof params.body !== "object") {
2075
+ return { error: createError("VALIDATION_ERROR", "body \u306F\u5FC5\u9808\u3067\u3059") };
2076
+ }
2077
+ const bodySource = params.body;
2078
+ const hasHtmlBody = typeof bodySource.htmlBody === "string" && bodySource.htmlBody.length > 0;
2079
+ const hasTemplateId = typeof bodySource.templateId === "string" && bodySource.templateId.length > 0;
2080
+ if (hasHtmlBody === hasTemplateId) {
2081
+ return {
2082
+ error: createError(
2083
+ "BODY_SOURCE_REQUIRED",
2084
+ "body \u306F htmlBody \u307E\u305F\u306F templateId \u306E\u3044\u305A\u308C\u304B\u4E00\u65B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044"
2085
+ )
2086
+ };
2087
+ }
2088
+ return fetchWithAuth(DISPATCH_ENDPOINT, {
2089
+ method: "POST",
2090
+ body: JSON.stringify({
2091
+ subject,
2092
+ articleUrl: params.articleUrl,
2093
+ body: params.body,
2094
+ segment: params.segment
2095
+ })
2096
+ });
2097
+ }
2098
+ return { subscribe, confirm, unsubscribe, dispatch };
1992
2099
  }
1993
2100
 
1994
2101
  // src/inquiry/ffid-inquiry-client.ts
@@ -2090,8 +2197,21 @@ function createFFIDClient(config) {
2090
2197
  if (!config.serviceCode || !config.serviceCode.trim()) {
2091
2198
  throw new Error("FFID Client: serviceCode \u304C\u672A\u8A2D\u5B9A\u3067\u3059");
2092
2199
  }
2200
+ const scope = config.scope?.trim() ?? "";
2093
2201
  const baseUrl = config.apiBaseUrl ?? DEFAULT_API_BASE_URL;
2094
2202
  const authMode = config.authMode ?? "cookie";
2203
+ const VALID_AUTH_MODES = ["cookie", "token", "service-key"];
2204
+ if (!VALID_AUTH_MODES.includes(authMode)) {
2205
+ throw new Error(
2206
+ `FFID Client: authMode \u304C\u4E0D\u6B63\u3067\u3059 (\u53D7\u4FE1: ${JSON.stringify(authMode)}, \u6709\u52B9\u5024: ${VALID_AUTH_MODES.join(" | ")})`
2207
+ );
2208
+ }
2209
+ if (authMode !== "service-key" && !scope) {
2210
+ const received = config.scope === void 0 ? "undefined" : JSON.stringify(config.scope);
2211
+ throw new Error(
2212
+ `FFID Client: scope \u304C\u672A\u8A2D\u5B9A\u3067\u3059 (\u53D7\u4FE1: ${received})\u3002\`DEFAULT_OAUTH_SCOPES\` \u3092 import \u3059\u308B\u304B\u3001\u660E\u793A\u7684\u306B scope \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044 (#2674)`
2213
+ );
2214
+ }
2095
2215
  const clientId = config.clientId ?? config.serviceCode;
2096
2216
  const rawRedirectUri = config.redirectUri ?? null;
2097
2217
  const serviceApiKey = config.serviceApiKey?.trim();
@@ -2262,6 +2382,7 @@ function createFFIDClient(config) {
2262
2382
  baseUrl,
2263
2383
  clientId,
2264
2384
  serviceCode: config.serviceCode,
2385
+ scope,
2265
2386
  resolvedRedirectUri,
2266
2387
  logger
2267
2388
  });
@@ -2318,6 +2439,10 @@ function createFFIDClient(config) {
2318
2439
  fetchWithAuth,
2319
2440
  createError
2320
2441
  });
2442
+ const { getAnalyticsConfig } = createAnalyticsMethods({
2443
+ fetchWithAuth,
2444
+ createError
2445
+ });
2321
2446
  const {
2322
2447
  requestPasswordReset,
2323
2448
  verifyPasswordResetToken,
@@ -2391,6 +2516,7 @@ function createFFIDClient(config) {
2391
2516
  removeMember,
2392
2517
  getProfile,
2393
2518
  updateProfile,
2519
+ getAnalyticsConfig,
2394
2520
  createCheckoutSession,
2395
2521
  createPortalSession,
2396
2522
  listPlans,
@@ -1,4 +1,4 @@
1
- import { g as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-Cjm_TKUc.cjs';
1
+ import { g as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-B26jbUp5.cjs';
2
2
 
3
3
  /**
4
4
  * FFID SDK - Test mode client (E2E / integration test bypass)
@@ -1,4 +1,4 @@
1
- import { g as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-Cjm_TKUc.js';
1
+ import { g as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-B26jbUp5.js';
2
2
 
3
3
  /**
4
4
  * FFID SDK - Test mode client (E2E / integration test bypass)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "2.20.0",
3
+ "version": "3.0.0",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",
@@ -1,4 +0,0 @@
1
- // src/constants.ts
2
- var DEFAULT_API_BASE_URL = "https://id.feelflow.net";
3
-
4
- export { DEFAULT_API_BASE_URL };
@@ -1,10 +0,0 @@
1
- /**
2
- * FFID SDK Shared Constants
3
- *
4
- * Constants shared across all SDK entry points.
5
- * Centralizing these prevents drift during domain/URL changes.
6
- */
7
- /** Default FFID API base URL (production) */
8
- declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
9
-
10
- export { DEFAULT_API_BASE_URL as D };
@@ -1,10 +0,0 @@
1
- /**
2
- * FFID SDK Shared Constants
3
- *
4
- * Constants shared across all SDK entry points.
5
- * Centralizing these prevents drift during domain/URL changes.
6
- */
7
- /** Default FFID API base URL (production) */
8
- declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
9
-
10
- export { DEFAULT_API_BASE_URL as D };