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
0
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 to 1.0.1-beta.0

.nyc_output/d47c74f8-e158-4567-845d-65e71be2382d.json

2

.nyc_output/processinfo/index.json

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

{"processes":{"1cdd1824-030a-4b65-8207-2f21e038c4d6":{"parent":null,"children":[]},"b578dbb4-ca0e-41a8-b8e9-6bdb5f4cd9d1":{"parent":null,"children":[]}},"files":{"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/config.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperClient.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/url.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/logger/index.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/logger/local.logger.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/logger/provider.logger.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/log.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/gatekeeperApi.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/chain.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperNetworkService.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/GatewayClientCore.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/orchestrate.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/listeners.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/civicPass.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/civicSign.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/fetch.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/gateway.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/inputs.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/remoteSign.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/issuance.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/orchestratorFlow.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/defaults.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6","b578dbb4-ca0e-41a8-b8e9-6bdb5f4cd9d1"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/errors.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/expiry.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/refresh.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/userInteraction.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/userInteraction.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/partnerReview.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/common.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/state.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/stateMapping.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/flow.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/flow.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/gatewayStatus.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/error.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/initialisation.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/issuance.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/partnerReview.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/refresh.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/flowParameters.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/object.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/ui.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/ui.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/index.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/eventInterface.ts":["1cdd1824-030a-4b65-8207-2f21e038c4d6"]},"externalIds":{}}
{"processes":{"d47c74f8-e158-4567-845d-65e71be2382d":{"parent":null,"children":[]},"e213186e-fed4-4e72-b471-a29aaf4b2516":{"parent":null,"children":[]}},"files":{"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/defaults.ts":["d47c74f8-e158-4567-845d-65e71be2382d","e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/config.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperClient.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/url.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/logger/index.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/logger/local.logger.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/logger/provider.logger.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/log.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/gatekeeperApi.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/chain.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperNetworkService.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/GatewayClientCore.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/orchestrate.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/listeners.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/civicPass.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/civicSign.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/fetch.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/gateway.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/inputs.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/remoteSign.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/issuance.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/orchestratorFlow.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/errors.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/expiry.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/refresh.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/userInteraction.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/userInteraction.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/partnerReview.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/common.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/state.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/stateMapping.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/flow.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/flow.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/gatewayStatus.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/error.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/initialisation.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/issuance.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/partnerReview.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/refresh.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/flowParameters.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/utils/object.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/state/ui.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/ui.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/index.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"],"/Users/daneel/work/ociv-gatekeeper/packages/gateway-client-core/src/types/eventInterface.ts":["e213186e-fed4-4e72-b471-a29aaf4b2516"]},"externalIds":{}}
# gateway client core
## 1.0.1-beta.0 - New options for issuance flow
- add option to not show the Token Active screen at the end of the flow
## 1.0.0 - Initial release

@@ -31,2 +31,3 @@ import { GatekeeperAPIStatus, GatekeeperClientConfig, GatekeeperRecordResponse, RequestTokenIssuanceResponse, RequestTokenRefreshResponse, TokenRequest } from './types/gatekeeperApi';

fetchFreshTransaction({ payer }: TokenRequest): Promise<RequestTokenRefreshResponse | null>;
updateTransactionStatus(txId: string, status?: string): Promise<void | null>;
}

@@ -9,3 +9,6 @@ export declare const GKN_SERVICE_ENDPOINTS: Record<string, string>;

};
client?: {
tokenActiveDisplay?: 'default' | 'minimal' | 'hidden';
};
};
export declare const getGatekeeperNetworkData: (stage: string, gknId: string) => Promise<GknData>;
import { ClientCoreInput } from './types/clientCore';
import { GatewayClientCoreInterface } from './types/gatewayCore';
import { GatewayClientCoreInterface, GatewayInput } from './types/gatewayCore';
import { DynamicGatewayClientParameters, GatewayClientParameters } from './types/parameters';
import { ChainDetails } from './types/chain';
import { UIInput } from './types/ui';
import { GknData } from './gatekeeperNetworkService';
export declare const getInstanceInputObject: (input: ClientCoreInput | undefined) => InstanceInputObject;

