@connectid-tools/idp-selector-react 6.4.1
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/Benefits.css +48 -0
- package/Benefits.d.ts +4 -0
- package/Benefits.js +20 -0
- package/CidButton.css +57 -0
- package/CidButton.d.ts +26 -0
- package/CidButton.js +133 -0
- package/CidButtonHowItWorks.css +25 -0
- package/CidButtonHowItWorks.d.ts +2 -0
- package/CidButtonHowItWorks.js +20 -0
- package/CidButtonInfo.css +33 -0
- package/CidButtonInfo.d.ts +2 -0
- package/CidButtonInfo.js +8 -0
- package/FullProcess.css +150 -0
- package/FullProcess.d.ts +4 -0
- package/FullProcess.js +35 -0
- package/IdpLogoList.css +53 -0
- package/IdpLogoList.d.ts +8 -0
- package/IdpLogoList.js +13 -0
- package/InfoBox.css +49 -0
- package/InfoBox.d.ts +9 -0
- package/InfoBox.js +12 -0
- package/IntroText.css +24 -0
- package/IntroText.d.ts +5 -0
- package/IntroText.js +14 -0
- package/LearnMore.css +27 -0
- package/LearnMore.d.ts +2 -0
- package/LearnMore.js +20 -0
- package/NoIdpError.d.ts +6 -0
- package/NoIdpError.js +12 -0
- package/Overlay.css +9 -0
- package/Overlay.d.ts +6 -0
- package/Overlay.js +6 -0
- package/ParticipantsLoader.css +50 -0
- package/ParticipantsLoader.d.ts +2 -0
- package/ParticipantsLoader.js +12 -0
- package/Popup.css +457 -0
- package/Popup.d.ts +22 -0
- package/Popup.js +137 -0
- package/Process.css +51 -0
- package/Process.d.ts +2 -0
- package/Process.js +12 -0
- package/README.md +633 -0
- package/Skeleton.css +27 -0
- package/Skeleton.d.ts +10 -0
- package/Skeleton.js +5 -0
- package/TabHook.d.ts +2 -0
- package/TabHook.js +37 -0
- package/ThemeContext.d.ts +2 -0
- package/ThemeContext.js +2 -0
- package/analytics.d.ts +1 -0
- package/analytics.js +88 -0
- package/certification.d.ts +8 -0
- package/certification.js +103 -0
- package/certification.test.d.ts +1 -0
- package/certification.test.js +387 -0
- package/global.css +11 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/license +201 -0
- package/navigator.d.ts +1 -0
- package/navigator.js +1 -0
- package/package.json +46 -0
- package/types.d.ts +41 -0
- package/types.js +1 -0
- package/userAgent.d.ts +2 -0
- package/userAgent.js +10 -0
- package/validator.d.ts +3 -0
- package/validator.js +12 -0
- package/validator.test.d.ts +1 -0
- package/validator.test.js +36 -0
package/TabHook.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
export function useOverrideTab(element, nextElement) {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (!(element === null || element === void 0 ? void 0 : element.current) || !(nextElement === null || nextElement === void 0 ? void 0 : nextElement.current))
|
|
5
|
+
return;
|
|
6
|
+
const handleKeyDown = (event) => {
|
|
7
|
+
if (event.code === 'Tab' && element.current === document.activeElement) {
|
|
8
|
+
nextElement.current.focus();
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
element.current.addEventListener('keydown', handleKeyDown);
|
|
13
|
+
return () => {
|
|
14
|
+
if (!(element === null || element === void 0 ? void 0 : element.current))
|
|
15
|
+
return;
|
|
16
|
+
element.current.removeEventListener('keydown', handleKeyDown);
|
|
17
|
+
};
|
|
18
|
+
}, [element, nextElement]);
|
|
19
|
+
}
|
|
20
|
+
export function useOverrideShiftTab(element, nextElement) {
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!(element === null || element === void 0 ? void 0 : element.current) || !(nextElement === null || nextElement === void 0 ? void 0 : nextElement.current))
|
|
23
|
+
return;
|
|
24
|
+
const handleKeyDown = (event) => {
|
|
25
|
+
if (event.shiftKey && event.code === 'Tab' && element.current === document.activeElement) {
|
|
26
|
+
nextElement.current.focus();
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
element.current.addEventListener('keydown', handleKeyDown);
|
|
31
|
+
return () => {
|
|
32
|
+
if (!(element === null || element === void 0 ? void 0 : element.current))
|
|
33
|
+
return;
|
|
34
|
+
element.current.removeEventListener('keydown', handleKeyDown);
|
|
35
|
+
};
|
|
36
|
+
}, [element, nextElement]);
|
|
37
|
+
}
|
package/ThemeContext.js
ADDED
package/analytics.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAnalytics: () => void;
|
package/analytics.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const PROD_WRITE_KEY = 'LrD9CEGUEy1O3s73nGbaGcyTqELujozJ';
|
|
2
|
+
const DEV_WRITE_KEY = 'PWlESErGso9uTimwmGB7SsnxCpKF8pRl';
|
|
3
|
+
const WRITE_KEY = 'production' === 'production' ? PROD_WRITE_KEY : DEV_WRITE_KEY;
|
|
4
|
+
export const useAnalytics = () => {
|
|
5
|
+
// copied from https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
// Create a queue, but don't obliterate an existing one!
|
|
8
|
+
var analytics = (window.analytics = window.analytics || []);
|
|
9
|
+
// If the real analytics.js is already on the page return.
|
|
10
|
+
if (analytics.initialize)
|
|
11
|
+
return;
|
|
12
|
+
// If the snippet was invoked already show an error.
|
|
13
|
+
if (analytics.invoked) {
|
|
14
|
+
if (window.console && console.error) {
|
|
15
|
+
console.error('Segment snippet included twice.');
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Invoked flag, to make sure the snippet
|
|
20
|
+
// is never invoked twice.
|
|
21
|
+
analytics.invoked = true;
|
|
22
|
+
// A list of the methods in Analytics.js to stub.
|
|
23
|
+
analytics.methods = [
|
|
24
|
+
'trackSubmit',
|
|
25
|
+
'trackClick',
|
|
26
|
+
'trackLink',
|
|
27
|
+
'trackForm',
|
|
28
|
+
'pageview',
|
|
29
|
+
'identify',
|
|
30
|
+
'reset',
|
|
31
|
+
'group',
|
|
32
|
+
'track',
|
|
33
|
+
'ready',
|
|
34
|
+
'alias',
|
|
35
|
+
'debug',
|
|
36
|
+
'page',
|
|
37
|
+
'once',
|
|
38
|
+
'off',
|
|
39
|
+
'on',
|
|
40
|
+
'addSourceMiddleware',
|
|
41
|
+
'addIntegrationMiddleware',
|
|
42
|
+
'setAnonymousId',
|
|
43
|
+
'addDestinationMiddleware',
|
|
44
|
+
];
|
|
45
|
+
// Define a factory to create stubs. These are placeholders
|
|
46
|
+
// for methods in Analytics.js so that you never have to wait
|
|
47
|
+
// for it to load to actually record data. The `method` is
|
|
48
|
+
// stored as the first argument, so we can replay the data.
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
analytics.factory = function (method) {
|
|
51
|
+
return function () {
|
|
52
|
+
var args = Array.prototype.slice.call(arguments);
|
|
53
|
+
args.unshift(method);
|
|
54
|
+
analytics.push(args);
|
|
55
|
+
return analytics;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
// For each of our methods, generate a queueing stub.
|
|
59
|
+
for (var i = 0; i < analytics.methods.length; i++) {
|
|
60
|
+
var key = analytics.methods[i];
|
|
61
|
+
analytics[key] = analytics.factory(key);
|
|
62
|
+
}
|
|
63
|
+
// Define a method to load Analytics.js from our CDN,
|
|
64
|
+
// and that will be sure to only ever load it once.
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
analytics.load = function (key, options) {
|
|
67
|
+
// Create an async script element based on your key.
|
|
68
|
+
var script = document.createElement('script');
|
|
69
|
+
script.type = 'text/javascript';
|
|
70
|
+
script.async = true;
|
|
71
|
+
script.src = 'https://cdn.segment.com/analytics.js/v1/' + key + '/analytics.min.js';
|
|
72
|
+
// Insert our script next to the first script element.
|
|
73
|
+
var first = document.getElementsByTagName('script')[0];
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
first.parentNode.insertBefore(script, first);
|
|
76
|
+
analytics._loadOptions = options;
|
|
77
|
+
};
|
|
78
|
+
analytics._writeKey = WRITE_KEY;
|
|
79
|
+
// Add a version to keep track of what's in the wild.
|
|
80
|
+
analytics.SNIPPET_VERSION = '4.15.2';
|
|
81
|
+
// Load Analytics.js with your key, which will automatically
|
|
82
|
+
// load the tools you've enabled for your account. Boosh!
|
|
83
|
+
analytics.load(WRITE_KEY);
|
|
84
|
+
// Make the first page call to load the integrations. If
|
|
85
|
+
// you'd like to manually name or tag the page, edit or
|
|
86
|
+
// move this call however you'd like.
|
|
87
|
+
analytics.page();
|
|
88
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AuthorisationServer, CertificationStatus, Claim, Device, RequiredCertification } from './types';
|
|
2
|
+
export declare const filterAuthorisationServers: (authorisationServers: AuthorisationServer[], showAllParticipants: boolean, certificationStatus: CertificationStatus, claims: Claim[], requiredCertifications?: RequiredCertification[]) => AuthorisationServer[];
|
|
3
|
+
export declare const getManualAuthorisationServer: (authorisationServers: AuthorisationServer[], showAllParticipants: boolean) => AuthorisationServer | undefined;
|
|
4
|
+
export declare const removeExpiredOrNotStartedCertifications: (authorisationServers: AuthorisationServer[]) => AuthorisationServer[];
|
|
5
|
+
export declare const filterAuthorisationServerByClaims: (authorisationServers: AuthorisationServer[], claims: Claim[]) => AuthorisationServer[];
|
|
6
|
+
export declare const mapAuthorisationServerToDeviceType: (authorisationServers: AuthorisationServer[], deviceType: Device) => Map<AuthorisationServer, Device>;
|
|
7
|
+
export declare const filterAuthorisationServerByCertification: (authorisationServers: AuthorisationServer[], status: CertificationStatus, requiredCertifications?: RequiredCertification[]) => AuthorisationServer[];
|
|
8
|
+
export declare const hasStarted: (startDateStr: string) => boolean;
|
package/certification.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const requiredCertificationsMap = {
|
|
2
|
+
'TDIF.IDP': { type: 'TDIF Accreditation', variant: 'Identity Provider' },
|
|
3
|
+
'Redirect.FAPI2': { type: 'Redirect', variant: 'FAPI2 Adv. OP w/Private Key, PAR' },
|
|
4
|
+
};
|
|
5
|
+
export const filterAuthorisationServers = (authorisationServers, showAllParticipants, certificationStatus, claims, requiredCertifications) => {
|
|
6
|
+
if (showAllParticipants)
|
|
7
|
+
return authorisationServers;
|
|
8
|
+
const authorisationServersWithValidCertifications = removeExpiredOrNotStartedCertifications(authorisationServers);
|
|
9
|
+
const filteredAuthorisationServersByClaims = filterAuthorisationServerByClaims(authorisationServersWithValidCertifications, claims);
|
|
10
|
+
const filteredAuthorisationServers = filterAuthorisationServerByCertification(filteredAuthorisationServersByClaims, certificationStatus, requiredCertifications);
|
|
11
|
+
return filteredAuthorisationServers;
|
|
12
|
+
};
|
|
13
|
+
export const getManualAuthorisationServer = (authorisationServers, showAllParticipants) => {
|
|
14
|
+
const filtered = showAllParticipants
|
|
15
|
+
? authorisationServers
|
|
16
|
+
: removeExpiredOrNotStartedCertifications(authorisationServers);
|
|
17
|
+
return filtered.find(({ AuthorisationServerCertifications }) => AuthorisationServerCertifications === null || AuthorisationServerCertifications === void 0 ? void 0 : AuthorisationServerCertifications.find(({ ProfileVariant }) => ProfileVariant === 'Fallback Identity Service Provider'));
|
|
18
|
+
};
|
|
19
|
+
export const removeExpiredOrNotStartedCertifications = (authorisationServers) => {
|
|
20
|
+
const certifiedAuthorisationServers = [...authorisationServers];
|
|
21
|
+
certifiedAuthorisationServers.forEach((authorisationServer) => {
|
|
22
|
+
authorisationServer.AuthorisationServerCertifications =
|
|
23
|
+
authorisationServer.AuthorisationServerCertifications.filter(({ Status, CertificationStartDate, CertificationExpirationDate }) => Status === 'Certified' && !isExpired(CertificationExpirationDate) && hasStarted(CertificationStartDate));
|
|
24
|
+
});
|
|
25
|
+
return certifiedAuthorisationServers;
|
|
26
|
+
};
|
|
27
|
+
export const filterAuthorisationServerByClaims = (authorisationServers, claims) => {
|
|
28
|
+
const nameClaims = ['given_name', 'middle_name', 'family_name'];
|
|
29
|
+
const hasNameClaims = claims.find((claim) => nameClaims.includes(claim));
|
|
30
|
+
// All name claims (given_name, middle_name, family_name) are mapped to `name` in the authorisation server
|
|
31
|
+
// So if an authorisation server has any name claim, remove all name claims and leave only `name`
|
|
32
|
+
const profileVariants = hasNameClaims
|
|
33
|
+
? ['name', ...claims.filter((claim) => !nameClaims.includes(claim))]
|
|
34
|
+
: claims;
|
|
35
|
+
return authorisationServers.filter((authorisationServer) => {
|
|
36
|
+
const authorisationServerProfileVariants = authorisationServer.AuthorisationServerCertifications.filter(({ ProfileType }) => ProfileType === 'ConnectID Claims').map((cert) => cert.ProfileVariant);
|
|
37
|
+
return profileVariants.every((profileVariant) => authorisationServerProfileVariants.includes(profileVariant));
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export const mapAuthorisationServerToDeviceType = (authorisationServers, deviceType) => {
|
|
41
|
+
const authServerMap = new Map();
|
|
42
|
+
if (deviceType === 'mobile') {
|
|
43
|
+
authorisationServers.forEach((authorisationServer) => {
|
|
44
|
+
authServerMap.set(authorisationServer, 'mobile');
|
|
45
|
+
});
|
|
46
|
+
return authServerMap;
|
|
47
|
+
}
|
|
48
|
+
authorisationServers.map((authorisationServer) => {
|
|
49
|
+
const channelCertifications = authorisationServer.AuthorisationServerCertifications.filter((cert) => cert.ProfileType === 'Channel');
|
|
50
|
+
authServerMap.set(authorisationServer, channelCertifications.length === 1 && channelCertifications[0].ProfileVariant === 'app' ? 'desktop' : 'mobile');
|
|
51
|
+
});
|
|
52
|
+
return authServerMap;
|
|
53
|
+
};
|
|
54
|
+
export const filterAuthorisationServerByCertification = (authorisationServers, status, requiredCertifications) => {
|
|
55
|
+
const filteredByStatus = filterByStatus(authorisationServers, status);
|
|
56
|
+
const filteredByStatusAndRequiredCertifications = filterByRequiredCertifications(filteredByStatus, requiredCertifications);
|
|
57
|
+
return filteredByStatusAndRequiredCertifications;
|
|
58
|
+
};
|
|
59
|
+
const filterByStatus = (authorisationServers, status) => {
|
|
60
|
+
if (status === 'All')
|
|
61
|
+
return authorisationServers;
|
|
62
|
+
if (status === 'Active') {
|
|
63
|
+
return authorisationServers.filter(({ AuthorisationServerCertifications }) => AuthorisationServerCertifications.find(({ ProfileVariant, ProfileType }) => ProfileType === 'Redirect' && ProfileVariant === 'FAPI2 Adv. OP w/Private Key, PAR'));
|
|
64
|
+
}
|
|
65
|
+
throw Error(`Status ${status} not supported`);
|
|
66
|
+
};
|
|
67
|
+
// The idea is to loop the requiredCertications and check if all
|
|
68
|
+
// of them were found in the auth server certifications (AND)
|
|
69
|
+
// if so return the auth server
|
|
70
|
+
const filterByRequiredCertifications = (authorisationServers, requiredCertifications) => {
|
|
71
|
+
if (!requiredCertifications)
|
|
72
|
+
return authorisationServers;
|
|
73
|
+
return authorisationServers.filter(({ AuthorisationServerCertifications }) => {
|
|
74
|
+
let requiredCertificationsFound = 0;
|
|
75
|
+
requiredCertifications.forEach((required) => {
|
|
76
|
+
const found = AuthorisationServerCertifications.find(({ ProfileType, ProfileVariant }) => ProfileType === requiredCertificationsMap[required].type &&
|
|
77
|
+
ProfileVariant === requiredCertificationsMap[required].variant);
|
|
78
|
+
if (found)
|
|
79
|
+
requiredCertificationsFound++;
|
|
80
|
+
});
|
|
81
|
+
return requiredCertificationsFound === requiredCertifications.length;
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const isExpired = (expiryDateStr) => {
|
|
85
|
+
const expiryDate = parseCertificationDate(expiryDateStr);
|
|
86
|
+
expiryDate.setHours(23);
|
|
87
|
+
expiryDate.setMinutes(59);
|
|
88
|
+
expiryDate.setSeconds(59);
|
|
89
|
+
const today = new Date();
|
|
90
|
+
return expiryDate.getTime() < today.getTime();
|
|
91
|
+
};
|
|
92
|
+
export const hasStarted = (startDateStr) => {
|
|
93
|
+
const startDate = parseCertificationDate(startDateStr);
|
|
94
|
+
startDate.setHours(0);
|
|
95
|
+
startDate.setMinutes(0);
|
|
96
|
+
startDate.setSeconds(0);
|
|
97
|
+
const today = new Date();
|
|
98
|
+
return startDate.getTime() <= today.getTime();
|
|
99
|
+
};
|
|
100
|
+
const parseCertificationDate = (dateStr) => {
|
|
101
|
+
const dateArr = dateStr.split('/');
|
|
102
|
+
return new Date(`${dateArr[2]}-${dateArr[1]}-${dateArr[0]}`);
|
|
103
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
import { filterAuthorisationServerByClaims, filterAuthorisationServers, getManualAuthorisationServer, mapAuthorisationServerToDeviceType, removeExpiredOrNotStartedCertifications, } from './certification';
|
|
4
|
+
describe('filterAuthorisationServers', () => {
|
|
5
|
+
it('should return all authorisation servers if showAllParticipants is true regardless of certification status, required certifications and claims', () => {
|
|
6
|
+
const authorisationServers = [
|
|
7
|
+
// no certifications at all
|
|
8
|
+
{
|
|
9
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b21',
|
|
10
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
11
|
+
CustomerFriendlyName: 'Mock Bank B',
|
|
12
|
+
AuthorisationServerCertifications: [],
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
assert.deepStrictEqual(filterAuthorisationServers(authorisationServers, true, 'Active', ['email'], ['TDIF.IDP']), authorisationServers);
|
|
16
|
+
});
|
|
17
|
+
it('should filter authorisation servers if showAllParticipants is false', () => {
|
|
18
|
+
Object.defineProperty(global, 'navigator', { value: { userAgent: 'xxxdesktop' }, configurable: true });
|
|
19
|
+
const authorisationServers = [
|
|
20
|
+
// no certifications at all
|
|
21
|
+
{
|
|
22
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b21',
|
|
23
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
24
|
+
CustomerFriendlyName: 'Mock Bank B',
|
|
25
|
+
AuthorisationServerCertifications: [],
|
|
26
|
+
},
|
|
27
|
+
// expired
|
|
28
|
+
{
|
|
29
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b22',
|
|
30
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
31
|
+
CustomerFriendlyName: 'Mock Bank C',
|
|
32
|
+
AuthorisationServerCertifications: [
|
|
33
|
+
{
|
|
34
|
+
CertificationStartDate: '10/04/1900',
|
|
35
|
+
CertificationExpirationDate: '10/04/2000',
|
|
36
|
+
Status: 'Certified',
|
|
37
|
+
ProfileVariant: 'FAPI2 Adv. OP w/Private Key, PAR',
|
|
38
|
+
ProfileType: 'Redirect',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
// fapi2, web and email claim
|
|
43
|
+
{
|
|
44
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b23',
|
|
45
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
46
|
+
CustomerFriendlyName: 'Mock Bank D',
|
|
47
|
+
AuthorisationServerCertifications: [
|
|
48
|
+
{
|
|
49
|
+
CertificationStartDate: '10/04/1900',
|
|
50
|
+
CertificationExpirationDate: '10/04/2099',
|
|
51
|
+
Status: 'Certified',
|
|
52
|
+
ProfileVariant: 'FAPI2 Adv. OP w/Private Key, PAR',
|
|
53
|
+
ProfileType: 'Redirect',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
CertificationStartDate: '10/04/1900',
|
|
57
|
+
CertificationExpirationDate: '10/04/2099',
|
|
58
|
+
Status: 'Certified',
|
|
59
|
+
ProfileVariant: 'web',
|
|
60
|
+
ProfileType: 'Channel',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
CertificationStartDate: '10/04/1900',
|
|
64
|
+
CertificationExpirationDate: '10/04/2099',
|
|
65
|
+
Status: 'Certified',
|
|
66
|
+
ProfileVariant: 'email',
|
|
67
|
+
ProfileType: 'ConnectID Claims',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
// fapi2, web and birthdate claim
|
|
72
|
+
{
|
|
73
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b24',
|
|
74
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
75
|
+
CustomerFriendlyName: 'Mock Bank E',
|
|
76
|
+
AuthorisationServerCertifications: [
|
|
77
|
+
{
|
|
78
|
+
CertificationStartDate: '10/04/1900',
|
|
79
|
+
CertificationExpirationDate: '10/04/2099',
|
|
80
|
+
Status: 'Certified',
|
|
81
|
+
ProfileVariant: 'FAPI2 Adv. OP w/Private Key, PAR',
|
|
82
|
+
ProfileType: 'Redirect',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
CertificationStartDate: '10/04/1900',
|
|
86
|
+
CertificationExpirationDate: '10/04/2099',
|
|
87
|
+
Status: 'Certified',
|
|
88
|
+
ProfileVariant: 'web',
|
|
89
|
+
ProfileType: 'Channel',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
CertificationStartDate: '10/04/1900',
|
|
93
|
+
CertificationExpirationDate: '10/04/2099',
|
|
94
|
+
Status: 'Certified',
|
|
95
|
+
ProfileVariant: 'birthdate',
|
|
96
|
+
ProfileType: 'ConnectID Claims',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
assert.deepStrictEqual(filterAuthorisationServers(authorisationServers, false, 'Active', ['email'], ['Redirect.FAPI2']), [authorisationServers[2]]);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe('getManualAuthorisationServer', () => {
|
|
105
|
+
const authorisationServers = [
|
|
106
|
+
{
|
|
107
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b2b',
|
|
108
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
109
|
+
CustomerFriendlyName: 'Mock Bank A',
|
|
110
|
+
// expired
|
|
111
|
+
AuthorisationServerCertifications: [
|
|
112
|
+
{
|
|
113
|
+
CertificationExpirationDate: '10/04/2000',
|
|
114
|
+
Status: 'Certified',
|
|
115
|
+
ProfileVariant: 'Fallback Identity Service Provider',
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
ProfileType: 'ConnectID',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
it('should return expired manual servers if showAllParticipants is true', () => {
|
|
123
|
+
assert.deepStrictEqual(getManualAuthorisationServer(authorisationServers, true), authorisationServers[0]);
|
|
124
|
+
});
|
|
125
|
+
it('should not return expired manual servers if showAllParticipants is false', () => {
|
|
126
|
+
assert.deepStrictEqual(getManualAuthorisationServer(authorisationServers, false), undefined);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe('filterAuthorisationServerByClaims', () => {
|
|
130
|
+
const authorisationServers = [
|
|
131
|
+
{
|
|
132
|
+
AuthorisationServerId: '1',
|
|
133
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
134
|
+
CustomerFriendlyName: 'Mock Bank A',
|
|
135
|
+
AuthorisationServerCertifications: [
|
|
136
|
+
{
|
|
137
|
+
CertificationStartDate: '10/04/1900',
|
|
138
|
+
CertificationExpirationDate: '10/04/2099',
|
|
139
|
+
Status: 'Certified',
|
|
140
|
+
ProfileVariant: 'email',
|
|
141
|
+
ProfileType: 'ConnectID Claims',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
AuthorisationServerId: '2',
|
|
147
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
148
|
+
CustomerFriendlyName: 'Mock Bank B',
|
|
149
|
+
// no claims
|
|
150
|
+
AuthorisationServerCertifications: [],
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
AuthorisationServerId: '3',
|
|
154
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
155
|
+
CustomerFriendlyName: 'Mock Bank C',
|
|
156
|
+
AuthorisationServerCertifications: [
|
|
157
|
+
// multiple claims
|
|
158
|
+
{
|
|
159
|
+
CertificationStartDate: '10/04/1900',
|
|
160
|
+
CertificationExpirationDate: '10/04/2099',
|
|
161
|
+
Status: 'Certified',
|
|
162
|
+
ProfileVariant: 'email',
|
|
163
|
+
ProfileType: 'ConnectID Claims',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
CertificationStartDate: '10/04/1900',
|
|
167
|
+
CertificationExpirationDate: '10/04/2099',
|
|
168
|
+
Status: 'Certified',
|
|
169
|
+
ProfileVariant: 'birthdate',
|
|
170
|
+
ProfileType: 'ConnectID Claims',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
CertificationStartDate: '10/04/1900',
|
|
174
|
+
CertificationExpirationDate: '10/04/2099',
|
|
175
|
+
Status: 'Certified',
|
|
176
|
+
ProfileVariant: 'name',
|
|
177
|
+
ProfileType: 'ConnectID Claims',
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
it('should return no authorisation servers when claim is address', () => {
|
|
183
|
+
assert.deepStrictEqual(filterAuthorisationServerByClaims(authorisationServers, ['address']), []);
|
|
184
|
+
});
|
|
185
|
+
it('should return bank C and A when claim email', () => {
|
|
186
|
+
assert.deepStrictEqual(filterAuthorisationServerByClaims(authorisationServers, ['email']), [
|
|
187
|
+
authorisationServers[0],
|
|
188
|
+
authorisationServers[2],
|
|
189
|
+
]);
|
|
190
|
+
});
|
|
191
|
+
it('should return bank C when claim is email and birthdate', () => {
|
|
192
|
+
assert.deepStrictEqual(filterAuthorisationServerByClaims(authorisationServers, ['email', 'birthdate']), [
|
|
193
|
+
authorisationServers[2],
|
|
194
|
+
]);
|
|
195
|
+
});
|
|
196
|
+
it('should return bank C when claim is given_name, middle_name and birthdate', () => {
|
|
197
|
+
assert.deepStrictEqual(filterAuthorisationServerByClaims(authorisationServers, ['given_name', 'middle_name', 'birthdate']), [authorisationServers[2]]);
|
|
198
|
+
});
|
|
199
|
+
it('should return bank C when claim is name', () => {
|
|
200
|
+
assert.deepStrictEqual(filterAuthorisationServerByClaims(authorisationServers, ['given_name']), [
|
|
201
|
+
authorisationServers[2],
|
|
202
|
+
]);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
describe('removeExpiredCertifications', () => {
|
|
206
|
+
it('should remove expired or not started certifications', () => {
|
|
207
|
+
const authorisationServers = [
|
|
208
|
+
{
|
|
209
|
+
AuthorisationServerId: '1',
|
|
210
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
211
|
+
CustomerFriendlyName: 'Mock Bank A',
|
|
212
|
+
AuthorisationServerCertifications: [
|
|
213
|
+
// certified and not expired
|
|
214
|
+
{
|
|
215
|
+
CertificationStartDate: '10/04/1900',
|
|
216
|
+
CertificationExpirationDate: '10/04/2099',
|
|
217
|
+
Status: 'Certified',
|
|
218
|
+
ProfileVariant: 'web',
|
|
219
|
+
ProfileType: 'Channel',
|
|
220
|
+
},
|
|
221
|
+
// not certified and not expired
|
|
222
|
+
{
|
|
223
|
+
CertificationStartDate: '10/04/1900',
|
|
224
|
+
CertificationExpirationDate: '10/04/2099',
|
|
225
|
+
Status: 'Deprecated',
|
|
226
|
+
ProfileVariant: 'FAPI2 Adv. OP w/Private Key, PAR',
|
|
227
|
+
ProfileType: 'Redirect',
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
AuthorisationServerId: '2',
|
|
233
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
234
|
+
CustomerFriendlyName: 'Mock Bank B',
|
|
235
|
+
// no certifications
|
|
236
|
+
AuthorisationServerCertifications: [],
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
AuthorisationServerId: '3',
|
|
240
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
241
|
+
CustomerFriendlyName: 'Mock Bank C',
|
|
242
|
+
AuthorisationServerCertifications: [
|
|
243
|
+
// certified but expired
|
|
244
|
+
{
|
|
245
|
+
CertificationStartDate: '10/04/1900',
|
|
246
|
+
CertificationExpirationDate: '10/04/2000',
|
|
247
|
+
Status: 'Certified',
|
|
248
|
+
ProfileVariant: 'web',
|
|
249
|
+
ProfileType: 'Channel',
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
AuthorisationServerId: '4',
|
|
255
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
256
|
+
CustomerFriendlyName: 'Mock Bank D',
|
|
257
|
+
AuthorisationServerCertifications: [
|
|
258
|
+
// certified and not expired but not started
|
|
259
|
+
{
|
|
260
|
+
CertificationStartDate: '10/04/2098',
|
|
261
|
+
CertificationExpirationDate: '10/04/2099',
|
|
262
|
+
Status: 'Certified',
|
|
263
|
+
ProfileVariant: 'web',
|
|
264
|
+
ProfileType: 'Channel',
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
const expected = [
|
|
270
|
+
{
|
|
271
|
+
AuthorisationServerId: '1',
|
|
272
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
273
|
+
CustomerFriendlyName: 'Mock Bank A',
|
|
274
|
+
AuthorisationServerCertifications: [
|
|
275
|
+
// certified and not expired
|
|
276
|
+
{
|
|
277
|
+
CertificationStartDate: '10/04/1900',
|
|
278
|
+
CertificationExpirationDate: '10/04/2099',
|
|
279
|
+
Status: 'Certified',
|
|
280
|
+
ProfileVariant: 'web',
|
|
281
|
+
ProfileType: 'Channel',
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
AuthorisationServerId: '2',
|
|
287
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
288
|
+
CustomerFriendlyName: 'Mock Bank B',
|
|
289
|
+
// no certifications
|
|
290
|
+
AuthorisationServerCertifications: [],
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
AuthorisationServerId: '3',
|
|
294
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
295
|
+
CustomerFriendlyName: 'Mock Bank C',
|
|
296
|
+
AuthorisationServerCertifications: [],
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
AuthorisationServerId: '4',
|
|
300
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
301
|
+
CustomerFriendlyName: 'Mock Bank D',
|
|
302
|
+
AuthorisationServerCertifications: [],
|
|
303
|
+
},
|
|
304
|
+
];
|
|
305
|
+
assert.deepStrictEqual(removeExpiredOrNotStartedCertifications(authorisationServers), expected);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
describe('filterAuthorisationServerByDevice', () => {
|
|
309
|
+
const authorisationServers = [
|
|
310
|
+
{
|
|
311
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b2b',
|
|
312
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
313
|
+
CustomerFriendlyName: 'Mock Bank A',
|
|
314
|
+
AuthorisationServerCertifications: [
|
|
315
|
+
{
|
|
316
|
+
CertificationStartDate: '10/04/1900',
|
|
317
|
+
CertificationExpirationDate: '10/04/2024',
|
|
318
|
+
Status: 'Certified',
|
|
319
|
+
ProfileVariant: 'web',
|
|
320
|
+
ProfileType: 'Channel',
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
AuthorisationServerId: '71fe3927-f596-4192-ab9a-f6644cdb9b2x',
|
|
326
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankA.svg',
|
|
327
|
+
CustomerFriendlyName: 'Mock Bank B',
|
|
328
|
+
AuthorisationServerCertifications: [
|
|
329
|
+
{
|
|
330
|
+
CertificationStartDate: '10/04/1900',
|
|
331
|
+
CertificationExpirationDate: '10/04/2024',
|
|
332
|
+
Status: 'Certified',
|
|
333
|
+
ProfileVariant: 'web',
|
|
334
|
+
ProfileType: 'Channel',
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
AuthorisationServerId: 'fa8573a1-953a-4085-b5f7-070a42a4d5a9',
|
|
340
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankC.svg',
|
|
341
|
+
CustomerFriendlyName: 'Mock Bank C',
|
|
342
|
+
AuthorisationServerCertifications: [
|
|
343
|
+
{
|
|
344
|
+
CertificationStartDate: '10/04/1900',
|
|
345
|
+
CertificationExpirationDate: '10/04/2024',
|
|
346
|
+
Status: 'Certified',
|
|
347
|
+
ProfileVariant: 'app',
|
|
348
|
+
ProfileType: 'Channel',
|
|
349
|
+
},
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
AuthorisationServerId: 'fa8573a1-953a-4085-b5f7-070a42a4d5a1',
|
|
354
|
+
CustomerFriendlyLogoUri: 'https://static.sandbox.connectid.com.au/BankC.svg',
|
|
355
|
+
CustomerFriendlyName: 'Mock Bank D',
|
|
356
|
+
AuthorisationServerCertifications: [],
|
|
357
|
+
},
|
|
358
|
+
];
|
|
359
|
+
it('should return all auth servers when device is mobile', () => {
|
|
360
|
+
const authServers = mapAuthorisationServerToDeviceType(authorisationServers, 'mobile');
|
|
361
|
+
const values = Array.from(authServers.values());
|
|
362
|
+
assert.deepStrictEqual(values.every((value) => value === 'mobile'), true);
|
|
363
|
+
});
|
|
364
|
+
it('should not return auth servers with only app cert when device is desktop', () => {
|
|
365
|
+
const authServers = mapAuthorisationServerToDeviceType(authorisationServers, 'desktop');
|
|
366
|
+
const filteredAuthServers = Array.from(authServers)
|
|
367
|
+
.filter(([_, device]) => device === 'mobile')
|
|
368
|
+
.map(([key, _]) => key);
|
|
369
|
+
assert.deepStrictEqual(filteredAuthServers, [
|
|
370
|
+
authorisationServers[0],
|
|
371
|
+
authorisationServers[1],
|
|
372
|
+
authorisationServers[3],
|
|
373
|
+
]);
|
|
374
|
+
});
|
|
375
|
+
it('should not return auth servers with only app cert when device is tablet', () => {
|
|
376
|
+
const authServers = mapAuthorisationServerToDeviceType(authorisationServers, 'tablet');
|
|
377
|
+
console.log(authServers);
|
|
378
|
+
const filteredAuthServers = Array.from(authServers)
|
|
379
|
+
.filter(([_, device]) => device === 'mobile')
|
|
380
|
+
.map(([key, _]) => key);
|
|
381
|
+
assert.deepStrictEqual(filteredAuthServers, [
|
|
382
|
+
authorisationServers[0],
|
|
383
|
+
authorisationServers[1],
|
|
384
|
+
authorisationServers[3],
|
|
385
|
+
]);
|
|
386
|
+
});
|
|
387
|
+
});
|
package/global.css
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&display=swap');
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--font: 'DM Sans', sans-serif;
|
|
5
|
+
--charcoal: #262626;
|
|
6
|
+
--charcoal10: #e9e9e9;
|
|
7
|
+
--charcoal50: #939393;
|
|
8
|
+
--charcoal75: #5C5C5C;
|
|
9
|
+
--grey: #464646;
|
|
10
|
+
--mint: #BEEDD2;
|
|
11
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CidButton } from './CidButton';
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CidButton } from './CidButton';
|