@welshare/react 0.2.3 → 0.4.0

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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +85 -44
  3. package/dist/esm/components/connect-button.d.ts.map +1 -1
  4. package/dist/esm/components/connect-button.js +1 -4
  5. package/dist/esm/components/welshare-logo.d.ts +1 -1
  6. package/dist/esm/hooks/use-binary-uploads.d.ts +59 -0
  7. package/dist/esm/hooks/use-binary-uploads.d.ts.map +1 -0
  8. package/dist/esm/hooks/use-binary-uploads.js +93 -0
  9. package/dist/esm/hooks/use-welshare.d.ts.map +1 -1
  10. package/dist/esm/hooks/use-welshare.js +16 -8
  11. package/dist/esm/index.d.ts +3 -1
  12. package/dist/esm/index.d.ts.map +1 -1
  13. package/dist/esm/index.js +8 -5
  14. package/dist/esm/lib/encryption.d.ts.map +1 -1
  15. package/dist/esm/lib/encryption.js +3 -13
  16. package/dist/esm/lib/uploads.d.ts.map +1 -1
  17. package/dist/esm/lib/uploads.js +1 -3
  18. package/dist/esm/types.d.ts +11 -0
  19. package/dist/esm/types.d.ts.map +1 -1
  20. package/dist/esm/utils.d.ts.map +1 -1
  21. package/dist/node_modules/@welshare/react/.turbo/turbo-build.log +5 -0
  22. package/dist/node_modules/@welshare/react/.turbo/turbo-lint.log +14 -0
  23. package/dist/node_modules/@welshare/react/LICENSE +1 -1
  24. package/dist/node_modules/@welshare/react/README.md +85 -44
  25. package/dist/node_modules/@welshare/react/dist/esm/components/connect-button.d.ts.map +1 -1
  26. package/dist/node_modules/@welshare/react/dist/esm/components/connect-button.js +1 -4
  27. package/dist/node_modules/@welshare/react/dist/esm/components/welshare-logo.d.ts +1 -1
  28. package/dist/node_modules/@welshare/react/dist/esm/hooks/use-binary-uploads.d.ts +59 -0
  29. package/dist/node_modules/@welshare/react/dist/esm/hooks/use-binary-uploads.d.ts.map +1 -0
  30. package/dist/node_modules/@welshare/react/dist/esm/hooks/use-binary-uploads.js +93 -0
  31. package/dist/node_modules/@welshare/react/dist/esm/hooks/use-welshare.d.ts.map +1 -1
  32. package/dist/node_modules/@welshare/react/dist/esm/hooks/use-welshare.js +16 -8
  33. package/dist/node_modules/@welshare/react/dist/esm/index.d.ts +3 -1
  34. package/dist/node_modules/@welshare/react/dist/esm/index.d.ts.map +1 -1
  35. package/dist/node_modules/@welshare/react/dist/esm/index.js +8 -5
  36. package/dist/node_modules/@welshare/react/dist/esm/lib/encryption.d.ts.map +1 -1
  37. package/dist/node_modules/@welshare/react/dist/esm/lib/encryption.js +3 -13
  38. package/dist/node_modules/@welshare/react/dist/esm/lib/uploads.d.ts.map +1 -1
  39. package/dist/node_modules/@welshare/react/dist/esm/lib/uploads.js +1 -3
  40. package/dist/node_modules/@welshare/react/dist/esm/types.d.ts +11 -0
  41. package/dist/node_modules/@welshare/react/dist/esm/types.d.ts.map +1 -1
  42. package/dist/node_modules/@welshare/react/dist/esm/utils.d.ts.map +1 -1
  43. package/dist/node_modules/@welshare/react/eslint.config.mjs +2 -2
  44. package/dist/node_modules/@welshare/react/package.json +5 -2
  45. package/dist/node_modules/@welshare/react/src/components/connect-button.tsx +1 -4
  46. package/dist/node_modules/@welshare/react/src/components/welshare-logo.tsx +1 -1
  47. package/dist/node_modules/@welshare/react/src/hooks/use-binary-uploads.ts +181 -0
  48. package/dist/node_modules/@welshare/react/src/hooks/use-welshare.ts +24 -10
  49. package/dist/node_modules/@welshare/react/src/index.ts +22 -5
  50. package/dist/node_modules/@welshare/react/src/lib/encryption.ts +3 -13
  51. package/dist/node_modules/@welshare/react/src/lib/uploads.ts +2 -4
  52. package/dist/node_modules/@welshare/react/src/types.ts +21 -10
  53. package/dist/node_modules/@welshare/react/src/utils.ts +1 -5
  54. package/dist/node_modules/@welshare/react/tsconfig.json +3 -12
  55. package/package.json +5 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  ### Disclaimer, notes on maturity
4
4
 
5
- This library is in Alpha / demo state at this moment. We're using it to review the security aspects while data is in transfer and in rest. There's absolutely no guarantee or warrant that at this point any data is safe. All data can be lost at any time - even though we're using resources that puts decentralization and resilience values to the front. Be **very** careful if you're integrating this into user facing code. Welshare Health wallets are controlled by cryptographic material which _can_ be stored in non custodial / MPC environments (Privy). While that's considered very safe, we can't guarantee at this point that we've already got each aspect of inter application communication or key derivation features right, so don't connect wallets that store significant value with the welshare wallet yet.
5
+ This library is in Alpha / demo state at this moment. We're using it to review the security aspects while data is in transfer and in rest. There's absolutely no guarantee or warrant that at this point any data is safe, even though we're using resources that prioritize decentralization and resilience. Welshare Health wallets are controlled by cryptographic material which _can_ be stored in non custodial / MPC environments (Privy). While that's considered very safe, we can't guarantee at this point that we've already got each aspect of inter application communication or key derivation features right, so don't connect wallets that store significant value with the welshare wallet yet.
6
6
 
7
7
  ## Purpose
8
8
 
@@ -32,9 +32,10 @@ If you want to submit questionnaire data, your application must first register a
32
32
 
33
33
  At the moment there are only two supported submission types: Fhir compatible QuestionnaireResponses and our custom "Reflex" app submissions. Both types are identified by schema uids that are accessible on the `Schemas` export.
34
34
 
35
- ```
35
+ ```js
36
36
  export const Schemas = {
37
- QuestionnaireResponse: "b14b538f-7de3-4767-ad77-464d755d78bd"
37
+ QuestionnaireResponse: "b14b538f-7de3-4767-ad77-464d755d78bd",
38
+ BinaryFile: "9d696baf-483f-4cc0-b748-23a22c1705f5",
38
39
  };
39
40
  ```
40
41
 
@@ -83,47 +84,93 @@ export function QuestionnaireForm() {
83
84
 
84
85
  ### Binary file uploads (e.g. images)
85
86
 
86
- binary file uploads require a lot of back and forth with the wallet dialog that we wrapped into one convenient upload API. If you want to include binary uploads into your questionnaires, you would typically hook into your own form, upload the file using the `uploadFile` function exposed by the `useWelshare` hook and use the response information to in the respective questionnaire form answer item.
87
+ The package provides two ways to upload binary files:
88
+
89
+ 1. **`useWelshare` hook** - Upload via the wallet dialog (external wallet flow)
90
+ 2. **`useBinaryUploads` hook** - Upload directly with your own session keypair
91
+
92
+ Before data hits any server, the SDK encrypts all files with a new random symmetric AES (GCM / 256 bits) key. Users request a presigned upload url and post the encrypted file to an S3 compatible API that's currently operated by Welshare. Ultimately, they encrypt the encryption key for a Nillion _owned_ BinaryData collection and store it across Nillion nodes (no single node can recover the key). At the time of insertion, they currently also grant ACL read rights for the application (Technically, this is the welshare builder keypair at the moment).
93
+
94
+ #### Option 1: Upload via Wallet Dialog (`useWelshare`)
87
95
 
88
- Each download should contain a reference to the resource that initiated its upload. As Welshare right now is mostly about questionnaires, you should use a combination of the resource type (questionnaire), the questionnaire id and the answer item's id
96
+ This works best for applications that **don't** manage their own keypairs. It delegates the heavy lifting to the welshare wallet dialog frame.
89
97
 
90
98
  ```ts
91
- const reference = `questionnaire/${questionnaireId}/${answerItemId}`;
99
+ const { isConnected, openWallet, uploadFile, submitData } = useWelshare({
100
+ applicationId: process.env.NEXT_PUBLIC_WELSHARE_APP_ID || "",
101
+ });
102
+
103
+ // Upload file (wallet dialog handles auth)
104
+ const { url: uploadedFileUrl, binaryFileUid } = await uploadFile(
105
+ userFile,
106
+ `questionnaire/${questionnaireId}/${linkId}`
107
+ );
108
+
109
+ // Use in QuestionnaireResponse
110
+ const responseItem = {
111
+ answer: [
112
+ {
113
+ valueAttachment: {
114
+ id: binaryFileUid,
115
+ contentType: userFile.type,
116
+ size: userFile.size,
117
+ title: userFile.name,
118
+ url: uploadedFileUrl,
119
+ },
120
+ },
121
+ ],
122
+ };
92
123
  ```
93
124
 
94
- Binary files are addressed as items of type `valueAttachment` in Fhir. See https://www.hl7.org/fhir/questionnaireresponse.html
95
-
96
- Before uploading, welshare encrypts all files with a new random symmetric AES (GCM / 256 bits) key. Users request a presigned upload url and post the encrypted file to an S3 compatible API of ours. Finally, they encrypt the encryption key on a user controlled Nillion *owned* collection for binary data and grant respective access rights for the application. The application a user used to upload the file is by default able to download the file again (Technically, that application is always welshare right now. This will change to the "builder" address of the respective app and the hpmp enclave keys, which allow AI access to the files)
125
+ #### Option 2: Direct Upload (`useBinaryUploads`)
97
126
 
98
- Here's an example how to use it:
127
+ For applications that manage storage keypairs directly:
99
128
 
100
129
  ```ts
