trustflows-client 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from './auth';
2
+ export * from './types';
3
+ export * from './utils';
4
+ export * from './uma/claims/accessToken';
5
+ export * from './uma/claims/idToken';
6
+ export * from './uma/claims/registry';
7
+ export * from './uma/claims/types';
8
+ export * from './uma/types';
9
+ export * from './uma/utils';
@@ -0,0 +1,39 @@
1
+ export type JsonObject = Record<string, unknown>;
2
+ /**
3
+ * The dereferencable identifier of a client, which is also the URL where the client's metadata document is served.
4
+ */
5
+ export interface ClientMetadata extends JsonObject {
6
+ /**
7
+ * Client identifier URL.
8
+ */
9
+ client_id: string;
10
+ /**
11
+ * Redirect URIs for redirect-based flows.
12
+ */
13
+ redirect_uris?: string[];
14
+ /**
15
+ * JWK Set (inline).
16
+ */
17
+ jwks?: {
18
+ keys: Record<string, unknown>[];
19
+ };
20
+ /**
21
+ * URI pointing to the JWK Set.
22
+ */
23
+ jwks_uri?: string;
24
+ /**
25
+ * Authentication method at the token endpoint.
26
+ * REQUIRED for confidential clients and MUST be "private_key_jwt".
27
+ */
28
+ token_endpoint_auth_method?: 'private_key_jwt';
29
+ /**
30
+ * Declares UMA / A4DS profiles supported by the client.
31
+ */
32
+ uma_profiles_supported?: string[];
33
+ /**
34
+ * Indicates the client can act as an automated requesting party
35
+ * (e.g., Aggregator-style non-interactive access).
36
+ */
37
+ automated?: boolean;
38
+ }
39
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;KACjC,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,0BAA0B,CAAC,EAAE,iBAAiB,CAAC;IAE/C;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAElC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ ;
2
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { Auth } from '../../auth';
2
+ import type { Claim } from '../types';
3
+ import type { ClaimResolverDefinition, RequiredClaims } from './types';
4
+ export declare const ACCESS_TOKEN_CLAIM_FORMAT = "urn:ietf:params:oauth:token-type:access_token";
5
+ export declare const ACCESS_TOKEN_CLAIM_TYPE = "https://spec.knows.idlab.ugent.be/aggregator-protocol/latest/#derivation-access";
6
+ export declare function accessTokenClaimResolver(required: RequiredClaims, auth: Auth): Promise<Claim | undefined>;
7
+ export declare const accessTokenClaimResolvers: ClaimResolverDefinition[];
8
+ //# sourceMappingURL=accessToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessToken.d.ts","sourceRoot":"","sources":["../../../src/uma/claims/accessToken.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,yBAAyB,kDACW,CAAC;AAClD,eAAO,MAAM,uBAAuB,oFAC+C,CAAC;AAkBpF,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAiB5B;AAED,eAAO,MAAM,yBAAyB,EAAE,uBAAuB,EAU9D,CAAC"}
@@ -0,0 +1,42 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { fetchAccessToken } from '../utils';
3
+ export const ACCESS_TOKEN_CLAIM_FORMAT = 'urn:ietf:params:oauth:token-type:access_token';
4
+ export const ACCESS_TOKEN_CLAIM_TYPE = 'https://spec.knows.idlab.ugent.be/aggregator-protocol/latest/#derivation-access';
5
+ function pickSingle(value, field) {
6
+ if (!value) {
7
+ return undefined;
8
+ }
9
+ if (!Array.isArray(value)) {
10
+ return value;
11
+ }
12
+ if (value.length === 1) {
13
+ return value[0];
14
+ }
15
+ throw new Error(`UMA claim field "${field}" must be a single value.`);
16
+ }
17
+ export async function accessTokenClaimResolver(required, auth) {
18
+ const issuer = pickSingle(required.issuer, 'issuer');
19
+ const resourceId = required.name ?? pickSingle(required.claim_type, 'claim_type');
20
+ if (!issuer || !resourceId) {
21
+ throw new Error('UMA access_token claim requires issuer and resource identifier.');
22
+ }
23
+ const endpoint = `${issuer.replace(/\/$/u, '')}/token`;
24
+ const tokenResult = await fetchAccessToken(auth, endpoint, [
25
+ { resource_id: resourceId },
26
+ ]);
27
+ return {
28
+ claim_token: tokenResult.access_token,
29
+ claim_token_format: ACCESS_TOKEN_CLAIM_FORMAT,
30
+ };
31
+ }
32
+ export const accessTokenClaimResolvers = [
33
+ {
34
+ id: 'access-token',
35
+ match: [
36
+ { claim_token_format: ACCESS_TOKEN_CLAIM_FORMAT },
37
+ { claim_type: ACCESS_TOKEN_CLAIM_FORMAT },
38
+ { claim_type: ACCESS_TOKEN_CLAIM_TYPE },
39
+ ],
40
+ resolve: accessTokenClaimResolver,
41
+ },
42
+ ];
@@ -0,0 +1,8 @@
1
+ import type { Auth } from '../../auth';
2
+ import type { Claim } from '../types';
3
+ import type { ClaimResolverDefinition, RequiredClaims } from './types';
4
+ export declare const ID_TOKEN_CLAIM_FORMAT = "http://openid.net/specs/openid-connect-core-1_0.html#IDToken";
5
+ export declare const ID_TOKEN_CLAIM_FORMAT_URN = "urn:ietf:params:oauth:token-type:id_token";
6
+ export declare function idTokenClaimResolver(required: RequiredClaims, auth: Auth): Promise<Claim | undefined>;
7
+ export declare const idTokenClaimResolvers: ClaimResolverDefinition[];
8
+ //# sourceMappingURL=idToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idToken.d.ts","sourceRoot":"","sources":["../../../src/uma/claims/idToken.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,qBAAqB,iEAC8B,CAAC;AACjE,eAAO,MAAM,yBAAyB,8CACO,CAAC;AAE9C,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAM5B;AAED,eAAO,MAAM,qBAAqB,EAAE,uBAAuB,EAW1D,CAAC"}
@@ -0,0 +1,21 @@
1
+ export const ID_TOKEN_CLAIM_FORMAT = 'http://openid.net/specs/openid-connect-core-1_0.html#IDToken';
2
+ export const ID_TOKEN_CLAIM_FORMAT_URN = 'urn:ietf:params:oauth:token-type:id_token';
3
+ export async function idTokenClaimResolver(required, auth) {
4
+ void required;
5
+ return {
6
+ claim_token: await auth.createClaimToken(),
7
+ claim_token_format: ID_TOKEN_CLAIM_FORMAT,
8
+ };
9
+ }
10
+ export const idTokenClaimResolvers = [
11
+ {
12
+ id: 'id-token',
13
+ match: [
14
+ {
15
+ claim_token_format: [ID_TOKEN_CLAIM_FORMAT, ID_TOKEN_CLAIM_FORMAT_URN],
16
+ },
17
+ { claim_type: [ID_TOKEN_CLAIM_FORMAT, ID_TOKEN_CLAIM_FORMAT_URN] },
18
+ ],
19
+ resolve: idTokenClaimResolver,
20
+ },
21
+ ];
@@ -0,0 +1,7 @@
1
+ import type { Claim } from '../types';
2
+ import type { Auth } from '../../auth';
3
+ import type { ClaimResolverDefinition, ClaimResolverRegistry, RequiredClaims } from './types';
4
+ export declare function createDefaultClaimResolvers(): ClaimResolverRegistry;
5
+ export declare function resolveClaimResolver(requiredClaim: RequiredClaims, resolvers: ClaimResolverRegistry): ClaimResolverDefinition | undefined;
6
+ export declare function gatherClaims(existing: Claim[], requiredClaims: RequiredClaims[] | undefined, auth: Auth, resolvers: ClaimResolverRegistry): Promise<Claim[]>;
7
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/uma/claims/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAIV,uBAAuB,EAEvB,qBAAqB,EACrB,cAAc,EACf,MAAM,SAAS,CAAC;AAIjB,wBAAgB,2BAA2B,IAAI,qBAAqB,CAEnE;AA0DD,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,cAAc,EAC7B,SAAS,EAAE,qBAAqB,GAC/B,uBAAuB,GAAG,SAAS,CA0BrC;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,KAAK,EAAE,EACjB,cAAc,EAAE,cAAc,EAAE,GAAG,SAAS,EAC5C,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,qBAAqB,GAC/B,OAAO,CAAC,KAAK,EAAE,CAAC,CAqBlB"}
@@ -0,0 +1,82 @@
1
+ import { accessTokenClaimResolvers } from './accessToken';
2
+ import { idTokenClaimResolvers } from './idToken';
3
+ export function createDefaultClaimResolvers() {
4
+ return [...idTokenClaimResolvers, ...accessTokenClaimResolvers];
5
+ }
6
+ function matchesField(value, matcher) {
7
+ if (!value) {
8
+ return false;
9
+ }
10
+ const values = Array.isArray(value) ? value : [value];
11
+ const matchers = Array.isArray(matcher) ? matcher : [matcher];
12
+ return matchers.some((match) => values.includes(match));
13
+ }
14
+ function evaluateMatcher(claim, matcher) {
15
+ const keys = Object.keys(matcher);
16
+ let specificity = 0;
17
+ for (const key of keys) {
18
+ const fieldMatcher = matcher[key];
19
+ if (!fieldMatcher) {
20
+ continue;
21
+ }
22
+ specificity += 1;
23
+ const value = claim[key];
24
+ if (!matchesField(value, fieldMatcher)) {
25
+ return { matched: false, specificity };
26
+ }
27
+ }
28
+ return { matched: true, specificity };
29
+ }
30
+ function evaluateMatch(claim, matcher) {
31
+ if (!matcher) {
32
+ return { matched: true, specificity: 0 };
33
+ }
34
+ const matchers = Array.isArray(matcher) ? matcher : [matcher];
35
+ let bestSpecificity = -1;
36
+ for (const entry of matchers) {
37
+ const result = evaluateMatcher(claim, entry);
38
+ if (result.matched && result.specificity > bestSpecificity) {
39
+ bestSpecificity = result.specificity;
40
+ }
41
+ }
42
+ if (bestSpecificity >= 0) {
43
+ return { matched: true, specificity: bestSpecificity };
44
+ }
45
+ return { matched: false, specificity: 0 };
46
+ }
47
+ export function resolveClaimResolver(requiredClaim, resolvers) {
48
+ let best;
49
+ let bestPriority = Number.NEGATIVE_INFINITY;
50
+ let bestSpecificity = -1;
51
+ for (const resolver of resolvers) {
52
+ const { matched, specificity } = evaluateMatch(requiredClaim, resolver.match);
53
+ if (!matched) {
54
+ continue;
55
+ }
56
+ const priority = resolver.priority ?? 0;
57
+ if (priority > bestPriority ||
58
+ (priority === bestPriority && specificity > bestSpecificity)) {
59
+ best = resolver;
60
+ bestPriority = priority;
61
+ bestSpecificity = specificity;
62
+ }
63
+ }
64
+ return best;
65
+ }
66
+ export async function gatherClaims(existing, requiredClaims, auth, resolvers) {
67
+ if (!Array.isArray(requiredClaims) || requiredClaims.length === 0) {
68
+ return existing;
69
+ }
70
+ const claims = [...existing];
71
+ for (const requiredClaim of requiredClaims) {
72
+ const resolver = resolveClaimResolver(requiredClaim, resolvers);
73
+ if (!resolver) {
74
+ throw new Error(`No claim resolver matched required claim: ${JSON.stringify(requiredClaim)}`);
75
+ }
76
+ const claim = await resolver.resolve(requiredClaim, auth);
77
+ if (claim) {
78
+ claims.push(claim);
79
+ }
80
+ }
81
+ return claims;
82
+ }
@@ -0,0 +1,59 @@
1
+ import type { Auth } from '../../auth';
2
+ import type { JsonObject } from '../../types';
3
+ import type { Claim } from '../types';
4
+ /**
5
+ * An UMA Required Claim object.
6
+ */
7
+ export interface RequiredClaims extends JsonObject {
8
+ /**
9
+ * A URI(s) that identifies the claim token format.
10
+ */
11
+ claim_token_format?: string | string[];
12
+ /**
13
+ * A URI(s) that identifies the type of claim.
14
+ */
15
+ claim_type?: string | string[];
16
+ /**
17
+ * The issuer(s) the claim needs to come from.
18
+ */
19
+ issuer?: string | string[];
20
+ /**
21
+ * The name of the claim request.
22
+ */
23
+ name?: string;
24
+ /**
25
+ * A human-friendly name for the claim.
26
+ */
27
+ friendly_name?: string;
28
+ }
29
+ /**
30
+ * Resolves a required claim into a claim token.
31
+ */
32
+ export type ClaimResolver = (required: RequiredClaims, auth: Auth) => Promise<Claim | undefined> | Claim | undefined;
33
+ export type ClaimField = 'claim_token_format' | 'claim_type' | 'issuer' | 'name' | 'friendly_name';
34
+ export type ClaimFieldMatcher = string | string[];
35
+ export type ClaimMatcher = Partial<Record<ClaimField, ClaimFieldMatcher>>;
36
+ export type ClaimResolverMatch = ClaimMatcher | ClaimMatcher[];
37
+ /**
38
+ * A claim resolver definition that can be registered with the registry.
39
+ */
40
+ export interface ClaimResolverDefinition {
41
+ /**
42
+ * Resolver identifier.
43
+ */
44
+ id: string;
45
+ /**
46
+ * Declarative matchers for required claim fields.
47
+ */
48
+ match?: ClaimResolverMatch;
49
+ /**
50
+ * Resolver priority (higher wins).
51
+ */
52
+ priority?: number;
53
+ /**
54
+ * Resolver implementation.
55
+ */
56
+ resolve: ClaimResolver;
57
+ }
58
+ export type ClaimResolverRegistry = ClaimResolverDefinition[];
59
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/uma/claims/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEvC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE/B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,IAAI,KACP,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,KAAK,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACtB,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,eAAe,CAAC;AAClB,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAClD,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAC1E,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,YAAY,EAAE,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,161 @@
1
+ import type { JsonObject } from '../types';
2
+ import type { RequiredClaims } from './claims/types';
3
+ /**
4
+ * The WWW-Authenticate challenge for UMA authorization.
5
+ */
6
+ export interface AuthorizationChallenge extends JsonObject {
7
+ /**
8
+ * The scheme, which is always "UMA".
9
+ */
10
+ scheme: 'UMA';
11
+ /**
12
+ * The authorization server URI.
13
+ */
14
+ as_uri: string;
15
+ /**
16
+ * The ticket issued by the authorization server.
17
+ */
18
+ ticket: string;
19
+ }
20
+ /**
21
+ * The .well-known UMA authorization server metadata.
22
+ */
23
+ export interface AuthorizationServerMetadata extends JsonObject {
24
+ /**
25
+ * The UMA profiles supported by the authorization server.
26
+ */
27
+ uma_profiles_supported: string[];
28
+ /**
29
+ * Whether the authorization server supports client ID metadata documents.
30
+ */
31
+ client_id_metadata_document_supported: true;
32
+ /**
33
+ * The issuer identifier for the authorization server.
34
+ */
35
+ issuer: string;
36
+ /**
37
+ * The resource registration endpoint URL.
38
+ */
39
+ resource_registration_endpoint: string;
40
+ /**
41
+ * The permission endpoint URL.
42
+ */
43
+ permission_endpoint: string;
44
+ /**
45
+ * The token endpoint URL.
46
+ */
47
+ token_endpoint: string;
48
+ /**
49
+ * The introspection endpoint URL.
50
+ */
51
+ introspection_endpoint: string;
52
+ /**
53
+ * The claim interaction endpoint URL.
54
+ */
55
+ claims_interaction_endpoint?: string;
56
+ /**
57
+ * The JWKS URI for the authorization server.
58
+ */
59
+ jwks_uri?: string;
60
+ }
61
+ /**
62
+ * The UMA token request payload.
63
+ */
64
+ export interface TokenRequest extends Claim, JsonObject {
65
+ /**
66
+ * The grant type, which is always "urn:ietf:params:oauth:grant-type:uma-ticket".
67
+ */
68
+ grant_type: 'urn:ietf:params:oauth:grant-type:uma-ticket';
69
+ /**
70
+ * The ticket issued by the authorization server.
71
+ * Either this or permissions must be provided.
72
+ */
73
+ ticket?: string;
74
+ /**
75
+ * The permissions being requested.
76
+ * Either this or ticket must be provided.
77
+ */
78
+ permissions?: PermissionDescription | PermissionDescription[];
79
+ /**
80
+ * An optional global scope.
81
+ */
82
+ scope?: string;
83
+ }
84
+ /**
85
+ * UMA claim.
86
+ */
87
+ export interface Claim {
88
+ /**
89
+ * A claim token to satisfy required claims.
90
+ */
91
+ claim_token?: string;
92
+ /**
93
+ * The format of the claim token.
94
+ */
95
+ claim_token_format?: string;
96
+ }
97
+ /**
98
+ * A UMA permission description.
99
+ */
100
+ export interface PermissionDescription {
101
+ /**
102
+ * The resource ID for the permission.
103
+ */
104
+ resource_id: string;
105
+ /**
106
+ * The scopes associated with the permission.
107
+ */
108
+ resource_scopes?: string[];
109
+ }
110
+ /**
111
+ * A UMA need_info response indicating additional claims are required.
112
+ */
113
+ export interface FailedTokenResponse extends JsonObject {
114
+ /**
115
+ * The error code.
116
+ */
117
+ error: 'need_info';
118
+ /**
119
+ * The error description.
120
+ */
121
+ error_description?: string;
122
+ /**
123
+ * The URI reference of a web page with human-readable information about the error.
124
+ */
125
+ error_uri?: string;
126
+ /**
127
+ * If a state parameter was present in the request that triggered the error.
128
+ */
129
+ state?: string;
130
+ /**
131
+ * The ticket issued by the authorization server.
132
+ */
133
+ ticket?: string;
134
+ /**
135
+ * The required claims to satisfy the authorization request.
136
+ */
137
+ required_claims?: RequiredClaims[];
138
+ /**
139
+ * The URI to redirect the user to for interactive authorization, if applicable.
140
+ */
141
+ redirect_user?: string;
142
+ /**
143
+ * The minimum amount of time in seconds that the client SHOULD wait between polling requests
144
+ */
145
+ interval?: number;
146
+ }
147
+ /**
148
+ * The UMA token response.
149
+ */
150
+ export interface SuccessfulTokenResponse extends JsonObject {
151
+ /**
152
+ * The access token issued by the authorization server.
153
+ */
154
+ access_token: string;
155
+ /**
156
+ * The type of the token, which is typically "Bearer".
157
+ */
158
+ token_type: string;
159
+ }
160
+ export type TokenResponse = SuccessfulTokenResponse | FailedTokenResponse;
161
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/uma/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACxD;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,UAAU;IAC7D;;OAEG;IACH,sBAAsB,EAAE,MAAM,EAAE,CAAC;IAEjC;;OAEG;IACH,qCAAqC,EAAE,IAAI,CAAC;IAE5C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,8BAA8B,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,KAAK,EAAE,UAAU;IACrD;;OAEG;IACH,UAAU,EAAE,6CAA6C,CAAC;IAE1D;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,qBAAqB,GAAG,qBAAqB,EAAE,CAAC;IAE9D;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD;;OAEG;IACH,KAAK,EAAE,WAAW,CAAC;IAEnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAEnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,UAAU;IACzD;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,uBAAuB,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { Auth } from '../auth';
2
+ import type { AuthorizationChallenge, AuthorizationServerMetadata, PermissionDescription, SuccessfulTokenResponse } from './types';
3
+ export declare class TokenRequestError extends Error {
4
+ readonly status: number;
5
+ readonly payload?: unknown;
6
+ constructor(message: string, status: number, payload?: unknown);
7
+ }
8
+ export declare function parseUmaAuthenticateHeader(headers: Headers): AuthorizationChallenge | null;
9
+ export declare function discoverUmaConfiguration(asUri: string, fetchFn?: typeof fetch): Promise<AuthorizationServerMetadata>;
10
+ export declare function fetchAccessToken(auth: Auth, tokenEndpoint: string, request: string | PermissionDescription[]): Promise<SuccessfulTokenResponse>;
11
+ export interface UmaFetchOptions {
12
+ auth: Auth;
13
+ challenge: AuthorizationChallenge;
14
+ }
15
+ export declare function fetchWithUma(input: RequestInfo | URL, init?: RequestInit, options?: UmaFetchOptions): Promise<Response>;
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/uma/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAE3B,qBAAqB,EACrB,uBAAuB,EAGxB,MAAM,SAAS,CAAC;AAQjB,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAMtE;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,GACf,sBAAsB,GAAG,IAAI,CAgC/B;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC,2BAA2B,CAAC,CAwBtC;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GAAG,qBAAqB,EAAE,GACxC,OAAO,CAAC,uBAAuB,CAAC,CAiHlC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,sBAAsB,CAAC;CACnC;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,QAAQ,CAAC,CA+BnB"}