mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-15 20:27:15 +02:00
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
import type { Context } from "@yaakapp/api";
|
|
import { fetchAccessToken } from "../fetchAccessToken";
|
|
import { getOrRefreshAccessToken } from "../getOrRefreshAccessToken";
|
|
import type { AccessToken, TokenStoreArgs } from "../store";
|
|
import { storeToken } from "../store";
|
|
|
|
export async function getPassword(
|
|
ctx: Context,
|
|
contextId: string,
|
|
{
|
|
accessTokenUrl,
|
|
clientId,
|
|
clientSecret,
|
|
username,
|
|
password,
|
|
credentialsInBody,
|
|
audience,
|
|
scope,
|
|
}: {
|
|
accessTokenUrl: string;
|
|
clientId: string;
|
|
clientSecret: string;
|
|
username: string;
|
|
password: string;
|
|
scope: string | null;
|
|
audience: string | null;
|
|
credentialsInBody: boolean;
|
|
},
|
|
): Promise<AccessToken> {
|
|
const tokenArgs: TokenStoreArgs = {
|
|
contextId,
|
|
clientId,
|
|
accessTokenUrl,
|
|
authorizationUrl: null,
|
|
};
|
|
const token = await getOrRefreshAccessToken(ctx, tokenArgs, {
|
|
accessTokenUrl,
|
|
scope,
|
|
clientId,
|
|
clientSecret,
|
|
credentialsInBody,
|
|
});
|
|
if (token != null) {
|
|
return token;
|
|
}
|
|
|
|
const response = await fetchAccessToken(ctx, {
|
|
accessTokenUrl,
|
|
clientId,
|
|
clientSecret,
|
|
scope,
|
|
audience,
|
|
grantType: "password",
|
|
credentialsInBody,
|
|
params: [
|
|
{ name: "username", value: username },
|
|
{ name: "password", value: password },
|
|
],
|
|
});
|
|
|
|
return storeToken(ctx, tokenArgs, response);
|
|
}
|