@greensecurity/javascript-sdk 0.45.0-beta.16 → 0.45.0-beta.18

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.
Files changed (137) hide show
  1. package/dist/commonjs/__tests__/vendors.test.js +1 -1
  2. package/dist/commonjs/__tests__/webhooks.test.js +1 -1
  3. package/dist/commonjs/__tests__/webhooks.test.js.map +1 -1
  4. package/dist/commonjs/__tests__/zones.test.js +2 -9
  5. package/dist/commonjs/__tests__/zones.test.js.map +1 -1
  6. package/dist/commonjs/funcs/usersPostAuthenticate.d.ts +37 -0
  7. package/dist/commonjs/funcs/usersPostAuthenticate.d.ts.map +1 -1
  8. package/dist/commonjs/funcs/usersPostAuthenticate.js +37 -0
  9. package/dist/commonjs/funcs/usersPostAuthenticate.js.map +1 -1
  10. package/dist/commonjs/lib/config.d.ts +2 -2
  11. package/dist/commonjs/lib/config.js +2 -2
  12. package/dist/commonjs/models/components/authenticatesuccessresponse.d.ts +91 -0
  13. package/dist/commonjs/models/components/authenticatesuccessresponse.d.ts.map +1 -0
  14. package/dist/commonjs/models/components/authenticatesuccessresponse.js +100 -0
  15. package/dist/commonjs/models/components/authenticatesuccessresponse.js.map +1 -0
  16. package/dist/commonjs/models/components/index.d.ts +2 -0
  17. package/dist/commonjs/models/components/index.d.ts.map +1 -1
  18. package/dist/commonjs/models/components/index.js +2 -0
  19. package/dist/commonjs/models/components/index.js.map +1 -1
  20. package/dist/commonjs/models/components/loginemailandpassword.d.ts +34 -0
  21. package/dist/commonjs/models/components/loginemailandpassword.d.ts.map +1 -1
  22. package/dist/commonjs/models/components/loginemailandpassword.js +2 -0
  23. package/dist/commonjs/models/components/loginemailandpassword.js.map +1 -1
  24. package/dist/commonjs/models/components/loginrequirementsfromemail.d.ts +34 -0
  25. package/dist/commonjs/models/components/loginrequirementsfromemail.d.ts.map +1 -1
  26. package/dist/commonjs/models/components/loginrequirementsfromemail.js +2 -0
  27. package/dist/commonjs/models/components/loginrequirementsfromemail.js.map +1 -1
  28. package/dist/commonjs/models/components/mfarequiredresponse.d.ts +33 -0
  29. package/dist/commonjs/models/components/mfarequiredresponse.d.ts.map +1 -1
  30. package/dist/commonjs/models/components/mfarequiredresponse.js +2 -0
  31. package/dist/commonjs/models/components/mfarequiredresponse.js.map +1 -1
  32. package/dist/commonjs/models/components/passwordnotsetresponse.d.ts +34 -1
  33. package/dist/commonjs/models/components/passwordnotsetresponse.d.ts.map +1 -1
  34. package/dist/commonjs/models/components/passwordnotsetresponse.js +2 -0
  35. package/dist/commonjs/models/components/passwordnotsetresponse.js.map +1 -1
  36. package/dist/commonjs/models/components/passwordrequiredresponse.d.ts +33 -0
  37. package/dist/commonjs/models/components/passwordrequiredresponse.d.ts.map +1 -1
  38. package/dist/commonjs/models/components/passwordrequiredresponse.js +6 -0
  39. package/dist/commonjs/models/components/passwordrequiredresponse.js.map +1 -1
  40. package/dist/commonjs/models/components/samlloginrequiredresponse.d.ts +33 -0
  41. package/dist/commonjs/models/components/samlloginrequiredresponse.d.ts.map +1 -1
  42. package/dist/commonjs/models/components/samlloginrequiredresponse.js +2 -0
  43. package/dist/commonjs/models/components/samlloginrequiredresponse.js.map +1 -1
  44. package/dist/commonjs/models/components/ssocontinuation.d.ts +44 -0
  45. package/dist/commonjs/models/components/ssocontinuation.d.ts.map +1 -0
  46. package/dist/commonjs/models/components/ssocontinuation.js +56 -0
  47. package/dist/commonjs/models/components/ssocontinuation.js.map +1 -0
  48. package/dist/commonjs/models/operations/postauthenticate.d.ts +1 -1
  49. package/dist/commonjs/models/operations/postauthenticate.d.ts.map +1 -1
  50. package/dist/commonjs/models/operations/postauthenticate.js +1 -1
  51. package/dist/commonjs/models/operations/postauthenticate.js.map +1 -1
  52. package/dist/commonjs/react-query/usersPostAuthenticate.d.ts +37 -0
  53. package/dist/commonjs/react-query/usersPostAuthenticate.d.ts.map +1 -1
  54. package/dist/commonjs/react-query/usersPostAuthenticate.js +37 -0
  55. package/dist/commonjs/react-query/usersPostAuthenticate.js.map +1 -1
  56. package/dist/commonjs/sdk/users.d.ts +37 -0
  57. package/dist/commonjs/sdk/users.d.ts.map +1 -1
  58. package/dist/commonjs/sdk/users.js +37 -0
  59. package/dist/commonjs/sdk/users.js.map +1 -1
  60. package/dist/esm/__tests__/vendors.test.js +1 -1
  61. package/dist/esm/__tests__/webhooks.test.js +1 -1
  62. package/dist/esm/__tests__/webhooks.test.js.map +1 -1
  63. package/dist/esm/__tests__/zones.test.js +2 -9
  64. package/dist/esm/__tests__/zones.test.js.map +1 -1
  65. package/dist/esm/funcs/usersPostAuthenticate.d.ts +37 -0
  66. package/dist/esm/funcs/usersPostAuthenticate.d.ts.map +1 -1
  67. package/dist/esm/funcs/usersPostAuthenticate.js +37 -0
  68. package/dist/esm/funcs/usersPostAuthenticate.js.map +1 -1
  69. package/dist/esm/lib/config.d.ts +2 -2
  70. package/dist/esm/lib/config.js +2 -2
  71. package/dist/esm/models/components/authenticatesuccessresponse.d.ts +91 -0
  72. package/dist/esm/models/components/authenticatesuccessresponse.d.ts.map +1 -0
  73. package/dist/esm/models/components/authenticatesuccessresponse.js +61 -0
  74. package/dist/esm/models/components/authenticatesuccessresponse.js.map +1 -0
  75. package/dist/esm/models/components/index.d.ts +2 -0
  76. package/dist/esm/models/components/index.d.ts.map +1 -1
  77. package/dist/esm/models/components/index.js +2 -0
  78. package/dist/esm/models/components/index.js.map +1 -1
  79. package/dist/esm/models/components/loginemailandpassword.d.ts +34 -0
  80. package/dist/esm/models/components/loginemailandpassword.d.ts.map +1 -1
  81. package/dist/esm/models/components/loginemailandpassword.js +2 -0
  82. package/dist/esm/models/components/loginemailandpassword.js.map +1 -1
  83. package/dist/esm/models/components/loginrequirementsfromemail.d.ts +34 -0
  84. package/dist/esm/models/components/loginrequirementsfromemail.d.ts.map +1 -1
  85. package/dist/esm/models/components/loginrequirementsfromemail.js +2 -0
  86. package/dist/esm/models/components/loginrequirementsfromemail.js.map +1 -1
  87. package/dist/esm/models/components/mfarequiredresponse.d.ts +33 -0
  88. package/dist/esm/models/components/mfarequiredresponse.d.ts.map +1 -1
  89. package/dist/esm/models/components/mfarequiredresponse.js +2 -0
  90. package/dist/esm/models/components/mfarequiredresponse.js.map +1 -1
  91. package/dist/esm/models/components/passwordnotsetresponse.d.ts +34 -1
  92. package/dist/esm/models/components/passwordnotsetresponse.d.ts.map +1 -1
  93. package/dist/esm/models/components/passwordnotsetresponse.js +2 -0
  94. package/dist/esm/models/components/passwordnotsetresponse.js.map +1 -1
  95. package/dist/esm/models/components/passwordrequiredresponse.d.ts +33 -0
  96. package/dist/esm/models/components/passwordrequiredresponse.d.ts.map +1 -1
  97. package/dist/esm/models/components/passwordrequiredresponse.js +6 -0
  98. package/dist/esm/models/components/passwordrequiredresponse.js.map +1 -1
  99. package/dist/esm/models/components/samlloginrequiredresponse.d.ts +33 -0
  100. package/dist/esm/models/components/samlloginrequiredresponse.d.ts.map +1 -1
  101. package/dist/esm/models/components/samlloginrequiredresponse.js +2 -0
  102. package/dist/esm/models/components/samlloginrequiredresponse.js.map +1 -1
  103. package/dist/esm/models/components/ssocontinuation.d.ts +44 -0
  104. package/dist/esm/models/components/ssocontinuation.d.ts.map +1 -0
  105. package/dist/esm/models/components/ssocontinuation.js +19 -0
  106. package/dist/esm/models/components/ssocontinuation.js.map +1 -0
  107. package/dist/esm/models/operations/postauthenticate.d.ts +1 -1
  108. package/dist/esm/models/operations/postauthenticate.d.ts.map +1 -1
  109. package/dist/esm/models/operations/postauthenticate.js +1 -1
  110. package/dist/esm/models/operations/postauthenticate.js.map +1 -1
  111. package/dist/esm/react-query/usersPostAuthenticate.d.ts +37 -0
  112. package/dist/esm/react-query/usersPostAuthenticate.d.ts.map +1 -1
  113. package/dist/esm/react-query/usersPostAuthenticate.js +37 -0
  114. package/dist/esm/react-query/usersPostAuthenticate.js.map +1 -1
  115. package/dist/esm/sdk/users.d.ts +37 -0
  116. package/dist/esm/sdk/users.d.ts.map +1 -1
  117. package/dist/esm/sdk/users.js +37 -0
  118. package/dist/esm/sdk/users.js.map +1 -1
  119. package/jsr.json +1 -1
  120. package/package.json +1 -1
  121. package/src/__tests__/vendors.test.ts +1 -1
  122. package/src/__tests__/webhooks.test.ts +1 -1
  123. package/src/__tests__/zones.test.ts +2 -9
  124. package/src/funcs/usersPostAuthenticate.ts +37 -0
  125. package/src/lib/config.ts +2 -2
  126. package/src/models/components/authenticatesuccessresponse.ts +189 -0
  127. package/src/models/components/index.ts +2 -0
  128. package/src/models/components/loginemailandpassword.ts +36 -0
  129. package/src/models/components/loginrequirementsfromemail.ts +36 -0
  130. package/src/models/components/mfarequiredresponse.ts +35 -0
  131. package/src/models/components/passwordnotsetresponse.ts +36 -1
  132. package/src/models/components/passwordrequiredresponse.ts +39 -0
  133. package/src/models/components/samlloginrequiredresponse.ts +35 -0
  134. package/src/models/components/ssocontinuation.ts +71 -0
  135. package/src/models/operations/postauthenticate.ts +2 -2
  136. package/src/react-query/usersPostAuthenticate.ts +37 -0
  137. package/src/sdk/users.ts +37 -0
