@feelflow/ffid-sdk 2.21.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-JEVK2XUM.js +5 -0
- package/dist/{chunk-HUU4Q5VH.cjs → chunk-JNR4AKL5.cjs} +71 -3
- package/dist/{chunk-YUIITYBE.cjs → chunk-MDHKSVLP.cjs} +2 -0
- package/dist/{chunk-I7NEMG52.js → chunk-XWI4BFKW.js} +71 -4
- 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-B26jbUp5.d.cts} +48 -0
- package/dist/{ffid-client-DgJRU-YZ.d.ts → ffid-client-B26jbUp5.d.ts} +48 -0
- package/dist/{index-Dr5G9HQ4.d.cts → index-C3zyNa4j.d.cts} +13 -0
- package/dist/{index-Dr5G9HQ4.d.ts → index-C3zyNa4j.d.ts} +13 -0
- package/dist/index.cjs +37 -31
- package/dist/index.d.cts +67 -4
- package/dist/index.d.ts +67 -4
- 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 +73 -5
- package/dist/server/index.d.cts +3 -3
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +68 -4
- 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.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMDHKSVLP_cjs = require('../chunk-MDHKSVLP.cjs');
|
|
4
4
|
var jose = require('jose');
|
|
5
5
|
|
|
6
6
|
// src/auth/token-store.ts
|
|
@@ -803,7 +803,7 @@ function createProfileMethods(deps) {
|
|
|
803
803
|
}
|
|
804
804
|
|
|
805
805
|
// src/client/version-check.ts
|
|
806
|
-
var SDK_VERSION = "
|
|
806
|
+
var SDK_VERSION = "3.0.0";
|
|
807
807
|
var SDK_USER_AGENT = `FFID-SDK/${SDK_VERSION} (TypeScript)`;
|
|
808
808
|
var SDK_VERSION_HEADER = "X-FFID-SDK-Version";
|
|
809
809
|
function sdkHeaders() {
|
|
@@ -1419,6 +1419,7 @@ function createRedirectMethods(deps) {
|
|
|
1419
1419
|
baseUrl,
|
|
1420
1420
|
clientId,
|
|
1421
1421
|
serviceCode,
|
|
1422
|
+
scope,
|
|
1422
1423
|
resolvedRedirectUri,
|
|
1423
1424
|
logger
|
|
1424
1425
|
} = deps;
|
|
@@ -1427,6 +1428,24 @@ function createRedirectMethods(deps) {
|
|
|
1427
1428
|
logger.warn("SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093");
|
|
1428
1429
|
return { success: false, error: "SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093" };
|
|
1429
1430
|
}
|
|
1431
|
+
if (authMode === "service-key") {
|
|
1432
|
+
logger.error(
|
|
1433
|
+
"[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"
|
|
1434
|
+
);
|
|
1435
|
+
return {
|
|
1436
|
+
success: false,
|
|
1437
|
+
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"
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
if (!scope || !scope.trim()) {
|
|
1441
|
+
logger.error(
|
|
1442
|
+
"[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"
|
|
1443
|
+
);
|
|
1444
|
+
return {
|
|
1445
|
+
success: false,
|
|
1446
|
+
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"
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1430
1449
|
const authorizeKey = buildAuthorizeKey(baseUrl, clientId, options?.organizationId);
|
|
1431
1450
|
const now = Date.now();
|
|
1432
1451
|
const recentCount = getRecentRedirectCount(authorizeKey, now, logger);
|
|
@@ -1459,6 +1478,7 @@ function createRedirectMethods(deps) {
|
|
|
1459
1478
|
const params = new URLSearchParams({
|
|
1460
1479
|
response_type: "code",
|
|
1461
1480
|
client_id: clientId,
|
|
1481
|
+
scope,
|
|
1462
1482
|
redirect_uri: redirectUri,
|
|
1463
1483
|
state,
|
|
1464
1484
|
code_challenge: challenge,
|
|
@@ -1941,6 +1961,7 @@ function createContractWizardMethods(deps) {
|
|
|
1941
1961
|
var EXT_SUBSCRIBE_ENDPOINT2 = "/api/v1/ext/newsletter/subscribe";
|
|
1942
1962
|
var CONFIRM_ENDPOINT = "/api/newsletter/confirm";
|
|
1943
1963
|
var UNSUBSCRIBE_ENDPOINT = "/api/newsletter/unsubscribe";
|
|
1964
|
+
var DISPATCH_ENDPOINT = "/api/v1/newsletter/dispatch";
|
|
1944
1965
|
function trimOrEmpty(s) {
|
|
1945
1966
|
return typeof s === "string" ? s.trim() : "";
|
|
1946
1967
|
}
|
|
@@ -2046,7 +2067,36 @@ function createNewsletterMethods(deps) {
|
|
|
2046
2067
|
}
|
|
2047
2068
|
);
|
|
2048
2069
|
}
|
|
2049
|
-
|
|
2070
|
+
async function dispatch(params) {
|
|
2071
|
+
const subject = trimOrEmpty(params.subject);
|
|
2072
|
+
if (!subject) {
|
|
2073
|
+
return { error: createError("VALIDATION_ERROR", "subject \u306F\u5FC5\u9808\u3067\u3059") };
|
|
2074
|
+
}
|
|
2075
|
+
if (!params.body || typeof params.body !== "object") {
|
|
2076
|
+
return { error: createError("VALIDATION_ERROR", "body \u306F\u5FC5\u9808\u3067\u3059") };
|
|
2077
|
+
}
|
|
2078
|
+
const bodySource = params.body;
|
|
2079
|
+
const hasHtmlBody = typeof bodySource.htmlBody === "string" && bodySource.htmlBody.length > 0;
|
|
2080
|
+
const hasTemplateId = typeof bodySource.templateId === "string" && bodySource.templateId.length > 0;
|
|
2081
|
+
if (hasHtmlBody === hasTemplateId) {
|
|
2082
|
+
return {
|
|
2083
|
+
error: createError(
|
|
2084
|
+
"BODY_SOURCE_REQUIRED",
|
|
2085
|
+
"body \u306F htmlBody \u307E\u305F\u306F templateId \u306E\u3044\u305A\u308C\u304B\u4E00\u65B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044"
|
|
2086
|
+
)
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
return fetchWithAuth(DISPATCH_ENDPOINT, {
|
|
2090
|
+
method: "POST",
|
|
2091
|
+
body: JSON.stringify({
|
|
2092
|
+
subject,
|
|
2093
|
+
articleUrl: params.articleUrl,
|
|
2094
|
+
body: params.body,
|
|
2095
|
+
segment: params.segment
|
|
2096
|
+
})
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
return { subscribe, confirm, unsubscribe, dispatch };
|
|
2050
2100
|
}
|
|
2051
2101
|
|
|
2052
2102
|
// src/inquiry/ffid-inquiry-client.ts
|
|
@@ -2148,8 +2198,21 @@ function createFFIDClient(config) {
|
|
|
2148
2198
|
if (!config.serviceCode || !config.serviceCode.trim()) {
|
|
2149
2199
|
throw new Error("FFID Client: serviceCode \u304C\u672A\u8A2D\u5B9A\u3067\u3059");
|
|
2150
2200
|
}
|
|
2151
|
-
const
|
|
2201
|
+
const scope = config.scope?.trim() ?? "";
|
|
2202
|
+
const baseUrl = config.apiBaseUrl ?? chunkMDHKSVLP_cjs.DEFAULT_API_BASE_URL;
|
|
2152
2203
|
const authMode = config.authMode ?? "cookie";
|
|
2204
|
+
const VALID_AUTH_MODES = ["cookie", "token", "service-key"];
|
|
2205
|
+
if (!VALID_AUTH_MODES.includes(authMode)) {
|
|
2206
|
+
throw new Error(
|
|
2207
|
+
`FFID Client: authMode \u304C\u4E0D\u6B63\u3067\u3059 (\u53D7\u4FE1: ${JSON.stringify(authMode)}, \u6709\u52B9\u5024: ${VALID_AUTH_MODES.join(" | ")})`
|
|
2208
|
+
);
|
|
2209
|
+
}
|
|
2210
|
+
if (authMode !== "service-key" && !scope) {
|
|
2211
|
+
const received = config.scope === void 0 ? "undefined" : JSON.stringify(config.scope);
|
|
2212
|
+
throw new Error(
|
|
2213
|
+
`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)`
|
|
2214
|
+
);
|
|
2215
|
+
}
|
|
2153
2216
|
const clientId = config.clientId ?? config.serviceCode;
|
|
2154
2217
|
const rawRedirectUri = config.redirectUri ?? null;
|
|
2155
2218
|
const serviceApiKey = config.serviceApiKey?.trim();
|
|
@@ -2320,6 +2383,7 @@ function createFFIDClient(config) {
|
|
|
2320
2383
|
baseUrl,
|
|
2321
2384
|
clientId,
|
|
2322
2385
|
serviceCode: config.serviceCode,
|
|
2386
|
+
scope,
|
|
2323
2387
|
resolvedRedirectUri,
|
|
2324
2388
|
logger
|
|
2325
2389
|
});
|
|
@@ -2541,7 +2605,11 @@ function createKVCacheAdapter(kv) {
|
|
|
2541
2605
|
|
|
2542
2606
|
Object.defineProperty(exports, "DEFAULT_API_BASE_URL", {
|
|
2543
2607
|
enumerable: true,
|
|
2544
|
-
get: function () { return
|
|
2608
|
+
get: function () { return chunkMDHKSVLP_cjs.DEFAULT_API_BASE_URL; }
|
|
2609
|
+
});
|
|
2610
|
+
Object.defineProperty(exports, "DEFAULT_OAUTH_SCOPES", {
|
|
2611
|
+
enumerable: true,
|
|
2612
|
+
get: function () { return chunkMDHKSVLP_cjs.DEFAULT_OAUTH_SCOPES; }
|
|
2545
2613
|
});
|
|
2546
2614
|
exports.createFFIDClient = createFFIDClient;
|
|
2547
2615
|
exports.createKVCacheAdapter = createKVCacheAdapter;
|
package/dist/server/index.d.cts
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-B26jbUp5.cjs';
|
|
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-B26jbUp5.cjs';
|
|
3
|
+
export { D as DEFAULT_API_BASE_URL, a as DEFAULT_OAUTH_SCOPES } from '../constants-D61jqRIO.cjs';
|
|
4
4
|
|
|
5
5
|
/** Token verification - verifyAccessToken() implementation */
|
|
6
6
|
|
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-B26jbUp5.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-B26jbUp5.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.0.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() {
|
|
@@ -1418,6 +1418,7 @@ function createRedirectMethods(deps) {
|
|
|
1418
1418
|
baseUrl,
|
|
1419
1419
|
clientId,
|
|
1420
1420
|
serviceCode,
|
|
1421
|
+
scope,
|
|
1421
1422
|
resolvedRedirectUri,
|
|
1422
1423
|
logger
|
|
1423
1424
|
} = deps;
|
|
@@ -1426,6 +1427,24 @@ function createRedirectMethods(deps) {
|
|
|
1426
1427
|
logger.warn("SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093");
|
|
1427
1428
|
return { success: false, error: "SSR \u74B0\u5883\u3067\u306F\u30EA\u30C0\u30A4\u30EC\u30AF\u30C8\u3067\u304D\u307E\u305B\u3093" };
|
|
1428
1429
|
}
|
|
1430
|
+
if (authMode === "service-key") {
|
|
1431
|
+
logger.error(
|
|
1432
|
+
"[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"
|
|
1433
|
+
);
|
|
1434
|
+
return {
|
|
1435
|
+
success: false,
|
|
1436
|
+
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"
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
if (!scope || !scope.trim()) {
|
|
1440
|
+
logger.error(
|
|
1441
|
+
"[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"
|
|
1442
|
+
);
|
|
1443
|
+
return {
|
|
1444
|
+
success: false,
|
|
1445
|
+
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"
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1429
1448
|
const authorizeKey = buildAuthorizeKey(baseUrl, clientId, options?.organizationId);
|
|
1430
1449
|
const now = Date.now();
|
|
1431
1450
|
const recentCount = getRecentRedirectCount(authorizeKey, now, logger);
|
|
@@ -1458,6 +1477,7 @@ function createRedirectMethods(deps) {
|
|
|
1458
1477
|
const params = new URLSearchParams({
|
|
1459
1478
|
response_type: "code",
|
|
1460
1479
|
client_id: clientId,
|
|
1480
|
+
scope,
|
|
1461
1481
|
redirect_uri: redirectUri,
|
|
1462
1482
|
state,
|
|
1463
1483
|
code_challenge: challenge,
|
|
@@ -1940,6 +1960,7 @@ function createContractWizardMethods(deps) {
|
|
|
1940
1960
|
var EXT_SUBSCRIBE_ENDPOINT2 = "/api/v1/ext/newsletter/subscribe";
|
|
1941
1961
|
var CONFIRM_ENDPOINT = "/api/newsletter/confirm";
|
|
1942
1962
|
var UNSUBSCRIBE_ENDPOINT = "/api/newsletter/unsubscribe";
|
|
1963
|
+
var DISPATCH_ENDPOINT = "/api/v1/newsletter/dispatch";
|
|
1943
1964
|
function trimOrEmpty(s) {
|
|
1944
1965
|
return typeof s === "string" ? s.trim() : "";
|
|
1945
1966
|
}
|
|
@@ -2045,7 +2066,36 @@ function createNewsletterMethods(deps) {
|
|
|
2045
2066
|
}
|
|
2046
2067
|
);
|
|
2047
2068
|
}
|
|
2048
|
-
|
|
2069
|
+
async function dispatch(params) {
|
|
2070
|
+
const subject = trimOrEmpty(params.subject);
|
|
2071
|
+
if (!subject) {
|
|
2072
|
+
return { error: createError("VALIDATION_ERROR", "subject \u306F\u5FC5\u9808\u3067\u3059") };
|
|
2073
|
+
}
|
|
2074
|
+
if (!params.body || typeof params.body !== "object") {
|
|
2075
|
+
return { error: createError("VALIDATION_ERROR", "body \u306F\u5FC5\u9808\u3067\u3059") };
|
|
2076
|
+
}
|
|
2077
|
+
const bodySource = params.body;
|
|
2078
|
+
const hasHtmlBody = typeof bodySource.htmlBody === "string" && bodySource.htmlBody.length > 0;
|
|
2079
|
+
const hasTemplateId = typeof bodySource.templateId === "string" && bodySource.templateId.length > 0;
|
|
2080
|
+
if (hasHtmlBody === hasTemplateId) {
|
|
2081
|
+
return {
|
|
2082
|
+
error: createError(
|
|
2083
|
+
"BODY_SOURCE_REQUIRED",
|
|
2084
|
+
"body \u306F htmlBody \u307E\u305F\u306F templateId \u306E\u3044\u305A\u308C\u304B\u4E00\u65B9\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044"
|
|
2085
|
+
)
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
return fetchWithAuth(DISPATCH_ENDPOINT, {
|
|
2089
|
+
method: "POST",
|
|
2090
|
+
body: JSON.stringify({
|
|
2091
|
+
subject,
|
|
2092
|
+
articleUrl: params.articleUrl,
|
|
2093
|
+
body: params.body,
|
|
2094
|
+
segment: params.segment
|
|
2095
|
+
})
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
return { subscribe, confirm, unsubscribe, dispatch };
|
|
2049
2099
|
}
|
|
2050
2100
|
|
|
2051
2101
|
// src/inquiry/ffid-inquiry-client.ts
|
|
@@ -2147,8 +2197,21 @@ function createFFIDClient(config) {
|
|
|
2147
2197
|
if (!config.serviceCode || !config.serviceCode.trim()) {
|
|
2148
2198
|
throw new Error("FFID Client: serviceCode \u304C\u672A\u8A2D\u5B9A\u3067\u3059");
|
|
2149
2199
|
}
|
|
2200
|
+
const scope = config.scope?.trim() ?? "";
|
|
2150
2201
|
const baseUrl = config.apiBaseUrl ?? DEFAULT_API_BASE_URL;
|
|
2151
2202
|
const authMode = config.authMode ?? "cookie";
|
|
2203
|
+
const VALID_AUTH_MODES = ["cookie", "token", "service-key"];
|
|
2204
|
+
if (!VALID_AUTH_MODES.includes(authMode)) {
|
|
2205
|
+
throw new Error(
|
|
2206
|
+
`FFID Client: authMode \u304C\u4E0D\u6B63\u3067\u3059 (\u53D7\u4FE1: ${JSON.stringify(authMode)}, \u6709\u52B9\u5024: ${VALID_AUTH_MODES.join(" | ")})`
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
if (authMode !== "service-key" && !scope) {
|
|
2210
|
+
const received = config.scope === void 0 ? "undefined" : JSON.stringify(config.scope);
|
|
2211
|
+
throw new Error(
|
|
2212
|
+
`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)`
|
|
2213
|
+
);
|
|
2214
|
+
}
|
|
2152
2215
|
const clientId = config.clientId ?? config.serviceCode;
|
|
2153
2216
|
const rawRedirectUri = config.redirectUri ?? null;
|
|
2154
2217
|
const serviceApiKey = config.serviceApiKey?.trim();
|
|
@@ -2319,6 +2382,7 @@ function createFFIDClient(config) {
|
|
|
2319
2382
|
baseUrl,
|
|
2320
2383
|
clientId,
|
|
2321
2384
|
serviceCode: config.serviceCode,
|
|
2385
|
+
scope,
|
|
2322
2386
|
resolvedRedirectUri,
|
|
2323
2387
|
logger
|
|
2324
2388
|
});
|
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 };
|