@feelflow/ffid-sdk 2.12.0 → 2.14.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.
@@ -755,8 +755,34 @@ function createMembersMethods(deps) {
755
755
  return { listMembers, updateMemberRole, removeMember };
756
756
  }
757
757
 
758
+ // src/client/profile-methods.ts
759
+ var EXT_PROFILE_ENDPOINT = "/api/v1/users/ext/me";
760
+ function createProfileMethods(deps) {
761
+ const { fetchWithAuth, createError } = deps;
762
+ async function getProfile() {
763
+ return fetchWithAuth(EXT_PROFILE_ENDPOINT);
764
+ }
765
+ async function updateProfile(data) {
766
+ if (data === null || typeof data !== "object" || Array.isArray(data)) {
767
+ return {
768
+ error: createError("VALIDATION_ERROR", "data \u306F\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059")
769
+ };
770
+ }
771
+ if (Object.keys(data).length === 0) {
772
+ return {
773
+ error: createError("VALIDATION_ERROR", "\u66F4\u65B0\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u30921\u3064\u4EE5\u4E0A\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044")
774
+ };
775
+ }
776
+ return fetchWithAuth(EXT_PROFILE_ENDPOINT, {
777
+ method: "PUT",
778
+ body: JSON.stringify(data)
779
+ });
780
+ }
781
+ return { getProfile, updateProfile };
782
+ }
783
+
758
784
  // src/client/version-check.ts
759
- var SDK_VERSION = "2.12.0";
785
+ var SDK_VERSION = "2.14.0";
760
786
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
761
787
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
762
788
  function sdkHeaders() {
@@ -1366,6 +1392,23 @@ function createRedirectMethods(deps) {
1366
1392
  return { redirectToLogin, redirectToAuthorize, getLoginUrl, getSignupUrl, getLogoutUrl, redirectToLogout };
1367
1393
  }
1368
1394
 
1395
+ // src/client/redirect-uri.ts
1396
+ var AUTHORITY_BOUNDARY = /^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/?#]+)([/?#]?)/;
1397
+ function normalizeRedirectUri(input) {
1398
+ const url = new URL(input);
1399
+ const isRootPath = url.pathname === "" || url.pathname === "/";
1400
+ if (!isRootPath) {
1401
+ return { normalized: input, changed: false };
1402
+ }
1403
+ const match = input.match(AUTHORITY_BOUNDARY);
1404
+ if (match === null || match[2] === "/") {
1405
+ return { normalized: input, changed: false };
1406
+ }
1407
+ const authority = match[1];
1408
+ const rest = input.slice(authority.length);
1409
+ return { normalized: `${authority}/${rest}`, changed: true };
1410
+ }
1411
+
1369
1412
  // src/client/password-reset.ts
1370
1413
  var RESET_PASSWORD_BASE = "/api/v1/auth/reset-password";
1371
1414
  function isBlank(value) {
@@ -1876,6 +1919,24 @@ var FFID_ERROR_CODES = {
1876
1919
  TOKEN_VERIFICATION_ERROR: "TOKEN_VERIFICATION_ERROR"
1877
1920
  };
1878
1921
  var EXT_CHECK_ENDPOINT = "/api/v1/subscriptions/ext/check";
1922
+ function resolveRedirectUri(raw, logger) {
1923
+ if (raw === null) return null;
1924
+ try {
1925
+ const { normalized, changed } = normalizeRedirectUri(raw);
1926
+ if (changed) {
1927
+ logger.warn(
1928
+ `FFID Client: redirect_uri \u3092\u6B63\u898F\u5316\u3057\u307E\u3057\u305F (${raw} \u2192 ${normalized})\u3002FFID \u7BA1\u7406\u753B\u9762\u3067\u306E\u767B\u9332\u5024\u3068\u4E00\u81F4\u3055\u305B\u3066\u304F\u3060\u3055\u3044\u3002`
1929
+ );
1930
+ }
1931
+ return normalized;
1932
+ } catch (error) {
1933
+ logger.warn(
1934
+ `FFID Client: redirectUri \u306E\u30D1\u30FC\u30B9\u306B\u5931\u6557\u3057\u305F\u305F\u3081\u6B63\u898F\u5316\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3057\u305F (${raw})`,
1935
+ error
1936
+ );
1937
+ return raw;
1938
+ }
1939
+ }
1879
1940
  function createFFIDClient(config) {
1880
1941
  if (!config.serviceCode || !config.serviceCode.trim()) {
1881
1942
  throw new Error("FFID Client: serviceCode \u304C\u672A\u8A2D\u5B9A\u3067\u3059");
@@ -1883,7 +1944,7 @@ function createFFIDClient(config) {
1883
1944
  const baseUrl = config.apiBaseUrl ?? DEFAULT_API_BASE_URL;
1884
1945
  const authMode = config.authMode ?? "cookie";
1885
1946
  const clientId = config.clientId ?? config.serviceCode;
1886
- const resolvedRedirectUri = config.redirectUri ?? null;
1947
+ const rawRedirectUri = config.redirectUri ?? null;
1887
1948
  const serviceApiKey = config.serviceApiKey?.trim();
1888
1949
  const verifyStrategy = config.verifyStrategy ?? "jwt";
1889
1950
  const cache = config.cache;
@@ -1898,6 +1959,7 @@ function createFFIDClient(config) {
1898
1959
  throw new Error("FFID Client: timeout \u306F\u6B63\u306E\u6570\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
1899
1960
  }
1900
1961
  const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
1962
+ const resolvedRedirectUri = resolveRedirectUri(rawRedirectUri, logger);
1901
1963
  const tokenStore = authMode === "token" ? createTokenStore() : createTokenStore("memory");
1902
1964
  function createError(code, message) {
1903
1965
  return { code, message };
@@ -2091,6 +2153,10 @@ function createFFIDClient(config) {
2091
2153
  createError,
2092
2154
  serviceCode: config.serviceCode
2093
2155
  });
2156
+ const { getProfile, updateProfile } = createProfileMethods({
2157
+ fetchWithAuth,
2158
+ createError
2159
+ });
2094
2160
  const {
2095
2161
  requestPasswordReset,
2096
2162
  verifyPasswordResetToken,
@@ -2162,6 +2228,8 @@ function createFFIDClient(config) {
2162
2228
  listMembers,
2163
2229
  updateMemberRole,
2164
2230
  removeMember,
2231
+ getProfile,
2232
+ updateProfile,
2165
2233
  createCheckoutSession,
2166
2234
  createPortalSession,
2167
2235
  listPlans,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "2.12.0",
3
+ "version": "2.14.0",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",