@utilix-tech/sdk 0.74.0 → 0.76.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 +8 -0
- package/README.md +13 -4
- package/dist/{api-C8rImfka.d.cts → api-CQnIUrVB.d.cts} +26 -2
- package/dist/{api-C8rImfka.d.ts → api-CQnIUrVB.d.ts} +26 -2
- package/dist/{chunk-P7TXG7CI.js → chunk-QVOK3BXM.js} +97 -1
- package/dist/{chunk-AKVWWLNJ.js → chunk-RP574L5Z.js} +66 -1
- package/dist/{chunk-4S63T7Y4.js → chunk-U2HREMZU.js} +37 -2
- package/dist/index.cjs +197 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{text-DWUcY8H1.d.ts → text-CNn3whZA.d.cts} +55 -2
- package/dist/{text-DWUcY8H1.d.cts → text-CNn3whZA.d.ts} +55 -2
- package/dist/tools/api.cjs +35 -0
- package/dist/tools/api.d.cts +1 -1
- package/dist/tools/api.d.ts +1 -1
- package/dist/tools/api.js +1 -1
- package/dist/tools/text.cjs +96 -0
- package/dist/tools/text.d.cts +1 -1
- package/dist/tools/text.d.ts +1 -1
- package/dist/tools/text.js +1 -1
- package/dist/tools/units.cjs +65 -0
- package/dist/tools/units.d.cts +1 -1
- package/dist/tools/units.d.ts +1 -1
- package/dist/tools/units.js +1 -1
- package/dist/{units-BAwyBk4x.d.cts → units-BqegyALA.d.cts} +42 -2
- package/dist/{units-BAwyBk4x.d.ts → units-BqegyALA.d.ts} +42 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.76.0
|
|
6
|
+
- Add `detectWordyPhrases` (wordy-phrase-detector): scan text against a curated table of wordy/redundant phrases ("due to the fact that", "in order to") and flag each occurrence with a suggested concise replacement, an occurrence count, and character offsets.
|
|
7
|
+
- Add `checkOxfordCommaConsistency` (oxford-comma-checker): scan a document for comma-before-and/or usage in three-or-more-item lists and flag documents that mix Oxford comma styles.
|
|
8
|
+
|
|
9
|
+
## 0.75.0
|
|
10
|
+
- Add `verifyWebhookSignature` (webhook-signature-verifier): recompute an HMAC over a raw webhook payload and compare it to a provided signature, supporting the `sha256=` prefix style (Stripe/GitHub-style webhooks) plus raw hex or base64 encoding.
|
|
11
|
+
- Add `calculateTransferTime` and `calculateRequiredBandwidth` (data-transfer-time-estimator): estimate the theoretical time to transfer a file over a connection of a given speed, or the reverse: the bandwidth required to hit a target time.
|
|
12
|
+
|
|
5
13
|
## 0.74.0
|
|
6
14
|
- Add `calculateLoanPrepaymentPenalty` (loan-prepayment-penalty-calculator): compute the dollar penalty cost of paying a loan off early, given its payoff balance and a prepayment penalty structure (a flat percent of balance, or a fixed number of months of interest).
|
|
7
15
|
- Add `validateAria` (aria-validator): check every role and aria-* attribute in an HTML snippet against a curated WAI-ARIA 1.2 role table, flagging unknown roles, disallowed attributes, and missing required states.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**703 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -152,7 +152,8 @@ generateEtag("console.log(1)");
|
|
|
152
152
|
```ts
|
|
153
153
|
import { convertCase, slugify, countWords, generateWords, generateParagraphs,
|
|
154
154
|
escapeString, htmlToMarkdown, applyOps, detectPassiveVoice, scoreReadability,
|
|
155
|
-
detectFillerWords,
|
|
155
|
+
detectFillerWords, detectWordyPhrases, checkOxfordCommaConsistency,
|
|
156
|
+
calculateStringDistance, analyzeSentenceLengths,
|
|
156
157
|
analyzeKeywordDensity, searchEmoji, getEmojiByShortcode } from "@utilix-tech/sdk/text";
|
|
157
158
|
|
|
158
159
|
convertCase("hello world", "camelCase"); // "helloWorld"
|
|
@@ -183,6 +184,14 @@ scoreReadability("The cat sat on the mat. It was a sunny day.");
|
|
|
183
184
|
detectFillerWords("At the end of the day, I just really think we should circle back.");
|
|
184
185
|
// { totalMatches: 4, fillerCount: 2, clicheCount: 2, density: 28.6, matches: [...] }
|
|
185
186
|
|
|
187
|
+
// Flag wordy/redundant phrases with a suggested concise replacement
|
|
188
|
+
detectWordyPhrases("Due to the fact that it was late, we decided, in order to save time, to skip the meeting.");
|
|
189
|
+
// { totalMatches: 2, density: 10.5, matches: [{ phrase: "due to the fact that", suggestion: "because", ... }, ...] }
|
|
190
|
+
|
|
191
|
+
// Flag a document that mixes Oxford-comma and non-Oxford-comma lists
|
|
192
|
+
checkOxfordCommaConsistency("I bought apples, bananas, and pears. Then I bought milk, eggs and bread.");
|
|
193
|
+
// { totalLists: 2, withOxfordComma: 1, withoutOxfordComma: 1, consistent: false, instances: [...] }
|
|
194
|
+
|
|
186
195
|
// Levenshtein edit distance + similarity ratio; pass mode: "damerau" to count a transposition as 1 edit
|
|
187
196
|
calculateStringDistance("kitten", "sitting");
|
|
188
197
|
// { distance: 3, similarity: 0.5714, maxLength: 7, mode: "levenshtein" }
|
|
@@ -995,9 +1004,9 @@ readMidiInfo(new Uint8Array(midiBytes));
|
|
|
995
1004
|
| `@utilix-tech/sdk/data` | CSV, YAML, TOML, XML, INI, NDJSON parse and convert, NDJSON record deduplicator, SRT/WebVTT subtitles, Markdown front matter parser, YAML anchor/alias resolver, CSV column type inferencer, Markdown table column aligner |
|
|
996
1005
|
| `@utilix-tech/sdk/generators` | UUID v4/v7, ULID, passwords, strength check, entropy estimator, fake data, CSP nonce generator |
|
|
997
1006
|
| `@utilix-tech/sdk/time` | Date diff, timezone convert, cron parse, relative time |
|
|
998
|
-
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN/VIN/ISIN validation, loan calculator, EMI calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator, savings goal calculator, ROI calculator, cash denomination/till calculator, payback period calculator, CD maturity calculator, debt-to-income ratio calculator, freelancer hourly rate calculator, debt snowball/avalanche payoff planner, tax-equivalent yield calculator, mortgage discount points break-even calculator, loan prepayment penalty calculator |
|
|
1007
|
+
| `@utilix-tech/sdk/units` | Bytes, CSS px/rem, number bases, currency format, credit card/IBAN/barcode/ISBN/VIN/ISIN validation, loan calculator, EMI calculator, compound/simple interest calculators, VAT/sales tax calculator, tip/bill split calculator, break-even point calculator, Rule of 72 calculator, savings goal calculator, ROI calculator, cash denomination/till calculator, payback period calculator, CD maturity calculator, debt-to-income ratio calculator, freelancer hourly rate calculator, debt snowball/avalanche payoff planner, tax-equivalent yield calculator, mortgage discount points break-even calculator, loan prepayment penalty calculator, data transfer time / required bandwidth estimator |
|
|
999
1008
|
| `@utilix-tech/sdk/network` | HTTP status codes, IP validation, country flags, geolocation URLs, HAR file parsing, User-Agent parsing, IPv6 address compress/expand, Permissions-Policy header builder, Client Hints header builder/parser, Content-Disposition header builder/parser, X-Content-Type-Options header builder/risk assessor, sitemap.xml validator, sitemap index splitter, Prefer header builder/parser (RFC 7240), Retry-After header builder/parser (RFC 9110), Priority header builder/parser (RFC 9218), WebSocket close code reference/lookup, Strict-Transport-Security (HSTS) header builder/parser, X-Robots-Tag header builder/parser, WebSocket frame opcode reference/lookup, robots meta tag builder/parser, Cookie header byte-size budget calculator |
|
|
1000
|
-
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header, TOTP/HOTP code generator |
|
|
1009
|
+
| `@utilix-tech/sdk/api` | cURL build/parse, JWT decode/sign, JWKS parse, CORS headers, CSP header, TOTP/HOTP code generator, webhook HMAC signature verifier |
|
|
1001
1010
|
| `@utilix-tech/sdk/code` | SQL format/minify, HTML format/minify, regex tester, GraphQL format, MIME type lookup, GitHub URL parsing, regex ReDoS detector, Conventional Commits linter, package.json exports field validator, package.json dependency range auditor, regex capture group/backreference visualizer, SVG sprite symbol extractor, ARIA role & attribute validator |
|
|
1002
1011
|
| `@utilix-tech/sdk/color` | Hex/RGB/HSL/HSV/CMYK convert, palette generation, contrast check |
|
|
1003
1012
|
| `@utilix-tech/sdk/css` | CSS gradient, box-shadow, border-radius, keyframe animation generators |
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* encodeUrlComponent, decodeUrlComponent, isValidUrl, normalizeUrl
|
|
15
15
|
* - og-meta : parseMetaTags, validateOgTags, generateMetaHtml
|
|
16
16
|
* - totp-hotp-generator : generateHotp, generateTotp
|
|
17
|
+
* - webhook-signature-verifier : verifyWebhookSignature
|
|
17
18
|
*
|
|
18
19
|
* Node 18+ only. All crypto uses node:crypto; no browser-only APIs.
|
|
19
20
|
*/
|
|
@@ -333,6 +334,26 @@ interface TotpResult {
|
|
|
333
334
|
declare function generateTotp(secret: string, options?: TotpOptions): TotpResult | {
|
|
334
335
|
error: string;
|
|
335
336
|
};
|
|
337
|
+
type WebhookHashAlgorithm = 'sha1' | 'sha256' | 'sha512';
|
|
338
|
+
interface WebhookSignatureResult {
|
|
339
|
+
valid: boolean;
|
|
340
|
+
algorithm: WebhookHashAlgorithm;
|
|
341
|
+
expectedHex: string;
|
|
342
|
+
expectedBase64: string;
|
|
343
|
+
providedSignature: string;
|
|
344
|
+
matchedEncoding: 'hex' | 'base64' | null;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Recomputes an HMAC over a raw webhook payload and compares it to a
|
|
348
|
+
* provided signature, the check every webhook receiver (Stripe, GitHub,
|
|
349
|
+
* Shopify, etc.) has to do before trusting a request. Accepts a signature
|
|
350
|
+
* with or without the common `sha256=` prefix style, and matches against
|
|
351
|
+
* either hex or base64 encoding since providers differ on which they send.
|
|
352
|
+
* Comparison is constant-time to avoid leaking timing information.
|
|
353
|
+
*/
|
|
354
|
+
declare function verifyWebhookSignature(payload: string, secret: string, signature: string, algorithm?: WebhookHashAlgorithm): WebhookSignatureResult | {
|
|
355
|
+
error: string;
|
|
356
|
+
};
|
|
336
357
|
|
|
337
358
|
declare const api_COMMON_HEADERS: typeof COMMON_HEADERS;
|
|
338
359
|
declare const api_COMMON_PRESETS: typeof COMMON_PRESETS;
|
|
@@ -378,6 +399,8 @@ type api_TargetLanguage = TargetLanguage;
|
|
|
378
399
|
type api_TotpOptions = TotpOptions;
|
|
379
400
|
type api_TotpResult = TotpResult;
|
|
380
401
|
type api_TwitterTags = TwitterTags;
|
|
402
|
+
type api_WebhookHashAlgorithm = WebhookHashAlgorithm;
|
|
403
|
+
type api_WebhookSignatureResult = WebhookSignatureResult;
|
|
381
404
|
declare const api_addParam: typeof addParam;
|
|
382
405
|
declare const api_base64urlDecode: typeof base64urlDecode;
|
|
383
406
|
declare const api_base64urlEncode: typeof base64urlEncode;
|
|
@@ -414,8 +437,9 @@ declare const api_signJwt: typeof signJwt;
|
|
|
414
437
|
declare const api_validateCorsConfig: typeof validateCorsConfig;
|
|
415
438
|
declare const api_validateCspConfig: typeof validateCspConfig;
|
|
416
439
|
declare const api_validateOgTags: typeof validateOgTags;
|
|
440
|
+
declare const api_verifyWebhookSignature: typeof verifyWebhookSignature;
|
|
417
441
|
declare namespace api {
|
|
418
|
-
export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HotpResult as HotpResult, type api_HttpMethod as HttpMethod, type api_JwkSummary as JwkSummary, type api_JwkThumbprintErrorResult as JwkThumbprintErrorResult, type api_JwkThumbprintHash as JwkThumbprintHash, type api_JwkThumbprintOutcome as JwkThumbprintOutcome, type api_JwkThumbprintResult as JwkThumbprintResult, type api_JwksError as JwksError, type api_JwksParseResult as JwksParseResult, type api_JwksResult as JwksResult, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_OtpAlgorithm as OtpAlgorithm, type api_OtpOptions as OtpOptions, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TotpOptions as TotpOptions, type api_TotpResult as TotpResult, type api_TwitterTags as TwitterTags, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_computeJwkThumbprint as computeJwkThumbprint, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateHotp as generateHotp, api_generateMetaHtml as generateMetaHtml, api_generateTotp as generateTotp, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseJwks as parseJwks, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags };
|
|
442
|
+
export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HotpResult as HotpResult, type api_HttpMethod as HttpMethod, type api_JwkSummary as JwkSummary, type api_JwkThumbprintErrorResult as JwkThumbprintErrorResult, type api_JwkThumbprintHash as JwkThumbprintHash, type api_JwkThumbprintOutcome as JwkThumbprintOutcome, type api_JwkThumbprintResult as JwkThumbprintResult, type api_JwksError as JwksError, type api_JwksParseResult as JwksParseResult, type api_JwksResult as JwksResult, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_OtpAlgorithm as OtpAlgorithm, type api_OtpOptions as OtpOptions, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TotpOptions as TotpOptions, type api_TotpResult as TotpResult, type api_TwitterTags as TwitterTags, type api_WebhookHashAlgorithm as WebhookHashAlgorithm, type api_WebhookSignatureResult as WebhookSignatureResult, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_computeJwkThumbprint as computeJwkThumbprint, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateHotp as generateHotp, api_generateMetaHtml as generateMetaHtml, api_generateTotp as generateTotp, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseJwks as parseJwks, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags, api_verifyWebhookSignature as verifyWebhookSignature };
|
|
419
443
|
}
|
|
420
444
|
|
|
421
|
-
export {
|
|
445
|
+
export { computeJwkThumbprint as $, type JwtPart as A, type JwtResult as B, COMMON_HEADERS as C, DEFAULT_CORS_CONFIG as D, type JwtSignOptions as E, type FormatResult as F, type OtpAlgorithm as G, HTTP_METHODS as H, type OtpOptions as I, type JwkSummary as J, type TotpOptions as K, type TotpResult as L, type MetaTags as M, type TwitterTags as N, type OgTags as O, type ParsedUrl as P, type WebhookSignatureResult as Q, type ResponseFormat as R, SUPPORTED_LANGUAGES as S, type TargetLanguage as T, addParam as U, base64urlDecode as V, type WebhookHashAlgorithm as W, base64urlEncode as X, buildCurl as Y, buildCurlMultiline as Z, buildUrl as _, api as a, convertToCode as a0, decodeJwt as a1, decodeUrlComponent as a2, detectFormat as a3, encodeUrlComponent as a4, extractJsonPaths as a5, formatJwtJson as a6, formatResponse as a7, generateCors as a8, generateCspHeader as a9, generateFullHeader as aa, generateHotp as ab, generateMetaHtml as ac, generateTotp as ad, getParam as ae, getStats as af, isValidUrl as ag, normalizeUrl as ah, parseCspHeader as ai, parseCurl as aj, parseCurlCommand as ak, parseJwks as al, parseMetaTags as am, parseUrl as an, removeParam as ao, signJwt as ap, validateCorsConfig as aq, validateCspConfig as ar, validateOgTags as as, verifyWebhookSignature as at, COMMON_PRESETS as b, CORS_COMMON_HEADERS as c, type CorsConfig as d, type CorsOutput as e, type CspConfig as f, type CspDirective as g, type CspSource as h, type CurlCommand as i, type CurlConfig as j, DIRECTIVE_DESCRIPTIONS as k, type DirectiveConfig as l, type Header as m, type HotpResult as n, type HttpMethod as o, type JwkThumbprintErrorResult as p, type JwkThumbprintHash as q, type JwkThumbprintOutcome as r, type JwkThumbprintResult as s, type JwksError as t, type JwksParseResult as u, type JwksResult as v, type JwtAlgorithm as w, type JwtDecodeError as x, type JwtDecodeResult as y, type JwtExpiry as z };
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* encodeUrlComponent, decodeUrlComponent, isValidUrl, normalizeUrl
|
|
15
15
|
* - og-meta : parseMetaTags, validateOgTags, generateMetaHtml
|
|
16
16
|
* - totp-hotp-generator : generateHotp, generateTotp
|
|
17
|
+
* - webhook-signature-verifier : verifyWebhookSignature
|
|
17
18
|
*
|
|
18
19
|
* Node 18+ only. All crypto uses node:crypto; no browser-only APIs.
|
|
19
20
|
*/
|
|
@@ -333,6 +334,26 @@ interface TotpResult {
|
|
|
333
334
|
declare function generateTotp(secret: string, options?: TotpOptions): TotpResult | {
|
|
334
335
|
error: string;
|
|
335
336
|
};
|
|
337
|
+
type WebhookHashAlgorithm = 'sha1' | 'sha256' | 'sha512';
|
|
338
|
+
interface WebhookSignatureResult {
|
|
339
|
+
valid: boolean;
|
|
340
|
+
algorithm: WebhookHashAlgorithm;
|
|
341
|
+
expectedHex: string;
|
|
342
|
+
expectedBase64: string;
|
|
343
|
+
providedSignature: string;
|
|
344
|
+
matchedEncoding: 'hex' | 'base64' | null;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Recomputes an HMAC over a raw webhook payload and compares it to a
|
|
348
|
+
* provided signature, the check every webhook receiver (Stripe, GitHub,
|
|
349
|
+
* Shopify, etc.) has to do before trusting a request. Accepts a signature
|
|
350
|
+
* with or without the common `sha256=` prefix style, and matches against
|
|
351
|
+
* either hex or base64 encoding since providers differ on which they send.
|
|
352
|
+
* Comparison is constant-time to avoid leaking timing information.
|
|
353
|
+
*/
|
|
354
|
+
declare function verifyWebhookSignature(payload: string, secret: string, signature: string, algorithm?: WebhookHashAlgorithm): WebhookSignatureResult | {
|
|
355
|
+
error: string;
|
|
356
|
+
};
|
|
336
357
|
|
|
337
358
|
declare const api_COMMON_HEADERS: typeof COMMON_HEADERS;
|
|
338
359
|
declare const api_COMMON_PRESETS: typeof COMMON_PRESETS;
|
|
@@ -378,6 +399,8 @@ type api_TargetLanguage = TargetLanguage;
|
|
|
378
399
|
type api_TotpOptions = TotpOptions;
|
|
379
400
|
type api_TotpResult = TotpResult;
|
|
380
401
|
type api_TwitterTags = TwitterTags;
|
|
402
|
+
type api_WebhookHashAlgorithm = WebhookHashAlgorithm;
|
|
403
|
+
type api_WebhookSignatureResult = WebhookSignatureResult;
|
|
381
404
|
declare const api_addParam: typeof addParam;
|
|
382
405
|
declare const api_base64urlDecode: typeof base64urlDecode;
|
|
383
406
|
declare const api_base64urlEncode: typeof base64urlEncode;
|
|
@@ -414,8 +437,9 @@ declare const api_signJwt: typeof signJwt;
|
|
|
414
437
|
declare const api_validateCorsConfig: typeof validateCorsConfig;
|
|
415
438
|
declare const api_validateCspConfig: typeof validateCspConfig;
|
|
416
439
|
declare const api_validateOgTags: typeof validateOgTags;
|
|
440
|
+
declare const api_verifyWebhookSignature: typeof verifyWebhookSignature;
|
|
417
441
|
declare namespace api {
|
|
418
|
-
export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HotpResult as HotpResult, type api_HttpMethod as HttpMethod, type api_JwkSummary as JwkSummary, type api_JwkThumbprintErrorResult as JwkThumbprintErrorResult, type api_JwkThumbprintHash as JwkThumbprintHash, type api_JwkThumbprintOutcome as JwkThumbprintOutcome, type api_JwkThumbprintResult as JwkThumbprintResult, type api_JwksError as JwksError, type api_JwksParseResult as JwksParseResult, type api_JwksResult as JwksResult, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_OtpAlgorithm as OtpAlgorithm, type api_OtpOptions as OtpOptions, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TotpOptions as TotpOptions, type api_TotpResult as TotpResult, type api_TwitterTags as TwitterTags, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_computeJwkThumbprint as computeJwkThumbprint, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateHotp as generateHotp, api_generateMetaHtml as generateMetaHtml, api_generateTotp as generateTotp, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseJwks as parseJwks, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags };
|
|
442
|
+
export { api_COMMON_HEADERS as COMMON_HEADERS, api_COMMON_PRESETS as COMMON_PRESETS, api_CORS_COMMON_HEADERS as CORS_COMMON_HEADERS, type api_CorsConfig as CorsConfig, type api_CorsOutput as CorsOutput, type api_CspConfig as CspConfig, type api_CspDirective as CspDirective, type api_CspSource as CspSource, type api_CurlCommand as CurlCommand, type api_CurlConfig as CurlConfig, api_DEFAULT_CORS_CONFIG as DEFAULT_CORS_CONFIG, api_DIRECTIVE_DESCRIPTIONS as DIRECTIVE_DESCRIPTIONS, type api_DirectiveConfig as DirectiveConfig, type api_FormatResult as FormatResult, api_HTTP_METHODS as HTTP_METHODS, type api_Header as Header, type api_HotpResult as HotpResult, type api_HttpMethod as HttpMethod, type api_JwkSummary as JwkSummary, type api_JwkThumbprintErrorResult as JwkThumbprintErrorResult, type api_JwkThumbprintHash as JwkThumbprintHash, type api_JwkThumbprintOutcome as JwkThumbprintOutcome, type api_JwkThumbprintResult as JwkThumbprintResult, type api_JwksError as JwksError, type api_JwksParseResult as JwksParseResult, type api_JwksResult as JwksResult, type api_JwtAlgorithm as JwtAlgorithm, type api_JwtDecodeError as JwtDecodeError, type api_JwtDecodeResult as JwtDecodeResult, type api_JwtExpiry as JwtExpiry, type api_JwtPart as JwtPart, type api_JwtResult as JwtResult, type api_JwtSignOptions as JwtSignOptions, type api_MetaTags as MetaTags, type api_OgTags as OgTags, type api_OtpAlgorithm as OtpAlgorithm, type api_OtpOptions as OtpOptions, type api_ParsedUrl as ParsedUrl, type api_ResponseFormat as ResponseFormat, api_SUPPORTED_LANGUAGES as SUPPORTED_LANGUAGES, type api_TargetLanguage as TargetLanguage, type api_TotpOptions as TotpOptions, type api_TotpResult as TotpResult, type api_TwitterTags as TwitterTags, type api_WebhookHashAlgorithm as WebhookHashAlgorithm, type api_WebhookSignatureResult as WebhookSignatureResult, api_addParam as addParam, api_base64urlDecode as base64urlDecode, api_base64urlEncode as base64urlEncode, api_buildCurl as buildCurl, api_buildCurlMultiline as buildCurlMultiline, api_buildUrl as buildUrl, api_computeJwkThumbprint as computeJwkThumbprint, api_convertToCode as convertToCode, api_decodeJwt as decodeJwt, api_decodeUrlComponent as decodeUrlComponent, api_detectFormat as detectFormat, api_encodeUrlComponent as encodeUrlComponent, api_extractJsonPaths as extractJsonPaths, api_formatJwtJson as formatJwtJson, api_formatResponse as formatResponse, api_generateCors as generateCors, api_generateCspHeader as generateCspHeader, api_generateFullHeader as generateFullHeader, api_generateHotp as generateHotp, api_generateMetaHtml as generateMetaHtml, api_generateTotp as generateTotp, api_getParam as getParam, api_getStats as getStats, api_isValidUrl as isValidUrl, api_normalizeUrl as normalizeUrl, api_parseCspHeader as parseCspHeader, api_parseCurl as parseCurl, api_parseCurlCommand as parseCurlCommand, api_parseJwks as parseJwks, api_parseMetaTags as parseMetaTags, api_parseUrl as parseUrl, api_removeParam as removeParam, api_signJwt as signJwt, api_validateCorsConfig as validateCorsConfig, api_validateCspConfig as validateCspConfig, api_validateOgTags as validateOgTags, api_verifyWebhookSignature as verifyWebhookSignature };
|
|
419
443
|
}
|
|
420
444
|
|
|
421
|
-
export {
|
|
445
|
+
export { computeJwkThumbprint as $, type JwtPart as A, type JwtResult as B, COMMON_HEADERS as C, DEFAULT_CORS_CONFIG as D, type JwtSignOptions as E, type FormatResult as F, type OtpAlgorithm as G, HTTP_METHODS as H, type OtpOptions as I, type JwkSummary as J, type TotpOptions as K, type TotpResult as L, type MetaTags as M, type TwitterTags as N, type OgTags as O, type ParsedUrl as P, type WebhookSignatureResult as Q, type ResponseFormat as R, SUPPORTED_LANGUAGES as S, type TargetLanguage as T, addParam as U, base64urlDecode as V, type WebhookHashAlgorithm as W, base64urlEncode as X, buildCurl as Y, buildCurlMultiline as Z, buildUrl as _, api as a, convertToCode as a0, decodeJwt as a1, decodeUrlComponent as a2, detectFormat as a3, encodeUrlComponent as a4, extractJsonPaths as a5, formatJwtJson as a6, formatResponse as a7, generateCors as a8, generateCspHeader as a9, generateFullHeader as aa, generateHotp as ab, generateMetaHtml as ac, generateTotp as ad, getParam as ae, getStats as af, isValidUrl as ag, normalizeUrl as ah, parseCspHeader as ai, parseCurl as aj, parseCurlCommand as ak, parseJwks as al, parseMetaTags as am, parseUrl as an, removeParam as ao, signJwt as ap, validateCorsConfig as aq, validateCspConfig as ar, validateOgTags as as, verifyWebhookSignature as at, COMMON_PRESETS as b, CORS_COMMON_HEADERS as c, type CorsConfig as d, type CorsOutput as e, type CspConfig as f, type CspDirective as g, type CspSource as h, type CurlCommand as i, type CurlConfig as j, DIRECTIVE_DESCRIPTIONS as k, type DirectiveConfig as l, type Header as m, type HotpResult as n, type HttpMethod as o, type JwkThumbprintErrorResult as p, type JwkThumbprintHash as q, type JwkThumbprintOutcome as r, type JwkThumbprintResult as s, type JwksError as t, type JwksParseResult as u, type JwksResult as v, type JwtAlgorithm as w, type JwtDecodeError as x, type JwtDecodeResult as y, type JwtExpiry as z };
|
|
@@ -18,6 +18,7 @@ __export(text_exports, {
|
|
|
18
18
|
applyOps: () => applyOps,
|
|
19
19
|
calculateStringDistance: () => calculateStringDistance,
|
|
20
20
|
centerText: () => centerText,
|
|
21
|
+
checkOxfordCommaConsistency: () => checkOxfordCommaConsistency,
|
|
21
22
|
convertAll: () => convertAll,
|
|
22
23
|
convertCase: () => convertCase,
|
|
23
24
|
countWords: () => countWords,
|
|
@@ -26,6 +27,7 @@ __export(text_exports, {
|
|
|
26
27
|
detectDelimiter: () => detectDelimiter,
|
|
27
28
|
detectFillerWords: () => detectFillerWords,
|
|
28
29
|
detectPassiveVoice: () => detectPassiveVoice,
|
|
30
|
+
detectWordyPhrases: () => detectWordyPhrases,
|
|
29
31
|
diffLines: () => diffLines,
|
|
30
32
|
diffLinesSimple: () => diffLinesSimple,
|
|
31
33
|
diffStats: () => diffStats,
|
|
@@ -3095,5 +3097,99 @@ function getEmojiByCategory(category) {
|
|
|
3095
3097
|
function getEmojiCategories() {
|
|
3096
3098
|
return Array.from(new Set(EMOJI_TABLE.map((e) => e.category)));
|
|
3097
3099
|
}
|
|
3100
|
+
var WORDY_PHRASES = [
|
|
3101
|
+
{ phrase: "due to the fact that", suggestion: "because" },
|
|
3102
|
+
{ phrase: "in spite of the fact that", suggestion: "although" },
|
|
3103
|
+
{ phrase: "despite the fact that", suggestion: "although" },
|
|
3104
|
+
{ phrase: "in order to", suggestion: "to" },
|
|
3105
|
+
{ phrase: "for the purpose of", suggestion: "for" },
|
|
3106
|
+
{ phrase: "in the event that", suggestion: "if" },
|
|
3107
|
+
{ phrase: "in the near future", suggestion: "soon" },
|
|
3108
|
+
{ phrase: "at this point in time", suggestion: "now" },
|
|
3109
|
+
{ phrase: "at the present time", suggestion: "now" },
|
|
3110
|
+
{ phrase: "on a daily basis", suggestion: "daily" },
|
|
3111
|
+
{ phrase: "on a regular basis", suggestion: "regularly" },
|
|
3112
|
+
{ phrase: "in a timely manner", suggestion: "promptly" },
|
|
3113
|
+
{ phrase: "with regard to", suggestion: "regarding" },
|
|
3114
|
+
{ phrase: "with respect to", suggestion: "regarding" },
|
|
3115
|
+
{ phrase: "in regards to", suggestion: "regarding" },
|
|
3116
|
+
{ phrase: "with the exception of", suggestion: "except" },
|
|
3117
|
+
{ phrase: "in close proximity to", suggestion: "near" },
|
|
3118
|
+
{ phrase: "take into consideration", suggestion: "consider" },
|
|
3119
|
+
{ phrase: "give consideration to", suggestion: "consider" },
|
|
3120
|
+
{ phrase: "make a decision", suggestion: "decide" },
|
|
3121
|
+
{ phrase: "is able to", suggestion: "can" },
|
|
3122
|
+
{ phrase: "are able to", suggestion: "can" },
|
|
3123
|
+
{ phrase: "a large number of", suggestion: "many" },
|
|
3124
|
+
{ phrase: "a majority of", suggestion: "most" },
|
|
3125
|
+
{ phrase: "each and every", suggestion: "each" },
|
|
3126
|
+
{ phrase: "first and foremost", suggestion: "first" },
|
|
3127
|
+
{ phrase: "last but not least", suggestion: "finally" },
|
|
3128
|
+
{ phrase: "null and void", suggestion: "void" },
|
|
3129
|
+
{ phrase: "whether or not", suggestion: "whether" },
|
|
3130
|
+
{ phrase: "the reason why", suggestion: "the reason" },
|
|
3131
|
+
{ phrase: "end result", suggestion: "result" },
|
|
3132
|
+
{ phrase: "future plans", suggestion: "plans" },
|
|
3133
|
+
{ phrase: "past history", suggestion: "history" },
|
|
3134
|
+
{ phrase: "basic fundamentals", suggestion: "fundamentals" },
|
|
3135
|
+
{ phrase: "absolutely essential", suggestion: "essential" },
|
|
3136
|
+
{ phrase: "it is important to note that", suggestion: "(often removable)" },
|
|
3137
|
+
{ phrase: "as a matter of fact", suggestion: "in fact" },
|
|
3138
|
+
{ phrase: "in the process of", suggestion: "(often removable)" }
|
|
3139
|
+
];
|
|
3140
|
+
function _wordyRegex(phrase) {
|
|
3141
|
+
const tokens = phrase.split(/\s+/).map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
3142
|
+
return new RegExp("\\b" + tokens.join("\\s+") + "\\b", "gi");
|
|
3143
|
+
}
|
|
3144
|
+
function detectWordyPhrases(text) {
|
|
3145
|
+
const totalWords = (text.match(/[A-Za-z0-9']+/g) ?? []).length;
|
|
3146
|
+
const matches = [];
|
|
3147
|
+
for (const entry of WORDY_PHRASES) {
|
|
3148
|
+
const re = _wordyRegex(entry.phrase);
|
|
3149
|
+
const indices = [];
|
|
3150
|
+
let m;
|
|
3151
|
+
while ((m = re.exec(text)) !== null) {
|
|
3152
|
+
indices.push(m.index);
|
|
3153
|
+
if (m.index === re.lastIndex) re.lastIndex++;
|
|
3154
|
+
}
|
|
3155
|
+
if (indices.length > 0) {
|
|
3156
|
+
matches.push({ phrase: entry.phrase, suggestion: entry.suggestion, count: indices.length, indices });
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
matches.sort((a, b) => b.count - a.count || a.phrase.localeCompare(b.phrase));
|
|
3160
|
+
const totalMatches = matches.reduce((s, m) => s + m.count, 0);
|
|
3161
|
+
const density = totalWords > 0 ? Math.round(totalMatches / totalWords * 1e3) / 10 : 0;
|
|
3162
|
+
return { totalWords, totalMatches, density, matches };
|
|
3163
|
+
}
|
|
3164
|
+
var _OXFORD_CONJ_RE = /(,)?\s+\b(?:and|or)\b\s+/gi;
|
|
3165
|
+
function checkOxfordCommaConsistency(text) {
|
|
3166
|
+
const instances = [];
|
|
3167
|
+
_OXFORD_CONJ_RE.lastIndex = 0;
|
|
3168
|
+
let m;
|
|
3169
|
+
while ((m = _OXFORD_CONJ_RE.exec(text)) !== null) {
|
|
3170
|
+
const matchStart = m.index;
|
|
3171
|
+
const hasCommaBefore = !!m[1];
|
|
3172
|
+
let clauseStart = -1;
|
|
3173
|
+
for (const ch of [".", "!", "?", "\n"]) {
|
|
3174
|
+
const idx = text.lastIndexOf(ch, matchStart - 1);
|
|
3175
|
+
if (idx > clauseStart) clauseStart = idx;
|
|
3176
|
+
}
|
|
3177
|
+
clauseStart += 1;
|
|
3178
|
+
const clause = text.slice(clauseStart, matchStart);
|
|
3179
|
+
const commaCount = (clause.match(/,/g) ?? []).length;
|
|
3180
|
+
if (commaCount < 1) continue;
|
|
3181
|
+
const snippetStart = Math.max(clauseStart, matchStart - 60);
|
|
3182
|
+
const afterConjEnd = _OXFORD_CONJ_RE.lastIndex;
|
|
3183
|
+
const tail = text.slice(afterConjEnd);
|
|
3184
|
+
const boundaryOffset = tail.search(/[.!?\n,]/);
|
|
3185
|
+
const snippetEnd = boundaryOffset === -1 ? Math.min(text.length, afterConjEnd + 40) : afterConjEnd + boundaryOffset;
|
|
3186
|
+
const snippet = text.slice(snippetStart, snippetEnd).trim();
|
|
3187
|
+
instances.push({ snippet, hasOxfordComma: hasCommaBefore, index: matchStart });
|
|
3188
|
+
}
|
|
3189
|
+
const withOxfordComma = instances.filter((i) => i.hasOxfordComma).length;
|
|
3190
|
+
const withoutOxfordComma = instances.length - withOxfordComma;
|
|
3191
|
+
const consistent = withOxfordComma === 0 || withoutOxfordComma === 0;
|
|
3192
|
+
return { totalLists: instances.length, withOxfordComma, withoutOxfordComma, consistent, instances };
|
|
3193
|
+
}
|
|
3098
3194
|
|
|
3099
|
-
export { CASE_FORMATS, DEFAULT_CONVERT_OPTIONS, EMOJI_TABLE, ESCAPE_MODES, LINE_OPS, MORSE_CODE, addBorder, analyzeKeywordDensity, analyzeSentenceLengths, analyzeText, applyOp, applyOps, calculateStringDistance, centerText, convertAll, convertCase, countWords, csvToHtml, csvToMarkdown, detectDelimiter, detectFillerWords, detectPassiveVoice, diffLines, diffLinesSimple, diffStats, escapeAll, escapeString, extractHeadings, formatReadingTime, generate, generateDiff, generateHtmlTable, generateMarkdownTable, generateParagraphs, generateSentences, generateWords, getAvailableFonts, getEmojiByCategory, getEmojiByChar, getEmojiByShortcode, getEmojiCategories, getMorseForChar, getMorseTiming, htmlToMarkdown, isValidMorse, markdownToHtml, morseToText, numberToOrdinal, numberToRoman, numberToWords, ordinalWords, parseDiff, parseTableData, readabilityScore, renderMarkdown, romanToNumber, scoreReadability, searchEmoji, sentenceCount, slugify, slugifyAll, syllableCount, textToAscii, textToMorse, text_exports, unescapeString, wordFrequency };
|
|
3195
|
+
export { CASE_FORMATS, DEFAULT_CONVERT_OPTIONS, EMOJI_TABLE, ESCAPE_MODES, LINE_OPS, MORSE_CODE, addBorder, analyzeKeywordDensity, analyzeSentenceLengths, analyzeText, applyOp, applyOps, calculateStringDistance, centerText, checkOxfordCommaConsistency, convertAll, convertCase, countWords, csvToHtml, csvToMarkdown, detectDelimiter, detectFillerWords, detectPassiveVoice, detectWordyPhrases, diffLines, diffLinesSimple, diffStats, escapeAll, escapeString, extractHeadings, formatReadingTime, generate, generateDiff, generateHtmlTable, generateMarkdownTable, generateParagraphs, generateSentences, generateWords, getAvailableFonts, getEmojiByCategory, getEmojiByChar, getEmojiByShortcode, getEmojiCategories, getMorseForChar, getMorseTiming, htmlToMarkdown, isValidMorse, markdownToHtml, morseToText, numberToOrdinal, numberToRoman, numberToWords, ordinalWords, parseDiff, parseTableData, readabilityScore, renderMarkdown, romanToNumber, scoreReadability, searchEmoji, sentenceCount, slugify, slugifyAll, syllableCount, textToAscii, textToMorse, text_exports, unescapeString, wordFrequency };
|
|
@@ -44,6 +44,7 @@ __export(units_exports, {
|
|
|
44
44
|
calculateMovingAverages: () => calculateMovingAverages,
|
|
45
45
|
calculatePaybackPeriod: () => calculatePaybackPeriod,
|
|
46
46
|
calculatePercentageChange: () => calculatePercentageChange,
|
|
47
|
+
calculateRequiredBandwidth: () => calculateRequiredBandwidth,
|
|
47
48
|
calculateRoi: () => calculateRoi,
|
|
48
49
|
calculateRuleOf72: () => calculateRuleOf72,
|
|
49
50
|
calculateSavingsGoal: () => calculateSavingsGoal,
|
|
@@ -52,6 +53,7 @@ __export(units_exports, {
|
|
|
52
53
|
calculateTaxEquivalentYield: () => calculateTaxEquivalentYield,
|
|
53
54
|
calculateTimeValue: () => calculateTimeValue,
|
|
54
55
|
calculateTipSplit: () => calculateTipSplit,
|
|
56
|
+
calculateTransferTime: () => calculateTransferTime,
|
|
55
57
|
calculateVideoBitrate: () => calculateVideoBitrate,
|
|
56
58
|
compareSemver: () => compareSemver,
|
|
57
59
|
compareUnitPrices: () => compareUnitPrices,
|
|
@@ -2697,5 +2699,68 @@ function calculateLoanPrepaymentPenalty(payoffBalance, penaltyType, params) {
|
|
|
2697
2699
|
totalPayoffCost: round2(payoffBalance + penaltyAmount)
|
|
2698
2700
|
};
|
|
2699
2701
|
}
|
|
2702
|
+
var FILE_SIZE_UNIT_BYTES = {
|
|
2703
|
+
B: 1,
|
|
2704
|
+
KB: 1e3,
|
|
2705
|
+
MB: 1e6,
|
|
2706
|
+
GB: 1e9,
|
|
2707
|
+
TB: 1e12
|
|
2708
|
+
};
|
|
2709
|
+
var SPEED_UNIT_BITS_PER_SECOND = {
|
|
2710
|
+
Kbps: 1e3,
|
|
2711
|
+
Mbps: 1e6,
|
|
2712
|
+
Gbps: 1e9,
|
|
2713
|
+
KBps: 1e3 * 8,
|
|
2714
|
+
MBps: 1e6 * 8,
|
|
2715
|
+
GBps: 1e9 * 8
|
|
2716
|
+
};
|
|
2717
|
+
function formatDurationSeconds(totalSeconds) {
|
|
2718
|
+
if (totalSeconds < 1) return `${(totalSeconds * 1e3).toFixed(0)}ms`;
|
|
2719
|
+
if (totalSeconds < 60) {
|
|
2720
|
+
const decimals = totalSeconds < 10 && totalSeconds % 1 !== 0 ? 1 : 0;
|
|
2721
|
+
return `${totalSeconds.toFixed(decimals)}s`;
|
|
2722
|
+
}
|
|
2723
|
+
const days = Math.floor(totalSeconds / 86400);
|
|
2724
|
+
const hours = Math.floor(totalSeconds % 86400 / 3600);
|
|
2725
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
2726
|
+
const seconds = Math.round(totalSeconds % 60);
|
|
2727
|
+
const parts = [];
|
|
2728
|
+
if (days > 0) parts.push(`${days}d`);
|
|
2729
|
+
if (hours > 0) parts.push(`${hours}h`);
|
|
2730
|
+
if (minutes > 0) parts.push(`${minutes}m`);
|
|
2731
|
+
if (seconds > 0 || parts.length === 0) parts.push(`${seconds}s`);
|
|
2732
|
+
return parts.join(" ");
|
|
2733
|
+
}
|
|
2734
|
+
function calculateTransferTime(fileSize, fileSizeUnit, speed, speedUnit) {
|
|
2735
|
+
if (!Number.isFinite(fileSize) || fileSize <= 0) return { error: "File size must be a positive number" };
|
|
2736
|
+
if (!Number.isFinite(speed) || speed <= 0) return { error: "Connection speed must be a positive number" };
|
|
2737
|
+
if (!(fileSizeUnit in FILE_SIZE_UNIT_BYTES)) return { error: `Unsupported file size unit: ${fileSizeUnit}` };
|
|
2738
|
+
if (!(speedUnit in SPEED_UNIT_BITS_PER_SECOND)) return { error: `Unsupported speed unit: ${speedUnit}` };
|
|
2739
|
+
const fileSizeBytes = fileSize * FILE_SIZE_UNIT_BYTES[fileSizeUnit];
|
|
2740
|
+
const speedBitsPerSecond = speed * SPEED_UNIT_BITS_PER_SECOND[speedUnit];
|
|
2741
|
+
const transferTimeSeconds = fileSizeBytes * 8 / speedBitsPerSecond;
|
|
2742
|
+
return {
|
|
2743
|
+
fileSizeBytes,
|
|
2744
|
+
speedBitsPerSecond,
|
|
2745
|
+
transferTimeSeconds,
|
|
2746
|
+
formattedTime: formatDurationSeconds(transferTimeSeconds)
|
|
2747
|
+
};
|
|
2748
|
+
}
|
|
2749
|
+
function calculateRequiredBandwidth(fileSize, fileSizeUnit, targetSeconds) {
|
|
2750
|
+
if (!Number.isFinite(fileSize) || fileSize <= 0) return { error: "File size must be a positive number" };
|
|
2751
|
+
if (!Number.isFinite(targetSeconds) || targetSeconds <= 0) {
|
|
2752
|
+
return { error: "Target time must be a positive number of seconds" };
|
|
2753
|
+
}
|
|
2754
|
+
if (!(fileSizeUnit in FILE_SIZE_UNIT_BYTES)) return { error: `Unsupported file size unit: ${fileSizeUnit}` };
|
|
2755
|
+
const fileSizeBytes = fileSize * FILE_SIZE_UNIT_BYTES[fileSizeUnit];
|
|
2756
|
+
const requiredBitsPerSecond = fileSizeBytes * 8 / targetSeconds;
|
|
2757
|
+
return {
|
|
2758
|
+
fileSizeBytes,
|
|
2759
|
+
targetSeconds,
|
|
2760
|
+
requiredBitsPerSecond,
|
|
2761
|
+
requiredMbps: requiredBitsPerSecond / 1e6,
|
|
2762
|
+
requiredMBps: requiredBitsPerSecond / 8 / 1e6
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2700
2765
|
|
|
2701
|
-
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, GPA_GRADE_POINTS, USD_DENOMINATIONS, applySuccessiveDiscounts, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateBlendedLoanRate, calculateBreakEven, calculateCashBreakdown, calculateCashRounding, calculateCdMaturity, calculateChange, calculateCompoundInterest, calculateCreditUtilization, calculateDebtToIncomeRatio, calculateDepreciationSchedule, calculateDiscount, calculateEmi, calculateExtraPaymentPayoff, calculateFreelancerRate, calculateGpa, calculateLoan, calculateLoanPrepaymentPenalty, calculateLoanRefinance, calculateMarginMarkup, calculateMortgagePoints, calculateMovingAverages, calculatePaybackPeriod, calculatePercentageChange, calculateRoi, calculateRuleOf72, calculateSavingsGoal, calculateSimpleInterest, calculateTax, calculateTaxEquivalentYield, calculateTimeValue, calculateTipSplit, calculateVideoBitrate, compareSemver, compareUnitPrices, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, marginToMarkup, markupToMargin, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, planDebtPayoff, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, validateIsin, validateVin, viewportToPx };
|
|
2766
|
+
export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, GPA_GRADE_POINTS, USD_DENOMINATIONS, applySuccessiveDiscounts, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateBlendedLoanRate, calculateBreakEven, calculateCashBreakdown, calculateCashRounding, calculateCdMaturity, calculateChange, calculateCompoundInterest, calculateCreditUtilization, calculateDebtToIncomeRatio, calculateDepreciationSchedule, calculateDiscount, calculateEmi, calculateExtraPaymentPayoff, calculateFreelancerRate, calculateGpa, calculateLoan, calculateLoanPrepaymentPenalty, calculateLoanRefinance, calculateMarginMarkup, calculateMortgagePoints, calculateMovingAverages, calculatePaybackPeriod, calculatePercentageChange, calculateRequiredBandwidth, calculateRoi, calculateRuleOf72, calculateSavingsGoal, calculateSimpleInterest, calculateTax, calculateTaxEquivalentYield, calculateTimeValue, calculateTipSplit, calculateTransferTime, calculateVideoBitrate, compareSemver, compareUnitPrices, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, marginToMarkup, markupToMargin, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, planDebtPayoff, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, units_exports, validateBarcode, validateCardNumber, validateIban, validateIsbn, validateIsin, validateVin, viewportToPx };
|
|
@@ -46,7 +46,8 @@ __export(api_exports, {
|
|
|
46
46
|
signJwt: () => signJwt,
|
|
47
47
|
validateCorsConfig: () => validateCorsConfig,
|
|
48
48
|
validateCspConfig: () => validateCspConfig,
|
|
49
|
-
validateOgTags: () => validateOgTags
|
|
49
|
+
validateOgTags: () => validateOgTags,
|
|
50
|
+
verifyWebhookSignature: () => verifyWebhookSignature
|
|
50
51
|
});
|
|
51
52
|
function escapeShell(value) {
|
|
52
53
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
@@ -1379,5 +1380,39 @@ function generateTotp(secret, options = {}) {
|
|
|
1379
1380
|
const secondsRemaining = periodSeconds - timestamp % periodSeconds;
|
|
1380
1381
|
return { ...hotp, periodSeconds, secondsRemaining };
|
|
1381
1382
|
}
|
|
1383
|
+
var WEBHOOK_HASH_ALGORITHMS = ["sha1", "sha256", "sha512"];
|
|
1384
|
+
function constantTimeEqual(a, b) {
|
|
1385
|
+
if (a.length !== b.length) return false;
|
|
1386
|
+
let diff = 0;
|
|
1387
|
+
for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
1388
|
+
return diff === 0;
|
|
1389
|
+
}
|
|
1390
|
+
function verifyWebhookSignature(payload, secret, signature, algorithm = "sha256") {
|
|
1391
|
+
if (!payload) return { error: "Payload is required" };
|
|
1392
|
+
if (!secret) return { error: "Secret is required" };
|
|
1393
|
+
if (!signature || !signature.trim()) return { error: "Signature is required" };
|
|
1394
|
+
if (!WEBHOOK_HASH_ALGORITHMS.includes(algorithm)) {
|
|
1395
|
+
return { error: "Algorithm must be one of sha1, sha256, sha512" };
|
|
1396
|
+
}
|
|
1397
|
+
const trimmedSignature = signature.trim();
|
|
1398
|
+
const prefixMatch = trimmedSignature.match(/^(sha1|sha256|sha512)=(.+)$/i);
|
|
1399
|
+
const providedSignature = prefixMatch ? prefixMatch[2].trim() : trimmedSignature;
|
|
1400
|
+
const expectedHex = createHmac(algorithm, secret).update(payload, "utf8").digest("hex");
|
|
1401
|
+
const expectedBase64 = createHmac(algorithm, secret).update(payload, "utf8").digest("base64");
|
|
1402
|
+
let matchedEncoding = null;
|
|
1403
|
+
if (constantTimeEqual(providedSignature.toLowerCase(), expectedHex.toLowerCase())) {
|
|
1404
|
+
matchedEncoding = "hex";
|
|
1405
|
+
} else if (constantTimeEqual(providedSignature, expectedBase64)) {
|
|
1406
|
+
matchedEncoding = "base64";
|
|
1407
|
+
}
|
|
1408
|
+
return {
|
|
1409
|
+
valid: matchedEncoding !== null,
|
|
1410
|
+
algorithm,
|
|
1411
|
+
expectedHex,
|
|
1412
|
+
expectedBase64,
|
|
1413
|
+
providedSignature: trimmedSignature,
|
|
1414
|
+
matchedEncoding
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1382
1417
|
|
|
1383
|
-
export { COMMON_HEADERS, COMMON_PRESETS, CORS_COMMON_HEADERS, DEFAULT_CORS_CONFIG, DIRECTIVE_DESCRIPTIONS, HTTP_METHODS, SUPPORTED_LANGUAGES, addParam, api_exports, base64urlDecode, base64urlEncode, buildCurl, buildCurlMultiline, buildUrl, computeJwkThumbprint, convertToCode, decodeJwt, decodeUrlComponent, detectFormat, encodeUrlComponent, extractJsonPaths, formatJwtJson, formatResponse, generateCors, generateCspHeader, generateFullHeader, generateHotp, generateMetaHtml, generateTotp, getParam, getStats, isValidUrl, normalizeUrl, parseCspHeader, parseCurl, parseCurlCommand, parseJwks, parseMetaTags, parseUrl, removeParam, signJwt, validateCorsConfig, validateCspConfig, validateOgTags };
|
|
1418
|
+
export { COMMON_HEADERS, COMMON_PRESETS, CORS_COMMON_HEADERS, DEFAULT_CORS_CONFIG, DIRECTIVE_DESCRIPTIONS, HTTP_METHODS, SUPPORTED_LANGUAGES, addParam, api_exports, base64urlDecode, base64urlEncode, buildCurl, buildCurlMultiline, buildUrl, computeJwkThumbprint, convertToCode, decodeJwt, decodeUrlComponent, detectFormat, encodeUrlComponent, extractJsonPaths, formatJwtJson, formatResponse, generateCors, generateCspHeader, generateFullHeader, generateHotp, generateMetaHtml, generateTotp, getParam, getStats, isValidUrl, normalizeUrl, parseCspHeader, parseCurl, parseCurlCommand, parseJwks, parseMetaTags, parseUrl, removeParam, signJwt, validateCorsConfig, validateCspConfig, validateOgTags, verifyWebhookSignature };
|