@@ -20,9 +20,42 @@ export type PasswordNotSetResponse = {
20
20
  */
21
21
  error: string;
22
22
  /**
23
- * URL to redirect the user to set their password (forgot password flow). Includes return_url query param when provided in the request.
23
+ * URL to redirect the user to set their password (forgot password flow). Carries the `return_url` and `sso_state` query params when those were provided on the request, because the browser follows this redirect and leaves the JSON body behind.
24
24
  */
25
25
  redirectUrl: string;
26
+ /**
27
+ * Opaque, signed state that Green Security issues when a third-party service
28
+ *
29
+ * @remarks
30
+ * provider starts a "Login with Green Security" SAML flow at
31
+ * `/saml/idp/sso`. The login screen receives it as the `sso_state` query
32
+ * string parameter and must pass it back, byte for byte, on every call to
33
+ * this endpoint for the remainder of the login journey — including the
34
+ * second call that carries an `mfa_code`.
35
+ *
36
+ * The blob is signed, not encrypted, and it expires five minutes after the
37
+ * service provider's request arrives. Do not parse it, shorten it, decode
38
+ * it, or re-encode it.
39
+ *
40
+ * **An invalid blob does not fail the login.** This is the opposite of what
41
+ * most integrators assume, so it is worth stating plainly: a forged, edited
42
+ * or expired `sso_state` is silently discarded, and the request then
43
+ * proceeds as an ordinary login. Valid credentials still authenticate and
44
+ * still return `200` — just with no `sso` object, leaving the user signed in
45
+ * to Green Security with no way back to the service provider that sent them.
46
+ * Never treat a `200` as proof that the SSO hand-off survived; check for
47
+ * `sso` explicitly.
48
+ *
49
+ * Every `202` response echoes the *verified* blob back in its own
50
+ * `sso_state` field. Always send back the value from the response you just
51
+ * received rather than the one you started with, so that a blob the server
52
+ * has already rejected is never resent, and so a client does not have to
53
+ * hold state of its own across the login journey.
54
+ *
55
+ * Omit this field entirely for an ordinary login that did not originate
56
+ * from a service provider.
57
+ */
58
+ ssoState?: string | undefined;
26
59
  };
