@feelflow/ffid-sdk 0.3.0 → 1.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.
@@ -1,30 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var chunkA6YJDYIX_cjs = require('../chunk-A6YJDYIX.cjs');
3
+ var chunkTL6U5TJT_cjs = require('../chunk-TL6U5TJT.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "FFIDAnnouncementBadge", {
8
8
  enumerable: true,
9
- get: function () { return chunkA6YJDYIX_cjs.FFIDAnnouncementBadge; }
9
+ get: function () { return chunkTL6U5TJT_cjs.FFIDAnnouncementBadge; }
10
10
  });
11
11
  Object.defineProperty(exports, "FFIDAnnouncementList", {
12
12
  enumerable: true,
13
- get: function () { return chunkA6YJDYIX_cjs.FFIDAnnouncementList; }
13
+ get: function () { return chunkTL6U5TJT_cjs.FFIDAnnouncementList; }
14
14
  });
15
15
  Object.defineProperty(exports, "FFIDLoginButton", {
16
16
  enumerable: true,
17
- get: function () { return chunkA6YJDYIX_cjs.FFIDLoginButton; }
17
+ get: function () { return chunkTL6U5TJT_cjs.FFIDLoginButton; }
18
18
  });
19
19
  Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
20
20
  enumerable: true,
21
- get: function () { return chunkA6YJDYIX_cjs.FFIDOrganizationSwitcher; }
21
+ get: function () { return chunkTL6U5TJT_cjs.FFIDOrganizationSwitcher; }
22
22
  });
23
23
  Object.defineProperty(exports, "FFIDSubscriptionBadge", {
24
24
  enumerable: true,
25
- get: function () { return chunkA6YJDYIX_cjs.FFIDSubscriptionBadge; }
25
+ get: function () { return chunkTL6U5TJT_cjs.FFIDSubscriptionBadge; }
26
26
  });
27
27
  Object.defineProperty(exports, "FFIDUserMenu", {
28
28
  enumerable: true,
29
- get: function () { return chunkA6YJDYIX_cjs.FFIDUserMenu; }
29
+ get: function () { return chunkTL6U5TJT_cjs.FFIDUserMenu; }
30
30
  });
@@ -1,3 +1,3 @@
1
- export { k as FFIDAnnouncementBadge, B as FFIDAnnouncementBadgeClassNames, C as FFIDAnnouncementBadgeProps, l as FFIDAnnouncementList, D as FFIDAnnouncementListClassNames, E as FFIDAnnouncementListProps, s as FFIDLoginButton, G as FFIDLoginButtonProps, t as FFIDOrganizationSwitcher, H as FFIDOrganizationSwitcherClassNames, I as FFIDOrganizationSwitcherProps, w as FFIDSubscriptionBadge, J as FFIDSubscriptionBadgeClassNames, K as FFIDSubscriptionBadgeProps, x as FFIDUserMenu, M as FFIDUserMenuClassNames, N as FFIDUserMenuProps } from '../index-DBp3Ulyl.cjs';
1
+ export { k as FFIDAnnouncementBadge, H as FFIDAnnouncementBadgeClassNames, I as FFIDAnnouncementBadgeProps, l as FFIDAnnouncementList, J as FFIDAnnouncementListClassNames, K as FFIDAnnouncementListProps, s as FFIDLoginButton, M as FFIDLoginButtonProps, x as FFIDOrganizationSwitcher, N as FFIDOrganizationSwitcherClassNames, O as FFIDOrganizationSwitcherProps, C as FFIDSubscriptionBadge, P as FFIDSubscriptionBadgeClassNames, Q as FFIDSubscriptionBadgeProps, D as FFIDUserMenu, R as FFIDUserMenuClassNames, S as FFIDUserMenuProps } from '../index-CyYHo3-R.cjs';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
@@ -1,3 +1,3 @@
1
- export { k as FFIDAnnouncementBadge, B as FFIDAnnouncementBadgeClassNames, C as FFIDAnnouncementBadgeProps, l as FFIDAnnouncementList, D as FFIDAnnouncementListClassNames, E as FFIDAnnouncementListProps, s as FFIDLoginButton, G as FFIDLoginButtonProps, t as FFIDOrganizationSwitcher, H as FFIDOrganizationSwitcherClassNames, I as FFIDOrganizationSwitcherProps, w as FFIDSubscriptionBadge, J as FFIDSubscriptionBadgeClassNames, K as FFIDSubscriptionBadgeProps, x as FFIDUserMenu, M as FFIDUserMenuClassNames, N as FFIDUserMenuProps } from '../index-DBp3Ulyl.js';
1
+ export { k as FFIDAnnouncementBadge, H as FFIDAnnouncementBadgeClassNames, I as FFIDAnnouncementBadgeProps, l as FFIDAnnouncementList, J as FFIDAnnouncementListClassNames, K as FFIDAnnouncementListProps, s as FFIDLoginButton, M as FFIDLoginButtonProps, x as FFIDOrganizationSwitcher, N as FFIDOrganizationSwitcherClassNames, O as FFIDOrganizationSwitcherProps, C as FFIDSubscriptionBadge, P as FFIDSubscriptionBadgeClassNames, Q as FFIDSubscriptionBadgeProps, D as FFIDUserMenu, R as FFIDUserMenuClassNames, S as FFIDUserMenuProps } from '../index-CyYHo3-R.js';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
@@ -1 +1 @@
1
- export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-VXBUXOLF.js';
1
+ export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-K525KYQP.js';
@@ -9,6 +9,9 @@ import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
9
9
  /**
10
10
  * User information from FFID
11
11
  */
12
+ type FFIDSeatModel = 'organization' | 'individual';
13
+ /** Userinfo member role for OAuth responses */
14
+ type FFIDOAuthUserInfoMemberRole = 'owner' | 'admin' | 'member' | 'viewer';
12
15
  interface FFIDUser {
13
16
  /** User ID (UUID) */
14
17
  id: string;
@@ -80,6 +83,29 @@ interface FFIDSubscription {
80
83
  status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused';
81
84
  /** Current billing period end date */
82
85
  currentPeriodEnd: string | null;
86
+ /** Service seat model (available when sourced from OAuth userinfo) */
87
+ seatModel?: FFIDSeatModel | undefined;
88
+ /** Member role in the resolved organization context */
89
+ memberRole?: FFIDOAuthUserInfoMemberRole | undefined;
90
+ /** Organization ID used to resolve subscription access */
91
+ organizationId?: string | null | undefined;
92
+ }
93
+ /** OAuth userinfo subscription summary */
94
+ interface FFIDOAuthUserInfoSubscription {
95
+ status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused' | null;
96
+ planCode: string | null;
97
+ seatModel: FFIDSeatModel | null;
98
+ memberRole: FFIDOAuthUserInfoMemberRole | null;
99
+ organizationId: string | null;
100
+ }
101
+ /** OAuth userinfo response exposed by FFID */
102
+ interface FFIDOAuthUserInfo {
103
+ sub: string;
104
+ email: string | null;
105
+ name: string | null;
106
+ picture: string | null;
107
+ organizationId?: string | null;
108
+ subscription?: FFIDOAuthUserInfoSubscription;
83
109
  }
84
110
  /**
85
111
  * SDK configuration options
@@ -107,6 +133,10 @@ interface FFIDConfig {
107
133
  onAuthStateChange?: ((user: FFIDUser | null) => void) | undefined;
108
134
  /** Callback on authentication error */
109
135
  onError?: ((error: FFIDError) => void) | undefined;
136
+ /** Authentication mode: 'cookie' (default) or 'token' (OAuth Bearer) */
137
+ authMode?: 'cookie' | 'token' | undefined;
138
+ /** Client ID for token mode (defaults to serviceCode if not set) */
139
+ clientId?: string | undefined;
110
140
  }
111
141
  /**
112
142
  * FFID context value provided to consumers
@@ -202,6 +232,15 @@ type FFIDApiResponse<T> = {
202
232
  data?: undefined;
203
233
  error: FFIDError;
204
234
  };
235
+ /**
236
+ * OAuth 2.0 token response from FFID token endpoint
237
+ */
238
+ interface FFIDOAuthTokenResponse {
239
+ access_token: string;
240
+ token_type: 'Bearer';
241
+ expires_in: number;
242
+ refresh_token: string;
243
+ }
205
244
 
206
245
  /**
207
246
  * FFID Announcements SDK Type Definitions
@@ -564,4 +603,4 @@ interface FFIDAnnouncementListProps {
564
603
  */
565
604
  declare function FFIDAnnouncementList({ announcements, isLoading, className, classNames, style, formatDate, emptyMessage, loadingRender, renderItem, maxContentLines, }: FFIDAnnouncementListProps): react_jsx_runtime.JSX.Element;
566
605
 
