@feelflow/ffid-sdk 4.2.0 → 5.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.
@@ -704,6 +704,7 @@ function createSubscriptionMethods(deps) {
704
704
  var EXT_MEMBERS_ENDPOINT = "/api/v1/organizations/ext/members";
705
705
  function createMembersMethods(deps) {
706
706
  const { fetchWithAuth, createError, serviceCode } = deps;
707
+ const assignableRoles = /* @__PURE__ */ new Set(["admin", "member", "viewer"]);
707
708
  function buildQuery(organizationId) {
708
709
  return new URLSearchParams({ organizationId, serviceCode }).toString();
709
710
  }
@@ -717,6 +718,37 @@ function createMembersMethods(deps) {
717
718
  `${EXT_MEMBERS_ENDPOINT}?${buildQuery(params.organizationId)}`
718
719
  );
719
720
  }
721
+ function normalizeAddMemberArgs(paramsOrOrganizationId, data) {
722
+ if (typeof paramsOrOrganizationId === "string") {
723
+ const params = {
724
+ organizationId: paramsOrOrganizationId,
725
+ email: data?.email ?? ""
726
+ };
727
+ if (data?.role !== void 0) params.role = data.role;
728
+ return params;
729
+ }
730
+ return paramsOrOrganizationId;
731
+ }
732
+ async function addMember(paramsOrOrganizationId, data) {
733
+ const params = normalizeAddMemberArgs(paramsOrOrganizationId, data);
734
+ if (!params.organizationId || !params.email) {
735
+ return {
736
+ error: createError("VALIDATION_ERROR", "organizationId \u3068 email \u306F\u5FC5\u9808\u3067\u3059")
737
+ };
738
+ }
739
+ if (params.role !== void 0 && !assignableRoles.has(params.role)) {
740
+ return {
741
+ error: createError("VALIDATION_ERROR", "role \u306F admin\u3001member\u3001viewer \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044")
742
+ };
743
+ }
744
+ return fetchWithAuth(
745
+ `${EXT_MEMBERS_ENDPOINT}?${buildQuery(params.organizationId)}`,
746
+ {
747
+ method: "POST",
748
+ body: JSON.stringify({ email: params.email, role: params.role })
749
+ }
750
+ );
751
+ }
720
752
  async function updateMemberRole(params) {
721
753
  if (!params.organizationId || !params.userId) {
722
754
  return {
@@ -749,7 +781,7 @@ function createMembersMethods(deps) {
749
781
  }
750
782
  );
751
783
  }
752
- return { listMembers, updateMemberRole, removeMember };
784
+ return { listMembers, addMember, updateMemberRole, removeMember };
753
785
  }
754
786
 
755
787
  // src/client/profile-methods.ts
@@ -802,7 +834,7 @@ function createProfileMethods(deps) {
802
834
  }
803
835
 
804
836
  // src/client/version-check.ts
805
- var SDK_VERSION = "4.2.0";
837
+ var SDK_VERSION = "5.0.0";
806
838
  var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
807
839
  var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
808
840
  function sdkHeaders() {
@@ -2552,7 +2584,7 @@ function createFFIDClient(config) {
2552
2584
  fetchWithAuth,
2553
2585
  createError
2554
2586
  });
2555
- const { listMembers, updateMemberRole, removeMember } = createMembersMethods({
2587
+ const { listMembers, addMember, updateMemberRole, removeMember } = createMembersMethods({
2556
2588
  fetchWithAuth,
2557
2589
  createError,
2558
2590
  serviceCode: config.serviceCode
@@ -2636,6 +2668,7 @@ function createFFIDClient(config) {
2636
2668
  checkServiceAccess,
2637
2669
  requireServiceAccess,
2638
2670
  listMembers,
2671
+ addMember,
2639
2672
  updateMemberRole,
2640
2673
  removeMember,
2641
2674
  getProfile,
@@ -2726,4 +2759,95 @@ function createKVCacheAdapter(kv) {
2726
2759
  };
2727
2760
  }
2728
2761
 
2729
- export { createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, createVerifyAccessToken };
2762
+ // src/consent/storage/encode.ts
2763
+ var COOKIE_VERSION = "v1";
2764
+ var ALL_DENIED_EXCEPT_NECESSARY = {
2765
+ necessary: true,
2766
+ functional: false,
2767
+ analytics: false,
2768
+ marketing: false
2769
+ };
2770
+ var CATEGORY_LETTERS = {
2771
+ n: "necessary",
2772
+ f: "functional",
2773
+ a: "analytics",
2774
+ m: "marketing"
2775
+ };
2776
+ var ORDERED_LETTERS = ["n", "f", "a", "m"];
2777
+ function encodeConsentCookie(cats) {
2778
+ const parts = ORDERED_LETTERS.map((letter) => {
2779
+ const key = CATEGORY_LETTERS[letter];
2780
+ return `${letter}${cats[key] ? "+" : "-"}`;
2781
+ });
2782
+ return `${COOKIE_VERSION}:${parts.join(",")}`;
2783
+ }
2784
+ function decodeConsentCookie(raw) {
2785
+ if (typeof raw !== "string" || raw.length === 0) {
2786
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2787
+ }
2788
+ const colonIdx = raw.indexOf(":");
2789
+ if (colonIdx === -1) {
2790
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2791
+ }
2792
+ const version = raw.slice(0, colonIdx);
2793
+ if (version !== COOKIE_VERSION) {
2794
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2795
+ }
2796
+ const body = raw.slice(colonIdx + 1);
2797
+ if (body.length === 0) {
2798
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2799
+ }
2800
+ const tokens = body.split(",");
2801
+ if (tokens.length !== ORDERED_LETTERS.length) {
2802
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2803
+ }
2804
+ const seen = /* @__PURE__ */ new Set();
2805
+ const result = {};
2806
+ for (const token of tokens) {
2807
+ if (token.length !== 2) {
2808
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2809
+ }
2810
+ const letter = token[0];
2811
+ const value = token[1];
2812
+ if (!CATEGORY_LETTERS[letter] || value !== "+" && value !== "-") {
2813
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2814
+ }
2815
+ if (seen.has(letter)) {
2816
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2817
+ }
2818
+ seen.add(letter);
2819
+ const key = CATEGORY_LETTERS[letter];
2820
+ result[key] = value === "+";
2821
+ }
2822
+ if (result.necessary !== true) {
2823
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2824
+ }
2825
+ return {
2826
+ necessary: true,
2827
+ functional: result.functional ?? false,
2828
+ analytics: result.analytics ?? false,
2829
+ marketing: result.marketing ?? false
2830
+ };
2831
+ }
2832
+
2833
+ // src/consent/storage/cookie.ts
2834
+ var CONSENT_COOKIE_NAME = "ffid_consent";
2835
+
2836
+ // src/server/cookie-consent.ts
2837
+ function getFFIDConsentFromCookies(store) {
2838
+ if (!store) return { ...ALL_DENIED_EXCEPT_NECESSARY };
2839
+ const entry = store.get(CONSENT_COOKIE_NAME);
2840
+ if (!entry) return { ...ALL_DENIED_EXCEPT_NECESSARY };
2841
+ return decodeConsentCookie(entry.value);
2842
+ }
2843
+ function getFFIDConsentFromCookieHeader(cookieHeader) {
2844
+ if (typeof cookieHeader !== "string" || cookieHeader.length === 0) {
2845
+ return { ...ALL_DENIED_EXCEPT_NECESSARY };
2846
+ }
2847
+ const raw = cookieHeader.split(";").map((c) => c.trim()).find((c) => c.startsWith(`${CONSENT_COOKIE_NAME}=`));
2848
+ if (!raw) return { ...ALL_DENIED_EXCEPT_NECESSARY };
2849
+ const value = raw.slice(CONSENT_COOKIE_NAME.length + 1);
2850
+ return decodeConsentCookie(decodeURIComponent(value));
2851
+ }
2852
+
2853
+ export { ALL_DENIED_EXCEPT_NECESSARY, CONSENT_COOKIE_NAME, COOKIE_VERSION, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, createVerifyAccessToken, decodeConsentCookie, encodeConsentCookie, getFFIDConsentFromCookieHeader, getFFIDConsentFromCookies };
@@ -1,4 +1,4 @@
1
- import { g as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-CKMGqqPi.cjs';
1
+ import { k as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-DgprK2ec.cjs';
2
2
  import '../../types-5g_Bg6Ey.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { g as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-CUOFknXy.js';
1
+ import { k as FFIDClient, e as FFIDOAuthUserInfo } from '../../ffid-client-BaStAONh.js';
2
2
  import '../../types-5g_Bg6Ey.js';
3
3
 
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "4.2.0",
3
+ "version": "5.0.0",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",
@@ -36,6 +36,11 @@
36
36
  "import": "./dist/components/index.js",
37
37
  "require": "./dist/components/index.cjs"
38
38
  },
39
+ "./consent": {
40
+ "types": "./dist/consent/index.d.ts",
41
+ "import": "./dist/consent/index.js",
42
+ "require": "./dist/consent/index.cjs"
43
+ },
39
44
  "./legal": {
40
45
  "types": "./dist/legal/index.d.ts",
41
46
  "import": "./dist/legal/index.js",
@@ -85,7 +90,8 @@
85
90
  "sdk:publish": "./scripts/publish.sh"
86
91
  },
87
92
  "dependencies": {
88
- "jose": "^6.0.0"
93
+ "jose": "^6.0.0",
94
+ "zod": "^4.4.3"
89
95
  },
90
96
  "peerDependencies": {
91
97
  "react": "^18.0.0 || ^19.0.0",