27
60
 
28
61
  /** @internal */
@@ -35,9 +68,11 @@ export const PasswordNotSetResponse$inboundSchema: z.ZodType<
35
68
  success: types.boolean(),
36
69
  error: types.string(),
37
70
  redirect_url: types.string(),
71
+ sso_state: types.optional(types.string()),
38
72
  }).transform((v) => {
39
73
  return remap$(v, {
40
74
  "redirect_url": "redirectUrl",
75
+ "sso_state": "ssoState",
41
76
  });
42
77
  });
43
78
 
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
6
7
  import { safeParse } from "../../lib/schemas.js";
7
8
  import { Result as SafeParseResult } from "../../types/fp.js";
8
9
  import * as types from "../../types/primitives.js";
@@ -18,6 +19,39 @@ export type PasswordRequiredResponse = {
18
19
  * Error describing the exact condition of what further steps are needed to finish the login process.
19
20
  */
20
21
  error: string;
22
+ /**
23
+ * Opaque, signed state that Green Security issues when a third-party service
24
+ *
25
+ * @remarks
26
+ * provider starts a "Login with Green Security" SAML flow at
27
+ * `/saml/idp/sso`. The login screen receives it as the `sso_state` query
28
+ * string parameter and must pass it back, byte for byte, on every call to
29
+ * this endpoint for the remainder of the login journey — including the
30
+ * second call that carries an `mfa_code`.
31
+ *
32
+ * The blob is signed, not encrypted, and it expires five minutes after the
33
+ * service provider's request arrives. Do not parse it, shorten it, decode
34
+ * it, or re-encode it.
35
+ *
36
+ * **An invalid blob does not fail the login.** This is the opposite of what
37
+ * most integrators assume, so it is worth stating plainly: a forged, edited
38
+ * or expired `sso_state` is silently discarded, and the request then
39
+ * proceeds as an ordinary login. Valid credentials still authenticate and
40
+ * still return `200` — just with no `sso` object, leaving the user signed in
41
+ * to Green Security with no way back to the service provider that sent them.
42
+ * Never treat a `200` as proof that the SSO hand-off survived; check for
43
+ * `sso` explicitly.
44
+ *
45
+ * Every `202` response echoes the *verified* blob back in its own
46
+ * `sso_state` field. Always send back the value from the response you just
47
+ * received rather than the one you started with, so that a blob the server
48
+ * has already rejected is never resent, and so a client does not have to
49
+ * hold state of its own across the login journey.
50
+ *
51
+ * Omit this field entirely for an ordinary login that did not originate
52
+ * from a service provider.
53
+ */
54
+ ssoState?: string | undefined;
21
55
  };
