@@ -16,16 +16,15 @@ describe("generateAuthUrl", () => {
16
16
connectionId : "conn123" ,
17
17
redirectURL : "https://example.com" ,
18
18
audience : "audience123" ,
19
- prompt : "login" ,
20
19
state : "state123" ,
21
20
} ;
22
21
const expectedUrl =
23
- "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&start_page=login& login_hint=user%40example.com&is_create_org=true&connection_id=conn123&redirect_uri=https%3A%2F%2Fexample.com&audience=audience123&scope=openid+profile&prompt=login &state=state123&code_challenge_method=S256" ;
22
+ "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&login_hint=user%40example.com&is_create_org=true&connection_id=conn123&redirect_uri=https%3A%2F%2Fexample.com&audience=audience123&scope=openid+profile&state=state123&code_challenge_method=S256" ;
24
23
25
24
const result = await generateAuthUrl (
26
25
domain ,
27
26
IssuerRouteTypes . login ,
28
- options ,
27
+ options
29
28
) ;
30
29
const nonce = result . url . searchParams . get ( "nonce" ) ;
31
30
expect ( nonce ) . not . toBeNull ( ) ;
@@ -37,6 +36,33 @@ describe("generateAuthUrl", () => {
37
36
expect ( result . url . toString ( ) ) . toBe ( expectedUrl ) ;
38
37
} ) ;
39
38
39
+ it ( "should generate the register URL when type is 'registration'" , async ( ) => {
40
+ const domain = "https://auth.example.com" ;
41
+ const options : LoginOptions = {
42
+ clientId : "client123" ,
43
+ responseType : "code" ,
44
+ scope : [ Scopes . openid , Scopes . profile ] ,
45
+ state : "state123" ,
46
+ codeChallenge : "challenge123" ,
47
+ codeChallengeMethod : "S256" ,
48
+ redirectURL : "https://example2.com" ,
49
+ } ;
50
+ const expectedUrl =
51
+ "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&redirect_uri=https%3A%2F%2Fexample2.com&audience=&scope=openid+profile&state=state123&code_challenge=challenge123&code_challenge_method=S256&prompt=create" ;
52
+
53
+ const result = await generateAuthUrl (
54
+ domain ,
55
+ IssuerRouteTypes . register ,
56
+ options
57
+ ) ;
58
+ const nonce = result . url . searchParams . get ( "nonce" ) ;
59
+ expect ( nonce ) . not . toBeNull ( ) ;
60
+ expect ( nonce ! . length ) . toBe ( 16 ) ;
61
+ result . url . searchParams . delete ( "nonce" ) ;
62
+
63
+ expect ( result . url . toString ( ) ) . toBe ( expectedUrl ) ;
64
+ } ) ;
65
+
40
66
it ( "should include optional parameters if provided" , async ( ) => {
41
67
const domain = "https://auth.example.com" ;
42
68
const options : LoginOptions = {
@@ -47,15 +73,15 @@ describe("generateAuthUrl", () => {
47
73
codeChallenge : "challenge123" ,
48
74
codeChallengeMethod : "S256" ,
49
75
redirectURL : "https://example2.com" ,
50
- prompt : "create " ,
76
+ prompt : "login " ,
51
77
} ;
52
78
const expectedUrl =
53
- "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&start_page=login& redirect_uri=https%3A%2F%2Fexample2.com&audience=&scope=openid+profile&prompt=create &state=state123&code_challenge=challenge123&code_challenge_method=S256" ;
79
+ "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&redirect_uri=https%3A%2F%2Fexample2.com&audience=&scope=openid+profile&prompt=login &state=state123&code_challenge=challenge123&code_challenge_method=S256" ;
54
80
55
81
const result = await generateAuthUrl (
56
82
domain ,
57
83
IssuerRouteTypes . login ,
58
- options ,
84
+ options
59
85
) ;
60
86
const nonce = result . url . searchParams . get ( "nonce" ) ;
61
87
expect ( nonce ) . not . toBeNull ( ) ;
@@ -75,12 +101,12 @@ describe("generateAuthUrl", () => {
75
101
state : "state123" ,
76
102
} ;
77
103
const expectedUrl =
78
- "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&start_page=login& redirect_uri=https%3A%2F%2Fexample2.com&audience=&scope=openid+profile+offline&prompt=create&state=state123&code_challenge_method=S256" ;
104
+ "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&redirect_uri=https%3A%2F%2Fexample2.com&audience=&scope=openid+profile+offline&prompt=create&state=state123&code_challenge_method=S256" ;
79
105
80
106
const result = await generateAuthUrl (
81
107
domain ,
82
108
IssuerRouteTypes . login ,
83
- options ,
109
+ options
84
110
) ;
85
111
const nonce = result . url . searchParams . get ( "nonce" ) ;
86
112
expect ( nonce ) . not . toBeNull ( ) ;
@@ -103,12 +129,12 @@ describe("generateAuthUrl", () => {
103
129
prompt : "create" ,
104
130
} ;
105
131
const expectedUrl =
106
- "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&start_page=login& redirect_uri=https%3A%2F%2Fexample2.com&audience=&scope=openid+profile+offline&prompt=create&code_challenge_method=S256" ;
132
+ "https://auth.example.com/oauth2/auth?client_id=client123&response_type=code&redirect_uri=https%3A%2F%2Fexample2.com&audience=&scope=openid+profile+offline&prompt=create&code_challenge_method=S256" ;
107
133
108
134
const result = await generateAuthUrl (
109
135
domain ,
110
136
IssuerRouteTypes . login ,
111
- options ,
137
+ options
112
138
) ;
113
139
const nonce = result . url . searchParams . get ( "nonce" ) ;
114
140
expect ( nonce ) . not . toBeNull ( ) ;
0 commit comments