@ductape/mcp 0.1.52 → 0.1.53
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/index.js +14 -4
- package/package.json +1 -1
- package/scripts/check-frontend-analytics-guidance.mjs +10 -0
- package/src/index.ts +14 -4
package/dist/index.js
CHANGED
|
@@ -2876,10 +2876,20 @@ Import (register an EXISTING cloud resource):
|
|
|
2876
2876
|
Only produce to topics whose schema is safe for client authorship.
|
|
2877
2877
|
NEVER allow clients to produce to topics that trigger privileged server-side operations
|
|
2878
2878
|
(payments, admin actions, state mutations) — those must go through a backend endpoint first.
|
|
2879
|
-
import
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2879
|
+
import { createClient } from '@ductape/client';
|
|
2880
|
+
// Equivalent supported import: import Ductape from '@ductape/client';
|
|
2881
|
+
const ductape = createClient({
|
|
2882
|
+
publishableKey: 'pk_...',
|
|
2883
|
+
env: 'prd',
|
|
2884
|
+
product: 'my-product',
|
|
2885
|
+
});
|
|
2886
|
+
await ductape.connect();
|
|
2887
|
+
await ductape.brokers.connect({
|
|
2888
|
+
broker: 'user-events',
|
|
2889
|
+
session: 'user-session:eyJ...',
|
|
2890
|
+
});
|
|
2891
|
+
await ductape.brokers.publish({
|
|
2892
|
+
topic: 'user-action',
|
|
2883
2893
|
message: { action: "button-click", screen: "dashboard" },
|
|
2884
2894
|
session: "user-session:eyJ...", // REQUIRED for client-side produce
|
|
2885
2895
|
});
|
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@ const safetyChecks = [
|
|
|
42
42
|
['raw token logging prohibited', /Never log,[\s\S]*raw session\/refresh token/],
|
|
43
43
|
['durable token expiry semantics documented', /does not expose an immutable[\s\S]*expired-token attribution contract/],
|
|
44
44
|
['frontend durable work prohibits persisted JWTs', /For delayed\/durable work, do not persist raw JWTs indefinitely/],
|
|
45
|
+
['browser events use frontend client', /CLIENT-SIDE \(browser — publishable key\):[\s\S]*import \{ createClient \} from '@ductape\/client';[\s\S]*ductape\.brokers\.publish/],
|
|
45
46
|
['resilience decision matrix present', /DECISION MATRIX[\s\S]*Database atomicity/],
|
|
46
47
|
['payload session-awareness metadata present', /session_awareness:[\s\S]*accepts_session/],
|
|
47
48
|
['execute blocks administrative mutations', /Administrative operation.*is blocked in ductape_execute/],
|
|
@@ -55,4 +56,13 @@ for (const [name, pattern] of safetyChecks) {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
const clientEventsSection = source.match(
|
|
60
|
+
/CLIENT-SIDE \(browser — publishable key\):[\s\S]*?SCHEDULED DISPATCH \(background job\):/,
|
|
61
|
+
)?.[0] ?? '';
|
|
62
|
+
assert.doesNotMatch(
|
|
63
|
+
clientEventsSection,
|
|
64
|
+
/from '@ductape\/sdk'/,
|
|
65
|
+
'Browser Events guidance must not import the server SDK',
|
|
66
|
+
);
|
|
67
|
+
|
|
58
68
|
console.log(`MCP guidance: ${checks.length + 1 + safetyChecks.length} acceptance checks passed`);
|
package/src/index.ts
CHANGED
|
@@ -2963,10 +2963,20 @@ Import (register an EXISTING cloud resource):
|
|
|
2963
2963
|
Only produce to topics whose schema is safe for client authorship.
|
|
2964
2964
|
NEVER allow clients to produce to topics that trigger privileged server-side operations
|
|
2965
2965
|
(payments, admin actions, state mutations) — those must go through a backend endpoint first.
|
|
2966
|
-
import
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2966
|
+
import { createClient } from '@ductape/client';
|
|
2967
|
+
// Equivalent supported import: import Ductape from '@ductape/client';
|
|
2968
|
+
const ductape = createClient({
|
|
2969
|
+
publishableKey: 'pk_...',
|
|
2970
|
+
env: 'prd',
|
|
2971
|
+
product: 'my-product',
|
|
2972
|
+
});
|
|
2973
|
+
await ductape.connect();
|
|
2974
|
+
await ductape.brokers.connect({
|
|
2975
|
+
broker: 'user-events',
|
|
2976
|
+
session: 'user-session:eyJ...',
|
|
2977
|
+
});
|
|
2978
|
+
await ductape.brokers.publish({
|
|
2979
|
+
topic: 'user-action',
|
|
2970
2980
|
message: { action: "button-click", screen: "dashboard" },
|
|
2971
2981
|
session: "user-session:eyJ...", // REQUIRED for client-side produce
|
|
2972
2982
|
});
|