101
- const { isConnected, openWallet, uploadFile, submitData } = useWelshare({
102
- applicationId: process.env.NEXT_PUBLIC_WELSHARE_APP_ID || ""
103
- })
104
- //... let users select a file on their box
105
-
106
- const { url: uploadedFileUrl, binaryFileUid } = await uploadFile(
107
- userFile,
108
- reference: `questionnaire/${questionnaireId}/<linkId>`
109
- );
130
+ import {
131
+ useBinaryUploads,
132
+ encryptAndUploadFile,
133
+ Schemas,
134
+ } from "@welshare/react";
135
+ import { WelshareApi } from "@welshare/sdk";
136
+
137
+ const { createUploadCredentials, downloadAndDecryptFile, isRunning, error } =
138
+ useBinaryUploads({
139
+ keypair: storageKeyPair, // storage keypairs are derived by users
140
+ environment: "production",
141
+ });
110
142
 
111
- const responseItem = {
112
- answer = [
113
- {
114
- valueAttachment: {
115
- id: binaryFileUid,
116
- contentType: userFile.type,
117
- size: userFile.size,
118
- title: userFile.name,
119
- url: uploadedFileUrl,
120
- },
121
- },
122
- ];
123
- }
124
- // insert the responseItem into your QuestionnaireResponse
143
+ // Get presigned URL
144
+ const { presignedUrl, uploadKey } = await createUploadCredentials({
145
+ applicationId: "your-app-id",
146
+ reference: `questionnaire/${questionnaireId}/photo`,
147
+ fileName: file.name,
148
+ fileType: file.type,
149
+ });
150
+
151
+ // Encrypt & upload to S3, then submit metadata to Nillion
152
+ const { encryptionKey } = await encryptAndUploadFile(file, presignedUrl);
153
+ await WelshareApi.submitBinaryData(
154
+ storageKeyPair,
155
+ {
156
+ encryption_key: JSON.stringify(encryptionKey),
157
+ reference: `questionnaire/${questionnaireId}/photo`,
158
+ file_name: file.name,
159
+ file_size: file.size,
160
+ file_type: file.type,
161
+ controller_did: storageKeyPair.toDidString(),
162
+ url: `welshare://${uploadKey}`,
163
+ },
164
+ "production",
165
+ applicationId
166
+ );
167
+
168
+ // Download and decrypt owned files
169
+ const decryptedFile = await downloadAndDecryptFile(documentId);
125
170
  ```
126
171
 
172
+ Binary files are addressed as `valueAttachment` items in FHIR. See https://www.hl7.org/fhir/questionnaireresponse.html
173
+
127
174
  ## API
128
175
 
129
176
  ### supported callbacks
@@ -143,21 +190,15 @@ those are configured in the `useWelshare` options parameter and called back duri
143
190
 
144
191
  ## Security Notes
145
192
 
146
- No part of this application deals with a "blockchain" directly (Nillion nodes are validated by a custom chain but that's not a fact relevant for end users' security in this scope).
147
-
148
- The EVM addresses that control a user profile are (supposedly) never leaked to a third party.
149
-
150
- The key derivation mechanism that creates new storage keys that users use to sign messages is not guaranteed to be 100% sound. At this moment it's used as a cryptographic authenticator, but the derivation mechanism will change in the future, rendering already existing keys obsolete. We're not guaranteeing that your key material stays trivially derivable.
193
+ No part of this application interacts with a "blockchain" (Nillion nodes are validated by a custom chain but that's relevant for end users' security or privacy).
151
194
 
152
- Data is stored on [nilDB (by Nillion)](https://docs.nillion.com/build/private-storage/quickstart), a system that can enforces access control, encryption at rest and storage redundancy. While technically possible, the current library does not MPC-encrypt any information. The data is sent to nilDB by a _user client_ that's controlled by the user's own key material. Welshare only delegates NUCs (access rights) to the users. Right now the welshare builder _can_ read any data users upload. This concept will eventually change - welshare's goal is to only make user originated information available inside trusted execution environments.
195
+ The EVM addresses that control a user profile are never disclosed to third parties, hence they cannot correlate the wallet control keys with the keys that control the actual data.
153
196
 
154
- ## Development
197
+ The key derivation mechanism is used for creating self signed cryptographic authentication tokens, but the mechanism that keys are derived will very likely change in the future. Existing keys might render obsolete at that point which will require users to manually migrate their data. We don't guarantee that the current key derivation mechanism will be part of this SDK's exposed feature set forever. However, users will always be able to derive keys on their own, as long as they know the rules and don't lose the required secret inputs (e.g. signing keys or salts).
155
198
 
156
- This package is built using:
199
+ Data is stored on [nilDB (by Nillion)](https://docs.nillion.com/build/private-storage/quickstart), a protocol that enforces access control lists, encrypts data at rest and stores records redundantly. Plain data documents are not generally encrypted at this point in time, however. Binary uploads are end to end encrypted in the way that's described above.
157
200
 
158
- - TypeScript
159
- - Tshy for build management
160
- - Vitest for testing
201
+ All data that's sent to nilDB via _user client_ is exclusively controlled by the user's own key material. Welshare only delegates NUCs (access rights) to the users. Be aware that right now the welshare builder key _can_ read any data users upload. This will structurally improve once Nillion supports delegated reads for non builder grantees. Welshare's goal is to make user originated information available exclusively for code that runs in execution environments trusted by the users.
161
202
 
162
203
  ## License
163
204
 
@@ -1 +1 @@
1
- {"version":3,"file":"connect-button.d.ts","sourceRoot":"","sources":["../../../src/components/connect-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,qBAAqB,UAAW;IAC3C,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,4CAiGA,CAAC"}
1
+ {"version":3,"file":"connect-button.d.ts","sourceRoot":"","sources":["../../../src/components/connect-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,qBAAqB,UAAW;IAC3C,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,4CA8FA,CAAC"}
@@ -55,8 +55,5 @@ export const ConnectWelshareButton = (props) => {
55
55
  const handleBlur = (e) => {
56
56
  e.currentTarget.style.boxShadow = "0 2px 6px rgba(1, 152, 255, 0.2)";
57
57
  };
58
- return (_jsx("button", { onClick: props.openWallet, style: buttonStyles, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseDown: handleMouseDown, onFocus: handleFocus, onBlur: handleBlur, type: "button", children: _jsx(_Fragment, { children: props.children || (_jsxs(_Fragment, { children: [_jsx("span", { className: "", children: _jsx(WelshareLogo, { width: 24, height: 18, style: {
59
- "marginRight": "4px",
60
- color: "#ffffff",
61
- } }) }), _jsx("span", { children: "Connect Welshare Profile" })] })) }) }));
58
+ return (_jsx("button", { onClick: props.openWallet, style: buttonStyles, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseDown: handleMouseDown, onFocus: handleFocus, onBlur: handleBlur, type: "button", children: _jsx(_Fragment, { children: props.children || (_jsxs(_Fragment, { children: [_jsx("span", { className: "", children: _jsx(WelshareLogo, { width: 24, height: 18, style: { marginRight: "4px", color: "#ffffff" } }) }), _jsx("span", { children: "Connect Welshare Profile" })] })) }) }));
62
59
  };
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  export interface WelshareLogoProps {
3
3
  className?: string;
4
4
  style?: React.CSSProperties;
@@ -0,0 +1,59 @@
1
+ import type { RequestUploadCredentialsPayload, UploadCredentials } from "../types.js";
2
+ import { Nillion, type WelshareApiEnvironment, type WelshareEnvironmentName } from "@welshare/sdk";
3
+ export interface UseBinaryUploadsOptions {
4
+ /**
5
+ * The user's session keypair for authentication.
6
+ */
7
+ keypair: Nillion.Keypair | null | undefined;
8
+ /**
9
+ * The Welshare environment to use for API calls.
10
+ */
11
+ environment: WelshareApiEnvironment | WelshareEnvironmentName;
12
+ }
13
+ export interface UseBinaryUploadsResult {
14
+ /**
15
+ * Request upload credentials (presigned URL) for uploading an encrypted file.
16
+ */
17
+ createUploadCredentials: (payload: RequestUploadCredentialsPayload) => Promise<UploadCredentials>;
18
+ /**
19
+ * Download and decrypt a file by its document ID.
20
+ * Only works for files owned by the current user.
21
+ */
22
+ downloadAndDecryptFile: (documentId: string) => Promise<File | undefined>;
23
+ /**
24
+ * Whether an operation is currently running.
25
+ */
26
+ isRunning: boolean;
27
+ /**
28
+ * Error message if the last operation failed.
29
+ */
30
+ error: string | null;
31
+ }
32
+ /**
33
+ * Hook for managing binary file uploads and downloads with Welshare.
34
+ *
35
+ * This hook provides functionality to:
36
+ * - Request presigned URLs for uploading encrypted files to S3
37
+ * - Download and decrypt files from Nillion storage
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * const { createUploadCredentials, downloadAndDecryptFile, isRunning, error } = useBinaryUploads({
42
+ * keypair: sessionKeyPair,
43
+ * environment: 'production',
44
+ * });
45
+ *
46
+ * // Upload flow: get credentials, encrypt, upload to S3, then submit metadata via submitBinaryData
47
+ * const credentials = await createUploadCredentials({
48
+ * applicationId: 'my-app',
49
+ * reference: 'user-photo',
50
+ * fileName: 'photo.jpg',
51
+ * fileType: 'image/jpeg',
52
+ * });
53
+ *
54
+ * // Download and decrypt
55
+ * const file = await downloadAndDecryptFile(documentId);
56
+ * ```
57
+ */
58
+ export declare const useBinaryUploads: (options: UseBinaryUploadsOptions) => UseBinaryUploadsResult;
59
+ //# sourceMappingURL=use-binary-uploads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-binary-uploads.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-binary-uploads.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,+BAA+B,EAC/B,iBAAiB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EAGP,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C;;OAEG;IACH,WAAW,EAAE,sBAAsB,GAAG,uBAAuB,CAAC;CAC/D;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,uBAAuB,EAAE,CACvB,OAAO,EAAE,+BAA+B,KACrC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEhC;;;OAGG;IACH,sBAAsB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;IAC1E;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gBAAgB,YAClB,uBAAuB,KAC/B,sBAuGF,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { decrypt } from "../lib/encryption.js";
3
+ import { WelshareApi, resolveEnvironment, } from "@welshare/sdk";
4
+ /**
5
+ * Hook for managing binary file uploads and downloads with Welshare.
6
+ *
7
+ * This hook provides functionality to:
8
+ * - Request presigned URLs for uploading encrypted files to S3
9
+ * - Download and decrypt files from Nillion storage
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * const { createUploadCredentials, downloadAndDecryptFile, isRunning, error } = useBinaryUploads({
14
+ * keypair: sessionKeyPair,
15
+ * environment: 'production',
16
+ * });
17
+ *
18
+ * // Upload flow: get credentials, encrypt, upload to S3, then submit metadata via submitBinaryData
19
+ * const credentials = await createUploadCredentials({
20
+ * applicationId: 'my-app',
21
+ * reference: 'user-photo',
22
+ * fileName: 'photo.jpg',
23
+ * fileType: 'image/jpeg',
24
+ * });
25
+ *
26
+ * // Download and decrypt
27
+ * const file = await downloadAndDecryptFile(documentId);
28
+ * ```
29
+ */
30
+ export const useBinaryUploads = (options) => {
31
+ const [isRunning, setIsRunning] = useState(false);
32
+ const [error, setError] = useState(null);
33
+ const mountedRef = useRef(true);
34
+ useEffect(() => {
35
+ mountedRef.current = true;
36
+ return () => {
37
+ mountedRef.current = false;
38
+ };
39
+ }, []);
40
+ const resolvedEnvironment = useMemo(() => resolveEnvironment(options.environment), [options.environment]);
41
+ const { keypair } = options;
42
+ const createUploadCredentials = useCallback(async (payload) => {
43
+ if (!keypair) {
44
+ throw new Error("No keypair available");
45
+ }
46
+ const { reference, fileName, fileType } = payload;
47
+ const { presignedUrl, uploadKey } = await WelshareApi.fetchS3WriteDelegation(keypair, { reference, fileName, fileType }, resolvedEnvironment);
48
+ return { presignedUrl, uploadKey };
49
+ }, [keypair, resolvedEnvironment]);
50
+ /**
51
+ * Downloads and decrypts a file by its document ID from Nillion.
52
+ */
53
+ const downloadAndDecryptFile = useCallback(async (documentId) => {
54
+ if (!keypair) {
55
+ throw new Error("No keypair available");
56
+ }
57
+ try {
58
+ setIsRunning(true);
59
+ setError(null);
60
+ const { binaryFile, data: downloadResponse } = await WelshareApi.fetchBinaryData(keypair, resolvedEnvironment, documentId);
61
+ const encodedEncryptionKey = JSON.parse(binaryFile.encryption_key);
62
+ const decryptedData = await decrypt(await downloadResponse, encodedEncryptionKey);
63
+ if (!decryptedData) {
64
+ throw new Error("Failed to decrypt file (received null)");
65
+ }
66
+ const decryptedFile = new File([decryptedData], binaryFile.file_name, {
67
+ type: binaryFile.file_type,
68
+ });
69
+ return decryptedFile;
70
+ }
71
+ catch (err) {
72
+ console.error("Error during file download/decryption:", err);
73
+ const errorMessage = err instanceof Error
74
+ ? err.message
75
+ : "Failed to download/decrypt file";
76
+ if (mountedRef.current) {
77
+ setError(errorMessage);
78
+ }
79
+ return undefined;
80
+ }
81
+ finally {
82
+ if (mountedRef.current) {
83
+ setIsRunning(false);
84
+ }
85
+ }
86
+ }, [keypair, resolvedEnvironment]);
87
+ return {
88
+ createUploadCredentials,
89
+ downloadAndDecryptFile,
90
+ isRunning,
91
+ error,
92
+ };
93
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"use-welshare.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-welshare.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EACjB,kBAAkB,EAElB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,WAAW,UAAW,yBAAyB;;;;;uBAmLlD,IAAI,aACC,MAAM,KAChB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;iBA0C9B,CAAC,YACT,kBAAkB,cAChB,iBAAiB,CAAC,CAAC,CAAC;;;CAqEnC,CAAC"}
1
+ {"version":3,"file":"use-welshare.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-welshare.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EACjB,kBAAkB,EAElB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAQpB,eAAO,MAAM,WAAW,UAAW,yBAAyB;;;;;uBA8LlD,IAAI,aACC,MAAM,KAChB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;iBAuC9B,CAAC,YACT,kBAAkB,cAChB,iBAAiB,CAAC,CAAC,CAAC;;;CAuEnC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { getBaseUrl, WELSHARE_API_ENVIRONMENT, } from "@welshare/sdk/environment";
1
2
  import { useEffect, useRef, useState } from "react";
2
3
  import { encryptAndUploadFile } from "../lib/uploads.js";
3
4
  export const useWelshare = (props) => {
@@ -9,11 +10,15 @@ export const useWelshare = (props) => {
9
10
  const [uploadState, setUploadState] = useState();
10
11
  // (claude opus) Use ref to control current upload in effect without triggering re-renders
11
12
  const currentUploadRef = useRef(null);
13
+ // Resolve the base URL from environment or apiBaseUrl
14
+ const resolvedBaseUrl = props.environment
15
+ ? getBaseUrl(props.environment)
16
+ : (props.apiBaseUrl ?? getBaseUrl(WELSHARE_API_ENVIRONMENT.production));
12
17
  const options = {
13
- apiBaseUrl: "https://wallet.welshare.app",
14
18
  ...props,
19
+ apiBaseUrl: resolvedBaseUrl,
15
20
  };
16
- const WELSHARE_WALLET_URL = `${options.apiBaseUrl}/wallet-external`;
21
+ const WELSHARE_WALLET_URL = `${resolvedBaseUrl}/wallet-external`;
17
22
  useEffect(() => {
18
23
  const handleMessage = async (event) => {
19
24
  // Verify origin for security
@@ -128,7 +133,13 @@ export const useWelshare = (props) => {
128
133
  return () => {
129
134
  window.removeEventListener("message", handleMessage);
130
135
  };
131
- }, [WELSHARE_WALLET_URL, dialogWindow, messageIdCounter, options.applicationId, options.callbacks]);
136
+ }, [
137
+ WELSHARE_WALLET_URL,
138
+ dialogWindow,
139
+ messageIdCounter,
140
+ options.applicationId,
141
+ options.callbacks,
142
+ ]);
132
143
  /**
133
144
  * Starts a file upload and returns a promise that resolves with the uploaded file URL
134
145
  * @param file The file to upload
@@ -159,10 +170,7 @@ export const useWelshare = (props) => {
159
170
  const message = {
160
171
  type: "REQUEST_UPLOAD_CREDENTIALS",
161
172
  id: String(messageIdCounter),
162
- payload: {
163
- ...payload,
164
- applicationId: options.applicationId,
165
- },
173
+ payload: { ...payload, applicationId: options.applicationId },
166
174
  };
167
175
  dialogWindow.postMessage(message, WELSHARE_WALLET_URL);
168
176
  setMessageIdCounter((prev) => prev + 1);
@@ -207,7 +215,7 @@ export const useWelshare = (props) => {
207
215
  .filter(([_, value]) => value !== undefined && value !== null)
208
216
  .map(([key, value]) => `social.${key}=${encodeURIComponent(String(value))}`);
209
217
  if (socialEntries.length > 0) {
210
- socialParams = `&${socialEntries.join('&')}`;
218
+ socialParams = `&${socialEntries.join("&")}`;
211
219
  }
212
220
  }
213
221
  const walletUrl = `${WELSHARE_WALLET_URL}?applicationId=${options.applicationId}${socialParams}`;
@@ -1,7 +1,9 @@
1
1
  export { ConnectWelshareButton } from "./components/connect-button.js";
2
2
  export { WelshareLogo } from "./components/welshare-logo.js";
3
3
  export { useWelshare } from "./hooks/use-welshare.js";
4
- export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey } from "./lib/encryption.js";
4
+ export { useBinaryUploads, type UseBinaryUploadsOptions, type UseBinaryUploadsResult, } from "./hooks/use-binary-uploads.js";
5
+ export { WELSHARE_API_ENVIRONMENT, resolveEnvironment, getBaseUrl, type WelshareApiEnvironment, type WelshareEnvironmentName, type NillionClusterConfig, } from "@welshare/sdk/environment";
6
+ export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey, } from "./lib/encryption.js";
5
7
  export { decodeEncryptionKey, type EncryptionKey } from "./utils.js";
6
8
  export { browserDownload, encryptAndUploadFile } from "./lib/uploads.js";
7
9
  export declare const Schemas: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,eAAO,MAAM,OAAO;;;;CAInB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,UAAU,EACV,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,GAC1B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,WAAW,EACX,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGzE,eAAO,MAAM,OAAO;;;;CAInB,CAAC"}
@@ -1,13 +1,16 @@
1
- //todo: this is not tree shaken and leaks nillion dependencies transitively. Consider pulling it up
2
- //import { QuestionnaireResponseSchema, ReflexSubmissionSchema } from "@welshare/sdk";
1
+ // ---- Components ----
3
2
  export { ConnectWelshareButton } from "./components/connect-button.js";
4
3
  export { WelshareLogo } from "./components/welshare-logo.js";
5
- // ---- hooks ----
4
+ // ---- Hooks ----
6
5
  export { useWelshare } from "./hooks/use-welshare.js";
7
- export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey } from "./lib/encryption.js";
6
+ export { useBinaryUploads, } from "./hooks/use-binary-uploads.js";
7
+ // ---- Environment (re-exported from @welshare/sdk) ----
8
+ export { WELSHARE_API_ENVIRONMENT, resolveEnvironment, getBaseUrl, } from "@welshare/sdk/environment";
9
+ // ---- Utils ----
10
+ export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey, } from "./lib/encryption.js";
8
11
  export { decodeEncryptionKey } from "./utils.js";
9
12
  export { browserDownload, encryptAndUploadFile } from "./lib/uploads.js";
10
- //todo: import them from the SDK or a dedicated SDK constants export
13
+ //todo: import them from the SDK
11
14
  export const Schemas = {
12
15
  QuestionnaireResponse: "b14b538f-7de3-4767-ad77-464d755d78bd", //QuestionnaireResponseSchema.schemaUid,
13
16
  ReflexSubmission: "f5cf2d8a-1f78-4f21-b4bd-082e983b830c", //ReflexSubmissionSchema.schemaUid,
@@ -1 +1 @@
1
- {"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../src/lib/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAuB,MAAM,aAAa,CAAC;AAE5E,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,SAAS,CAU9D,CAAC;AAIF,eAAO,MAAM,WAAW,SAChB,IAAI,OACL,SAAS,KACb,OAAO,CAAC;IAAE,aAAa,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,CAgBxD,CAAC;AAEF,eAAO,MAAM,mBAAmB,QACzB,SAAS,MACV,UAAU,KACb,OAAO,CAAC,aAAa,CAgBvB,CAAC;AAGF,eAAO,MAAM,OAAO,kBACH,WAAW,iBACX,aAAa,KAC3B,OAAO,CAAC,WAAW,GAAG,IAAI,CA0B5B,CAAC"}
1
+ {"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../src/lib/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAuB,MAAM,aAAa,CAAC;AAE5E,eAAO,MAAM,oBAAoB,QAAa,OAAO,CAAC,SAAS,CAU9D,CAAC;AAIF,eAAO,MAAM,WAAW,SAChB,IAAI,OACL,SAAS,KACb,OAAO,CAAC;IAAE,aAAa,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,CAaxD,CAAC;AAEF,eAAO,MAAM,mBAAmB,QACzB,SAAS,MACV,UAAU,KACb,OAAO,CAAC,aAAa,CAYvB,CAAC;AAGF,eAAO,MAAM,OAAO,kBACH,WAAW,iBACX,aAAa,KAC3B,OAAO,CAAC,WAAW,GAAG,IAAI,CAuB5B,CAAC"}
@@ -15,10 +15,7 @@ export const encryptFile = async (file, key) => {
15
15
  const fileData = await file.arrayBuffer();
16
16
  const iv = window.crypto.getRandomValues(new Uint8Array(12));
17
17
  // Encrypt the file data
18
- const encryptedData = await window.crypto.subtle.encrypt({
19
- name: ALGORITHM,
20
- iv: iv,
21
- }, key, fileData);
18
+ const encryptedData = await window.crypto.subtle.encrypt({ name: ALGORITHM, iv: iv }, key, fileData);
22
19
  return { encryptedData, iv };
23
20
  };
24
21
  export const encodeEncryptionKey = async (key, iv) => {
@@ -30,21 +27,14 @@ export const encodeEncryptionKey = async (key, iv) => {
30
27
  const ivHex = Array.from(iv)
31
28
  .map((b) => b.toString(16).padStart(2, "0"))
32
29
  .join("");
33
- return {
34
- algorithm: ALGORITHM,
35
- key: keyHex,
36
- iv: ivHex,
37
- };
30
+ return { algorithm: ALGORITHM, key: keyHex, iv: ivHex };
38
31
  };
39
32
  // Helper function to decrypt a file using encoded encryption key
40
33
  export const decrypt = async (encryptedData, encryptionKey) => {
41
34
  try {
42
35
  const { key: keyBytes, iv } = decodeEncryptionKey(encryptionKey);
43
36
  const key = await window.crypto.subtle.importKey("raw", keyBytes, { name: ALGORITHM }, false, ["decrypt"]);
44
- const decryptedData = await window.crypto.subtle.decrypt({
45
- name: ALGORITHM,
46
- iv: iv,
47
- }, key, encryptedData);
37
+ const decryptedData = await window.crypto.subtle.decrypt({ name: ALGORITHM, iv: iv }, key, encryptedData);
48
38
  return decryptedData;
49
39
  }
50
40
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../../src/lib/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAO3C,eAAO,MAAM,oBAAoB,SACzB,IAAI,gBACI,MAAM,KACnB,OAAO,CAAC,aAAa,CAkBvB,CAAC;AAEF,eAAO,MAAM,eAAe,kBAAmB,IAAI,SASlD,CAAA"}
1
+ {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../../src/lib/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAO3C,eAAO,MAAM,oBAAoB,SACzB,IAAI,gBACI,MAAM,KACnB,OAAO,CAAC,aAAa,CAgBvB,CAAC;AAEF,eAAO,MAAM,eAAe,kBAAmB,IAAI,SASlD,CAAC"}
@@ -6,9 +6,7 @@ export const encryptAndUploadFile = async (file, presignedUrl) => {
6
6
  const uploadResponse = await fetch(presignedUrl, {
7
7
  method: "PUT",
8
8
  body: encryptedData,
9
- headers: {
10
- "Content-Type": file.type,
11
- },
9
+ headers: { "Content-Type": file.type },
12
10
  });
13
11
  if (!uploadResponse.ok) {
14
12
  throw new Error(`Failed to upload file ${uploadResponse.status}`);
@@ -1,4 +1,5 @@
1
1
  import { EncryptionKey } from "./utils.js";
2
+ import type { WelshareApiEnvironment, WelshareEnvironmentName } from "@welshare/sdk/environment";
2
3
  export interface DialogMessage {
3
4
  type: string;
4
5
  payload?: any;
@@ -52,6 +53,16 @@ export interface WelshareConnectionOptions {
52
53
  privy?: string;
53
54
  twitter?: string;
54
55
  };
56
+ /**
57
+ * The Welshare environment to connect to.
58
+ * Can be an environment name ('production', 'staging', etc.) or a full environment object.
59
+ * Takes precedence over apiBaseUrl if both are provided.
60
+ */
61
+ environment?: WelshareApiEnvironment | WelshareEnvironmentName;
62
+ /**
63
+ * @deprecated Use `environment` instead for type-safe configuration.
64
+ * The base URL of the Welshare API. Defaults to production.
65
+ */
55
66
  apiBaseUrl?: string;
56
67
  callbacks: {
57
68
  onFileUploaded?: (insertedUid: string, url: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEvC,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,UAAU,EAAE,CAAC,CAAC;CACf;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,MAAM,WAAW,+BAA+B;IAC9C,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,2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ACrB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,mBAAmB,kBACf,aAAa,KAC3B;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,YAAY,CAAA;CAUvC,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,YAAY,CAAC;AACnC,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC;AAElC,MAAM,MAAM,aAAa,GAAG;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,eAAO,MAAM,mBAAmB,kBACf,aAAa,KAC3B;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,YAAY,CAAA;CAUvC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { config } from "@workspace/eslint-config/react-internal"
1
+ import { config } from "@workspace/eslint-config/react-internal";
2
2
 
3
3
  /** @type {import("eslint").Linter.Config} */
4
- export default config
4
+ export default config;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@welshare/react",
3
- "version": "0.2.3",
3
+ "version": "0.4.0",
4
4
  "description": "React library for integrating with Welshare's sovereign data sharing platform",
5
5
  "keywords": [
6
6
  "react",
@@ -31,6 +31,9 @@
31
31
  "test:coverage": "vitest run --coverage",
32
32
  "prepublishOnly": "npm run build:clean && npm run build"
33
33
  },
34
+ "dependencies": {
35
+ "@welshare/sdk": "workspace:*"
36
+ },
34
37
  "peerDependencies": {
35
38
  "react": "^19",
36
39
  "react-dom": "^19"
@@ -90,6 +93,6 @@
90
93
  "LICENSE"
91
94
  ],
92
95
  "engines": {
93
- "node": ">=20.0.0"
96
+ "node": "^22.0.0"
94
97
  }
95
98
  }
@@ -89,10 +89,7 @@ export const ConnectWelshareButton = (props: {
89
89
  <WelshareLogo
90
90
  width={24}
91
91
  height={18}
92
- style={{
93
- "marginRight": "4px",
94
- color: "#ffffff",
95
- }}
92
+ style={{ marginRight: "4px", color: "#ffffff" }}
96
93
  />
97
94
  </span>
98
95
  <span>Connect Welshare Profile</span>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
 
3
3
  export interface WelshareLogoProps {
4
4
  className?: string;