@kubun/service-graph-api 0.16.0 → 0.16.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/lib/handlers.js +14 -7
- package/package.json +4 -4
package/lib/handlers.js
CHANGED
|
@@ -72,8 +72,9 @@ export function createGraphHandlers(params) {
|
|
|
72
72
|
if (ctx.param.mutations != null) {
|
|
73
73
|
// Pre-signed mode: client submitted JWT tokens keyed by GraphQL field alias
|
|
74
74
|
const mutations = ctx.param.mutations;
|
|
75
|
-
const
|
|
76
|
-
const
|
|
75
|
+
const entries = Object.entries(mutations);
|
|
76
|
+
const keys = entries.map(([key])=>key);
|
|
77
|
+
const tokens = entries.map(([, token])=>token);
|
|
77
78
|
// Apply all mutations atomically via engine primitive. A
|
|
78
79
|
// capability-check failure throws `WriteAccessDeniedError` from the
|
|
79
80
|
// apply path; translate it into a GraphQL-shaped result so the wire
|
|
@@ -106,12 +107,12 @@ export function createGraphHandlers(params) {
|
|
|
106
107
|
// mode does not configure an accessGate, so every result here carries
|
|
107
108
|
// a non-null `document`.
|
|
108
109
|
const mutatedDocuments = {};
|
|
109
|
-
for(
|
|
110
|
-
const doc = results[i]
|
|
110
|
+
for (const [i, key] of keys.entries()){
|
|
111
|
+
const doc = results[i]?.document;
|
|
111
112
|
if (doc == null) {
|
|
112
113
|
throw new Error('Unexpected dropped mutation in pre-signed apply (no gate configured)');
|
|
113
114
|
}
|
|
114
|
-
mutatedDocuments[
|
|
115
|
+
mutatedDocuments[key] = doc;
|
|
115
116
|
}
|
|
116
117
|
// Execute GraphQL with overridden mutation executors that return pre-applied results.
|
|
117
118
|
// contextExtensions overrides the engine's default executors via shallow merge.
|
|
@@ -146,6 +147,12 @@ export function createGraphHandlers(params) {
|
|
|
146
147
|
throw new Error('Delegated mutations require a SigningIdentity on the engine');
|
|
147
148
|
}
|
|
148
149
|
const transactionID = ctx.param.transactionID ?? null;
|
|
150
|
+
// Client may request an explicit document owner distinct from the signed
|
|
151
|
+
// viewer (e.g. a controller root the device is delegated to write for).
|
|
152
|
+
// The engine's write-access check gates it: when owner != signer, apply
|
|
153
|
+
// requires a delegation from `owner` for `document/write`. Omitting owner
|
|
154
|
+
// preserves the historical owner = viewerDID behavior.
|
|
155
|
+
const owner = ctx.param.owner ?? viewerDID;
|
|
149
156
|
// Non-transaction delegated: engine.mutateGraph() handles signing internally
|
|
150
157
|
if (transactionID == null) {
|
|
151
158
|
const result = await engine.mutateGraph({
|
|
@@ -153,7 +160,7 @@ export function createGraphHandlers(params) {
|
|
|
153
160
|
text: ctx.param.text,
|
|
154
161
|
variables: ctx.param.variables ?? {},
|
|
155
162
|
viewerDID,
|
|
156
|
-
owner
|
|
163
|
+
owner
|
|
157
164
|
});
|
|
158
165
|
return toGraphResult(result);
|
|
159
166
|
}
|
|
@@ -189,7 +196,7 @@ export function createGraphHandlers(params) {
|
|
|
189
196
|
issuer: signingIdentity.id,
|
|
190
197
|
hlc,
|
|
191
198
|
getRandomValues,
|
|
192
|
-
owner
|
|
199
|
+
owner,
|
|
193
200
|
async processSetMutation (mutation) {
|
|
194
201
|
return await signAndBuffer(mutation);
|
|
195
202
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/service-graph-api",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@kubun/id": "^0.16.0",
|
|
23
23
|
"@kubun/mutation": "^0.16.0",
|
|
24
24
|
"@kubun/plugin-service-api": "^0.16.0",
|
|
25
|
-
"@kubun/protocol": "^0.16.
|
|
25
|
+
"@kubun/protocol": "^0.16.1",
|
|
26
26
|
"@sozai/generator": "^0.2.0",
|
|
27
27
|
"@sozai/runtime": "^0.1.0",
|
|
28
28
|
"graphql": "^16.14.2"
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|
|
49
49
|
"build:clean": "del lib",
|
|
50
|
-
"build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
|
|
51
|
-
"build:types": "tsc --emitDeclarationOnly --skipLibCheck",
|
|
50
|
+
"build:js": "del 'lib/**/*.js' && swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
|
|
51
|
+
"build:types": "del 'lib/**/*.d.ts' 'lib/**/*.d.ts.map' && tsc --emitDeclarationOnly --skipLibCheck",
|
|
52
52
|
"build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
|
|
53
53
|
"test": "pnpm run test:types && pnpm run test:unit",
|
|
54
54
|
"test:types": "tsc --noEmit -p tsconfig.test.json",
|