@jskit-ai/users-core 0.1.146 → 0.1.147

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.
@@ -1,7 +1,7 @@
1
1
  export default Object.freeze({
2
2
  packageVersion: 1,
3
3
  packageId: "@jskit-ai/users-core",
4
- version: "0.1.146",
4
+ version: "0.1.147",
5
5
  kind: "runtime",
6
6
  description: "Users/account runtime plus HTTP routes for account features.",
7
7
  dependsOn: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/users-core",
3
- "version": "0.1.146",
3
+ "version": "0.1.147",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -135,7 +135,7 @@ function bootAccountProfileRoutes(app) {
135
135
  stream: filePart.stream,
136
136
  mimeType: filePart.mimeType,
137
137
  fileName: filePart.fileName,
138
- uploadDimension
138
+ ...(uploadDimension !== undefined ? { uploadDimension } : {})
139
139
  }
140
140
  });
141
141
 
@@ -116,11 +116,12 @@ function bootAccountSecurityRoutes(app) {
116
116
  }
117
117
  },
118
118
  async function (request, reply) {
119
+ const query = request.input.query || {};
119
120
  const result = await request.executeAction({
120
121
  actionId: "settings.security.oauth.link.start",
121
122
  input: {
122
123
  provider: request.input.params.provider,
123
- returnTo: request.input.query.returnTo
124
+ ...(Object.hasOwn(query, "returnTo") ? { returnTo: query.returnTo } : {})
124
125
  }
125
126
  });
126
127
 
@@ -228,6 +228,54 @@ test("account route handlers build action input from request.input", async () =>
228
228
  assert.equal(calls[7].actionId, "settings.security.sessions.logout_others");
229
229
  });
230
230
 
231
+ test("account route handlers preserve omitted optional action fields", async () => {
232
+ const routes = await registerRoutes();
233
+ const calls = [];
234
+ const executeAction = async (payload) => {
235
+ calls.push(payload);
236
+ if (payload.actionId === "settings.security.oauth.link.start") {
237
+ return { url: "/oauth/link" };
238
+ }
239
+ return {};
240
+ };
241
+
242
+ await findRoute(routes, { method: "GET", path: "/api/settings/security/oauth/:provider/start" }).handler(
243
+ createActionRequest({
244
+ input: {
245
+ params: { provider: "github" },
246
+ query: {}
247
+ },
248
+ executeAction
249
+ }),
250
+ createReplyDouble()
251
+ );
252
+
253
+ const avatarStream = {};
254
+ await findRoute(routes, { method: "POST", path: "/api/settings/profile/avatar" }).handler(
255
+ createActionRequest({
256
+ file: async () => ({
257
+ fieldname: "avatar",
258
+ filename: "avatar.png",
259
+ mimetype: "image/png",
260
+ encoding: "7bit",
261
+ file: avatarStream,
262
+ fields: {}
263
+ }),
264
+ executeAction
265
+ }),
266
+ createReplyDouble()
267
+ );
268
+
269
+ assert.deepEqual(calls[0].input, { provider: "github" });
270
+ assert.equal(Object.hasOwn(calls[0].input, "returnTo"), false);
271
+ assert.deepEqual(calls[1].input, {
272
+ stream: avatarStream,
273
+ mimeType: "image/png",
274
+ fileName: "avatar.png"
275
+ });
276
+ assert.equal(Object.hasOwn(calls[1].input, "uploadDimension"), false);
277
+ });
278
+
231
279
  test("account settings jsonapi transport resolves response resource id from request user", async () => {
232
280
  const routes = await registerRoutes();
233
281
  const settingsRoute = findRoute(routes, { method: "GET", path: "/api/settings" });