22
56
 
23
57
  /** @internal */
@@ -29,6 +63,11 @@ export const PasswordRequiredResponse$inboundSchema: z.ZodType<
29
63
  requires: types.literal("password"),
30
64
  success: types.boolean(),
31
65
  error: types.string(),
66
+ sso_state: types.optional(types.string()),
67
+ }).transform((v) => {
68
+ return remap$(v, {
69
+ "sso_state": "ssoState",
70
+ });
32
71
  });
33
72
 
34
73
  export function passwordRequiredResponseFromJSON(
@@ -28,6 +28,39 @@ export type SamlLoginRequiredResponse = {
28
28
  * This is the URL that should be opened to initiate the SAML login flow
29
29
  */
30
30
  ssoUrl: string;
31
+ /**
32
+ * Opaque, signed state that Green Security issues when a third-party service
33
+ *
34
+ * @remarks
35
+ * provider starts a "Login with Green Security" SAML flow at
36
+ * `/saml/idp/sso`. The login screen receives it as the `sso_state` query
37
+ * string parameter and must pass it back, byte for byte, on every call to
38
+ * this endpoint for the remainder of the login journey — including the
39
+ * second call that carries an `mfa_code`.
40
+ *
41
+ * The blob is signed, not encrypted, and it expires five minutes after the
42
+ * service provider's request arrives. Do not parse it, shorten it, decode
43
+ * it, or re-encode it.
44
+ *
45
+ * **An invalid blob does not fail the login.** This is the opposite of what
46
+ * most integrators assume, so it is worth stating plainly: a forged, edited
47
+ * or expired `sso_state` is silently discarded, and the request then
48
+ * proceeds as an ordinary login. Valid credentials still authenticate and
49
+ * still return `200` — just with no `sso` object, leaving the user signed in
50
+ * to Green Security with no way back to the service provider that sent them.
51
+ * Never treat a `200` as proof that the SSO hand-off survived; check for
52
+ * `sso` explicitly.
53
+ *
54
+ * Every `202` response echoes the *verified* blob back in its own
55
+ * `sso_state` field. Always send back the value from the response you just
56
+ * received rather than the one you started with, so that a blob the server
57
+ * has already rejected is never resent, and so a client does not have to
58
+ * hold state of its own across the login journey.
59
+ *
60
+ * Omit this field entirely for an ordinary login that did not originate
61
+ * from a service provider.
62
+ */
63
+ ssoState?: string | undefined;
31
64
  };
32
65
 
33
66
  /** @internal */
@@ -41,10 +74,12 @@ export const SamlLoginRequiredResponse$inboundSchema: z.ZodType<
41
74
  error: types.string(),
42
75
  sso_instructions: types.optional(types.string()),
43
76
  sso_url: types.string(),
77
+ sso_state: types.optional(types.string()),
44
78
  }).transform((v) => {
45
79
  return remap$(v, {
46
80
  "sso_instructions": "ssoInstructions",
47
81
  "sso_url": "ssoUrl",
82
+ "sso_state": "ssoState",
48
83
  });
49
84
  });
