Continue frontend building
This commit is contained in:
16
packages/sshecret-frontend/src/api/password.ts
Normal file
16
packages/sshecret-frontend/src/api/password.ts
Normal file
@ -0,0 +1,16 @@
|
||||
export function generateRandomPassword(length: number = 16): string {
|
||||
const lower = 'abcdefghijklmnopqrstuvwxyz'
|
||||
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
const numbers = '0123456789'
|
||||
const special = '!@#$%^&*()-_=+[]{};:,.<>?'
|
||||
|
||||
const allChars = lower + upper + numbers + special
|
||||
|
||||
let password = ''
|
||||
for (let i = 0; i < length; i++) {
|
||||
const index = Math.floor(Math.random() * allChars.length)
|
||||
password += allChars[index]
|
||||
}
|
||||
|
||||
return password
|
||||
}
|
||||
13
packages/sshecret-frontend/src/api/typeguards.ts
Normal file
13
packages/sshecret-frontend/src/api/typeguards.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// Typeguards
|
||||
|
||||
import { OPERATIONS } from '@/api/types'
|
||||
import { SUBSYSTEM } from '@/api/types'
|
||||
import type { Operation, SubSystem } from '@/client'
|
||||
|
||||
export function isOperation(value: string): value is Operation {
|
||||
return (OPERATIONS as readonly string[]).includes(value)
|
||||
}
|
||||
|
||||
export function isSubSystem(value: string): value is SubSystem {
|
||||
return (SUBSYSTEM as readonly string[]).includes(value)
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
import type { SubSystem, Operation } from "@/client";
|
||||
export type PageRequest = {
|
||||
offset: number;
|
||||
limit: number;
|
||||
@ -6,9 +7,67 @@ export type PageRequest = {
|
||||
export enum SshecretObjectType {
|
||||
Client = "Client",
|
||||
ClientSecret = "ClientSecret",
|
||||
SecretGroup = "SecretGroup",
|
||||
}
|
||||
|
||||
export type SshecretObject = {
|
||||
objectType: SshecretObjectType,
|
||||
id: string,
|
||||
param?: string,
|
||||
}
|
||||
|
||||
export type AuditFilter = {
|
||||
/**
|
||||
* Subsystem
|
||||
*/
|
||||
subsystem?: SubSystem | null;
|
||||
/**
|
||||
* Operation
|
||||
*/
|
||||
operation?: Operation | null;
|
||||
/**
|
||||
* Client Id
|
||||
*/
|
||||
client_id?: string | null;
|
||||
/**
|
||||
* Client Name
|
||||
*/
|
||||
client_name?: string | null;
|
||||
/**
|
||||
* Secret Id
|
||||
*/
|
||||
secret_id?: string | null;
|
||||
/**
|
||||
* Secret Name
|
||||
*/
|
||||
secret_name?: string | null;
|
||||
/**
|
||||
* Origin
|
||||
*/
|
||||
origin?: string | null;
|
||||
/**
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* Limit
|
||||
*/
|
||||
limit?: number;
|
||||
|
||||
}
|
||||
|
||||
export const OPERATIONS = [
|
||||
'create',
|
||||
'read',
|
||||
'update',
|
||||
'delete',
|
||||
'deny',
|
||||
'permit',
|
||||
'login',
|
||||
'none',
|
||||
] as const
|
||||
|
||||
export const SUBSYSTEM = [
|
||||
'admin',
|
||||
'sshd',
|
||||
'backend',
|
||||
] as const
|
||||
|
||||
Reference in New Issue
Block a user