Skip to content

Commit a999bf0

Browse files
committed
Made the behaviour from PR #20 just the default onError callback
1 parent dc59c9e commit a999bf0

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,6 @@ The `props` values are end-to-end encrypted, so they can safely contain sensitiv
266266

267267
By using the `onError` option, you can emit notifications or take other actions when an error response was to be emitted:
268268

269-
```ts
270-
new OAuthProvider({
271-
// ... other options ...
272-
onError({ code, description, status, headers }) {
273-
console.error(`Error ${code}: ${description}`)
274-
}
275-
})
276-
```
277-
278-
Or sending events to an external system as required:
279-
280269
```ts
281270
new OAuthProvider({
282271
// ... other options ...
@@ -300,6 +289,8 @@ new OAuthProvider({
300289
})
301290
```
302291

292+
By default, the `onError` callback is set to ``({ status, code, description }) => console.warn(`OAuth error response: ${status} ${code} - ${description}`)``.
293+
303294
## Implementation Notes
304295

305296
### End-to-end encryption

src/oauth-provider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,10 @@ class OAuthProviderImpl {
698698
}
699699

700700
this.options = {
701+
accessTokenTTL: DEFAULT_ACCESS_TOKEN_TTL,
702+
onError: ({ status, code, description }) =>
703+
console.warn(`OAuth error response: ${status} ${code} - ${description}`),
701704
...options,
702-
accessTokenTTL: options.accessTokenTTL || DEFAULT_ACCESS_TOKEN_TTL,
703705
};
704706
}
705707

0 commit comments

Comments
 (0)