@outfoxx/sunday 2.0.0-beta.1 → 2.0.0-beta.11
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 +94 -0
- package/build/client-settings.d.ts +23 -0
- package/build/client-settings.js +150 -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 +14 -5
- 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-transport.d.ts +8 -0
- package/build/fetch-transport.js +84 -15
- package/build/fetch-transport.js.map +1 -1
- package/build/fetch.js +3 -2
- package/build/fetch.js.map +1 -1
- package/build/index.d.ts +12 -0
- package/build/index.js +12 -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/oauth-wire.d.ts +33 -0
- package/build/oauth-wire.js +143 -0
- package/build/oauth-wire.js.map +1 -0
- package/build/operation.d.ts +11 -1
- package/build/operation.js +3 -0
- package/build/operation.js.map +1 -1
- 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/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 +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/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-factory.d.ts +9 -0
- package/build/token-manager-factory.js +15 -0
- package/build/token-manager-factory.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 +5 -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
|
@@ -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';
|
|
@@ -29,10 +30,14 @@ export interface RequestSpec<B> {
|
|
|
29
30
|
queryParameters?: Record<string, unknown>;
|
|
30
31
|
body?: B;
|
|
31
32
|
bodyType?: SchemaLike<B>;
|
|
33
|
+
/** Revalidates typed parameters on every request build, before wire conversion. */
|
|
34
|
+
parameterValidation?: () => void;
|
|
32
35
|
contentTypes?: MediaType[];
|
|
33
36
|
acceptTypes?: MediaType[];
|
|
34
37
|
headers?: Record<string, unknown>;
|
|
35
38
|
signal?: AbortSignal;
|
|
39
|
+
/** Complete, explicitly selected credential bindings for this operation. */
|
|
40
|
+
security?: readonly SecurityBinding[];
|
|
36
41
|
}
|
|
37
42
|
export interface RequestAdapter {
|
|
38
43
|
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,C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CAAC"}
|
package/build/url-template.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
/** An RFC 6570 URL template with reusable parameter defaults. */
|
|
1
2
|
export declare class URLTemplate {
|
|
2
3
|
template: string;
|
|
3
4
|
parameters: Record<string, unknown>;
|
|
5
|
+
/** Creates a template whose stored parameters can be overridden for each expansion. */
|
|
4
6
|
constructor(template: string, parameters?: Record<string, unknown>);
|
|
7
|
+
/** Expands base and relative templates, preserving empty values and omitting null or missing values. */
|
|
5
8
|
complete(relativeTemplate: string, parameters: Record<string, unknown>): URL;
|
|
6
9
|
}
|
package/build/url-template.js
CHANGED
|
@@ -11,14 +11,17 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { parse } from 'uri-template';
|
|
14
|
+
import { expandExpression, parse } from 'uri-template';
|
|
15
|
+
/** An RFC 6570 URL template with reusable parameter defaults. */
|
|
15
16
|
export class URLTemplate {
|
|
16
17
|
template;
|
|
17
18
|
parameters;
|
|
19
|
+
/** Creates a template whose stored parameters can be overridden for each expansion. */
|
|
18
20
|
constructor(template, parameters = {}) {
|
|
19
21
|
this.template = template;
|
|
20
22
|
this.parameters = parameters;
|
|
21
23
|
}
|
|
24
|
+
/** Expands base and relative templates, preserving empty values and omitting null or missing values. */
|
|
22
25
|
complete(relativeTemplate, parameters) {
|
|
23
26
|
const allParameters = { ...this.parameters, ...parameters };
|
|
24
27
|
const baseTempl = this.template.endsWith('/')
|
|
@@ -27,7 +30,32 @@ export class URLTemplate {
|
|
|
27
30
|
const relTempl = relativeTemplate.startsWith('/') || !relativeTemplate.length
|
|
28
31
|
? relativeTemplate
|
|
29
32
|
: `/${relativeTemplate}`;
|
|
30
|
-
|
|
33
|
+
const template = parse(baseTempl + relTempl);
|
|
34
|
+
const expanded = template.ast.parts
|
|
35
|
+
.map((part) => {
|
|
36
|
+
if (part.type === 'literal')
|
|
37
|
+
return part.value;
|
|
38
|
+
const value = expandExpression(part, allParameters);
|
|
39
|
+
// uri-template 2 drops the path prefix when defined variables expand to an empty string.
|
|
40
|
+
if (part.operator === '/' &&
|
|
41
|
+
value === '' &&
|
|
42
|
+
part.variables.some((variable) => isDefined(allParameters[variable.name]))) {
|
|
43
|
+
return '/';
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
})
|
|
47
|
+
.join('');
|
|
48
|
+
return new URL(expanded);
|
|
31
49
|
}
|
|
32
50
|
}
|
|
51
|
+
// RFC 6570 treats empty collections as undefined, but an empty string is defined.
|
|
52
|
+
function isDefined(value) {
|
|
53
|
+
if (value == null)
|
|
54
|
+
return false;
|
|
55
|
+
if (typeof value !== 'object')
|
|
56
|
+
return true;
|
|
57
|
+
if (Array.isArray(value))
|
|
58
|
+
return value.length > 0;
|
|
59
|
+
return Object.values(value).some((entry) => entry != null);
|
|
60
|
+
}
|
|
33
61
|
//# sourceMappingURL=url-template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-template.js","sourceRoot":"","sources":["../src/url-template.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,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"url-template.js","sourceRoot":"","sources":["../src/url-template.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,EA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,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACxC,EACD,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF;AAED,kFAAkF;AAClF,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Decodes standard or URL-safe base64 with optional padding and loose final chunks. */
|
|
2
|
+
export declare function decodeBase64(value: string, alphabet?: 'base64' | 'base64url'): ArrayBuffer;
|
|
3
|
+
/** Encodes a byte view as unpadded standard or URL-safe base64. */
|
|
4
|
+
export declare function encodeBase64(value: Uint8Array, alphabet?: 'base64' | 'base64url'): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
/** Decodes standard or URL-safe base64 with optional padding and loose final chunks. */
|
|
15
|
+
export function decodeBase64(value, alphabet = 'base64') {
|
|
16
|
+
if (alphabet === 'base64url') {
|
|
17
|
+
if (/[+/]/.test(value)) {
|
|
18
|
+
throw new SyntaxError('Invalid base64url input');
|
|
19
|
+
}
|
|
20
|
+
value = value.replaceAll('-', '+').replaceAll('_', '/');
|
|
21
|
+
}
|
|
22
|
+
let binary;
|
|
23
|
+
try {
|
|
24
|
+
binary = atob(value);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new SyntaxError('Invalid base64 input', { cause: error });
|
|
28
|
+
}
|
|
29
|
+
const bytes = new Uint8Array(binary.length);
|
|
30
|
+
for (let index = 0; index < binary.length; index++) {
|
|
31
|
+
bytes[index] = binary.charCodeAt(index);
|
|
32
|
+
}
|
|
33
|
+
return bytes.buffer;
|
|
34
|
+
}
|
|
35
|
+
/** Encodes a byte view as unpadded standard or URL-safe base64. */
|
|
36
|
+
export function encodeBase64(value, alphabet = 'base64') {
|
|
37
|
+
const chunks = [];
|
|
38
|
+
// Bound temporary binary strings and spread arguments; align chunks so padding only occurs at the end.
|
|
39
|
+
const chunkSize = 0x6000;
|
|
40
|
+
for (let offset = 0; offset < value.length; offset += chunkSize) {
|
|
41
|
+
const encoded = btoa(String.fromCharCode(...value.subarray(offset, offset + chunkSize))).replace(/=+$/, '');
|
|
42
|
+
chunks.push(alphabet === 'base64url' ? encoded.replaceAll('+', '-').replaceAll('/', '_') : encoded);
|
|
43
|
+
}
|
|
44
|
+
return chunks.join('');
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/util/base64.ts"],"names":[],"mappings":"A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MAAM,CAAC;IACzB,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,SAAS,EAAE,CAAC;QAChE,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5G,MAAM,CAAC,IAAI,CAAC,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACtG,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outfoxx/sunday",
|
|
3
|
-
"version": "v2.0.0-beta.
|
|
3
|
+
"version": "v2.0.0-beta.11",
|
|
4
4
|
"description": "Sunday 🙏 The framework of REST for TypeScript/JavaScript",
|
|
5
5
|
"packageManager": "bun@1.3.10",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"types": "./build/*.d.ts",
|
|
15
15
|
"import": "./build/*.js"
|
|
16
16
|
},
|
|
17
|
-
"./package.json": "./package.json"
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
"./oauth-wire": null
|
|
18
19
|
},
|
|
19
20
|
"engines": {
|
|
20
21
|
"node": ">=22"
|
|
@@ -66,6 +67,8 @@
|
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@js-joda/core": "^5.7.0",
|
|
68
69
|
"cbor-redux": "^1.0.0",
|
|
70
|
+
"lossless-json": "4.3.0",
|
|
71
|
+
"oauth4webapi": "3.8.8",
|
|
69
72
|
"tslib": "^2.8.1",
|
|
70
73
|
"uri-template": "^2.0.0",
|
|
71
74
|
"zod": "^4.3.6"
|
|
@@ -83,6 +86,7 @@
|
|
|
83
86
|
"globals": "^17.3.0",
|
|
84
87
|
"husky": "^9.1.7",
|
|
85
88
|
"lint-staged": "^16.2.7",
|
|
89
|
+
"playwright": "1.58.0",
|
|
86
90
|
"prettier": "^3.8.1",
|
|
87
91
|
"pretty-quick": "^4.2.2",
|
|
88
92
|
"rimraf": "^6.1.3",
|