567
- export { type AnnouncementListResponse as A, type FFIDAnnouncementBadgeClassNames as B, type FFIDAnnouncementBadgeProps as C, type FFIDAnnouncementListClassNames as D, type FFIDAnnouncementListProps as E, type FFIDConfig as F, type FFIDLoginButtonProps as G, type FFIDOrganizationSwitcherClassNames as H, type FFIDOrganizationSwitcherProps as I, type FFIDSubscriptionBadgeClassNames as J, type FFIDSubscriptionBadgeProps as K, type ListAnnouncementsOptions as L, type FFIDUserMenuClassNames as M, type FFIDUserMenuProps as N, type UseFFIDAnnouncementsOptions as U, type FFIDUser as a, type FFIDOrganization as b, type FFIDError as c, type FFIDSubscriptionContextValue as d, type FFIDAnnouncementsClientConfig as e, type FFIDAnnouncementsApiResponse as f, type FFIDAnnouncementsLogger as g, type Announcement as h, type AnnouncementStatus as i, type AnnouncementType as j, FFIDAnnouncementBadge as k, FFIDAnnouncementList as l, type FFIDAnnouncementsError as m, type FFIDAnnouncementsErrorCode as n, type FFIDAnnouncementsServerResponse as o, type FFIDApiResponse as p, type FFIDContextValue as q, type FFIDLogger as r, FFIDLoginButton as s, FFIDOrganizationSwitcher as t, type FFIDSessionResponse as u, type FFIDSubscription as v, FFIDSubscriptionBadge as w, FFIDUserMenu as x, type UseFFIDAnnouncementsReturn as y, useFFIDAnnouncements as z };
606
+ export { type AnnouncementListResponse as A, type FFIDSubscription as B, FFIDSubscriptionBadge as C, FFIDUserMenu as D, type UseFFIDAnnouncementsReturn as E, type FFIDConfig as F, useFFIDAnnouncements as G, type FFIDAnnouncementBadgeClassNames as H, type FFIDAnnouncementBadgeProps as I, type FFIDAnnouncementListClassNames as J, type FFIDAnnouncementListProps as K, type ListAnnouncementsOptions as L, type FFIDLoginButtonProps as M, type FFIDOrganizationSwitcherClassNames as N, type FFIDOrganizationSwitcherProps as O, type FFIDSubscriptionBadgeClassNames as P, type FFIDSubscriptionBadgeProps as Q, type FFIDUserMenuClassNames as R, type FFIDUserMenuProps as S, type UseFFIDAnnouncementsOptions as U, type FFIDUser as a, type FFIDOrganization as b, type FFIDError as c, type FFIDSubscriptionContextValue as d, type FFIDAnnouncementsClientConfig as e, type FFIDAnnouncementsApiResponse as f, type FFIDAnnouncementsLogger as g, type Announcement as h, type AnnouncementStatus as i, type AnnouncementType as j, FFIDAnnouncementBadge as k, FFIDAnnouncementList as l, type FFIDAnnouncementsError as m, type FFIDAnnouncementsErrorCode as n, type FFIDAnnouncementsServerResponse as o, type FFIDApiResponse as p, type FFIDContextValue as q, type FFIDLogger as r, FFIDLoginButton as s, type FFIDOAuthTokenResponse as t, type FFIDOAuthUserInfo as u, type FFIDOAuthUserInfoMemberRole as v, type FFIDOAuthUserInfoSubscription as w, FFIDOrganizationSwitcher as x, type FFIDSeatModel as y, type FFIDSessionResponse as z };
@@ -9,6 +9,9 @@ import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
9
9
  /**
10
10
  * User information from FFID
11
11
  */
12
+ type FFIDSeatModel = 'organization' | 'individual';
13
+ /** Userinfo member role for OAuth responses */
14
+ type FFIDOAuthUserInfoMemberRole = 'owner' | 'admin' | 'member' | 'viewer';
12
15
  interface FFIDUser {
13
16
  /** User ID (UUID) */
14
17
  id: string;
@@ -80,6 +83,29 @@ interface FFIDSubscription {
80
83
  status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused';
81
84
  /** Current billing period end date */
82
85
  currentPeriodEnd: string | null;
86
+ /** Service seat model (available when sourced from OAuth userinfo) */
87
+ seatModel?: FFIDSeatModel | undefined;
88
+ /** Member role in the resolved organization context */
89
+ memberRole?: FFIDOAuthUserInfoMemberRole | undefined;
90
+ /** Organization ID used to resolve subscription access */
91
+ organizationId?: string | null | undefined;
92
+ }
93
+ /** OAuth userinfo subscription summary */
94
+ interface FFIDOAuthUserInfoSubscription {
95
+ status: 'trialing' | 'active' | 'past_due' | 'canceled' | 'paused' | null;
96
+ planCode: string | null;
97
+ seatModel: FFIDSeatModel | null;
98
+ memberRole: FFIDOAuthUserInfoMemberRole | null;
99
+ organizationId: string | null;
100
+ }
101
+ /** OAuth userinfo response exposed by FFID */
102
+ interface FFIDOAuthUserInfo {
103
+ sub: string;
104
+ email: string | null;
105
+ name: string | null;
106
+ picture: string | null;
107
+ organizationId?: string | null;
108
+ subscription?: FFIDOAuthUserInfoSubscription;
83
109
  }
84
110
  /**
85
111
  * SDK configuration options
@@ -107,6 +133,10 @@ interface FFIDConfig {
107
133
  onAuthStateChange?: ((user: FFIDUser | null) => void) | undefined;
108
134
  /** Callback on authentication error */
109
135
  onError?: ((error: FFIDError) => void) | undefined;
136
+ /** Authentication mode: 'cookie' (default) or 'token' (OAuth Bearer) */
137
+ authMode?: 'cookie' | 'token' | undefined;
138
+ /** Client ID for token mode (defaults to serviceCode if not set) */
139
+ clientId?: string | undefined;
110
140
  }
111
141
  /**
112
142
  * FFID context value provided to consumers
@@ -202,6 +232,15 @@ type FFIDApiResponse<T> = {
202
232
  data?: undefined;
203
233
  error: FFIDError;
204
234
  };
235
+ /**
236
+ * OAuth 2.0 token response from FFID token endpoint
237
+ */
238
+ interface FFIDOAuthTokenResponse {
239
+ access_token: string;
240
+ token_type: 'Bearer';
241
+ expires_in: number;
242
+ refresh_token: string;
243
+ }
205
244
 
