@@ -17,7 +17,7 @@ pnpm install @kinde/infrastructure
1717
1818## Usage
1919
20- ### Methods
20+ ### Workflow Methods
2121
2222` idTokenCustomClaims ` - Define and set custom claims on the id token
2323
@@ -29,10 +29,46 @@ pnpm install @kinde/infrastructure
2929
3030` fetch ` - Sent a request to external API
3131
32+ ` secureFetch ` - Sent an encypted request to external API
33+
3234` getEnvironmentVariable ` - Get Environment variable from Kinde secrets
3335
3436` createKindeAPI ` - Create handler to call the Kinde management SDK
3537
38+ ### Custom Pages Methods
39+
40+ ` getKindeWidget ` - Places the kinde widget on the page
41+
42+ ` getKindeNonce ` - Places the generated Nonce on your page for increased security
43+
44+ ` getKindeRequiredCSS ` - Inserts the required CSS
45+
46+ ` getKindeRequiredJS ` - Inserts the required JS
47+
48+ ` getKindeCSRF ` - Places the generated CSRF on your page for increased security
49+
50+ ` getKindeRegisterUrl ` or ` getKindeSignUpUrl ` - Gets the registration Url
51+
52+ ` getKindeLoginUrl ` or ` getKindeSignInUrl ` - Gets the login Url
53+
54+ ` getLogoUrl ` - Gets the organisations logo Url
55+
56+ ` getDarkModeLogoUrl ` - gets the organisations dark mode logo Url
57+
58+ ` getSVGFaviconUrl ` - gets the organistaions SVG favicon
59+
60+ ` getFallbackFaviconUrl ` - geths the organisations fallback favicon
61+
62+ ` setKindeDesignerCustomProperties ` - Update styling of the Kinde widget
63+
64+ - baseBackgroundColor
65+ - baseLinkColor
66+ - buttonBorderRadius,
67+ - primaryButtonBackgroundColor
68+ - primaryButtonColor
69+ - cardBorderRadius
70+ - inputBorderRadius
71+
3672### Workflow Event
3773
3874#### User token generation
@@ -95,6 +131,62 @@ pnpm install @kinde/infrastructure
95131}
96132```
97133
134+ #### On new password provided
135+
136+ ``` json
137+ {
138+ "request" : {
139+ "ip" : " 1.2.3.4" ,
140+ "auth" : {
141+ "audience" : [" https://api.example.com/v1" ]
142+ }
143+ },
144+ "context" : {
145+ "auth" : {
146+ "firstPassword" : " somesecurepassword" ,
147+ "secondPassword" : " somesecurepassword" ,
148+ "newPasswordReason" : " reset"
149+ },
150+ "domains" : {
151+ "kindeDomain" : " https://mykindebusiness.kinde.com"
152+ },
153+ "workflow" : {
154+ "trigger" : " user:new_password_provided"
155+ },
156+ "application" : {
157+ "clientId" : " f77dbc..."
158+ }
159+ }
160+ }
161+ ```
162+
163+ #### On existing password provided
164+
165+ ``` json
166+ {
167+ "request" : {
168+ "ip" : " 1.2.3.4" ,
169+ "auth" : {
170+ "audience" : [" https://api.example.com/v1" ]
171+ }
172+ },
173+ "context" : {
174+ "auth" : {
175+ "password" : " somesecurepassword"
176+ },
177+ "domains" : {
178+ "kindeDomain" : " https://mykindebusiness.kinde.com"
179+ },
180+ "workflow" : {
181+ "trigger" : " user:existing_password_provided"
182+ },
183+ "application" : {
184+ "clientId" : " f77dbc..."
185+ }
186+ }
187+ }
188+ ```
189+
98190### Examples
99191
100192#### Customise tokens
@@ -121,17 +213,15 @@ export const workflowSettings: WorkflowSettings = {
121213 },
122214};
123215
124- export default {
125- async handle(event : onUserTokenGeneratedEvent ) {
126- const accessToken = accessTokenCustomClaims <{
127- hello: string ;
128- ipAddress: string ;
129- }>();
216+ export default async function (event : onUserTokenGeneratedEvent ) {
217+ const accessToken = accessTokenCustomClaims <{
218+ hello: string ;
219+ ipAddress: string ;
220+ }>();
130221
131- accessToken .hello = " Hello there!" ;
132- accessToken .ipAddress = event .request .ip ;
133- },
134- };
222+ accessToken .hello = " Hello there!" ;
223+ accessToken .ipAddress = event .request .ip ;
224+ },
135225```
136226
137227This will result with two new extra claims added to the AccessToken
@@ -154,8 +244,8 @@ kinde.accessToken
154244```
155245
156246``` typescript
157- async handle (event : onUserTokenGeneratedEvent ) {
158- if (event .request .ip .startsWith (' 192' )) {
247+ export default async function (event : onUserTokenGeneratedEvent ) {
248+ if (event .request .ip .startsWith (" 192" )) {
159249 denyAccess (" You are not allowed to access this resource" );
160250 }
161251}
@@ -175,22 +265,23 @@ url
175265```
176266
177267``` typescript
178- async handle (event : onUserTokenGeneratedEvent ) {
179- const ipInfoToken = getEnvironmentVariable (' IP_INFO_TOKEN' )?.value
180-
181- const { data : ipDetails } = await fetch (` https://ipinfo.io/${event .request .ip }?token=${ipInfoToken } ` , {
182- method: " GET" ,
183- responseFormat: ' json' ,
184- headers: {
185- " Content-Type" : " application/json" ,
186- }
187- });
268+ export default async function (event : onUserTokenGeneratedEvent ) {
269+ const ipInfoToken = getEnvironmentVariable (" IP_INFO_TOKEN" )?.value ;
188270
189- const idToken = idTokenCustomClaims <
271+ const { data : ipDetails } = await fetch (
272+ ` https://ipinfo.io/${event .request .ip }?token=${ipInfoToken } ` ,
190273 {
191- timezone : string ;
192- }
193- > ();
274+ method: " GET" ,
275+ responseFormat: " json" ,
276+ headers: {
277+ " Content-Type" : " application/json" ,
278+ },
279+ },
280+ );
281+
282+ const idToken = idTokenCustomClaims <{
283+ timezone: string ;
284+ }>();
194285
195286 idToken .timezone = ipDetails .timezone ;
196287}
219310```
220311
221312``` typescript
222- async handle (event : onUserTokenGeneratedEvent ) {
313+ export default async function (event : onUserTokenGeneratedEvent ) {
223314 const orgCode = event .context .organization .code ;
224315 const userId = event .context .user .id ;
225316
0 commit comments