@serve.zone/dcrouter 10.0.0 → 10.1.0

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.
@@ -1115,6 +1115,18 @@ export async function createApiToken(name: string, scopes: interfaces.data.TApiT
1115
1115
  });
1116
1116
  }
1117
1117
 
1118
+ export async function rollApiToken(id: string) {
1119
+ const context = getActionContext();
1120
+ const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
1121
+ interfaces.requests.IReq_RollApiToken
1122
+ >('/typedrequest', 'rollApiToken');
1123
+
1124
+ return request.fire({
1125
+ identity: context.identity,
1126
+ id,
1127
+ });
1128
+ }
1129
+
1118
1130
  export const revokeApiTokenAction = routeManagementStatePart.createAction<string>(
1119
1131
  async (statePartArg, tokenId) => {
1120
1132
  const context = getActionContext();
@@ -152,6 +152,15 @@ export class OpsViewApiTokens extends DeesElement {
152
152
  );
153
153
  },
154
154
  },
155
+ {
156
+ name: 'Roll',
157
+ iconName: 'lucide:refresh-cw',
158
+ type: ['inRow', 'contextmenu'] as any,
159
+ actionFunc: async (actionData: any) => {
160
+ const token = actionData.item as interfaces.data.IApiTokenInfo;
161
+ await this.showRollTokenDialog(token);
162
+ },
163
+ },
155
164
  {
156
165
  name: 'Revoke',
157
166
  iconName: 'lucide:trash2',
@@ -279,6 +288,60 @@ export class OpsViewApiTokens extends DeesElement {
279
288
  });
280
289
  }
281
290
 
291
+ private async showRollTokenDialog(token: interfaces.data.IApiTokenInfo) {
292
+ const { DeesModal } = await import('@design.estate/dees-catalog');
293
+
294
+ await DeesModal.createAndShow({
295
+ heading: 'Roll Token Secret',
296
+ content: html`
297
+ <div style="color: #ccc; padding: 8px 0;">
298
+ <p>This will regenerate the secret for <strong>${token.name}</strong>. The old token value will stop working immediately.</p>
299
+ </div>
300
+ `,
301
+ menuOptions: [
302
+ {
303
+ name: 'Cancel',
304
+ iconName: 'lucide:x',
305
+ action: async (modalArg: any) => await modalArg.destroy(),
306
+ },
307
+ {
308
+ name: 'Roll Token',
309
+ iconName: 'lucide:refresh-cw',
310
+ action: async (modalArg: any) => {
311
+ await modalArg.destroy();
312
+ try {
313
+ const response = await appstate.rollApiToken(token.id);
314
+ if (response.success && response.tokenValue) {
315
+ await appstate.routeManagementStatePart.dispatchAction(appstate.fetchApiTokensAction, null);
316
+
317
+ await DeesModal.createAndShow({
318
+ heading: 'Token Rolled',
319
+ content: html`
320
+ <div style="color: #ccc; padding: 8px 0;">
321
+ <p>Copy this token now. It will not be shown again.</p>
322
+ <div style="background: #111; padding: 12px; border-radius: 6px; margin-top: 8px;">
323
+ <code style="color: #0f8; word-break: break-all; font-size: 13px;">${response.tokenValue}</code>
324
+ </div>
325
+ </div>
326
+ `,
327
+ menuOptions: [
328
+ {
329
+ name: 'Done',
330
+ iconName: 'lucide:check',
331
+ action: async (m: any) => await m.destroy(),
332
+ },
333
+ ],
334
+ });
335
+ }
336
+ } catch (error) {
337
+ console.error('Failed to roll token:', error);
338
+ }
339
+ },
340
+ },
341
+ ],
342
+ });
343
+ }
344
+
282
345
  async firstUpdated() {
283
346
  await appstate.routeManagementStatePart.dispatchAction(appstate.fetchApiTokensAction, null);
284
347
  }