@outfoxx/sunday 1.1.0 → 2.0.0-beta.10
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/README.md +64 -0
- package/build/client-settings.d.ts +22 -0
- package/build/client-settings.js +147 -0
- package/build/client-settings.js.map +1 -0
- package/build/credentials.d.ts +58 -0
- package/build/credentials.js +51 -0
- package/build/credentials.js.map +1 -0
- package/build/event-parser.d.ts +2 -0
- package/build/event-parser.js.map +1 -1
- package/build/fetch-event-source.d.ts +15 -6
- package/build/fetch-event-source.js +109 -44
- package/build/fetch-event-source.js.map +1 -1
- package/build/fetch-oauth-token-provider.d.ts +28 -0
- package/build/fetch-oauth-token-provider.js +171 -0
- package/build/fetch-oauth-token-provider.js.map +1 -0
- package/build/{fetch-request-factory.d.ts → fetch-transport.d.ts} +15 -7
- package/build/{fetch-request-factory.js → fetch-transport.js} +95 -31
- package/build/fetch-transport.js.map +1 -0
- package/build/fetch.js +3 -2
- package/build/fetch.js.map +1 -1
- package/build/index.d.ts +15 -3
- package/build/index.js +15 -3
- package/build/index.js.map +1 -1
- package/build/media-type-codecs/cbor-encoder.d.ts +2 -2
- package/build/media-type-codecs/cbor-encoder.js +2 -2
- package/build/media-type-codecs/cbor-encoder.js.map +1 -1
- package/build/media-type-codecs/json-encoder.d.ts +3 -3
- package/build/media-type-codecs/json-encoder.js +4 -4
- package/build/media-type-codecs/json-encoder.js.map +1 -1
- package/build/media-type-codecs/media-type-encoder.d.ts +3 -3
- package/build/media-type-codecs/media-type-encoder.js.map +1 -1
- package/build/media-type-codecs/www-form-url-encoder.d.ts +2 -2
- package/build/media-type-codecs/www-form-url-encoder.js +2 -2
- package/build/media-type-codecs/www-form-url-encoder.js.map +1 -1
- package/build/model-construction.d.ts +5 -0
- package/build/model-construction.js +40 -0
- package/build/model-construction.js.map +1 -0
- package/build/model-schema.d.ts +9 -0
- package/build/model-schema.js +131 -0
- package/build/model-schema.js.map +1 -0
- package/build/oauth-wire.d.ts +33 -0
- package/build/oauth-wire.js +143 -0
- package/build/oauth-wire.js.map +1 -0
- package/build/operation-response.d.ts +33 -0
- package/build/operation-response.js +140 -0
- package/build/operation-response.js.map +1 -0
- package/build/operation.d.ts +64 -0
- package/build/operation.js +90 -0
- package/build/operation.js.map +1 -0
- package/build/problem.js +2 -1
- package/build/problem.js.map +1 -1
- package/build/request-adapters.d.ts +5 -5
- package/build/request-adapters.js +3 -3
- package/build/request-adapters.js.map +1 -1
- package/build/request-security.d.ts +16 -0
- package/build/request-security.js +167 -0
- package/build/request-security.js.map +1 -0
- package/build/request-validation-error.d.ts +4 -0
- package/build/request-validation-error.js +21 -0
- package/build/request-validation-error.js.map +1 -0
- package/build/schema-builtins.js +11 -21
- package/build/schema-builtins.js.map +1 -1
- package/build/schema-runtime.d.ts +21 -3
- package/build/schema-runtime.js +12 -3
- package/build/schema-runtime.js.map +1 -1
- package/build/security-binding.d.ts +22 -0
- package/build/{result-response.js → security-binding.js} +1 -1
- package/build/security-binding.js.map +1 -0
- package/build/streaming-body.d.ts +21 -0
- package/build/streaming-body.js +65 -0
- package/build/streaming-body.js.map +1 -0
- package/build/token-manager.d.ts +33 -0
- package/build/token-manager.js +199 -0
- package/build/token-manager.js.map +1 -0
- package/build/token-provider.d.ts +44 -0
- package/build/token-provider.js +31 -0
- package/build/token-provider.js.map +1 -0
- package/build/{request-factory.d.ts → transport.d.ts} +13 -8
- package/build/{request-factory.js → transport.js} +1 -1
- package/build/transport.js.map +1 -0
- package/build/unknown-variant.d.ts +12 -0
- package/build/unknown-variant.js +45 -0
- package/build/unknown-variant.js.map +1 -0
- package/build/url-template.d.ts +3 -0
- package/build/url-template.js +30 -2
- package/build/url-template.js.map +1 -1
- package/build/util/base64.d.ts +4 -0
- package/build/util/base64.js +46 -0
- package/build/util/base64.js.map +1 -0
- package/package.json +6 -2
- package/build/fetch-request-factory.js.map +0 -1
- package/build/request-factory.js.map +0 -1
- package/build/result-response.d.ts +0 -4
- package/build/result-response.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SchemaDef, SchemaRuntime } from './schema-runtime.js';
|
|
3
|
+
/** Defines a generated synchronous model codec with native Zod cycle diagnostics in both directions. */
|
|
4
|
+
export declare function defineModelSchema<Output, Input = unknown>(build: (runtime: SchemaRuntime) => z.ZodType<Output, Input>, options?: {
|
|
5
|
+
id?: symbol;
|
|
6
|
+
debugName?: string;
|
|
7
|
+
}): SchemaDef<z.ZodType<Output, Input>>;
|
|
8
|
+
/** Applies common native schema assertions without replacing a reusable union's payload type. */
|
|
9
|
+
export declare function withModelConstraints<Output, Input>(payload: z.ZodType<Output, Input>, common: z.ZodType, discriminator?: string): z.ZodType<Output, Input>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Copyright 2020 Outfox, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { Instant, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, ZonedDateTime } from '@js-joda/core';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { defineSchema } from './schema-runtime.js';
|
|
17
|
+
// Generated schemas and their transformations are synchronous. A root invocation owns the
|
|
18
|
+
// untyped-payload cycle check; nested schemas protect only their own recursive entry points.
|
|
19
|
+
let invocationDepth = 0;
|
|
20
|
+
/** Defines a generated synchronous model codec with native Zod cycle diagnostics in both directions. */
|
|
21
|
+
export function defineModelSchema(build, options) {
|
|
22
|
+
return defineSchema((runtime) => {
|
|
23
|
+
const schema = build(runtime);
|
|
24
|
+
const ancestors = new WeakSet();
|
|
25
|
+
function evaluate(value, context, direction) {
|
|
26
|
+
const object = typeof value === 'object' && value !== null ? value : undefined;
|
|
27
|
+
if (object && ancestors.has(object)) {
|
|
28
|
+
context.issues.push(cycleIssue([]));
|
|
29
|
+
return z.NEVER;
|
|
30
|
+
}
|
|
31
|
+
if (object)
|
|
32
|
+
ancestors.add(object);
|
|
33
|
+
const root = invocationDepth++ === 0;
|
|
34
|
+
try {
|
|
35
|
+
const result = direction === 'decode' ? schema.safeParse(value) : schema.safeEncode(value);
|
|
36
|
+
if (!result.success) {
|
|
37
|
+
context.issues.push(...result.error.issues.map(issue => ({ ...issue, input: undefined })));
|
|
38
|
+
return z.NEVER;
|
|
39
|
+
}
|
|
40
|
+
// Native object parsing has already removed non-participating fields. Inspecting its result
|
|
41
|
+
// also covers raw extension payloads without rejecting discarded input or invoking constructors.
|
|
42
|
+
const path = root ? cyclePath(result.data) : undefined;
|
|
43
|
+
if (path) {
|
|
44
|
+
context.issues.push(cycleIssue(path));
|
|
45
|
+
return z.NEVER;
|
|
46
|
+
}
|
|
47
|
+
return result.data;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
invocationDepth--;
|
|
51
|
+
if (object)
|
|
52
|
+
ancestors.delete(object);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return z.codec(z.custom(), z.custom(), {
|
|
56
|
+
decode: (value, context) => evaluate(value, context, 'decode'),
|
|
57
|
+
encode: (value, context) => evaluate(value, context, 'encode'),
|
|
58
|
+
});
|
|
59
|
+
}, options);
|
|
60
|
+
}
|
|
61
|
+
/** Applies common native schema assertions without replacing a reusable union's payload type. */
|
|
62
|
+
export function withModelConstraints(payload, common, discriminator) {
|
|
63
|
+
function evaluate(value, context, direction) {
|
|
64
|
+
let fields = value;
|
|
65
|
+
if (direction === 'encode' && discriminator && typeof value === 'object' && value !== null && discriminator in value) {
|
|
66
|
+
const tag = value[discriminator];
|
|
67
|
+
if (typeof tag === 'object' && tag !== null && 'rawValue' in tag && typeof tag.rawValue === 'string') {
|
|
68
|
+
// Reused payload enums may have another nominal type; common tag rules inspect their wire value.
|
|
69
|
+
fields = { ...value, [discriminator]: tag.rawValue };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const constraints = direction === 'decode' ? common.safeParse(fields) : common.safeEncode(fields);
|
|
73
|
+
if (!constraints.success) {
|
|
74
|
+
context.issues.push(...constraints.error.issues.map(issue => ({ ...issue, input: undefined })));
|
|
75
|
+
return z.NEVER;
|
|
76
|
+
}
|
|
77
|
+
// Keep the selected payload's native conversion and identity. The common schema is assertion-only.
|
|
78
|
+
const result = direction === 'decode' ? payload.safeParse(value) : payload.safeEncode(value);
|
|
79
|
+
if (!result.success) {
|
|
80
|
+
context.issues.push(...result.error.issues.map(issue => ({ ...issue, input: undefined })));
|
|
81
|
+
return z.NEVER;
|
|
82
|
+
}
|
|
83
|
+
return result.data;
|
|
84
|
+
}
|
|
85
|
+
// A refinement attached directly to a union loses its issues during Zod's reverse union pass.
|
|
86
|
+
return z.codec(z.custom(), z.custom(), {
|
|
87
|
+
decode: (value, context) => evaluate(value, context, 'decode'),
|
|
88
|
+
encode: (value, context) => evaluate(value, context, 'encode'),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function cycleIssue(path) {
|
|
92
|
+
return { code: 'custom', input: undefined, message: 'Object cycles cannot be serialized', path, params: { reason: 'cycle' } };
|
|
93
|
+
}
|
|
94
|
+
function cyclePath(value) {
|
|
95
|
+
const ancestors = new WeakSet();
|
|
96
|
+
const pending = [{ value, path: [] }];
|
|
97
|
+
while (pending.length) {
|
|
98
|
+
const entry = pending.pop();
|
|
99
|
+
if (typeof entry.value !== 'object' || entry.value === null)
|
|
100
|
+
continue;
|
|
101
|
+
// Temporal codecs serialize these native values as scalars, not their cyclic zone-rule internals.
|
|
102
|
+
if (entry.value instanceof Instant || entry.value instanceof LocalDate ||
|
|
103
|
+
entry.value instanceof LocalDateTime || entry.value instanceof LocalTime ||
|
|
104
|
+
entry.value instanceof OffsetDateTime || entry.value instanceof ZonedDateTime)
|
|
105
|
+
continue;
|
|
106
|
+
if (entry.leave) {
|
|
107
|
+
ancestors.delete(entry.value);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (ancestors.has(entry.value))
|
|
111
|
+
return entry.path;
|
|
112
|
+
ancestors.add(entry.value);
|
|
113
|
+
pending.push({ ...entry, leave: true });
|
|
114
|
+
const children = modelChildren(entry.value);
|
|
115
|
+
for (let index = children.length - 1; index >= 0; index--) {
|
|
116
|
+
const [key, item] = children[index];
|
|
117
|
+
pending.push({ value: item, path: [...entry.path, key] });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
function modelChildren(value) {
|
|
123
|
+
if (Array.isArray(value))
|
|
124
|
+
return value.map((item, index) => [index, item]);
|
|
125
|
+
if (value instanceof Map)
|
|
126
|
+
return [...value].flatMap(([key, item], index) => [[`key:${index}`, key], [String(key), item]]);
|
|
127
|
+
if (value instanceof Set)
|
|
128
|
+
return [...value].map((item, index) => [index, item]);
|
|
129
|
+
return Object.entries(value);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=model-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-schema.js","sourceRoot":"","sources":["../src/model-schema.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,a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O,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1H,IAAI,KAAK,YAAY,GAAG;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TokenSet } from './token-provider.js';
|
|
2
|
+
/** Internal wire decoding; client/session policy remains in the provider. */
|
|
3
|
+
export declare class DiscoveryMetadata {
|
|
4
|
+
readonly issuer: string;
|
|
5
|
+
readonly tokenUrl: string | undefined;
|
|
6
|
+
readonly authorizationUrl: string | undefined;
|
|
7
|
+
readonly methods: readonly string[] | undefined;
|
|
8
|
+
private constructor();
|
|
9
|
+
static parse(body: string): DiscoveryMetadata;
|
|
10
|
+
}
|
|
11
|
+
/** Internal token message, validated before conversion to application credentials. */
|
|
12
|
+
export declare class TokenSuccessResponse {
|
|
13
|
+
private readonly accessToken;
|
|
14
|
+
private readonly tokenType;
|
|
15
|
+
private readonly expiresIn;
|
|
16
|
+
private readonly refreshToken;
|
|
17
|
+
private readonly scope;
|
|
18
|
+
private constructor();
|
|
19
|
+
static parse(body: string): Promise<TokenSuccessResponse>;
|
|
20
|
+
tokens(scopes: readonly string[], now: number): TokenSet;
|
|
21
|
+
toString(): string;
|
|
22
|
+
toJSON(): string;
|
|
23
|
+
}
|
|
24
|
+
/** Internal error message; provider diagnostics never use descriptions from the server. */
|
|
25
|
+
export declare class TokenErrorResponse {
|
|
26
|
+
readonly code: string;
|
|
27
|
+
private constructor();
|
|
28
|
+
static parse(body: string): TokenErrorResponse;
|
|
29
|
+
toString(): string;
|
|
30
|
+
toJSON(): string;
|
|
31
|
+
}
|
|
32
|
+
/** Validates a selected or advertised endpoint before application authorization. */
|
|
33
|
+
export declare function endpoint(value: string | undefined): string;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Copyright 2020 Outfox, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import * as oauth from 'oauth4webapi';
|
|
15
|
+
import { parse, isLosslessNumber, isSafeNumber } from 'lossless-json';
|
|
16
|
+
import { TokenProviderError } from './token-provider.js';
|
|
17
|
+
/** Internal wire decoding; client/session policy remains in the provider. */
|
|
18
|
+
export class DiscoveryMetadata {
|
|
19
|
+
issuer;
|
|
20
|
+
tokenUrl;
|
|
21
|
+
authorizationUrl;
|
|
22
|
+
methods;
|
|
23
|
+
constructor(issuer, tokenUrl, authorizationUrl, methods) {
|
|
24
|
+
this.issuer = issuer;
|
|
25
|
+
this.tokenUrl = tokenUrl;
|
|
26
|
+
this.authorizationUrl = authorizationUrl;
|
|
27
|
+
this.methods = methods;
|
|
28
|
+
}
|
|
29
|
+
static parse(body) {
|
|
30
|
+
const data = document(body);
|
|
31
|
+
const issuer = string(data, 'issuer', true);
|
|
32
|
+
const tokenUrl = string(data, 'token_endpoint');
|
|
33
|
+
const authorizationUrl = string(data, 'authorization_endpoint');
|
|
34
|
+
if (tokenUrl !== undefined)
|
|
35
|
+
endpoint(tokenUrl);
|
|
36
|
+
if (authorizationUrl !== undefined)
|
|
37
|
+
endpoint(authorizationUrl);
|
|
38
|
+
for (const name of ['jwks_uri', 'registration_endpoint', 'revocation_endpoint', 'introspection_endpoint']) {
|
|
39
|
+
const value = string(data, name);
|
|
40
|
+
if (value !== undefined)
|
|
41
|
+
endpoint(value);
|
|
42
|
+
}
|
|
43
|
+
let methods;
|
|
44
|
+
if ('token_endpoint_auth_methods_supported' in data) {
|
|
45
|
+
const raw = data.token_endpoint_auth_methods_supported;
|
|
46
|
+
if (!Array.isArray(raw) || raw.some(value => typeof value !== 'string'))
|
|
47
|
+
throw new TokenProviderError();
|
|
48
|
+
methods = raw;
|
|
49
|
+
}
|
|
50
|
+
return new DiscoveryMetadata(issuer, tokenUrl, authorizationUrl, methods);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Internal token message, validated before conversion to application credentials. */
|
|
54
|
+
export class TokenSuccessResponse {
|
|
55
|
+
accessToken;
|
|
56
|
+
tokenType;
|
|
57
|
+
expiresIn;
|
|
58
|
+
refreshToken;
|
|
59
|
+
scope;
|
|
60
|
+
constructor(accessToken, tokenType, expiresIn, refreshToken, scope) {
|
|
61
|
+
this.accessToken = accessToken;
|
|
62
|
+
this.tokenType = tokenType;
|
|
63
|
+
this.expiresIn = expiresIn;
|
|
64
|
+
this.refreshToken = refreshToken;
|
|
65
|
+
this.scope = scope;
|
|
66
|
+
}
|
|
67
|
+
static async parse(body) {
|
|
68
|
+
const data = document(body);
|
|
69
|
+
let expiresIn;
|
|
70
|
+
if ('expires_in' in data) {
|
|
71
|
+
const raw = data.expires_in;
|
|
72
|
+
if (!isLosslessNumber(raw) || !isSafeNumber(raw.value) || !Number.isInteger(Number(raw.value)))
|
|
73
|
+
throw new TokenProviderError();
|
|
74
|
+
expiresIn = Number(raw.value);
|
|
75
|
+
data.expires_in = expiresIn;
|
|
76
|
+
}
|
|
77
|
+
const scope = string(data, 'scope');
|
|
78
|
+
if (scope !== undefined && !/^[\x21\x23-\x5b\x5d-\x7e]+(?: [\x21\x23-\x5b\x5d-\x7e]+)*(?![\s\S])/.test(scope))
|
|
79
|
+
throw new TokenProviderError();
|
|
80
|
+
// ID tokens are outside this OAuth-only API. Pass only the fields it consumes;
|
|
81
|
+
// oauth4webapi would otherwise also perform OIDC claim validation.
|
|
82
|
+
const protocolFields = Object.fromEntries(['access_token', 'token_type', 'expires_in', 'refresh_token', 'scope']
|
|
83
|
+
.filter(key => key in data).map(key => [key, data[key]]));
|
|
84
|
+
const parsed = await oauth.processGenericTokenEndpointResponse({ issuer: 'https://oauth.invalid' }, { client_id: 'sunday' }, Response.json(protocolFields));
|
|
85
|
+
return new TokenSuccessResponse(parsed.access_token, parsed.token_type, expiresIn, parsed.refresh_token, scope);
|
|
86
|
+
}
|
|
87
|
+
tokens(scopes, now) {
|
|
88
|
+
if (this.tokenType.toLowerCase() !== 'bearer' || (this.scope !== undefined && !scopes.every(scope => this.scope.split(' ').includes(scope))))
|
|
89
|
+
throw new TokenProviderError();
|
|
90
|
+
let expiresAt;
|
|
91
|
+
if (this.expiresIn !== undefined) {
|
|
92
|
+
expiresAt = Math.floor(now) + this.expiresIn * 1000;
|
|
93
|
+
if (this.expiresIn <= 0 || !Number.isSafeInteger(expiresAt))
|
|
94
|
+
throw new TokenProviderError();
|
|
95
|
+
}
|
|
96
|
+
return { accessToken: this.accessToken, expiresAt, refreshToken: this.refreshToken };
|
|
97
|
+
}
|
|
98
|
+
toString() { return 'OAuthSuccess()'; }
|
|
99
|
+
toJSON() { return this.toString(); }
|
|
100
|
+
}
|
|
101
|
+
/** Internal error message; provider diagnostics never use descriptions from the server. */
|
|
102
|
+
export class TokenErrorResponse {
|
|
103
|
+
code;
|
|
104
|
+
constructor(code) {
|
|
105
|
+
this.code = code;
|
|
106
|
+
}
|
|
107
|
+
static parse(body) {
|
|
108
|
+
const data = document(body);
|
|
109
|
+
string(data, 'error_description', false, true);
|
|
110
|
+
string(data, 'error_uri');
|
|
111
|
+
return new TokenErrorResponse(string(data, 'error', true));
|
|
112
|
+
}
|
|
113
|
+
toString() { return 'OAuthError()'; }
|
|
114
|
+
toJSON() { return this.toString(); }
|
|
115
|
+
}
|
|
116
|
+
/** Validates a selected or advertised endpoint before application authorization. */
|
|
117
|
+
export function endpoint(value) {
|
|
118
|
+
if (!value)
|
|
119
|
+
throw new TokenProviderError();
|
|
120
|
+
const url = new URL(value);
|
|
121
|
+
if (url.username || url.password || url.hash)
|
|
122
|
+
throw new TokenProviderError();
|
|
123
|
+
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)))
|
|
124
|
+
throw new TokenProviderError();
|
|
125
|
+
return url.toString();
|
|
126
|
+
}
|
|
127
|
+
function document(body) {
|
|
128
|
+
const data = parse(body);
|
|
129
|
+
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
130
|
+
throw new TokenProviderError();
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
function string(data, key, required = false, allowEmpty = false) {
|
|
134
|
+
if (!(key in data)) {
|
|
135
|
+
if (required)
|
|
136
|
+
throw new TokenProviderError();
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
if (typeof data[key] !== 'string' || (!allowEmpty && !data[key]))
|
|
140
|
+
throw new TokenProviderError();
|
|
141
|
+
return data[key];
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=oauth-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-wire.js","sourceRoot":"","sources":["../src/oauth-wire.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,KAAK,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
|
+
export interface ResponseHeaderEntry {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly value: string;
|
|
6
|
+
}
|
|
7
|
+
/** HTTP response headers with case-insensitive lookup. */
|
|
8
|
+
export declare class ResponseHeaders {
|
|
9
|
+
readonly entries: readonly ResponseHeaderEntry[];
|
|
10
|
+
constructor(entries: readonly ResponseHeaderEntry[]);
|
|
11
|
+
/** Creates response headers from a Fetch API `Headers` value. */
|
|
12
|
+
static from(headers: Headers): ResponseHeaders;
|
|
13
|
+
/** Retrieves all values matching `name` case-insensitively. */
|
|
14
|
+
getAll(name: string): readonly string[];
|
|
15
|
+
/** Retrieves the first value matching `name` case-insensitively. */
|
|
16
|
+
get(name: string): string | undefined;
|
|
17
|
+
/** Parsed `Content-Type` header value. */
|
|
18
|
+
get contentType(): MediaType | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** A decoded operation result with HTTP response metadata. */
|
|
21
|
+
export declare class OperationResponse<R> {
|
|
22
|
+
readonly result: R;
|
|
23
|
+
readonly transportResponse: Response;
|
|
24
|
+
readonly status: number;
|
|
25
|
+
readonly headers: ResponseHeaders;
|
|
26
|
+
constructor(result: R, transportResponse: Response);
|
|
27
|
+
/** Retrieves all response header values matching `name`. */
|
|
28
|
+
getHeaders(name: string): readonly string[];
|
|
29
|
+
/** Retrieves the first response header value matching `name`. */
|
|
30
|
+
getHeader(name: string): string | undefined;
|
|
31
|
+
/** Parsed `Content-Type` header value. */
|
|
32
|
+
get contentType(): MediaType | undefined;
|
|
33
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Copyright 2020 Outfox, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { MediaType } from './media-type.js';
|
|
15
|
+
const commaSeparatedResponseHeaders = new Set([
|
|
16
|
+
'accept-ranges',
|
|
17
|
+
'access-control-allow-headers',
|
|
18
|
+
'access-control-allow-methods',
|
|
19
|
+
'access-control-expose-headers',
|
|
20
|
+
'allow',
|
|
21
|
+
'cache-control',
|
|
22
|
+
'connection',
|
|
23
|
+
'content-encoding',
|
|
24
|
+
'link',
|
|
25
|
+
'transfer-encoding',
|
|
26
|
+
'upgrade',
|
|
27
|
+
'vary',
|
|
28
|
+
]);
|
|
29
|
+
/** HTTP response headers with case-insensitive lookup. */
|
|
30
|
+
export class ResponseHeaders {
|
|
31
|
+
entries;
|
|
32
|
+
constructor(entries) {
|
|
33
|
+
this.entries = entries;
|
|
34
|
+
}
|
|
35
|
+
/** Creates response headers from a Fetch API `Headers` value. */
|
|
36
|
+
static from(headers) {
|
|
37
|
+
const entries = [];
|
|
38
|
+
const setCookies = headers.getSetCookie?.() ?? [];
|
|
39
|
+
headers.forEach((value, name) => {
|
|
40
|
+
if (name.toLowerCase() === 'set-cookie' && setCookies.length > 0) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
splitHeaderValue(name, value).forEach((value) => {
|
|
44
|
+
entries.push({ name, value });
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
setCookies.forEach((value) => {
|
|
48
|
+
entries.push({ name: 'set-cookie', value });
|
|
49
|
+
});
|
|
50
|
+
return new ResponseHeaders(entries);
|
|
51
|
+
}
|
|
52
|
+
/** Retrieves all values matching `name` case-insensitively. */
|
|
53
|
+
getAll(name) {
|
|
54
|
+
return this.entries
|
|
55
|
+
.filter((entry) => entry.name.toLowerCase() === name.toLowerCase())
|
|
56
|
+
.map((entry) => entry.value);
|
|
57
|
+
}
|
|
58
|
+
/** Retrieves the first value matching `name` case-insensitively. */
|
|
59
|
+
get(name) {
|
|
60
|
+
return this.entries.find((entry) => entry.name.toLowerCase() === name.toLowerCase())?.value;
|
|
61
|
+
}
|
|
62
|
+
/** Parsed `Content-Type` header value. */
|
|
63
|
+
get contentType() {
|
|
64
|
+
const value = this.get('content-type');
|
|
65
|
+
if (!value) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return MediaType.from(value);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function splitHeaderValue(name, value) {
|
|
77
|
+
if (!commaSeparatedResponseHeaders.has(name.toLowerCase())) {
|
|
78
|
+
return [value];
|
|
79
|
+
}
|
|
80
|
+
const values = [];
|
|
81
|
+
let start = 0;
|
|
82
|
+
let inQuotes = false;
|
|
83
|
+
let inAngleBrackets = false;
|
|
84
|
+
let escaping = false;
|
|
85
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
86
|
+
const char = value[index];
|
|
87
|
+
if (escaping) {
|
|
88
|
+
escaping = false;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (char === '\\' && inQuotes) {
|
|
92
|
+
escaping = true;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (char === '"' && !inAngleBrackets) {
|
|
96
|
+
inQuotes = !inQuotes;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (char === '<' && !inQuotes) {
|
|
100
|
+
inAngleBrackets = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (char === '>' && !inQuotes) {
|
|
104
|
+
inAngleBrackets = false;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (char === ',' && !inQuotes && !inAngleBrackets) {
|
|
108
|
+
values.push(value.slice(start, index).trim());
|
|
109
|
+
start = index + 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
values.push(value.slice(start).trim());
|
|
113
|
+
return values.filter((value) => value.length > 0);
|
|
114
|
+
}
|
|
115
|
+
/** A decoded operation result with HTTP response metadata. */
|
|
116
|
+
export class OperationResponse {
|
|
117
|
+
result;
|
|
118
|
+
transportResponse;
|
|
119
|
+
status;
|
|
120
|
+
headers;
|
|
121
|
+
constructor(result, transportResponse) {
|
|
122
|
+
this.result = result;
|
|
123
|
+
this.transportResponse = transportResponse;
|
|
124
|
+
this.status = transportResponse.status;
|
|
125
|
+
this.headers = ResponseHeaders.from(transportResponse.headers);
|
|
126
|
+
}
|
|
127
|
+
/** Retrieves all response header values matching `name`. */
|
|
128
|
+
getHeaders(name) {
|
|
129
|
+
return this.headers.getAll(name);
|
|
130
|
+
}
|
|
131
|
+
/** Retrieves the first response header value matching `name`. */
|
|
132
|
+
getHeader(name) {
|
|
133
|
+
return this.headers.get(name);
|
|
134
|
+
}
|
|
135
|
+
/** Parsed `Content-Type` header value. */
|
|
136
|
+
get contentType() {
|
|
137
|
+
return this.headers.contentType;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=operation-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-response.js","sourceRoot":"","sources":["../src/operation-response.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAC;IAC5C,eAAe;IACf,8BAA8B;IAC9B,8BAA8B;IAC9B,+BAA+B;IAC/B,OAAO;IACP,eAAe;IACf,YA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AC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IAED,4DAA4D;IAC5D,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,iEAAiE;IACjE,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,0CAA0C;IAC1C,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Transport, RequestSpec } from './transport.js';
|
|
2
|
+
import { OperationResponse } from './operation-response.js';
|
|
3
|
+
import { SchemaLike } from './schema-runtime.js';
|
|
4
|
+
import { StreamingBody } from './streaming-body.js';
|
|
5
|
+
import { type ProblemMatcher } from './util/nullify.js';
|
|
6
|
+
/** Extracts the native request type from a transport. */
|
|
7
|
+
export type TransportRequest<Factory> = Factory extends {
|
|
8
|
+
transportRequest(requestSpec: RequestSpec<unknown>): Promise<infer NativeRequest>;
|
|
9
|
+
} ? NativeRequest : never;
|
|
10
|
+
/** Options used when converting an operation into a native request. */
|
|
11
|
+
export interface BuildRequestOptions {
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
/** Options used when executing an operation. */
|
|
15
|
+
export interface ExecuteOptions {
|
|
16
|
+
readonly signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
/** Describes the generated HTTP request and optional response decoder for an operation. */
|
|
19
|
+
export interface OperationSpec<RequestBody, ResponseBody> {
|
|
20
|
+
readonly request: RequestSpec<RequestBody>;
|
|
21
|
+
readonly responseType?: SchemaLike<ResponseBody>;
|
|
22
|
+
}
|
|
23
|
+
/** Describes an operation with no decoded response body. */
|
|
24
|
+
export interface VoidOperationSpec<RequestBody = void> extends OperationSpec<RequestBody, void> {
|
|
25
|
+
readonly responseType?: undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Describes an operation with a decoded response body. */
|
|
28
|
+
export interface TypedOperationSpec<RequestBody, ResponseBody> extends OperationSpec<RequestBody, ResponseBody> {
|
|
29
|
+
readonly responseType: SchemaLike<ResponseBody>;
|
|
30
|
+
}
|
|
31
|
+
/** Describes problems that should be translated into a null response value. */
|
|
32
|
+
export interface NullifySpec {
|
|
33
|
+
readonly statuses: readonly number[];
|
|
34
|
+
readonly problemTypes: readonly ProblemMatcher[];
|
|
35
|
+
}
|
|
36
|
+
/** A generated operation that can be executed or converted into a native transport request. */
|
|
37
|
+
export interface Operation<RequestBody, ResponseBody, Factory extends Transport<unknown> = Transport> {
|
|
38
|
+
readonly spec: OperationSpec<RequestBody, ResponseBody>;
|
|
39
|
+
execute(options?: ExecuteOptions): Promise<ResponseBody>;
|
|
40
|
+
response(options?: ExecuteOptions): Promise<OperationResponse<ResponseBody>>;
|
|
41
|
+
transportRequest(options?: BuildRequestOptions): Promise<TransportRequest<Factory>>;
|
|
42
|
+
transportResponse(options?: ExecuteOptions): Promise<Response>;
|
|
43
|
+
}
|
|
44
|
+
/** A generated streaming upload operation. */
|
|
45
|
+
export interface StreamingOperation<ResponseBody, Factory extends Transport<unknown> = Transport> extends Operation<StreamingBody, ResponseBody, Factory> {
|
|
46
|
+
}
|
|
47
|
+
/** A generated operation that can execute select problems as null responses. */
|
|
48
|
+
export interface NullableOperation<RequestBody, ResponseBody, Factory extends Transport<unknown> = Transport> extends Operation<RequestBody, ResponseBody, Factory> {
|
|
49
|
+
readonly nullify: NullifySpec;
|
|
50
|
+
executeOrNull(options?: ExecuteOptions): Promise<ResponseBody | null>;
|
|
51
|
+
responseOrNull(options?: ExecuteOptions): Promise<OperationResponse<ResponseBody> | null>;
|
|
52
|
+
}
|
|
53
|
+
/** Creates an operation with a decoded response body. */
|
|
54
|
+
export declare function createOperation<RequestBody = void, ResponseBody = void, Factory extends Transport<unknown> = Transport>(transport: Factory, spec: TypedOperationSpec<RequestBody, ResponseBody>): Operation<RequestBody, ResponseBody, Factory>;
|
|
55
|
+
/** Creates an operation with no decoded response body. */
|
|
56
|
+
export declare function createOperation<RequestBody = void, Factory extends Transport<unknown> = Transport>(transport: Factory, spec: VoidOperationSpec<RequestBody>): Operation<RequestBody, void, Factory>;
|
|
57
|
+
/** Creates a streaming upload operation with a decoded response body. */
|
|
58
|
+
export declare function createStreamingOperation<ResponseBody = void, Factory extends Transport<unknown> = Transport>(transport: Factory, spec: TypedOperationSpec<StreamingBody, ResponseBody>): StreamingOperation<ResponseBody, Factory>;
|
|
59
|
+
/** Creates a streaming upload operation with no decoded response body. */
|
|
60
|
+
export declare function createStreamingOperation<Factory extends Transport<unknown> = Transport>(transport: Factory, spec: VoidOperationSpec<StreamingBody>): StreamingOperation<void, Factory>;
|
|
61
|
+
/** Creates a nullable operation with a decoded response body. */
|
|
62
|
+
export declare function createNullableOperation<RequestBody = void, ResponseBody = void, Factory extends Transport<unknown> = Transport>(transport: Factory, spec: TypedOperationSpec<RequestBody, ResponseBody>, nullify: NullifySpec): NullableOperation<RequestBody, ResponseBody, Factory>;
|
|
63
|
+
/** Creates a nullable operation with no decoded response body. */
|
|
64
|
+
export declare function createNullableOperation<RequestBody = void, Factory extends Transport<unknown> = Transport>(transport: Factory, spec: VoidOperationSpec<RequestBody>, nullify: NullifySpec): NullableOperation<RequestBody, void, Factory>;
|