@welshare/react 0.2.3 → 0.3.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.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2025 Welshare Health UG (haftungsbeschränkt) 2025
1
+ Copyright © 2025-2026 Welshare Health UG (haftungsbeschränkt)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
@@ -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;AAKpB,eAAO,MAAM,WAAW,UAAW,yBAAyB;;;;;uBAwLlD,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,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
@@ -1,6 +1,7 @@
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 { WELSHARE_API_ENVIRONMENT, resolveEnvironment, getBaseUrl, type WelshareApiEnvironment, type WelshareEnvironmentName, type NillionClusterConfig, } from "@welshare/sdk/environment";
4
5
  export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey } from "./lib/encryption.js";
5
6
  export { decodeEncryptionKey, type EncryptionKey } from "./utils.js";
6
7
  export { browserDownload, encryptAndUploadFile } from "./lib/uploads.js";
@@ -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;AAGtD,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,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;AAGzE,eAAO,MAAM,OAAO;;;;CAInB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,13 +1,15 @@
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";
6
+ // ---- Environment (re-exported from @welshare/sdk) ----
7
+ export { WELSHARE_API_ENVIRONMENT, resolveEnvironment, getBaseUrl, } from "@welshare/sdk/environment";
8
+ // ---- Utils ----
7
9
  export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey } from "./lib/encryption.js";
8
10
  export { decodeEncryptionKey } from "./utils.js";
9
11
  export { browserDownload, encryptAndUploadFile } from "./lib/uploads.js";
10
- //todo: import them from the SDK or a dedicated SDK constants export
12
+ //todo: import them from the SDK
11
13
  export const Schemas = {
12
14
  QuestionnaireResponse: "b14b538f-7de3-4767-ad77-464d755d78bd", //QuestionnaireResponseSchema.schemaUid,
13
15
  ReflexSubmission: "f5cf2d8a-1f78-4f21-b4bd-082e983b830c", //ReflexSubmissionSchema.schemaUid,
@@ -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,CAA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AE,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAC5D,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;QAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QAClC,cAAc,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;QACjD,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;QAC7B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;KAC5B,CAAC;CACH"}
@@ -0,0 +1,5 @@
1
+
2
+ 
3
+ > @welshare/react@0.3.0 build /Users/stadolf/work/welshare/workspace/surveys-monorepo/packages/welshare-react
4
+ > tshy
5
+
@@ -1,4 +1,4 @@
1
- Copyright © 2025 Welshare Health UG (haftungsbeschränkt) 2025
1
+ Copyright © 2025-2026 Welshare Health UG (haftungsbeschränkt)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
@@ -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;AAKpB,eAAO,MAAM,WAAW,UAAW,yBAAyB;;;;;uBAwLlD,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,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
@@ -1,6 +1,7 @@
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 { WELSHARE_API_ENVIRONMENT, resolveEnvironment, getBaseUrl, type WelshareApiEnvironment, type WelshareEnvironmentName, type NillionClusterConfig, } from "@welshare/sdk/environment";
4
5
  export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey } from "./lib/encryption.js";
5
6
  export { decodeEncryptionKey, type EncryptionKey } from "./utils.js";
6
7
  export { browserDownload, encryptAndUploadFile } from "./lib/uploads.js";
@@ -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;AAGtD,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,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;AAGzE,eAAO,MAAM,OAAO;;;;CAInB,CAAC"}
@@ -1,13 +1,15 @@
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";
6
+ // ---- Environment (re-exported from @welshare/sdk) ----
7
+ export { WELSHARE_API_ENVIRONMENT, resolveEnvironment, getBaseUrl, } from "@welshare/sdk/environment";
8
+ // ---- Utils ----
7
9
  export { decrypt, encodeEncryptionKey, encryptFile, generateRandomAESKey } from "./lib/encryption.js";
8
10
  export { decodeEncryptionKey } from "./utils.js";
9
11
  export { browserDownload, encryptAndUploadFile } from "./lib/uploads.js";
10
- //todo: import them from the SDK or a dedicated SDK constants export
12
+ //todo: import them from the SDK
11
13
  export const Schemas = {
12
14
  QuestionnaireResponse: "b14b538f-7de3-4767-ad77-464d755d78bd", //QuestionnaireResponseSchema.schemaUid,
13
15
  ReflexSubmission: "f5cf2d8a-1f78-4f21-b4bd-082e983b830c", //ReflexSubmissionSchema.schemaUid,
@@ -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,2BAA4B,SAAQ,+BAA+B;IAClF,aAAa,EAAE,aAAa,CAAC;IAE7B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAkB,SAAQ,+BAA+B;IACxE,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MA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CAAC;CACrC;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAA;IACD;;;;OAIG;IACH,WAAW,CAAC,EAAE,sBAAsB,GAAG,uBAAuB,CAAC;IAC/D;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE;QACT,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAC5D,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;QAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;QAClC,cAAc,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;QACjD,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;QAC7B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;KAC5B,CAAC;CACH"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@welshare/react",
3
- "version": "0.2.3",
3
+ "version": "0.3.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
  }