206
245
  /**
207
246
  * FFID Announcements SDK Type Definitions
@@ -564,4 +603,4 @@ interface FFIDAnnouncementListProps {
564
603
  */
565
604
  declare function FFIDAnnouncementList({ announcements, isLoading, className, classNames, style, formatDate, emptyMessage, loadingRender, renderItem, maxContentLines, }: FFIDAnnouncementListProps): react_jsx_runtime.JSX.Element;
566
605
 
567
- export { type AnnouncementListResponse as A, type FFIDAnnouncementBadgeClassNames as B, type FFIDAnnouncementBadgeProps as C, type FFIDAnnouncementListClassNames as D, type FFIDAnnouncementListProps as E, type FFIDConfig as F, type FFIDLoginButtonProps as G, type FFIDOrganizationSwitcherClassNames as H, type FFIDOrganizationSwitcherProps as I, type FFIDSubscriptionBadgeClassNames as J, type FFIDSubscriptionBadgeProps as K, type ListAnnouncementsOptions as L, type FFIDUserMenuClassNames as M, type FFIDUserMenuProps as N, type UseFFIDAnnouncementsOptions as U, type FFIDUser as a, type FFIDOrganization as b, type FFIDError as c, type FFIDSubscriptionContextValue as d, type FFIDAnnouncementsClientConfig as e, type FFIDAnnouncementsApiResponse as f, type FFIDAnnouncementsLogger as g, type Announcement as h, type AnnouncementStatus as i, type AnnouncementType as j, FFIDAnnouncementBadge as k, FFIDAnnouncementList as l, type FFIDAnnouncementsError as m, type FFIDAnnouncementsErrorCode as n, type FFIDAnnouncementsServerResponse as o, type FFIDApiResponse as p, type FFIDContextValue as q, type FFIDLogger as r, FFIDLoginButton as s, FFIDOrganizationSwitcher as t, type FFIDSessionResponse as u, type FFIDSubscription as v, FFIDSubscriptionBadge as w, FFIDUserMenu as x, type UseFFIDAnnouncementsReturn as y, useFFIDAnnouncements as z };
606
+ export { type AnnouncementListResponse as A, type FFIDSubscription as B, FFIDSubscriptionBadge as C, FFIDUserMenu as D, type UseFFIDAnnouncementsReturn as E, type FFIDConfig as F, useFFIDAnnouncements as G, type FFIDAnnouncementBadgeClassNames as H, type FFIDAnnouncementBadgeProps as I, type FFIDAnnouncementListClassNames as J, type FFIDAnnouncementListProps as K, type ListAnnouncementsOptions as L, type FFIDLoginButtonProps as M, type FFIDOrganizationSwitcherClassNames as N, type FFIDOrganizationSwitcherProps as O, type FFIDSubscriptionBadgeClassNames as P, type FFIDSubscriptionBadgeProps as Q, type FFIDUserMenuClassNames as R, type FFIDUserMenuProps as S, type UseFFIDAnnouncementsOptions as U, type FFIDUser as a, type FFIDOrganization as b, type FFIDError as c, type FFIDSubscriptionContextValue as d, type FFIDAnnouncementsClientConfig as e, type FFIDAnnouncementsApiResponse as f, type FFIDAnnouncementsLogger as g, type Announcement as h, type AnnouncementStatus as i, type AnnouncementType as j, FFIDAnnouncementBadge as k, FFIDAnnouncementList as l, type FFIDAnnouncementsError as m, type FFIDAnnouncementsErrorCode as n, type FFIDAnnouncementsServerResponse as o, type FFIDApiResponse as p, type FFIDContextValue as q, type FFIDLogger as r, FFIDLoginButton as s, type FFIDOAuthTokenResponse as t, type FFIDOAuthUserInfo as u, type FFIDOAuthUserInfoMemberRole as v, type FFIDOAuthUserInfoSubscription as w, FFIDOrganizationSwitcher as x, type FFIDSeatModel as y, type FFIDSessionResponse as z };
package/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkA6YJDYIX_cjs = require('./chunk-A6YJDYIX.cjs');
3
+ var chunkTL6U5TJT_cjs = require('./chunk-TL6U5TJT.cjs');
4
4
  var react = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
 
