Identity & run queries callback >= 0.0.40
In the release @vizzly/dashboard@0.0.40
, the return value of the identity callback has changed from
a full identity config, to an object containing two JSON web tokens (JWTs).
The new type definition of the callback is as follows, where both dashboardAccessToken
and dataAccessToken
are JWTs that are signed on your server with your Vizzly generated private key.
type CallbackError = null;
export type identityCallback = () => Promise<
| {
dashboardAccessToken: string;
dataAccessToken?: string;
}
| CallbackError
>;
The dataAccessToken
is optional when you're running Vizzly with a custom query engine implementation, but the dashboardAccessToken
is always required.
Example Dashboard React component with an identity callback
<Vizzly.Dashboard
type="self-hosted"
vizzlyDockerImageEndpoint="/query-engine"
identityCallback={async () => {
const response = await fetch("/api/identity");
if (response.ok) {
const tokens = await response.json();
return tokens;
}
return null;
}}
/>
Changes to runQueriesCallback
The runQueriesCallback
callback has also changed slightly. The only difference is as follows;
export type runQueriesCallback = (
queries: VizzlyComponents.Query[],
params: {
dataSets: VizzlyComponents.DataSet[];
virtualFields: {
[dataSetId: string]: VizzlyComponents.Studio.Dashboard.VirtualField[];
};
abortSignal?: AbortSignal;
- identityConfigIntegritySignature?: string;
+ dataAccessToken?: string;
}
) => Promise<VizzlyComponents.Result[] | CallbackError>;
@vizzly/auth changes
To make this transition easier, we've also updated the @vizzly/auth
package to generate the tokens and return an object in the same format as the identity callback requires.
@vizzly/auth usage diff to upgrade from versions lower than 0.0.4 of the auth package.
If you are currently using a version of the Vizzly auth package <= 0.0.4, the following diff will help you upgrade;
const vizzAuth = createSigner({
privateKey: PRIVATE_KEY,
ttlInMinutes: 60,
});
let identityConfig = {
userReference: "usr_12345",
- userType: 'editor' | 'standard',
+ accessType: 'editor' | 'standard',
- dataSets: "*",
+ dataSetIds: "*",
secureFilters: {},
organisationId: "org_7e58f56ceff84f80bc529b57f802d638",
dashboardId: "dsh_3259c56329884d4c8de2c354063fa401",
};
- const {integritySignature, expires} = await vizzAuth.signIdentityConfig(partialIdentityConfig);
- const identityConfig = {...partialIdentityConfig, integritySignature, expires};
+ const tokens = await vizzAuth.generateTokens(identityConfig);
res
.status(200)
.setHeader('Access-Control-Allow-Origin', '*')
- .json({ identityConfig });
+ .json(tokens);