@truenorth-it/dataverse-client 1.3.2 → 1.3.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.
Files changed (2) hide show
  1. package/README.md +17 -8
  2. package/package.json +6 -3
package/README.md CHANGED
@@ -22,7 +22,7 @@ import { createClient } from "@truenorth-it/dataverse-client";
22
22
  const client = createClient({
23
23
  baseUrl: "https://api.dataverse-contact.tnapps.co.uk",
24
24
  scope: "default", // scope segment in API URLs (e.g. /api/v2/default/me/case)
25
- getToken: () => getAccessTokenSilently(), // your Auth0 token provider
25
+ getToken: () => getAccessTokenSilently(), // any function returning a Bearer token (e.g. MSAL for Entra External ID)
26
26
  });
27
27
 
28
28
  const result = await client.me.list("case", {
@@ -172,28 +172,37 @@ const tsSource = generateTableTypes(schema);
172
172
  // Write tsSource to a file, pipe it, etc.
173
173
  ```
174
174
 
175
- ## Usage with React + Auth0
175
+ ## Usage with React + MSAL (Entra External ID)
176
176
 
177
177
  ```tsx
178
178
  import { useMemo } from "react";
179
- import { useAuth0 } from "@auth0/auth0-react";
179
+ import { useMsal } from "@azure/msal-react";
180
180
  import { createClient } from "@truenorth-it/dataverse-client";
181
181
 
182
182
  function useApiClient() {
183
- const { getAccessTokenSilently } = useAuth0();
183
+ const { instance, accounts } = useMsal();
184
184
 
185
185
  return useMemo(
186
186
  () =>
187
187
  createClient({
188
188
  baseUrl: import.meta.env.VITE_API_BASE_URL,
189
189
  scope: "default",
190
- getToken: () => getAccessTokenSilently(),
190
+ getToken: async () => {
191
+ const { accessToken } = await instance.acquireTokenSilent({
192
+ // Application ID URI of your API's Entra app registration
193
+ scopes: [`${import.meta.env.VITE_API_SCOPE}/access_as_user`],
194
+ account: accounts[0],
195
+ });
196
+ return accessToken;
197
+ },
191
198
  }),
192
- [getAccessTokenSilently],
199
+ [instance, accounts],
193
200
  );
194
201
  }
195
202
  ```
196
203
 
204
+ The SDK is identity-provider-agnostic — `getToken` just needs to return a Bearer string. Swap MSAL for any other OIDC client if your deployment uses a different provider.
205
+
197
206
  ## Client configuration
198
207
 
199
208
  ```typescript
@@ -594,7 +603,7 @@ The API must have `SIGNALR_CONNECTION_STRING` configured. When it's not set, `ne
594
603
 
595
604
  ### Negotiate
596
605
 
597
- The client exposes a `negotiate()` method that exchanges your Auth0 token for a SignalR connection token:
606
+ The client exposes a `negotiate()` method that exchanges your Bearer token for a SignalR connection token:
598
607
 
599
608
  ```typescript
600
609
  const { url, accessToken } = await client.negotiate();
@@ -761,7 +770,7 @@ import type { Case, Contact, TableName } from "./dataverse-tables.generated";
761
770
  ## Requirements
762
771
 
763
772
  - Node.js 18+
764
- - An Auth0 token provider (or any async function that returns a Bearer token) — optional if using only `client.public`
773
+ - An async function that returns a Bearer token — typically MSAL for Entra External ID, but any OIDC client works (optional if using only `client.public`)
765
774
  - Access to a deployed Dataverse Contact API instance
766
775
 
767
776
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truenorth-it/dataverse-client",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "main": "./sdk/dist/index.js",
6
6
  "types": "./sdk/dist/index.d.ts",
@@ -38,13 +38,16 @@
38
38
  "test:stats": "vitest run --coverage && node scripts/generate-test-stats.cjs",
39
39
  "build:landing": "vite build --config landing/vite.config.ts && cp -rL docs dist/docs",
40
40
  "build": "npm run build:landing && npm run build:sdk && npm run build:admin-cli",
41
- "start": "node --import tsx docker/server.ts",
41
+ "start": "node --env-file-if-exists=.env --import tsx docker/server.ts",
42
42
  "docker:build": "docker build -t dataverse-contact-api .",
43
43
  "docker:run": "docker run -p 8080:8080 --env-file .env dataverse-contact-api",
44
- "docker:build:azure": "docker build -f Dockerfile.azure-functions -t dataverse-contact-api-azure ."
44
+ "docker:build:azure": "docker build -f Dockerfile.azure-functions -t dataverse-contact-api-azure .",
45
+ "env:check": "op whoami && op vault get \"LA stack\" > /dev/null && echo \"OK: LA stack vault accessible\"",
46
+ "env:pull": "op inject -f -i .env.tpl -o .env && op inject -f -i .env.e2e.tpl -o .env.e2e && echo \"Rendered .env and .env.e2e from 1Password\""
45
47
  },
46
48
  "dependencies": {
47
49
  "@azure/identity": "^4.2.0",
50
+ "@azure/msal-browser": "^5.11.0",
48
51
  "@azure/storage-blob": "^12.31.0",
49
52
  "@modelcontextprotocol/sdk": "^1.26.0",
50
53
  "applicationinsights": "^2.9.8",