@strivacity/sdk-core 1.0.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/CHANGELOG.md +6 -0
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/Metadata.cjs +2 -0
- package/dist/Metadata.cjs.map +1 -0
- package/dist/Metadata.d.ts +74 -0
- package/dist/Metadata.mjs +2 -0
- package/dist/Metadata.mjs.map +1 -0
- package/dist/Session.cjs +2 -0
- package/dist/Session.cjs.map +1 -0
- package/dist/Session.d.ts +82 -0
- package/dist/Session.mjs +2 -0
- package/dist/Session.mjs.map +1 -0
- package/dist/State.cjs +2 -0
- package/dist/State.cjs.map +1 -0
- package/dist/State.d.ts +43 -0
- package/dist/State.mjs +2 -0
- package/dist/State.mjs.map +1 -0
- package/dist/flows/BaseFlow.cjs +2 -0
- package/dist/flows/BaseFlow.cjs.map +1 -0
- package/dist/flows/BaseFlow.d.ts +177 -0
- package/dist/flows/BaseFlow.mjs +2 -0
- package/dist/flows/BaseFlow.mjs.map +1 -0
- package/dist/flows/PopupFlow.cjs +2 -0
- package/dist/flows/PopupFlow.cjs.map +1 -0
- package/dist/flows/PopupFlow.d.ts +31 -0
- package/dist/flows/PopupFlow.mjs +2 -0
- package/dist/flows/PopupFlow.mjs.map +1 -0
- package/dist/flows/RedirectFlow.cjs +2 -0
- package/dist/flows/RedirectFlow.cjs.map +1 -0
- package/dist/flows/RedirectFlow.d.ts +32 -0
- package/dist/flows/RedirectFlow.mjs +2 -0
- package/dist/flows/RedirectFlow.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/storages/LocalStorage.cjs +2 -0
- package/dist/storages/LocalStorage.cjs.map +1 -0
- package/dist/storages/LocalStorage.d.ts +23 -0
- package/dist/storages/LocalStorage.mjs +2 -0
- package/dist/storages/LocalStorage.mjs.map +1 -0
- package/dist/storages/SessionStorage.cjs +2 -0
- package/dist/storages/SessionStorage.cjs.map +1 -0
- package/dist/storages/SessionStorage.d.ts +23 -0
- package/dist/storages/SessionStorage.mjs +2 -0
- package/dist/storages/SessionStorage.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +861 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils/base64Url.cjs +2 -0
- package/dist/utils/base64Url.cjs.map +1 -0
- package/dist/utils/base64Url.d.ts +27 -0
- package/dist/utils/base64Url.mjs +2 -0
- package/dist/utils/base64Url.mjs.map +1 -0
- package/dist/utils/constants.cjs +2 -0
- package/dist/utils/constants.cjs.map +1 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.mjs +2 -0
- package/dist/utils/constants.mjs.map +1 -0
- package/dist/utils/crypto.cjs +2 -0
- package/dist/utils/crypto.cjs.map +1 -0
- package/dist/utils/crypto.d.ts +32 -0
- package/dist/utils/crypto.mjs +2 -0
- package/dist/utils/crypto.mjs.map +1 -0
- package/dist/utils/date.cjs +2 -0
- package/dist/utils/date.cjs.map +1 -0
- package/dist/utils/date.d.ts +6 -0
- package/dist/utils/date.mjs +2 -0
- package/dist/utils/date.mjs.map +1 -0
- package/dist/utils/fetch.cjs +2 -0
- package/dist/utils/fetch.cjs.map +1 -0
- package/dist/utils/fetch.d.ts +2 -0
- package/dist/utils/fetch.mjs +2 -0
- package/dist/utils/fetch.mjs.map +1 -0
- package/dist/utils/handlers.cjs +2 -0
- package/dist/utils/handlers.cjs.map +1 -0
- package/dist/utils/handlers.d.ts +34 -0
- package/dist/utils/handlers.mjs +2 -0
- package/dist/utils/handlers.mjs.map +1 -0
- package/dist/utils/jwt.cjs +2 -0
- package/dist/utils/jwt.cjs.map +1 -0
- package/dist/utils/jwt.d.ts +34 -0
- package/dist/utils/jwt.mjs +2 -0
- package/dist/utils/jwt.mjs.map +1 -0
- package/package.json +49 -0
package/dist/types.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=["code","id_token"],o=["query","fragment"],n=["none"],s=["authorization_code","refresh_token"],i=["RS256"],c=["public"],p=["none","login","create"],r=["redirect","popup"];class a{}const L=["item","group"];export{i as AlgorithmTypeList,r as FallbackModeTypeList,s as GrantTypeList,p as PromptTypeList,o as ResponseModeList,e as ResponseTypeList,a as SDKStorage,L as SelectOptionTypeList,c as SubjectTypeList,n as TokenEndpointAuthMethodList};
|
|
2
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../src/types.ts"],"sourcesContent":["/**\n * Makes properties of `T` required based on the keys provided in `K`.\n *\n * @template T - The type from which properties will be made required.\n * @template K - The keys of `T` that should be required.\n * @example\n * type MyType = { a?: string; b?: number; c?: boolean };\n * type RequiredAB = Mandatory<MyType, 'a' | 'b'>; // { a: string; b: number; c?: boolean }\n */\nexport type Mandatory<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;\n\n/**\n * A type representing a partial record of key-value pairs where keys are of type `K` and values are of type `T`.\n *\n * @template K - The type of the keys in the record.\n * @template T - The type of the values in the record.\n * @example\n * type StringMap = PartialRecord<string, string>; // { [key: string]: string | undefined }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PartialRecord<K extends keyof any, T> = {\n\t[P in K]?: T;\n};\n\n// region SDK\n\n/**\n * List of supported response types.\n */\nexport const ResponseTypeList = ['code', 'id_token'] as const;\n/**\n * Type representing valid response types.\n */\nexport type ResponseType = (typeof ResponseTypeList)[number];\n\n/**\n * List of supported response modes.\n */\nexport const ResponseModeList = ['query', 'fragment'] as const;\n/**\n * Type representing valid response modes.\n */\nexport type ResponseMode = (typeof ResponseModeList)[number];\n\n/**\n * List of supported token endpoint authentication methods.\n */\nexport const TokenEndpointAuthMethodList = ['none'] as const;\n/**\n * Type representing valid token endpoint authentication methods.\n */\nexport type TokenEndpointAuthMethod = (typeof TokenEndpointAuthMethodList)[number];\n\n/**\n * List of supported grant types.\n */\nexport const GrantTypeList = ['authorization_code', 'refresh_token'] as const;\n/**\n * Type representing valid grant types.\n */\nexport type GrantType = (typeof GrantTypeList)[number];\n\n/**\n * List of supported algorithm types.\n */\nexport const AlgorithmTypeList = ['RS256'] as const;\n/**\n * Type representing valid algorithm types.\n */\nexport type AlgorithmType = (typeof AlgorithmTypeList)[number];\n\n/**\n * List of supported subject types.\n */\nexport const SubjectTypeList = ['public'] as const;\n/**\n * Type representing valid subject types.\n */\nexport type SubjectType = (typeof SubjectTypeList)[number];\n\n/**\n * List of supported prompt types.\n */\nexport const PromptTypeList = ['none', 'login', 'create'] as const;\n/**\n * Type representing valid prompt types.\n */\nexport type PromptType = (typeof PromptTypeList)[number];\n\n/**\n * List of supported fallback modes.\n */\nexport const FallbackModeTypeList = ['redirect', 'popup'] as const;\n/**\n * Type representing valid fallback modes.\n */\nexport type FallbackMode = (typeof FallbackModeTypeList)[number];\n\n/**\n * Represents a signing key used in cryptographic operations, such as signing JSON Web Tokens (JWTs).\n *\n * This type defines the key's properties, including its usage, type, identifier, algorithm, and key material.\n */\nexport type SigningKey = {\n\t/**\n\t * The intended use of the key. Common values include \"sig\" for signature and \"enc\" for encryption.\n\t *\n\t * @type {string}\n\t * @example 'sig'\n\t */\n\tuse: string;\n\n\t/**\n\t * The key type. For example, \"RSA\" for RSA keys or \"EC\" for Elliptic Curve keys.\n\t *\n\t * @type {string}\n\t * @example 'RSA'\n\t */\n\tkty: string;\n\n\t/**\n\t * A unique identifier for the key. This is used to distinguish the key from others.\n\t *\n\t * @type {string}\n\t * @example 'key-id-1234'\n\t */\n\tkid: string;\n\n\t/**\n\t * The algorithm used with the key. For example, \"RS256\" for RSA SHA-256.\n\t *\n\t * @type {AlgorithmType}\n\t * @example 'RS256'\n\t */\n\talg: AlgorithmType;\n\n\t/**\n\t * The modulus of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-modulus'\n\t */\n\tn: string;\n\n\t/**\n\t * The exponent of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-exponent'\n\t */\n\te: string;\n};\n\n/**\n * Represents the metadata options provided by an authorization server.\n *\n * This metadata includes information about the server's endpoints, supported features, and supported claims.\n */\nexport type MetadataOptions = {\n\t/**\n\t * The issuer of the tokens. This is the authorization server or entity that issues the tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The URL of the authorization endpoint where authentication requests are sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/authorize'\n\t */\n\tauthorization_endpoint: string;\n\n\t/**\n\t * The URL of the token endpoint where tokens are exchanged.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/token'\n\t */\n\ttoken_endpoint: string;\n\n\t/**\n\t * The URL of the JSON Web Key Set (JWKS) endpoint where public keys are available.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/jwks'\n\t */\n\tjwks_uri: string;\n\n\t/**\n\t * The types of subjects that are supported by the authorization server.\n\t *\n\t * @type {Array<SubjectType>}\n\t * @example ['public']\n\t */\n\tsubject_types_supported: Array<SubjectType>;\n\n\t/**\n\t * The types of responses supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['code', 'id_token']\n\t */\n\tresponse_types_supported: Array<string>;\n\n\t/**\n\t * The claims supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['sub', 'name', 'email']\n\t */\n\tclaims_supported: Array<string>;\n\n\t/**\n\t * The grant types supported by the authorization server.\n\t *\n\t * @type {Array<GrantType>}\n\t * @example ['authorization_code', 'refresh_token']\n\t */\n\tgrant_types_supported: Array<GrantType>;\n\n\t/**\n\t * The response modes supported by the authorization server.\n\t *\n\t * @type {Array<ResponseMode>}\n\t * @example ['query', 'fragment']\n\t */\n\tresponse_modes_supported: Array<ResponseMode>;\n\n\t/**\n\t * The URL of the user info endpoint where user information can be retrieved.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/userinfo'\n\t */\n\tuserinfo_endpoint: string;\n\n\t/**\n\t * The scopes supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['openid', 'profile', 'email']\n\t */\n\tscopes_supported: Array<string>;\n\n\t/**\n\t * The authentication methods supported for token endpoint authentication.\n\t *\n\t * @type {Array<TokenEndpointAuthMethod>}\n\t * @example ['none']\n\t */\n\ttoken_endpoint_auth_methods_supported: Array<TokenEndpointAuthMethod>;\n\n\t/**\n\t * The algorithms supported for signing tokens used in the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms supported for signing ID tokens.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign ID tokens in response.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign responses from the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * Indicates whether the request parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether the request URI parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_uri_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether request URI registration is required.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequire_request_uri_registration: boolean;\n\n\t/**\n\t * Indicates whether the claims parameter is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tclaims_parameter_supported: boolean;\n\n\t/**\n\t * The URL of the revocation endpoint for revoking tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/revoke'\n\t */\n\trevocation_endpoint: string;\n\n\t/**\n\t * Indicates whether backchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether backchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_session_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_session_supported: boolean;\n\n\t/**\n\t * The URL of the endpoint where end-session requests can be sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/logout'\n\t */\n\tend_session_endpoint: string;\n\n\t/**\n\t * The algorithms supported for signing request objects.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\trequest_object_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The code challenge methods supported by the authorization server.\n\t *\n\t * @type {Array<'S256'>}\n\t * @example ['S256']\n\t */\n\tcode_challenge_methods_supported: Array<'S256'>;\n};\n\n/**\n * Represents the standard claims in a JSON Web Token (JWT).\n *\n * These claims are part of the payload in a JWT and convey information about the token, such as its issuer, subject, and expiration.\n */\nexport type JwtClaims = {\n\t/**\n\t * The issuer of the token. This typically represents the authorization server or entity that issued the JWT.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tiss?: string;\n\n\t/**\n\t * The subject of the token. This is the identifier for the entity the token represents, such as a user ID.\n\t *\n\t * @type {string}\n\t * @example 'user123'\n\t */\n\tsub?: string;\n\n\t/**\n\t * The audience for which the token is intended. This can be a single identifier or an array of identifiers.\n\t *\n\t * @type {string | Array<string>}\n\t * @example 'your-client-id' | ['client1', 'client2']\n\t */\n\taud?: string | Array<string>;\n\n\t/**\n\t * The expiration time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633024800\n\t */\n\texp?: number;\n\n\t/**\n\t * The not-before time of the token, expressed as a Unix timestamp. The token must not be accepted before this time.\n\t *\n\t * @type {number}\n\t * @example 1633021200\n\t */\n\tnbf?: number;\n\n\t/**\n\t * The issued-at time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tiat?: number;\n\n\t/**\n\t * A unique identifier for the token. This can be used to prevent token replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'unique-jwt-id-1234'\n\t */\n\tjti?: string;\n};\n\n/**\n * Represents the claims included in an ID token, extending standard JWT claims with additional properties specific to identity tokens.\n *\n * ID tokens are used to authenticate and provide identity information about the user.\n */\nexport type IdTokenClaims = Mandatory<JwtClaims, 'iss' | 'sub' | 'aud' | 'exp' | 'iat'> & {\n\t/**\n\t * The authentication time, indicating when the user was authenticated.\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tauth_time?: number;\n\n\t/**\n\t * A nonce value used to associate a client session with an ID token, preventing replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'nonce-value-1234'\n\t */\n\tnonce?: string;\n\n\t/**\n\t * The Authentication Context Class Reference, indicating the authentication methods used.\n\t *\n\t * @type {string}\n\t * @example '2'\n\t */\n\tacr?: string;\n\n\t/**\n\t * The Authentication Methods References, providing information about the authentication methods used.\n\t *\n\t * @type {unknown}\n\t */\n\tamr?: unknown;\n\n\t/**\n\t * Authorized party, the client that the ID token is intended for.\n\t *\n\t * @type {string}\n\t * @example 'client-id'\n\t */\n\tazp?: string;\n\n\t/**\n\t * Session ID for the user, which can be used to manage user sessions.\n\t *\n\t * @type {string}\n\t * @example 'session-id-1234'\n\t */\n\tsid?: string;\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[key: string]: any;\n};\n\n/**\n * Options for configuring the SDK.\n */\nexport type SDKOptions = {\n\t/**\n\t * Specifies the mode of the SDK operation, either 'popup' or 'redirect'.\n\t *\n\t * @type {'popup' | 'redirect'}\n\t * @default 'redirect'\n\t */\n\tmode?: 'popup' | 'redirect';\n\n\t/**\n\t * The issuer of the tokens, typically the URL of the authorization server.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The client ID issued by the authorization server, used to identify the application.\n\t *\n\t * @type {string}\n\t * @example 'your-client-id'\n\t */\n\tclientId: string;\n\n\t/**\n\t * The URI to which the user will be redirected after authentication or authorization.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/callback'\n\t */\n\tredirectUri: string;\n\n\t/**\n\t * A list of scopes requested by the application, defining the access levels for the tokens.\n\t *\n\t * @type {Array<string>}\n\t * @default ['openid']\n\t * @example ['openid', 'profile']\n\t */\n\tscopes?: Array<string>;\n\n\t/**\n\t * The type of response expected from the authorization server.\n\t *\n\t * @type {ResponseType}\n\t * @default 'code'\n\t */\n\tresponseType?: ResponseType;\n\n\t/**\n\t * The mode in which the response is returned from the authorization server.\n\t *\n\t * @type {ResponseMode}\n\t * @default 'query'\n\t */\n\tresponseMode?: ResponseMode;\n\n\t/**\n\t * The name of the token in storage used to persist authentication information.\n\t *\n\t * @type {string}\n\t * @default 'sty.session'\n\t * @example 'accessToken'\n\t */\n\tstorageTokenName?: string;\n\n\t/**\n\t * The storage mechanism used to save and retrieve authentication information.\n\t *\n\t * @type {SDKStorageType}\n\t * @default LocalStorage\n\t */\n\tstorage?: SDKStorageType;\n};\n\n/**\n * Abstract class for SDK storage mechanisms.\n */\nexport abstract class SDKStorage {\n\t/**\n\t * Retrieves an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to retrieve.\n\t * @returns {string | null} The value associated with the key, or `null` if not found.\n\t */\n\tabstract get(key: string): string | null;\n\n\t/**\n\t * Deletes an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to delete.\n\t */\n\tabstract delete(key: string): void;\n\n\t/**\n\t * Sets an item in the storage with the specified key and value.\n\t *\n\t * @param {string} key - The key to associate with the value.\n\t * @param {string} value - The value to store.\n\t */\n\tabstract set(key: string, value: string): void;\n}\n\n/**\n * Type representing a constructor function for SDKStorage.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SDKStorageType = new (...args: Array<any>) => SDKStorage;\n\n/**\n * A collection of functions used to handle various events that occur within the SDK.\n */\nexport type EventFunctions = {\n\t/**\n\t * Handler called when an access token has expired.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The expired access token.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the access token, if available.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\taccessTokenExpired: (params: { accessToken: string; refreshToken?: string | null }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when the SDK is initialized.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the initialization is complete, or void if no asynchronous operation is needed.\n\t */\n\tinit: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user has successfully logged in.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token obtained after login.\n\t * @param {string | null} [params.refreshToken] - The refresh token obtained after login, if available.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\tloggedIn: (params: { accessToken: string; refreshToken?: string | null; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when login has been initiated.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the login initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tloginInitiated: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a logout request has been initiated.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.idToken - The ID token associated with the logout request.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the logout initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tlogoutInitiated: (params: { idToken: string; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user session has been successfully loaded.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token associated with the loaded session.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the session, if available.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token in the session.\n\t * @returns {Promise<void> | void} A promise that resolves when the session loading is complete, or void if no asynchronous operation is needed.\n\t */\n\tsessionLoaded: (params: { accessToken: string; refreshToken?: string | null; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when an access token has been successfully refreshed.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The new access token obtained after the refresh.\n\t * @param {string} params.refreshToken - The refresh token used to obtain the new access token.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the new ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the token refresh is complete, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshed: (params: { accessToken: string; refreshToken: string; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token refresh operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.refreshToken - The refresh token that was used in the failed refresh operation.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshFailed: (params: { refreshToken: string }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token has been successfully revoked.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevoked: (params: { token: string; tokenTypeHint: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token revocation operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was attempted to be revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was attempted to be revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevokeFailed: (params: { token: string; tokenTypeHint: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n};\n\n// endregion\n\n// region Flows\n\n/**\n * Extra parameters that can be used in requests.\n */\n/**\n * Additional parameters that can be included in authentication or authorization requests.\n */\nexport type ExtraRequestArgs = {\n\t/**\n\t * Specifies the type of prompt to display to the user during authentication or authorization.\n\t *\n\t * @type {PromptType}\n\t * @example 'none' | 'login' | 'create'\n\t */\n\tprompt?: PromptType;\n\n\t/**\n\t * Provides a hint to the authorization server about the user's email or username.\n\t *\n\t * @type {string}\n\t * @example 'user@example.com'\n\t */\n\tloginHint?: string;\n\n\t/**\n\t * A list of values used to request specific authentication contexts or levels of assurance.\n\t *\n\t * This parameter allows requesting specific authentication contexts (e.g., multi-factor authentication)\n\t * or other criteria that the authorization server should consider when authenticating the user.\n\t *\n\t * @type {Array<string>}\n\t * @example ['urn:mace:incommon:iap:bronze', 'urn:mace:incommon:iap:silver']\n\t */\n\tacrValues?: Array<string>;\n\n\t/**\n\t * A list of locale codes to request specific language and regional preferences for the user interface.\n\t *\n\t * This parameter allows requesting the user interface to be presented in specific languages or regional formats.\n\t *\n\t * @type {Array<string>}\n\t * @example ['en-US', 'fr-CA']\n\t */\n\tuiLocales?: Array<string>;\n};\n\n/**\n * Options for configuring logout behavior.\n */\nexport type LogoutOptions = {\n\t/**\n\t * The URI to redirect to after a successful logout.\n\t *\n\t * If specified, the user will be redirected to this URI upon completing the logout process.\n\t * This is often used to send users back to the main application or a custom post-logout page.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/home'\n\t */\n\tpostLogoutRedirectUri?: string;\n};\n\n/**\n * List of select option types.\n */\nexport const SelectOptionTypeList = ['item', 'group'] as const;\n/**\n * Type representing valid select option types.\n */\nexport type SelectOptionType = (typeof SelectOptionTypeList)[number];\n\n/**\n * Data for branding purposes, such as logo and brand name.\n */\nexport type BrandingData = {\n\tlogoUrl: string | null;\n\tbrandName: string | null;\n\tcopyright: string | null;\n\tprivacyPolicyUrl: string | null;\n\tsiteTermsUrl: string | null;\n};\n\n/**\n * Parameters for redirect authentication flow.\n */\nexport type RedirectParams = ExtraRequestArgs & {\n\t/**\n\t * The method used to update the browser's location after authentication or authorization.\n\t *\n\t * Determines whether the new URL should replace the current URL in the history or be added to it.\n\t *\n\t * @type {'replace' | 'assign'}\n\t * @default 'assign'\n\t */\n\tlocationMethod?: 'replace' | 'assign';\n\n\t/**\n\t * The window in which the redirect should occur.\n\t *\n\t * Specifies whether the redirect should happen in the top-level window or the current window.\n\t *\n\t * @type {'top' | 'self'}\n\t * @default 'self'\n\t */\n\ttargetWindow?: 'top' | 'self';\n};\n\n/**\n * Features for customizing the popup window.\n */\nexport type PopupWindowFeatures = {\n\t/**\n\t * The horizontal position of the popup window relative to the left edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\tleft?: number;\n\n\t/**\n\t * The vertical position of the popup window relative to the top edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\ttop?: number;\n\n\t/**\n\t * The width of the popup window.\n\t *\n\t * @type {number}\n\t * @example 600\n\t */\n\twidth?: number;\n\n\t/**\n\t * The height of the popup window.\n\t *\n\t * @type {number}\n\t * @example 400\n\t */\n\theight?: number;\n\n\t/**\n\t * Whether the popup window should display a menubar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tmenubar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a toolbar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\ttoolbar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display the address/location bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tlocation?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a status bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tstatus?: boolean | string;\n\n\t/**\n\t * Whether the popup window should be resizable.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tresizable?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display scrollbars.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tscrollbars?: boolean | string;\n\n\t[key: string]: boolean | string | number | undefined;\n};\n\n/**\n * Parameters for popup authentication flow.\n */\nexport type PopupWindowParams = ExtraRequestArgs & {\n\t/**\n\t * Configuration options for the popup window, including size, position, and other features.\n\t *\n\t * @type {PopupWindowFeatures}\n\t */\n\tpopupWindowFeatures?: PopupWindowFeatures;\n\n\t/**\n\t * The target of the popup window, which specifies where the popup should be opened.\n\t *\n\t * @type {string}\n\t * @example '_blank' | '_self' | '_parent' | '_top'\n\t */\n\tpopupWindowTarget?: string;\n};\n\n// endregion\n"],"names":["ResponseTypeList","ResponseModeList","TokenEndpointAuthMethodList","GrantTypeList","AlgorithmTypeList","SubjectTypeList","PromptTypeList","FallbackModeTypeList","SDKStorage","SelectOptionTypeList"],"mappings":"AA6Ba,MAAAA,EAAmB,CAAC,OAAQ,UAAU,EAStCC,EAAmB,CAAC,QAAS,UAAU,EASvCC,EAA8B,CAAC,MAAM,EASrCC,EAAgB,CAAC,qBAAsB,eAAe,EAStDC,EAAoB,CAAC,OAAO,EAS5BC,EAAkB,CAAC,QAAQ,EAS3BC,EAAiB,CAAC,OAAQ,QAAS,QAAQ,EAS3CC,EAAuB,CAAC,WAAY,OAAO,EA8ejD,MAAeC,CAAW,CAuBjC,CAiLa,MAAAC,EAAuB,CAAC,OAAQ,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e){if(typeof e=="string")return e;const n=String.fromCharCode.apply(null,[...new Uint8Array(e)]);return btoa(n).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function a(e){if(typeof e!="string")return e;const n=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,""),r=atob(n),t=new Uint8Array(r.length);for(let o=0;o<r.length;o++)t[o]=r.charCodeAt(o);return t.buffer}function i(e){return decodeURIComponent(atob(e).replace(/(.)/g,(n,r)=>{let t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t}))}const l={encode:c,decode:a,decodeUnicode:i};exports.Base64Url=l;
|
|
2
|
+
//# sourceMappingURL=base64Url.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64Url.cjs","sources":["../../src/utils/base64Url.ts"],"sourcesContent":["/**\n * Encodes a buffer or string into a Base64 URL-safe string.\n *\n * @param {string | null | BufferSource | ArrayBuffer} buffer The buffer or string to encode.\n * @returns {string} The Base64 URL-encoded string.\n */\nfunction encode(buffer: string | null | BufferSource | ArrayBuffer): string {\n\tif (typeof buffer === 'string') {\n\t\treturn buffer;\n\t}\n\n\tconst str = String.fromCharCode.apply(null, [...new Uint8Array(buffer as ArrayBuffer)]);\n\n\treturn btoa(str).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\n/**\n * Decodes a Base64 URL-safe string into an ArrayBuffer.\n *\n * @param {string | BufferSource} base64Url The Base64 URL-safe string or BufferSource to decode.\n * @returns {ArrayBuffer} The decoded ArrayBuffer.\n */\nfunction decode(base64Url: string | BufferSource): ArrayBuffer {\n\tif (typeof base64Url !== 'string') {\n\t\treturn base64Url as ArrayBuffer;\n\t}\n\n\tconst base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n\tconst binStr = atob(base64);\n\tconst binary = new Uint8Array(binStr.length);\n\n\tfor (let i = 0; i < binStr.length; i++) {\n\t\tbinary[i] = binStr.charCodeAt(i);\n\t}\n\n\treturn binary.buffer;\n}\n\n/**\n * Decodes a Base64 URL-safe string into a UTF-8 string.\n *\n * @param {string} base64Url The Base64 URL-safe string to decode.\n * @returns {string} The decoded Unicode string.\n */\nfunction decodeUnicode(base64Url: string): string {\n\treturn decodeURIComponent(\n\t\tatob(base64Url).replace(/(.)/g, (m, p) => {\n\t\t\tlet code = (p as string).charCodeAt(0).toString(16).toUpperCase();\n\t\t\tif (code.length < 2) {\n\t\t\t\tcode = '0' + code;\n\t\t\t}\n\t\t\treturn '%' + code;\n\t\t}),\n\t);\n}\n\nexport const Base64Url = {\n\tencode,\n\tdecode,\n\tdecodeUnicode,\n};\n"],"names":["encode","buffer","str","decode","base64Url","base64","binStr","binary","i","decodeUnicode","m","p","code","Base64Url"],"mappings":"gFAMA,SAASA,EAAOC,EAA4D,CACvE,GAAA,OAAOA,GAAW,SACd,OAAAA,EAGF,MAAAC,EAAM,OAAO,aAAa,MAAM,KAAM,CAAC,GAAG,IAAI,WAAWD,CAAqB,CAAC,CAAC,EAEtF,OAAO,KAAKC,CAAG,EAAE,QAAQ,KAAM,EAAE,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,MAAO,GAAG,CAC1E,CAQA,SAASC,EAAOC,EAA+C,CAC1D,GAAA,OAAOA,GAAc,SACjB,OAAAA,EAGR,MAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAAE,QAAQ,MAAO,EAAE,EAC1EE,EAAS,KAAKD,CAAM,EACpBE,EAAS,IAAI,WAAWD,EAAO,MAAM,EAE3C,QAASE,EAAI,EAAGA,EAAIF,EAAO,OAAQE,IAClCD,EAAOC,CAAC,EAAIF,EAAO,WAAWE,CAAC,EAGhC,OAAOD,EAAO,MACf,CAQA,SAASE,EAAcL,EAA2B,CAC1C,OAAA,mBACN,KAAKA,CAAS,EAAE,QAAQ,OAAQ,CAACM,EAAGC,IAAM,CACrC,IAAAC,EAAQD,EAAa,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,cAChD,OAAAC,EAAK,OAAS,IACjBA,EAAO,IAAMA,GAEP,IAAMA,CAAA,CACb,CAAA,CAEH,CAEO,MAAMC,EAAY,CACxB,OAAAb,EACA,OAAAG,EACA,cAAAM,CACD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a buffer or string into a Base64 URL-safe string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string | null | BufferSource | ArrayBuffer} buffer The buffer or string to encode.
|
|
5
|
+
* @returns {string} The Base64 URL-encoded string.
|
|
6
|
+
*/
|
|
7
|
+
declare function encode(buffer: string | null | BufferSource | ArrayBuffer): string;
|
|
8
|
+
/**
|
|
9
|
+
* Decodes a Base64 URL-safe string into an ArrayBuffer.
|
|
10
|
+
*
|
|
11
|
+
* @param {string | BufferSource} base64Url The Base64 URL-safe string or BufferSource to decode.
|
|
12
|
+
* @returns {ArrayBuffer} The decoded ArrayBuffer.
|
|
13
|
+
*/
|
|
14
|
+
declare function decode(base64Url: string | BufferSource): ArrayBuffer;
|
|
15
|
+
/**
|
|
16
|
+
* Decodes a Base64 URL-safe string into a UTF-8 string.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} base64Url The Base64 URL-safe string to decode.
|
|
19
|
+
* @returns {string} The decoded Unicode string.
|
|
20
|
+
*/
|
|
21
|
+
declare function decodeUnicode(base64Url: string): string;
|
|
22
|
+
export declare const Base64Url: {
|
|
23
|
+
encode: typeof encode;
|
|
24
|
+
decode: typeof decode;
|
|
25
|
+
decodeUnicode: typeof decodeUnicode;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function c(e){if(typeof e=="string")return e;const r=String.fromCharCode.apply(null,[...new Uint8Array(e)]);return btoa(r).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function a(e){if(typeof e!="string")return e;const r=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,""),n=atob(r),t=new Uint8Array(n.length);for(let o=0;o<n.length;o++)t[o]=n.charCodeAt(o);return t.buffer}function i(e){return decodeURIComponent(atob(e).replace(/(.)/g,(r,n)=>{let t=n.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t}))}const p={encode:c,decode:a,decodeUnicode:i};export{p as Base64Url};
|
|
2
|
+
//# sourceMappingURL=base64Url.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64Url.mjs","sources":["../../src/utils/base64Url.ts"],"sourcesContent":["/**\n * Encodes a buffer or string into a Base64 URL-safe string.\n *\n * @param {string | null | BufferSource | ArrayBuffer} buffer The buffer or string to encode.\n * @returns {string} The Base64 URL-encoded string.\n */\nfunction encode(buffer: string | null | BufferSource | ArrayBuffer): string {\n\tif (typeof buffer === 'string') {\n\t\treturn buffer;\n\t}\n\n\tconst str = String.fromCharCode.apply(null, [...new Uint8Array(buffer as ArrayBuffer)]);\n\n\treturn btoa(str).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\n/**\n * Decodes a Base64 URL-safe string into an ArrayBuffer.\n *\n * @param {string | BufferSource} base64Url The Base64 URL-safe string or BufferSource to decode.\n * @returns {ArrayBuffer} The decoded ArrayBuffer.\n */\nfunction decode(base64Url: string | BufferSource): ArrayBuffer {\n\tif (typeof base64Url !== 'string') {\n\t\treturn base64Url as ArrayBuffer;\n\t}\n\n\tconst base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n\tconst binStr = atob(base64);\n\tconst binary = new Uint8Array(binStr.length);\n\n\tfor (let i = 0; i < binStr.length; i++) {\n\t\tbinary[i] = binStr.charCodeAt(i);\n\t}\n\n\treturn binary.buffer;\n}\n\n/**\n * Decodes a Base64 URL-safe string into a UTF-8 string.\n *\n * @param {string} base64Url The Base64 URL-safe string to decode.\n * @returns {string} The decoded Unicode string.\n */\nfunction decodeUnicode(base64Url: string): string {\n\treturn decodeURIComponent(\n\t\tatob(base64Url).replace(/(.)/g, (m, p) => {\n\t\t\tlet code = (p as string).charCodeAt(0).toString(16).toUpperCase();\n\t\t\tif (code.length < 2) {\n\t\t\t\tcode = '0' + code;\n\t\t\t}\n\t\t\treturn '%' + code;\n\t\t}),\n\t);\n}\n\nexport const Base64Url = {\n\tencode,\n\tdecode,\n\tdecodeUnicode,\n};\n"],"names":["encode","buffer","str","decode","base64Url","base64","binStr","binary","i","decodeUnicode","m","p","code","Base64Url"],"mappings":"AAMA,SAASA,EAAOC,EAA4D,CACvE,GAAA,OAAOA,GAAW,SACd,OAAAA,EAGF,MAAAC,EAAM,OAAO,aAAa,MAAM,KAAM,CAAC,GAAG,IAAI,WAAWD,CAAqB,CAAC,CAAC,EAEtF,OAAO,KAAKC,CAAG,EAAE,QAAQ,KAAM,EAAE,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,MAAO,GAAG,CAC1E,CAQA,SAASC,EAAOC,EAA+C,CAC1D,GAAA,OAAOA,GAAc,SACjB,OAAAA,EAGR,MAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAAE,QAAQ,MAAO,EAAE,EAC1EE,EAAS,KAAKD,CAAM,EACpBE,EAAS,IAAI,WAAWD,EAAO,MAAM,EAE3C,QAASE,EAAI,EAAGA,EAAIF,EAAO,OAAQE,IAClCD,EAAOC,CAAC,EAAIF,EAAO,WAAWE,CAAC,EAGhC,OAAOD,EAAO,MACf,CAQA,SAASE,EAAcL,EAA2B,CAC1C,OAAA,mBACN,KAAKA,CAAS,EAAE,QAAQ,OAAQ,CAACM,EAAGC,IAAM,CACrC,IAAAC,EAAQD,EAAa,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,cAChD,OAAAC,EAAK,OAAS,IACjBA,EAAO,IAAMA,GAEP,IAAMA,CAAA,CACb,CAAA,CAEH,CAEO,MAAMC,EAAY,CACxB,OAAAb,EACA,OAAAG,EACA,cAAAM,CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["../../src/utils/constants.ts"],"sourcesContent":["/**\n * Determines if the code is running in a browser environment.\n *\n * @type {boolean}\n */\nexport const isBrowser = typeof window !== 'undefined';\n"],"names":["isBrowser"],"mappings":"gFAKa,MAAAA,EAAY,OAAO,OAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../src/utils/constants.ts"],"sourcesContent":["/**\n * Determines if the code is running in a browser environment.\n *\n * @type {boolean}\n */\nexport const isBrowser = typeof window !== 'undefined';\n"],"names":["isBrowser"],"mappings":"AAKa,MAAAA,EAAY,OAAO,OAAW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./base64Url.cjs");function t(){return crypto.randomUUID().replace(/-/g,"")}function n(){return crypto.randomUUID().replace(/-/g,"")}function o(){return`${crypto.randomUUID()}${crypto.randomUUID()}`.replace(/-/g,"")}async function c(e){return r.Base64Url.encode(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)))}const a={generateState:t,generateNonce:n,generateCodeVerifier:o,generateCodeChallenge:c};exports.Crypto=a;
|
|
2
|
+
//# sourceMappingURL=crypto.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.cjs","sources":["../../src/utils/crypto.ts"],"sourcesContent":["import { Base64Url } from './base64Url';\n\n/**\n * Generates a unique state string using UUID, suitable for OAuth flows.\n *\n * @returns {string} A randomly generated state string.\n */\nfunction generateState(): string {\n\treturn crypto.randomUUID().replace(/-/g, '');\n}\n\n/**\n * Generates a unique nonce using UUID, suitable for security in OAuth flows.\n *\n * @returns {string} A randomly generated nonce string.\n */\nfunction generateNonce(): string {\n\treturn crypto.randomUUID().replace(/-/g, '');\n}\n\n/**\n * Generates a code verifier for PKCE (Proof Key for Code Exchange).\n *\n * @returns {string} A randomly generated code verifier string.\n */\nfunction generateCodeVerifier(): string {\n\treturn `${crypto.randomUUID()}${crypto.randomUUID()}`.replace(/-/g, '');\n}\n\n/**\n * Generates a code challenge from a code verifier using SHA-256 hashing.\n *\n * @param {string} codeVerifier The code verifier string.\n * @returns {Promise<string>} A promise that resolves to the generated code challenge.\n */\nasync function generateCodeChallenge(codeVerifier: string): Promise<string> {\n\treturn Base64Url.encode(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(codeVerifier)));\n}\n\nexport const Crypto = {\n\tgenerateState,\n\tgenerateNonce,\n\tgenerateCodeVerifier,\n\tgenerateCodeChallenge,\n};\n"],"names":["generateState","generateNonce","generateCodeVerifier","generateCodeChallenge","codeVerifier","Base64Url","Crypto"],"mappings":"mHAOA,SAASA,GAAwB,CAChC,OAAO,OAAO,WAAa,EAAA,QAAQ,KAAM,EAAE,CAC5C,CAOA,SAASC,GAAwB,CAChC,OAAO,OAAO,WAAa,EAAA,QAAQ,KAAM,EAAE,CAC5C,CAOA,SAASC,GAA+B,CAChC,MAAA,GAAG,OAAO,WAAA,CAAY,GAAG,OAAO,WAAY,CAAA,GAAG,QAAQ,KAAM,EAAE,CACvE,CAQA,eAAeC,EAAsBC,EAAuC,CAC3E,OAAOC,EAAU,UAAA,OAAO,MAAM,OAAO,OAAO,OAAO,UAAW,IAAI,YAAY,EAAE,OAAOD,CAAY,CAAC,CAAC,CACtG,CAEO,MAAME,EAAS,CACrB,cAAAN,EACA,cAAAC,EACA,qBAAAC,EACA,sBAAAC,CACD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique state string using UUID, suitable for OAuth flows.
|
|
3
|
+
*
|
|
4
|
+
* @returns {string} A randomly generated state string.
|
|
5
|
+
*/
|
|
6
|
+
declare function generateState(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Generates a unique nonce using UUID, suitable for security in OAuth flows.
|
|
9
|
+
*
|
|
10
|
+
* @returns {string} A randomly generated nonce string.
|
|
11
|
+
*/
|
|
12
|
+
declare function generateNonce(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a code verifier for PKCE (Proof Key for Code Exchange).
|
|
15
|
+
*
|
|
16
|
+
* @returns {string} A randomly generated code verifier string.
|
|
17
|
+
*/
|
|
18
|
+
declare function generateCodeVerifier(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Generates a code challenge from a code verifier using SHA-256 hashing.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} codeVerifier The code verifier string.
|
|
23
|
+
* @returns {Promise<string>} A promise that resolves to the generated code challenge.
|
|
24
|
+
*/
|
|
25
|
+
declare function generateCodeChallenge(codeVerifier: string): Promise<string>;
|
|
26
|
+
export declare const Crypto: {
|
|
27
|
+
generateState: typeof generateState;
|
|
28
|
+
generateNonce: typeof generateNonce;
|
|
29
|
+
generateCodeVerifier: typeof generateCodeVerifier;
|
|
30
|
+
generateCodeChallenge: typeof generateCodeChallenge;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Base64Url as r}from"./base64Url.mjs";function n(){return crypto.randomUUID().replace(/-/g,"")}function t(){return crypto.randomUUID().replace(/-/g,"")}function o(){return`${crypto.randomUUID()}${crypto.randomUUID()}`.replace(/-/g,"")}async function c(e){return r.encode(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)))}const p={generateState:n,generateNonce:t,generateCodeVerifier:o,generateCodeChallenge:c};export{p as Crypto};
|
|
2
|
+
//# sourceMappingURL=crypto.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.mjs","sources":["../../src/utils/crypto.ts"],"sourcesContent":["import { Base64Url } from './base64Url';\n\n/**\n * Generates a unique state string using UUID, suitable for OAuth flows.\n *\n * @returns {string} A randomly generated state string.\n */\nfunction generateState(): string {\n\treturn crypto.randomUUID().replace(/-/g, '');\n}\n\n/**\n * Generates a unique nonce using UUID, suitable for security in OAuth flows.\n *\n * @returns {string} A randomly generated nonce string.\n */\nfunction generateNonce(): string {\n\treturn crypto.randomUUID().replace(/-/g, '');\n}\n\n/**\n * Generates a code verifier for PKCE (Proof Key for Code Exchange).\n *\n * @returns {string} A randomly generated code verifier string.\n */\nfunction generateCodeVerifier(): string {\n\treturn `${crypto.randomUUID()}${crypto.randomUUID()}`.replace(/-/g, '');\n}\n\n/**\n * Generates a code challenge from a code verifier using SHA-256 hashing.\n *\n * @param {string} codeVerifier The code verifier string.\n * @returns {Promise<string>} A promise that resolves to the generated code challenge.\n */\nasync function generateCodeChallenge(codeVerifier: string): Promise<string> {\n\treturn Base64Url.encode(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(codeVerifier)));\n}\n\nexport const Crypto = {\n\tgenerateState,\n\tgenerateNonce,\n\tgenerateCodeVerifier,\n\tgenerateCodeChallenge,\n};\n"],"names":["generateState","generateNonce","generateCodeVerifier","generateCodeChallenge","codeVerifier","Base64Url","Crypto"],"mappings":"4CAOA,SAASA,GAAwB,CAChC,OAAO,OAAO,WAAa,EAAA,QAAQ,KAAM,EAAE,CAC5C,CAOA,SAASC,GAAwB,CAChC,OAAO,OAAO,WAAa,EAAA,QAAQ,KAAM,EAAE,CAC5C,CAOA,SAASC,GAA+B,CAChC,MAAA,GAAG,OAAO,WAAA,CAAY,GAAG,OAAO,WAAY,CAAA,GAAG,QAAQ,KAAM,EAAE,CACvE,CAQA,eAAeC,EAAsBC,EAAuC,CAC3E,OAAOC,EAAU,OAAO,MAAM,OAAO,OAAO,OAAO,UAAW,IAAI,YAAY,EAAE,OAAOD,CAAY,CAAC,CAAC,CACtG,CAEO,MAAME,EAAS,CACrB,cAAAN,EACA,cAAAC,EACA,qBAAAC,EACA,sBAAAC,CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.cjs","sources":["../../src/utils/date.ts"],"sourcesContent":["/**\n * Returns the current Unix timestamp (seconds since the epoch).\n *\n * @returns {number} The current timestamp in seconds.\n */\nexport function timestamp(): number {\n\treturn Math.floor(Date.now() / 1000);\n}\n"],"names":["timestamp"],"mappings":"gFAKO,SAASA,GAAoB,CACnC,OAAO,KAAK,MAAM,KAAK,MAAQ,GAAI,CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.mjs","sources":["../../src/utils/date.ts"],"sourcesContent":["/**\n * Returns the current Unix timestamp (seconds since the epoch).\n *\n * @returns {number} The current timestamp in seconds.\n */\nexport function timestamp(): number {\n\treturn Math.floor(Date.now() / 1000);\n}\n"],"names":["timestamp"],"mappings":"AAKO,SAASA,GAAoB,CACnC,OAAO,KAAK,MAAM,KAAK,MAAQ,GAAI,CACpC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var E=Object.defineProperty;var S=(r,t,e)=>t in r?E(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var h=(r,t,e)=>S(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class w extends Error{constructor(e,s,o){const n=e.status||e.status===0?e.status:"",i=e.statusText||"",a=`${n} ${i}`.trim(),u=a?`status code ${a}`:"an unknown error";super(`Request failed with ${u}: ${s.method} ${s.url}`);h(this,"response");h(this,"request");h(this,"options");this.name="HTTPError",this.response=e,this.request=s,this.options=o}}class T extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`);h(this,"request");this.name="TimeoutError",this.request=e}}const p=r=>r!==null&&typeof r=="object",l=(...r)=>{for(const t of r)if((!p(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return _({},...r)},g=(r={},t={})=>{const e=new globalThis.Headers(r),s=t instanceof globalThis.Headers,o=new globalThis.Headers(t);for(const[n,i]of o.entries())s&&i==="undefined"||i===void 0?e.delete(n):e.set(n,i);return e};function d(r,t,e){return Object.hasOwn(t,e)&&t[e]===void 0?[]:_(r[e]??[],t[e]??[])}const q=(r={},t={})=>({beforeRequest:d(r,t,"beforeRequest"),beforeRetry:d(r,t,"beforeRetry"),afterResponse:d(r,t,"afterResponse"),beforeError:d(r,t,"beforeError")}),_=(...r)=>{let t={},e={},s={};for(const o of r)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(p(o)){for(let[n,i]of Object.entries(o))p(i)&&n in t&&(i=_(t[n],i)),t={...t,[n]:i};p(o.hooks)&&(s=q(s,o.hooks),t.hooks=s),p(o.headers)&&(e=g(e,o.headers),t.headers=e)}return t},C=(()=>{let r=!1,t=!1;const e=typeof globalThis.ReadableStream=="function",s=typeof globalThis.Request=="function";if(e&&s)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type")}catch(o){if(o instanceof Error&&o.message==="unsupported BodyInit type")return!1;throw o}return r&&!t})(),A=typeof globalThis.AbortController=="function",P=typeof globalThis.ReadableStream=="function",O=typeof globalThis.FormData=="function",k=["get","post","put","patch","head","delete"],I={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},m=2147483647,x=Symbol("stop"),U={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},j={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},L=r=>k.includes(r)?r.toUpperCase():r,H=["get","put","head","delete","options","trace"],v=[408,413,429,500,502,503,504],N=[413,429,503],R={limit:2,methods:H,statusCodes:v,afterStatusCodes:N,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:r=>.3*2**(r-1)*1e3},M=(r={})=>{if(typeof r=="number")return{...R,limit:r};if(r.methods&&!Array.isArray(r.methods))throw new Error("retry.methods must be an array");if(r.statusCodes&&!Array.isArray(r.statusCodes))throw new Error("retry.statusCodes must be an array");return{...R,...r}};async function $(r,t,e,s){return new Promise((o,n)=>{const i=setTimeout(()=>{e&&e.abort(),n(new T(r))},s.timeout);s.fetch(r,t).then(o).catch(n).then(()=>{clearTimeout(i)})})}async function B(r,{signal:t}){return new Promise((e,s)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",o,{once:!0}));function o(){clearTimeout(n),s(t.reason)}const n=setTimeout(()=>{t==null||t.removeEventListener("abort",o),e()},r)})}const D=(r,t)=>{const e={};for(const s in t)!(s in j)&&!(s in U)&&!(s in r)&&(e[s]=t[s]);return e};class y{constructor(t,e={}){h(this,"request");h(this,"abortController");h(this,"_retryCount",0);h(this,"_input");h(this,"_options");var s,o;if(this._input=t,this._options={...e,headers:g(this._input.headers,e.headers),hooks:q({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:L(e.method??this._input.method),prefixUrl:String(e.prefixUrl||""),retry:M(e.retry),throwHttpErrors:e.throwHttpErrors!==!1,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(A){this.abortController=new globalThis.AbortController;const n=this._options.signal??this._input.signal;n==null||n.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(C&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((o=(s=this._options).stringifyJson)==null?void 0:o.call(s,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(O&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}static create(t,e){const s=new y(t,e),o=async()=>{if(typeof s._options.timeout=="number"&&s._options.timeout>m)throw new RangeError(`The \`timeout\` option cannot be greater than ${m}`);await Promise.resolve();let a=await s._fetch();for(const u of s._options.hooks.afterResponse){const c=await u(s.request,s._options,s._decorateResponse(a.clone()));c instanceof globalThis.Response&&(a=c)}if(s._decorateResponse(a),!a.ok&&s._options.throwHttpErrors){let u=new w(a,s.request,s._options);for(const c of s._options.hooks.beforeError)u=await c(u);throw u}if(s._options.onDownloadProgress){if(typeof s._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!P)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return s._stream(a.clone(),s._options.onDownloadProgress)}return a},i=s._options.retry.methods.includes(s.request.method.toLowerCase())?s._retry(o):o();for(const[a,u]of Object.entries(I))i[a]=async()=>{s.request.headers.set("accept",s.request.headers.get("accept")||u);const f=(await i).clone();if(a==="json"){if(f.status===204||(await f.clone().arrayBuffer()).byteLength===0)return"";if(e.parseJson)return e.parseJson(await f.text())}return f[a]()};return i}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof T)throw t;if(t instanceof w){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const s=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(s&&this._options.retry.afterStatusCodes.includes(t.response.status)){let o=Number(s)*1e3;Number.isNaN(o)?o=Date.parse(s)-Date.now():o>=Date.parse("2024-01-01")&&(o-=Date.now());const n=this._options.retry.maxRetryAfter??o;return o<n?o:n}if(t.response.status===413)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const s=Math.min(this._calculateRetryDelay(e),m);if(this._retryCount<1)throw e;await B(s,{signal:this._options.signal});for(const o of this._options.hooks.beforeRetry)if(await o({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===x)return;return this._retry(t)}}async _fetch(){for(const s of this._options.hooks.beforeRequest){const o=await s(this.request,this._options);if(o instanceof Request){this.request=o;break}if(o instanceof Response)return o}const t=D(this.request,this._options),e=this.request;return this.request=e.clone(),this._options.timeout===!1?this._options.fetch(e,t):$(e,t,this.abortController,this._options)}_stream(t,e){const s=Number(t.headers.get("content-length"))||0;let o=0;return t.status===204?(e&&e({percent:1,totalBytes:s,transferredBytes:o},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(n){const i=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:s},new Uint8Array);async function a(){const{done:u,value:c}=await i.read();if(u){n.close();return}if(e){o+=c.byteLength;const f=s===0?0:o/s;e({percent:f,transferredBytes:o,totalBytes:s},c)}n.enqueue(c),await a()}await a()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}/*! MIT License © Sindre Sorhus */const b=r=>{const t=(e,s)=>y.create(e,l(r,s));for(const e of k)t[e]=(s,o)=>y.create(s,l(r,o,{method:e}));return t.create=e=>b(l(e)),t.extend=e=>(typeof e=="function"&&(e=e(r??{})),b(l(r,e))),t.stop=x,t},J=b();exports.fetch=J;
|
|
2
|
+
//# sourceMappingURL=fetch.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.cjs","sources":["../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/errors/HTTPError.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/errors/TimeoutError.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/is.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/merge.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/core/constants.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/normalize.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/timeout.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/delay.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/options.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/core/Ky.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/index.js"],"sourcesContent":["export class HTTPError extends Error {\n response;\n request;\n options;\n constructor(response, request, options) {\n const code = (response.status || response.status === 0) ? response.status : '';\n const title = response.statusText || '';\n const status = `${code} ${title}`.trim();\n const reason = status ? `status code ${status}` : 'an unknown error';\n super(`Request failed with ${reason}: ${request.method} ${request.url}`);\n this.name = 'HTTPError';\n this.response = response;\n this.request = request;\n this.options = options;\n }\n}\n//# sourceMappingURL=HTTPError.js.map","export class TimeoutError extends Error {\n request;\n constructor(request) {\n super(`Request timed out: ${request.method} ${request.url}`);\n this.name = 'TimeoutError';\n this.request = request;\n }\n}\n//# sourceMappingURL=TimeoutError.js.map","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value) => value !== null && typeof value === 'object';\n//# sourceMappingURL=is.js.map","import { isObject } from './is.js';\nexport const validateAndMerge = (...sources) => {\n for (const source of sources) {\n if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n throw new TypeError('The `options` argument must be an object');\n }\n }\n return deepMerge({}, ...sources);\n};\nexport const mergeHeaders = (source1 = {}, source2 = {}) => {\n const result = new globalThis.Headers(source1);\n const isHeadersInstance = source2 instanceof globalThis.Headers;\n const source = new globalThis.Headers(source2);\n for (const [key, value] of source.entries()) {\n if ((isHeadersInstance && value === 'undefined') || value === undefined) {\n result.delete(key);\n }\n else {\n result.set(key, value);\n }\n }\n return result;\n};\nfunction newHookValue(original, incoming, property) {\n return (Object.hasOwn(incoming, property) && incoming[property] === undefined)\n ? []\n : deepMerge(original[property] ?? [], incoming[property] ?? []);\n}\nexport const mergeHooks = (original = {}, incoming = {}) => ({\n beforeRequest: newHookValue(original, incoming, 'beforeRequest'),\n beforeRetry: newHookValue(original, incoming, 'beforeRetry'),\n afterResponse: newHookValue(original, incoming, 'afterResponse'),\n beforeError: newHookValue(original, incoming, 'beforeError'),\n});\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = (...sources) => {\n let returnValue = {};\n let headers = {};\n let hooks = {};\n for (const source of sources) {\n if (Array.isArray(source)) {\n if (!Array.isArray(returnValue)) {\n returnValue = [];\n }\n returnValue = [...returnValue, ...source];\n }\n else if (isObject(source)) {\n for (let [key, value] of Object.entries(source)) {\n if (isObject(value) && key in returnValue) {\n value = deepMerge(returnValue[key], value);\n }\n returnValue = { ...returnValue, [key]: value };\n }\n if (isObject(source.hooks)) {\n hooks = mergeHooks(hooks, source.hooks);\n returnValue.hooks = hooks;\n }\n if (isObject(source.headers)) {\n headers = mergeHeaders(headers, source.headers);\n returnValue.headers = headers;\n }\n }\n }\n return returnValue;\n};\n//# sourceMappingURL=merge.js.map","export const supportsRequestStreams = (() => {\n let duplexAccessed = false;\n let hasContentType = false;\n const supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n const supportsRequest = typeof globalThis.Request === 'function';\n if (supportsReadableStream && supportsRequest) {\n try {\n hasContentType = new globalThis.Request('https://empty.invalid', {\n body: new globalThis.ReadableStream(),\n method: 'POST',\n // @ts-expect-error - Types are outdated.\n get duplex() {\n duplexAccessed = true;\n return 'half';\n },\n }).headers.has('Content-Type');\n }\n catch (error) {\n // QQBrowser on iOS throws \"unsupported BodyInit type\" error (see issue #581)\n if (error instanceof Error && error.message === 'unsupported BodyInit type') {\n return false;\n }\n throw error;\n }\n }\n return duplexAccessed && !hasContentType;\n})();\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'];\nconst validate = () => undefined;\nvalidate();\nexport const responseTypes = {\n json: 'application/json',\n text: 'text/*',\n formData: 'multipart/form-data',\n arrayBuffer: '*/*',\n blob: '*/*',\n};\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\nexport const stop = Symbol('stop');\nexport const kyOptionKeys = {\n json: true,\n parseJson: true,\n stringifyJson: true,\n searchParams: true,\n prefixUrl: true,\n retry: true,\n timeout: true,\n hooks: true,\n throwHttpErrors: true,\n onDownloadProgress: true,\n fetch: true,\n};\nexport const requestOptionsRegistry = {\n method: true,\n headers: true,\n body: true,\n mode: true,\n credentials: true,\n cache: true,\n redirect: true,\n referrer: true,\n referrerPolicy: true,\n integrity: true,\n keepalive: true,\n signal: true,\n window: true,\n dispatcher: true,\n duplex: true,\n priority: true,\n};\n//# sourceMappingURL=constants.js.map","import { requestMethods } from '../core/constants.js';\nexport const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\nconst retryAfterStatusCodes = [413, 429, 503];\nconst defaultRetryOptions = {\n limit: 2,\n methods: retryMethods,\n statusCodes: retryStatusCodes,\n afterStatusCodes: retryAfterStatusCodes,\n maxRetryAfter: Number.POSITIVE_INFINITY,\n backoffLimit: Number.POSITIVE_INFINITY,\n delay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n};\nexport const normalizeRetryOptions = (retry = {}) => {\n if (typeof retry === 'number') {\n return {\n ...defaultRetryOptions,\n limit: retry,\n };\n }\n if (retry.methods && !Array.isArray(retry.methods)) {\n throw new Error('retry.methods must be an array');\n }\n if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n throw new Error('retry.statusCodes must be an array');\n }\n return {\n ...defaultRetryOptions,\n ...retry,\n };\n};\n//# sourceMappingURL=normalize.js.map","import { TimeoutError } from '../errors/TimeoutError.js';\n// `Promise.race()` workaround (#91)\nexport default async function timeout(request, init, abortController, options) {\n return new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n if (abortController) {\n abortController.abort();\n }\n reject(new TimeoutError(request));\n }, options.timeout);\n void options\n .fetch(request, init)\n .then(resolve)\n .catch(reject)\n .then(() => {\n clearTimeout(timeoutId);\n });\n });\n}\n//# sourceMappingURL=timeout.js.map","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\nexport default async function delay(ms, { signal }) {\n return new Promise((resolve, reject) => {\n if (signal) {\n signal.throwIfAborted();\n signal.addEventListener('abort', abortHandler, { once: true });\n }\n function abortHandler() {\n clearTimeout(timeoutId);\n reject(signal.reason);\n }\n const timeoutId = setTimeout(() => {\n signal?.removeEventListener('abort', abortHandler);\n resolve();\n }, ms);\n });\n}\n//# sourceMappingURL=delay.js.map","import { kyOptionKeys, requestOptionsRegistry } from '../core/constants.js';\nexport const findUnknownOptions = (request, options) => {\n const unknownOptions = {};\n for (const key in options) {\n if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {\n unknownOptions[key] = options[key];\n }\n }\n return unknownOptions;\n};\n//# sourceMappingURL=options.js.map","import { HTTPError } from '../errors/HTTPError.js';\nimport { TimeoutError } from '../errors/TimeoutError.js';\nimport { mergeHeaders, mergeHooks } from '../utils/merge.js';\nimport { normalizeRequestMethod, normalizeRetryOptions } from '../utils/normalize.js';\nimport timeout from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport { findUnknownOptions } from '../utils/options.js';\nimport { maxSafeTimeout, responseTypes, stop, supportsAbortController, supportsFormData, supportsResponseStreams, supportsRequestStreams, } from './constants.js';\nexport class Ky {\n static create(input, options) {\n const ky = new Ky(input, options);\n const function_ = async () => {\n if (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n throw new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n }\n // Delay the fetch so that body method shortcuts can set the Accept header\n await Promise.resolve();\n let response = await ky._fetch();\n for (const hook of ky._options.hooks.afterResponse) {\n // eslint-disable-next-line no-await-in-loop\n const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));\n if (modifiedResponse instanceof globalThis.Response) {\n response = modifiedResponse;\n }\n }\n ky._decorateResponse(response);\n if (!response.ok && ky._options.throwHttpErrors) {\n let error = new HTTPError(response, ky.request, ky._options);\n for (const hook of ky._options.hooks.beforeError) {\n // eslint-disable-next-line no-await-in-loop\n error = await hook(error);\n }\n throw error;\n }\n // If `onDownloadProgress` is passed, it uses the stream API internally\n /* istanbul ignore next */\n if (ky._options.onDownloadProgress) {\n if (typeof ky._options.onDownloadProgress !== 'function') {\n throw new TypeError('The `onDownloadProgress` option must be a function');\n }\n if (!supportsResponseStreams) {\n throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n }\n return ky._stream(response.clone(), ky._options.onDownloadProgress);\n }\n return response;\n };\n const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n const result = (isRetriableMethod ? ky._retry(function_) : function_());\n for (const [type, mimeType] of Object.entries(responseTypes)) {\n result[type] = async () => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n const awaitedResult = await result;\n const response = awaitedResult.clone();\n if (type === 'json') {\n if (response.status === 204) {\n return '';\n }\n const arrayBuffer = await response.clone().arrayBuffer();\n const responseSize = arrayBuffer.byteLength;\n if (responseSize === 0) {\n return '';\n }\n if (options.parseJson) {\n return options.parseJson(await response.text());\n }\n }\n return response[type]();\n };\n }\n return result;\n }\n request;\n abortController;\n _retryCount = 0;\n _input;\n _options;\n // eslint-disable-next-line complexity\n constructor(input, options = {}) {\n this._input = input;\n this._options = {\n ...options,\n headers: mergeHeaders(this._input.headers, options.headers),\n hooks: mergeHooks({\n beforeRequest: [],\n beforeRetry: [],\n beforeError: [],\n afterResponse: [],\n }, options.hooks),\n method: normalizeRequestMethod(options.method ?? this._input.method),\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n prefixUrl: String(options.prefixUrl || ''),\n retry: normalizeRetryOptions(options.retry),\n throwHttpErrors: options.throwHttpErrors !== false,\n timeout: options.timeout ?? 10_000,\n fetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n };\n if (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n throw new TypeError('`input` must be a string, URL, or Request');\n }\n if (this._options.prefixUrl && typeof this._input === 'string') {\n if (this._input.startsWith('/')) {\n throw new Error('`input` must not begin with a slash when using `prefixUrl`');\n }\n if (!this._options.prefixUrl.endsWith('/')) {\n this._options.prefixUrl += '/';\n }\n this._input = this._options.prefixUrl + this._input;\n }\n if (supportsAbortController) {\n this.abortController = new globalThis.AbortController();\n const originalSignal = this._options.signal ?? this._input.signal;\n originalSignal?.addEventListener('abort', () => {\n this.abortController.abort(originalSignal.reason);\n });\n this._options.signal = this.abortController.signal;\n }\n if (supportsRequestStreams) {\n // @ts-expect-error - Types are outdated.\n this._options.duplex = 'half';\n }\n if (this._options.json !== undefined) {\n this._options.body = this._options.stringifyJson?.(this._options.json) ?? JSON.stringify(this._options.json);\n this._options.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n }\n this.request = new globalThis.Request(this._input, this._options);\n if (this._options.searchParams) {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const textSearchParams = typeof this._options.searchParams === 'string'\n ? this._options.searchParams.replace(/^\\?/, '')\n : new URLSearchParams(this._options.searchParams).toString();\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const searchParams = '?' + textSearchParams;\n const url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n // To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n if (((supportsFormData && this._options.body instanceof globalThis.FormData)\n || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {\n this.request.headers.delete('content-type');\n }\n // The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);\n }\n }\n _calculateRetryDelay(error) {\n this._retryCount++;\n if (this._retryCount > this._options.retry.limit || error instanceof TimeoutError) {\n throw error;\n }\n if (error instanceof HTTPError) {\n if (!this._options.retry.statusCodes.includes(error.response.status)) {\n throw error;\n }\n const retryAfter = error.response.headers.get('Retry-After')\n ?? error.response.headers.get('RateLimit-Reset')\n ?? error.response.headers.get('X-RateLimit-Reset') // GitHub\n ?? error.response.headers.get('X-Rate-Limit-Reset'); // Twitter\n if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n let after = Number(retryAfter) * 1000;\n if (Number.isNaN(after)) {\n after = Date.parse(retryAfter) - Date.now();\n }\n else if (after >= Date.parse('2024-01-01')) {\n // A large number is treated as a timestamp (fixed threshold protects against clock skew)\n after -= Date.now();\n }\n const max = this._options.retry.maxRetryAfter ?? after;\n return after < max ? after : max;\n }\n if (error.response.status === 413) {\n throw error;\n }\n }\n const retryDelay = this._options.retry.delay(this._retryCount);\n return Math.min(this._options.retry.backoffLimit, retryDelay);\n }\n _decorateResponse(response) {\n if (this._options.parseJson) {\n response.json = async () => this._options.parseJson(await response.text());\n }\n return response;\n }\n async _retry(function_) {\n try {\n return await function_();\n }\n catch (error) {\n const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n if (this._retryCount < 1) {\n throw error;\n }\n await delay(ms, { signal: this._options.signal });\n for (const hook of this._options.hooks.beforeRetry) {\n // eslint-disable-next-line no-await-in-loop\n const hookResult = await hook({\n request: this.request,\n options: this._options,\n error: error,\n retryCount: this._retryCount,\n });\n // If `stop` is returned from the hook, the retry process is stopped\n if (hookResult === stop) {\n return;\n }\n }\n return this._retry(function_);\n }\n }\n async _fetch() {\n for (const hook of this._options.hooks.beforeRequest) {\n // eslint-disable-next-line no-await-in-loop\n const result = await hook(this.request, this._options);\n if (result instanceof Request) {\n this.request = result;\n break;\n }\n if (result instanceof Response) {\n return result;\n }\n }\n const nonRequestOptions = findUnknownOptions(this.request, this._options);\n // Cloning is done here to prepare in advance for retries\n const mainRequest = this.request;\n this.request = mainRequest.clone();\n if (this._options.timeout === false) {\n return this._options.fetch(mainRequest, nonRequestOptions);\n }\n return timeout(mainRequest, nonRequestOptions, this.abortController, this._options);\n }\n /* istanbul ignore next */\n _stream(response, onDownloadProgress) {\n const totalBytes = Number(response.headers.get('content-length')) || 0;\n let transferredBytes = 0;\n if (response.status === 204) {\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());\n }\n return new globalThis.Response(null, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n return new globalThis.Response(new globalThis.ReadableStream({\n async start(controller) {\n const reader = response.body.getReader();\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());\n }\n async function read() {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n return;\n }\n if (onDownloadProgress) {\n transferredBytes += value.byteLength;\n const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n onDownloadProgress({ percent, transferredBytes, totalBytes }, value);\n }\n controller.enqueue(value);\n await read();\n }\n await read();\n },\n }), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n}\n//# sourceMappingURL=Ky.js.map","/*! MIT License © Sindre Sorhus */\nimport { Ky } from './core/Ky.js';\nimport { requestMethods, stop } from './core/constants.js';\nimport { validateAndMerge } from './utils/merge.js';\nconst createInstance = (defaults) => {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));\n for (const method of requestMethods) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));\n }\n ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));\n ky.extend = (newDefaults) => {\n if (typeof newDefaults === 'function') {\n newDefaults = newDefaults(defaults ?? {});\n }\n return createInstance(validateAndMerge(defaults, newDefaults));\n };\n ky.stop = stop;\n return ky;\n};\nconst ky = createInstance();\nexport default ky;\nexport { HTTPError } from './errors/HTTPError.js';\nexport { TimeoutError } from './errors/TimeoutError.js';\n//# sourceMappingURL=index.js.map"],"names":["HTTPError","response","request","options","code","title","status","reason","__publicField","TimeoutError","isObject","value","validateAndMerge","sources","source","deepMerge","mergeHeaders","source1","source2","result","isHeadersInstance","key","newHookValue","original","incoming","property","mergeHooks","returnValue","headers","hooks","supportsRequestStreams","duplexAccessed","hasContentType","supportsReadableStream","supportsRequest","error","supportsAbortController","supportsResponseStreams","supportsFormData","requestMethods","responseTypes","maxSafeTimeout","stop","kyOptionKeys","requestOptionsRegistry","normalizeRequestMethod","input","retryMethods","retryStatusCodes","retryAfterStatusCodes","defaultRetryOptions","attemptCount","normalizeRetryOptions","retry","timeout","init","abortController","resolve","reject","timeoutId","delay","ms","signal","abortHandler","findUnknownOptions","unknownOptions","Ky","originalSignal","_b","_a","searchParams","url","ky","function_","hook","modifiedResponse","type","mimeType","retryAfter","after","max","retryDelay","nonRequestOptions","mainRequest","onDownloadProgress","totalBytes","transferredBytes","controller","reader","read","done","percent","createInstance","defaults","method","newDefaults"],"mappings":"oPAAO,MAAMA,UAAkB,KAAM,CAIjC,YAAYC,EAAUC,EAASC,EAAS,CACpC,MAAMC,EAAQH,EAAS,QAAUA,EAAS,SAAW,EAAKA,EAAS,OAAS,GACtEI,EAAQJ,EAAS,YAAc,GAC/BK,EAAS,GAAGF,CAAI,IAAIC,CAAK,GAAG,OAC5BE,EAASD,EAAS,eAAeA,CAAM,GAAK,mBAClD,MAAM,uBAAuBC,CAAM,KAAKL,EAAQ,MAAM,IAAIA,EAAQ,GAAG,EAAE,EAR3EM,EAAA,iBACAA,EAAA,gBACAA,EAAA,gBAOI,KAAK,KAAO,YACZ,KAAK,SAAWP,EAChB,KAAK,QAAUC,EACf,KAAK,QAAUC,CAClB,CACL,CCfO,MAAMM,UAAqB,KAAM,CAEpC,YAAYP,EAAS,CACjB,MAAM,sBAAsBA,EAAQ,MAAM,IAAIA,EAAQ,GAAG,EAAE,EAF/DM,EAAA,gBAGI,KAAK,KAAO,eACZ,KAAK,QAAUN,CAClB,CACL,CCNO,MAAMQ,EAAYC,GAAUA,IAAU,MAAQ,OAAOA,GAAU,SCAzDC,EAAmB,IAAIC,IAAY,CAC5C,UAAWC,KAAUD,EACjB,IAAK,CAACH,EAASI,CAAM,GAAK,MAAM,QAAQA,CAAM,IAAMA,IAAW,OAC3D,MAAM,IAAI,UAAU,0CAA0C,EAGtE,OAAOC,EAAU,CAAA,EAAI,GAAGF,CAAO,CACnC,EACaG,EAAe,CAACC,EAAU,GAAIC,EAAU,CAAA,IAAO,CACxD,MAAMC,EAAS,IAAI,WAAW,QAAQF,CAAO,EACvCG,EAAoBF,aAAmB,WAAW,QAClDJ,EAAS,IAAI,WAAW,QAAQI,CAAO,EAC7C,SAAW,CAACG,EAAKV,CAAK,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[0,1,2,3,4,5,6,7,8,9,10]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var E=Object.defineProperty;var C=(r,t,e)=>t in r?E(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var h=(r,t,e)=>C(r,typeof t!="symbol"?t+"":t,e);class w extends Error{constructor(e,s,o){const n=e.status||e.status===0?e.status:"",i=e.statusText||"",a=`${n} ${i}`.trim(),u=a?`status code ${a}`:"an unknown error";super(`Request failed with ${u}: ${s.method} ${s.url}`);h(this,"response");h(this,"request");h(this,"options");this.name="HTTPError",this.response=e,this.request=s,this.options=o}}class T extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`);h(this,"request");this.name="TimeoutError",this.request=e}}const p=r=>r!==null&&typeof r=="object",l=(...r)=>{for(const t of r)if((!p(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return _({},...r)},g=(r={},t={})=>{const e=new globalThis.Headers(r),s=t instanceof globalThis.Headers,o=new globalThis.Headers(t);for(const[n,i]of o.entries())s&&i==="undefined"||i===void 0?e.delete(n):e.set(n,i);return e};function d(r,t,e){return Object.hasOwn(t,e)&&t[e]===void 0?[]:_(r[e]??[],t[e]??[])}const q=(r={},t={})=>({beforeRequest:d(r,t,"beforeRequest"),beforeRetry:d(r,t,"beforeRetry"),afterResponse:d(r,t,"afterResponse"),beforeError:d(r,t,"beforeError")}),_=(...r)=>{let t={},e={},s={};for(const o of r)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(p(o)){for(let[n,i]of Object.entries(o))p(i)&&n in t&&(i=_(t[n],i)),t={...t,[n]:i};p(o.hooks)&&(s=q(s,o.hooks),t.hooks=s),p(o.headers)&&(e=g(e,o.headers),t.headers=e)}return t},S=(()=>{let r=!1,t=!1;const e=typeof globalThis.ReadableStream=="function",s=typeof globalThis.Request=="function";if(e&&s)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type")}catch(o){if(o instanceof Error&&o.message==="unsupported BodyInit type")return!1;throw o}return r&&!t})(),A=typeof globalThis.AbortController=="function",P=typeof globalThis.ReadableStream=="function",I=typeof globalThis.FormData=="function",k=["get","post","put","patch","head","delete"],O={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},m=2147483647,x=Symbol("stop"),U={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},L={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},j=r=>k.includes(r)?r.toUpperCase():r,H=["get","put","head","delete","options","trace"],v=[408,413,429,500,502,503,504],N=[413,429,503],R={limit:2,methods:H,statusCodes:v,afterStatusCodes:N,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:r=>.3*2**(r-1)*1e3},$=(r={})=>{if(typeof r=="number")return{...R,limit:r};if(r.methods&&!Array.isArray(r.methods))throw new Error("retry.methods must be an array");if(r.statusCodes&&!Array.isArray(r.statusCodes))throw new Error("retry.statusCodes must be an array");return{...R,...r}};async function M(r,t,e,s){return new Promise((o,n)=>{const i=setTimeout(()=>{e&&e.abort(),n(new T(r))},s.timeout);s.fetch(r,t).then(o).catch(n).then(()=>{clearTimeout(i)})})}async function B(r,{signal:t}){return new Promise((e,s)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",o,{once:!0}));function o(){clearTimeout(n),s(t.reason)}const n=setTimeout(()=>{t==null||t.removeEventListener("abort",o),e()},r)})}const D=(r,t)=>{const e={};for(const s in t)!(s in L)&&!(s in U)&&!(s in r)&&(e[s]=t[s]);return e};class y{constructor(t,e={}){h(this,"request");h(this,"abortController");h(this,"_retryCount",0);h(this,"_input");h(this,"_options");var s,o;if(this._input=t,this._options={...e,headers:g(this._input.headers,e.headers),hooks:q({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:j(e.method??this._input.method),prefixUrl:String(e.prefixUrl||""),retry:$(e.retry),throwHttpErrors:e.throwHttpErrors!==!1,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(A){this.abortController=new globalThis.AbortController;const n=this._options.signal??this._input.signal;n==null||n.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(S&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((o=(s=this._options).stringifyJson)==null?void 0:o.call(s,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(I&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}}static create(t,e){const s=new y(t,e),o=async()=>{if(typeof s._options.timeout=="number"&&s._options.timeout>m)throw new RangeError(`The \`timeout\` option cannot be greater than ${m}`);await Promise.resolve();let a=await s._fetch();for(const u of s._options.hooks.afterResponse){const c=await u(s.request,s._options,s._decorateResponse(a.clone()));c instanceof globalThis.Response&&(a=c)}if(s._decorateResponse(a),!a.ok&&s._options.throwHttpErrors){let u=new w(a,s.request,s._options);for(const c of s._options.hooks.beforeError)u=await c(u);throw u}if(s._options.onDownloadProgress){if(typeof s._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!P)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return s._stream(a.clone(),s._options.onDownloadProgress)}return a},i=s._options.retry.methods.includes(s.request.method.toLowerCase())?s._retry(o):o();for(const[a,u]of Object.entries(O))i[a]=async()=>{s.request.headers.set("accept",s.request.headers.get("accept")||u);const f=(await i).clone();if(a==="json"){if(f.status===204||(await f.clone().arrayBuffer()).byteLength===0)return"";if(e.parseJson)return e.parseJson(await f.text())}return f[a]()};return i}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof T)throw t;if(t instanceof w){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const s=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(s&&this._options.retry.afterStatusCodes.includes(t.response.status)){let o=Number(s)*1e3;Number.isNaN(o)?o=Date.parse(s)-Date.now():o>=Date.parse("2024-01-01")&&(o-=Date.now());const n=this._options.retry.maxRetryAfter??o;return o<n?o:n}if(t.response.status===413)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const s=Math.min(this._calculateRetryDelay(e),m);if(this._retryCount<1)throw e;await B(s,{signal:this._options.signal});for(const o of this._options.hooks.beforeRetry)if(await o({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===x)return;return this._retry(t)}}async _fetch(){for(const s of this._options.hooks.beforeRequest){const o=await s(this.request,this._options);if(o instanceof Request){this.request=o;break}if(o instanceof Response)return o}const t=D(this.request,this._options),e=this.request;return this.request=e.clone(),this._options.timeout===!1?this._options.fetch(e,t):M(e,t,this.abortController,this._options)}_stream(t,e){const s=Number(t.headers.get("content-length"))||0;let o=0;return t.status===204?(e&&e({percent:1,totalBytes:s,transferredBytes:o},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(n){const i=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:s},new Uint8Array);async function a(){const{done:u,value:c}=await i.read();if(u){n.close();return}if(e){o+=c.byteLength;const f=s===0?0:o/s;e({percent:f,transferredBytes:o,totalBytes:s},c)}n.enqueue(c),await a()}await a()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}/*! MIT License © Sindre Sorhus */const b=r=>{const t=(e,s)=>y.create(e,l(r,s));for(const e of k)t[e]=(s,o)=>y.create(s,l(r,o,{method:e}));return t.create=e=>b(l(e)),t.extend=e=>(typeof e=="function"&&(e=e(r??{})),b(l(r,e))),t.stop=x,t},V=b();export{V as fetch};
|
|
2
|
+
//# sourceMappingURL=fetch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.mjs","sources":["../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/errors/HTTPError.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/errors/TimeoutError.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/is.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/merge.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/core/constants.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/normalize.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/timeout.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/delay.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/utils/options.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/core/Ky.js","../../../../node_modules/.pnpm/ky@1.7.2/node_modules/ky/distribution/index.js"],"sourcesContent":["export class HTTPError extends Error {\n response;\n request;\n options;\n constructor(response, request, options) {\n const code = (response.status || response.status === 0) ? response.status : '';\n const title = response.statusText || '';\n const status = `${code} ${title}`.trim();\n const reason = status ? `status code ${status}` : 'an unknown error';\n super(`Request failed with ${reason}: ${request.method} ${request.url}`);\n this.name = 'HTTPError';\n this.response = response;\n this.request = request;\n this.options = options;\n }\n}\n//# sourceMappingURL=HTTPError.js.map","export class TimeoutError extends Error {\n request;\n constructor(request) {\n super(`Request timed out: ${request.method} ${request.url}`);\n this.name = 'TimeoutError';\n this.request = request;\n }\n}\n//# sourceMappingURL=TimeoutError.js.map","// eslint-disable-next-line @typescript-eslint/ban-types\nexport const isObject = (value) => value !== null && typeof value === 'object';\n//# sourceMappingURL=is.js.map","import { isObject } from './is.js';\nexport const validateAndMerge = (...sources) => {\n for (const source of sources) {\n if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n throw new TypeError('The `options` argument must be an object');\n }\n }\n return deepMerge({}, ...sources);\n};\nexport const mergeHeaders = (source1 = {}, source2 = {}) => {\n const result = new globalThis.Headers(source1);\n const isHeadersInstance = source2 instanceof globalThis.Headers;\n const source = new globalThis.Headers(source2);\n for (const [key, value] of source.entries()) {\n if ((isHeadersInstance && value === 'undefined') || value === undefined) {\n result.delete(key);\n }\n else {\n result.set(key, value);\n }\n }\n return result;\n};\nfunction newHookValue(original, incoming, property) {\n return (Object.hasOwn(incoming, property) && incoming[property] === undefined)\n ? []\n : deepMerge(original[property] ?? [], incoming[property] ?? []);\n}\nexport const mergeHooks = (original = {}, incoming = {}) => ({\n beforeRequest: newHookValue(original, incoming, 'beforeRequest'),\n beforeRetry: newHookValue(original, incoming, 'beforeRetry'),\n afterResponse: newHookValue(original, incoming, 'afterResponse'),\n beforeError: newHookValue(original, incoming, 'beforeError'),\n});\n// TODO: Make this strongly-typed (no `any`).\nexport const deepMerge = (...sources) => {\n let returnValue = {};\n let headers = {};\n let hooks = {};\n for (const source of sources) {\n if (Array.isArray(source)) {\n if (!Array.isArray(returnValue)) {\n returnValue = [];\n }\n returnValue = [...returnValue, ...source];\n }\n else if (isObject(source)) {\n for (let [key, value] of Object.entries(source)) {\n if (isObject(value) && key in returnValue) {\n value = deepMerge(returnValue[key], value);\n }\n returnValue = { ...returnValue, [key]: value };\n }\n if (isObject(source.hooks)) {\n hooks = mergeHooks(hooks, source.hooks);\n returnValue.hooks = hooks;\n }\n if (isObject(source.headers)) {\n headers = mergeHeaders(headers, source.headers);\n returnValue.headers = headers;\n }\n }\n }\n return returnValue;\n};\n//# sourceMappingURL=merge.js.map","export const supportsRequestStreams = (() => {\n let duplexAccessed = false;\n let hasContentType = false;\n const supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n const supportsRequest = typeof globalThis.Request === 'function';\n if (supportsReadableStream && supportsRequest) {\n try {\n hasContentType = new globalThis.Request('https://empty.invalid', {\n body: new globalThis.ReadableStream(),\n method: 'POST',\n // @ts-expect-error - Types are outdated.\n get duplex() {\n duplexAccessed = true;\n return 'half';\n },\n }).headers.has('Content-Type');\n }\n catch (error) {\n // QQBrowser on iOS throws \"unsupported BodyInit type\" error (see issue #581)\n if (error instanceof Error && error.message === 'unsupported BodyInit type') {\n return false;\n }\n throw error;\n }\n }\n return duplexAccessed && !hasContentType;\n})();\nexport const supportsAbortController = typeof globalThis.AbortController === 'function';\nexport const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\nexport const supportsFormData = typeof globalThis.FormData === 'function';\nexport const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'];\nconst validate = () => undefined;\nvalidate();\nexport const responseTypes = {\n json: 'application/json',\n text: 'text/*',\n formData: 'multipart/form-data',\n arrayBuffer: '*/*',\n blob: '*/*',\n};\n// The maximum value of a 32bit int (see issue #117)\nexport const maxSafeTimeout = 2_147_483_647;\nexport const stop = Symbol('stop');\nexport const kyOptionKeys = {\n json: true,\n parseJson: true,\n stringifyJson: true,\n searchParams: true,\n prefixUrl: true,\n retry: true,\n timeout: true,\n hooks: true,\n throwHttpErrors: true,\n onDownloadProgress: true,\n fetch: true,\n};\nexport const requestOptionsRegistry = {\n method: true,\n headers: true,\n body: true,\n mode: true,\n credentials: true,\n cache: true,\n redirect: true,\n referrer: true,\n referrerPolicy: true,\n integrity: true,\n keepalive: true,\n signal: true,\n window: true,\n dispatcher: true,\n duplex: true,\n priority: true,\n};\n//# sourceMappingURL=constants.js.map","import { requestMethods } from '../core/constants.js';\nexport const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;\nconst retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\nconst retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\nconst retryAfterStatusCodes = [413, 429, 503];\nconst defaultRetryOptions = {\n limit: 2,\n methods: retryMethods,\n statusCodes: retryStatusCodes,\n afterStatusCodes: retryAfterStatusCodes,\n maxRetryAfter: Number.POSITIVE_INFINITY,\n backoffLimit: Number.POSITIVE_INFINITY,\n delay: attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000,\n};\nexport const normalizeRetryOptions = (retry = {}) => {\n if (typeof retry === 'number') {\n return {\n ...defaultRetryOptions,\n limit: retry,\n };\n }\n if (retry.methods && !Array.isArray(retry.methods)) {\n throw new Error('retry.methods must be an array');\n }\n if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n throw new Error('retry.statusCodes must be an array');\n }\n return {\n ...defaultRetryOptions,\n ...retry,\n };\n};\n//# sourceMappingURL=normalize.js.map","import { TimeoutError } from '../errors/TimeoutError.js';\n// `Promise.race()` workaround (#91)\nexport default async function timeout(request, init, abortController, options) {\n return new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n if (abortController) {\n abortController.abort();\n }\n reject(new TimeoutError(request));\n }, options.timeout);\n void options\n .fetch(request, init)\n .then(resolve)\n .catch(reject)\n .then(() => {\n clearTimeout(timeoutId);\n });\n });\n}\n//# sourceMappingURL=timeout.js.map","// https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\nexport default async function delay(ms, { signal }) {\n return new Promise((resolve, reject) => {\n if (signal) {\n signal.throwIfAborted();\n signal.addEventListener('abort', abortHandler, { once: true });\n }\n function abortHandler() {\n clearTimeout(timeoutId);\n reject(signal.reason);\n }\n const timeoutId = setTimeout(() => {\n signal?.removeEventListener('abort', abortHandler);\n resolve();\n }, ms);\n });\n}\n//# sourceMappingURL=delay.js.map","import { kyOptionKeys, requestOptionsRegistry } from '../core/constants.js';\nexport const findUnknownOptions = (request, options) => {\n const unknownOptions = {};\n for (const key in options) {\n if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {\n unknownOptions[key] = options[key];\n }\n }\n return unknownOptions;\n};\n//# sourceMappingURL=options.js.map","import { HTTPError } from '../errors/HTTPError.js';\nimport { TimeoutError } from '../errors/TimeoutError.js';\nimport { mergeHeaders, mergeHooks } from '../utils/merge.js';\nimport { normalizeRequestMethod, normalizeRetryOptions } from '../utils/normalize.js';\nimport timeout from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport { findUnknownOptions } from '../utils/options.js';\nimport { maxSafeTimeout, responseTypes, stop, supportsAbortController, supportsFormData, supportsResponseStreams, supportsRequestStreams, } from './constants.js';\nexport class Ky {\n static create(input, options) {\n const ky = new Ky(input, options);\n const function_ = async () => {\n if (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n throw new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n }\n // Delay the fetch so that body method shortcuts can set the Accept header\n await Promise.resolve();\n let response = await ky._fetch();\n for (const hook of ky._options.hooks.afterResponse) {\n // eslint-disable-next-line no-await-in-loop\n const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));\n if (modifiedResponse instanceof globalThis.Response) {\n response = modifiedResponse;\n }\n }\n ky._decorateResponse(response);\n if (!response.ok && ky._options.throwHttpErrors) {\n let error = new HTTPError(response, ky.request, ky._options);\n for (const hook of ky._options.hooks.beforeError) {\n // eslint-disable-next-line no-await-in-loop\n error = await hook(error);\n }\n throw error;\n }\n // If `onDownloadProgress` is passed, it uses the stream API internally\n /* istanbul ignore next */\n if (ky._options.onDownloadProgress) {\n if (typeof ky._options.onDownloadProgress !== 'function') {\n throw new TypeError('The `onDownloadProgress` option must be a function');\n }\n if (!supportsResponseStreams) {\n throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n }\n return ky._stream(response.clone(), ky._options.onDownloadProgress);\n }\n return response;\n };\n const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n const result = (isRetriableMethod ? ky._retry(function_) : function_());\n for (const [type, mimeType] of Object.entries(responseTypes)) {\n result[type] = async () => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n const awaitedResult = await result;\n const response = awaitedResult.clone();\n if (type === 'json') {\n if (response.status === 204) {\n return '';\n }\n const arrayBuffer = await response.clone().arrayBuffer();\n const responseSize = arrayBuffer.byteLength;\n if (responseSize === 0) {\n return '';\n }\n if (options.parseJson) {\n return options.parseJson(await response.text());\n }\n }\n return response[type]();\n };\n }\n return result;\n }\n request;\n abortController;\n _retryCount = 0;\n _input;\n _options;\n // eslint-disable-next-line complexity\n constructor(input, options = {}) {\n this._input = input;\n this._options = {\n ...options,\n headers: mergeHeaders(this._input.headers, options.headers),\n hooks: mergeHooks({\n beforeRequest: [],\n beforeRetry: [],\n beforeError: [],\n afterResponse: [],\n }, options.hooks),\n method: normalizeRequestMethod(options.method ?? this._input.method),\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n prefixUrl: String(options.prefixUrl || ''),\n retry: normalizeRetryOptions(options.retry),\n throwHttpErrors: options.throwHttpErrors !== false,\n timeout: options.timeout ?? 10_000,\n fetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n };\n if (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n throw new TypeError('`input` must be a string, URL, or Request');\n }\n if (this._options.prefixUrl && typeof this._input === 'string') {\n if (this._input.startsWith('/')) {\n throw new Error('`input` must not begin with a slash when using `prefixUrl`');\n }\n if (!this._options.prefixUrl.endsWith('/')) {\n this._options.prefixUrl += '/';\n }\n this._input = this._options.prefixUrl + this._input;\n }\n if (supportsAbortController) {\n this.abortController = new globalThis.AbortController();\n const originalSignal = this._options.signal ?? this._input.signal;\n originalSignal?.addEventListener('abort', () => {\n this.abortController.abort(originalSignal.reason);\n });\n this._options.signal = this.abortController.signal;\n }\n if (supportsRequestStreams) {\n // @ts-expect-error - Types are outdated.\n this._options.duplex = 'half';\n }\n if (this._options.json !== undefined) {\n this._options.body = this._options.stringifyJson?.(this._options.json) ?? JSON.stringify(this._options.json);\n this._options.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n }\n this.request = new globalThis.Request(this._input, this._options);\n if (this._options.searchParams) {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const textSearchParams = typeof this._options.searchParams === 'string'\n ? this._options.searchParams.replace(/^\\?/, '')\n : new URLSearchParams(this._options.searchParams).toString();\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const searchParams = '?' + textSearchParams;\n const url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n // To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n if (((supportsFormData && this._options.body instanceof globalThis.FormData)\n || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {\n this.request.headers.delete('content-type');\n }\n // The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);\n }\n }\n _calculateRetryDelay(error) {\n this._retryCount++;\n if (this._retryCount > this._options.retry.limit || error instanceof TimeoutError) {\n throw error;\n }\n if (error instanceof HTTPError) {\n if (!this._options.retry.statusCodes.includes(error.response.status)) {\n throw error;\n }\n const retryAfter = error.response.headers.get('Retry-After')\n ?? error.response.headers.get('RateLimit-Reset')\n ?? error.response.headers.get('X-RateLimit-Reset') // GitHub\n ?? error.response.headers.get('X-Rate-Limit-Reset'); // Twitter\n if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n let after = Number(retryAfter) * 1000;\n if (Number.isNaN(after)) {\n after = Date.parse(retryAfter) - Date.now();\n }\n else if (after >= Date.parse('2024-01-01')) {\n // A large number is treated as a timestamp (fixed threshold protects against clock skew)\n after -= Date.now();\n }\n const max = this._options.retry.maxRetryAfter ?? after;\n return after < max ? after : max;\n }\n if (error.response.status === 413) {\n throw error;\n }\n }\n const retryDelay = this._options.retry.delay(this._retryCount);\n return Math.min(this._options.retry.backoffLimit, retryDelay);\n }\n _decorateResponse(response) {\n if (this._options.parseJson) {\n response.json = async () => this._options.parseJson(await response.text());\n }\n return response;\n }\n async _retry(function_) {\n try {\n return await function_();\n }\n catch (error) {\n const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n if (this._retryCount < 1) {\n throw error;\n }\n await delay(ms, { signal: this._options.signal });\n for (const hook of this._options.hooks.beforeRetry) {\n // eslint-disable-next-line no-await-in-loop\n const hookResult = await hook({\n request: this.request,\n options: this._options,\n error: error,\n retryCount: this._retryCount,\n });\n // If `stop` is returned from the hook, the retry process is stopped\n if (hookResult === stop) {\n return;\n }\n }\n return this._retry(function_);\n }\n }\n async _fetch() {\n for (const hook of this._options.hooks.beforeRequest) {\n // eslint-disable-next-line no-await-in-loop\n const result = await hook(this.request, this._options);\n if (result instanceof Request) {\n this.request = result;\n break;\n }\n if (result instanceof Response) {\n return result;\n }\n }\n const nonRequestOptions = findUnknownOptions(this.request, this._options);\n // Cloning is done here to prepare in advance for retries\n const mainRequest = this.request;\n this.request = mainRequest.clone();\n if (this._options.timeout === false) {\n return this._options.fetch(mainRequest, nonRequestOptions);\n }\n return timeout(mainRequest, nonRequestOptions, this.abortController, this._options);\n }\n /* istanbul ignore next */\n _stream(response, onDownloadProgress) {\n const totalBytes = Number(response.headers.get('content-length')) || 0;\n let transferredBytes = 0;\n if (response.status === 204) {\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());\n }\n return new globalThis.Response(null, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n return new globalThis.Response(new globalThis.ReadableStream({\n async start(controller) {\n const reader = response.body.getReader();\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());\n }\n async function read() {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n return;\n }\n if (onDownloadProgress) {\n transferredBytes += value.byteLength;\n const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n onDownloadProgress({ percent, transferredBytes, totalBytes }, value);\n }\n controller.enqueue(value);\n await read();\n }\n await read();\n },\n }), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n}\n//# sourceMappingURL=Ky.js.map","/*! MIT License © Sindre Sorhus */\nimport { Ky } from './core/Ky.js';\nimport { requestMethods, stop } from './core/constants.js';\nimport { validateAndMerge } from './utils/merge.js';\nconst createInstance = (defaults) => {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));\n for (const method of requestMethods) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));\n }\n ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));\n ky.extend = (newDefaults) => {\n if (typeof newDefaults === 'function') {\n newDefaults = newDefaults(defaults ?? {});\n }\n return createInstance(validateAndMerge(defaults, newDefaults));\n };\n ky.stop = stop;\n return ky;\n};\nconst ky = createInstance();\nexport default ky;\nexport { HTTPError } from './errors/HTTPError.js';\nexport { TimeoutError } from './errors/TimeoutError.js';\n//# sourceMappingURL=index.js.map"],"names":["HTTPError","response","request","options","code","title","status","reason","__publicField","TimeoutError","isObject","value","validateAndMerge","sources","source","deepMerge","mergeHeaders","source1","source2","result","isHeadersInstance","key","newHookValue","original","incoming","property","mergeHooks","returnValue","headers","hooks","supportsRequestStreams","duplexAccessed","hasContentType","supportsReadableStream","supportsRequest","error","supportsAbortController","supportsResponseStreams","supportsFormData","requestMethods","responseTypes","maxSafeTimeout","stop","kyOptionKeys","requestOptionsRegistry","normalizeRequestMethod","input","retryMethods","retryStatusCodes","retryAfterStatusCodes","defaultRetryOptions","attemptCount","normalizeRetryOptions","retry","timeout","init","abortController","resolve","reject","timeoutId","delay","ms","signal","abortHandler","findUnknownOptions","unknownOptions","Ky","_a","_b","originalSignal","searchParams","url","ky","function_","hook","modifiedResponse","type","mimeType","retryAfter","after","max","retryDelay","nonRequestOptions","mainRequest","onDownloadProgress","totalBytes","transferredBytes","controller","reader","read","done","percent","createInstance","defaults","method","newDefaults"],"mappings":"oKAAO,MAAMA,UAAkB,KAAM,CAIjC,YAAYC,EAAUC,EAASC,EAAS,CACpC,MAAMC,EAAQH,EAAS,QAAUA,EAAS,SAAW,EAAKA,EAAS,OAAS,GACtEI,EAAQJ,EAAS,YAAc,GAC/BK,EAAS,GAAGF,CAAI,IAAIC,CAAK,GAAG,OAC5BE,EAASD,EAAS,eAAeA,CAAM,GAAK,mBAClD,MAAM,uBAAuBC,CAAM,KAAKL,EAAQ,MAAM,IAAIA,EAAQ,GAAG,EAAE,EAR3EM,EAAA,iBACAA,EAAA,gBACAA,EAAA,gBAOI,KAAK,KAAO,YACZ,KAAK,SAAWP,EAChB,KAAK,QAAUC,EACf,KAAK,QAAUC,CAClB,CACL,CCfO,MAAMM,UAAqB,KAAM,CAEpC,YAAYP,EAAS,CACjB,MAAM,sBAAsBA,EAAQ,MAAM,IAAIA,EAAQ,GAAG,EAAE,EAF/DM,EAAA,gBAGI,KAAK,KAAO,eACZ,KAAK,QAAUN,CAClB,CACL,CCNO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+D,EAAG,OAAOpB,EAAOlC,EAAiBiF,EAAU1F,CAAO,CAAC,EACnF,UAAW2F,KAAUvD,EAEjBiC,EAAGsB,CAAM,EAAI,CAAChD,EAAO3C,IAAY+D,EAAG,OAAOpB,EAAOlC,EAAiBiF,EAAU1F,EAAS,CAAE,OAAA2F,CAAM,CAAE,CAAC,EAErG,OAAAtB,EAAG,OAAUuB,GAAgBH,EAAehF,EAAiBmF,CAAW,CAAC,EACzEvB,EAAG,OAAUuB,IACL,OAAOA,GAAgB,aACvBA,EAAcA,EAAYF,GAAY,CAAA,CAAE,GAErCD,EAAehF,EAAiBiF,EAAUE,CAAW,CAAC,GAEjEvB,EAAG,KAAO9B,EACH8B,CACX,EACMA,EAAKoB,EAAc","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let o=null;async function h(l,e,n=!0){const t=(e==null?void 0:e.targetWindow)==="top"?window.top:window.self,a=(e==null?void 0:e.locationMethod)||"assign";if(t&&t.location[a](l),n)return new Promise(()=>{})}function f(l=(n=>(n=globalThis.window)==null?void 0:n.location.href)(),e){const t=new URL(l)[e==="query"?"search":"hash"].slice(1);return Object.fromEntries(new URLSearchParams(t))}async function u(l,e){const n=new Set,t=()=>{o&&(o.closed||o.close(),o=null);for(const r of n)r();n.clear()};o&&t();const a={location:!1,toolbar:!1,height:640,...e==null?void 0:e.popupWindowFeatures};if(a.width===void 0&&(a.width=[800,720,600,480].find(r=>r<=window.outerWidth/1.618)??360),a.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-a.width)/2)),a.height!==void 0&&(a.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-a.height)/2))),o=window.open(void 0,(e==null?void 0:e.popupWindowTarget)||"_blank",Object.entries(a).filter(([,r])=>r!==null).map(([r,i])=>`${r}=${typeof i!="boolean"?i:i?"yes":"no"}`).join(",")),!o)throw Error("Popup window blocked");o.focus(),o.location.replace(l);const d=await new Promise((r,i)=>{const s=async c=>{c.origin===window.location.origin&&c.source===o&&c.data&&r(c.data)},w=setInterval(()=>{o!=null&&o.closed&&(clearInterval(w),i(Error("Popup closed by user")))},500);window.addEventListener("message",s),n.add(()=>window.removeEventListener("message",s)),n.add(()=>clearInterval(w))});return t(),d}function g(l){var n,t,a,d;const e={};l==="fragment"?new URLSearchParams((n=globalThis.window)==null?void 0:n.location.hash.replace("#","?")).forEach((r,i)=>e[i]=r):new URLSearchParams((t=globalThis.window)==null?void 0:t.location.search).forEach((r,i)=>e[i]=r),(d=(a=globalThis.window)==null?void 0:a.opener)==null||d.postMessage(e,"*")}exports.popupCallbackHandler=g;exports.popupUrlHandler=u;exports.redirectCallbackHandler=f;exports.redirectUrlHandler=h;
|
|
2
|
+
//# sourceMappingURL=handlers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.cjs","sources":["../../src/utils/handlers.ts"],"sourcesContent":["import type { RedirectParams, ResponseMode, PopupWindowParams, PopupWindowFeatures } from '../types';\n\nlet popupWindow: WindowProxy | null = null;\n\n/**\n * Handles URL redirection to a target window using a specified location method.\n *\n * @param {URL} url The URL to redirect to.\n * @param {RedirectParams} [options] Optional parameters for the redirection, including the target window and location method.\n * @param {boolean} [shouldWait=true] Whether to wait for the previous action (default is true).\n * @returns {Promise<void>} A promise that resolves when the redirection occurs.\n */\nasync function redirectUrlHandler(url: URL, options?: RedirectParams, shouldWait = true): Promise<void> {\n\tconst targetWindow = options?.targetWindow === 'top' ? window.top : window.self;\n\tconst method = options?.locationMethod || 'assign';\n\n\tif (targetWindow) {\n\t\ttargetWindow.location[method](url);\n\t}\n\n\tif (shouldWait) {\n\t\t// NOTE: Wait for the previous action\n\t\treturn new Promise(() => undefined);\n\t}\n}\n\n/**\n * Handles the callback after a redirect and parses the response from the URL.\n *\n * @param {string} [url=globalThis.window?.location.href] The URL to parse, defaults to the current window location.\n * @param {ResponseMode} responseMode The response mode, either 'query' or 'fragment'.\n * @returns {Record<string, string>} A key-value map of the parsed URL parameters.\n */\nfunction redirectCallbackHandler(url: string = globalThis.window?.location.href, responseMode: ResponseMode): Record<string, string> {\n\tconst data = new URL(url)[responseMode === 'query' ? 'search' : 'hash'].slice(1);\n\n\treturn Object.fromEntries(new URLSearchParams(data));\n}\n\n/**\n * Opens a popup window to handle URL redirection and resolves with the data received from the popup.\n *\n * @param {URL} url The URL to redirect to in the popup.\n * @param {PopupWindowParams} [options] Optional parameters for the popup, including window features and target.\n * @returns {Promise<Record<string, string>>} A promise that resolves to the data received from the popup window.\n * @throws {Error} If the popup window is blocked or closed by the user.\n */\nasync function popupUrlHandler(url: URL, options?: PopupWindowParams): Promise<Record<string, string>> {\n\tconst disposables = new Set<() => void>();\n\tconst closeWindow = (): void => {\n\t\tif (popupWindow) {\n\t\t\tif (!popupWindow.closed) {\n\t\t\t\tpopupWindow.close();\n\t\t\t}\n\n\t\t\tpopupWindow = null;\n\t\t}\n\n\t\tfor (const dispose of disposables) {\n\t\t\tdispose();\n\t\t}\n\n\t\tdisposables.clear();\n\t};\n\n\tif (popupWindow) {\n\t\tcloseWindow();\n\t}\n\n\tconst popupWindowFeatures: PopupWindowFeatures = {\n\t\tlocation: false,\n\t\ttoolbar: false,\n\t\theight: 640,\n\t\t...options?.popupWindowFeatures,\n\t};\n\n\tif (popupWindowFeatures.width === undefined) {\n\t\tpopupWindowFeatures.width = [800, 720, 600, 480].find((width) => width <= window.outerWidth / 1.618) ?? 360;\n\t}\n\n\tpopupWindowFeatures.left = Math.max(0, Math.round(window.screenX + (window.outerWidth - popupWindowFeatures.width) / 2));\n\n\tif (popupWindowFeatures.height !== undefined) {\n\t\tpopupWindowFeatures.top = Math.max(0, Math.round(window.screenY + (window.outerHeight - popupWindowFeatures.height) / 2));\n\t}\n\n\tpopupWindow = window.open(\n\t\tundefined,\n\t\toptions?.popupWindowTarget || '_blank',\n\t\tObject.entries(popupWindowFeatures)\n\t\t\t.filter(([, value]) => value !== null)\n\t\t\t.map(([key, value]) => `${key}=${typeof value !== 'boolean' ? (value as string) : value ? 'yes' : 'no'}`)\n\t\t\t.join(','),\n\t);\n\n\tif (!popupWindow) {\n\t\tthrow Error('Popup window blocked');\n\t}\n\n\tpopupWindow.focus();\n\tpopupWindow.location.replace(url);\n\n\tconst data = await new Promise<Record<string, string>>((resolve, reject) => {\n\t\tconst listener = async (event: MessageEvent<Record<string, string>>) => {\n\t\t\tif (event.origin === window.location.origin && event.source === popupWindow && event.data) {\n\t\t\t\tresolve(event.data);\n\t\t\t}\n\t\t};\n\n\t\tconst timer = setInterval(() => {\n\t\t\tif (popupWindow?.closed) {\n\t\t\t\tclearInterval(timer);\n\t\t\t\treject(Error('Popup closed by user'));\n\t\t\t}\n\t\t}, 500);\n\n\t\twindow.addEventListener('message', listener);\n\t\tdisposables.add(() => window.removeEventListener('message', listener));\n\t\tdisposables.add(() => clearInterval(timer));\n\t});\n\n\tcloseWindow();\n\n\treturn data;\n}\n\n/**\n * Handles the callback from a popup window, parsing the response parameters from the URL and posting them to the opener window.\n *\n * @param {ResponseMode} responseMode The response mode, either 'query' or 'fragment'.\n */\nfunction popupCallbackHandler(responseMode: ResponseMode): void {\n\tconst args: Record<string, string> = {};\n\n\tif (responseMode === 'fragment') {\n\t\tnew URLSearchParams(globalThis.window?.location.hash.replace('#', '?')).forEach((value, key) => (args[key] = value));\n\t} else {\n\t\tnew URLSearchParams(globalThis.window?.location.search).forEach((value, key) => (args[key] = value));\n\t}\n\n\tglobalThis.window?.opener?.postMessage(args, '*');\n}\n\nexport { redirectUrlHandler, redirectCallbackHandler, popupUrlHandler, popupCallbackHandler };\n"],"names":["popupWindow","redirectUrlHandler","url","options","shouldWait","targetWindow","method","redirectCallbackHandler","_a","responseMode","data","popupUrlHandler","disposables","closeWindow","dispose","popupWindowFeatures","width","value","key","resolve","reject","listener","event","timer","popupCallbackHandler","args","_b","_d","_c"],"mappings":"gFAEA,IAAIA,EA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34 @@
|
|
|
1
|
+
import { RedirectParams, ResponseMode, PopupWindowParams } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Handles URL redirection to a target window using a specified location method.
|
|
4
|
+
*
|
|
5
|
+
* @param {URL} url The URL to redirect to.
|
|
6
|
+
* @param {RedirectParams} [options] Optional parameters for the redirection, including the target window and location method.
|
|
7
|
+
* @param {boolean} [shouldWait=true] Whether to wait for the previous action (default is true).
|
|
8
|
+
* @returns {Promise<void>} A promise that resolves when the redirection occurs.
|
|
9
|
+
*/
|
|
10
|
+
declare function redirectUrlHandler(url: URL, options?: RedirectParams, shouldWait?: boolean): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Handles the callback after a redirect and parses the response from the URL.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} [url=globalThis.window?.location.href] The URL to parse, defaults to the current window location.
|
|
15
|
+
* @param {ResponseMode} responseMode The response mode, either 'query' or 'fragment'.
|
|
16
|
+
* @returns {Record<string, string>} A key-value map of the parsed URL parameters.
|
|
17
|
+
*/
|
|
18
|
+
declare function redirectCallbackHandler(url: string | undefined, responseMode: ResponseMode): Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Opens a popup window to handle URL redirection and resolves with the data received from the popup.
|
|
21
|
+
*
|
|
22
|
+
* @param {URL} url The URL to redirect to in the popup.
|
|
23
|
+
* @param {PopupWindowParams} [options] Optional parameters for the popup, including window features and target.
|
|
24
|
+
* @returns {Promise<Record<string, string>>} A promise that resolves to the data received from the popup window.
|
|
25
|
+
* @throws {Error} If the popup window is blocked or closed by the user.
|
|
26
|
+
*/
|
|
27
|
+
declare function popupUrlHandler(url: URL, options?: PopupWindowParams): Promise<Record<string, string>>;
|
|
28
|
+
/**
|
|
29
|
+
* Handles the callback from a popup window, parsing the response parameters from the URL and posting them to the opener window.
|
|
30
|
+
*
|
|
31
|
+
* @param {ResponseMode} responseMode The response mode, either 'query' or 'fragment'.
|
|
32
|
+
*/
|
|
33
|
+
declare function popupCallbackHandler(responseMode: ResponseMode): void;
|
|
34
|
+
export { redirectUrlHandler, redirectCallbackHandler, popupUrlHandler, popupCallbackHandler };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let o=null;async function h(d,e,n=!0){const i=(e==null?void 0:e.targetWindow)==="top"?window.top:window.self,a=(e==null?void 0:e.locationMethod)||"assign";if(i&&i.location[a](d),n)return new Promise(()=>{})}function f(d=(n=>(n=globalThis.window)==null?void 0:n.location.href)(),e){const i=new URL(d)[e==="query"?"search":"hash"].slice(1);return Object.fromEntries(new URLSearchParams(i))}async function u(d,e){const n=new Set,i=()=>{o&&(o.closed||o.close(),o=null);for(const r of n)r();n.clear()};o&&i();const a={location:!1,toolbar:!1,height:640,...e==null?void 0:e.popupWindowFeatures};if(a.width===void 0&&(a.width=[800,720,600,480].find(r=>r<=window.outerWidth/1.618)??360),a.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-a.width)/2)),a.height!==void 0&&(a.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-a.height)/2))),o=window.open(void 0,(e==null?void 0:e.popupWindowTarget)||"_blank",Object.entries(a).filter(([,r])=>r!==null).map(([r,t])=>`${r}=${typeof t!="boolean"?t:t?"yes":"no"}`).join(",")),!o)throw Error("Popup window blocked");o.focus(),o.location.replace(d);const l=await new Promise((r,t)=>{const w=async c=>{c.origin===window.location.origin&&c.source===o&&c.data&&r(c.data)},s=setInterval(()=>{o!=null&&o.closed&&(clearInterval(s),t(Error("Popup closed by user")))},500);window.addEventListener("message",w),n.add(()=>window.removeEventListener("message",w)),n.add(()=>clearInterval(s))});return i(),l}function g(d){var n,i,a,l;const e={};d==="fragment"?new URLSearchParams((n=globalThis.window)==null?void 0:n.location.hash.replace("#","?")).forEach((r,t)=>e[t]=r):new URLSearchParams((i=globalThis.window)==null?void 0:i.location.search).forEach((r,t)=>e[t]=r),(l=(a=globalThis.window)==null?void 0:a.opener)==null||l.postMessage(e,"*")}export{g as popupCallbackHandler,u as popupUrlHandler,f as redirectCallbackHandler,h as redirectUrlHandler};
|
|
2
|
+
//# sourceMappingURL=handlers.mjs.map
|