@feelflow/ffid-sdk 1.8.0 → 1.9.1
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/README.md +1 -1
- package/dist/agency/index.cjs +3 -3
- package/dist/agency/index.d.cts +1 -1
- package/dist/agency/index.d.ts +1 -1
- package/dist/agency/index.js +2 -2
- package/dist/announcements/index.cjs +2 -2
- package/dist/announcements/index.d.cts +2 -2
- package/dist/announcements/index.d.ts +2 -2
- package/dist/announcements/index.js +1 -1
- package/dist/{chunk-DEN7AUNE.cjs → chunk-AD2MA4LH.cjs} +65 -17
- package/dist/chunk-QBRM2RRC.js +4 -0
- package/dist/{chunk-7WZBWL56.js → chunk-S7GPQ4OJ.js} +65 -17
- package/dist/{chunk-P5PPUZGX.cjs → chunk-YUIITYBE.cjs} +1 -1
- package/dist/components/index.cjs +7 -7
- 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/{constants-BeWMWOOd.d.cts → constants-DvTGHPZn.d.cts} +1 -1
- package/dist/{constants-BeWMWOOd.d.ts → constants-DvTGHPZn.d.ts} +1 -1
- package/dist/{index-ea8WAh39.d.cts → index-DsXjcF0i.d.cts} +36 -2
- package/dist/{index-ea8WAh39.d.ts → index-DsXjcF0i.d.ts} +36 -2
- package/dist/index.cjs +64 -22
- package/dist/index.d.cts +28 -5
- package/dist/index.d.ts +28 -5
- package/dist/index.js +43 -3
- package/dist/legal/index.cjs +3 -3
- package/dist/legal/index.d.cts +3 -3
- package/dist/legal/index.d.ts +3 -3
- package/dist/legal/index.js +2 -2
- package/package.json +4 -3
- package/dist/chunk-P4MLCG4T.js +0 -4
package/README.md
CHANGED
|
@@ -369,7 +369,7 @@ SDK の `package.json` で `react` / `react-dom` は `optional: true` に設定
|
|
|
369
369
|
オプションで環境変数を使用してデフォルト設定を上書きできます:
|
|
370
370
|
|
|
371
371
|
```bash
|
|
372
|
-
NEXT_PUBLIC_FFID_API_URL=https://id.feelflow.
|
|
372
|
+
NEXT_PUBLIC_FFID_API_URL=https://id.feelflow.net
|
|
373
373
|
NEXT_PUBLIC_FFID_SERVICE_CODE=chatbot
|
|
374
374
|
```
|
|
375
375
|
|
package/dist/agency/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYUIITYBE_cjs = require('../chunk-YUIITYBE.cjs');
|
|
4
4
|
|
|
5
5
|
// src/agency/ffid-agency-client.ts
|
|
6
6
|
var API_PREFIX = "/api/v1/agencies";
|
|
@@ -26,7 +26,7 @@ var consoleLogger = {
|
|
|
26
26
|
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
27
27
|
};
|
|
28
28
|
function createFFIDAgencyClient(config = {}) {
|
|
29
|
-
const baseUrl = config.apiBaseUrl ??
|
|
29
|
+
const baseUrl = config.apiBaseUrl ?? chunkYUIITYBE_cjs.DEFAULT_API_BASE_URL;
|
|
30
30
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
31
31
|
function validateIds(...pairs) {
|
|
32
32
|
for (const [value, name] of pairs) {
|
|
@@ -316,7 +316,7 @@ function createFFIDAgencyClient(config = {}) {
|
|
|
316
316
|
|
|
317
317
|
Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
|
|
318
318
|
enumerable: true,
|
|
319
|
-
get: function () { return
|
|
319
|
+
get: function () { return chunkYUIITYBE_cjs.DEFAULT_API_BASE_URL; }
|
|
320
320
|
});
|
|
321
321
|
exports.FFID_AGENCY_ERROR_CODES = FFID_AGENCY_ERROR_CODES;
|
|
322
322
|
exports.createFFIDAgencyClient = createFFIDAgencyClient;
|
package/dist/agency/index.d.cts
CHANGED
package/dist/agency/index.d.ts
CHANGED
package/dist/agency/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DEFAULT_API_BASE_URL } from '../chunk-
|
|
2
|
-
export { DEFAULT_API_BASE_URL } from '../chunk-
|
|
1
|
+
import { DEFAULT_API_BASE_URL } from '../chunk-QBRM2RRC.js';
|
|
2
|
+
export { DEFAULT_API_BASE_URL } from '../chunk-QBRM2RRC.js';
|
|
3
3
|
|
|
4
4
|
// src/agency/ffid-agency-client.ts
|
|
5
5
|
var API_PREFIX = "/api/v1/agencies";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYUIITYBE_cjs = require('../chunk-YUIITYBE.cjs');
|
|
4
4
|
|
|
5
5
|
// src/announcements/ffid-announcements-client.ts
|
|
6
6
|
var API_PATH = "/api/v1/announcements";
|
|
@@ -29,7 +29,7 @@ var consoleLogger = {
|
|
|
29
29
|
error: (...args) => console.error(SDK_LOG_PREFIX, ...args)
|
|
30
30
|
};
|
|
31
31
|
function createFFIDAnnouncementsClient(config = {}) {
|
|
32
|
-
const baseUrl = config.apiBaseUrl ??
|
|
32
|
+
const baseUrl = config.apiBaseUrl ?? chunkYUIITYBE_cjs.DEFAULT_API_BASE_URL;
|
|
33
33
|
const logger = config.logger ?? (config.debug ? consoleLogger : quietLogger);
|
|
34
34
|
async function fetchApi(endpoint) {
|
|
35
35
|
const url = `${baseUrl}${endpoint}`;
|
|
@@ -55,7 +55,7 @@ interface ListAnnouncementsOptions {
|
|
|
55
55
|
}
|
|
56
56
|
/** Configuration for the FFID Announcements Client */
|
|
57
57
|
interface FFIDAnnouncementsClientConfig {
|
|
58
|
-
/** FFID API base URL (defaults to https://id.feelflow.
|
|
58
|
+
/** FFID API base URL (defaults to https://id.feelflow.net) */
|
|
59
59
|
apiBaseUrl?: string | undefined;
|
|
60
60
|
/** Enable debug logging */
|
|
61
61
|
debug?: boolean | undefined;
|
|
@@ -118,7 +118,7 @@ type FFIDAnnouncementsServerResponse<T> = {
|
|
|
118
118
|
* import { createFFIDAnnouncementsClient } from '@feelflow/ffid-sdk/announcements'
|
|
119
119
|
*
|
|
120
120
|
* const client = createFFIDAnnouncementsClient({
|
|
121
|
-
* apiBaseUrl: 'https://id.feelflow.
|
|
121
|
+
* apiBaseUrl: 'https://id.feelflow.net',
|
|
122
122
|
* })
|
|
123
123
|
*
|
|
124
124
|
* const { data, error } = await client.listAnnouncements({ limit: 10 })
|
|
@@ -55,7 +55,7 @@ interface ListAnnouncementsOptions {
|
|
|
55
55
|
}
|
|
56
56
|
/** Configuration for the FFID Announcements Client */
|
|
57
57
|
interface FFIDAnnouncementsClientConfig {
|
|
58
|
-
/** FFID API base URL (defaults to https://id.feelflow.
|
|
58
|
+
/** FFID API base URL (defaults to https://id.feelflow.net) */
|
|
59
59
|
apiBaseUrl?: string | undefined;
|
|
60
60
|
/** Enable debug logging */
|
|
61
61
|
debug?: boolean | undefined;
|
|
@@ -118,7 +118,7 @@ type FFIDAnnouncementsServerResponse<T> = {
|
|
|
118
118
|
* import { createFFIDAnnouncementsClient } from '@feelflow/ffid-sdk/announcements'
|
|
119
119
|
*
|
|
120
120
|
* const client = createFFIDAnnouncementsClient({
|
|
121
|
-
* apiBaseUrl: 'https://id.feelflow.
|
|
121
|
+
* apiBaseUrl: 'https://id.feelflow.net',
|
|
122
122
|
* })
|
|
123
123
|
*
|
|
124
124
|
* const { data, error } = await client.listAnnouncements({ limit: 10 })
|
|
@@ -5,7 +5,7 @@ var jose = require('jose');
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
|
|
7
7
|
// src/constants.ts
|
|
8
|
-
var DEFAULT_API_BASE_URL = "https://id.feelflow.
|
|
8
|
+
var DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
9
9
|
|
|
10
10
|
// src/auth/token-store.ts
|
|
11
11
|
var STORAGE_KEY = "ffid_tokens";
|
|
@@ -181,7 +181,7 @@ function mapUserinfoSubscriptionToSession(userinfo, serviceCode) {
|
|
|
181
181
|
];
|
|
182
182
|
}
|
|
183
183
|
var JWKS_ENDPOINT = "/.well-known/jwks.json";
|
|
184
|
-
var JWT_ISSUER = "https://id.feelflow.
|
|
184
|
+
var JWT_ISSUER = "https://id.feelflow.net";
|
|
185
185
|
var JWT_ALGORITHM = "ES256";
|
|
186
186
|
var JWT_CLOCK_TOLERANCE_SECONDS = 30;
|
|
187
187
|
function createJwtVerifier(deps) {
|
|
@@ -238,8 +238,11 @@ function createJwtVerifier(deps) {
|
|
|
238
238
|
|
|
239
239
|
// src/client/verify-access-token.ts
|
|
240
240
|
var OAUTH_INTROSPECT_ENDPOINT = "/api/v1/oauth/introspect";
|
|
241
|
+
var CACHE_KEY_PREFIX = "ffid:introspect:";
|
|
242
|
+
var HEX_BASE = 16;
|
|
243
|
+
var HEX_BYTE_WIDTH = 2;
|
|
241
244
|
function createVerifyAccessToken(deps) {
|
|
242
|
-
const { authMode, baseUrl, serviceCode, serviceApiKey, verifyStrategy, logger, createError, errorCodes } = deps;
|
|
245
|
+
const { authMode, baseUrl, serviceCode, serviceApiKey, verifyStrategy, logger, createError, errorCodes, cache, timeout } = deps;
|
|
243
246
|
let jwtVerify2 = null;
|
|
244
247
|
function getJwtVerifier() {
|
|
245
248
|
if (!jwtVerify2) {
|
|
@@ -286,17 +289,33 @@ function createVerifyAccessToken(deps) {
|
|
|
286
289
|
}
|
|
287
290
|
const url = `${baseUrl}${OAUTH_INTROSPECT_ENDPOINT}`;
|
|
288
291
|
logger.debug("Verifying access token:", url);
|
|
292
|
+
const cacheKey = await buildCacheKey(accessToken);
|
|
293
|
+
if (cache) {
|
|
294
|
+
try {
|
|
295
|
+
const cached = await cache.adapter.get(cacheKey);
|
|
296
|
+
if (cached && typeof cached === "object" && "sub" in cached) {
|
|
297
|
+
logger.debug("Cache hit for introspect result");
|
|
298
|
+
return { data: cached };
|
|
299
|
+
}
|
|
300
|
+
} catch (cacheError) {
|
|
301
|
+
logger.warn("Cache read failed, falling back to API call:", cacheError);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const fetchOptions = {
|
|
305
|
+
method: "POST",
|
|
306
|
+
credentials: "omit",
|
|
307
|
+
headers: {
|
|
308
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
309
|
+
"X-Service-Api-Key": serviceApiKey
|
|
310
|
+
},
|
|
311
|
+
body: new URLSearchParams({ token: accessToken }).toString()
|
|
312
|
+
};
|
|
313
|
+
if (timeout !== void 0) {
|
|
314
|
+
fetchOptions.signal = AbortSignal.timeout(timeout);
|
|
315
|
+
}
|
|
289
316
|
let response;
|
|
290
317
|
try {
|
|
291
|
-
response = await fetch(url,
|
|
292
|
-
method: "POST",
|
|
293
|
-
credentials: "omit",
|
|
294
|
-
headers: {
|
|
295
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
296
|
-
"X-Service-Api-Key": serviceApiKey
|
|
297
|
-
},
|
|
298
|
-
body: new URLSearchParams({ token: accessToken }).toString()
|
|
299
|
-
});
|
|
318
|
+
response = await fetch(url, fetchOptions);
|
|
300
319
|
} catch (error) {
|
|
301
320
|
logger.error("Network error during token verification:", error);
|
|
302
321
|
return {
|
|
@@ -362,7 +381,26 @@ function createVerifyAccessToken(deps) {
|
|
|
362
381
|
organization_id: introspectResponse.subscription.organization_id
|
|
363
382
|
}
|
|
364
383
|
} : base;
|
|
365
|
-
|
|
384
|
+
const userinfo = normalizeUserinfo(raw);
|
|
385
|
+
if (cache) {
|
|
386
|
+
try {
|
|
387
|
+
await cache.adapter.set(cacheKey, userinfo, cache.ttl);
|
|
388
|
+
} catch (cacheError) {
|
|
389
|
+
logger.warn("Cache write failed (result still returned):", cacheError);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return { data: userinfo };
|
|
393
|
+
}
|
|
394
|
+
async function buildCacheKey(token) {
|
|
395
|
+
if (typeof globalThis.crypto?.subtle?.digest === "function") {
|
|
396
|
+
const encoder = new TextEncoder();
|
|
397
|
+
const data = encoder.encode(token);
|
|
398
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
399
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
400
|
+
const hashHex = hashArray.map((b) => b.toString(HEX_BASE).padStart(HEX_BYTE_WIDTH, "0")).join("");
|
|
401
|
+
return CACHE_KEY_PREFIX + hashHex;
|
|
402
|
+
}
|
|
403
|
+
return CACHE_KEY_PREFIX + token;
|
|
366
404
|
}
|
|
367
405
|
return verifyAccessToken;
|
|
368
406
|
}
|
|
@@ -415,7 +453,7 @@ function createBillingMethods(deps) {
|
|
|
415
453
|
}
|
|
416
454
|
|
|
417
455
|
// src/client/version-check.ts
|
|
418
|
-
var SDK_VERSION = "1.
|
|
456
|
+
var SDK_VERSION = "1.9.1";
|
|
419
457
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
420
458
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
421
459
|
var LATEST_VERSION_HEADER = "X-FFID-SDK-Latest-Version";
|
|
@@ -464,7 +502,7 @@ var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
|
464
502
|
var MS_PER_SECOND = 1e3;
|
|
465
503
|
var UNAUTHORIZED_STATUS = 401;
|
|
466
504
|
var STATE_RANDOM_BYTES = 16;
|
|
467
|
-
var
|
|
505
|
+
var HEX_BASE2 = 16;
|
|
468
506
|
var noopLogger = {
|
|
469
507
|
debug: () => {
|
|
470
508
|
},
|
|
@@ -499,9 +537,17 @@ function createFFIDClient(config) {
|
|
|
499
537
|
const resolvedRedirectUri = config.redirectUri ?? null;
|
|
500
538
|
const serviceApiKey = config.serviceApiKey?.trim();
|
|
501
539
|
const verifyStrategy = config.verifyStrategy ?? "jwt";
|
|
540
|
+
const cache = config.cache;
|
|
541
|
+
const timeout = config.timeout;
|
|
502
542
|
if (authMode === "service-key" && !serviceApiKey) {
|
|
503
543
|
throw new Error("FFID Client: service-key \u30E2\u30FC\u30C9\u3067\u306F serviceApiKey \u304C\u5FC5\u9808\u3067\u3059");
|
|
504
544
|
}
|
|
545
|
+
if (cache && cache.ttl <= 0) {
|
|
546
|
+
throw new Error("FFID Client: cache.ttl \u306F\u6B63\u306E\u6570\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
547
|
+
}
|
|
548
|
+
if (timeout !== void 0 && timeout <= 0) {
|
|
549
|
+
throw new Error("FFID Client: timeout \u306F\u6B63\u306E\u6570\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
550
|
+
}
|
|
505
551
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
506
552
|
const tokenStore = authMode === "token" ? createTokenStore() : createTokenStore("memory");
|
|
507
553
|
async function fetchWithAuth(endpoint, options = {}) {
|
|
@@ -1021,7 +1067,9 @@ function createFFIDClient(config) {
|
|
|
1021
1067
|
verifyStrategy,
|
|
1022
1068
|
logger,
|
|
1023
1069
|
createError,
|
|
1024
|
-
errorCodes: FFID_ERROR_CODES
|
|
1070
|
+
errorCodes: FFID_ERROR_CODES,
|
|
1071
|
+
cache,
|
|
1072
|
+
timeout
|
|
1025
1073
|
});
|
|
1026
1074
|
return {
|
|
1027
1075
|
getSession,
|
|
@@ -1051,7 +1099,7 @@ function createFFIDClient(config) {
|
|
|
1051
1099
|
function generateRandomState() {
|
|
1052
1100
|
const array = new Uint8Array(STATE_RANDOM_BYTES);
|
|
1053
1101
|
crypto.getRandomValues(array);
|
|
1054
|
-
return Array.from(array, (byte) => byte.toString(
|
|
1102
|
+
return Array.from(array, (byte) => byte.toString(HEX_BASE2).padStart(2, "0")).join("");
|
|
1055
1103
|
}
|
|
1056
1104
|
var DEFAULT_REFRESH_INTERVAL_MS = 5 * 60 * 1e3;
|
|
1057
1105
|
var TOKEN_REFRESH_RATIO = 0.8;
|
|
@@ -3,7 +3,7 @@ import { createRemoteJWKSet, jwtVerify } from 'jose';
|
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
// src/constants.ts
|
|
6
|
-
var DEFAULT_API_BASE_URL = "https://id.feelflow.
|
|
6
|
+
var DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
7
7
|
|
|
8
8
|
// src/auth/token-store.ts
|
|
9
9
|
var STORAGE_KEY = "ffid_tokens";
|
|
@@ -179,7 +179,7 @@ function mapUserinfoSubscriptionToSession(userinfo, serviceCode) {
|
|
|
179
179
|
];
|
|
180
180
|
}
|
|
181
181
|
var JWKS_ENDPOINT = "/.well-known/jwks.json";
|
|
182
|
-
var JWT_ISSUER = "https://id.feelflow.
|
|
182
|
+
var JWT_ISSUER = "https://id.feelflow.net";
|
|
183
183
|
var JWT_ALGORITHM = "ES256";
|
|
184
184
|
var JWT_CLOCK_TOLERANCE_SECONDS = 30;
|
|
185
185
|
function createJwtVerifier(deps) {
|
|
@@ -236,8 +236,11 @@ function createJwtVerifier(deps) {
|
|
|
236
236
|
|
|
237
237
|
// src/client/verify-access-token.ts
|
|
238
238
|
var OAUTH_INTROSPECT_ENDPOINT = "/api/v1/oauth/introspect";
|
|
239
|
+
var CACHE_KEY_PREFIX = "ffid:introspect:";
|
|
240
|
+
var HEX_BASE = 16;
|
|
241
|
+
var HEX_BYTE_WIDTH = 2;
|
|
239
242
|
function createVerifyAccessToken(deps) {
|
|
240
|
-
const { authMode, baseUrl, serviceCode, serviceApiKey, verifyStrategy, logger, createError, errorCodes } = deps;
|
|
243
|
+
const { authMode, baseUrl, serviceCode, serviceApiKey, verifyStrategy, logger, createError, errorCodes, cache, timeout } = deps;
|
|
241
244
|
let jwtVerify2 = null;
|
|
242
245
|
function getJwtVerifier() {
|
|
243
246
|
if (!jwtVerify2) {
|
|
@@ -284,17 +287,33 @@ function createVerifyAccessToken(deps) {
|
|
|
284
287
|
}
|
|
285
288
|
const url = `${baseUrl}${OAUTH_INTROSPECT_ENDPOINT}`;
|
|
286
289
|
logger.debug("Verifying access token:", url);
|
|
290
|
+
const cacheKey = await buildCacheKey(accessToken);
|
|
291
|
+
if (cache) {
|
|
292
|
+
try {
|
|
293
|
+
const cached = await cache.adapter.get(cacheKey);
|
|
294
|
+
if (cached && typeof cached === "object" && "sub" in cached) {
|
|
295
|
+
logger.debug("Cache hit for introspect result");
|
|
296
|
+
return { data: cached };
|
|
297
|
+
}
|
|
298
|
+
} catch (cacheError) {
|
|
299
|
+
logger.warn("Cache read failed, falling back to API call:", cacheError);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const fetchOptions = {
|
|
303
|
+
method: "POST",
|
|
304
|
+
credentials: "omit",
|
|
305
|
+
headers: {
|
|
306
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
307
|
+
"X-Service-Api-Key": serviceApiKey
|
|
308
|
+
},
|
|
309
|
+
body: new URLSearchParams({ token: accessToken }).toString()
|
|
310
|
+
};
|
|
311
|
+
if (timeout !== void 0) {
|
|
312
|
+
fetchOptions.signal = AbortSignal.timeout(timeout);
|
|
313
|
+
}
|
|
287
314
|
let response;
|
|
288
315
|
try {
|
|
289
|
-
response = await fetch(url,
|
|
290
|
-
method: "POST",
|
|
291
|
-
credentials: "omit",
|
|
292
|
-
headers: {
|
|
293
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
294
|
-
"X-Service-Api-Key": serviceApiKey
|
|
295
|
-
},
|
|
296
|
-
body: new URLSearchParams({ token: accessToken }).toString()
|
|
297
|
-
});
|
|
316
|
+
response = await fetch(url, fetchOptions);
|
|
298
317
|
} catch (error) {
|
|
299
318
|
logger.error("Network error during token verification:", error);
|
|
300
319
|
return {
|
|
@@ -360,7 +379,26 @@ function createVerifyAccessToken(deps) {
|
|
|
360
379
|
organization_id: introspectResponse.subscription.organization_id
|
|
361
380
|
}
|
|
362
381
|
} : base;
|
|
363
|
-
|
|
382
|
+
const userinfo = normalizeUserinfo(raw);
|
|
383
|
+
if (cache) {
|
|
384
|
+
try {
|
|
385
|
+
await cache.adapter.set(cacheKey, userinfo, cache.ttl);
|
|
386
|
+
} catch (cacheError) {
|
|
387
|
+
logger.warn("Cache write failed (result still returned):", cacheError);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return { data: userinfo };
|
|
391
|
+
}
|
|
392
|
+
async function buildCacheKey(token) {
|
|
393
|
+
if (typeof globalThis.crypto?.subtle?.digest === "function") {
|
|
394
|
+
const encoder = new TextEncoder();
|
|
395
|
+
const data = encoder.encode(token);
|
|
396
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
397
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
398
|
+
const hashHex = hashArray.map((b) => b.toString(HEX_BASE).padStart(HEX_BYTE_WIDTH, "0")).join("");
|
|
399
|
+
return CACHE_KEY_PREFIX + hashHex;
|
|
400
|
+
}
|
|
401
|
+
return CACHE_KEY_PREFIX + token;
|
|
364
402
|
}
|
|
365
403
|
return verifyAccessToken;
|
|
366
404
|
}
|
|
@@ -413,7 +451,7 @@ function createBillingMethods(deps) {
|
|
|
413
451
|
}
|
|
414
452
|
|
|
415
453
|
// src/client/version-check.ts
|
|
416
|
-
var SDK_VERSION = "1.
|
|
454
|
+
var SDK_VERSION = "1.9.1";
|
|
417
455
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
418
456
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
419
457
|
var LATEST_VERSION_HEADER = "X-FFID-SDK-Latest-Version";
|
|
@@ -462,7 +500,7 @@ var SDK_LOG_PREFIX = "[FFID SDK]";
|
|
|
462
500
|
var MS_PER_SECOND = 1e3;
|
|
463
501
|
var UNAUTHORIZED_STATUS = 401;
|
|
464
502
|
var STATE_RANDOM_BYTES = 16;
|
|
465
|
-
var
|
|
503
|
+
var HEX_BASE2 = 16;
|
|
466
504
|
var noopLogger = {
|
|
467
505
|
debug: () => {
|
|
468
506
|
},
|
|
@@ -497,9 +535,17 @@ function createFFIDClient(config) {
|
|
|
497
535
|
const resolvedRedirectUri = config.redirectUri ?? null;
|
|
498
536
|
const serviceApiKey = config.serviceApiKey?.trim();
|
|
499
537
|
const verifyStrategy = config.verifyStrategy ?? "jwt";
|
|
538
|
+
const cache = config.cache;
|
|
539
|
+
const timeout = config.timeout;
|
|
500
540
|
if (authMode === "service-key" && !serviceApiKey) {
|
|
501
541
|
throw new Error("FFID Client: service-key \u30E2\u30FC\u30C9\u3067\u306F serviceApiKey \u304C\u5FC5\u9808\u3067\u3059");
|
|
502
542
|
}
|
|
543
|
+
if (cache && cache.ttl <= 0) {
|
|
544
|
+
throw new Error("FFID Client: cache.ttl \u306F\u6B63\u306E\u6570\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
545
|
+
}
|
|
546
|
+
if (timeout !== void 0 && timeout <= 0) {
|
|
547
|
+
throw new Error("FFID Client: timeout \u306F\u6B63\u306E\u6570\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
548
|
+
}
|
|
503
549
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
504
550
|
const tokenStore = authMode === "token" ? createTokenStore() : createTokenStore("memory");
|
|
505
551
|
async function fetchWithAuth(endpoint, options = {}) {
|
|
@@ -1019,7 +1065,9 @@ function createFFIDClient(config) {
|
|
|
1019
1065
|
verifyStrategy,
|
|
1020
1066
|
logger,
|
|
1021
1067
|
createError,
|
|
1022
|
-
errorCodes: FFID_ERROR_CODES
|
|
1068
|
+
errorCodes: FFID_ERROR_CODES,
|
|
1069
|
+
cache,
|
|
1070
|
+
timeout
|
|
1023
1071
|
});
|
|
1024
1072
|
return {
|
|
1025
1073
|
getSession,
|
|
@@ -1049,7 +1097,7 @@ function createFFIDClient(config) {
|
|
|
1049
1097
|
function generateRandomState() {
|
|
1050
1098
|
const array = new Uint8Array(STATE_RANDOM_BYTES);
|
|
1051
1099
|
crypto.getRandomValues(array);
|
|
1052
|
-
return Array.from(array, (byte) => byte.toString(
|
|
1100
|
+
return Array.from(array, (byte) => byte.toString(HEX_BASE2).padStart(2, "0")).join("");
|
|
1053
1101
|
}
|
|
1054
1102
|
var DEFAULT_REFRESH_INTERVAL_MS = 5 * 60 * 1e3;
|
|
1055
1103
|
var TOKEN_REFRESH_RATIO = 0.8;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAD2MA4LH_cjs = require('../chunk-AD2MA4LH.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "FFIDAnnouncementBadge", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDAnnouncementBadge; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "FFIDAnnouncementList", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDAnnouncementList; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "FFIDLoginButton", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDLoginButton; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDOrganizationSwitcher; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "FFIDSubscriptionBadge", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDSubscriptionBadge; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "FFIDUserMenu", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDUserMenu; }
|
|
30
30
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { v as FFIDAnnouncementBadge, S as FFIDAnnouncementBadgeClassNames, T as FFIDAnnouncementBadgeProps, w as FFIDAnnouncementList, V as FFIDAnnouncementListClassNames, W as FFIDAnnouncementListProps, E as FFIDLoginButton, X as FFIDLoginButtonProps, J as FFIDOrganizationSwitcher, Y as FFIDOrganizationSwitcherClassNames, Z as FFIDOrganizationSwitcherProps, M as FFIDSubscriptionBadge, _ as FFIDSubscriptionBadgeClassNames, $ as FFIDSubscriptionBadgeProps, P as FFIDUserMenu, a0 as FFIDUserMenuClassNames, a1 as FFIDUserMenuProps } from '../index-DsXjcF0i.cjs';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { v as FFIDAnnouncementBadge, S as FFIDAnnouncementBadgeClassNames, T as FFIDAnnouncementBadgeProps, w as FFIDAnnouncementList, V as FFIDAnnouncementListClassNames, W as FFIDAnnouncementListProps, E as FFIDLoginButton, X as FFIDLoginButtonProps, J as FFIDOrganizationSwitcher, Y as FFIDOrganizationSwitcherClassNames, Z as FFIDOrganizationSwitcherProps, M as FFIDSubscriptionBadge, _ as FFIDSubscriptionBadgeClassNames, $ as FFIDSubscriptionBadgeProps, P as FFIDUserMenu, a0 as FFIDUserMenuClassNames, a1 as FFIDUserMenuProps } from '../index-DsXjcF0i.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-
|
|
1
|
+
export { FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDSubscriptionBadge, FFIDUserMenu } from '../chunk-S7GPQ4OJ.js';
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Centralizing these prevents drift during domain/URL changes.
|
|
6
6
|
*/
|
|
7
7
|
/** Default FFID API base URL (production) */
|
|
8
|
-
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.
|
|
8
|
+
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
9
9
|
|
|
10
10
|
export { DEFAULT_API_BASE_URL as D };
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Centralizing these prevents drift during domain/URL changes.
|
|
6
6
|
*/
|
|
7
7
|
/** Default FFID API base URL (production) */
|
|
8
|
-
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.
|
|
8
|
+
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
9
9
|
|
|
10
10
|
export { DEFAULT_API_BASE_URL as D };
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
|
|
3
3
|
|
|
4
|
+
/** Cache adapter interface for FFID SDK token verification */
|
|
5
|
+
/**
|
|
6
|
+
* Pluggable cache adapter interface.
|
|
7
|
+
* Implement this to use custom cache backends (Redis, Memcached, etc.)
|
|
8
|
+
*/
|
|
9
|
+
interface FFIDCacheAdapter {
|
|
10
|
+
/** Get a cached value by key. Returns null if not found or expired. */
|
|
11
|
+
get(key: string): Promise<unknown | null>;
|
|
12
|
+
/** Set a value with TTL in seconds. */
|
|
13
|
+
set(key: string, value: unknown, ttlSeconds: number): Promise<void>;
|
|
14
|
+
/** Delete a cached value. */
|
|
15
|
+
delete(key: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/** Cache configuration for createFFIDClient */
|
|
18
|
+
interface FFIDCacheConfig {
|
|
19
|
+
/** Cache adapter instance */
|
|
20
|
+
adapter: FFIDCacheAdapter;
|
|
21
|
+
/** Cache TTL in seconds (how long to cache userinfo/introspect results) */
|
|
22
|
+
ttl: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
4
25
|
/**
|
|
5
26
|
* FFID SDK Type Definitions
|
|
6
27
|
*
|
|
7
28
|
* Core types for the FeelFlow ID SDK
|
|
8
29
|
*/
|
|
30
|
+
|
|
9
31
|
/**
|
|
10
32
|
* User information from FFID
|
|
11
33
|
*/
|
|
@@ -151,6 +173,18 @@ interface FFIDConfig {
|
|
|
151
173
|
* Use 'introspect' if you need full user profile data.
|
|
152
174
|
*/
|
|
153
175
|
verifyStrategy?: 'jwt' | 'introspect' | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* Cache configuration for token verification results.
|
|
178
|
+
* When set, introspect/userinfo responses are cached to reduce API calls.
|
|
179
|
+
* Only effective in service-key mode with verifyStrategy: 'introspect'.
|
|
180
|
+
*/
|
|
181
|
+
cache?: FFIDCacheConfig | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Request timeout in milliseconds for FFID API calls.
|
|
184
|
+
* Applies to token verification and introspection requests.
|
|
185
|
+
* @default undefined (no timeout, uses fetch default)
|
|
186
|
+
*/
|
|
187
|
+
timeout?: number | undefined;
|
|
154
188
|
}
|
|
155
189
|
/**
|
|
156
190
|
* FFID JWT claims structure (minimal payload).
|
|
@@ -423,7 +457,7 @@ interface ListAnnouncementsOptions {
|
|
|
423
457
|
}
|
|
424
458
|
/** Configuration for the FFID Announcements Client */
|
|
425
459
|
interface FFIDAnnouncementsClientConfig {
|
|
426
|
-
/** FFID API base URL (defaults to https://id.feelflow.
|
|
460
|
+
/** FFID API base URL (defaults to https://id.feelflow.net) */
|
|
427
461
|
apiBaseUrl?: string | undefined;
|
|
428
462
|
/** Enable debug logging */
|
|
429
463
|
debug?: boolean | undefined;
|
|
@@ -727,4 +761,4 @@ interface FFIDAnnouncementListProps {
|
|
|
727
761
|
*/
|
|
728
762
|
declare function FFIDAnnouncementList({ announcements, isLoading, className, classNames, style, formatDate, emptyMessage, loadingRender, renderItem, maxContentLines, }: FFIDAnnouncementListProps): react_jsx_runtime.JSX.Element;
|
|
729
763
|
|
|
730
|
-
export { type
|
|
764
|
+
export { type FFIDSubscriptionBadgeProps as $, type AnnouncementListResponse as A, type FFIDCacheConfig as B, type FFIDContextValue as C, type FFIDJwtClaims as D, FFIDLoginButton as E, type FFIDConfig as F, type FFIDOAuthTokenResponse as G, type FFIDOAuthUserInfoMemberRole as H, type FFIDOAuthUserInfoSubscription as I, FFIDOrganizationSwitcher as J, type FFIDSeatModel as K, type ListAnnouncementsOptions as L, FFIDSubscriptionBadge as M, type FFIDSubscriptionStatus as N, type FFIDTokenIntrospectionResponse as O, FFIDUserMenu as P, type UseFFIDAnnouncementsReturn as Q, useFFIDAnnouncements as R, type FFIDAnnouncementBadgeClassNames as S, type FFIDAnnouncementBadgeProps as T, type UseFFIDAnnouncementsOptions as U, type FFIDAnnouncementListClassNames as V, type FFIDAnnouncementListProps as W, type FFIDLoginButtonProps as X, type FFIDOrganizationSwitcherClassNames as Y, type FFIDOrganizationSwitcherProps as Z, type FFIDSubscriptionBadgeClassNames as _, type FFIDApiResponse as a, type FFIDUserMenuClassNames as a0, type FFIDUserMenuProps as a1, type FFIDSessionResponse as b, type FFIDError as c, type FFIDSubscriptionCheckResponse as d, type FFIDCreateCheckoutParams as e, type FFIDCheckoutSessionResponse as f, type FFIDCreatePortalParams as g, type FFIDPortalSessionResponse as h, type FFIDOAuthUserInfo as i, type FFIDLogger as j, type FFIDCacheAdapter as k, type FFIDUser as l, type FFIDOrganization as m, type FFIDSubscription as n, type FFIDSubscriptionContextValue as o, type FFIDAnnouncementsClientConfig as p, type FFIDAnnouncementsApiResponse as q, type FFIDAnnouncementsLogger as r, type Announcement as s, type AnnouncementStatus as t, type AnnouncementType as u, FFIDAnnouncementBadge as v, FFIDAnnouncementList as w, type FFIDAnnouncementsError as x, type FFIDAnnouncementsErrorCode as y, type FFIDAnnouncementsServerResponse as z };
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ButtonHTMLAttributes, ReactNode, CSSProperties } from 'react';
|
|
3
3
|
|
|
4
|
+
/** Cache adapter interface for FFID SDK token verification */
|
|
5
|
+
/**
|
|
6
|
+
* Pluggable cache adapter interface.
|
|
7
|
+
* Implement this to use custom cache backends (Redis, Memcached, etc.)
|
|
8
|
+
*/
|
|
9
|
+
interface FFIDCacheAdapter {
|
|
10
|
+
/** Get a cached value by key. Returns null if not found or expired. */
|
|
11
|
+
get(key: string): Promise<unknown | null>;
|
|
12
|
+
/** Set a value with TTL in seconds. */
|
|
13
|
+
set(key: string, value: unknown, ttlSeconds: number): Promise<void>;
|
|
14
|
+
/** Delete a cached value. */
|
|
15
|
+
delete(key: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/** Cache configuration for createFFIDClient */
|
|
18
|
+
interface FFIDCacheConfig {
|
|
19
|
+
/** Cache adapter instance */
|
|
20
|
+
adapter: FFIDCacheAdapter;
|
|
21
|
+
/** Cache TTL in seconds (how long to cache userinfo/introspect results) */
|
|
22
|
+
ttl: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
4
25
|
/**
|
|
5
26
|
* FFID SDK Type Definitions
|
|
6
27
|
*
|
|
7
28
|
* Core types for the FeelFlow ID SDK
|
|
8
29
|
*/
|
|
30
|
+
|
|
9
31
|
/**
|
|
10
32
|
* User information from FFID
|
|
11
33
|
*/
|
|
@@ -151,6 +173,18 @@ interface FFIDConfig {
|
|
|
151
173
|
* Use 'introspect' if you need full user profile data.
|
|
152
174
|
*/
|
|
153
175
|
verifyStrategy?: 'jwt' | 'introspect' | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* Cache configuration for token verification results.
|
|
178
|
+
* When set, introspect/userinfo responses are cached to reduce API calls.
|
|
179
|
+
* Only effective in service-key mode with verifyStrategy: 'introspect'.
|
|
180
|
+
*/
|
|
181
|
+
cache?: FFIDCacheConfig | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Request timeout in milliseconds for FFID API calls.
|
|
184
|
+
* Applies to token verification and introspection requests.
|
|
185
|
+
* @default undefined (no timeout, uses fetch default)
|
|
186
|
+
*/
|
|
187
|
+
timeout?: number | undefined;
|
|
154
188
|
}
|
|
155
189
|
/**
|
|
156
190
|
* FFID JWT claims structure (minimal payload).
|
|
@@ -423,7 +457,7 @@ interface ListAnnouncementsOptions {
|
|
|
423
457
|
}
|
|
424
458
|
/** Configuration for the FFID Announcements Client */
|
|
425
459
|
interface FFIDAnnouncementsClientConfig {
|
|
426
|
-
/** FFID API base URL (defaults to https://id.feelflow.
|
|
460
|
+
/** FFID API base URL (defaults to https://id.feelflow.net) */
|
|
427
461
|
apiBaseUrl?: string | undefined;
|
|
428
462
|
/** Enable debug logging */
|
|
429
463
|
debug?: boolean | undefined;
|
|
@@ -727,4 +761,4 @@ interface FFIDAnnouncementListProps {
|
|
|
727
761
|
*/
|
|
728
762
|
declare function FFIDAnnouncementList({ announcements, isLoading, className, classNames, style, formatDate, emptyMessage, loadingRender, renderItem, maxContentLines, }: FFIDAnnouncementListProps): react_jsx_runtime.JSX.Element;
|
|
729
763
|
|
|
730
|
-
export { type
|
|
764
|
+
export { type FFIDSubscriptionBadgeProps as $, type AnnouncementListResponse as A, type FFIDCacheConfig as B, type FFIDContextValue as C, type FFIDJwtClaims as D, FFIDLoginButton as E, type FFIDConfig as F, type FFIDOAuthTokenResponse as G, type FFIDOAuthUserInfoMemberRole as H, type FFIDOAuthUserInfoSubscription as I, FFIDOrganizationSwitcher as J, type FFIDSeatModel as K, type ListAnnouncementsOptions as L, FFIDSubscriptionBadge as M, type FFIDSubscriptionStatus as N, type FFIDTokenIntrospectionResponse as O, FFIDUserMenu as P, type UseFFIDAnnouncementsReturn as Q, useFFIDAnnouncements as R, type FFIDAnnouncementBadgeClassNames as S, type FFIDAnnouncementBadgeProps as T, type UseFFIDAnnouncementsOptions as U, type FFIDAnnouncementListClassNames as V, type FFIDAnnouncementListProps as W, type FFIDLoginButtonProps as X, type FFIDOrganizationSwitcherClassNames as Y, type FFIDOrganizationSwitcherProps as Z, type FFIDSubscriptionBadgeClassNames as _, type FFIDApiResponse as a, type FFIDUserMenuClassNames as a0, type FFIDUserMenuProps as a1, type FFIDSessionResponse as b, type FFIDError as c, type FFIDSubscriptionCheckResponse as d, type FFIDCreateCheckoutParams as e, type FFIDCheckoutSessionResponse as f, type FFIDCreatePortalParams as g, type FFIDPortalSessionResponse as h, type FFIDOAuthUserInfo as i, type FFIDLogger as j, type FFIDCacheAdapter as k, type FFIDUser as l, type FFIDOrganization as m, type FFIDSubscription as n, type FFIDSubscriptionContextValue as o, type FFIDAnnouncementsClientConfig as p, type FFIDAnnouncementsApiResponse as q, type FFIDAnnouncementsLogger as r, type Announcement as s, type AnnouncementStatus as t, type AnnouncementType as u, FFIDAnnouncementBadge as v, FFIDAnnouncementList as w, type FFIDAnnouncementsError as x, type FFIDAnnouncementsErrorCode as y, type FFIDAnnouncementsServerResponse as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,52 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAD2MA4LH_cjs = require('./chunk-AD2MA4LH.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
|
|
7
|
+
// src/client/cache/memory-cache-adapter.ts
|
|
8
|
+
var MS_PER_SECOND = 1e3;
|
|
9
|
+
function createMemoryCacheAdapter() {
|
|
10
|
+
const store = /* @__PURE__ */ new Map();
|
|
11
|
+
return {
|
|
12
|
+
async get(key) {
|
|
13
|
+
const entry = store.get(key);
|
|
14
|
+
if (!entry) return null;
|
|
15
|
+
if (Date.now() >= entry.expiresAt) {
|
|
16
|
+
store.delete(key);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return entry.value;
|
|
20
|
+
},
|
|
21
|
+
async set(key, value, ttlSeconds) {
|
|
22
|
+
store.set(key, {
|
|
23
|
+
value,
|
|
24
|
+
expiresAt: Date.now() + ttlSeconds * MS_PER_SECOND
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
async delete(key) {
|
|
28
|
+
store.delete(key);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/client/cache/kv-cache-adapter.ts
|
|
34
|
+
function createKVCacheAdapter(kv) {
|
|
35
|
+
return {
|
|
36
|
+
async get(key) {
|
|
37
|
+
return kv.get(key, "json");
|
|
38
|
+
},
|
|
39
|
+
async set(key, value, ttlSeconds) {
|
|
40
|
+
await kv.put(key, JSON.stringify(value), { expirationTtl: ttlSeconds });
|
|
41
|
+
},
|
|
42
|
+
async delete(key) {
|
|
43
|
+
await kv.delete(key);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
7
47
|
function withFFIDAuth(Component, options = {}) {
|
|
8
48
|
const WrappedComponent = (props) => {
|
|
9
|
-
const { isLoading, isAuthenticated, login } =
|
|
49
|
+
const { isLoading, isAuthenticated, login } = chunkAD2MA4LH_cjs.useFFIDContext();
|
|
10
50
|
const hasRedirected = react.useRef(false);
|
|
11
51
|
react.useEffect(() => {
|
|
12
52
|
if (!isLoading && !isAuthenticated && options.redirectToLogin && !hasRedirected.current) {
|
|
@@ -31,82 +71,84 @@ function withFFIDAuth(Component, options = {}) {
|
|
|
31
71
|
|
|
32
72
|
Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
|
|
33
73
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkAD2MA4LH_cjs.DEFAULT_API_BASE_URL; }
|
|
35
75
|
});
|
|
36
76
|
Object.defineProperty(exports, "FFIDAnnouncementBadge", {
|
|
37
77
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDAnnouncementBadge; }
|
|
39
79
|
});
|
|
40
80
|
Object.defineProperty(exports, "FFIDAnnouncementList", {
|
|
41
81
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDAnnouncementList; }
|
|
43
83
|
});
|
|
44
84
|
Object.defineProperty(exports, "FFIDLoginButton", {
|
|
45
85
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDLoginButton; }
|
|
47
87
|
});
|
|
48
88
|
Object.defineProperty(exports, "FFIDOrganizationSwitcher", {
|
|
49
89
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDOrganizationSwitcher; }
|
|
51
91
|
});
|
|
52
92
|
Object.defineProperty(exports, "FFIDProvider", {
|
|
53
93
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDProvider; }
|
|
55
95
|
});
|
|
56
96
|
Object.defineProperty(exports, "FFIDSubscriptionBadge", {
|
|
57
97
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDSubscriptionBadge; }
|
|
59
99
|
});
|
|
60
100
|
Object.defineProperty(exports, "FFIDUserMenu", {
|
|
61
101
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkAD2MA4LH_cjs.FFIDUserMenu; }
|
|
63
103
|
});
|
|
64
104
|
Object.defineProperty(exports, "FFID_ANNOUNCEMENTS_ERROR_CODES", {
|
|
65
105
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkAD2MA4LH_cjs.FFID_ANNOUNCEMENTS_ERROR_CODES; }
|
|
67
107
|
});
|
|
68
108
|
Object.defineProperty(exports, "createFFIDAnnouncementsClient", {
|
|
69
109
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkAD2MA4LH_cjs.createFFIDAnnouncementsClient; }
|
|
71
111
|
});
|
|
72
112
|
Object.defineProperty(exports, "createFFIDClient", {
|
|
73
113
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkAD2MA4LH_cjs.createFFIDClient; }
|
|
75
115
|
});
|
|
76
116
|
Object.defineProperty(exports, "createTokenStore", {
|
|
77
117
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkAD2MA4LH_cjs.createTokenStore; }
|
|
79
119
|
});
|
|
80
120
|
Object.defineProperty(exports, "generateCodeChallenge", {
|
|
81
121
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkAD2MA4LH_cjs.generateCodeChallenge; }
|
|
83
123
|
});
|
|
84
124
|
Object.defineProperty(exports, "generateCodeVerifier", {
|
|
85
125
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkAD2MA4LH_cjs.generateCodeVerifier; }
|
|
87
127
|
});
|
|
88
128
|
Object.defineProperty(exports, "retrieveCodeVerifier", {
|
|
89
129
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunkAD2MA4LH_cjs.retrieveCodeVerifier; }
|
|
91
131
|
});
|
|
92
132
|
Object.defineProperty(exports, "storeCodeVerifier", {
|
|
93
133
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
134
|
+
get: function () { return chunkAD2MA4LH_cjs.storeCodeVerifier; }
|
|
95
135
|
});
|
|
96
136
|
Object.defineProperty(exports, "useFFID", {
|
|
97
137
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
138
|
+
get: function () { return chunkAD2MA4LH_cjs.useFFID; }
|
|
99
139
|
});
|
|
100
140
|
Object.defineProperty(exports, "useFFIDAnnouncements", {
|
|
101
141
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
142
|
+
get: function () { return chunkAD2MA4LH_cjs.useFFIDAnnouncements; }
|
|
103
143
|
});
|
|
104
144
|
Object.defineProperty(exports, "useSubscription", {
|
|
105
145
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
146
|
+
get: function () { return chunkAD2MA4LH_cjs.useSubscription; }
|
|
107
147
|
});
|
|
108
148
|
Object.defineProperty(exports, "withSubscription", {
|
|
109
149
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
150
|
+
get: function () { return chunkAD2MA4LH_cjs.withSubscription; }
|
|
111
151
|
});
|
|
152
|
+
exports.createKVCacheAdapter = createKVCacheAdapter;
|
|
153
|
+
exports.createMemoryCacheAdapter = createMemoryCacheAdapter;
|
|
112
154
|
exports.withFFIDAuth = withFFIDAuth;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FFIDConfig, a as FFIDApiResponse, b as FFIDSessionResponse, c as FFIDError, d as FFIDSubscriptionCheckResponse, e as FFIDCreateCheckoutParams, f as FFIDCheckoutSessionResponse, g as FFIDCreatePortalParams, h as FFIDPortalSessionResponse, i as FFIDOAuthUserInfo, j as FFIDLogger, k as
|
|
2
|
-
export {
|
|
1
|
+
import { F as FFIDConfig, a as FFIDApiResponse, b as FFIDSessionResponse, c as FFIDError, d as FFIDSubscriptionCheckResponse, e as FFIDCreateCheckoutParams, f as FFIDCheckoutSessionResponse, g as FFIDCreatePortalParams, h as FFIDPortalSessionResponse, i as FFIDOAuthUserInfo, j as FFIDLogger, k as FFIDCacheAdapter, l as FFIDUser, m as FFIDOrganization, n as FFIDSubscription, o as FFIDSubscriptionContextValue, p as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, q as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, r as FFIDAnnouncementsLogger } from './index-DsXjcF0i.cjs';
|
|
2
|
+
export { s as Announcement, t as AnnouncementStatus, u as AnnouncementType, v as FFIDAnnouncementBadge, w as FFIDAnnouncementList, x as FFIDAnnouncementsError, y as FFIDAnnouncementsErrorCode, z as FFIDAnnouncementsServerResponse, B as FFIDCacheConfig, C as FFIDContextValue, D as FFIDJwtClaims, E as FFIDLoginButton, G as FFIDOAuthTokenResponse, H as FFIDOAuthUserInfoMemberRole, I as FFIDOAuthUserInfoSubscription, J as FFIDOrganizationSwitcher, K as FFIDSeatModel, M as FFIDSubscriptionBadge, N as FFIDSubscriptionStatus, O as FFIDTokenIntrospectionResponse, P as FFIDUserMenu, U as UseFFIDAnnouncementsOptions, Q as UseFFIDAnnouncementsReturn, R as useFFIDAnnouncements } from './index-DsXjcF0i.cjs';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, ComponentType, FC } from 'react';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import { ReactNode, ComponentType, FC } from 'react';
|
|
|
10
10
|
* Centralizing these prevents drift during domain/URL changes.
|
|
11
11
|
*/
|
|
12
12
|
/** Default FFID API base URL (production) */
|
|
13
|
-
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.
|
|
13
|
+
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Token Store
|
|
@@ -115,6 +115,29 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
115
115
|
/** Type of the FFID client */
|
|
116
116
|
type FFIDClient = ReturnType<typeof createFFIDClient>;
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Create an in-memory cache adapter using a Map.
|
|
120
|
+
* Suitable for single-process environments (e.g., development, testing).
|
|
121
|
+
*/
|
|
122
|
+
declare function createMemoryCacheAdapter(): FFIDCacheAdapter;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Minimal KVNamespace-compatible interface.
|
|
126
|
+
* Matches Cloudflare Workers KV without requiring the CF Workers dependency.
|
|
127
|
+
*/
|
|
128
|
+
interface KVNamespaceLike {
|
|
129
|
+
get(key: string, type: 'json'): Promise<unknown | null>;
|
|
130
|
+
put(key: string, value: string, options?: {
|
|
131
|
+
expirationTtl?: number;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
delete(key: string): Promise<void>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Create a cache adapter backed by a KVNamespace-compatible store.
|
|
137
|
+
* Suitable for Cloudflare Workers and other KV-based environments.
|
|
138
|
+
*/
|
|
139
|
+
declare function createKVCacheAdapter(kv: KVNamespaceLike): FFIDCacheAdapter;
|
|
140
|
+
|
|
118
141
|
/**
|
|
119
142
|
* Props for FFIDProvider component
|
|
120
143
|
*/
|
|
@@ -299,7 +322,7 @@ declare function withFFIDAuth<P extends object>(Component: ComponentType<P>, opt
|
|
|
299
322
|
* import { createFFIDAnnouncementsClient } from '@feelflow/ffid-sdk/announcements'
|
|
300
323
|
*
|
|
301
324
|
* const client = createFFIDAnnouncementsClient({
|
|
302
|
-
* apiBaseUrl: 'https://id.feelflow.
|
|
325
|
+
* apiBaseUrl: 'https://id.feelflow.net',
|
|
303
326
|
* })
|
|
304
327
|
*
|
|
305
328
|
* const { data, error } = await client.listAnnouncements({ limit: 10 })
|
|
@@ -343,4 +366,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
|
|
|
343
366
|
/** Type of the FFID Announcements client */
|
|
344
367
|
type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
|
|
345
368
|
|
|
346
|
-
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDLogger, FFIDOAuthUserInfo, FFIDOrganization, FFIDPortalSessionResponse, FFIDProvider, type FFIDProviderProps, FFIDSessionResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, ListAnnouncementsOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
|
369
|
+
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, FFIDCacheAdapter, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDLogger, FFIDOAuthUserInfo, FFIDOrganization, FFIDPortalSessionResponse, FFIDProvider, type FFIDProviderProps, FFIDSessionResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, type KVNamespaceLike, ListAnnouncementsOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FFIDConfig, a as FFIDApiResponse, b as FFIDSessionResponse, c as FFIDError, d as FFIDSubscriptionCheckResponse, e as FFIDCreateCheckoutParams, f as FFIDCheckoutSessionResponse, g as FFIDCreatePortalParams, h as FFIDPortalSessionResponse, i as FFIDOAuthUserInfo, j as FFIDLogger, k as
|
|
2
|
-
export {
|
|
1
|
+
import { F as FFIDConfig, a as FFIDApiResponse, b as FFIDSessionResponse, c as FFIDError, d as FFIDSubscriptionCheckResponse, e as FFIDCreateCheckoutParams, f as FFIDCheckoutSessionResponse, g as FFIDCreatePortalParams, h as FFIDPortalSessionResponse, i as FFIDOAuthUserInfo, j as FFIDLogger, k as FFIDCacheAdapter, l as FFIDUser, m as FFIDOrganization, n as FFIDSubscription, o as FFIDSubscriptionContextValue, p as FFIDAnnouncementsClientConfig, L as ListAnnouncementsOptions, q as FFIDAnnouncementsApiResponse, A as AnnouncementListResponse, r as FFIDAnnouncementsLogger } from './index-DsXjcF0i.js';
|
|
2
|
+
export { s as Announcement, t as AnnouncementStatus, u as AnnouncementType, v as FFIDAnnouncementBadge, w as FFIDAnnouncementList, x as FFIDAnnouncementsError, y as FFIDAnnouncementsErrorCode, z as FFIDAnnouncementsServerResponse, B as FFIDCacheConfig, C as FFIDContextValue, D as FFIDJwtClaims, E as FFIDLoginButton, G as FFIDOAuthTokenResponse, H as FFIDOAuthUserInfoMemberRole, I as FFIDOAuthUserInfoSubscription, J as FFIDOrganizationSwitcher, K as FFIDSeatModel, M as FFIDSubscriptionBadge, N as FFIDSubscriptionStatus, O as FFIDTokenIntrospectionResponse, P as FFIDUserMenu, U as UseFFIDAnnouncementsOptions, Q as UseFFIDAnnouncementsReturn, R as useFFIDAnnouncements } from './index-DsXjcF0i.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, ComponentType, FC } from 'react';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ import { ReactNode, ComponentType, FC } from 'react';
|
|
|
10
10
|
* Centralizing these prevents drift during domain/URL changes.
|
|
11
11
|
*/
|
|
12
12
|
/** Default FFID API base URL (production) */
|
|
13
|
-
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.
|
|
13
|
+
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Token Store
|
|
@@ -115,6 +115,29 @@ declare function createFFIDClient(config: FFIDConfig): {
|
|
|
115
115
|
/** Type of the FFID client */
|
|
116
116
|
type FFIDClient = ReturnType<typeof createFFIDClient>;
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Create an in-memory cache adapter using a Map.
|
|
120
|
+
* Suitable for single-process environments (e.g., development, testing).
|
|
121
|
+
*/
|
|
122
|
+
declare function createMemoryCacheAdapter(): FFIDCacheAdapter;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Minimal KVNamespace-compatible interface.
|
|
126
|
+
* Matches Cloudflare Workers KV without requiring the CF Workers dependency.
|
|
127
|
+
*/
|
|
128
|
+
interface KVNamespaceLike {
|
|
129
|
+
get(key: string, type: 'json'): Promise<unknown | null>;
|
|
130
|
+
put(key: string, value: string, options?: {
|
|
131
|
+
expirationTtl?: number;
|
|
132
|
+
}): Promise<void>;
|
|
133
|
+
delete(key: string): Promise<void>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Create a cache adapter backed by a KVNamespace-compatible store.
|
|
137
|
+
* Suitable for Cloudflare Workers and other KV-based environments.
|
|
138
|
+
*/
|
|
139
|
+
declare function createKVCacheAdapter(kv: KVNamespaceLike): FFIDCacheAdapter;
|
|
140
|
+
|
|
118
141
|
/**
|
|
119
142
|
* Props for FFIDProvider component
|
|
120
143
|
*/
|
|
@@ -299,7 +322,7 @@ declare function withFFIDAuth<P extends object>(Component: ComponentType<P>, opt
|
|
|
299
322
|
* import { createFFIDAnnouncementsClient } from '@feelflow/ffid-sdk/announcements'
|
|
300
323
|
*
|
|
301
324
|
* const client = createFFIDAnnouncementsClient({
|
|
302
|
-
* apiBaseUrl: 'https://id.feelflow.
|
|
325
|
+
* apiBaseUrl: 'https://id.feelflow.net',
|
|
303
326
|
* })
|
|
304
327
|
*
|
|
305
328
|
* const { data, error } = await client.listAnnouncements({ limit: 10 })
|
|
@@ -343,4 +366,4 @@ declare function createFFIDAnnouncementsClient(config?: FFIDAnnouncementsClientC
|
|
|
343
366
|
/** Type of the FFID Announcements client */
|
|
344
367
|
type FFIDAnnouncementsClient = ReturnType<typeof createFFIDAnnouncementsClient>;
|
|
345
368
|
|
|
346
|
-
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDLogger, FFIDOAuthUserInfo, FFIDOrganization, FFIDPortalSessionResponse, FFIDProvider, type FFIDProviderProps, FFIDSessionResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, ListAnnouncementsOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
|
369
|
+
export { AnnouncementListResponse, DEFAULT_API_BASE_URL, FFIDAnnouncementsApiResponse, type FFIDAnnouncementsClient, FFIDAnnouncementsClientConfig, FFIDAnnouncementsLogger, FFIDApiResponse, FFIDCacheAdapter, FFIDCheckoutSessionResponse, type FFIDClient, FFIDConfig, FFIDCreateCheckoutParams, FFIDCreatePortalParams, FFIDError, FFIDLogger, FFIDOAuthUserInfo, FFIDOrganization, FFIDPortalSessionResponse, FFIDProvider, type FFIDProviderProps, FFIDSessionResponse, FFIDSubscription, FFIDSubscriptionCheckResponse, FFIDSubscriptionContextValue, FFIDUser, FFID_ANNOUNCEMENTS_ERROR_CODES, type KVNamespaceLike, ListAnnouncementsOptions, type TokenData, type TokenStore, type UseFFIDReturn, type WithFFIDAuthOptions, type WithSubscriptionOptions, createFFIDAnnouncementsClient, createFFIDClient, createKVCacheAdapter, createMemoryCacheAdapter, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useSubscription, withFFIDAuth, withSubscription };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
|
-
import { useFFIDContext } from './chunk-
|
|
2
|
-
export { DEFAULT_API_BASE_URL, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-
|
|
1
|
+
import { useFFIDContext } from './chunk-S7GPQ4OJ.js';
|
|
2
|
+
export { DEFAULT_API_BASE_URL, FFIDAnnouncementBadge, FFIDAnnouncementList, FFIDLoginButton, FFIDOrganizationSwitcher, FFIDProvider, FFIDSubscriptionBadge, FFIDUserMenu, FFID_ANNOUNCEMENTS_ERROR_CODES, createFFIDAnnouncementsClient, createFFIDClient, createTokenStore, generateCodeChallenge, generateCodeVerifier, retrieveCodeVerifier, storeCodeVerifier, useFFID, useFFIDAnnouncements, useSubscription, withSubscription } from './chunk-S7GPQ4OJ.js';
|
|
3
3
|
import { useRef, useEffect } from 'react';
|
|
4
4
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
|
+
// src/client/cache/memory-cache-adapter.ts
|
|
7
|
+
var MS_PER_SECOND = 1e3;
|
|
8
|
+
function createMemoryCacheAdapter() {
|
|
9
|
+
const store = /* @__PURE__ */ new Map();
|
|
10
|
+
return {
|
|
11
|
+
async get(key) {
|
|
12
|
+
const entry = store.get(key);
|
|
13
|
+
if (!entry) return null;
|
|
14
|
+
if (Date.now() >= entry.expiresAt) {
|
|
15
|
+
store.delete(key);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return entry.value;
|
|
19
|
+
},
|
|
20
|
+
async set(key, value, ttlSeconds) {
|
|
21
|
+
store.set(key, {
|
|
22
|
+
value,
|
|
23
|
+
expiresAt: Date.now() + ttlSeconds * MS_PER_SECOND
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
async delete(key) {
|
|
27
|
+
store.delete(key);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/client/cache/kv-cache-adapter.ts
|
|
33
|
+
function createKVCacheAdapter(kv) {
|
|
34
|
+
return {
|
|
35
|
+
async get(key) {
|
|
36
|
+
return kv.get(key, "json");
|
|
37
|
+
},
|
|
38
|
+
async set(key, value, ttlSeconds) {
|
|
39
|
+
await kv.put(key, JSON.stringify(value), { expirationTtl: ttlSeconds });
|
|
40
|
+
},
|
|
41
|
+
async delete(key) {
|
|
42
|
+
await kv.delete(key);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
6
46
|
function withFFIDAuth(Component, options = {}) {
|
|
7
47
|
const WrappedComponent = (props) => {
|
|
8
48
|
const { isLoading, isAuthenticated, login } = useFFIDContext();
|
|
@@ -28,4 +68,4 @@ function withFFIDAuth(Component, options = {}) {
|
|
|
28
68
|
return WrappedComponent;
|
|
29
69
|
}
|
|
30
70
|
|
|
31
|
-
export { withFFIDAuth };
|
|
71
|
+
export { createKVCacheAdapter, createMemoryCacheAdapter, withFFIDAuth };
|
package/dist/legal/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYUIITYBE_cjs = require('../chunk-YUIITYBE.cjs');
|
|
4
4
|
|
|
5
5
|
// src/legal/ffid-legal-client.ts
|
|
6
6
|
var API_PREFIX = "/api/v1/legal/ext";
|
|
@@ -37,7 +37,7 @@ function createFFIDLegalClient(config) {
|
|
|
37
37
|
if (!config.apiKey) {
|
|
38
38
|
throw new Error("FFID Legal Client: apiKey \u304C\u672A\u8A2D\u5B9A\u3067\u3059");
|
|
39
39
|
}
|
|
40
|
-
const baseUrl = config.apiBaseUrl ??
|
|
40
|
+
const baseUrl = config.apiBaseUrl ?? chunkYUIITYBE_cjs.DEFAULT_API_BASE_URL;
|
|
41
41
|
const logger = config.logger ?? (config.debug ? consoleLogger : noopLogger);
|
|
42
42
|
async function fetchWithApiKey(endpoint, options = {}) {
|
|
43
43
|
const url = `${baseUrl}${API_PREFIX}${endpoint}`;
|
|
@@ -176,7 +176,7 @@ function createFFIDLegalClient(config) {
|
|
|
176
176
|
|
|
177
177
|
Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
|
|
178
178
|
enumerable: true,
|
|
179
|
-
get: function () { return
|
|
179
|
+
get: function () { return chunkYUIITYBE_cjs.DEFAULT_API_BASE_URL; }
|
|
180
180
|
});
|
|
181
181
|
exports.FFID_LEGAL_ERROR_CODES = FFID_LEGAL_ERROR_CODES;
|
|
182
182
|
exports.createFFIDLegalClient = createFFIDLegalClient;
|
package/dist/legal/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DEFAULT_API_BASE_URL } from '../constants-
|
|
1
|
+
export { D as DEFAULT_API_BASE_URL } from '../constants-DvTGHPZn.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* FFID Legal SDK Type Definitions
|
|
@@ -16,7 +16,7 @@ export { D as DEFAULT_API_BASE_URL } from '../constants-BeWMWOOd.cjs';
|
|
|
16
16
|
interface FFIDLegalClientConfig {
|
|
17
17
|
/** Service API key (format: ffid_sk_live_xxx or ffid_sk_test_xxx) */
|
|
18
18
|
apiKey: string;
|
|
19
|
-
/** FFID API base URL (defaults to https://id.feelflow.
|
|
19
|
+
/** FFID API base URL (defaults to https://id.feelflow.net) */
|
|
20
20
|
apiBaseUrl?: string;
|
|
21
21
|
/** Enable debug logging */
|
|
22
22
|
debug?: boolean;
|
|
@@ -293,7 +293,7 @@ declare const FFID_LEGAL_ERROR_CODES: {
|
|
|
293
293
|
* ```typescript
|
|
294
294
|
* const legal = createFFIDLegalClient({
|
|
295
295
|
* apiKey: process.env.FFID_SERVICE_API_KEY!,
|
|
296
|
-
* apiBaseUrl: 'https://id.feelflow.
|
|
296
|
+
* apiBaseUrl: 'https://id.feelflow.net',
|
|
297
297
|
* debug: true,
|
|
298
298
|
* })
|
|
299
299
|
* ```
|
package/dist/legal/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DEFAULT_API_BASE_URL } from '../constants-
|
|
1
|
+
export { D as DEFAULT_API_BASE_URL } from '../constants-DvTGHPZn.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* FFID Legal SDK Type Definitions
|
|
@@ -16,7 +16,7 @@ export { D as DEFAULT_API_BASE_URL } from '../constants-BeWMWOOd.js';
|
|
|
16
16
|
interface FFIDLegalClientConfig {
|
|
17
17
|
/** Service API key (format: ffid_sk_live_xxx or ffid_sk_test_xxx) */
|
|
18
18
|
apiKey: string;
|
|
19
|
-
/** FFID API base URL (defaults to https://id.feelflow.
|
|
19
|
+
/** FFID API base URL (defaults to https://id.feelflow.net) */
|
|
20
20
|
apiBaseUrl?: string;
|
|
21
21
|
/** Enable debug logging */
|
|
22
22
|
debug?: boolean;
|
|
@@ -293,7 +293,7 @@ declare const FFID_LEGAL_ERROR_CODES: {
|
|
|
293
293
|
* ```typescript
|
|
294
294
|
* const legal = createFFIDLegalClient({
|
|
295
295
|
* apiKey: process.env.FFID_SERVICE_API_KEY!,
|
|
296
|
-
* apiBaseUrl: 'https://id.feelflow.
|
|
296
|
+
* apiBaseUrl: 'https://id.feelflow.net',
|
|
297
297
|
* debug: true,
|
|
298
298
|
* })
|
|
299
299
|
* ```
|
package/dist/legal/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DEFAULT_API_BASE_URL } from '../chunk-
|
|
2
|
-
export { DEFAULT_API_BASE_URL } from '../chunk-
|
|
1
|
+
import { DEFAULT_API_BASE_URL } from '../chunk-QBRM2RRC.js';
|
|
2
|
+
export { DEFAULT_API_BASE_URL } from '../chunk-QBRM2RRC.js';
|
|
3
3
|
|
|
4
4
|
// src/legal/ffid-legal-client.ts
|
|
5
5
|
var API_PREFIX = "/api/v1/legal/ext";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feelflow/ffid-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "FeelFlow ID Platform SDK for React/Next.js applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"feelflow",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"nextjs",
|
|
11
11
|
"authentication"
|
|
12
12
|
],
|
|
13
|
-
"author": "FeelFlow <dev@feelflow.
|
|
13
|
+
"author": "FeelFlow <dev@feelflow.net>",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"homepage": "https://github.com/feel-flow/feelflow-id-platform/tree/develop/sdk/typescript#readme",
|
|
16
16
|
"bugs": {
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"test": "vitest run",
|
|
72
72
|
"test:watch": "vitest",
|
|
73
73
|
"test:coverage": "vitest run --coverage",
|
|
74
|
-
"prepublishOnly": "npm run build"
|
|
74
|
+
"prepublishOnly": "npm run build",
|
|
75
|
+
"sdk:publish": "./scripts/publish.sh"
|
|
75
76
|
},
|
|
76
77
|
"dependencies": {
|
|
77
78
|
"jose": "^6.0.0"
|
package/dist/chunk-P4MLCG4T.js
DELETED