opscms-meta-plugin 0.6.0 → 0.6.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/CHANGELOG.md +15 -5
- package/README.md +13 -13
- package/dist/{chunk-TSCTFPN2.mjs → chunk-VPSQ2E3Q.mjs} +1 -1
- package/dist/components/MetaCatalogSync/index.mjs +1 -1
- package/dist/components/MetaConnectPanel/index.js +1 -1
- package/dist/components/MetaConnectPanel/index.mjs +1 -1
- package/dist/components/MetaPixelSelect/index.mjs +1 -1
- package/dist/components/ThreadsConnectPanel/index.js +1 -1
- package/dist/components/ThreadsConnectPanel/index.mjs +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +7 -11
- package/dist/index.mjs +7 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **An organization admin (and an editor) could not create a Meta connection, so no site could be connected.** The create rule refused unless the request already named a
|
|
8
|
+
site, but the admin screen asks "may this person create one?" before there is a document, so the answer was always no and "Create New" never appeared (only a
|
|
9
|
+
super-admin saw it). An admin or editor may now start one. Nothing else is looser: the site is still a required field, an editor is still pinned to their own site,
|
|
10
|
+
and a site that is submitted is still checked against the admin's organization.
|
|
11
|
+
|
|
3
12
|
## 0.6.0
|
|
4
13
|
|
|
5
|
-
###
|
|
14
|
+
### Changed (breaking)
|
|
6
15
|
|
|
7
|
-
- **The
|
|
8
|
-
for it when it needs it, so a host that keeps the app in its own settings needs nothing
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
- **The platform's Meta app comes from the host, and only from the host.** `metaPlugin({ app: () => ({ appId, appSecret, webhookVerifyToken }) })`: the
|
|
17
|
+
plugin asks for it when it needs it, so a host that keeps the app in its own settings needs nothing on the server, and a change is used at once.
|
|
18
|
+
`META_APP_ID`, `META_APP_SECRET` and `META_WEBHOOK_VERIFY_TOKEN` are **no longer read**: one place to set the app, no second value that can disagree.
|
|
19
|
+
A host that passes no `app` has Meta Connect, Facebook login and the webhook switched off. (`META_ENCRYPTION_KEY` and `META_OAUTH_STATE_SECRET` are
|
|
20
|
+
not part of this: they protect what is stored and signed, so they stay on the server.)
|
|
11
21
|
|
|
12
22
|
## 0.4.2
|
|
13
23
|
|
package/README.md
CHANGED
|
@@ -87,18 +87,18 @@ export default buildConfig({
|
|
|
87
87
|
```bash
|
|
88
88
|
# .env
|
|
89
89
|
META_ENCRYPTION_KEY=$(openssl rand -hex 32)
|
|
90
|
-
META_APP_ID=your-meta-app-id
|
|
91
|
-
META_APP_SECRET=your-meta-app-secret
|
|
92
90
|
```
|
|
93
91
|
|
|
92
|
+
The Meta App itself is **not** set in the environment: the host CMS passes it in (`metaPlugin({ app: () => ({ appId, appSecret, webhookVerifyToken }) })`), from wherever it keeps its own settings (OpsCMS: Platform Settings → Meta app). A host that passes no `app` has Meta Connect, Facebook login and the webhook switched off.
|
|
93
|
+
|
|
94
94
|
Without `META_ENCRYPTION_KEY`, credentials are stored in plain text (allowed in development; the plugin **fails fast at startup in production** unless you explicitly set `ALLOW_PLAINTEXT_META_CREDS=true`, which you should not do).
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
The App ID and secret the host passes are the **one Meta App for the whole deployment** — same pattern as Buffer/Hootsuite/Zapier: every tenant site connects through this single App, they never create their own. There's no API to create a Meta App programmatically (unlike, say, ERPNext's OAuth Client doctype), so this is a one-time manual step:
|
|
97
97
|
|
|
98
98
|
1. Create an App at [developers.facebook.com](https://developers.facebook.com), add the **Facebook Login for Business** product (and **Threads API** if you'll connect Threads).
|
|
99
99
|
2. Add `{PAYLOAD_PUBLIC_SERVER_URL}/api/meta-oauth/callback` and `{PAYLOAD_PUBLIC_SERVER_URL}/api/threads-oauth/callback` as **Valid OAuth Redirect URIs**.
|
|
100
100
|
3. Switch the App to **Live** mode and request **Advanced Access** (via App Review) for whichever scopes you need — `pages_show_list`, `pages_read_engagement`, `instagram_basic`, `business_management`, `ads_management`, etc. In Development mode, OAuth only works for users added as Testers/Admins/Developers on the App itself — real tenant site owners won't be able to connect until this is done. Meta may also require **Business Verification** for the ads/marketing-adjacent scopes.
|
|
101
|
-
4.
|
|
101
|
+
4. Give the host the App ID and App secret from that App's Settings → Basic page (OpsCMS: Platform Settings → Meta app). It is used at once; no restart.
|
|
102
102
|
|
|
103
103
|
Site owners never see or enter these — the admin UI shows only a masked, read-only App ID (`GET /api/meta-oauth/app-info`) so they can confirm a platform App is configured before clicking Connect.
|
|
104
104
|
|
|
@@ -136,7 +136,7 @@ Paste a long-lived Page or System User access token directly into `accessToken`
|
|
|
136
136
|
|
|
137
137
|
### Option B — Connect to Meta Business (OAuth)
|
|
138
138
|
|
|
139
|
-
Uses the one platform-level Meta App
|
|
139
|
+
Uses the one platform-level Meta App the host passes in (see [Set the encryption key and the platform Meta App](#2-set-the-encryption-key-and-the-platform-meta-app) — that's a one-time deployment setup step, not something each site does). Once that's configured:
|
|
140
140
|
|
|
141
141
|
1. On the `meta-config` document's 🔑 Connection tab, the panel shows a masked, read-only **Platform Meta App** ID confirming it's configured.
|
|
142
142
|
2. Click **Connect to Meta Business** — you'll be redirected to Meta's OAuth consent screen requesting `business_management`, `pages_show_list`, `pages_read_engagement`, `pages_manage_metadata`, `instagram_basic`, `ads_management`, `catalog_management`, and `whatsapp_business_management` (trim the scope list in `metaOAuth.ts` if your App's review doesn't cover all of them — Meta simply omits ungranted permissions from the resulting token rather than failing the whole flow).
|
|
@@ -145,7 +145,7 @@ Uses the one platform-level Meta App set up via `META_APP_ID`/`META_APP_SECRET`
|
|
|
145
145
|
|
|
146
146
|
### Connecting Threads
|
|
147
147
|
|
|
148
|
-
Threads is a **separate product/API** from Facebook and Instagram — its own OAuth host (`threads.net`, not `facebook.com`), its own token host (`graph.threads.net`, not `graph.facebook.com`), and its own token/profile shape — even though it's added as a product on the *same* Meta App and reuses the same platform-level
|
|
148
|
+
Threads is a **separate product/API** from Facebook and Instagram — its own OAuth host (`threads.net`, not `facebook.com`), its own token host (`graph.threads.net`, not `graph.facebook.com`), and its own token/profile shape — even though it's added as a product on the *same* Meta App and reuses the same platform-level the app ID/the app secret.
|
|
149
149
|
|
|
150
150
|
1. Add the **Threads API** product to the same Meta App (see setup step above), and register `{PAYLOAD_PUBLIC_SERVER_URL}/api/threads-oauth/callback` as its redirect URI.
|
|
151
151
|
2. On the **🧵 Threads** tab, click **Connect Threads** — separate consent screen (`threads_basic`, `threads_content_publish`), separate callback, separate stored token (`threadsAccessToken`). Connecting Threads does not affect or require the Facebook/Instagram connection above, or vice versa.
|
|
@@ -167,7 +167,7 @@ export interface MetaPluginOptions {
|
|
|
167
167
|
|
|
168
168
|
| Variable | Required | Description |
|
|
169
169
|
|---|---|---|
|
|
170
|
-
|
|
|
170
|
+
| *(the host's `app` option)* | For OAuth Connect | The one Meta App for the whole deployment (developers.facebook.com) — every tenant site's Connect button uses this. Not required if every site only ever uses manual Access Token entry. Not an environment variable, and never entered by a site owner; see [Set the encryption key and the platform Meta App](#2-set-the-encryption-key-and-the-platform-meta-app). |
|
|
171
171
|
| `META_ENCRYPTION_KEY` | Production: yes | 32-byte hex key (`openssl rand -hex 32`) for AES-256-GCM credential encryption. Separate from `opscms-erpnext-plugin`'s `ERPNEXT_ENCRYPTION_KEY` — rotating one doesn't affect the other. |
|
|
172
172
|
| `ALLOW_PLAINTEXT_META_CREDS` | No | Set to `true` to explicitly allow plain-text credential storage in production. Do not set this unless you understand the risk (a DB dump/backup leaks every tenant's Meta access token). |
|
|
173
173
|
| `PAYLOAD_PUBLIC_SERVER_URL` | For Catalog feed + OAuth | Used to build absolute image URLs in the Commerce Catalog feed, and the OAuth callback redirect URIs (`/api/meta-oauth/callback`, `/api/threads-oauth/callback`). Already set for the host CMS's other public-facing needs. |
|
|
@@ -177,7 +177,7 @@ export interface MetaPluginOptions {
|
|
|
177
177
|
|
|
178
178
|
## The `meta-config` Collection
|
|
179
179
|
|
|
180
|
-
One document per site. `appId`/`appSecret` are **not** fields here — they're the one platform-level Meta App
|
|
180
|
+
One document per site. `appId`/`appSecret` are **not** fields here — they're the one platform-level Meta App the host passes in, never per-site. Every other credential field is directly editable (manual entry) — the Connect buttons are a convenience layer on top, not a replacement:
|
|
181
181
|
|
|
182
182
|
| Tab | Fields | Notes |
|
|
183
183
|
|---|---|---|
|
|
@@ -187,7 +187,7 @@ One document per site. `appId`/`appSecret` are **not** fields here — they're t
|
|
|
187
187
|
| 💬 WhatsApp Business | `whatsappEnabled`, `whatsappPhoneNumberId`, `whatsappBusinessAccountId` | Populates the host CMS's existing `lib/whatsapp.ts` `metaCloud` provider — no plugin code needed for outbound sending. |
|
|
188
188
|
| 🧵 Threads | `threadsEnabled`, **Connect Threads** button, `threadsUserId`/`threadsUsername` (read-only, set by Connect), `threadsAccessToken` (hidden, encrypted) | Independent OAuth flow — see [Connecting Facebook, Instagram, and Threads](#connecting-facebook-instagram-and-threads). |
|
|
189
189
|
|
|
190
|
-
Credentials (`accessToken`, `oauthUserAccessToken`, `threadsAccessToken`) are AES-256-GCM encrypted at rest and masked in the admin UI (`••••1234`) for any authenticated non-internal request — the same pattern `ErpnextConfig` uses for `apiKey`/`apiSecret`.
|
|
190
|
+
Credentials (`accessToken`, `oauthUserAccessToken`, `threadsAccessToken`) are AES-256-GCM encrypted at rest and masked in the admin UI (`••••1234`) for any authenticated non-internal request — the same pattern `ErpnextConfig` uses for `apiKey`/`apiSecret`. the app secret never touches the database at all — it's read from the environment on each OAuth request.
|
|
191
191
|
|
|
192
192
|
---
|
|
193
193
|
|
|
@@ -270,7 +270,7 @@ The one real gap: Meta's WhatsApp Cloud API webhook subscription requires a `GET
|
|
|
270
270
|
|
|
271
271
|
## Security
|
|
272
272
|
|
|
273
|
-
- Credentials (`accessToken`) are AES-256-GCM encrypted at rest (`META_ENCRYPTION_KEY`), masked in the admin UI, and only decrypted server-side when actually needed (e.g. `getMetaCredentials()`, the connection-health check).
|
|
273
|
+
- Credentials (`accessToken`) are AES-256-GCM encrypted at rest (`META_ENCRYPTION_KEY`), masked in the admin UI, and only decrypted server-side when actually needed (e.g. `getMetaCredentials()`, the connection-health check). the app secret is never stored in the database at all — it's read from the environment only, on each OAuth request.
|
|
274
274
|
- `accessToken` is only writable by `admin`/`super-admin` roles (`adminOrAboveField` field-level access) — editors can see the masked config but can't rotate credentials or repoint a connection.
|
|
275
275
|
- `getMetaCredentials()` never falls back across sites — a lookup for one site's slug will never return another tenant's credentials, even on a partial/missing config.
|
|
276
276
|
- The Commerce Catalog feed is intentionally public (Meta's crawler needs unauthenticated access) but strictly site-scoped — it can never return another site's data, and only returns docs that already belong to the requested site.
|
|
@@ -298,8 +298,8 @@ MIT
|
|
|
298
298
|
|
|
299
299
|
Meta reports what happens on its side to one callback address per app. Register
|
|
300
300
|
`https://<your CMS>/api/meta-webhook` as the callback of the platform's Meta app, for the
|
|
301
|
-
**WhatsApp Business Account** topic, with the verify token
|
|
302
|
-
The app secret
|
|
301
|
+
**WhatsApp Business Account** topic, with the verify token the host passes in (`webhookVerifyToken`).
|
|
302
|
+
The app secret must also be set: every delivery is signed with it, and a
|
|
303
303
|
delivery with a missing or wrong signature is refused with 401.
|
|
304
304
|
|
|
305
305
|
Each site's business account is subscribed to the app when the site chooses its WhatsApp
|
|
@@ -329,7 +329,7 @@ The plugin adds "Continue with Facebook" to the platform's login page, using the
|
|
|
329
329
|
|
|
330
330
|
- **Who gets in:** someone who already has a platform account. Their Facebook email must be the same as their platform email to join the
|
|
331
331
|
two; after that they sign in by Facebook id. Signing in never creates an account, and an account is never matched on a different email.
|
|
332
|
-
- **Setup:**
|
|
332
|
+
- **Setup:** the Meta app given to the plugin by the host, the Facebook Login product on the Meta app, and
|
|
333
333
|
`<PAYLOAD_PUBLIC_SERVER_URL>/api/meta-login/callback` listed as a valid OAuth redirect URI. Only `email` and `public_profile` are
|
|
334
334
|
requested, which need no App Review.
|
|
335
335
|
- **Database:** the plugin adds a unique `facebookId` field to the users collection; the platform needs a migration for the column.
|
|
@@ -70,7 +70,7 @@ function useMetaAppInfo() {
|
|
|
70
70
|
var MetaAppInfoBadge = ({ appInfo }) => {
|
|
71
71
|
if (appInfo.loading) return null;
|
|
72
72
|
if (!appInfo.configured) {
|
|
73
|
-
return /* @__PURE__ */ jsx(ErrorState, { message: "Meta App not configured on this deployment \u2014 the platform owner needs to enter its App ID and secret in Platform Settings
|
|
73
|
+
return /* @__PURE__ */ jsx(ErrorState, { message: "Meta App not configured on this deployment \u2014 the platform owner needs to enter its App ID and secret in Platform Settings." });
|
|
74
74
|
}
|
|
75
75
|
return /* @__PURE__ */ jsxs("div", { style: { ...messageBoxStyle("info"), display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
76
76
|
/* @__PURE__ */ jsx("span", { children: "Platform Meta App" }),
|
|
@@ -110,7 +110,7 @@ function useMetaAppInfo() {
|
|
|
110
110
|
var MetaAppInfoBadge = ({ appInfo }) => {
|
|
111
111
|
if (appInfo.loading) return null;
|
|
112
112
|
if (!appInfo.configured) {
|
|
113
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorState, { message: "Meta App not configured on this deployment \u2014 the platform owner needs to enter its App ID and secret in Platform Settings
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorState, { message: "Meta App not configured on this deployment \u2014 the platform owner needs to enter its App ID and secret in Platform Settings." });
|
|
114
114
|
}
|
|
115
115
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { ...messageBoxStyle("info"), display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
116
116
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Platform Meta App" }),
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
openMetaOAuthPopup,
|
|
16
16
|
useMetaAppInfo,
|
|
17
17
|
useOAuthRedirectMessage
|
|
18
|
-
} from "../../chunk-
|
|
18
|
+
} from "../../chunk-VPSQ2E3Q.mjs";
|
|
19
19
|
|
|
20
20
|
// src/components/MetaConnectPanel/index.tsx
|
|
21
21
|
import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
@@ -89,7 +89,7 @@ function useMetaAppInfo() {
|
|
|
89
89
|
var MetaAppInfoBadge = ({ appInfo }) => {
|
|
90
90
|
if (appInfo.loading) return null;
|
|
91
91
|
if (!appInfo.configured) {
|
|
92
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorState, { message: "Meta App not configured on this deployment \u2014 the platform owner needs to enter its App ID and secret in Platform Settings
|
|
92
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorState, { message: "Meta App not configured on this deployment \u2014 the platform owner needs to enter its App ID and secret in Platform Settings." });
|
|
93
93
|
}
|
|
94
94
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { ...messageBoxStyle("info"), display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
95
95
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Platform Meta App" }),
|
package/dist/index.d.mts
CHANGED
|
@@ -69,7 +69,7 @@ declare function explainTemplateSendError(body: string): {
|
|
|
69
69
|
error: string;
|
|
70
70
|
} | null;
|
|
71
71
|
|
|
72
|
-
/** Resolved Meta API credentials for a single site, decrypted and ready to use. appId/appSecret are deployment-wide (
|
|
72
|
+
/** Resolved Meta API credentials for a single site, decrypted and ready to use. appId/appSecret are deployment-wide (given by the host, see utils/metaCrypto.ts), not part of a site's credentials. */
|
|
73
73
|
interface MetaCredentials {
|
|
74
74
|
accessToken: string;
|
|
75
75
|
businessManagerId?: string;
|
|
@@ -229,7 +229,7 @@ declare const metaWhatsAppChannel: NotificationChannelProvider<MetaCloudGateway>
|
|
|
229
229
|
* The plugin's webhook: the address Meta calls to report what happens on its side.
|
|
230
230
|
*
|
|
231
231
|
* Register `https://<your CMS>/api/meta-webhook` as the callback of the platform's Meta app, for the WhatsApp business account
|
|
232
|
-
* topic, with the verify token set in the host's Meta app settings
|
|
232
|
+
* topic, with the verify token set in the host's Meta app settings. Each site's business account is subscribed to the app when
|
|
233
233
|
* the site connects (see utils/wabaSubscription.ts), so its events arrive here.
|
|
234
234
|
*
|
|
235
235
|
* - GET answers Meta's handshake.
|
|
@@ -350,8 +350,9 @@ interface MetaPluginOptions {
|
|
|
350
350
|
host?: MetaHost;
|
|
351
351
|
/**
|
|
352
352
|
* The platform's Meta app (App ID, secret, webhook verify token), as the host keeps it in its own settings. Called whenever the plugin needs it, so
|
|
353
|
-
* keep it quick (answer from memory).
|
|
354
|
-
*
|
|
353
|
+
* keep it quick (answer from memory). It is the ONLY source: the plugin does not read the app from the server's environment, so a host that does
|
|
354
|
+
* not pass this leaves Meta Connect, Facebook login and the webhook switched off. (`META_ENCRYPTION_KEY`, the key that protects what is stored,
|
|
355
|
+
* is still read from the environment.)
|
|
355
356
|
*/
|
|
356
357
|
app?: () => MetaAppSettings | null | undefined;
|
|
357
358
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ declare function explainTemplateSendError(body: string): {
|
|
|
69
69
|
error: string;
|
|
70
70
|
} | null;
|
|
71
71
|
|
|
72
|
-
/** Resolved Meta API credentials for a single site, decrypted and ready to use. appId/appSecret are deployment-wide (
|
|
72
|
+
/** Resolved Meta API credentials for a single site, decrypted and ready to use. appId/appSecret are deployment-wide (given by the host, see utils/metaCrypto.ts), not part of a site's credentials. */
|
|
73
73
|
interface MetaCredentials {
|
|
74
74
|
accessToken: string;
|
|
75
75
|
businessManagerId?: string;
|
|
@@ -229,7 +229,7 @@ declare const metaWhatsAppChannel: NotificationChannelProvider<MetaCloudGateway>
|
|
|
229
229
|
* The plugin's webhook: the address Meta calls to report what happens on its side.
|
|
230
230
|
*
|
|
231
231
|
* Register `https://<your CMS>/api/meta-webhook` as the callback of the platform's Meta app, for the WhatsApp business account
|
|
232
|
-
* topic, with the verify token set in the host's Meta app settings
|
|
232
|
+
* topic, with the verify token set in the host's Meta app settings. Each site's business account is subscribed to the app when
|
|
233
233
|
* the site connects (see utils/wabaSubscription.ts), so its events arrive here.
|
|
234
234
|
*
|
|
235
235
|
* - GET answers Meta's handshake.
|
|
@@ -350,8 +350,9 @@ interface MetaPluginOptions {
|
|
|
350
350
|
host?: MetaHost;
|
|
351
351
|
/**
|
|
352
352
|
* The platform's Meta app (App ID, secret, webhook verify token), as the host keeps it in its own settings. Called whenever the plugin needs it, so
|
|
353
|
-
* keep it quick (answer from memory).
|
|
354
|
-
*
|
|
353
|
+
* keep it quick (answer from memory). It is the ONLY source: the plugin does not read the app from the server's environment, so a host that does
|
|
354
|
+
* not pass this leaves Meta Connect, Facebook login and the webhook switched off. (`META_ENCRYPTION_KEY`, the key that protects what is stored,
|
|
355
|
+
* is still read from the environment.)
|
|
355
356
|
*/
|
|
356
357
|
app?: () => MetaAppSettings | null | undefined;
|
|
357
358
|
}
|
package/dist/index.js
CHANGED
|
@@ -155,7 +155,7 @@ var siteScopedCreate = (siteField = "site") => {
|
|
|
155
155
|
if (u.role === "super-admin") return true;
|
|
156
156
|
if (!["admin", "editor"].includes(u.role)) return false;
|
|
157
157
|
const rawDocSite = submittedSiteId(data, siteField);
|
|
158
|
-
if (rawDocSite === void 0 || rawDocSite === null || rawDocSite === "") return
|
|
158
|
+
if (rawDocSite === void 0 || rawDocSite === null || rawDocSite === "") return true;
|
|
159
159
|
const siteId = getUserSiteId(u);
|
|
160
160
|
if (siteId) return String(rawDocSite) === String(siteId);
|
|
161
161
|
if (u.role !== "admin") return false;
|
|
@@ -308,11 +308,7 @@ function metaAppSettings() {
|
|
|
308
308
|
} catch {
|
|
309
309
|
given = null;
|
|
310
310
|
}
|
|
311
|
-
return {
|
|
312
|
-
appId: text(given?.appId) ?? text(process.env.META_APP_ID),
|
|
313
|
-
appSecret: text(given?.appSecret) ?? text(process.env.META_APP_SECRET),
|
|
314
|
-
webhookVerifyToken: text(given?.webhookVerifyToken) ?? text(process.env.META_WEBHOOK_VERIFY_TOKEN)
|
|
315
|
-
};
|
|
311
|
+
return { appId: text(given?.appId), appSecret: text(given?.appSecret), webhookVerifyToken: text(given?.webhookVerifyToken) };
|
|
316
312
|
}
|
|
317
313
|
function getMetaAppCredentials() {
|
|
318
314
|
const { appId, appSecret } = metaAppSettings();
|
|
@@ -565,7 +561,7 @@ var MetaConfig = {
|
|
|
565
561
|
// ── Tab 1: Connection ────────────────────────────────
|
|
566
562
|
{
|
|
567
563
|
label: "\u{1F511} Connection",
|
|
568
|
-
description: "
|
|
564
|
+
description: "The Meta app is set once for the whole platform (by the platform owner, in its settings). Log in with Facebook below. The fields fill in from that login and stay read-only. Disconnect clears them.",
|
|
569
565
|
fields: [
|
|
570
566
|
{
|
|
571
567
|
name: "accessToken",
|
|
@@ -1631,7 +1627,7 @@ var metaOAuthStartEndpoint = {
|
|
|
1631
1627
|
}
|
|
1632
1628
|
const appCreds = getMetaAppCredentials();
|
|
1633
1629
|
if (!appCreds) {
|
|
1634
|
-
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1630
|
+
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings." }, { status: 400 });
|
|
1635
1631
|
}
|
|
1636
1632
|
const state = signOAuthState(configId);
|
|
1637
1633
|
const params = new URLSearchParams({
|
|
@@ -1669,7 +1665,7 @@ var metaOAuthCallbackEndpoint = {
|
|
|
1669
1665
|
}
|
|
1670
1666
|
const appCreds = getMetaAppCredentials();
|
|
1671
1667
|
if (!appCreds) {
|
|
1672
|
-
return oauthFinished({ ok: false, configId, error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1668
|
+
return oauthFinished({ ok: false, configId, error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings." });
|
|
1673
1669
|
}
|
|
1674
1670
|
const shortLived = await graphGet("/oauth/access_token", {
|
|
1675
1671
|
client_id: appCreds.appId,
|
|
@@ -1952,7 +1948,7 @@ var threadsOAuthStartEndpoint = {
|
|
|
1952
1948
|
}
|
|
1953
1949
|
const appCreds = getMetaAppCredentials();
|
|
1954
1950
|
if (!appCreds) {
|
|
1955
|
-
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1951
|
+
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings." }, { status: 400 });
|
|
1956
1952
|
}
|
|
1957
1953
|
const state = signOAuthState(configId);
|
|
1958
1954
|
const params = new URLSearchParams({
|
|
@@ -1990,7 +1986,7 @@ var threadsOAuthCallbackEndpoint = {
|
|
|
1990
1986
|
}
|
|
1991
1987
|
const appCreds = getMetaAppCredentials();
|
|
1992
1988
|
if (!appCreds) {
|
|
1993
|
-
return Response.redirect(`${adminBase}/${configId}?threads_oauth_error=${encodeURIComponent("Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1989
|
+
return Response.redirect(`${adminBase}/${configId}?threads_oauth_error=${encodeURIComponent("Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings.")}`, 302);
|
|
1994
1990
|
}
|
|
1995
1991
|
const shortLived = await threadsPost("/oauth/access_token", {
|
|
1996
1992
|
client_id: appCreds.appId,
|
package/dist/index.mjs
CHANGED
|
@@ -119,7 +119,7 @@ var siteScopedCreate = (siteField = "site") => {
|
|
|
119
119
|
if (u.role === "super-admin") return true;
|
|
120
120
|
if (!["admin", "editor"].includes(u.role)) return false;
|
|
121
121
|
const rawDocSite = submittedSiteId(data, siteField);
|
|
122
|
-
if (rawDocSite === void 0 || rawDocSite === null || rawDocSite === "") return
|
|
122
|
+
if (rawDocSite === void 0 || rawDocSite === null || rawDocSite === "") return true;
|
|
123
123
|
const siteId = getUserSiteId(u);
|
|
124
124
|
if (siteId) return String(rawDocSite) === String(siteId);
|
|
125
125
|
if (u.role !== "admin") return false;
|
|
@@ -272,11 +272,7 @@ function metaAppSettings() {
|
|
|
272
272
|
} catch {
|
|
273
273
|
given = null;
|
|
274
274
|
}
|
|
275
|
-
return {
|
|
276
|
-
appId: text(given?.appId) ?? text(process.env.META_APP_ID),
|
|
277
|
-
appSecret: text(given?.appSecret) ?? text(process.env.META_APP_SECRET),
|
|
278
|
-
webhookVerifyToken: text(given?.webhookVerifyToken) ?? text(process.env.META_WEBHOOK_VERIFY_TOKEN)
|
|
279
|
-
};
|
|
275
|
+
return { appId: text(given?.appId), appSecret: text(given?.appSecret), webhookVerifyToken: text(given?.webhookVerifyToken) };
|
|
280
276
|
}
|
|
281
277
|
function getMetaAppCredentials() {
|
|
282
278
|
const { appId, appSecret } = metaAppSettings();
|
|
@@ -529,7 +525,7 @@ var MetaConfig = {
|
|
|
529
525
|
// ── Tab 1: Connection ────────────────────────────────
|
|
530
526
|
{
|
|
531
527
|
label: "\u{1F511} Connection",
|
|
532
|
-
description: "
|
|
528
|
+
description: "The Meta app is set once for the whole platform (by the platform owner, in its settings). Log in with Facebook below. The fields fill in from that login and stay read-only. Disconnect clears them.",
|
|
533
529
|
fields: [
|
|
534
530
|
{
|
|
535
531
|
name: "accessToken",
|
|
@@ -1572,7 +1568,7 @@ var metaOAuthStartEndpoint = {
|
|
|
1572
1568
|
}
|
|
1573
1569
|
const appCreds = getMetaAppCredentials();
|
|
1574
1570
|
if (!appCreds) {
|
|
1575
|
-
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1571
|
+
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings." }, { status: 400 });
|
|
1576
1572
|
}
|
|
1577
1573
|
const state = signOAuthState(configId);
|
|
1578
1574
|
const params = new URLSearchParams({
|
|
@@ -1610,7 +1606,7 @@ var metaOAuthCallbackEndpoint = {
|
|
|
1610
1606
|
}
|
|
1611
1607
|
const appCreds = getMetaAppCredentials();
|
|
1612
1608
|
if (!appCreds) {
|
|
1613
|
-
return oauthFinished({ ok: false, configId, error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1609
|
+
return oauthFinished({ ok: false, configId, error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings." });
|
|
1614
1610
|
}
|
|
1615
1611
|
const shortLived = await graphGet("/oauth/access_token", {
|
|
1616
1612
|
client_id: appCreds.appId,
|
|
@@ -1893,7 +1889,7 @@ var threadsOAuthStartEndpoint = {
|
|
|
1893
1889
|
}
|
|
1894
1890
|
const appCreds = getMetaAppCredentials();
|
|
1895
1891
|
if (!appCreds) {
|
|
1896
|
-
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1892
|
+
return Response.json({ error: "Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings." }, { status: 400 });
|
|
1897
1893
|
}
|
|
1898
1894
|
const state = signOAuthState(configId);
|
|
1899
1895
|
const params = new URLSearchParams({
|
|
@@ -1931,7 +1927,7 @@ var threadsOAuthCallbackEndpoint = {
|
|
|
1931
1927
|
}
|
|
1932
1928
|
const appCreds = getMetaAppCredentials();
|
|
1933
1929
|
if (!appCreds) {
|
|
1934
|
-
return Response.redirect(`${adminBase}/${configId}?threads_oauth_error=${encodeURIComponent("Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings
|
|
1930
|
+
return Response.redirect(`${adminBase}/${configId}?threads_oauth_error=${encodeURIComponent("Meta App not configured on this deployment \u2014 enter its App ID and secret in Platform Settings.")}`, 302);
|
|
1935
1931
|
}
|
|
1936
1932
|
const shortLived = await threadsPost("/oauth/access_token", {
|
|
1937
1933
|
client_id: appCreds.appId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opscms-meta-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Payload CMS plugin for connecting multi-tenant sites to Meta's network (Facebook Pixel + Conversions API, Facebook/Instagram Commerce Catalog, WhatsApp Business Cloud API). Modular per-channel, per-site — nothing hardcoded to one product line.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|