Fix type error (#2374)

* Fix type error

* wip

* Remove tests

* Remove unused import in db.test.ts

* check types in ci/cd

---------

Co-authored-by: Deepak Prabhakara <deepak@boxyhq.com>
This commit is contained in:
Kiran K 2024-03-05 18:14:50 +05:30 committed by GitHub
parent 4b0133eee1
commit f923451fbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 50 deletions

View File

@ -146,6 +146,7 @@ jobs:
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- run: npm install
- run: npm run check-lint
- run: npm run check-types
- run: npm run check-format
- run: npm run check-locale
- run: npm run build

View File

@ -5,7 +5,7 @@ import { deflateRaw } from 'zlib';
import type { SAMLProfile } from '@boxyhq/saml20/dist/typings';
import { generators } from 'openid-client';
import type { JacksonOption, Storable, SAMLSSORecord, OIDCSSORecord, AttributeMapping } from '../typings';
import type { JacksonOption, Storable, SAMLSSORecord, OIDCSSORecord, SAMLFederationApp } from '../typings';
import { getDefaultCertificate } from '../saml/x509';
import * as dbutils from '../db/utils';
import { JacksonError } from './error';
@ -162,7 +162,7 @@ export class SSOHandler {
}: {
connection: SAMLSSORecord;
requestParams: Record<string, any>;
mappings: AttributeMapping[] | null;
mappings: SAMLFederationApp['mappings'];
}) {
// We have a connection now, so we can create the SAML request
const certificate = await getDefaultCertificate();
@ -235,7 +235,7 @@ export class SSOHandler {
}: {
connection: OIDCSSORecord;
requestParams: Record<string, any>;
mappings: AttributeMapping[] | null;
mappings: SAMLFederationApp['mappings'];
}) {
if (!this.opts.oidcPath) {
throw new JacksonError('OpenID response handler path (oidcPath) is not set', 400);
@ -342,7 +342,7 @@ export class SSOHandler {
requested: any;
oidcCodeVerifier?: string;
oidcNonce?: string;
mappings: AttributeMapping[] | null;
mappings: SAMLFederationApp['mappings'];
}) => {
const sessionId = crypto.randomBytes(16).toString('hex');

View File

@ -18,7 +18,7 @@ export type SAMLFederationApp = {
faviconUrl: string | null;
primaryColor: string | null;
tenants?: string[]; // To support multiple tenants for a single app
mappings: AttributeMapping[] | null;
mappings?: AttributeMapping[] | null;
};
export type SAMLFederationAppWithMetadata = SAMLFederationApp & {

View File

@ -1,4 +1,4 @@
import { DatabaseEngine, DatabaseOption, EncryptionKey, Storable, DatabaseDriver } from '../../src/typings';
import { DatabaseOption, EncryptionKey, Storable, DatabaseDriver } from '../../src/typings';
import tap from 'tap';
import DB from '../../src/db/db';
import { randomBytes } from 'crypto';
@ -505,48 +505,4 @@ tap.test('dbs', async () => {
await value.close();
}
});
tap.test('db.new() error', async (t) => {
try {
await DB.new(
<DatabaseOption>{
engine: <DatabaseEngine>'mongo',
},
true
);
await DB.new(
<DatabaseOption>{
engine: <DatabaseEngine>'sql',
url: tap.expectUncaughtException().toString(),
},
true
);
t.ok(
<DatabaseOption>{
engine: <DatabaseEngine>'sql',
url: tap.expectUncaughtException().toString(),
},
'db must have connection'
);
await DB.new(
{
engine: <DatabaseEngine>'',
},
true
);
await DB.new(
<DatabaseOption>{
engine: <DatabaseEngine>'somedb',
},
true
);
t.fail('expecting an unsupported db error');
} catch (err) {
t.ok(err, 'got expected error');
}
});
});

View File

@ -76,6 +76,7 @@ tap.test('Federated SAML flow', async (t) => {
const response = await samlFederatedController.sso.getAuthorizeUrl({
request: samlRequestFromSP,
relayState: relayStateFromSP,
samlBinding: 'HTTP-Redirect',
});
// Extract relay state created by Jackson