@bcis/sdk 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,11 +30,12 @@ const auth = new AuthManager({
|
|
|
30
30
|
flow: 'client-credentials',
|
|
31
31
|
clientId: 'YOUR_CLIENT_ID',
|
|
32
32
|
clientSecret: 'YOUR_CLIENT_SECRET',
|
|
33
|
-
|
|
34
|
-
scopes: ['openid'], // optional
|
|
33
|
+
// scopes: ['openid'], // optional
|
|
35
34
|
});
|
|
36
35
|
```
|
|
37
36
|
|
|
37
|
+
> OAuth2 endpoints are resolved automatically via OpenID Connect discovery (see [Custom endpoints](#custom-oauth2-endpoints) below).
|
|
38
|
+
|
|
38
39
|
### Authorization Code + PKCE (user-facing applications)
|
|
39
40
|
|
|
40
41
|
Use this flow when your application acts on behalf of a logged-in user.
|
|
@@ -45,8 +46,6 @@ import { AuthManager } from '@bcis/sdk';
|
|
|
45
46
|
const auth = new AuthManager({
|
|
46
47
|
flow: 'authorization-code',
|
|
47
48
|
clientId: 'YOUR_CLIENT_ID',
|
|
48
|
-
tokenUrl: 'https://auth.bcis.co.uk/oauth/token',
|
|
49
|
-
authorizationUrl: 'https://auth.bcis.co.uk/authorize',
|
|
50
49
|
redirectUri: 'https://yourapp.com/callback',
|
|
51
50
|
scopes: ['openid', 'profile'],
|
|
52
51
|
});
|
|
@@ -61,6 +60,28 @@ await auth.handleCallback(code, codeVerifier);
|
|
|
61
60
|
// Step 3 — the SDK will now attach the token to every request automatically
|
|
62
61
|
```
|
|
63
62
|
|
|
63
|
+
### Custom OAuth2 endpoints
|
|
64
|
+
|
|
65
|
+
By default the SDK fetches `tokenUrl` and `authorizationUrl` from the BCIS OpenID Connect
|
|
66
|
+
discovery document at `https://id.bcis.co.uk/.well-known/openid-configuration`.
|
|
67
|
+
The result is cached in memory for the lifetime of the process.
|
|
68
|
+
|
|
69
|
+
You can override individual URLs or point to a different discovery document:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const auth = new AuthManager({
|
|
73
|
+
flow: 'client-credentials',
|
|
74
|
+
clientId: 'YOUR_CLIENT_ID',
|
|
75
|
+
clientSecret: 'YOUR_CLIENT_SECRET',
|
|
76
|
+
|
|
77
|
+
// Option A — supply a custom discovery URL (e.g. staging):
|
|
78
|
+
discoveryUrl: 'https://id.staging.bcis.co.uk/.well-known/openid-configuration',
|
|
79
|
+
|
|
80
|
+
// Option B — provide endpoint URLs directly (skips discovery entirely):
|
|
81
|
+
tokenUrl: 'https://id.bcis.co.uk/oauth/token',
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
64
85
|
---
|
|
65
86
|
|
|
66
87
|
## Available Clients
|
|
@@ -77,6 +98,9 @@ Core APIs Documentation
|
|
|
77
98
|
import { AuthManager, CoreApiClient } from '@bcis/sdk';
|
|
78
99
|
|
|
79
100
|
const client = new CoreApiClient(auth);
|
|
101
|
+
|
|
102
|
+
// Override the base URL (e.g. for a staging environment):
|
|
103
|
+
// const client = new CoreApiClient(auth, { baseUrl: 'https://api.bcis.co.uk/core-apis' });
|
|
80
104
|
```
|
|
81
105
|
|
|
82
106
|
**Methods:**
|
|
@@ -138,6 +162,9 @@ The target audience includes insurance companies and brokers that require rebuil
|
|
|
138
162
|
import { AuthManager, ResidentialRebuildClient } from '@bcis/sdk';
|
|
139
163
|
|
|
140
164
|
const client = new ResidentialRebuildClient(auth);
|
|
165
|
+
|
|
166
|
+
// Override the base URL (e.g. for a staging environment):
|
|
167
|
+
// const client = new ResidentialRebuildClient(auth, { baseUrl: 'https://api.bcis.co.uk/residential-rebuild-calculator' });
|
|
141
168
|
```
|
|
142
169
|
|
|
143
170
|
**Methods:**
|
|
@@ -186,6 +213,9 @@ The BCIS Schedule of Rates API is designed for integration with your application
|
|
|
186
213
|
import { AuthManager, ScheduleOfRatesClient } from '@bcis/sdk';
|
|
187
214
|
|
|
188
215
|
const client = new ScheduleOfRatesClient(auth);
|
|
216
|
+
|
|
217
|
+
// Override the base URL (e.g. for a staging environment):
|
|
218
|
+
// const client = new ScheduleOfRatesClient(auth, { baseUrl: 'https://api.bcis.co.uk/schedule-of-rates' });
|
|
189
219
|
```
|
|
190
220
|
|
|
191
221
|
**Methods:**
|