"Fossies" - the Fresh Open Source Software Archive 
Member "cli-1.1260.0/src/cli/commands/auth/is-authed.ts" (4 Dec 2023, 666 Bytes) of package /linux/misc/snyk-cli-1.1260.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 import * as snyk from '../../../lib';
2 import config from '../../../lib/config';
3 import { makeRequest } from '../../../lib/request';
4
5 export function isAuthed() {
6 const token = snyk.config.get('api');
7 return verifyAPI(token).then((res: any) => {
8 return res.body.ok;
9 });
10 }
11
12 export function verifyAPI(api) {
13 const payload = {
14 body: {
15 api,
16 },
17 method: 'POST',
18 url: config.API + '/verify/token',
19 json: true,
20 };
21
22 return new Promise((resolve, reject) => {
23 makeRequest(payload, (error, res, body) => {
24 if (error) {
25 return reject(error);
26 }
27
28 resolve({
29 res,
30 body,
31 });
32 });
33 });
34 }