Skip to content

Commit

Permalink
Expose the warrant_token attribute returned by the FGA check endpoi…
Browse files Browse the repository at this point in the history
…nt to the caller (#1212)

## Description
Now that the [FGA Check
endpoint](https://workos.com/docs/reference/fga/check) returns the
[Warrant Token](https://workos.com/docs/fga/warrant-tokens) that was
used during evaluation of the check, this PR updates the Node SDK to
expose the newly returned value to the caller.

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[X] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
workos/workos#34558
  • Loading branch information
kkajla12 authored Feb 7, 2025
1 parent 9c2335b commit ed32df1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fga/fga.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('FGA', () => {
fetchOnce({
result: 'authorized',
is_implicit: false,
warrant_token: 'abc',
});
const checkResult = await workos.fga.check({
checks: [
Expand All @@ -40,6 +41,7 @@ describe('FGA', () => {
expect(checkResult).toMatchObject({
result: 'authorized',
isImplicit: false,
warrantToken: 'abc',
});
});
});
Expand Down
4 changes: 4 additions & 0 deletions src/fga/interfaces/check.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface SerializedCheckBatchOptions {
export interface CheckResultResponse {
result: string;
is_implicit: boolean;
warrant_token: string;
debug_info?: DebugInfoResponse;
}

Expand Down Expand Up @@ -79,17 +80,20 @@ export interface DecisionTreeNodeResponse {
export interface CheckResultInterface {
result: string;
isImplicit: boolean;
warrantToken: string;
debugInfo?: DebugInfo;
}

export class CheckResult implements CheckResultInterface {
public result: string;
public isImplicit: boolean;
public warrantToken: string;
public debugInfo?: DebugInfo;

constructor(json: CheckResultResponse) {
this.result = json.result;
this.isImplicit = json.is_implicit;
this.warrantToken = json.warrant_token;
this.debugInfo = json.debug_info
? {
processingTime: json.debug_info.processing_time,
Expand Down

0 comments on commit ed32df1

Please sign in to comment.