@@ -22,2 +23,3 @@ export declare const shouldUpdateInstance: (inputs: ClientCoreInput, instance: GatewayClientCore | undefined) => boolean;

updateDynamicParameters(dynamicParameters: DynamicGatewayClientParameters): void;
updateGatekeeperNetworkServiceData(gknData: GatewayInput<GknData>): void;
startOrResumeFlow(): void;

@@ -24,0 +26,0 @@ abort(): void;

@@ -34,2 +34,3 @@ import { ListenerManager } from './listeners';

getOwnerDids(): Promise<void>;
fetchGatekeeperNetworkData(): Promise<void>;
lookupTokenState(): Promise<void>;

@@ -36,0 +37,0 @@ initialise(): Promise<void>;

@@ -49,3 +49,7 @@ import { Mutate, StoreApi } from 'zustand/vanilla';

};
gatekeeperNetworkData: {
status: null;
received: null;
};
};
export declare const createGatewayCoreStore: (options: DevtoolsOptions) => WritableDraft<Store>;

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

import { GknData } from 'src/gatekeeperNetworkService';
import { ChainConfirmationTimeout, ChainError } from '../utils/errors';

@@ -73,2 +74,3 @@ import { ChainDetails, ChainType, GatewayToken } from './chain';

gatekeeperRecord: GatewayInput<GatekeeperRecordResponse>;
gatekeeperNetworkData: GatewayInput<GknData>;
parameters: GatewayClientParameters | null;

@@ -75,0 +77,0 @@ dynamicParameters?: DynamicGatewayClientParameters;

@@ -5,2 +5,4 @@ import { LoggingInterface } from '../logger/provider.logger';

SIGN_TRANSACTION_ERROR: string;
SIGN_TRANSACTION_USER_REJECTED_ERROR: string;
SIGN_TRANSACTION_UNKNOWN_ERROR: string;
SEND_TRANSACTION_ERROR: string;

@@ -7,0 +9,0 @@ CUSTOM_HANDLE_TRANSACTION_ERROR: string;

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

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

"dev": "rollup -c -w",
"test": "TS_NODE_PROJECT=./tsconfig.test.json nyc mocha --require mocha-steps --timeout 20000"
"test": "TS_NODE_PROJECT=./tsconfig.test.json nyc mocha --require mocha-steps --timeout 20000",
"coverage": "TS_NODE_PROJECT=./tsconfig.test.json nyc report --reporter=text --reporter=html"
},

@@ -63,3 +64,3 @@ "keywords": [],

"license": "MIT",
"gitHead": "b0cd4fd86109d65b4f29bfc8ceac2d84422c5642"
"gitHead": "7e1f1082416e2ed5476d510df4c151a51261d96c"
}

@@ -340,2 +340,35 @@ import { default as fetchBuilder } from 'fetch-retry';

}
public async updateTransactionStatus(txId: string, status = 'sent'): Promise<void | null> {
const url = new URL(`${this.baseUrl}/${this.initConfig.walletAddress}/transaction/${txId}`);
this.addQueryParams(url);
const body = { status };
return this.fetchWithRetry(url.toString(), {
method: 'PATCH',
headers: {
...this.headers,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
signal: this.abortController.signal,
})
.then(
this.continueIfNotAborted(() => async () => {
logDebug('updateTransactionStatus successful', {
txId,
url,
wallet: this.initConfig.walletAddress,
});
})
)
.catch((error) => {
if (error.name === 'AbortError') {
logDebug('error due to abort controller signal aborted');
return null;
}
logError('updateTransactionStatus', error);
throw error;
});
}
}

@@ -16,2 +16,5 @@ export const GKN_SERVICE_ENDPOINTS: Record<string, string> = {

};
client?: {
tokenActiveDisplay?: 'default' | 'minimal' | 'hidden';
};
};

@@ -18,0 +21,0 @@

@@ -6,3 +6,3 @@ import { v4 as uuid } from 'uuid';

