@jskit-ai/auth-core 0.1.144 → 0.1.145
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/package.descriptor.mjs
CHANGED
package/package.json
CHANGED
|
@@ -51,6 +51,15 @@ class AuthActionsServiceProvider {
|
|
|
51
51
|
}
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
boot(app) {
|
|
57
|
+
// auth-core also owns the request policy used by deliberately public apps.
|
|
58
|
+
// Only contribute executable auth actions when one of the provider packages
|
|
59
|
+
// registered the service those actions require.
|
|
60
|
+
if (!app.has("authService")) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
54
63
|
|
|
55
64
|
app.actions(
|
|
56
65
|
withActionDefaults(buildAuthActions(), {
|
package/test/authActions.test.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
|
+
import { createSchema } from "json-rest-schema";
|
|
3
4
|
import { createApplication } from "@jskit-ai/kernel/_testable";
|
|
4
5
|
import { ActionRuntimeServiceProvider } from "@jskit-ai/kernel/server/actions";
|
|
5
6
|
import { AuthActionsServiceProvider } from "../src/server/providers/AuthActionsServiceProvider.js";
|
|
@@ -206,3 +207,59 @@ test("AuthActionsServiceProvider registers shared auth actions against auth.prov
|
|
|
206
207
|
]
|
|
207
208
|
);
|
|
208
209
|
});
|
|
210
|
+
|
|
211
|
+
test("AuthActionsServiceProvider leaves unrelated actions usable when no auth provider is selected", async () => {
|
|
212
|
+
const app = createApplication();
|
|
213
|
+
|
|
214
|
+
class PublicActionProvider {
|
|
215
|
+
static id = "public.actions";
|
|
216
|
+
|
|
217
|
+
static dependsOn = ["runtime.actions"];
|
|
218
|
+
|
|
219
|
+
register(targetApp) {
|
|
220
|
+
targetApp.action({
|
|
221
|
+
id: "public.ping",
|
|
222
|
+
domain: "public",
|
|
223
|
+
version: 1,
|
|
224
|
+
kind: "query",
|
|
225
|
+
channels: ["internal"],
|
|
226
|
+
surfaces: ["home"],
|
|
227
|
+
permission: { require: "none" },
|
|
228
|
+
input: {
|
|
229
|
+
schema: createSchema({}),
|
|
230
|
+
mode: "patch"
|
|
231
|
+
},
|
|
232
|
+
output: null,
|
|
233
|
+
idempotency: "none",
|
|
234
|
+
audit: { actionName: "public.ping" },
|
|
235
|
+
observability: {},
|
|
236
|
+
async execute() {
|
|
237
|
+
return { ok: true };
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
app.instance("appConfig", createAppConfigFixture());
|
|
244
|
+
|
|
245
|
+
await app.start({
|
|
246
|
+
providers: [ActionRuntimeServiceProvider, AuthActionsServiceProvider, PublicActionProvider]
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const actionExecutor = app.make("actionExecutor");
|
|
250
|
+
assert.equal(
|
|
251
|
+
actionExecutor.listDefinitions().some((definition) => definition.id.startsWith("auth.")),
|
|
252
|
+
false
|
|
253
|
+
);
|
|
254
|
+
assert.deepEqual(
|
|
255
|
+
await actionExecutor.execute({
|
|
256
|
+
actionId: "public.ping",
|
|
257
|
+
input: {},
|
|
258
|
+
context: {
|
|
259
|
+
channel: "internal",
|
|
260
|
+
surface: "home"
|
|
261
|
+
}
|
|
262
|
+
}),
|
|
263
|
+
{ ok: true }
|
|
264
|
+
);
|
|
265
|
+
});
|