50
85
 
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import * as types from "../../types/primitives.js";
10
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
+
12
+ /**
13
+ * Where to send the browser to finish a "Login with Green Security" flow.
14
+ *
15
+ * @remarks
16
+ *
17
+ * Present on a `200` from `POST /users/authenticate` only when the request
18
+ * carried a valid, unexpired `sso_state`. Its absence means the login
19
+ * succeeded but the SAML flow did not resume — treat the login as an
20
+ * ordinary one rather than retrying.
21
+ *
22
+ * This object is additive. The login itself is unaffected by it: the
23
+ * caller's own permanent token is in `user_token` exactly as it would be on
24
+ * any other successful authentication, and it is not the token embedded in
25
+ * `continue_url`.
26
+ */
27
+ export type SsoContinuation = {
28
+ /**
29
+ * An absolute, single-use URL on Green Security's domain. Navigate the
30
+ *
31
+ * @remarks
32
+ * browser to it (a full page navigation, not `fetch`); it answers with a
33
+ * self-submitting form that POSTs the signed `SAMLResponse` and the
34
+ * original `RelayState` to the service provider's assertion consumer
35
+ * service URL.
36
+ *
37
+ * The `token` in this URL is a separate **one-time** token that is
38
+ * consumed the first time the URL is followed, so the URL is good for
39
+ * exactly one navigation. It is not the caller's permanent token, which
40
+ * is returned unchanged in `user_token`. Treat the URL as a secret:
41
+ * whoever follows it first receives that user's assertion.
42
+ *
43
+ * Never fetch this URL from your own back end: the response is meant for
44
+ * the user's browser, and posting the assertion from anywhere else
45
+ * breaks the flow.
46
+ */
47
+ continueUrl: string;
48
+ };
49
+
50
+ /** @internal */
51
+ export const SsoContinuation$inboundSchema: z.ZodType<
52
+ SsoContinuation,
53
+ z.ZodTypeDef,
54
+ unknown
55
+ > = z.object({
56
+ continue_url: types.string(),
57
+ }).transform((v) => {
58
+ return remap$(v, {
59
+ "continue_url": "continueUrl",
60
+ });
61
+ });
62
+
63
+ export function ssoContinuationFromJSON(
64
+ jsonString: string,
65
+ ): SafeParseResult<SsoContinuation, SDKValidationError> {
66
+ return safeParse(
67
+ jsonString,
68
+ (x) => SsoContinuation$inboundSchema.parse(JSON.parse(x)),
69
+ `Failed to parse 'SsoContinuation' from JSON`,
70
+ );
71
+ }
@@ -26,7 +26,7 @@ export type PostAuthenticateResponseBody =
26
26
  | components.PasswordNotSetResponse;
