Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ On the other hand OpenSDKs is most valuable when you are working with multiple 3
Or use this single command

```
cp -r ../repo/kits/sdk/openapi.json sdks/sdk-openint/openint.oas.json && \
SDK=sdk-openint && \
turbo run build --filter 'cli' && \
turbo run download --filter $SDK && \
turbo run generate --filter $SDK && \
turbo run build --filter $SDK
```
Expand Down
9 changes: 4 additions & 5 deletions packages/fetch-links/links/authLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ import {openIntProxyLink, OpenIntProxyLinkOptions} from './openIntProxyLink.js'
import {mergeHeaders, modifyRequest} from '../modifyRequestResponse.js'
import type {Link} from '../link.js'

export type ClientAuthOptions =
export type ClientAuthOptions = Partial<NonDiscriminatedUnion<
| {openInt: OpenIntProxyLinkOptions}
/** to be passed as Authorization header as a bearer token, Should handle automatic refreshing */
| {oauth: {accessToken: string; refreshToken?: string; expiresAt?: number}}
| {basic: {username: string; password: string}}
/** non oauth / directly specifying bearer token */
| {bearer: string}
| {bearer: string}>>

type Indexify<T> = T & Record<string, undefined>
type AllUnionKeys<T> = keyof UnionToIntersection<{[K in keyof T]: undefined}>
type NonDiscriminatedUnion<T> = {
[K in AllUnionKeys<T> & string]: Indexify<T>[K]
}

export function authLink(_auth: ClientAuthOptions, baseUrl: string): Link {
if (!_auth) {
export function authLink(auth: ClientAuthOptions, baseUrl: string): Link {
if (!auth) {
// No Op
return (req, next) => next(req)
}
const auth = _auth as NonDiscriminatedUnion<ClientAuthOptions>

if (auth.openInt) {
return openIntProxyLink(auth.openInt, baseUrl)
Expand Down
122 changes: 108 additions & 14 deletions sdks/sdk-openint/openint.oas.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading