Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions test/typescript-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@

import { createAppAuth } from "../src";

function expectType<T>(what: T) {}

const auth = createAppAuth({
appId: 1,
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
clientId: "lv1.1234567890abcdef",
clientSecret: "1234567890abcdef12341234567890abcdef1234",
});

export async function readmeExample() {
const auth = createAppAuth({
appId: 1,
privateKey: "-----BEGIN PRIVATE KEY-----\n...",
clientId: "lv1.1234567890abcdef",
clientSecret: "1234567890abcdef12341234567890abcdef1234",
});
// Retrieve an oauth-access token
const userAuthentication = await auth({ type: "oauth-user", code: "123456" });

expectType<"token">(userAuthentication.type);
}

export async function issue268() {
// Retrieve an oauth-access token
await auth({ type: "oauth-user", code: "123456" });
const userAuthentication = await auth({ type: "installation" });

expectType<"token">(userAuthentication.type);
expectType<"tokenType">(userAuthentication.tokenType);
}