@corvushold/guard-sdk 0.12.0 → 0.13.1
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 +35 -1
- package/dist/index.d.ts +35 -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
|
@@ -276,6 +276,7 @@ interface components {
|
|
|
276
276
|
};
|
|
277
277
|
"controller.createTenantReq": {
|
|
278
278
|
name: string;
|
|
279
|
+
parent_tenant_id?: string;
|
|
279
280
|
};
|
|
280
281
|
"controller.fgaAuthorizeReq": {
|
|
281
282
|
object_id?: string;
|
|
@@ -526,6 +527,8 @@ interface components {
|
|
|
526
527
|
workos_default_organization_id?: string;
|
|
527
528
|
};
|
|
528
529
|
"controller.signupReq": {
|
|
530
|
+
/** @description If true, assigns admin role to the new user (for tenant bootstrap) */
|
|
531
|
+
assign_admin?: boolean;
|
|
529
532
|
email: string;
|
|
530
533
|
first_name?: string;
|
|
531
534
|
last_name?: string;
|
|
@@ -546,6 +549,7 @@ interface components {
|
|
|
546
549
|
id?: string;
|
|
547
550
|
is_active?: boolean;
|
|
548
551
|
name?: string;
|
|
552
|
+
parent_tenant_id?: string;
|
|
549
553
|
updated_at?: string;
|
|
550
554
|
};
|
|
551
555
|
"controller.updateProfileReq": {
|
|
@@ -575,6 +579,11 @@ interface components {
|
|
|
575
579
|
/** @description OIDC/OAuth2 fields */
|
|
576
580
|
issuer?: string;
|
|
577
581
|
jwks_uri?: string;
|
|
582
|
+
/**
|
|
583
|
+
* @description Policy for linking SSO identities to existing accounts
|
|
584
|
+
* @enum {string}
|
|
585
|
+
*/
|
|
586
|
+
linking_policy?: "never" | "verified_email" | "always";
|
|
578
587
|
name?: string;
|
|
579
588
|
response_mode?: string;
|
|
580
589
|
response_type?: string;
|
|
@@ -1095,12 +1104,25 @@ declare class GuardClient {
|
|
|
1095
1104
|
*
|
|
1096
1105
|
* @param providerSlug - The provider slug (e.g., 'okta', 'azure-ad', 'google-saml')
|
|
1097
1106
|
* @param params - Optional parameters for the SSO flow
|
|
1107
|
+
* @param params.useQueryParams - **SECURITY WARNING**: When true, tokens are returned as URL query parameters
|
|
1108
|
+
* instead of fragments. Query parameters are sent to servers and logged, potentially exposing tokens.
|
|
1109
|
+
* Only use this for server-side callback routes that cannot access URL fragments.
|
|
1110
|
+
* Default: false (uses secure URL fragments that aren't sent to servers or logged)
|
|
1098
1111
|
* @returns The redirect URL to send the user to for authentication
|
|
1099
1112
|
*
|
|
1100
1113
|
* @example
|
|
1101
1114
|
* ```ts
|
|
1102
|
-
*
|
|
1115
|
+
* // Recommended: Client-side callback (tokens in URL fragment - more secure)
|
|
1116
|
+
* const result = await client.startSso('okta', {
|
|
1117
|
+
* redirect_url: 'https://myapp.com/callback'
|
|
1118
|
+
* });
|
|
1103
1119
|
* window.location.href = result.data.redirect_url;
|
|
1120
|
+
*
|
|
1121
|
+
* // Less secure: Server-side callback (tokens in query params - visible in logs)
|
|
1122
|
+
* const result = await client.startSso('okta', {
|
|
1123
|
+
* redirect_url: 'https://myapp.com/api/callback',
|
|
1124
|
+
* useQueryParams: true // ⚠️ Tokens will be in server logs
|
|
1125
|
+
* });
|
|
1104
1126
|
* ```
|
|
1105
1127
|
*/
|
|
1106
1128
|
startSso(providerSlug: SsoProvider, params?: {
|
|
@@ -1108,6 +1130,18 @@ declare class GuardClient {
|
|
|
1108
1130
|
redirect_url?: string;
|
|
1109
1131
|
login_hint?: string;
|
|
1110
1132
|
force_authn?: boolean;
|
|
1133
|
+
/**
|
|
1134
|
+
* **SECURITY WARNING**: When true, tokens are returned as URL query parameters instead of fragments.
|
|
1135
|
+
*
|
|
1136
|
+
* - Query parameters are sent to servers and appear in access logs, referrer headers, and browser history
|
|
1137
|
+
* - URL fragments are NOT sent to servers and provide better security
|
|
1138
|
+
*
|
|
1139
|
+
* Only set this to `true` if you have a server-side callback route that cannot access URL fragments.
|
|
1140
|
+
* For client-side callbacks, leave this as `false` (default) to use the more secure fragment-based approach.
|
|
1141
|
+
*
|
|
1142
|
+
* @default false
|
|
1143
|
+
*/
|
|
1144
|
+
useQueryParams?: boolean;
|
|
1111
1145
|
}): Promise<ResponseWrapper<{
|
|
1112
1146
|
redirect_url: string;
|
|
1113
1147
|
}>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -276,6 +276,7 @@ interface components {
|
|
|
276
276
|
};
|
|
277
277
|
"controller.createTenantReq": {
|
|
278
278
|
name: string;
|
|
279
|
+
parent_tenant_id?: string;
|
|
279
280
|
};
|
|
280
281
|
"controller.fgaAuthorizeReq": {
|
|
281
282
|
object_id?: string;
|
|
@@ -526,6 +527,8 @@ interface components {
|
|
|
526
527
|
workos_default_organization_id?: string;
|
|
527
528
|
};
|
|
528
529
|
"controller.signupReq": {
|
|
530
|
+
/** @description If true, assigns admin role to the new user (for tenant bootstrap) */
|
|
531
|
+
assign_admin?: boolean;
|
|
529
532
|
email: string;
|
|
530
533
|
first_name?: string;
|
|
531
534
|
last_name?: string;
|
|
@@ -546,6 +549,7 @@ interface components {
|
|
|
546
549
|
id?: string;
|
|
547
550
|
is_active?: boolean;
|
|
548
551
|
name?: string;
|
|
552
|
+
parent_tenant_id?: string;
|
|
549
553
|
updated_at?: string;
|
|
550
554
|
};
|
|
551
555
|
"controller.updateProfileReq": {
|
|
@@ -575,6 +579,11 @@ interface components {
|
|
|
575
579
|
/** @description OIDC/OAuth2 fields */
|
|
576
580
|
issuer?: string;
|
|
577
581
|
jwks_uri?: string;
|
|
582
|
+
/**
|
|
583
|
+
* @description Policy for linking SSO identities to existing accounts
|
|
584
|
+
* @enum {string}
|
|
585
|
+
*/
|
|
586
|
+
linking_policy?: "never" | "verified_email" | "always";
|
|
578
587
|
name?: string;
|
|
579
588
|
response_mode?: string;
|
|
580
589
|
response_type?: string;
|
|
@@ -1095,12 +1104,25 @@ declare class GuardClient {
|
|
|
1095
1104
|
*
|
|
1096
1105
|
* @param providerSlug - The provider slug (e.g., 'okta', 'azure-ad', 'google-saml')
|
|
1097
1106
|
* @param params - Optional parameters for the SSO flow
|
|
1107
|
+
* @param params.useQueryParams - **SECURITY WARNING**: When true, tokens are returned as URL query parameters
|
|
1108
|
+
* instead of fragments. Query parameters are sent to servers and logged, potentially exposing tokens.
|
|
1109
|
+
* Only use this for server-side callback routes that cannot access URL fragments.
|
|
1110
|
+
* Default: false (uses secure URL fragments that aren't sent to servers or logged)
|
|
1098
1111
|
* @returns The redirect URL to send the user to for authentication
|
|
1099
1112
|
*
|
|
1100
1113
|
* @example
|
|
1101
1114
|
* ```ts
|
|
1102
|
-
*
|
|
1115
|
+
* // Recommended: Client-side callback (tokens in URL fragment - more secure)
|
|
1116
|
+
* const result = await client.startSso('okta', {
|
|
1117
|
+
* redirect_url: 'https://myapp.com/callback'
|
|
1118
|
+
* });
|
|
1103
1119
|
* window.location.href = result.data.redirect_url;
|
|
1120
|
+
*
|
|
1121
|
+
* // Less secure: Server-side callback (tokens in query params - visible in logs)
|
|
1122
|
+
* const result = await client.startSso('okta', {
|
|
1123
|
+
* redirect_url: 'https://myapp.com/api/callback',
|
|
1124
|
+
* useQueryParams: true // ⚠️ Tokens will be in server logs
|
|
1125
|
+
* });
|
|
1104
1126
|
* ```
|
|
1105
1127
|
*/
|
|
1106
1128
|
startSso(providerSlug: SsoProvider, params?: {
|
|
@@ -1108,6 +1130,18 @@ declare class GuardClient {
|
|
|
1108
1130
|
redirect_url?: string;
|
|
1109
1131
|
login_hint?: string;
|
|
1110
1132
|
force_authn?: boolean;
|
|
1133
|
+
/**
|
|
1134
|
+
* **SECURITY WARNING**: When true, tokens are returned as URL query parameters instead of fragments.
|
|
1135
|
+
*
|
|
1136
|
+
* - Query parameters are sent to servers and appear in access logs, referrer headers, and browser history
|
|
1137
|
+
* - URL fragments are NOT sent to servers and provide better security
|
|
1138
|
+
*
|
|
1139
|
+
* Only set this to `true` if you have a server-side callback route that cannot access URL fragments.
|
|
1140
|
+
* For client-side callbacks, leave this as `false` (default) to use the more secure fragment-based approach.
|
|
1141
|
+
*
|
|
1142
|
+
* @default false
|
|
1143
|
+
*/
|
|
1144
|
+
useQueryParams?: boolean;
|
|
1111
1145
|
}): Promise<ResponseWrapper<{
|
|
1112
1146
|
redirect_url: string;
|
|
1113
1147
|
}>>;
|
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.1"};
|
|
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
|
});
|