Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@civic/gateway-client-core

Package Overview
Dependencies
Maintainers
13
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@civic/gateway-client-core - npm Package Compare versions

Comparing version 1.0.0-beta.4 to 1.0.0-beta.5

.nyc_output/6b90d1f3-3e74-44a8-a3ee-9131ed12443c.json

2

.nyc_output/processinfo/index.json

@@ -1,1 +0,1 @@

{"processes":{"28a3bebe-b91d-4046-9787-9731b3815112":{"parent":null,"children":[]},"2fcab246-015f-496c-b05e-01647cf18e5f":{"parent":null,"children":["c9bb2c1a-8768-44d2-9d25-757294ceb561"]},"c9bb2c1a-8768-44d2-9d25-757294ceb561":{"parent":"2fcab246-015f-496c-b05e-01647cf18e5f","children":[]},"ca85135c-aa52-4710-a5ec-1a58b7e5ecfd":{"parent":null,"children":[]}},"files":{"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperClient.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/url.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/index.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/local.logger.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/provider.logger.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/gatekeeperApi.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/chain.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperNetworkService.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/state.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/gateway.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/stateMapping.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/civicPass.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/flow.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/flow.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/userInteraction.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/expiry.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/gatewayStatus.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/fetch.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/common.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/error.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/defaults.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561","ca85135c-aa52-4710-a5ec-1a58b7e5ecfd"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/initialisation.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/issuance.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/errors.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/partnerReview.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/refresh.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/flowParameters.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/object.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/partnerReview.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/index.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/eventInterface.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/orchestrate.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/listeners.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/civicSign.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/inputs.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/remoteSign.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/issuance.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/refresh.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/userInteraction.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/log.ts":["28a3bebe-b91d-4046-9787-9731b3815112","c9bb2c1a-8768-44d2-9d25-757294ceb561"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/partnerReview.ts":["ca85135c-aa52-4710-a5ec-1a58b7e5ecfd"]},"externalIds":{}}
{"processes":{"6b90d1f3-3e74-44a8-a3ee-9131ed12443c":{"parent":null,"children":[]},"6c1cf6a5-8c24-4ffb-bf57-25d6d42c2bc3":{"parent":null,"children":[]}},"files":{"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperClient.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/url.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/index.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/local.logger.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/provider.logger.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/gatekeeperApi.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/chain.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperNetworkService.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/state.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/gateway.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/stateMapping.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/civicPass.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/flow.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/flow.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/userInteraction.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/expiry.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/gatewayStatus.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/fetch.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/common.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/error.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/defaults.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c","6c1cf6a5-8c24-4ffb-bf57-25d6d42c2bc3"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/initialisation.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/issuance.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/errors.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/partnerReview.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/refresh.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/flowParameters.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/object.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/partnerReview.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/index.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/eventInterface.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/orchestrate.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/listeners.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/civicSign.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/inputs.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/remoteSign.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/issuance.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/refresh.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/userInteraction.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/log.ts":["6b90d1f3-3e74-44a8-a3ee-9131ed12443c"]},"externalIds":{}}

@@ -6,2 +6,3 @@ import { GatewayStatus } from '../types/gateway';

export type ComputeCheckingType = GatewayStatus.ERROR | GatewayStatus.CHECKING;
export declare const civicPassStatusLookupInProgress: (state: GatewayCoreState) => boolean;
export declare const computeChecking: (state: GatewayCoreState) => ComputeCheckingType | undefined;

@@ -8,0 +9,0 @@ export declare const checkForInProgress: (state: GatewayCoreState) => GatewayTokenCheckType | ComputeCheckingType;

import { GatewayCoreState, GatewayInput } from '../types/gatewayCore';
import { ExtendedGatewayStatus, GatewayStatus, InternalGatewayStatus } from '../types/gateway';
import { GatewayTokenCheckType, StatusIfGatekeeperRecordRejectedType, ValidationGatewayStatusType } from './common';
import { CivicPassMessageResponse } from '../types/civicPass';
import { GatekeeperRecordResponse } from '../types/gatekeeperApi';
export declare const hasExistingDataCollectionProcessInProgress: (civicPassEvent: CivicPassMessageResponse | null) => boolean;
export declare const isInPartnerReview: (gatekeeperRecord: GatewayInput<GatekeeperRecordResponse> | undefined) => boolean;

@@ -6,0 +8,0 @@ export type CalculateFromIssuanceAwaitingOnChainReturn = ExtendedGatewayStatus.CHAIN_TIMEOUT_ERROR;

@@ -10,3 +10,3 @@ module.exports = {

statements: 96,
branches: 85,
branches: 87,
'skip-full': true,

@@ -13,0 +13,0 @@ include: ['src/**'],

{
"name": "@civic/gateway-client-core",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.5",
"description": "Sample project for creating typescript library with support of iife and types.",

@@ -58,3 +58,3 @@ "main": "dist/civic-gateway-client-core.min.js",

"license": "MIT",
"gitHead": "531b35b006a9748ae26d7752947a55dcccb60886"
"gitHead": "655c3681c937f639dac1bf6192a7b507ce9ea7e0"
}

@@ -57,2 +57,3 @@ import { prefixLogger } from '../logger';

...errorStatuses,
...validationProcessStatuses,
GatewayStatus.NOT_REQUESTED,

@@ -59,0 +60,0 @@ ExtendedGatewayStatus.ISSUANCE_RESTART_DATA_COLLECTION,

@@ -0,1 +1,2 @@

import { CivicPassMessageAction } from '../types/civicPass';
import { InputStatus } from '../types/fetch';

@@ -13,4 +14,14 @@ import { GatewayStatus } from '../types/gateway';

export type ComputeCheckingType = GatewayStatus.ERROR | GatewayStatus.CHECKING;
// returns true if:
// - the civicPass status action is STATUS
// AND the gatewayToken or gatekeeperRecord calls are still in progress
export const civicPassStatusLookupInProgress = (state: GatewayCoreState) =>
state.inputs.civicPass.received?.action === CivicPassMessageAction.STATUS &&
(!state.inputs.gatewayToken.status ||
state.inputs.gatewayToken.status === InputStatus.IN_PROGRESS ||
(!state.inputs.parameters?.disableInitialGatekeeperLookup &&
(!state.inputs.gatekeeperRecord.status || state.inputs.gatekeeperRecord?.status === InputStatus.IN_PROGRESS)));
export const computeChecking = (state: GatewayCoreState): ComputeCheckingType | undefined => {
if (!state.inputs.civicPass.status) {
if (!state.inputs.civicPass.status || civicPassStatusLookupInProgress(state)) {
if (

@@ -17,0 +28,0 @@ state.inputs.gatekeeperRecord.status === InputStatus.ERROR ||

@@ -15,6 +15,20 @@ import { GatewayCoreState, GatewayInput } from '../types/gatewayCore';

import { InputStatus } from '../types/fetch';
import { CivicPassMessageAction, CivicPassMessageEventResult } from '../types/civicPass';
import {
CivicPassMessageAction,
CivicPassMessageEventResult,
CivicPassMessageResponse,
ValidationStatus,
} from '../types/civicPass';
import { GatekeeperAPIStatus, GatekeeperRecordResponse } from '../types/gatekeeperApi';
import { getPendingRequestFromGatekeeperRecord } from '../utils/partnerReview';
// Civic pass emits a data-collection status event for longer-running data-collection processes
// to give more granular data-collection status updates
export const hasExistingDataCollectionProcessInProgress = (civicPassEvent: CivicPassMessageResponse | null): boolean =>
(civicPassEvent?.action === CivicPassMessageAction.STATUS &&
civicPassEvent?.event === CivicPassMessageEventResult.SUCCESS &&
civicPassEvent.payload?.status !== ValidationStatus.NOT_FOUND) ||
(civicPassEvent?.action === CivicPassMessageAction.ISSUANCE &&
civicPassEvent?.event === CivicPassMessageEventResult.IN_PROGRESS);
export const isInPartnerReview = (gatekeeperRecord: GatewayInput<GatekeeperRecordResponse> | undefined): boolean => {

@@ -133,8 +147,3 @@ return !!getPendingRequestFromGatekeeperRecord(gatekeeperRecord);

}
if (
(civicPassEvent?.action === CivicPassMessageAction.STATUS &&
civicPassEvent?.event === CivicPassMessageEventResult.SUCCESS) ||
(civicPassEvent?.action === CivicPassMessageAction.ISSUANCE &&
civicPassEvent?.event === CivicPassMessageEventResult.IN_PROGRESS)
) {
if (hasExistingDataCollectionProcessInProgress(civicPassEvent)) {
return gatewayStatusFromValidationProcess || GatewayStatus.COLLECTING_USER_INFORMATION;

@@ -191,9 +200,5 @@ }

// handle the case where the user has an expired validation process
// TODO check the action when the iframe is updated to send the correct action
if (civicPassEvent?.event === CivicPassMessageEventResult.FAILURE) {
return ExtendedGatewayStatus.RESTART;
}
const gatewayStatusFromValidationProcess =
validationProcessToGatewayStatus[civicPassEvent?.payload?.status as CheckValidationStatusType];

@@ -209,8 +214,5 @@ if (

if (!gatekeeperRecord?.received || gatekeeperRecord?.received?.state === GatekeeperAPIStatus.NOT_REQUESTED) {
if (
(civicPassEvent?.action === CivicPassMessageAction.STATUS &&
civicPassEvent?.event === CivicPassMessageEventResult.SUCCESS) ||
(civicPassEvent?.action === CivicPassMessageAction.ISSUANCE &&
civicPassEvent?.event === CivicPassMessageEventResult.IN_PROGRESS)
) {
if (hasExistingDataCollectionProcessInProgress(civicPassEvent)) {
const gatewayStatusFromValidationProcess =
validationProcessToGatewayStatus[civicPassEvent?.payload?.status as CheckValidationStatusType];
return gatewayStatusFromValidationProcess || GatewayStatus.COLLECTING_USER_INFORMATION;

@@ -217,0 +219,0 @@ }

@@ -8,2 +8,5 @@ import { step } from 'mocha-steps';

import { IntegrationTestHelpers, sleep } from './testSupport';
import { ValidationStatus } from '../../src/types/civicPass';
import { validationProcessToGatewayStatus } from '../../src/state/common';
import { GatewayStatus } from '../../src/types/gateway';

@@ -18,8 +21,8 @@ chai.use(sinonChai);

let testHelpers: IntegrationTestHelpers;
before(() => {
testHelpers = new IntegrationTestHelpers(sandbox);
testHelpers.stubSuccessfulFetchCalls();
});
context('with the initial gatekeeper record lookup disabled', () => {
before(() => {
testHelpers = new IntegrationTestHelpers(sandbox);
testHelpers.stubSuccessfulFetchCalls();
});
after(() => {

@@ -43,2 +46,6 @@ testHelpers.cleanup();

context('with the initial gatekeeper record lookup disabled flag not set', () => {
before(() => {
testHelpers = new IntegrationTestHelpers(sandbox);
testHelpers.stubSuccessfulFetchCalls();
});
after(() => {

@@ -60,2 +67,139 @@ testHelpers.cleanup();

});
context('with a validation in progress', () => {
Object.entries({
...validationProcessToGatewayStatus,
// this is a special case where data-collection needs to restart as we don't have a payload
// the internal status will go to ISSUANCE_RESTART_DATA_COLLECTION which maps to an output of NOT_REQUESTED
[ValidationStatus.COMPLETED]: GatewayStatus.NOT_REQUESTED,
}).forEach(([validationStatus, gatewayStatus]) => {
context(`with a civic-pass ${validationStatus} status event that arrives after checking is complete`, () => {
before(() => {
testHelpers = new IntegrationTestHelpers(sandbox);
testHelpers.stubSuccessfulFetchCalls();
});
after(() => {
testHelpers.cleanup();
sandbox.restore();
});
step('1. expect the Gatekeeper client to successfully initialize', () => {
testHelpers.initializeGatewayCore();
});
step('2. wait for GK and on-chain checks to complete', async () => {
await sleep(110);
});
step(`3. Simulate a ${validationStatus} civic pass validation process status event`, async () => {
testHelpers.simulateDataCollectionStatusEvent(validationStatus as ValidationStatus);
});
step(`4. Expect gateway status to change to ${gatewayStatus}`, async () => {
testHelpers.expectStatus(gatewayStatus);
});
});
context(`with a civic-pass ${validationStatus} status that arrives before checking is complete`, () => {
before(() => {
testHelpers = new IntegrationTestHelpers(sandbox);
testHelpers.stubSuccessfulFetchCalls();
});
after(() => {
testHelpers.cleanup();
sandbox.restore();
});
step('1. expect the Gatekeeper client to successfully initialize', () => {
testHelpers.initializeGatewayCore();
});
step('2. wait for GK and on-chain checks to be still in progress', async () => {
await sleep(5);
});
step(`3. Simulate a ${validationStatus} civic pass validation process status event`, async () => {
testHelpers.simulateDataCollectionStatusEvent(validationStatus as ValidationStatus);
});
step('4. expect status to still be CHECKING', async () => {
await sleep(5);
testHelpers.expectStatus(GatewayStatus.CHECKING);
});
step('5. wait for GK and on-chain checks to complete', async () => {
await sleep(110);
});
step(`6. Expect gateway status to change to ${gatewayStatus}`, async () => {
testHelpers.expectStatus(gatewayStatus);
});
});
});
});
context('with a validation not found', () => {
context('with a civic-pass status event that arrives after checking is complete', () => {
before(() => {
testHelpers = new IntegrationTestHelpers(sandbox);
testHelpers.stubSuccessfulFetchCalls();
});
after(() => {
testHelpers.cleanup();
sandbox.restore();
});
step('1. expect the Gatekeeper client to successfully initialize', () => {
testHelpers.initializeGatewayCore();
});
step('2. wait for GK and on-chain checks to complete', async () => {
await sleep(110);
});
step(`3. Simulate a NOT_FOUND civic pass validation process status event`, async () => {
testHelpers.simulateDataCollectionStatusEvent(ValidationStatus.NOT_FOUND);
});
step(`4. Expect gateway status to be NOT_REQUESTED`, async () => {
testHelpers.expectStatus(GatewayStatus.NOT_REQUESTED);
});
});
context('with a civic-pass status event that arrives before checking is complete', () => {
before(() => {
testHelpers = new IntegrationTestHelpers(sandbox);
testHelpers.stubSuccessfulFetchCalls();
});
after(() => {
testHelpers.cleanup();
sandbox.restore();
});
step('1. expect the Gatekeeper client to successfully initialize', () => {
testHelpers.initializeGatewayCore();
});
step('2. wait for GK and on-chain checks to be still in progress', async () => {
await sleep(5);
});
step(`3. Simulate a NOT_FOUND civic pass validation process status event`, async () => {
testHelpers.simulateDataCollectionStatusEvent(ValidationStatus.NOT_FOUND);
});
step('4. expect status to still be CHECKING', async () => {
await sleep(5);
testHelpers.expectStatus(GatewayStatus.CHECKING);
});
step('5. wait for GK and on-chain checks to complete', async () => {
await sleep(110);
});
step(`6. Expect gateway status to be NOT_REQUESTED`, async () => {
testHelpers.expectStatus(GatewayStatus.NOT_REQUESTED);
});
});
});
});

@@ -28,2 +28,3 @@ import GatewayClientCore, {

CivicPassMessageResponse,
ValidationStatus,
} from '../../src/types/civicPass';

@@ -481,2 +482,18 @@ import { CivicSignEventTypeRequest, CivicSignEventTypeResponse } from '../../src/types/civicSign';

async simulateDataCollectionStatusEvent(validationStatus: ValidationStatus) {
await this.emitter.emit('message', {
data: {
instanceId: this.client.instanceId,
source: '',
event: CivicPassMessageEventResult.SUCCESS,
action: CivicPassMessageAction.STATUS,
// here goes the payload required for the issuance action
// it will be different depending on the pass type
payload: {
status: validationStatus,
},
},
});
}
async simulateSucessfulDataCollectionTriggeringGKRefreshRequest() {

@@ -721,2 +738,6 @@ this.fetchStub.resetHistory();

expectStatus(gatewayStatus: GatewayStatus) {
expect(this.clientOutput.gatewayStatus).to.equal(gatewayStatus);
}
triggerForceRefresh() {

@@ -723,0 +744,0 @@ this.client.updateDynamicParameters({ forceRequireRefresh: true });

@@ -169,3 +169,3 @@ import chai from 'chai';

context('with statusFromGatewayTokenIfExists returning undefined', () => {
context('with statusFromGatewayTokenIfExists returning an unsupported state', () => {
it('should log an error and return ERROR', () => {

@@ -188,2 +188,21 @@ // Arrange

});
context('with statusFromGatewayTokenIfExists returning undefined', () => {
it('should log an error and return ERROR', () => {
// Arrange
const state = {
inputs: {
gatewayToken: {
received: {
state: undefined,
},
} as unknown as GatewayToken,
},
} as unknown as GatewayCoreState;
// Act
const result = handleGatewayTokenExistsStatus(state);
// Assert
expect(result).to.equal(GatewayStatus.ERROR);
});
});
});

@@ -265,3 +284,51 @@

});
context('with an ISSUED_EXPIRED API state', () => {
context('with a gatewayToken received', () => {
it('should return undefined', () => {
// Arrange
const state = {
inputs: {
gatekeeperRecord: {
received: {
state: GatekeeperAPIStatus.ISSUED_EXPIRED,
},
},
gatewayToken: {
received: {
state: 'ACTIVE',
},
},
},
} as GatewayCoreState;
// Act
const result = statusIfGatekeeperRecordRejected(state);
// Assert
expect(result).to.be.undefined;
});
});
context('with no gatewayToken received', () => {
it('should return ERROR', () => {
// Arrange
const state = {
inputs: {
gatekeeperRecord: {
received: {
state: GatekeeperAPIStatus.ISSUED_EXPIRED,
},
},
gatewayToken: {
received: null,
} as unknown as GatewayToken,
},
} as unknown as GatewayCoreState;
// Act
const result = statusIfGatekeeperRecordRejected(state);
// Assert
expect(result).to.equal(GatewayStatus.ERROR);
});
});
});
});
});

@@ -8,2 +8,3 @@ import { ExtendedGatewayStatus, GatewayCoreState, GatewayStatus } from '../../src';

calculateIssuanceStatus,
hasExistingDataCollectionProcessInProgress,
isInPartnerReview,

@@ -214,4 +215,87 @@ } from '../../src/state/issuance';

context('with a civicPass event of issuance in progress', () => {
context('with a derived validation process status', () => {
it('should return the mapping of the payload to gateway status', () => {
const state = {
inputs: {
civicPass: {
received: {
action: CivicPassMessageAction.ISSUANCE,
event: CivicPassMessageEventResult.IN_PROGRESS,
payload: {
status: ValidationStatus.COMPLETED,
},
},
},
},
} as unknown as GatewayCoreState;
const result = calculateIssuanceRequestedDataCollectionRestart(state);
expect(result).to.equal(GatewayStatus.USER_INFORMATION_VALIDATED);
});
});
context('with no derived validation process status', () => {
it('should return GatewayStatus.COLLECTING_USER_INFORMATION', () => {
const state = {
inputs: {
civicPass: {
received: {
action: CivicPassMessageAction.ISSUANCE,
event: CivicPassMessageEventResult.IN_PROGRESS,
},
},
},
} as unknown as GatewayCoreState;
const result = calculateIssuanceRequestedDataCollectionRestart(state);
expect(result).to.equal(GatewayStatus.COLLECTING_USER_INFORMATION);
});
});
});
context('with a civicPass status succcess', () => {
it('should return the mapping of the payload to gateway status', () => {
context('with a not-found payload', () => {
it('should return undefined', () => {
const state = {
inputs: {
civicPass: {
received: {
action: CivicPassMessageAction.STATUS,
event: CivicPassMessageEventResult.SUCCESS,
payload: {
status: ValidationStatus.NOT_FOUND,
},
},
},
},
} as unknown as GatewayCoreState;
const result = calculateIssuanceRequestedDataCollectionRestart(state);
expect(result).to.equal(undefined);
});
});
Object.entries(validationProcessToGatewayStatus).forEach(([validationStatus, gatewayStatus]) => {
context('with a payload status of ' + validationStatus, () => {
it('should return the mapping of the payload to gateway status', () => {
const state = {
inputs: {
civicPass: {
received: {
action: CivicPassMessageAction.STATUS,
event: CivicPassMessageEventResult.SUCCESS,
payload: {
status: validationStatus,
},
},
},
},
} as unknown as GatewayCoreState;
const result = calculateIssuanceRequestedDataCollectionRestart(state);
expect(result).to.equal(gatewayStatus);
});
});
});
});
context('with a civicPass issuance succcess', () => {
it('should return USER_INFORMATION_VALIDATED', () => {
const state = {

@@ -221,7 +305,4 @@ inputs: {

received: {
action: CivicPassMessageAction.STATUS,
action: CivicPassMessageAction.ISSUANCE,
event: CivicPassMessageEventResult.SUCCESS,
payload: {
status: ValidationStatus.COLLECTING,
},
},

@@ -231,4 +312,4 @@ },

} as unknown as GatewayCoreState;
const result = calculateIssuanceStatus(state);
expect(result).to.equal(GatewayStatus.COLLECTING_USER_INFORMATION);
const result = calculateIssuanceRequestedDataCollectionRestart(state);
expect(result).to.equal(GatewayStatus.USER_INFORMATION_VALIDATED);
});

@@ -565,2 +646,66 @@ });

});
context('hasExistingDataCollectionProcessInProgress', () => {
context('with no civicPass received', () => {
it('should return false', () => {
const result = hasExistingDataCollectionProcessInProgress(null);
expect(result).to.be.false;
});
});
context('with a civicPass received', () => {
context('with a STATUS SUCCESS', () => {
context('with a payload of NOT_FOUND', () => {
it('should return false', () => {
const result = hasExistingDataCollectionProcessInProgress({
action: CivicPassMessageAction.STATUS,
event: CivicPassMessageEventResult.SUCCESS,
payload: {
status: ValidationStatus.NOT_FOUND,
},
});
expect(result).to.be.false;
});
});
context('with any other payload than NOT_FOUND', () => {
['COLLECTING', 'PROCESSING', 'IN_REVIEW', 'COMPLETED', 'FAILED'].forEach((status) => {
it(`should return true for status: ${status}`, () => {
const result = hasExistingDataCollectionProcessInProgress({
action: CivicPassMessageAction.STATUS,
event: CivicPassMessageEventResult.SUCCESS,
payload: {
status: status as ValidationStatus,
},
});
expect(result).to.be.true;
});
});
});
});
context('with an issuance in progress event', () => {
it('should return true', () => {
const result = hasExistingDataCollectionProcessInProgress({
action: CivicPassMessageAction.ISSUANCE,
event: CivicPassMessageEventResult.IN_PROGRESS,
});
expect(result).to.be.true;
});
});
context('with a payload status of COLLECTING', () => {
it('should return true', () => {
const result = hasExistingDataCollectionProcessInProgress({
action: CivicPassMessageAction.STATUS,
event: CivicPassMessageEventResult.SUCCESS,
payload: {
status: ValidationStatus.COLLECTING,
},
});
expect(result).to.be.true;
});
});
});
});
});

@@ -1,2 +0,346 @@

// TODO refresh state tests
describe('refresh', () => {});
import { GatewayCoreState } from '../../src/types/gatewayCore';
import {
calculateFromGatekeeperRefreshRequested,
calculateFromRefreshAwaitingOnChain,
calculateFromRefreshInReview,
calculateRefreshStatus,
tokenNotRefreshRequired,
} from '../../src/state/refresh';
import { ExtendedGatewayStatus, GatewayStatus } from '../../src/types/gateway';
import { expect } from 'chai';
import { InputStatus } from '../../src/types/fetch';
import { GatekeeperAPIStatus } from '../../src/types/gatekeeperApi';
import { CivicPassMessageAction, CivicPassMessageEventResult } from '../../src/types/civicPass';
import { ChainConfirmationTimeout } from '../../src/utils/errors';
describe('refresh state functions', () => {
context('calculateFromRefreshInReview', () => {
context('with an input payer', () => {
context('with a sent transaction', () => {
it('returns REFRESH_AWAITING_ON_CHAIN_TOKEN', () => {
// Arrange
const state = {
inputs: {
parameters: {
payer: 'payer',
},
},
internal: {
chainTransaction: {
sentTxId: 'sentTxId',
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshInReview(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.REFRESH_AWAITING_ON_CHAIN_TOKEN);
});
});
context('with a transaction error', () => {
it('returns CHAIN_TRANSACTION_ERROR', () => {
// Arrange
const state = {
inputs: {
parameters: {
payer: 'payer',
},
},
internal: {
chainTransaction: {
error: 'error',
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshInReview(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.CHAIN_TRANSACTION_ERROR);
});
});
context('with a gatekeeper record transaction', () => {
context('if the payer is the wallet owner', () => {
it('returns REFRESH_AWAITING_TRANSACTION_SEND', () => {
// Arrange
const state = {
inputs: {
parameters: {
wallet: { address: 'payer' },
payer: 'payer',
},
gatekeeperRecord: {
received: {
transaction: 'transaction',
},
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshInReview(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.REFRESH_AWAITING_TRANSACTION_SEND);
});
});
context('is the payer is not the wallet owner', () => {
it('returns REFRESH_AWAITING_THIRD_PARTY_TRANSACTION_SEND', () => {
// Arrange
const state = {
inputs: {
parameters: {
payer: 'payer',
},
gatekeeperRecord: {
received: {
transaction: 'transaction',
},
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshInReview(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.REFRESH_AWAITING_THIRD_PARTY_TRANSACTION_SEND);
});
});
});
});
context('with no payer set', () => {
it('returns REFRESH_AWAITING_ON_CHAIN_TOKEN', () => {
// Arrange
const state = {
inputs: {
parameters: {
payer: undefined,
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshInReview(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.REFRESH_AWAITING_ON_CHAIN_TOKEN);
});
});
});
context('calculateFromGatekeeperRefreshRequested', () => {
context('with a gatekeeper record in state', () => {
[
{
received: {
state: GatekeeperAPIStatus.REQUESTED,
},
},
{
status: InputStatus.IN_PROGRESS,
},
].forEach((gatekeeperRecordState) => {
context('with a gatekeeper record requested', () => {
context('with a payer set', () => {
context('with the payer the same as wallet owner', () => {
it('returns REFRESH_CLIENT_PAYER_REQUESTED', () => {
// Arrange
const state = {
inputs: {
parameters: {
wallet: { address: 'payer' },
payer: 'payer',
},
gatekeeperRecord: gatekeeperRecordState,
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromGatekeeperRefreshRequested(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.REFRESH_CLIENT_PAYER_REQUESTED);
});
});
context('if the payer is not the wallet owner', () => {
it('returns REFRESH_IN_REVIEW', () => {
// Arrange
const state = {
inputs: {
parameters: {
payer: 'payer',
},
gatekeeperRecord: gatekeeperRecordState,
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromGatekeeperRefreshRequested(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.REFRESH_IN_REVIEW);
});
});
});
});
});
});
context('with no gatekeeper record in state', () => {
it('returns undefined', () => {
// Arrange
const state = {
inputs: {
gatekeeperRecord: undefined,
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromGatekeeperRefreshRequested(state);
// Assert
expect(result).to.be.undefined;
});
});
});
context('tokenNotRefreshRequired', () => {
context('with a token status', () => {
context('with a token status that is not REFRESH_AWAITING_ON_CHAIN_TOKEN or REFRESH_TOKEN_REQUIRED', () => {
[GatewayStatus.ACTIVE, GatewayStatus.FROZEN, GatewayStatus.REVOKED].forEach((tokenStatus) => {
it('returns the token status', () => {
// Arrange
const state = {
inputs: {
gatewayToken: {
received: {
state: tokenStatus,
},
},
},
} as unknown as GatewayCoreState;
// Act
const result = tokenNotRefreshRequired(state);
// Assert
expect(result).to.equal(tokenStatus);
});
});
});
});
});
context('calculateRefreshStatus', () => {
context('with a civic pass REFRESH SUCCESS', () => {
it('should return REFRESH_USER_INFORMATION_VALIDATED', () => {
// Arrange
const state = {
inputs: {
civicPass: {
received: {
action: CivicPassMessageAction.REFRESH,
event: CivicPassMessageEventResult.SUCCESS,
},
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateRefreshStatus(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.REFRESH_USER_INFORMATION_VALIDATED);
});
});
context('with a non REFRESH civic pass event', () => {
it('should return undefined', () => {
// Arrange
const state = {
inputs: {
civicPass: {
received: {
action: 'OTHER',
event: 'SUCCESS',
},
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateRefreshStatus(state);
// Assert
expect(result).to.be.undefined;
});
});
});
context('calculateFromRefreshAwaitingOnChain', () => {
context('with a chain timeout error', () => {
it('returns CHAIN_TIMEOUT_ERROR', () => {
// Arrange
const state = {
internal: {
errors: {
expectedOnChainToken: new ChainConfirmationTimeout('message'),
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshAwaitingOnChain(state);
// Assert
expect(result).to.equal(ExtendedGatewayStatus.CHAIN_TIMEOUT_ERROR);
});
});
context('with no chain timeout error', () => {
it('returns undefined', () => {
// Arrange
const state = {
internal: {
chainTransaction: {
error: undefined,
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshAwaitingOnChain(state);
// Assert
expect(result).to.be.undefined;
});
});
context('with a non timeout error', () => {
it('returns undefined', () => {
// Arrange
const state = {
internal: {
chainTransaction: {
error: new Error('message'),
},
},
} as unknown as GatewayCoreState;
// Act
const result = calculateFromRefreshAwaitingOnChain(state);
// Assert
expect(result).to.equal(undefined);
});
});
});
});

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc