@feelflow/ffid-sdk 2.21.0 → 3.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.
- 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.js +1 -1
- package/dist/{chunk-HUU4Q5VH.cjs → chunk-HZZQ2BX7.cjs} +83 -11
- package/dist/chunk-JEVK2XUM.js +5 -0
- package/dist/{chunk-YUIITYBE.cjs → chunk-MDHKSVLP.cjs} +2 -0
- package/dist/{chunk-I7NEMG52.js → chunk-RRN3DTET.js} +83 -12
- package/dist/components/index.cjs +8 -8
- 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-D61jqRIO.d.cts +35 -0
- package/dist/constants-D61jqRIO.d.ts +35 -0
- package/dist/{ffid-client-DgJRU-YZ.d.cts → ffid-client-DM_t1seS.d.cts} +71 -1
- package/dist/{ffid-client-DgJRU-YZ.d.ts → ffid-client-DM_t1seS.d.ts} +71 -1
- package/dist/{index-Dr5G9HQ4.d.cts → index-COnReU8h.d.cts} +24 -2
- package/dist/{index-Dr5G9HQ4.d.ts → index-COnReU8h.d.ts} +24 -2
- package/dist/index.cjs +37 -31
- package/dist/index.d.cts +101 -7
- package/dist/index.d.ts +101 -7
- package/dist/index.js +4 -3
- package/dist/legal/index.cjs +3 -3
- package/dist/legal/index.d.cts +1 -1
- package/dist/legal/index.d.ts +1 -1
- package/dist/legal/index.js +2 -2
- package/dist/server/index.cjs +83 -11
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +78 -10
- package/dist/server/test/index.d.cts +1 -1
- package/dist/server/test/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-QBRM2RRC.js +0 -4
- package/dist/constants-DvTGHPZn.d.cts +0 -10
- package/dist/constants-DvTGHPZn.d.ts +0 -10
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-
|
|
2
|
-
export { f as FFIDCacheConfig, g as FFIDClient, h as FFIDConfig, i as FFIDOrganization, j as FFIDOtpSendResponse, k as FFIDOtpVerifyResponse, l as FFIDPasswordResetConfirmResponse, m as FFIDPasswordResetResponse, n as FFIDPasswordResetVerifyResponse, o as FFIDProfileCallOptions, p as FFIDResetSessionResponse, q as FFIDSubscription, r as FFIDUpdateUserProfileRequest, s as FFIDUser, t as FFIDUserProfile, T as TokenData, u as TokenStore, v as createFFIDClient, w as createTokenStore } from '../ffid-client-
|
|
3
|
-
export { D as DEFAULT_API_BASE_URL } from '../constants-
|
|
1
|
+
import { F as FFIDLogger, a as FFIDError, b as FFIDCacheAdapter, c as FFIDVerifyAccessTokenOptions, d as FFIDApiResponse, e as FFIDOAuthUserInfo } from '../ffid-client-DM_t1seS.js';
|
|
2
|
+
export { f as FFIDCacheConfig, g as FFIDClient, h as FFIDConfig, i as FFIDOrganization, j as FFIDOtpSendResponse, k as FFIDOtpVerifyResponse, l as FFIDPasswordResetConfirmResponse, m as FFIDPasswordResetResponse, n as FFIDPasswordResetVerifyResponse, o as FFIDProfileCallOptions, p as FFIDResetSessionResponse, q as FFIDSubscription, r as FFIDUpdateUserProfileRequest, s as FFIDUser, t as FFIDUserProfile, T as TokenData, u as TokenStore, v as createFFIDClient, w as createTokenStore } from '../ffid-client-DM_t1seS.js';
|
|
3
|
+
export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constants-D61jqRIO.js';
|
|
4
4
|
|
|
5
5
|
/** Token verification - verifyAccessToken() implementation */
|
|
6
6
|
|
package/dist/server/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-JEVK2XUM.js';
|
|
2
|
+
export { DEFAULT_API_BASE_URL, DEFAULT_OAUTH_SCOPES } from '../chunk-JEVK2XUM.js';
|
|
3
3
|
import { createRemoteJWKSet, jwtVerify } from 'jose';
|
|
4
4
|
|
|
5
5
|
// src/auth/token-store.ts
|
|
@@ -802,7 +802,7 @@ function createProfileMethods(deps) {
|
|
|
802
802
|
}
|
|
803
803
|
|
|
804
804
|
// src/client/version-check.ts
|
|
805
|
-
var SDK_VERSION = "
|
|
805
|
+
var SDK_VERSION = "3.1.0";
|
|
806
806
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
807
807
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
808
808
|
function sdkHeaders() {
|
|
@@ -1324,6 +1324,8 @@ function base64UrlEncode(buffer) {
|
|
|
1324
1324
|
// src/client/redirect.ts
|
|
1325
1325
|
var OAUTH_AUTHORIZE_ENDPOINT = "/api/v1/oauth/authorize";
|
|
1326
1326
|
var AUTH_LOGOUT_ENDPOINT = "/api/v1/auth/logout";
|
|
1327
|
+
var SCREEN_HINT_SIGNUP = "signup";
|
|
1328
|
+
var SCREEN_HINT_PARAM = "screen_hint";
|
|
1327
1329
|
var STATE_RANDOM_BYTES = 16;
|
|
1328
1330
|
var HEX_BASE2 = 16;
|
|
1329
1331
|
var REDIRECT_LOOP_KEY = "ffid_sdk_redirect_loop_history";
|
|
@@ -1418,6 +1420,7 @@ function createRedirectMethods(deps) {
|
|
|
1418
1420
|
baseUrl,
|
|
1419
1421
|
clientId,
|
|
1420
1422
|
serviceCode,
|
|
1423
|
+
scope,
|
|
1421
1424
|
resolvedRedirectUri,
|
|
1422
1425
|
logger
|
|
1423
1426
|
} = deps;
|
|
@@ -1426,6 +1429,24 @@ function createRedirectMethods(deps) {
|
|
|
1426
1429
|
logger.warn("SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093");
|
|
1427
1430
|
return { success: false, error: "SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093" };
|
|
1428
1431
|
}
|
|
1432
|
+
if (authMode === "service-key") {
|
|
1433
|
+
logger.error(
|
|
1434
|
+
"[FFID SDK] service-key \u30E2\u30FC\u30C9\u3067\u306F redirectToAuthorize \u306F\u547C\u3073\u51FA\u305B\u307E\u305B\u3093 \u2014 server-to-server \u7528\u9014\u306E\u305F\u3081 OAuth \u30D6\u30E9\u30A6\u30B6 flow \u3092\u6301\u3061\u307E\u305B\u3093"
|
|
1435
|
+
);
|
|
1436
|
+
return {
|
|
1437
|
+
success: false,
|
|
1438
|
+
error: "service-key \u30E2\u30FC\u30C9\u3067\u306F OAuth \u8A8D\u53EF\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093"
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
if (!scope || !scope.trim()) {
|
|
1442
|
+
logger.error(
|
|
1443
|
+
"[FFID SDK] scope \u304C\u672A\u8A2D\u5B9A\u306E\u305F\u3081 /oauth/authorize \u3092\u547C\u3073\u51FA\u305B\u307E\u305B\u3093 (#2674) \u2014 FFIDConfig.scope \u306B DEFAULT_OAUTH_SCOPES \u307E\u305F\u306F\u660E\u793A\u7684\u306A scope \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044"
|
|
1444
|
+
);
|
|
1445
|
+
return {
|
|
1446
|
+
success: false,
|
|
1447
|
+
error: "OAuth scope \u304C\u672A\u8A2D\u5B9A\u306E\u305F\u3081\u8A8D\u53EF\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3092\u5B9F\u884C\u3067\u304D\u307E\u305B\u3093"
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1429
1450
|
const authorizeKey = buildAuthorizeKey(baseUrl, clientId, options?.organizationId);
|
|
1430
1451
|
const now = Date.now();
|
|
1431
1452
|
const recentCount = getRecentRedirectCount(authorizeKey, now, logger);
|
|
@@ -1458,6 +1479,7 @@ function createRedirectMethods(deps) {
|
|
|
1458
1479
|
const params = new URLSearchParams({
|
|
1459
1480
|
response_type: "code",
|
|
1460
1481
|
client_id: clientId,
|
|
1482
|
+
scope,
|
|
1461
1483
|
redirect_uri: redirectUri,
|
|
1462
1484
|
state,
|
|
1463
1485
|
code_challenge: challenge,
|
|
@@ -1471,6 +1493,9 @@ function createRedirectMethods(deps) {
|
|
|
1471
1493
|
}
|
|
1472
1494
|
params.set("organization_id", trimmedOrgId);
|
|
1473
1495
|
}
|
|
1496
|
+
if (options?.screenHint === SCREEN_HINT_SIGNUP) {
|
|
1497
|
+
params.set(SCREEN_HINT_PARAM, SCREEN_HINT_SIGNUP);
|
|
1498
|
+
}
|
|
1474
1499
|
const authorizeUrl = `${baseUrl}${OAUTH_AUTHORIZE_ENDPOINT}?${params.toString()}`;
|
|
1475
1500
|
logger.debug("Redirecting to authorize:", authorizeUrl);
|
|
1476
1501
|
recordRedirectAttempt(authorizeKey, now, logger);
|
|
@@ -1482,18 +1507,17 @@ function createRedirectMethods(deps) {
|
|
|
1482
1507
|
}
|
|
1483
1508
|
return { success: true };
|
|
1484
1509
|
}
|
|
1485
|
-
async function redirectToLogin() {
|
|
1510
|
+
async function redirectToLogin(options) {
|
|
1486
1511
|
if (typeof window === "undefined") {
|
|
1487
1512
|
logger.warn("SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093");
|
|
1488
1513
|
return { success: false, error: "SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093" };
|
|
1489
1514
|
}
|
|
1490
1515
|
if (authMode === "token") {
|
|
1491
|
-
return redirectToAuthorize();
|
|
1516
|
+
return redirectToAuthorize(options);
|
|
1492
1517
|
}
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
window.location.href = loginUrl;
|
|
1518
|
+
const targetUrl = options?.screenHint === SCREEN_HINT_SIGNUP ? getSignupUrl() : getLoginUrl();
|
|
1519
|
+
logger.debug("Redirecting to auth page:", targetUrl);
|
|
1520
|
+
window.location.href = targetUrl;
|
|
1497
1521
|
return { success: true };
|
|
1498
1522
|
}
|
|
1499
1523
|
function getLoginUrl(redirectUrl) {
|
|
@@ -1940,6 +1964,7 @@ function createContractWizardMethods(deps) {
|
|
|
1940
1964
|
var EXT_SUBSCRIBE_ENDPOINT2 = "/api/v1/ext/newsletter/subscribe";
|
|
1941
1965
|
var CONFIRM_ENDPOINT = "/api/newsletter/confirm";
|
|
1942
1966
|
var UNSUBSCRIBE_ENDPOINT = "/api/newsletter/unsubscribe";
|
|
1967
|
+
var DISPATCH_ENDPOINT = "/api/v1/newsletter/dispatch";
|
|
1943
1968
|
function trimOrEmpty(s) {
|
|
1944
1969
|
return typeof s === "string" ? s.trim() : "";
|
|
1945
1970
|
}
|
|
@@ -2045,7 +2070,36 @@ function createNewsletterMethods(deps) {
|
|
|
2045
2070
|
}
|
|
2046
2071
|
);
|
|
2047
2072
|
}
|
|
2048
|
-
|
|
2073
|
+
async function dispatch(params) {
|
|
2074
|
+
const subject = trimOrEmpty(params.subject);
|
|
2075
|
+
if (!subject) {
|
|
2076
|
+
return { error: createError("VALIDATION_ERROR", "subject \u306F\u5FC5\u9808\u3067\u3059") };
|
|
2077
|
+
}
|
|
2078
|
+
if (!params.body || typeof params.body !== "object") {
|
|
2079
|
+
return { error: createError("VALIDATION_ERROR", "body \u306F\u5FC5\u9808\u3067\u3059") };
|
|
2080
|
+
}
|
|
2081
|
+
const bodySource = params.body;
|
|
2082
|
+
const hasHtmlBody = typeof bodySource.htmlBody === "string" && bodySource.htmlBody.length > 0;
|
|
2083
|
+
const hasTemplateId = typeof bodySource.templateId === "string" && bodySource.templateId.length > 0;
|
|
2084
|
+
if (hasHtmlBody === hasTemplateId) {
|
|
2085
|
+
return {
|
|
2086
|
+
error: createError(
|
|
2087
|
+
"BODY_SOURCE_REQUIRED",
|
|
2088
|
+
"body \u306F htmlBody \u307E\u305F\u306F templateId \u306E\u3044\u305A\u308C\u304B\u4E00\u65B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044"
|
|
2089
|
+
)
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
return fetchWithAuth(DISPATCH_ENDPOINT, {
|
|
2093
|
+
method: "POST",
|
|
2094
|
+
body: JSON.stringify({
|
|
2095
|
+
subject,
|
|
2096
|
+
articleUrl: params.articleUrl,
|
|
2097
|
+
body: params.body,
|
|
2098
|
+
segment: params.segment
|
|
2099
|
+
})
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
return { subscribe, confirm, unsubscribe, dispatch };
|
|
2049
2103
|
}
|
|
2050
2104
|
|
|
2051
2105
|
// src/inquiry/ffid-inquiry-client.ts
|
|
@@ -2147,8 +2201,21 @@ function createFFIDClient(config) {
|
|
|
2147
2201
|
if (!config.serviceCode || !config.serviceCode.trim()) {
|
|
2148
2202
|
throw new Error("FFID Client: serviceCode \u304C\u672A\u8A2D\u5B9A\u3067\u3059");
|
|
2149
2203
|
}
|
|
2204
|
+
const scope = config.scope?.trim() ?? "";
|
|
2150
2205
|
const baseUrl = config.apiBaseUrl ?? DEFAULT_API_BASE_URL;
|
|
2151
2206
|
const authMode = config.authMode ?? "cookie";
|
|
2207
|
+
const VALID_AUTH_MODES = ["cookie", "token", "service-key"];
|
|
2208
|
+
if (!VALID_AUTH_MODES.includes(authMode)) {
|
|
2209
|
+
throw new Error(
|
|
2210
|
+
`FFID Client: authMode \u304C\u4E0D\u6B63\u3067\u3059 (\u53D7\u4FE1: ${JSON.stringify(authMode)}, \u6709\u52B9\u5024: ${VALID_AUTH_MODES.join(" | ")})`
|
|
2211
|
+
);
|
|
2212
|
+
}
|
|
2213
|
+
if (authMode !== "service-key" && !scope) {
|
|
2214
|
+
const received = config.scope === void 0 ? "undefined" : JSON.stringify(config.scope);
|
|
2215
|
+
throw new Error(
|
|
2216
|
+
`FFID Client: scope \u304C\u672A\u8A2D\u5B9A\u3067\u3059 (\u53D7\u4FE1: ${received})\u3002\`DEFAULT_OAUTH_SCOPES\` \u3092 import \u3059\u308B\u304B\u3001\u660E\u793A\u7684\u306B scope \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044 (#2674)`
|
|
2217
|
+
);
|
|
2218
|
+
}
|
|
2152
2219
|
const clientId = config.clientId ?? config.serviceCode;
|
|
2153
2220
|
const rawRedirectUri = config.redirectUri ?? null;
|
|
2154
2221
|
const serviceApiKey = config.serviceApiKey?.trim();
|
|
@@ -2319,6 +2386,7 @@ function createFFIDClient(config) {
|
|
|
2319
2386
|
baseUrl,
|
|
2320
2387
|
clientId,
|
|
2321
2388
|
serviceCode: config.serviceCode,
|
|
2389
|
+
scope,
|
|
2322
2390
|
resolvedRedirectUri,
|
|
2323
2391
|
logger
|
|
2324
2392
|
});
|
package/package.json
CHANGED
package/dist/chunk-QBRM2RRC.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FFID SDK Shared Constants
|
|
3
|
-
*
|
|
4
|
-
* Constants shared across all SDK entry points.
|
|
5
|
-
* Centralizing these prevents drift during domain/URL changes.
|
|
6
|
-
*/
|
|
7
|
-
/** Default FFID API base URL (production) */
|
|
8
|
-
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
9
|
-
|
|
10
|
-
export { DEFAULT_API_BASE_URL as D };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FFID SDK Shared Constants
|
|
3
|
-
*
|
|
4
|
-
* Constants shared across all SDK entry points.
|
|
5
|
-
* Centralizing these prevents drift during domain/URL changes.
|
|
6
|
-
*/
|
|
7
|
-
/** Default FFID API base URL (production) */
|
|
8
|
-
declare const DEFAULT_API_BASE_URL = "https://id.feelflow.net";
|
|
9
|
-
|
|
10
|
-
export { DEFAULT_API_BASE_URL as D };
|