Download wp-calypso/client/me/security-ssh-key/use-ssh-key-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 793 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/me/security-ssh-key/use-ssh-key-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/me/security-ssh-key/use-ssh-key-query.ts
-
curl -L -o use-ssh-key-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/me/security-ssh-key/use-ssh-key-query.ts
793 Bytes
| import { useQuery } from '@tanstack/react-query'; | |
| import wp from 'calypso/lib/wp'; | |
| /** | |
| * List of allowed SSH key formats. | |
| * | |
| * We need to keep it in sync with \Openssh_Authorized_Key::VALID_TYPES_AND_BITS from WPCOM. | |
| */ | |
| export const SSH_KEY_FORMATS = [ | |
| 'ssh-rsa', | |
| 'ssh-ed25519', | |
| 'ecdsa-sha2-nistp256', | |
| 'ecdsa-sha2-nistp384', | |
| 'ecdsa-sha2-nistp521', | |
| ] as const; | |
| export interface SSHKeyData { | |
| name: string; | |
| key: string; | |
| type: ( typeof SSH_KEY_FORMATS )[ number ]; | |
| sha256: string; | |
| created_at: string; | |
| } | |
| export const SSH_KEY_QUERY_KEY = [ 'me', 'ssh-keys' ]; | |
| export const useSSHKeyQuery = () => | |
| useQuery( { | |
| queryKey: SSH_KEY_QUERY_KEY, | |
| queryFn: (): SSHKeyData[] => | |
| wp.req.get( '/me/ssh-keys', { | |
| apiNamespace: 'wpcom/v2', | |
| } ), | |
| meta: { | |
| persist: false, | |
| }, | |
| } ); | |