import { createGatewayCoreStore, Store } from './state/state';
import { ClientCoreOutput, GatewayClientCoreInterface } from './types/gatewayCore';
import { ClientCoreOutput, GatewayClientCoreInterface, GatewayInput } from './types/gatewayCore';
import { getPayer } from './utils/inputs';

@@ -16,2 +16,3 @@ import { UserInteractionStatus } from './types/userInteraction';

import * as R from 'ramda';
import { GknData } from './gatekeeperNetworkService';

@@ -122,2 +123,8 @@ export const getInstanceInputObject = (input: ClientCoreInput | undefined): InstanceInputObject =>

updateGatekeeperNetworkServiceData(gknData: GatewayInput<GknData>) {
this.gatewayCoreStore.setState((state) => {
state.inputs.gatekeeperNetworkData = R.clone(gknData);
});
}
startOrResumeFlow() {

@@ -124,0 +131,0 @@ this.gatewayCoreStore.setState((state) => {

@@ -80,2 +80,6 @@ import { GatekeeperClient } from './gatekeeperClient';

}
// Fire and forget the request to set the TXId on the gatekeeper
this.gatekeeperClient.updateTransactionStatus(txId);
state.internal.chainTransaction.sentTxId = txId;

@@ -82,0 +86,0 @@ });

