@corvushold/guard-sdk 0.11.5 → 0.13.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/dist/index.cjs +27 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1095,12 +1095,25 @@ declare class GuardClient {
|
|
|
1095
1095
|
*
|
|
1096
1096
|
* @param providerSlug - The provider slug (e.g., 'okta', 'azure-ad', 'google-saml')
|
|
1097
1097
|
* @param params - Optional parameters for the SSO flow
|
|
1098
|
+
* @param params.useQueryParams - **SECURITY WARNING**: When true, tokens are returned as URL query parameters
|
|
1099
|
+
* instead of fragments. Query parameters are sent to servers and logged, potentially exposing tokens.
|
|
1100
|
+
* Only use this for server-side callback routes that cannot access URL fragments.
|
|
1101
|
+
* Default: false (uses secure URL fragments that aren't sent to servers or logged)
|
|
1098
1102
|
* @returns The redirect URL to send the user to for authentication
|
|
1099
1103
|
*
|
|
1100
1104
|
* @example
|
|
1101
1105
|
* ```ts
|
|
1102
|
-
*
|
|
1106
|
+
* // Recommended: Client-side callback (tokens in URL fragment - more secure)
|
|
1107
|
+
* const result = await client.startSso('okta', {
|
|
1108
|
+
* redirect_url: 'https://myapp.com/callback'
|
|
1109
|
+
* });
|
|
1103
1110
|
* window.location.href = result.data.redirect_url;
|
|
1111
|
+
*
|
|
1112
|
+
* // Less secure: Server-side callback (tokens in query params - visible in logs)
|
|
1113
|
+
* const result = await client.startSso('okta', {
|
|
1114
|
+
* redirect_url: 'https://myapp.com/api/callback',
|
|
1115
|
+
* useQueryParams: true // ⚠️ Tokens will be in server logs
|
|
1116
|
+
* });
|
|
1104
1117
|
* ```
|
|
1105
1118
|
*/
|
|
1106
1119
|
startSso(providerSlug: SsoProvider, params?: {
|
|
@@ -1108,6 +1121,18 @@ declare class GuardClient {
|
|
|
1108
1121
|
redirect_url?: string;
|
|
1109
1122
|
login_hint?: string;
|
|
1110
1123
|
force_authn?: boolean;
|
|
1124
|
+
/**
|
|
1125
|
+
* **SECURITY WARNING**: When true, tokens are returned as URL query parameters instead of fragments.
|
|
1126
|
+
*
|
|
1127
|
+
* - Query parameters are sent to servers and appear in access logs, referrer headers, and browser history
|
|
1128
|
+
* - URL fragments are NOT sent to servers and provide better security
|
|
1129
|
+
*
|
|
1130
|
+
* Only set this to `true` if you have a server-side callback route that cannot access URL fragments.
|
|
1131
|
+
* For client-side callbacks, leave this as `false` (default) to use the more secure fragment-based approach.
|
|
1132
|
+
*
|
|
1133
|
+
* @default false
|
|
1134
|
+
*/
|
|
1135
|
+
useQueryParams?: boolean;
|
|
1111
1136
|
}): Promise<ResponseWrapper<{
|
|
1112
1137
|
redirect_url: string;
|
|
1113
1138
|
}>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1095,12 +1095,25 @@ declare class GuardClient {
|
|
|
1095
1095
|
*
|
|
1096
1096
|
* @param providerSlug - The provider slug (e.g., 'okta', 'azure-ad', 'google-saml')
|
|
1097
1097
|
* @param params - Optional parameters for the SSO flow
|
|
1098
|
+
* @param params.useQueryParams - **SECURITY WARNING**: When true, tokens are returned as URL query parameters
|
|
1099
|
+
* instead of fragments. Query parameters are sent to servers and logged, potentially exposing tokens.
|
|
1100
|
+
* Only use this for server-side callback routes that cannot access URL fragments.
|
|
1101
|
+
* Default: false (uses secure URL fragments that aren't sent to servers or logged)
|
|
1098
1102
|
* @returns The redirect URL to send the user to for authentication
|
|
1099
1103
|
*
|
|
1100
1104
|
* @example
|
|
1101
1105
|
* ```ts
|
|
1102
|
-
*
|
|
1106
|
+
* // Recommended: Client-side callback (tokens in URL fragment - more secure)
|
|
1107
|
+
* const result = await client.startSso('okta', {
|
|
1108
|
+
* redirect_url: 'https://myapp.com/callback'
|
|
1109
|
+
* });
|
|
1103
1110
|
* window.location.href = result.data.redirect_url;
|
|
1111
|
+
*
|
|
1112
|
+
* // Less secure: Server-side callback (tokens in query params - visible in logs)
|
|
1113
|
+
* const result = await client.startSso('okta', {
|
|
1114
|
+
* redirect_url: 'https://myapp.com/api/callback',
|
|
1115
|
+
* useQueryParams: true // ⚠️ Tokens will be in server logs
|
|
1116
|
+
* });
|
|
1104
1117
|
* ```
|
|
1105
1118
|
*/
|
|
1106
1119
|
startSso(providerSlug: SsoProvider, params?: {
|
|
@@ -1108,6 +1121,18 @@ declare class GuardClient {
|
|
|
1108
1121
|
redirect_url?: string;
|
|
1109
1122
|
login_hint?: string;
|
|
1110
1123
|
force_authn?: boolean;
|
|
1124
|
+
/**
|
|
1125
|
+
* **SECURITY WARNING**: When true, tokens are returned as URL query parameters instead of fragments.
|
|
1126
|
+
*
|
|
1127
|
+
* - Query parameters are sent to servers and appear in access logs, referrer headers, and browser history
|
|
1128
|
+
* - URL fragments are NOT sent to servers and provide better security
|
|
1129
|
+
*
|
|
1130
|
+
* Only set this to `true` if you have a server-side callback route that cannot access URL fragments.
|
|
1131
|
+
* For client-side callbacks, leave this as `false` (default) to use the more secure fragment-based approach.
|
|
1132
|
+
*
|
|
1133
|
+
* @default false
|
|
1134
|
+
*/
|
|
1135
|
+
useQueryParams?: boolean;
|
|
1111
1136
|
}): Promise<ResponseWrapper<{
|
|
1112
1137
|
redirect_url: string;
|
|
1113
1138
|
}>>;
|
package/dist/index.js
CHANGED
|
@@ -277,7 +277,7 @@ var HttpClient = class {
|
|
|
277
277
|
|
|
278
278
|
// package.json
|
|
279
279
|
var package_default = {
|
|
280
|
-
version: "0.
|
|
280
|
+
version: "0.13.0"};
|
|
281
281
|
|
|
282
282
|
// src/client.ts
|
|
283
283
|
function isTenantSelectionRequired(data) {
|
|
@@ -593,19 +593,43 @@ var GuardClient = class {
|
|
|
593
593
|
*
|
|
594
594
|
* @param providerSlug - The provider slug (e.g., 'okta', 'azure-ad', 'google-saml')
|
|
595
595
|
* @param params - Optional parameters for the SSO flow
|
|
596
|
+
* @param params.useQueryParams - **SECURITY WARNING**: When true, tokens are returned as URL query parameters
|
|
597
|
+
* instead of fragments. Query parameters are sent to servers and logged, potentially exposing tokens.
|
|
598
|
+
* Only use this for server-side callback routes that cannot access URL fragments.
|
|
599
|
+
* Default: false (uses secure URL fragments that aren't sent to servers or logged)
|
|
596
600
|
* @returns The redirect URL to send the user to for authentication
|
|
597
601
|
*
|
|
598
602
|
* @example
|
|
599
603
|
* ```ts
|
|
600
|
-
*
|
|
604
|
+
* // Recommended: Client-side callback (tokens in URL fragment - more secure)
|
|
605
|
+
* const result = await client.startSso('okta', {
|
|
606
|
+
* redirect_url: 'https://myapp.com/callback'
|
|
607
|
+
* });
|
|
601
608
|
* window.location.href = result.data.redirect_url;
|
|
609
|
+
*
|
|
610
|
+
* // Less secure: Server-side callback (tokens in query params - visible in logs)
|
|
611
|
+
* const result = await client.startSso('okta', {
|
|
612
|
+
* redirect_url: 'https://myapp.com/api/callback',
|
|
613
|
+
* useQueryParams: true // ⚠️ Tokens will be in server logs
|
|
614
|
+
* });
|
|
602
615
|
* ```
|
|
603
616
|
*/
|
|
604
617
|
async startSso(providerSlug, params = {}) {
|
|
605
618
|
const tenant = params.tenant_id ?? this.tenantId;
|
|
606
619
|
if (!tenant) throw new Error("tenant_id is required for SSO; set via params or client constructor");
|
|
620
|
+
let redirectUrl = params.redirect_url;
|
|
621
|
+
if (redirectUrl && params.useQueryParams) {
|
|
622
|
+
try {
|
|
623
|
+
const url = new URL(redirectUrl);
|
|
624
|
+
url.searchParams.set("use_query", "true");
|
|
625
|
+
redirectUrl = url.toString();
|
|
626
|
+
} catch {
|
|
627
|
+
const separator = redirectUrl.includes("?") ? "&" : "?";
|
|
628
|
+
redirectUrl = `${redirectUrl}${separator}use_query=true`;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
607
631
|
const qs = this.buildQuery({
|
|
608
|
-
redirect_url:
|
|
632
|
+
redirect_url: redirectUrl,
|
|
609
633
|
login_hint: params.login_hint,
|
|
610
634
|
force_authn: params.force_authn
|
|
611
635
|
});
|