@bcis/sdk 0.1.2 → 0.1.4

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.
Files changed (3) hide show
  1. package/LICENSE +185 -0
  2. package/README.md +34 -4
  3. package/package.json +3 -3
package/LICENSE ADDED
@@ -0,0 +1,185 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and derivative works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under
83
+ this License for that Work shall terminate as of the date such
84
+ litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative Works
92
+ a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the attribution
105
+ notices contained within such NOTICE file, in at least one
106
+ of the following places: within a NOTICE text file distributed
107
+ as part of the Derivative Works; within the Source form or
108
+ documentation, if provided along with the Derivative Works; or,
109
+ within a display generated by the Derivative Works, if and
110
+ wherever such third-party notices normally appear. The contents
111
+ of the NOTICE file are for informational purposes only and
112
+ do not modify the License. You may add Your own attribution
113
+ notices within Derivative Works that You distribute, alongside
114
+ or as an addendum to the NOTICE text from the Work, provided
115
+ that such additional attribution notices cannot be construed
116
+ as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Contribution, either on Your own behalf and on Your sole
122
+ responsibility, or together with other Contributors, on the terms
123
+ and conditions of this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any warranties or conditions
143
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
144
+ PARTICULAR PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or redistributing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (including but not limited to damages for loss of goodwill,
156
+ work stoppage, computer failure or malfunction, or all other
157
+ commercial damages or losses), even if such Contributor has been
158
+ advised of the possibility of such damages.
159
+
160
+ 9. Accepting Warranty or Additional Liability. While redistributing
161
+ the Work or Derivative Works thereof, You may choose to offer,
162
+ and charge a fee for, acceptance of support, warranty, indemnity,
163
+ or other liability obligations and/or rights consistent with this
164
+ License. However, in accepting such obligations, You may act only
165
+ on Your own behalf and on Your sole responsibility, not on behalf
166
+ of any other Contributor, and only if You agree to indemnify,
167
+ defend, and hold each Contributor harmless for any liability
168
+ incurred by, or claims asserted against, such Contributor by reason
169
+ of your accepting any such warranty or additional liability.
170
+
171
+ END OF TERMS AND CONDITIONS
172
+
173
+ Copyright 2025 BCIS (Building Cost Information Service)
174
+
175
+ Licensed under the Apache License, Version 2.0 (the "License");
176
+ you may not use this file except in compliance with the License.
177
+ You may obtain a copy of the License at
178
+
179
+ http://www.apache.org/licenses/LICENSE-2.0
180
+
181
+ Unless required by applicable law or agreed to in writing, software
182
+ distributed under the License is distributed on an "AS IS" BASIS,
183
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
184
+ See the License for the specific language governing permissions and
185
+ limitations under the License.
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
- tokenUrl: 'https://auth.bcis.co.uk/oauth/token',
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:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bcis/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Type-safe TypeScript SDK for BCIS APIs",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,7 +17,7 @@
17
17
  }
18
18
  }
19
19
  },
20
- "files": ["dist"],
20
+ "files": ["dist", "LICENSE"],
21
21
  "scripts": {
22
22
  "build": "tsup",
23
23
  "typecheck": "tsc --noEmit",
@@ -25,7 +25,7 @@
25
25
  "test:watch": "vitest"
26
26
  },
27
27
  "keywords": ["bcis", "construction", "cost", "sdk", "typescript"],
28
- "license": "Unlicensed",
28
+ "license": "Apache-2.0",
29
29
  "publishConfig": {
30
30
  "registry": "https://registry.npmjs.org/",
31
31
  "access": "public"