File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -63,12 +63,22 @@ export type DataType =
6363 | "array"
6464 | "null" ;
6565
66+ /**
67+ * Determines the specific data type of a JSON value
68+ * @param value The JSON value to analyze
69+ * @returns The specific data type including "array" and "null" as distinct types
70+ */
6671export function getDataType ( value : JsonValue ) : DataType {
6772 if ( Array . isArray ( value ) ) return "array" ;
6873 if ( value === null ) return "null" ;
6974 return typeof value ;
7075}
7176
77+ /**
78+ * Attempts to parse a string as JSON, only for objects and arrays
79+ * @param str The string to parse
80+ * @returns Object with success boolean and either parsed data or original string
81+ */
7282export function tryParseJson ( str : string ) : {
7383 success : boolean ;
7484 data : JsonValue ;
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ type CallbackParams =
2424 error_uri : string | null ;
2525 } ;
2626
27+ /**
28+ * Parses OAuth 2.1 callback parameters from a URL search string
29+ * @param location The URL search string (e.g., "?code=abc123" or "?error=access_denied")
30+ * @returns Parsed callback parameters with success/error information
31+ */
2732export const parseOAuthCallbackParams = ( location : string ) : CallbackParams => {
2833 const params = new URLSearchParams ( location ) ;
2934
@@ -62,6 +67,11 @@ export const generateOAuthState = () => {
6267 ) ;
6368} ;
6469
70+ /**
71+ * Generates a human-readable error description from OAuth callback error parameters
72+ * @param params OAuth error callback parameters containing error details
73+ * @returns Formatted multiline error message with error code, description, and optional URI
74+ */
6575export const generateOAuthErrorDescription = (
6676 params : Extract < CallbackParams , { successful : false } > ,
6777) : string => {
You can’t perform that action at this time.
0 commit comments