@@ -8,6 +8,7 @@ import {
8
8
  UploadCredentials,
9
9
  WelshareConnectionOptions,
10
10
  } from "@/types.js";
11
+ import { getBaseUrl, WELSHARE_API_ENVIRONMENT } from "@welshare/sdk/environment";
11
12
  import { useEffect, useRef, useState } from "react";
12
13
  import { encryptAndUploadFile } from "../lib/uploads.js";
13
14
 
@@ -24,12 +25,17 @@ export const useWelshare = (props: WelshareConnectionOptions) => {
24
25
  // (claude opus) Use ref to control current upload in effect without triggering re-renders
25
26
  const currentUploadRef = useRef<RunningFileUpload>(null);
26
27
 
28
+ // Resolve the base URL from environment or apiBaseUrl
29
+ const resolvedBaseUrl = props.environment
30
+ ? getBaseUrl(props.environment)
31
+ : props.apiBaseUrl ?? getBaseUrl(WELSHARE_API_ENVIRONMENT.production);
32
+
27
33
  const options: WelshareConnectionOptions = {
28
- apiBaseUrl: "https://wallet.welshare.app",
29
34
  ...props,
35
+ apiBaseUrl: resolvedBaseUrl,
30
36
  };
31
37
 
32
- const WELSHARE_WALLET_URL = `${options.apiBaseUrl}/wallet-external`;
38
+ const WELSHARE_WALLET_URL = `${resolvedBaseUrl}/wallet-external`;
33
39
 
34
40
  useEffect(() => {
35
41
  const handleMessage = async (event: MessageEvent<DialogMessage>) => {
@@ -1,10 +1,21 @@
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
+
5
+ // ---- Hooks ----
6
6
  export { useWelshare } from "./hooks/use-welshare.js";
7
7
 
8
+ // ---- Environment (re-exported from @welshare/sdk) ----
9
+ export {
10
+ WELSHARE_API_ENVIRONMENT,
11
+ resolveEnvironment,
12
+ getBaseUrl,
13
+ type WelshareApiEnvironment,
14
+ type WelshareEnvironmentName,
15
+ type NillionClusterConfig,
16
+ } from "@welshare/sdk/environment";
17
+
18
+ // ---- Utils ----
8
19
  export {
9
20
  decrypt,
10
21
  encodeEncryptionKey,
@@ -14,7 +25,8 @@ export {
14
25
  export { decodeEncryptionKey, type EncryptionKey } from "./utils.js";
15
26
 
16
27
  export { browserDownload, encryptAndUploadFile } from "./lib/uploads.js";
17
- //todo: import them from the SDK or a dedicated SDK constants export
28
+
29
+ //todo: import them from the SDK
18
30
  export const Schemas = {
19
31
  QuestionnaireResponse: "b14b538f-7de3-4767-ad77-464d755d78bd", //QuestionnaireResponseSchema.schemaUid,
20
32
  ReflexSubmission: "f5cf2d8a-1f78-4f21-b4bd-082e983b830c", //ReflexSubmissionSchema.schemaUid,
@@ -1,4 +1,5 @@
1
1
  import { EncryptionKey } from "./utils.js";
2
+ import type { WelshareApiEnvironment, WelshareEnvironmentName } from "@welshare/sdk/environment";
2
3
 
3
4
  export interface DialogMessage {
4
5
  type: string;
@@ -62,7 +63,16 @@ export interface WelshareConnectionOptions {
62
63
  privy?: string;
63
64
  twitter?: string;
64
65
  }
65
- //todo: must go into build config, not supposed to be used by users
66
+ /**
67
+ * The Welshare environment to connect to.
68
+ * Can be an environment name ('production', 'staging', etc.) or a full environment object.
69
+ * Takes precedence over apiBaseUrl if both are provided.
70
+ */
71
+ environment?: WelshareApiEnvironment | WelshareEnvironmentName;
72
+ /**
73
+ * @deprecated Use `environment` instead for type-safe configuration.
74
+ * The base URL of the Welshare API. Defaults to production.
75
+ */
66
76
  apiBaseUrl?: string;
67
77
  callbacks: {
68
78
  onFileUploaded?: (insertedUid: string, url: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@welshare/react",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "React library for integrating with Welshare's sovereign data sharing platform",
5
5
  "keywords": [
6
6
  "react",
@@ -22,6 +22,9 @@
22
22
  },
23
23
  "homepage": "https://welshare.health",
24
24
  "type": "module",
25
+ "dependencies": {
26
+ "@welshare/sdk": "0.1.4"
27
+ },
25
28
  "peerDependencies": {
26
29
  "react": "^19",
27
30
  "react-dom": "^19"
@@ -81,7 +84,7 @@
81
84
  "LICENSE"
82
85
  ],
83
86
  "engines": {
84
- "node": ">=20.0.0"
87
+ "node": "^22.0.0"
85
88
  },
86
89
  "scripts": {
87
90
  "lint": "eslint . --max-warnings 25",