• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperledger-identus / sdk-ts / 14494365886

16 Apr 2025 01:48PM UTC coverage: 74.812% (-0.7%) from 75.544%
14494365886

Pull #415

github

web-flow
Merge 7dc0c3267 into 0bddae204
Pull Request #415: feat: OIDC moving to plugin

1418 of 2086 branches covered (67.98%)

Branch coverage included in aggregate %.

80 of 211 new or added lines in 19 files covered. (37.91%)

15 existing lines in 3 files now uncovered.

3367 of 4310 relevant lines covered (78.12%)

52.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/plugins/internal/oidc/tasks/FetchAuthServerMeta.ts
1
import { AuthServerMetadata } from "../types";
2
import { Context } from "../plugin";
3
import * as Domain from "../../../../domain";
4
import * as Utils from "../../../../utils";
5

6
interface Args {
7
  serverUri: string | URL,
8
  algorithm?: string;
9
}
10

11
/**
12
 * try to retrieve Authorization Server Metadata from the give URI
13
 * `/.well-known/openid-configuration` will be appended to the URI
14
 * 
15
 * @param uri 
16
 * @returns {Promise<AuthServerMetadata>}
17
 */
18
export class FetchAuthServerMeta extends Utils.Task<Domain.ApiResponse<AuthServerMetadata>, Args> {
19
  async run(ctx: Context) {
20
    const serverUrl = new URL(this.args.serverUri);
×
21
    const url = new URL(serverUrl);
×
22

23
    if (url.protocol !== 'https:' && url.protocol !== 'http:') {
×
24
      throw new Error('"issuer.protocol" must be "https:" or "http:"');
×
25
    }
26

27
    switch (this.args.algorithm) {
×
28
      case undefined:
29
      case 'oidc':
30
        url.pathname = `${url.pathname}/.well-known/openid-configuration`.replace('//', '/');
×
31
        break;
×
32
      case 'oauth2': {
33
        const trail = url.pathname === '/' ? '' : `/${url.pathname}`;
×
34
        url.pathname = `.well-known/oauth-authorization-server${trail}`.replace('//', '/');
×
35
        break;
×
36
      }
37
      default:
38
        throw new Error('"options.algorithm" must be "oidc" (default), or "oauth2"');
×
39
    }
40

41
    const headers = new Headers();
×
42
    headers.set('accept', 'application/json');
×
43

44
    const response = await ctx.Api.request("GET", url.href, undefined, new Map(headers));
×
45

46
    if (response.status !== 200) {
×
47
      throw new Error('"response" is not a conform Authorization Server Metadata response');
×
48
    }
49

50
    this.validate(response);
×
51

52
    return response;
×
53
  }
54

55
  private validate(response: Domain.ApiResponse): asserts response is Domain.ApiResponse<AuthServerMetadata> {
NEW
56
    Utils.validate(response.body, AuthServerMetadata);
×
57
  }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc