Skip to content

Commit

Permalink
fix: Merge types
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed Nov 9, 2021
1 parent 2902f8a commit 810cc29
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion specs/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getIntegrationToken,
authorizeWebapp,
clientCredentials,
} from '../lib/esm'
} from '../src'

const S_CREDENTIALS = {
clientId: process.env.SALES_CHANNEL_ID,
Expand Down
6 changes: 3 additions & 3 deletions src/clientCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
ClientId,
ClientSecret,
Endpoint,
} from '#typings'
} from './typings'

export type Credentials = {
export type ClientCredentials = {
clientId: ClientId
endpoint: Endpoint
} & (
Expand All @@ -21,7 +21,7 @@ export type Credentials = {
}
)

export default async function ClientCredentials(args: Credentials) {
export default async function clientCredentials(args: ClientCredentials) {
const { scope, endpoint, clientSecret = '', ...obj } = args
const credentials: AuthConfig = {
...obj,
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import salesChannel, { GetCustomerToken, User } from './salesChannel'
import integration from './integration'
import webapp, { GetWebappToken } from './webapp'
import clientCredentials, { Credentials } from './clientCredentials'
import clientCredentials, { ClientCredentials } from './clientCredentials'
import { AuthReturnType, AuthScope } from './typings'

const getSalesChannelToken = salesChannel
Expand All @@ -17,7 +17,7 @@ export {
getIntegrationToken,
getSalesChannelToken,
getWebappToken,
Credentials,
ClientCredentials,
User,
AuthReturnType,
AuthScope,
Expand Down
15 changes: 2 additions & 13 deletions src/salesChannel.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import authenticate from './authenticate'
import {
ClientId,
Endpoint,
AuthReturnType,
AuthConfig,
AuthScope,
} from './typings'
import { ClientCredentials } from './clientCredentials'
import { AuthReturnType, AuthConfig } from './typings'

export interface User {
username: string
password: string
}

export interface ClientCredentials {
clientId: ClientId
endpoint: Endpoint
scope: AuthScope
}

export type GetCustomerToken = (
clientCredential: ClientCredentials,
user: User
Expand Down

0 comments on commit 810cc29

Please sign in to comment.