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 =
63
63
| "array"
64
64
| "null" ;
65
65
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
+ */
66
71
export function getDataType ( value : JsonValue ) : DataType {
67
72
if ( Array . isArray ( value ) ) return "array" ;
68
73
if ( value === null ) return "null" ;
69
74
return typeof value ;
70
75
}
71
76
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
+ */
72
82
export function tryParseJson ( str : string ) : {
73
83
success : boolean ;
74
84
data : JsonValue ;
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ type CallbackParams =
24
24
error_uri : string | null ;
25
25
} ;
26
26
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
+ */
27
32
export const parseOAuthCallbackParams = ( location : string ) : CallbackParams => {
28
33
const params = new URLSearchParams ( location ) ;
29
34
@@ -62,6 +67,11 @@ export const generateOAuthState = () => {
62
67
) ;
63
68
} ;
64
69
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
+ */
65
75
export const generateOAuthErrorDescription = (
66
76
params : Extract < CallbackParams , { successful : false } > ,
67
77
) : string => {
You can’t perform that action at this time.
0 commit comments