Skip to content

Commit

Permalink
removed idtoken function
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnichase committed Jul 7, 2024
1 parent 050d111 commit 0406e93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions packages/got-api/client-js/next/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { useSrp } from '@gothub-team/got-srp';
import {
createLowApi,
type CreateLowApiOtions,
type GotLowApi,
type InviteUserInput,
type LoginVerifyOutput,
} from '../api.js';
import { createLowApi, type GotLowApi, type InviteUserInput, type LoginVerifyOutput } from '../api.js';
import { post, put } from '../fetch.js';
import type { PushBody, PushResult } from '@gothub/got-core';

Expand Down Expand Up @@ -139,24 +133,23 @@ export type CreateApiOptions = {
*/
adminMode?: boolean;
/**
* Function to get the ID token which is used with all API requests that require authentication.
* Id token that is used to execute authenticated API calls.
*/
getIdToken: CreateLowApiOtions['getIdToken'];
idToken?: string;
};
export const createApi = ({ host, adminMode = false, getIdToken }: CreateApiOptions): GotApi => {
export const createApi = ({ host, adminMode = false, idToken }: CreateApiOptions): GotApi => {
if (!host) throw new Error('Provide host argument to create API.');
const _host = host.endsWith('/') ? host.substring(0, host.length - 1) : host;

const api = createLowApi({
host: _host,
getIdToken,
getIdToken: async () => idToken,
getAdminMode: () => adminMode,
});

return {
...api,
push: async (body: PushBody, asRole?: string) =>
post(`${host}/push`, body, await getIdToken(), adminMode, asRole),
push: async (body: PushBody, asRole?: string) => post(`${host}/push`, body, idToken, adminMode, asRole),
login: async ({ email, password }: LoginInput) => {
const { srpA, getSignature } = await useSrp();

Expand Down
2 changes: 1 addition & 1 deletion packages/got-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gothub/got-api",
"version": "0.0.14",
"version": "0.0.15",
"license": "MIT",
"type": "module",
"types": "dist/module/index.d.ts",
Expand Down

0 comments on commit 0406e93

Please sign in to comment.