Skip to content

Commit

Permalink
fix(oidc-provider): export Client and RefreshToken type
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Aug 29, 2022
1 parent 223cd74 commit b0b4360
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,27 @@ jobs:
publish-docs:
runs-on: ubuntu-latest
needs: deploy-packages
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
node-version: [16.x]
steps:
- run: gh workflow run website.yml --ref $GITHUB_REF_NAME
- uses: actions/checkout@v2
with:
ref: "production"
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install --frozen-lockfile --network-timeout 500000
- name: Build pages
env:
CI: true
run: yarn api:build && yarn vuepress:docs:build
- name: Publish pages
env:
CI: true
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn docs:publish
17 changes: 10 additions & 7 deletions docs/tutorials/oidc.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ Some part of the OIDC provider configuration needs function to work. And ideally
It's possible to do that by listening the `$alterOidcConfiguration` hook and inject the expected functions in the configuration:

```typescript
import {Module} from "@tsed/oidc-provider";
import {OidcSettings, OidcProviderContext} from "@tsed/oidc-provider";
import {set} from "lodash";
import {PlatformContext} from "@tsed/common";
import {InjectContext, Module} from "@tsed/di";
import {AuthorizationCode, BackchannelAuthenticationRequest, DeviceCode, RefreshToken, Client, OidcSettings} from "@tsed/oidc-provider";
import {KoaContextWithOIDC, Provider, ResourceServer} from "oidc-provider";

@Module()
class OidcResourceIndicatorsModule {
Expand All @@ -363,7 +364,7 @@ class OidcResourceIndicatorsModule {

async $alterOidcConfiguration(config: OidcSettings): Promise<OidcSettings> {
// example with the
config.features.resourceIndicators = {
config.features!.resourceIndicators = {
enabled: true,
defaultResource: this.defaultResource.bind(this),
getResourceServerInfo: this.getResourceServerInfo.bind(this),
Expand All @@ -373,18 +374,20 @@ class OidcResourceIndicatorsModule {
return config;
}

protected async defaultResource(ctx: KoaContextWithOIDC) {
protected async defaultResource(ctx: KoaContextWithOIDC): Promise<string | string[]> {
///
return "https://mydomain.com";
}

protected async getResourceServerInfo(ctx: KoaContextWithOIDC, resourceIndicator: string, client: Client): Promise<string | string[]> {
protected async getResourceServerInfo(ctx: KoaContextWithOIDC, resourceIndicator: string, client: Client): Promise<ResourceServer> {
///
return {};
}

protected async useGrantedResource(
ctx: KoaContextWithOIDC,
model: AuthorizationCode | RefreshToken | DeviceCode | BackchannelAuthenticationRequest
): Promise<Boolean> {
): Promise<boolean> {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {Provider, Account} from "oidc-provider";
export type AuthorizationCode = InstanceType<Provider["AuthorizationCode"]>;
export type AccessToken = InstanceType<Provider["AccessToken"]>;
export type DeviceCode = InstanceType<Provider["DeviceCode"]>;
export type RefreshToken = InstanceType<Provider["RefreshToken"]>;
export type Client = InstanceType<Provider["Client"]>;
export type BackchannelAuthenticationRequest = InstanceType<Provider["BackchannelAuthenticationRequest"]>;

export interface OidcAccountsMethods {
Expand Down

0 comments on commit b0b4360

Please sign in to comment.