27
27
 
28
28
  export type PostAuthenticateResponse =
29
- | components.User
29
+ | components.AuthenticateSuccessResponse
30
30
  | components.MfaRequiredResponse
31
31
  | components.SamlLoginRequiredResponse
32
32
  | components.PasswordRequiredResponse
@@ -85,7 +85,7 @@ export const PostAuthenticateResponse$inboundSchema: z.ZodType<
85
85
  z.ZodTypeDef,
86
86
  unknown
87
87
  > = smartUnion([
88
- components.User$inboundSchema,
88
+ components.AuthenticateSuccessResponse$inboundSchema,
89
89
  z.union([
90
90
  components.MfaRequiredResponse$inboundSchema,
91
91
  components.SamlLoginRequiredResponse$inboundSchema,
@@ -81,6 +81,43 @@ export type UsersPostAuthenticateMutationError =
81
81
  * 3. Site redirects to your selected `return_url`
82
82
  * 4. The `user_token` will be appended as a query string parameter to your `return_url` - you must parse this token and store it
83
83
  * 5. Fetch the user object from `/users/me` using the token
84
+ *
85
+ * ## Finishing a "Login with Green Security" flow
86
+ *
87
+ * Green Security is also a SAML2 **identity provider**. When a third-party service provider sends a user to
88
+ * `/saml/idp/sso` to sign in with their Green Security account, the user lands on a Green Security login screen
89
+ * carrying an `sso_state` query string parameter. That parameter is a signed, five-minute record of which service
90
+ * provider is waiting, where its assertion consumer service lives, and what `RelayState` it sent.
91
+ *
92
+ * Authentication itself is unchanged - the user may still need a password, an MFA code, a magic link or a round trip
93
+ * to their own SAML IdP, and every `requires` value above applies as normal. The only difference is that you must
94
+ * echo `sso_state` back on **every** call in the sequence, unchanged, including the follow-up that carries the
95
+ * `mfa_code`.
96
+ *
97
+ * Each `202` response carries the verified blob back to you in its own top-level `sso_state` field. Send back the
98
+ * value from the response you just received rather than the one you started with. The two are normally the same
99
+ * string, but re-sending your original copy is how a blob the server has already rejected gets resent, and it forces
100
+ * you to hold login state you would otherwise not need.
101
+ *
102
+ * 1. Read `sso_state` from the query string of the login screen you were sent to
103
+ * 2. Run the login exactly as you would otherwise, adding `sso_state` to each request body and taking the value for
104
+ * the next request from the previous `202` response
105
+ * 3. On the `200` response, read `sso.continue_url`
106
+ * 4. Navigate the browser to `sso.continue_url` - a full page navigation, not a background fetch. It answers with a
107
+ * self-submitting form that delivers the signed `SAMLResponse` and the original `RelayState` to the service
108
+ * provider
109
+ * 5. The service provider validates the assertion and the user is signed in on their side
110
+ *
111
+ * On the `password_reset` leg the blob is **also** appended to `redirect_url` as a query parameter, alongside
112
+ * `return_url`. The browser follows that redirect and leaves the JSON body behind, so anything the remaining legs of
113
+ * the login still need has to ride the URL. Preserve the query string exactly as given.
114
+ *
115
+ * An invalid `sso_state` never fails a login. A forged, edited or expired blob is silently dropped and the request is
116
+ * then treated as an ordinary login, so valid credentials still return `200` - just with no `sso` object. Check for
117
+ * `sso` explicitly rather than reading `200` as proof the hand-off survived. When it is absent, do not retry with the
118
+ * same blob; the user has to start again from the service provider. See the
119
+ * [Login with Green Security](https://greensecurity.apidocumentation.com/guides/sso-login-with-green-security)
120
+ * guide for the service provider half of this flow.
84
121
  */
85
122
  export function useUsersPostAuthenticateMutation(
86
123
  options?: MutationHookOptions<
package/src/sdk/users.ts CHANGED
@@ -148,6 +148,43 @@ export class Users extends ClientSDK {
148
148
  * 3. Site redirects to your selected `return_url`
149
149
  * 4. The `user_token` will be appended as a query string parameter to your `return_url` - you must parse this token and store it
150
150
  * 5. Fetch the user object from `/users/me` using the token
151
+ *
152
+ * ## Finishing a "Login with Green Security" flow
153
+ *
154
+ * Green Security is also a SAML2 **identity provider**. When a third-party service provider sends a user to
155
+ * `/saml/idp/sso` to sign in with their Green Security account, the user lands on a Green Security login screen
156
+ * carrying an `sso_state` query string parameter. That parameter is a signed, five-minute record of which service
157
+ * provider is waiting, where its assertion consumer service lives, and what `RelayState` it sent.
158
+ *
159
+ * Authentication itself is unchanged - the user may still need a password, an MFA code, a magic link or a round trip
160
+ * to their own SAML IdP, and every `requires` value above applies as normal. The only difference is that you must
161
+ * echo `sso_state` back on **every** call in the sequence, unchanged, including the follow-up that carries the
162
+ * `mfa_code`.
163
+ *
164
+ * Each `202` response carries the verified blob back to you in its own top-level `sso_state` field. Send back the
165
+ * value from the response you just received rather than the one you started with. The two are normally the same
166
+ * string, but re-sending your original copy is how a blob the server has already rejected gets resent, and it forces
167
+ * you to hold login state you would otherwise not need.
168
+ *
169
+ * 1. Read `sso_state` from the query string of the login screen you were sent to
170
+ * 2. Run the login exactly as you would otherwise, adding `sso_state` to each request body and taking the value for
171
+ * the next request from the previous `202` response
172
+ * 3. On the `200` response, read `sso.continue_url`
173
+ * 4. Navigate the browser to `sso.continue_url` - a full page navigation, not a background fetch. It answers with a
174
+ * self-submitting form that delivers the signed `SAMLResponse` and the original `RelayState` to the service
175
+ * provider
176
+ * 5. The service provider validates the assertion and the user is signed in on their side
177
+ *
178
+ * On the `password_reset` leg the blob is **also** appended to `redirect_url` as a query parameter, alongside
179
+ * `return_url`. The browser follows that redirect and leaves the JSON body behind, so anything the remaining legs of
180
+ * the login still need has to ride the URL. Preserve the query string exactly as given.
181
+ *
182
+ * An invalid `sso_state` never fails a login. A forged, edited or expired blob is silently dropped and the request is
183
+ * then treated as an ordinary login, so valid credentials still return `200` - just with no `sso` object. Check for
184
+ * `sso` explicitly rather than reading `200` as proof the hand-off survived. When it is absent, do not retry with the
185
+ * same blob; the user has to start again from the service provider. See the
186
+ * [Login with Green Security](https://greensecurity.apidocumentation.com/guides/sso-login-with-green-security)
187
+ * guide for the service provider half of this flow.
151
188
  */
152
189
  async postAuthenticate(
153
190
  request: operations.PostAuthenticateRequestBody,