@civic/gateway-client-core
Advanced tools
Comparing version 1.0.3 to 1.0.4-beta.0
@@ -1,1 +0,1 @@ | ||
{"processes":{"6a0bb000-57a6-4b84-938f-e9030ad389a8":{"parent":null,"children":[]},"d42c8e6a-179b-4aef-b80b-e38d6635e2c2":{"parent":null,"children":[]}},"files":{"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/config.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperClient.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/url.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/logger/index.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/logger/local.logger.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/logger/provider.logger.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/log.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/gatekeeperApi.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/chain.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperNetworkService.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/GatewayClientCore.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/orchestrate.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/listeners.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/civicPass.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/civicSign.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/fetch.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/gateway.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/inputs.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/remoteSign.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/issuance.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/orchestratorFlow.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/defaults.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8","d42c8e6a-179b-4aef-b80b-e38d6635e2c2"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/errors.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/expiry.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/refresh.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/userInteraction.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/userInteraction.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/partnerReview.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/common.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/state.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/stateMapping.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/flow.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/flow.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/gatewayStatus.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/error.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/initialisation.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/issuance.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/partnerReview.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/refresh.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/flowParameters.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/utils/object.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/state/ui.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/ui.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/index.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"],"/Users/christiano/Projects/ociv-gatekeeper/packages/gateway-client-core/src/types/eventInterface.ts":["6a0bb000-57a6-4b84-938f-e9030ad389a8"]},"externalIds":{}} | ||
{"processes":{"0541b0bd-ca4e-4566-9ebb-0fa31dbacb04":{"parent":null,"children":[]},"97c010af-9d52-4853-b9fa-8ea887e78759":{"parent":null,"children":[]}},"files":{"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/config.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperClient.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/url.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/index.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/local.logger.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/logger/provider.logger.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/log.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/gatekeeperApi.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/chain.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/gatekeeperNetworkService.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/GatewayClientCore.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/orchestrate.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/listeners.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/civicPass.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/civicSign.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/fetch.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/gateway.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/inputs.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/remoteSign.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/issuance.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/orchestratorFlow.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/defaults.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04","97c010af-9d52-4853-b9fa-8ea887e78759"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/errors.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/expiry.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/refresh.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/userInteraction.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/userInteraction.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/partnerReview.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/common.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/state.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/stateMapping.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/flow.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/flow.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/gatewayStatus.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/error.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/initialisation.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/issuance.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/partnerReview.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/refresh.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/flowParameters.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/utils/object.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/state/ui.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/ui.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/index.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"],"/Users/kevincolgan/code/ociv-gatekeeper/packages/gateway-client-core/src/types/eventInterface.ts":["0541b0bd-ca4e-4566-9ebb-0fa31dbacb04"]},"externalIds":{}} |
# gateway client core | ||
## 1.0.3 - Improve error handling | ||
- fix error handling for solana when signature is required | ||
## 1.0.2 - Improve error handling | ||
@@ -7,0 +4,0 @@ - add new error codes to differentiate user rejection and signature errors |
@@ -57,2 +57,3 @@ import { GatekeeperHttpConfig } from './parameters'; | ||
onDestroy: () => Promise<void>; | ||
signMessage?: (message: Uint8Array) => Promise<Uint8Array>; | ||
} | ||
@@ -59,0 +60,0 @@ export interface ChainLegacy { |
@@ -11,2 +11,6 @@ import { LoggingInterface } from '../logger/provider.logger'; | ||
CHAIN_CONFIRMATION_TIMEOUT_ERROR: string; | ||
TRANSACTION_FAILED_ON_CHAIN_ERROR: string; | ||
TRANSACTION_DROPPED_ERROR: string; | ||
TRANSACTION_CONFIRMATION_UNKNOWN_ERROR: string; | ||
BROWSER_CLOSED_WHILE_TRANSACTION_PENDING: string; | ||
EXPECTED_GATEKEEPER_RECORD: string; | ||
@@ -13,0 +17,0 @@ }; |
{ | ||
"name": "@civic/gateway-client-core", | ||
"version": "1.0.3", | ||
"version": "1.0.4-beta.0", | ||
"description": "Sample project for creating typescript library with support of iife and types.", | ||
@@ -63,3 +63,3 @@ "main": "dist/civic-gateway-client-core.min.js", | ||
"license": "MIT", | ||
"gitHead": "27048fcdb8d8ef0ad445f8bec2feba675f71f550" | ||
"gitHead": "2d97e5aae16a9f3106c8ce6653c49c698935bda7" | ||
} |
@@ -25,9 +25,3 @@ import { LogLevel } from '../types/log'; | ||
this.logger = logger; | ||
if (typeof window !== 'undefined') { | ||
const urlSearchParams = new URLSearchParams(window.location.search); | ||
const urllogLevel = urlSearchParams.get('logLevel') as LogLevel; | ||
this.logLevel = urllogLevel && logLevels.includes(urllogLevel) ? urllogLevel : logLevel; | ||
} else { | ||
this.logLevel = logLevel; | ||
} | ||
this.logLevel = logLevel; | ||
} | ||
@@ -34,0 +28,0 @@ |
@@ -203,4 +203,2 @@ /** | ||
// (in parallel) call chainImplementation.findGatewayToken to get on-chain state | ||
const retrieveGatewayToken = async () => { | ||
@@ -207,0 +205,0 @@ this.gatewayCoreStore.setState((state) => { |
@@ -101,8 +101,11 @@ import { prefixLogger } from './logger'; | ||
// TODO CPASS-1271 Check string vs UintArray | ||
const proveOwnershipResponse = await chainImplementation.proveWalletOwnership(message.payload as string); | ||
if (!chainImplementation.signMessage) { | ||
throw new Error('Chain implementation does not support signMessage'); | ||
} | ||
const signMessageResponse = await chainImplementation.signMessage?.(Buffer.from(message.payload)); | ||
// TODO send back a remote sign error: this requires the iframe to handle this | ||
remoteSignerInst?.sendSignedMessage(Buffer.from(proveOwnershipResponse.proof)); | ||
return proveOwnershipResponse; | ||
remoteSignerInst?.sendSignedMessage(signMessageResponse); | ||
return signMessageResponse; | ||
} | ||
} | ||
}; |
@@ -68,2 +68,3 @@ import { GatekeeperHttpConfig } from './parameters'; | ||
onDestroy: () => Promise<void>; | ||
signMessage?: (message: Uint8Array) => Promise<Uint8Array>; | ||
} | ||
@@ -70,0 +71,0 @@ |
@@ -13,2 +13,6 @@ import logger from '../logger'; | ||
CHAIN_CONFIRMATION_TIMEOUT_ERROR: '0x6', // the tx has been sent but hasn't confirmed on-chain within a timeout | ||
TRANSACTION_FAILED_ON_CHAIN_ERROR: '0x61', // The tx receipt indicates the transaction failed / had an error. | ||
TRANSACTION_DROPPED_ERROR: '0x62', // Transaction not found on-chain after sending it. For Solana, when confirmTransaction times out. | ||
TRANSACTION_CONFIRMATION_UNKNOWN_ERROR: '0x63', // For e.g. Solana confirmTransaction threw some error instead of just timing out. | ||
BROWSER_CLOSED_WHILE_TRANSACTION_PENDING: '0x64', // We use the Beacon API (in no-cors mode) to emit this if the user closes the browser tab while a tx is still in flight | ||
EXPECTED_GATEKEEPER_RECORD: '0x7', // we have a token on chain but no correspondoing record in the gatekeeper | ||
@@ -15,0 +19,0 @@ }; |
@@ -37,44 +37,7 @@ import { expect } from 'chai'; | ||
context('should instantiate a new loggingProvider with the log level from the window', () => { | ||
const originalWindow = global.window; | ||
beforeEach(() => { | ||
global.window = { | ||
location: { | ||
search: '?logLevel=debug', | ||
}, | ||
} as Window & typeof globalThis; | ||
logProvider = new LoggingProvider(console); | ||
}); | ||
afterEach(() => { | ||
// restore window | ||
global.window = originalWindow; | ||
}); | ||
it('log-level should be DEBUG', () => { | ||
logProvider.info('Should log this'); | ||
expect(spyInfo.called).to.be.true; | ||
logProvider.debug('Should log this'); | ||
expect(spyDebug.called).to.be.true; | ||
}); | ||
}); | ||
context('should instantiate a new loggingProvider with the default level from the params', () => { | ||
const originalWindow = global.window; | ||
beforeEach(() => { | ||
global.window = { | ||
location: { | ||
search: '', // no log level provided | ||
}, | ||
} as Window & typeof globalThis; | ||
logProvider = new LoggingProvider(console); | ||
}); | ||
afterEach(() => { | ||
// restore window | ||
global.window = originalWindow; | ||
}); | ||
it('log-level should be INFO', () => { | ||
@@ -81,0 +44,0 @@ logProvider.debug('Should not log this'); |
@@ -6,3 +6,3 @@ import sinon, { SinonStub } from 'sinon'; | ||
import { MessageEventInterface, PostMessageInterface, PostMessageTargetCallback } from '../src/types/eventInterface'; | ||
import { FetchConfig } from '../src/types/fetch'; | ||
import { FetchConfig, InputStatus } from '../src/types/fetch'; | ||
import chai from 'chai'; | ||
@@ -15,2 +15,4 @@ import { OrchestratorInputs } from '../src/types/orchestrate'; | ||
import { ListenerManager } from '../src/listeners'; | ||
import * as getGatekeeperNetworkData from '../src/gatekeeperNetworkService'; | ||
import { IntegrationTestHelpers, sleep } from './testSupport'; | ||
@@ -28,3 +30,3 @@ chai.use(chaiSubset); | ||
let fetchImplementationStub: any; | ||
let testHelpers: IntegrationTestHelpers; | ||
let gatewayCoreStore: Store; | ||
@@ -34,3 +36,10 @@ | ||
const dummyGKNData = { test: 'data' } as unknown as getGatekeeperNetworkData.GknData; | ||
let getGatekeeperNetworkDataStub: sinon.SinonStub< | ||
[stage: string, gknId: string], | ||
Promise<getGatekeeperNetworkData.GknData> | ||
>; | ||
beforeEach(() => { | ||
getGatekeeperNetworkDataStub = sandbox.stub(getGatekeeperNetworkData, 'getGatekeeperNetworkData'); | ||
getGatekeeperNetworkDataStub.resolves(dummyGKNData); | ||
gatewayCoreStore = createGatewayCoreStore({ name: 'test' }); | ||
@@ -69,2 +78,3 @@ fetchImplementationStub = sandbox.stub().returns( | ||
}); | ||
context('getRemoteSignInstance', () => { | ||
@@ -190,2 +200,47 @@ it('should return the remoteSignInstance', () => { | ||
}); | ||
context('fetchGatekeeperNetworkData', () => { | ||
let orchestrator: Orchestrator; | ||
beforeEach(() => { | ||
testHelpers = new IntegrationTestHelpers(sandbox, { clientSends: false }); | ||
gatewayCoreStore = testHelpers.getInitializedStore(); | ||
const chainClientInterface = { | ||
ownerDids: sandbox.stub().resolves([]), | ||
} as unknown as ChainClientInterface; | ||
orchestrator = new Orchestrator( | ||
gatewayCoreStore, | ||
messageEventInterface, | ||
instanceId, | ||
inputs, | ||
fetchConfig, | ||
postMessageTargetCallback, | ||
chainClientInterface | ||
); | ||
}); | ||
context('with a successful call', () => { | ||
it('should set the gatekeeperNetworkData', async () => { | ||
await orchestrator.fetchGatekeeperNetworkData(); | ||
await sleep(10); | ||
const state = gatewayCoreStore.getState(); | ||
expect(state.inputs.gatekeeperNetworkData.status).to.equal(InputStatus.COMPLETE); | ||
expect(state.inputs.gatekeeperNetworkData.received).to.deep.eq(dummyGKNData); | ||
}); | ||
}); | ||
context('with a failed call', () => { | ||
let error: Error; | ||
beforeEach(() => { | ||
error = new Error('test error'); | ||
getGatekeeperNetworkDataStub.rejects(error); | ||
}); | ||
it('should set the status to InputStatus.Error', async () => { | ||
await orchestrator.fetchGatekeeperNetworkData(); | ||
await sleep(10); | ||
const state = gatewayCoreStore.getState(); | ||
expect(state.inputs.gatekeeperNetworkData.status).to.equal(InputStatus.ERROR); | ||
expect(state.inputs.gatekeeperNetworkData.error).to.deep.eq(error); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -192,0 +247,0 @@ |
@@ -32,3 +32,3 @@ import { SinonStubbedInstance } from 'sinon'; | ||
proveWalletOwnership: () => {}, | ||
signMessage: () => {}, | ||
signMessage: (useMessage: Uint8Array) => useMessage, | ||
} as unknown as ChainClientInterface; | ||
@@ -179,2 +179,3 @@ | ||
context('when the event is REQUEST_SIGNED_MESSAGE', () => { | ||
let chainImplResponse: Buffer; | ||
beforeEach(() => { | ||
@@ -189,5 +190,8 @@ message = { | ||
.resolves({ proof: 'test_signedMessage', signatureMethod: SignatureMethod.MESSAGE }); | ||
chainImplResponse = Buffer.from('test_signedMessage'); | ||
sandbox.stub(chainImplementationStub, 'signMessage').withArgs(Buffer.from('proof')).resolves(chainImplResponse); | ||
}); | ||
it('should call chainImplementation.signMessage with the payload', async () => { | ||
it('should call chainImplementation.signMessage with a buffer created from the payload', async () => { | ||
await handleRemoteSignEvent(message, remoteSignerInstStub, { | ||
@@ -197,6 +201,6 @@ wallet, | ||
}); | ||
expect(chainImplementationStub.proveWalletOwnership).calledWith('proof'); | ||
expect(chainImplementationStub.signMessage).calledWith(Buffer.from('proof')); | ||
}); | ||
it('should call remoteSigner signMessage with the signedMessage', async () => { | ||
it('should call remoteSigner signMessage with the chainImpl signedMessage response', async () => { | ||
await handleRemoteSignEvent(message, remoteSignerInstStub, { | ||
@@ -206,6 +210,6 @@ wallet, | ||
}); | ||
expect(remoteSignerInstStub.sendSignedMessage).calledWith(Buffer.from('test_signedMessage')); | ||
expect(remoteSignerInstStub.sendSignedMessage).calledWith(chainImplResponse); | ||
}); | ||
it('should return the signedMessage', async () => { | ||
it('should return the chainImpl signedMessage response', async () => { | ||
const response = await handleRemoteSignEvent(message, remoteSignerInstStub, { | ||
@@ -215,7 +219,7 @@ wallet, | ||
}); | ||
expect(response).to.deep.equal({ proof: 'test_signedMessage', signatureMethod: SignatureMethod.MESSAGE }); | ||
expect(response).to.deep.equal(chainImplResponse); | ||
}); | ||
}); | ||
context('when the event is REQUEST_SIGNED_MESSAGE', () => { | ||
context('when the event is UNKNOWN_EVENT', () => { | ||
beforeEach(() => { | ||
@@ -226,19 +230,10 @@ message = { | ||
}; | ||
// 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, { | ||
it('should return undefined', async () => { | ||
const response = await handleRemoteSignEvent(message, remoteSignerInstStub, { | ||
wallet, | ||
chainImplementation: chainImplementationStub, | ||
}); | ||
expect( | ||
handleRemoteSignEvent(message, remoteSignerInstStub, { | ||
wallet, | ||
chainImplementation: chainImplementationStub, | ||
}) | ||
).to.be.rejectedWith('No result from remote sign event'); | ||
expect(response).to.be.undefined; | ||
}); | ||
@@ -245,0 +240,0 @@ }); |
@@ -159,2 +159,3 @@ import GatewayClientCore, { | ||
} as unknown as ChainClientInterface; | ||
this.stubGatekeeperNetworkServiceCall(); | ||
} | ||
@@ -196,2 +197,9 @@ | ||
stubGatekeeperNetworkServiceCall() { | ||
this.fetchStub.callsFake(async () => { | ||
await sleep(10); | ||
return getFetchStub(200, {}); | ||
}); | ||
} | ||
stubGetFetchCall({ getResponsePayload }: { getResponsePayload: [GatekeeperAPIStatus, Record<string, unknown>] }) { | ||
@@ -198,0 +206,0 @@ // stub GK call to check for an existing record |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4322617
25127
2