7
7
  function withFFIDAuth(Component, options = {}) {
8
8
  const WrappedComponent = (props) => {
9
- const { isLoading, isAuthenticated, login } = chunkA6YJDYIX_cjs.useFFIDContext();
9
+ const { isLoading, isAuthenticated, login } = chunkTL6U5TJT_cjs.useFFIDContext();
10
10
  const hasRedirected = react.useRef(false);
11
11
  react.useEffect(() => {
12
12
  if (!isLoading && !isAuthenticated && options.redirectToLogin && !hasRedirected.current) {
@@ -31,58 +31,78 @@ function withFFIDAuth(Component, options = {}) {
31
31
 
32
32
  Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
33
33
  enumerable: true,
34
- get: function () { return chunkA6YJDYIX_cjs.DEFAULT_API_BASE_URL; }
34
+ get: function () { return chunkTL6U5TJT_cjs.DEFAULT_API_BASE_URL; }
35
35
  });
36
36
  Object.defineProperty(exports, "FFIDAnnouncementBadge", {
37
37
  enumerable: true,
38
- get: function () { return chunkA6YJDYIX_cjs.FFIDAnnouncementBadge; }
38
+ get: function () { return chunkTL6U5TJT_cjs.FFIDAnnouncementBadge; }
39
39
  });
40
40
  Object.defineProperty(exports, "FFIDAnnouncementList", {
41
41
  enumerable: true,
42
- get: function () { return chunkA6YJDYIX_cjs.FFIDAnnouncementList; }
42
+ get: function () { return chunkTL6U5TJT_cjs.FFIDAnnouncementList; }
43
43
  });
44
44
  Object.defineProperty(exports, "FFIDLoginButton", {
45
45
  enumerable: true,
46
- get: function () { return chunkA6YJDYIX_cjs.FFIDLoginButton; }
46
+ get: function () { return chunkTL6U5TJT_cjs.FFIDLoginButton; }
47
47
  });
48
48
  Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
49
49
  enumerable: true,
50
- get: function () { return chunkA6YJDYIX_cjs.FFIDOrganizationSwitcher; }
50
+ get: function () { return chunkTL6U5TJT_cjs.FFIDOrganizationSwitcher; }
51
51
  });
52
52
  Object.defineProperty(exports, "FFIDProvider", {
53
53
  enumerable: true,
54
- get: function () { return chunkA6YJDYIX_cjs.FFIDProvider; }
54
+ get: function () { return chunkTL6U5TJT_cjs.FFIDProvider; }
55
55
  });
56
56
  Object.defineProperty(exports, "FFIDSubscriptionBadge", {
57
57
  enumerable: true,
58
- get: function () { return chunkA6YJDYIX_cjs.FFIDSubscriptionBadge; }
58
+ get: function () { return chunkTL6U5TJT_cjs.FFIDSubscriptionBadge; }
59
59
  });
60
60
  Object.defineProperty(exports, "FFIDUserMenu", {
61
61
  enumerable: true,
62
- get: function () { return chunkA6YJDYIX_cjs.FFIDUserMenu; }
62
+ get: function () { return chunkTL6U5TJT_cjs.FFIDUserMenu; }
63
63
  });
64
64
  Object.defineProperty(exports, "FFID_ANNOUNCEMENTS_ERROR_CODES", {
65
65
  enumerable: true,
66
- get: function () { return chunkA6YJDYIX_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
66
+ get: function () { return chunkTL6U5TJT_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
67
67
  });
68
68
  Object.defineProperty(exports, "createFFIDAnnouncementsClient", {
69
69
  enumerable: true,
70
- get: function () { return chunkA6YJDYIX_cjs.createFFIDAnnouncementsClient; }
70
+ get: function () { return chunkTL6U5TJT_cjs.createFFIDAnnouncementsClient; }
71
+ });
72
+ Object.defineProperty(exports, "createTokenStore", {
73
+ enumerable: true,
74
+ get: function () { return chunkTL6U5TJT_cjs.createTokenStore; }
75
+ });
76
+ Object.defineProperty(exports, "generateCodeChallenge", {
77
+ enumerable: true,
78
+ get: function () { return chunkTL6U5TJT_cjs.generateCodeChallenge; }
79
+ });
80
+ Object.defineProperty(exports, "generateCodeVerifier", {
81
+ enumerable: true,
82
+ get: function () { return chunkTL6U5TJT_cjs.generateCodeVerifier; }
83
+ });
84
+ Object.defineProperty(exports, "retrieveCodeVerifier", {
85
+ enumerable: true,
86
+ get: function () { return chunkTL6U5TJT_cjs.retrieveCodeVerifier; }
87
+ });
88
+ Object.defineProperty(exports, "storeCodeVerifier", {
89
+ enumerable: true,
90
+ get: function () { return chunkTL6U5TJT_cjs.storeCodeVerifier; }
71
91
  });
72
92
  Object.defineProperty(exports, "useFFID", {
73
93
  enumerable: true,
74
- get: function () { return chunkA6YJDYIX_cjs.useFFID; }
94
+ get: function () { return chunkTL6U5TJT_cjs.useFFID; }
75
95
  });
76
96
  Object.defineProperty(exports, "useFFIDAnnouncements", {
77
97
  enumerable: true,
78
- get: function () { return chunkA6YJDYIX_cjs.useFFIDAnnouncements; }
98
+ get: function () { return chunkTL6U5TJT_cjs.useFFIDAnnouncements; }
79
99
  });
80
100
  Object.defineProperty(exports, "useSubscription", {
81
101
  enumerable: true,
82
- get: function () { return chunkA6YJDYIX_cjs.useSubscription; }
102
+ get: function () { return chunkTL6U5TJT_cjs.useSubscription; }
83
103
  });
84
104
  Object.defineProperty(exports, "withSubscription", {
85
105
  enumerable: true,
86
- get: function () { return chunkA6YJDYIX_cjs.withSubscription; }
106
+ get: function () { return chunkTL6U5TJT_cjs.withSubscription; }
87
107
  });
88
108
  exports.withFFIDAuth = withFFIDAuth;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, ComponentType, FC } from 'react';
3
- import { F as FFIDConfig, a as FFIDUser, b as FFIDOrganization, c as FFIDError, d as FFIDSubscriptionContextValue, e as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, f as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, g as FFIDAnnouncementsLogger } from './index-DBp3Ulyl.cjs';
4
- export { h as Announcement, i as AnnouncementStatus, j as AnnouncementType, k as FFIDAnnouncementBadge, l as FFIDAnnouncementList, m as FFIDAnnouncementsError, n as FFIDAnnouncementsErrorCode, o as FFIDAnnouncementsServerResponse, p as FFIDApiResponse, q as FFIDContextValue, r as FFIDLogger, s as FFIDLoginButton, t as FFIDOrganizationSwitcher, u as FFIDSessionResponse, v as FFIDSubscription, w as FFIDSubscriptionBadge, x as FFIDUserMenu, U as UseFFIDAnnouncementsOptions, y as UseFFIDAnnouncementsReturn, z as useFFIDAnnouncements } from './index-DBp3Ulyl.cjs';
3
+ import { F as FFIDConfig, a as FFIDUser, b as FFIDOrganization, c as FFIDError, d as FFIDSubscriptionContextValue, e as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, f as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, g as FFIDAnnouncementsLogger } from './index-CyYHo3-R.cjs';
4
+ export { h as Announcement, i as AnnouncementStatus, j as AnnouncementType, k as FFIDAnnouncementBadge, l as FFIDAnnouncementList, m as FFIDAnnouncementsError, n as FFIDAnnouncementsErrorCode, o as FFIDAnnouncementsServerResponse, p as FFIDApiResponse, q as FFIDContextValue, r as FFIDLogger, s as FFIDLoginButton, t as FFIDOAuthTokenResponse, u as FFIDOAuthUserInfo, v as FFIDOAuthUserInfoMemberRole, w as FFIDOAuthUserInfoSubscription, x as FFIDOrganizationSwitcher, y as FFIDSeatModel, z as FFIDSessionResponse, B as FFIDSubscription, C as FFIDSubscriptionBadge, D as FFIDUserMenu, U as UseFFIDAnnouncementsOptions, E as UseFFIDAnnouncementsReturn, G as useFFIDAnnouncements } from './index-CyYHo3-R.cjs';
5
5
 
6
6
  /**
7
7
  * FFID SDK Shared Constants
@@ -12,6 +12,78 @@ export { h as Announcement, i as AnnouncementStatus, j as AnnouncementType, k as
12
12
  /** Default FFID API base URL (production) */
13
13
  declare const DEFAULT_API_BASE_URL = "https://id.feelflow.co.jp";
14
14
 
15
+ /**
16
+ * Token Store
17
+ *
18
+ * Manages OAuth 2.0 tokens (access + refresh) with dual-storage support.
19
+ * Falls back to in-memory storage when localStorage is unavailable
20
+ * (e.g., Safari private browsing mode).
21
+ */
22
+ /**
23
+ * Token data stored by the token store
24
+ */
25
+ interface TokenData {
26
+ /** OAuth 2.0 access token */
27
+ accessToken: string;
28
+ /** OAuth 2.0 refresh token */
29
+ refreshToken: string;
30
+ /** Expiration timestamp in milliseconds (Unix epoch) */
31
+ expiresAt: number;
32
+ }
33
+ /**
34
+ * Token store interface for managing OAuth tokens
35
+ */
36
+ interface TokenStore {
37
+ /** Get stored tokens (null if not stored) */
38
+ getTokens(): TokenData | null;
39
+ /** Store new tokens */
40
+ setTokens(tokens: TokenData): void;
41
+ /** Clear all stored tokens */
42
+ clearTokens(): void;
43
+ /** Check if access token is expired (with 30s buffer) */
44
+ isAccessTokenExpired(): boolean;
45
+ }
46
+ /**
47
+ * Create a token store with the specified storage type.
48
+ *
49
+ * When storageType is 'localStorage' (default in browser), falls back
50
+ * to memory if localStorage is not available (e.g., Safari private mode).
51
+ *
52
+ * @param storageType - 'localStorage' (default) or 'memory'
53
+ */
54
+ declare function createTokenStore(storageType?: 'localStorage' | 'memory'): TokenStore;
55
+
56
+ /**
57
+ * Generate a random code verifier (43-128 characters, RFC 7636 Section 4.1).
58
+ *
59
+ * Uses crypto.getRandomValues for cryptographic randomness.
60
+ */
61
+ declare function generateCodeVerifier(): string;
62
+ /**
63
+ * Generate S256 code challenge from a code verifier (RFC 7636 Section 4.2).
64
+ *
65
+ * Computes SHA-256 hash of the verifier, then base64url-encodes the result.
66
+ *
67
+ * @param verifier - The code verifier string
68
+ * @returns base64url-encoded SHA-256 hash
69
+ */
70
+ declare function generateCodeChallenge(verifier: string): Promise<string>;
71
+ /**
72
+ * Store code verifier in sessionStorage for later retrieval.
73
+ * Uses window.sessionStorage explicitly to ensure browser Web Storage API.
74
+ *
75
+ * @param verifier - The code verifier to store
76
+ */
77
+ declare function storeCodeVerifier(verifier: string): void;
78
+ /**
79
+ * Retrieve and remove the code verifier from sessionStorage.
80
+ * Uses window.sessionStorage explicitly to ensure browser Web Storage API.
81
+ *
82
+ * Returns null if no verifier is stored.
83
+ * Removes the verifier after retrieval (one-time use).
84
+ */
85
+ declare function retrieveCodeVerifier(): string | null;
86
+
15
87
  /**
16
88
  * Props for FFIDProvider component
17
89
  */
@@ -27,8 +99,9 @@ interface FFIDProviderProps extends FFIDConfig {
27
99
  * - User authentication state
28
100
  * - Organization switching
29
101
  * - Automatic session refresh
102
+ * - Token mode: automatic code exchange and token refresh
30
103
  */
31
- declare function FFIDProvider({ children, serviceCode, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
104
+ declare function FFIDProvider({ children, serviceCode, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, authMode, clientId, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
32
105
 
33
106
  /**
34
107
  * Return type for useFFID hook
@@ -54,6 +127,10 @@ interface UseFFIDReturn {
54
127
  switchOrganization: (organizationId: string) => void;
55
128
  /** Refresh session data */
56
129
  refresh: () => Promise<void>;
130
+ /** Get login URL with redirect parameter */
131
+ getLoginUrl: (redirectUrl?: string) => string;
132
+ /** Get signup URL with redirect parameter */
133
+ getSignupUrl: (redirectUrl?: string) => string;
57
134
  }
58
135
  /**
59
136
  * Hook to access FFID authentication and user data
@@ -233,4 +310,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
233
310
  /** Type of the FFID Announcements client */
234
311
  type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
235
312
 
236
- export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDConfig, FFIDError, FFIDOrganization, FFIDProvider, type FFIDProviderProps, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, ListAnnouncementsOptions, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, useFFID, useSubscription, withFFIDAuth, withSubscription };
313
+ export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDConfig, FFIDError, FFIDOrganization, FFIDProvider, type FFIDProviderProps, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, ListAnnouncementsOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, ComponentType, FC } from 'react';
3
- import { F as FFIDConfig, a as FFIDUser, b as FFIDOrganization, c as FFIDError, d as FFIDSubscriptionContextValue, e as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, f as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, g as FFIDAnnouncementsLogger } from './index-DBp3Ulyl.js';
4
- export { h as Announcement, i as AnnouncementStatus, j as AnnouncementType, k as FFIDAnnouncementBadge, l as FFIDAnnouncementList, m as FFIDAnnouncementsError, n as FFIDAnnouncementsErrorCode, o as FFIDAnnouncementsServerResponse, p as FFIDApiResponse, q as FFIDContextValue, r as FFIDLogger, s as FFIDLoginButton, t as FFIDOrganizationSwitcher, u as FFIDSessionResponse, v as FFIDSubscription, w as FFIDSubscriptionBadge, x as FFIDUserMenu, U as UseFFIDAnnouncementsOptions, y as UseFFIDAnnouncementsReturn, z as useFFIDAnnouncements } from './index-DBp3Ulyl.js';
3
+ import { F as FFIDConfig, a as FFIDUser, b as FFIDOrganization, c as FFIDError, d as FFIDSubscriptionContextValue, e as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, f as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, g as FFIDAnnouncementsLogger } from './index-CyYHo3-R.js';
4
+ export { h as Announcement, i as AnnouncementStatus, j as AnnouncementType, k as FFIDAnnouncementBadge, l as FFIDAnnouncementList, m as FFIDAnnouncementsError, n as FFIDAnnouncementsErrorCode, o as FFIDAnnouncementsServerResponse, p as FFIDApiResponse, q as FFIDContextValue, r as FFIDLogger, s as FFIDLoginButton, t as FFIDOAuthTokenResponse, u as FFIDOAuthUserInfo, v as FFIDOAuthUserInfoMemberRole, w as FFIDOAuthUserInfoSubscription, x as FFIDOrganizationSwitcher, y as FFIDSeatModel, z as FFIDSessionResponse, B as FFIDSubscription, C as FFIDSubscriptionBadge, D as FFIDUserMenu, U as UseFFIDAnnouncementsOptions, E as UseFFIDAnnouncementsReturn, G as useFFIDAnnouncements } from './index-CyYHo3-R.js';
5
5
 
6
6
  /**
7
7
  * FFID SDK Shared Constants
@@ -12,6 +12,78 @@ export { h as Announcement, i as AnnouncementStatus, j as AnnouncementType, k as
12
12
  /** Default FFID API base URL (production) */
13
13
  declare const DEFAULT_API_BASE_URL = "https://id.feelflow.co.jp";
14
14
 
15
+ /**
16
+ * Token Store
17
+ *
18
+ * Manages OAuth 2.0 tokens (access + refresh) with dual-storage support.
19
+ * Falls back to in-memory storage when localStorage is unavailable
20
+ * (e.g., Safari private browsing mode).
21
+ */
22
+ /**
23
+ * Token data stored by the token store
24
+ */
25
+ interface TokenData {
26
+ /** OAuth 2.0 access token */
27
+ accessToken: string;
28
+ /** OAuth 2.0 refresh token */
29
+ refreshToken: string;
30
+ /** Expiration timestamp in milliseconds (Unix epoch) */
31
+ expiresAt: number;
32
+ }
33
+ /**
34
+ * Token store interface for managing OAuth tokens
35
+ */
36
+ interface TokenStore {
37
+ /** Get stored tokens (null if not stored) */
38
+ getTokens(): TokenData | null;
39
+ /** Store new tokens */
40
+ setTokens(tokens: TokenData): void;
41
+ /** Clear all stored tokens */
42
+ clearTokens(): void;
43
+ /** Check if access token is expired (with 30s buffer) */
44
+ isAccessTokenExpired(): boolean;
45
+ }
46
+ /**
47
+ * Create a token store with the specified storage type.
48
+ *
49
+ * When storageType is 'localStorage' (default in browser), falls back
50
+ * to memory if localStorage is not available (e.g., Safari private mode).
51
+ *
52
+ * @param storageType - 'localStorage' (default) or 'memory'
53
+ */
54
+ declare function createTokenStore(storageType?: 'localStorage' | 'memory'): TokenStore;
55
+
56
+ /**
57
+ * Generate a random code verifier (43-128 characters, RFC 7636 Section 4.1).
58
+ *
59
+ * Uses crypto.getRandomValues for cryptographic randomness.
60
+ */
61
+ declare function generateCodeVerifier(): string;
62
+ /**
63
+ * Generate S256 code challenge from a code verifier (RFC 7636 Section 4.2).
64
+ *
65
+ * Computes SHA-256 hash of the verifier, then base64url-encodes the result.
66
+ *
67
+ * @param verifier - The code verifier string
68
+ * @returns base64url-encoded SHA-256 hash
69
+ */
70
+ declare function generateCodeChallenge(verifier: string): Promise<string>;
71
+ /**
72
+ * Store code verifier in sessionStorage for later retrieval.
73
+ * Uses window.sessionStorage explicitly to ensure browser Web Storage API.
74
+ *
75
+ * @param verifier - The code verifier to store
76
+ */
77
+ declare function storeCodeVerifier(verifier: string): void;
78
+ /**
79
+ * Retrieve and remove the code verifier from sessionStorage.
80
+ * Uses window.sessionStorage explicitly to ensure browser Web Storage API.
81
+ *
82
+ * Returns null if no verifier is stored.
83
+ * Removes the verifier after retrieval (one-time use).
84
+ */
85
+ declare function retrieveCodeVerifier(): string | null;
86
+
15
87
  /**
16
88
  * Props for FFIDProvider component
17
89
  */
@@ -27,8 +99,9 @@ interface FFIDProviderProps extends FFIDConfig {
27
99
  * - User authentication state
28
100
  * - Organization switching
29
101
  * - Automatic session refresh
102
+ * - Token mode: automatic code exchange and token refresh
30
103
  */
31
- declare function FFIDProvider({ children, serviceCode, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
104
+ declare function FFIDProvider({ children, serviceCode, apiBaseUrl, debug, logger, refreshInterval, onAuthStateChange, onError, authMode, clientId, }: FFIDProviderProps): react_jsx_runtime.JSX.Element;
32
105
 
33
106
  /**
34
107
  * Return type for useFFID hook
@@ -54,6 +127,10 @@ interface UseFFIDReturn {
54
127
  switchOrganization: (organizationId: string) => void;
55
128
  /** Refresh session data */
56
129
  refresh: () => Promise<void>;
130
+ /** Get login URL with redirect parameter */
131
+ getLoginUrl: (redirectUrl?: string) => string;
132
+ /** Get signup URL with redirect parameter */
133
+ getSignupUrl: (redirectUrl?: string) => string;
57
134
  }
58
135
  /**
59
136
  * Hook to access FFID authentication and user data
@@ -233,4 +310,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
233
310
  /** Type of the FFID Announcements client */
234
311
  type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
235
312
 
236
- export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDConfig, FFIDError, FFIDOrganization, FFIDProvider, type FFIDProviderProps, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, ListAnnouncementsOptions, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, useFFID, useSubscription, withFFIDAuth, withSubscription };
313
+ export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDConfig, FFIDError, FFIDOrganization, FFIDProvider, type FFIDProviderProps, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, ListAnnouncementsOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useFFIDContext } from './chunk-VXBUXOLF.js';
2
- export { DEFAULT_API_BASE_URL, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, createFFIDAnnouncementsClient, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-VXBUXOLF.js';
1
+ import { useFFIDContext } from './chunk-K525KYQP.js';
2
+ export { DEFAULT_API_BASE_URL, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, createFFIDAnnouncementsClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-K525KYQP.js';
3
3
  import { useRef, useEffect } from 'react';
4
4
  import { jsx, Fragment } from 'react/jsx-runtime';
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feelflow/ffid-sdk",
3
- "version": "0.3.0",
3
+ "version": "1.1.0",
4
4
  "description": "FeelFlow ID Platform SDK for React/Next.js applications",
5
5
  "keywords": [
6
6
  "feelflow",