@outfoxx/sunday 2.0.0-beta.2 → 2.0.0-beta.4
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 +42 -0
- package/build/event-parser.d.ts +2 -0
- package/build/event-parser.js.map +1 -1
- package/build/fetch-event-source.d.ts +14 -5
- package/build/fetch-event-source.js +107 -44
- package/build/fetch-event-source.js.map +1 -1
- package/build/fetch-oauth-token-provider.d.ts +43 -0
- package/build/fetch-oauth-token-provider.js +193 -0
- package/build/fetch-oauth-token-provider.js.map +1 -0
- package/build/fetch-transport.d.ts +5 -0
- package/build/fetch-transport.js +45 -8
- package/build/fetch-transport.js.map +1 -1
- package/build/index.d.ts +7 -0
- package/build/index.js +7 -0
- 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/problem.js +2 -1
- package/build/problem.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/schema-runtime.d.ts +8 -1
- 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/security-binding.js +15 -0
- package/build/security-binding.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/transport.d.ts +3 -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/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SecurityBinding } from './security-binding.js';
|
|
2
|
+
import { TokenProvider, TokenSet, TokenStore } from './token-provider.js';
|
|
3
|
+
/** A credential receipt used for conditional invalidation after an invalid-token response. */
|
|
4
|
+
export interface TokenLease {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly tokens: TokenSet;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Shared token lifecycle with one renewal per cache key. Canceling one caller leaves other waiters
|
|
10
|
+
* running; canceling the last waiter signals the provider. A failed renewal is never cached.
|
|
11
|
+
*/
|
|
12
|
+
export declare class TokenManager {
|
|
13
|
+
private readonly providers;
|
|
14
|
+
private readonly store;
|
|
15
|
+
private readonly renewals;
|
|
16
|
+
private readonly authorizationAttempts;
|
|
17
|
+
private readonly locks;
|
|
18
|
+
private readonly now;
|
|
19
|
+
private readonly skew;
|
|
20
|
+
constructor(providers: Readonly<Record<string, TokenProvider>>, options?: {
|
|
21
|
+
store?: TokenStore;
|
|
22
|
+
expirySkewMs?: number;
|
|
23
|
+
now?: () => number;
|
|
24
|
+
});
|
|
25
|
+
/** Acquires current credentials without invoking authorization twice for an expired interactive session. */
|
|
26
|
+
credentials(binding: SecurityBinding, signal?: AbortSignal): Promise<TokenLease>;
|
|
27
|
+
/** Invalidates only the credential that failed, preserving a token already renewed by another caller. */
|
|
28
|
+
invalidate(lease: TokenLease): Promise<void>;
|
|
29
|
+
private exclusive;
|
|
30
|
+
private renew;
|
|
31
|
+
private acquireOrRefresh;
|
|
32
|
+
private join;
|
|
33
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
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 { AuthorizationRequiredError, TokenProviderError, } from './token-provider.js';
|
|
15
|
+
/**
|
|
16
|
+
* Shared token lifecycle with one renewal per cache key. Canceling one caller leaves other waiters
|
|
17
|
+
* running; canceling the last waiter signals the provider. A failed renewal is never cached.
|
|
18
|
+
*/
|
|
19
|
+
export class TokenManager {
|
|
20
|
+
providers;
|
|
21
|
+
store;
|
|
22
|
+
renewals = new Map();
|
|
23
|
+
authorizationAttempts = new Set();
|
|
24
|
+
locks = new Map();
|
|
25
|
+
now;
|
|
26
|
+
skew;
|
|
27
|
+
constructor(providers, options = {}) {
|
|
28
|
+
this.providers = new Map(Object.entries(providers));
|
|
29
|
+
this.store = options.store ?? new MemoryTokenStore();
|
|
30
|
+
this.now = options.now ?? Date.now;
|
|
31
|
+
this.skew = options.expirySkewMs ?? 30_000;
|
|
32
|
+
if (!Number.isFinite(this.skew) || this.skew < 0)
|
|
33
|
+
throw new RangeError('Invalid token expiry skew');
|
|
34
|
+
}
|
|
35
|
+
/** Acquires current credentials without invoking authorization twice for an expired interactive session. */
|
|
36
|
+
async credentials(binding, signal) {
|
|
37
|
+
signal?.throwIfAborted();
|
|
38
|
+
const provider = this.providers.get(binding.provider);
|
|
39
|
+
if (!provider)
|
|
40
|
+
throw new TokenProviderError();
|
|
41
|
+
let configuration;
|
|
42
|
+
try {
|
|
43
|
+
configuration = provider.configure(binding);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw new TokenProviderError();
|
|
47
|
+
}
|
|
48
|
+
if (!provider.identity.trim() || !configuration.clientIdentity.trim() ||
|
|
49
|
+
(binding.flow === 'authorizationCode' && !configuration.grantIdentity?.trim()))
|
|
50
|
+
throw new TokenProviderError();
|
|
51
|
+
const request = Object.freeze({
|
|
52
|
+
...binding,
|
|
53
|
+
discoveryUrl: configuration.endpoints?.discoveryUrl ?? binding.discoveryUrl,
|
|
54
|
+
authorizationUrl: configuration.endpoints?.authorizationUrl ?? binding.authorizationUrl,
|
|
55
|
+
tokenUrl: configuration.endpoints?.tokenUrl ?? binding.tokenUrl,
|
|
56
|
+
refreshUrl: configuration.endpoints?.refreshUrl ?? binding.refreshUrl,
|
|
57
|
+
clientIdentity: configuration.clientIdentity,
|
|
58
|
+
grantIdentity: configuration.grantIdentity,
|
|
59
|
+
scopes: Object.freeze([...new Set(binding.scopes)].sort(compareScopes)),
|
|
60
|
+
transport: Object.freeze({ ...binding.transport }),
|
|
61
|
+
});
|
|
62
|
+
const key = JSON.stringify([
|
|
63
|
+
request.scheme, binding.provider, provider.identity, request.clientIdentity, request.grantIdentity,
|
|
64
|
+
request.profile, request.flow, request.discoveryUrl, request.authorizationUrl, request.tokenUrl,
|
|
65
|
+
request.refreshUrl, request.scopes, request.audience, request.resource,
|
|
66
|
+
]);
|
|
67
|
+
let renewal = this.renewals.get(key);
|
|
68
|
+
if (!renewal || renewal.controller.signal.aborted) {
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
const created = {
|
|
71
|
+
controller, waiters: 0, settled: false, committing: false,
|
|
72
|
+
promise: this.exclusive(key, () => this.renew(key, provider, request, controller.signal)),
|
|
73
|
+
};
|
|
74
|
+
this.renewals.set(key, created);
|
|
75
|
+
void created.promise.finally(() => {
|
|
76
|
+
created.settled = true;
|
|
77
|
+
if (this.renewals.get(key) === created)
|
|
78
|
+
this.renewals.delete(key);
|
|
79
|
+
}).catch(() => undefined);
|
|
80
|
+
renewal = created;
|
|
81
|
+
}
|
|
82
|
+
return this.join(renewal, signal);
|
|
83
|
+
}
|
|
84
|
+
/** Invalidates only the credential that failed, preserving a token already renewed by another caller. */
|
|
85
|
+
async invalidate(lease) {
|
|
86
|
+
try {
|
|
87
|
+
await this.exclusive(lease.key, async () => {
|
|
88
|
+
const current = await this.store.load(lease.key);
|
|
89
|
+
if (current?.accessToken === lease.tokens.accessToken) {
|
|
90
|
+
await this.store.save(lease.key, Object.freeze({ ...current, expiresAt: 0 }));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new TokenProviderError();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exclusive(key, action) {
|
|
99
|
+
const prior = this.locks.get(key) ?? Promise.resolve();
|
|
100
|
+
const next = prior.catch(() => undefined).then(action);
|
|
101
|
+
this.locks.set(key, next);
|
|
102
|
+
void next.finally(() => {
|
|
103
|
+
if (this.locks.get(key) === next)
|
|
104
|
+
this.locks.delete(key);
|
|
105
|
+
}).catch(() => undefined);
|
|
106
|
+
return next;
|
|
107
|
+
}
|
|
108
|
+
async renew(key, provider, request, signal) {
|
|
109
|
+
try {
|
|
110
|
+
signal.throwIfAborted();
|
|
111
|
+
const stored = await this.store.load(key);
|
|
112
|
+
signal.throwIfAborted();
|
|
113
|
+
if (stored && (stored.expiresAt === undefined || stored.expiresAt > this.now() + this.skew)) {
|
|
114
|
+
return { key, tokens: Object.freeze({ ...stored }) };
|
|
115
|
+
}
|
|
116
|
+
const tokens = await this.acquireOrRefresh(key, stored, provider, request, signal);
|
|
117
|
+
if (!tokens.accessToken || (tokens.expiresAt !== undefined &&
|
|
118
|
+
(!Number.isFinite(tokens.expiresAt) || tokens.expiresAt <= this.now())))
|
|
119
|
+
throw new TokenProviderError();
|
|
120
|
+
const snapshot = Object.freeze({ ...tokens });
|
|
121
|
+
signal.throwIfAborted();
|
|
122
|
+
const renewal = this.renewals.get(key);
|
|
123
|
+
if (renewal?.controller.signal !== signal)
|
|
124
|
+
throw new DOMException('Renewal expired', 'AbortError');
|
|
125
|
+
// Once persistence begins, cancellation must not discard a rotated refresh token.
|
|
126
|
+
renewal.committing = true;
|
|
127
|
+
await this.store.save(key, snapshot);
|
|
128
|
+
return { key, tokens: snapshot };
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (signal.aborted)
|
|
132
|
+
throw signal.reason;
|
|
133
|
+
if (error instanceof AuthorizationRequiredError || error instanceof TokenProviderError)
|
|
134
|
+
throw error;
|
|
135
|
+
throw new TokenProviderError();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async acquireOrRefresh(key, stored, provider, request, signal) {
|
|
139
|
+
if (stored?.refreshToken && provider.refresh) {
|
|
140
|
+
try {
|
|
141
|
+
const refreshed = await provider.refresh(request, stored.refreshToken, signal);
|
|
142
|
+
return { ...refreshed, refreshToken: refreshed.refreshToken ?? stored.refreshToken };
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
if (!(error instanceof TokenProviderError) || error.reason !== 'invalidGrant' || request.flow !== 'clientCredentials')
|
|
146
|
+
throw error;
|
|
147
|
+
signal.throwIfAborted();
|
|
148
|
+
await this.store.remove(key);
|
|
149
|
+
return provider.acquire(request, signal);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else if (request.flow === 'authorizationCode' && (stored || this.authorizationAttempts.has(key))) {
|
|
153
|
+
throw new AuthorizationRequiredError();
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
if (request.flow === 'authorizationCode')
|
|
157
|
+
this.authorizationAttempts.add(key);
|
|
158
|
+
return provider.acquire(request, signal);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
join(renewal, signal) {
|
|
162
|
+
renewal.waiters++;
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
let completed = false;
|
|
165
|
+
const finish = (value, error) => {
|
|
166
|
+
if (completed)
|
|
167
|
+
return;
|
|
168
|
+
completed = true;
|
|
169
|
+
signal?.removeEventListener('abort', abort);
|
|
170
|
+
renewal.waiters--;
|
|
171
|
+
if (renewal.waiters === 0 && !renewal.settled && !renewal.committing)
|
|
172
|
+
renewal.controller.abort();
|
|
173
|
+
if (value)
|
|
174
|
+
resolve(value);
|
|
175
|
+
else
|
|
176
|
+
reject(error);
|
|
177
|
+
};
|
|
178
|
+
const abort = () => finish(undefined, signal?.reason);
|
|
179
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
180
|
+
if (signal?.aborted)
|
|
181
|
+
abort();
|
|
182
|
+
renewal.promise.then(value => finish(value), error => finish(undefined, error));
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
class MemoryTokenStore {
|
|
187
|
+
tokens = new Map();
|
|
188
|
+
load(key) { return Promise.resolve(this.tokens.get(key)); }
|
|
189
|
+
save(key, tokens) { this.tokens.set(key, tokens); return Promise.resolve(); }
|
|
190
|
+
remove(key) { this.tokens.delete(key); return Promise.resolve(); }
|
|
191
|
+
}
|
|
192
|
+
function compareScopes(left, right) {
|
|
193
|
+
if (left < right)
|
|
194
|
+
return -1;
|
|
195
|
+
if (left > right)
|
|
196
|
+
return 1;
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=token-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-manager.js","sourceRoot":"","sources":["../src/token-manager.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,iCAAi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E,KAAK,EAAE,CAAC;YAC7B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,gBAAgB;IACH,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtD,IAAI,CAAC,GAAW,IAAmC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClG,IAAI,CAAC,GAAW,EAAE,MAAgB,IAAmB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC9G,MAAM,CAAC,GAAW,IAAmB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;CAC1F;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,KAAa;IAChD,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC,CAAC;IAC5B,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,CAAC,CAAC;IAC3B,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SecurityBinding, SecurityEndpoints } from './security-binding.js';
|
|
2
|
+
/** Credentials returned by an application provider; values are never included in runtime diagnostics. */
|
|
3
|
+
export interface TokenSet {
|
|
4
|
+
readonly accessToken: string;
|
|
5
|
+
readonly expiresAt?: number;
|
|
6
|
+
readonly refreshToken?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Non-secret identities isolate cache entries; grantIdentity must change with session or grant inputs. */
|
|
9
|
+
export interface TokenConfiguration {
|
|
10
|
+
readonly clientIdentity: string;
|
|
11
|
+
readonly grantIdentity?: string;
|
|
12
|
+
readonly endpoints?: SecurityEndpoints;
|
|
13
|
+
}
|
|
14
|
+
/** Fully selected acquisition parameters; this contains neither client secrets nor authorization codes. */
|
|
15
|
+
export interface TokenRequest extends SecurityBinding {
|
|
16
|
+
readonly clientIdentity: string;
|
|
17
|
+
readonly grantIdentity?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Application credential binding. OAuth providers exchange fresh authorization and refresh tokens;
|
|
21
|
+
* the shared manager owns caching, rotation, renewal coalescing, and cancellation.
|
|
22
|
+
*/
|
|
23
|
+
export interface TokenProvider {
|
|
24
|
+
readonly identity: string;
|
|
25
|
+
configure(binding: SecurityBinding): TokenConfiguration;
|
|
26
|
+
acquire(request: TokenRequest, signal: AbortSignal): Promise<TokenSet>;
|
|
27
|
+
refresh?(request: TokenRequest, refreshToken: string, signal: AbortSignal): Promise<TokenSet>;
|
|
28
|
+
}
|
|
29
|
+
/** Application-owned storage. Implementations must serialize writes and keep credentials private. */
|
|
30
|
+
export interface TokenStore {
|
|
31
|
+
load(key: string): Promise<TokenSet | undefined>;
|
|
32
|
+
save(key: string, tokens: TokenSet): Promise<void>;
|
|
33
|
+
remove(key: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** Signals that an interactive application must supply a fresh authorization session. */
|
|
36
|
+
export declare class AuthorizationRequiredError extends Error {
|
|
37
|
+
constructor();
|
|
38
|
+
}
|
|
39
|
+
/** Safe provider failure without a provider's potentially credential-bearing error message. */
|
|
40
|
+
export declare class TokenProviderError extends Error {
|
|
41
|
+
readonly reason: 'unavailable' | 'temporary' | 'invalidGrant';
|
|
42
|
+
/** Safe recovery classification; provider messages and credentials are never retained. */
|
|
43
|
+
constructor(reason?: 'unavailable' | 'temporary' | 'invalidGrant');
|
|
44
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
/** Signals that an interactive application must supply a fresh authorization session. */
|
|
15
|
+
export class AuthorizationRequiredError extends Error {
|
|
16
|
+
constructor() {
|
|
17
|
+
super('Fresh application authorization is required');
|
|
18
|
+
this.name = 'AuthorizationRequiredError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Safe provider failure without a provider's potentially credential-bearing error message. */
|
|
22
|
+
export class TokenProviderError extends Error {
|
|
23
|
+
reason;
|
|
24
|
+
/** Safe recovery classification; provider messages and credentials are never retained. */
|
|
25
|
+
constructor(reason = 'unavailable') {
|
|
26
|
+
super('The credential provider could not supply usable credentials');
|
|
27
|
+
this.reason = reason;
|
|
28
|
+
this.name = 'TokenProviderError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=token-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-provider.js","sourceRoot":"","sources":["../src/token-provider.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;AA0CjC,yFAAyF;AACzF,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD;QACE,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAED,+FAA+F;AAC/F,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEtB;IADrB,0FAA0F;IAC1F,YAAqB,SAAuD,aAAa;QACvF,KAAK,CAAC,6DAA6D,CAAC,CAAC;QADlD,WAAM,GAAN,MAAM,CAA8D;QAEvF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
package/build/transport.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SecurityBinding } from './security-binding.js';
|
|
1
2
|
import { MediaType } from './media-type.js';
|
|
2
3
|
import { TextMediaTypeDecoder } from './media-type-codecs/media-type-decoder.js';
|
|
3
4
|
import { Problem } from './problem.js';
|
|
@@ -33,6 +34,8 @@ export interface RequestSpec<B> {
|
|
|
33
34
|
acceptTypes?: MediaType[];
|
|
34
35
|
headers?: Record<string, unknown>;
|
|
35
36
|
signal?: AbortSignal;
|
|
37
|
+
/** Complete, explicitly selected credential bindings for this operation. */
|
|
38
|
+
security?: readonly SecurityBinding[];
|
|
36
39
|
}
|
|
37
40
|
export interface RequestAdapter {
|
|
38
41
|
adapt(transport: Transport, request: Request): Promise<Request>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Marks a fallback independently of its discriminator or structural fields. */
|
|
3
|
+
export declare const UnknownVariantTag: unique symbol;
|
|
4
|
+
/** An unknown discriminated payload whose original wire fields are preserved. */
|
|
5
|
+
export interface UnknownVariant {
|
|
6
|
+
readonly [UnknownVariantTag]: true;
|
|
7
|
+
readonly rawBody: Readonly<Record<string, unknown>>;
|
|
8
|
+
}
|
|
9
|
+
/** Identifies fallback instances even when their discriminator resembles a known branch. */
|
|
10
|
+
export declare function isUnknownVariant(value: unknown): value is UnknownVariant;
|
|
11
|
+
/** Dispatches encoding by fallback identity while retaining native schema validation. */
|
|
12
|
+
export declare function unionWithUnknown<K extends z.ZodType, U extends z.ZodType<UnknownVariant>>(known: K, unknown: U): z.ZodType<z.output<K> | z.output<U>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { z } from 'zod';
|
|
15
|
+
/** Marks a fallback independently of its discriminator or structural fields. */
|
|
16
|
+
export const UnknownVariantTag = Symbol.for('@outfoxx/sunday/UnknownVariant');
|
|
17
|
+
/** Identifies fallback instances even when their discriminator resembles a known branch. */
|
|
18
|
+
export function isUnknownVariant(value) {
|
|
19
|
+
return typeof value === 'object' && value !== null
|
|
20
|
+
&& UnknownVariantTag in value && value[UnknownVariantTag] === true;
|
|
21
|
+
}
|
|
22
|
+
/** Dispatches encoding by fallback identity while retaining native schema validation. */
|
|
23
|
+
export function unionWithUnknown(known, unknown) {
|
|
24
|
+
const wire = z.union([known, unknown]);
|
|
25
|
+
return z.codec(z.unknown(), z.custom(), {
|
|
26
|
+
decode(value, context) {
|
|
27
|
+
const result = wire.safeParse(value);
|
|
28
|
+
if (!result.success) {
|
|
29
|
+
context.issues.push(...result.error.issues.map(issue => ({ ...issue, input: undefined })));
|
|
30
|
+
return z.NEVER;
|
|
31
|
+
}
|
|
32
|
+
return result.data;
|
|
33
|
+
},
|
|
34
|
+
encode(value, context) {
|
|
35
|
+
const schema = isUnknownVariant(value) ? unknown : known;
|
|
36
|
+
const result = schema.safeEncode(value);
|
|
37
|
+
if (!result.success) {
|
|
38
|
+
context.issues.push(...result.error.issues.map(issue => ({ ...issue, input: undefined })));
|
|
39
|
+
return z.NEVER;
|
|
40
|
+
}
|
|
41
|
+
return result.data;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=unknown-variant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown-variant.js","sourceRoot":"","sources":["../src/unknown-variant.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,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAQ7F,4FAA4F;AAC5F,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;WAC7C,iBAAiB,IAAI,KAAK,IAAI,KAAK,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;AACvE,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,gBAAgB,CAC9B,KAAQ,EACR,OAAU;IAEV,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAA6B,EAAE;QACjE,MAAM,CAAC,KAAK,EAA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