@healthcloudai/hc-settings-connector 0.2.2 → 0.2.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.
package/README.md CHANGED
@@ -60,7 +60,7 @@ const settingsClient = new HCSettingsClient(
60
60
  );
61
61
  ```
62
62
 
63
- `HCLoginClient` must be configured before creating the Settings client. Most Settings methods require an authenticated patient session. `captureRegistrationDocument(...)` is intended for unauthenticated registration flows and does not send the auth token.
63
+ `HCLoginClient` must be configured before creating the Settings client. Most Settings methods require an authenticated patient session. `getRegistrationDocumentCannedUrl(...)` and `captureRegistrationDocument(...)` are intended for unauthenticated registration flows and do not send the auth token.
64
64
 
65
65
  ---
66
66
 
@@ -682,6 +682,90 @@ console.log(response);
682
682
 
683
683
  Registration document capture is used during registration, before the user is authenticated. It sends the same capture request shape as patient capture, but it does not attach the patient authorization token.
684
684
 
685
+ The full unauthenticated registration document flow is:
686
+
687
+ 1. `getRegistrationDocumentCannedUrl(documentType, extension)` — get a presigned upload URL and a `fileKey` (`FileName`), without an auth token.
688
+ 2. Upload the file directly to the returned `ImageURL` (`PUT`, with the **`x-amz-acl: public-read`** header — see warning below).
689
+ 3. `captureRegistrationDocument(fileKey, type)` — submit the uploaded file's `fileKey` for OCR capture, also without an auth token.
690
+
691
+ ## Get Registration Document Canned URL
692
+
693
+ Public signature:
694
+
695
+ ```ts
696
+ settingsClient.getRegistrationDocumentCannedUrl(
697
+ documentType,
698
+ extension
699
+ )
700
+ ```
701
+
702
+ `documentType` must be one of:
703
+
704
+ ```ts
705
+ "identification" | "healthinsurance"
706
+ ```
707
+
708
+ Returns a presigned upload URL (`ImageURL`) and a storage `FileName` (used as the `fileKey` for `captureRegistrationDocument`), without sending the patient auth token. Only `loginClient.configure(...)` is required.
709
+
710
+ ```ts
711
+ const response =
712
+ await settingsClient.getRegistrationDocumentCannedUrl(
713
+ "identification",
714
+ "png"
715
+ );
716
+
717
+ console.log(response.Data?.ImageURL, response.Data?.FileName);
718
+ ```
719
+
720
+ > ⚠️ **You MUST send the `x-amz-acl: public-read` header on the upload PUT request.** The presigned `ImageURL` is signed *with* an `x-amz-acl: public-read` header included in the signature. If your upload request to that URL omits this exact header, S3 recalculates a different signature and rejects the upload with:
721
+ >
722
+ > ```xml
723
+ > <Error>
724
+ > <Code>SignatureDoesNotMatch</Code>
725
+ > <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
726
+ > ...
727
+ > </Error>
728
+ > ```
729
+ >
730
+ > Example upload (must include the header):
731
+ >
732
+ > ```ts
733
+ > await fetch(response.Data!.ImageURL!, {
734
+ > method: "PUT",
735
+ > headers: {
736
+ > "Content-Type": "image/png",
737
+ > "x-amz-acl": "public-read",
738
+ > },
739
+ > body: fileBytes,
740
+ > });
741
+ > ```
742
+
743
+ ### API request
744
+
745
+ ```json
746
+ {
747
+ "Data": {
748
+ "Extension": "png"
749
+ }
750
+ }
751
+ ```
752
+
753
+ ### API response
754
+
755
+ ```json
756
+ {
757
+ "Data": {
758
+ "ImageURL": "https://storage.example.com/idcard_example.png?X-Amz-Expires=300&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=example&X-Amz-Date=example&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Signature=example",
759
+ "FileName": "idcard_example.png",
760
+ "Extension": "png"
761
+ },
762
+ "ErrorMessage": null,
763
+ "IsOK": true
764
+ }
765
+ ```
766
+
767
+
768
+
685
769
  ## Capture Registration Document
686
770
 
687
771
  Public signature:
@@ -798,7 +882,8 @@ console.log(response);
798
882
  * `captureDrivingLicense(...)` internally sends `Type: "identification"`.
799
883
  * `captureInsurance(...)` internally sends `Type: "healthinsurance"`.
800
884
  * `captureUserPhoto(...)` internally sends `Type: "userphoto"`.
801
- * `captureRegistrationDocument(...)` does not send the patient auth token.
885
+ * `getRegistrationDocumentCannedUrl(...)` and `captureRegistrationDocument(...)` do not send the patient auth token.
886
+ * The `ImageURL` returned by `getRegistrationDocumentCannedUrl(...)` is signed with `x-amz-acl: public-read` — your upload PUT request **must** include that exact header or S3 rejects it with `SignatureDoesNotMatch`. See [Get Registration Document Canned URL](#get-registration-document-canned-url).
802
887
 
803
888
  ```
804
889
  ```
@@ -808,7 +893,7 @@ console.log(response);
808
893
 
809
894
  ## Prerequisites
810
895
 
811
- `HCLoginClient` must be configured before using this connector. Most methods require the patient to be logged in. `captureRegistrationDocument(...)` is the unauthenticated exception and does not send the auth token.
896
+ `HCLoginClient` must be configured before using this connector. Most methods require the patient to be logged in. `getRegistrationDocumentCannedUrl(...)` and `captureRegistrationDocument(...)` are the unauthenticated exceptions they do not send the auth token.
812
897
 
813
898
  ```ts
814
899
  import { HCLoginClient } from "@healthcloudai/hc-login-connector";
package/dist/index.cjs CHANGED
@@ -242,6 +242,31 @@ var HCSettingsClient = class extends import_hc_http.HCBaseConnector {
242
242
  // ===========================================================================
243
243
  // Registration document capture
244
244
  // ===========================================================================
245
+ /**
246
+ * Returns a canned URL for uploading a registration document image
247
+ * (driving licence or insurance card) before the user is authenticated.
248
+ * Does not send the patient auth token.
249
+ *
250
+ * The returned `ImageURL` is signed with an `x-amz-acl: public-read`
251
+ * header — the upload PUT request to that URL must include the exact
252
+ * same header (`x-amz-acl: public-read`) or S3 will reject it with
253
+ * `SignatureDoesNotMatch`.
254
+ */
255
+ async getRegistrationDocumentCannedUrl(documentType, extension) {
256
+ const resolvedDocumentType = this.requireValue(documentType, "Document type", "documentType");
257
+ const resolvedExtension = this.requireValue(extension, "Extension", "extension");
258
+ const requestPayload = {
259
+ Data: { Extension: resolvedExtension }
260
+ };
261
+ return this.execute(
262
+ "getRegistrationDocumentCannedUrl",
263
+ () => this.http.put(
264
+ `${this.auth.getBaseUrl()}/api/patient/registration/document/cannedurl/${resolvedDocumentType}`,
265
+ requestPayload,
266
+ this.getHeaders()
267
+ )
268
+ );
269
+ }
245
270
  /**
246
271
  * Submits an uploaded registration document for capture without sending
247
272
  * an authenticated patient token.
package/dist/index.d.cts CHANGED
@@ -165,6 +165,17 @@ declare class HCSettingsClient extends HCBaseConnector {
165
165
  * fileKey is the storage key of the uploaded image.
166
166
  */
167
167
  captureUserPhoto(fileKey: string): Promise<APIResponse<CaptureResult<UserPhotoCaptureData>>>;
168
+ /**
169
+ * Returns a canned URL for uploading a registration document image
170
+ * (driving licence or insurance card) before the user is authenticated.
171
+ * Does not send the patient auth token.
172
+ *
173
+ * The returned `ImageURL` is signed with an `x-amz-acl: public-read`
174
+ * header — the upload PUT request to that URL must include the exact
175
+ * same header (`x-amz-acl: public-read`) or S3 will reject it with
176
+ * `SignatureDoesNotMatch`.
177
+ */
178
+ getRegistrationDocumentCannedUrl(documentType: CaptureType, extension: string): Promise<APIResponse<UserImage>>;
168
179
  /**
169
180
  * Submits an uploaded registration document for capture without sending
170
181
  * an authenticated patient token.
package/dist/index.d.ts CHANGED
@@ -165,6 +165,17 @@ declare class HCSettingsClient extends HCBaseConnector {
165
165
  * fileKey is the storage key of the uploaded image.
166
166
  */
167
167
  captureUserPhoto(fileKey: string): Promise<APIResponse<CaptureResult<UserPhotoCaptureData>>>;
168
+ /**
169
+ * Returns a canned URL for uploading a registration document image
170
+ * (driving licence or insurance card) before the user is authenticated.
171
+ * Does not send the patient auth token.
172
+ *
173
+ * The returned `ImageURL` is signed with an `x-amz-acl: public-read`
174
+ * header — the upload PUT request to that URL must include the exact
175
+ * same header (`x-amz-acl: public-read`) or S3 will reject it with
176
+ * `SignatureDoesNotMatch`.
177
+ */
178
+ getRegistrationDocumentCannedUrl(documentType: CaptureType, extension: string): Promise<APIResponse<UserImage>>;
168
179
  /**
169
180
  * Submits an uploaded registration document for capture without sending
170
181
  * an authenticated patient token.
package/dist/index.js CHANGED
@@ -210,6 +210,31 @@ var HCSettingsClient = class extends HCBaseConnector {
210
210
  // ===========================================================================
211
211
  // Registration document capture
212
212
  // ===========================================================================
213
+ /**
214
+ * Returns a canned URL for uploading a registration document image
215
+ * (driving licence or insurance card) before the user is authenticated.
216
+ * Does not send the patient auth token.
217
+ *
218
+ * The returned `ImageURL` is signed with an `x-amz-acl: public-read`
219
+ * header — the upload PUT request to that URL must include the exact
220
+ * same header (`x-amz-acl: public-read`) or S3 will reject it with
221
+ * `SignatureDoesNotMatch`.
222
+ */
223
+ async getRegistrationDocumentCannedUrl(documentType, extension) {
224
+ const resolvedDocumentType = this.requireValue(documentType, "Document type", "documentType");
225
+ const resolvedExtension = this.requireValue(extension, "Extension", "extension");
226
+ const requestPayload = {
227
+ Data: { Extension: resolvedExtension }
228
+ };
229
+ return this.execute(
230
+ "getRegistrationDocumentCannedUrl",
231
+ () => this.http.put(
232
+ `${this.auth.getBaseUrl()}/api/patient/registration/document/cannedurl/${resolvedDocumentType}`,
233
+ requestPayload,
234
+ this.getHeaders()
235
+ )
236
+ );
237
+ }
213
238
  /**
214
239
  * Submits an uploaded registration document for capture without sending
215
240
  * an authenticated patient token.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healthcloudai/hc-settings-connector",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Healthcheck Settings SDK with TypeScript",
5
5
  "author": "Healthcheck Systems Inc",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "axios": "^1.13.4",
39
- "@healthcloudai/hc-login-connector": "^0.3.1",
39
+ "@healthcloudai/hc-login-connector": "^0.4.0",
40
40
  "@healthcloudai/hc-http": "^0.2.1"
41
41
  },
42
42
  "peerDependencies": {