@@ -32,2 +32,3 @@ /**

import { ChainError, ErrorCode } from './utils/errors';
import { getGatekeeperNetworkData } from './gatekeeperNetworkService';

@@ -152,2 +153,26 @@ export class Orchestrator {

async fetchGatekeeperNetworkData() {
// We need the GKN data for control flow, so we fetch it here and set it on state so zustand-compute can get it synchronously.
this.gatewayCoreStore.setState((state) => {
state.inputs.gatekeeperNetworkData.status = InputStatus.IN_PROGRESS;
});
return getGatekeeperNetworkData(this.inputs.stage || 'prod', this.inputs.gatekeeperNetwork || '')
.then((response) => {
this.log.debug('getGatekeeperNetworkData', response);
if (this.abortController.signal.aborted) return;
this.gatewayCoreStore.setState((state) => {
state.inputs.gatekeeperNetworkData.status = InputStatus.COMPLETE;
state.inputs.gatekeeperNetworkData.received = response;
});
})
.catch((error) => {
this.log.error('Error retrieving gatekeeper network data', error);
if (this.abortController.signal.aborted) return;
this.gatewayCoreStore.setState((state) => {
state.inputs.gatekeeperNetworkData.status = InputStatus.ERROR;
state.inputs.gatekeeperNetworkData.error = error;
});
});
}
async lookupTokenState() {

@@ -228,2 +253,3 @@ const retrieveGKRecord = async () => {

this.lookupTokenState(),
this.fetchGatekeeperNetworkData(),
]);

@@ -230,0 +256,0 @@ }

@@ -52,2 +52,3 @@ /**

import { UIOutput } from '../types/ui';
import { FlowStatus } from '../types/flow';

@@ -78,3 +79,6 @@ export type Store = Mutate<

status: undefined,
userInteraction: { status: null, count: 0 },
userInteraction: {
status: null,
count: 0,
},
},

@@ -95,2 +99,3 @@ gatewayStatus: GatewayStatus.UNKNOWN,

dynamicParameters: { forceRequireRefresh: false },
gatekeeperNetworkData: { status: null, received: null },
};

@@ -114,2 +119,11 @@

};
// If the token active screen should not be shown we set the status to null so it can be detected when flow status is re-computed
// It will be reset when the user restarts a flow
const computedUserInteractionStatus =
[FlowStatus.RESULT, FlowStatus.FINISHED].includes(flowStatus as FlowStatus) &&
state.inputs.gatekeeperNetworkData?.received?.client?.tokenActiveDisplay === 'hidden'
? null
: state.internal.userInteraction.status;
return {

@@ -119,2 +133,6 @@ internal: {

status: computedInternalStatus,
userInteraction: {
...state.internal.userInteraction,
status: computedUserInteractionStatus,
},
},

@@ -128,3 +146,4 @@ output: {

userInteraction: {
status: state.internal.userInteraction.status,
...state.internal.userInteraction,
status: computedUserInteractionStatus,
},

@@ -167,3 +186,5 @@ },

...initialInternalState,
userInteraction: { status: state.internal.userInteraction.status },
userInteraction: {
status: state.internal.userInteraction.status,
},
instanceId: state.internal.instanceId,

@@ -170,0 +191,0 @@ ownerDids: [], // Dids will be queried using async chainImplementation.ownerDids() and updated here

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

import { GknData } from 'src/gatekeeperNetworkService';
import { ChainConfirmationTimeout, ChainError } from '../utils/errors';

@@ -80,2 +81,3 @@ import { ChainDetails, ChainType, GatewayToken } from './chain';

gatekeeperRecord: GatewayInput<GatekeeperRecordResponse>;
gatekeeperNetworkData: GatewayInput<GknData>;
parameters: GatewayClientParameters | null;

@@ -82,0 +84,0 @@ dynamicParameters?: DynamicGatewayClientParameters;

@@ -7,2 +7,4 @@ import logger from '../logger';

SIGN_TRANSACTION_ERROR: '0x2',
SIGN_TRANSACTION_USER_REJECTED_ERROR: '0x21',
SIGN_TRANSACTION_UNKNOWN_ERROR: '0x22',
SEND_TRANSACTION_ERROR: '0x3',

@@ -9,0 +11,0 @@ CUSTOM_HANDLE_TRANSACTION_ERROR: '0x4',

@@ -89,2 +89,3 @@ import { FlowStatus, FlowType } from '../types/flow';

];
export const flowStatusFromState = (

@@ -110,2 +111,7 @@ state: GatewayCoreState,

) {
if (state.inputs.gatekeeperNetworkData?.received?.client?.tokenActiveDisplay === 'hidden') {
// If the network is configured to not show the token active screen, we skip the RESULT state and go directly to FINISHED.
// state.internal.userInteraction will then be updated to null so the below checks return FINISHED instead of IN-PROGRESS
return FlowStatus.FINISHED;
}
return FlowStatus.RESULT;

@@ -118,2 +124,12 @@ }

if (
previousStatus === GatewayStatus.ACTIVE &&
state.inputs.gatekeeperNetworkData?.received?.client?.tokenActiveDisplay === 'hidden' &&
state.internal?.userInteraction?.status === null
) {
// If the network is configured to not show the token active screen and the flow status was set to FINISHED above
// there are still subsequent calls to flowStatusFromState so we need to handle them and keep returning FINISHED
return FlowStatus.FINISHED;
}
if (state.internal?.userInteraction.status === UserInteractionStatus.STARTED) {

@@ -120,0 +136,0 @@ return FlowStatus.IN_PROGRESS;

@@ -23,2 +23,3 @@ import sinon from 'sinon';

let abortController: AbortController;
let walletAddress: string;

@@ -43,2 +44,4 @@ afterEach(sandbox.restore);

walletAddress = '0x123';
// Configuration for the GatekeeperClient with the fetch stub

@@ -50,3 +53,3 @@ const config: GatekeeperClientConfig = {

numRetries: 3,
walletAddress: '0x123',
walletAddress,
stage: 'prod',

@@ -233,2 +236,43 @@ chainType: ChainType.SOLANA,

});
describe('updateTransactionStatus', function () {
const txId = 'tx123';
const status = 'sent';
it('should succeed with status 204', async () => {
fetchStub.resolves({
status: 204,
json: () => Promise.resolve({}),
clone: () => ({ json: () => Promise.resolve({}) }), // Ensure `clone` is also stubbed
});
await client.updateTransactionStatus(txId);
expect(fetchStub.calledOnce).to.be.true;
const fetchArgs = fetchStub.firstCall.args;
expect(fetchArgs[0]).to.include(`${walletAddress}/transaction/${txId}`);
expect(fetchArgs[1]).to.deep.include({
method: 'PATCH',
body: JSON.stringify({ status }),
});
});
it('should handle AbortError and return null', async () => {
fetchStub.rejects(new AbortError('Aborted'));
const result = await client.updateTransactionStatus(txId);
expect(result).to.be.null;
expect(fetchStub.calledOnce).to.be.true;
});
it('should throw an error for non-204 status', async () => {
fetchStub.rejects(new Error('Failed to update transaction status: Internal Server Error'));
await expect(client.updateTransactionStatus(txId)).to.be.rejectedWith(
'Failed to update transaction status: Internal Server Error'
);
expect(fetchStub.calledOnce).to.be.true;
});
});
});

@@ -49,2 +49,5 @@ import chai from 'chai';

},
client: {
tokenActiveDisplay: 'default',
},
};

@@ -51,0 +54,0 @@ fetchStub.resolves({

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

import { ChainClientInterface } from '../src/types/chain';
import { Stage } from '../src';
import { GknData, Stage } from '../src';
import * as state from '../src/state/state';

@@ -21,2 +21,3 @@ import { Store, WritableDraft } from '../src/state/state';

import { Orchestrator } from '../src/orchestrate';
import { InputStatus } from '../src/types/fetch';

@@ -225,2 +226,33 @@ chai.use(sinonChai);

context('updateGatekeeperNetworkServiceData', () => {
let store: WritableDraft<Store>;
beforeEach(() => {
store = state.createGatewayCoreStore({ name: 'test' });
sandbox.stub(state, 'createGatewayCoreStore').returns(store);
});
it('should update the gatekeeper network data in the store', () => {
// Arrange
coreInput = testHelpers.getCoreInputs();
const instance = new GatewayClientCore(coreInput);
const gknData: GknData = {
id: 'gknId',
chains: {
ethereum: {
chainSpecificId: '123',
},
},
client: {
tokenActiveDisplay: 'default',
},
};
// Act
instance.updateGatekeeperNetworkServiceData({ status: InputStatus.COMPLETE, received: gknData });
// Assert
const newState = store.getState();
expect(newState.inputs.gatekeeperNetworkData.received).to.deep.equal(gknData);
});
});
context('ui', () => {

@@ -227,0 +259,0 @@ let store: WritableDraft<Store>;

@@ -45,7 +45,7 @@ import { step } from 'mocha-steps';

step('6. Emit a civic-pass event to initiate the GK-API issuance request', async () => {
step('4. Emit a civic-pass event to initiate the GK-API issuance request', async () => {
await testHelpers.simulateSucessfulDataCollectionTriggeringGKTokenRequest();
});
step('7. Expect token in review', () => {
step('5. Expect token in review', () => {
testHelpers.expectCivicSendsInReview();

@@ -55,3 +55,3 @@ });

step(
'8. OnChain listener fires with active token and gateway status and gateway token are updated to active',
'6. OnChain listener fires with active token and gateway status and gateway token are updated to active',
async () => {

@@ -62,2 +62,11 @@ await testHelpers.simulateActiveOnChainToken();

);
step('7. User closes and re-opens the token active screen and see the token active screen again', async () => {
// Hide the token active screen
testHelpers.UiOnHide();
testHelpers.expectTokenActiveScreenHidden();
// Show the token active screen
testHelpers.UiOnShow();
testHelpers.expectTokenActiveScreenShown();
});
});

@@ -74,2 +74,3 @@ import sinon from 'sinon';

gatekeeperClient.requestGatewayTokenFromGatekeeper = sandbox.stub().resolves({ state: GatekeeperAPIStatus.ISSUED });
gatekeeperClient.updateTransactionStatus = sandbox.stub().resolves();
});

@@ -228,2 +229,8 @@

});
it('should patch the txId', async () => {
issuance = new Issuance(realGatewayCoreStore, chainImplementation, gatekeeperClient, abortController);
await issuance.sendTransaction();
expect(gatekeeperClient.updateTransactionStatus).to.have.been.calledOnceWith('txId');
});
});

@@ -230,0 +237,0 @@

@@ -114,3 +114,54 @@ import sinon, { SinonStub } from 'sinon';

it('should call getOwnerDids and lookupTokenState', () => {
it('should throw for invalid chain implementation input', () => {
expect(
() =>
new Orchestrator(
gatewayCoreStore,
messageEventInterface,
instanceId,
inputs,
fetchConfig,
postMessageTargetCallback,
false as unknown as ChainClientInterface
)
).to.throw('chainImplementation wallet and stage are required');
});
it('should throw for invalid wallet address input', () => {
expect(
() =>
new Orchestrator(
gatewayCoreStore,
messageEventInterface,
instanceId,
{
...inputs,
wallet: { address: false as unknown as string },
},
fetchConfig,
postMessageTargetCallback,
{} as unknown as ChainClientInterface
)
).to.throw('chainImplementation wallet and stage are required');
});
it('should throw for invalid stage input', () => {
expect(
() =>
new Orchestrator(
gatewayCoreStore,
messageEventInterface,
instanceId,
{
...inputs,
stage: undefined,
},
fetchConfig,
postMessageTargetCallback,
{} as unknown as ChainClientInterface
)
).to.throw('chainImplementation wallet and stage are required');
});
it('should call getOwnerDids, lookupTokenState and fetchGatekeeperNetworkData', () => {
const chainClientInterface = {

@@ -129,5 +180,7 @@ ownerDids: sandbox.stub().resolves([]),

const spyLookupTokenState = sandbox.spy(orchestrator, 'lookupTokenState');
const spyFetchGatekeeperData = sandbox.spy(orchestrator, 'fetchGatekeeperNetworkData');
orchestrator.initialise();
expect(chainClientInterface.ownerDids).to.be.calledOnce;
expect(spyLookupTokenState).to.be.calledOnce;
expect(spyFetchGatekeeperData).to.be.calledOnce;
});

@@ -134,0 +187,0 @@ });

@@ -5,3 +5,3 @@ import sinon from 'sinon';

import { createGatewayCoreStore, Store } from '../src/state/state';
import { GatekeeperClientConfig } from '../src/types/gatekeeperApi';
import { GatekeeperAPIStatus, GatekeeperClientConfig } from '../src/types/gatekeeperApi';
import { GatekeeperClient } from '../src/gatekeeperClient';

@@ -76,2 +76,3 @@ import { ChainClientInterface, ChainType, ExtendedGatewayStatus, GatewayCoreState } from '../src';

gatekeeperClient.refreshToken = sandbox.stub();
gatekeeperClient.updateTransactionStatus = sandbox.stub().resolves();
});

@@ -275,2 +276,29 @@

});
it('should patch the txId', async () => {
const handleTransactionStub = sandbox.stub().resolves('txId');
chainImplementation = {
httpConfig: {
baseUrl: 'https://example.com',
queryParams: {
network: '0x123',
},
headers: {},
},
handleTransaction: handleTransactionStub,
} as unknown as ChainClientInterface;
const store = createGatewayCoreStore({ name: 'test' });
store.setState((draft) => {
draft.inputs.gatekeeperRecord = {
status: InputStatus.COMPLETE,
received: {
state: GatekeeperAPIStatus.REQUESTED,
transaction: 'test_transaction',
},
};
});
refresh = new Refresh(store, chainImplementation, gatekeeperClient, abortController);
await refresh.sendTransaction();
expect(gatekeeperClient.updateTransactionStatus).to.have.been.calledOnceWith('txId');
});
});

@@ -277,0 +305,0 @@

@@ -213,3 +213,29 @@ import { SinonStubbedInstance } from 'sinon';

});
context('when the event is REQUEST_SIGNED_MESSAGE', () => {
beforeEach(() => {
message = {
request: 'UNKNOWN_EVENT' as CivicSignEventTypeRequest,
payload: 'proof',
};
// sinon
// .stub(chainImplementationStub, 'proveWalletOwnership')
// .withArgs(message.payload?.toString() as string)
// .resolves({ proof: 'test_signedMessage', signatureMethod: SignatureMethod.MESSAGE });
});
it('should call chainImplementation.signMessage with the payload', async () => {
await handleRemoteSignEvent(message, remoteSignerInstStub, {
wallet,
chainImplementation: chainImplementationStub,
});
expect(
handleRemoteSignEvent(message, remoteSignerInstStub, {
wallet,
chainImplementation: chainImplementationStub,
})
).to.be.rejectedWith('No result from remote sign event');
});
});
});
});

@@ -5,3 +5,6 @@ import GatewayClientCore, {

FlowParameters,
FlowStatus,
GatewayInput,
GatewayStatus,
GknData,
PostMessageInterface,

@@ -180,2 +183,7 @@ } from '../src';

};
state.inputs.gatekeeperNetworkData.status = InputStatus.COMPLETE;
state.inputs.gatekeeperNetworkData.received = {
id: 'testId',
chains: {},
};
});

@@ -633,2 +641,10 @@ return store;

UiOnShow() {
this.client.ui.onShow();
}
UiOnHide() {
this.client.ui.onHide();
}
async simulateDataCollectionStatusEvent(validationStatus: ValidationStatus) {

@@ -874,2 +890,12 @@ this.emitter.emit('message', {

expectTokenActiveScreenShown() {
expect(this.clientOutput?.flowState?.status).to.eq(FlowStatus.IN_PROGRESS);
expect(this.clientOutput?.ui?.isVisible).to.be.true;
}
expectTokenActiveScreenHidden() {
expect(this.clientOutput?.flowState?.status).to.eq(FlowStatus.FINISHED);
expect(this.clientOutput?.ui?.isVisible).to.be.false;
}
async simulateUserFinishedFlow(eventOverrides: Partial<CivicPassMessageResponse> = {}) {

@@ -923,2 +949,6 @@ this.emitter.emit('message', {

updateGknData(gknData: GatewayInput<GknData>) {
this.client.updateGatekeeperNetworkServiceData(gknData);
}
expectFlowIdToBeSet(prefix = 'GWRC') {

@@ -925,0 +955,0 @@ expect(this.clientOutput.flowParameters?.flowId).to.be.a('string');

@@ -339,2 +339,9 @@ import { UserInteractionStatus } from '../../src/types/userInteraction';

{
inputs: {
gatekeeperNetworkData: {
client: {
tokenActiveDisplay: 'default',
},
},
},
internal: {

@@ -360,2 +367,9 @@ status: GatewayStatus.CHECKING,

{
inputs: {
gatekeeperNetworkData: {
client: {
tokenActiveDisplay: 'default',
},
},
},
internal: {

@@ -383,2 +397,9 @@ status: GatewayStatus.COLLECTING_USER_INFORMATION,

{
inputs: {
gatekeeperNetworkData: {
client: {
tokenActiveDisplay: 'default',
},
},
},
internal: {

@@ -425,2 +446,66 @@ status: status,

});
it('should return FINISHED if GKN is configured to hide token active screen', () => {
expect(
flowStatusFromState(
{
internal: {
status: GatewayStatus.ACTIVE,
userInteraction: { status: UserInteractionStatus.STARTED },
},
inputs: {
dynamicParameters: {
forceRequireRefresh: true,
},
gatekeeperNetworkData: {
status: 'COMPLETE',
received: {
client: {
tokenActiveDisplay: 'hidden',
},
},
},
},
output: {
flowState: {
status: FlowStatus.IN_PROGRESS,
},
},
} as unknown as GatewayCoreState,
GatewayStatus.ACTIVE
)
).to.equal(FlowStatus.FINISHED);
});
it('should return FINISHED if GKN is configured to hide token active screen, forceRequireRefresh is false and UserInteractionStatus is null', () => {
expect(
flowStatusFromState(
{
internal: {
status: GatewayStatus.ACTIVE,
userInteraction: { status: null },
},
inputs: {
dynamicParameters: {
forceRequireRefresh: false,
},
gatekeeperNetworkData: {
status: 'COMPLETE',
received: {
client: {
tokenActiveDisplay: 'hidden',
},
},
},
},
output: {
flowState: {
status: FlowStatus.IN_PROGRESS,
},
},
} as unknown as GatewayCoreState,
GatewayStatus.ACTIVE
)
).to.equal(FlowStatus.FINISHED);
});
});

@@ -427,0 +512,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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