Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRivers committed Nov 5, 2024
1 parent 8053397 commit bfc585b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
54 changes: 36 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,57 @@ pnpm install @kinde/infrastructure

`m2mCustomClaims` - Returns mutatable M2M token object

`denyAccess` - Deny access to your application

`fetch` - Sent a request to external API

`getEnvironmentVariable` - Get Environment variable from Kinde secrets

`createKindeAPI` - Create handler to call the Kinde management SDK

### Workflow Event

```js
{
request: {
ipAddress // IP address of where the workflow was triggered from
};
context: {
workflowTrigger // This is the type of the trigger
clientId // this will contain the source application ID the workflow was triggered from
orgCode // Organisation code the user is logging into
userId // this is the user ID e.g. kp_XXXX
clientId // client id of the origin
}
};
request: {
ipAddress; // IP address of where the workflow was triggered from
}
context: {
workflowTrigger; // This is the type of the trigger
clientId; // this will contain the source application ID the workflow was triggered from
orgCode; // Organisation code the user is logging into
userId; // this is the user ID e.g. kp_XXXX
clientId; // client id of the origin
}
}
```

### Example

```ts
import { onUserTokenGeneratedEvent, getKindeAccessTokenHandle, WorkflowSettings, WorkflowTrigger } from "@kinde/infrastructure"
import {
onUserTokenGeneratedEvent,
getKindeAccessTokenHandle,
WorkflowSettings,
WorkflowTrigger,
} from "@kinde/infrastructure";

export const workflowSettings: WorkflowSettings = {
id: "addAccessTokenClaim",
trigger: WorkflowTrigger.UserTokenGeneration,
};

export default {
async handle(event: onUserTokenGeneratedEvent) {
const accessToken = accessCustomClaims<{ hello: string; ipAddress: string}>();
const accessToken = accessTokenCustomClaims<
{
hello: string;
ipAddress: string;
}
>();

accessToken.hello = "Hello there!";
accessToken.ipAddress = event.request.ipAddress
accessToken.ipAddress = event.request.ip
},
};
```
Expand All @@ -65,8 +84,8 @@ This will result with two new extra claims added to the AccessToken

```json
{
"hello": "Hello there!",
"ipAddress": "1.2.3.4"
"hello": "Hello there!",
"ipAddress": "1.2.3.4"
}
```

Expand All @@ -75,7 +94,6 @@ This will result with two new extra claims added to the AccessToken
>
> No sensitive data should be added to tokens as these can be accessed publically

## Kinde documentation

[Kinde Documentation](https://kinde.com/docs/) - Explore the Kinde docs
Expand Down
4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
"noFallthroughCasesInSwitch": true
},
"include": ["src", "lib/**/*.ts", "lib/types.ts"],
"exclude": [
"lib/**/*.test.ts"
]
"exclude": ["lib/**/*.test.ts"]
}

0 comments on commit bfc585b

Please sign in to comment.