@civic/gateway-client-core
Advanced tools
Comparing version 1.0.8-beta.0 to 1.0.9-beta.0
# gateway client core | ||
## 1.0.7 - Bugfix - reload on document pass | ||
Fix bug where the UI would be reloaded for document passes when it shouldn't. | ||
## 1.0.6 - Improve analytics | ||
Improvements to analytics to reduce null errorCode fields. | ||
## 1.0.5 - Improve error handling | ||
@@ -4,0 +10,0 @@ - Fix events so we can distinguish between tx failed, dropped, timed out, rejected |
@@ -41,2 +41,3 @@ import { GknData } from '../../src/gatekeeperNetworkService'; | ||
stage?: string; | ||
gatewayStatus?: InternalGatewayStatus | null; | ||
}; | ||
@@ -43,0 +44,0 @@ export type ClientCoreOutput = { |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "@civic/gateway-client-core:1.0.5"; | ||
export declare const VERSION = "@civic/gateway-client-core:1.0.7"; |
{ | ||
"name": "@civic/gateway-client-core", | ||
"version": "1.0.8-beta.0", | ||
"version": "1.0.9-beta.0", | ||
"description": "Sample project for creating typescript library with support of iife and types.", | ||
@@ -5,0 +5,0 @@ "main": "dist/civic-gateway-client-core.min.js", |
@@ -403,4 +403,8 @@ /** | ||
.catch((error) => { | ||
// If the error does not have an errorCode default to POWO_ERROR, | ||
this.gatewayCoreStore.setState((draft) => { | ||
draft.inputs.civicSign.error = error; | ||
const useError = !!error.errorCode | ||
? error | ||
: new ChainError('handleRemoteSignEvent failed', ErrorCode.POWO_ERROR); | ||
draft.inputs.civicSign.error = useError; | ||
draft.inputs.civicSign.status = InputStatus.ERROR; | ||
@@ -407,0 +411,0 @@ }); |
@@ -45,2 +45,3 @@ import { GknData } from '../../src/gatekeeperNetworkService'; | ||
stage?: string; | ||
gatewayStatus?: InternalGatewayStatus | null; // Helps when debugging null errorCodes in analytics events. | ||
}; | ||
@@ -47,0 +48,0 @@ |
import logger from '../logger'; | ||
import { Stage } from '../types/parameters'; | ||
// Auto-generated by 'yarn generate-version' from package.json | ||
// Done on preinstall, prebuild and pretest. | ||
// Done on prepublish and pretest | ||
import { VERSION as CORE_VERSION } from '../../src/version'; | ||
@@ -6,0 +6,0 @@ import { FlowParameters } from '../../src/types/gatewayCore'; |
// This is an auto-generated file. Do not edit. | ||
export const VERSION = '@civic/gateway-client-core:1.0.5'; | ||
export const VERSION = '@civic/gateway-client-core:1.0.7'; |
@@ -10,3 +10,3 @@ import * as R from 'ramda'; | ||
// Auto-generated by 'yarn generate-version' from package.json | ||
// Done on preinstall, prebuild and pretest. | ||
// Done on prepublish and pretest. | ||
import { VERSION as CORE_VERSION } from '../../src/version'; | ||
@@ -17,23 +17,37 @@ | ||
const { expect } = chai; | ||
describe('computeFlowParameters', () => { | ||
let state: GatewayCoreState; | ||
beforeEach(() => { | ||
state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
}, | ||
referrer: 'referrer', | ||
domain: 'domain', | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
}); | ||
afterEach(sandbox.restore); | ||
context('with no wallet, chainDetails, or instanceId', () => { | ||
beforeEach(() => { | ||
state = R.pipe( | ||
R.assocPath(['inputs', 'parameters', 'wallet'], undefined), | ||
R.assocPath(['internal', 'instanceId'], undefined), | ||
R.assocPath(['internal', 'chainDetails'], undefined) | ||
)(state) as GatewayCoreState; | ||
}); | ||
it('should return null', () => { | ||
// Arrange | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: undefined, | ||
}, | ||
dynamicParameters: {}, | ||
}, | ||
internal: { | ||
instanceId: undefined, | ||
chainDetails: undefined, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
const computedInternalStatus = GatewayStatus.UNKNOWN; | ||
// Act | ||
const result = computeFlowParameters(state, computedInternalStatus); | ||
// Assert | ||
expect(result).to.be.null; | ||
@@ -45,23 +59,4 @@ }); | ||
it('should return null', () => { | ||
// Arrange | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
}, | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
const computedInternalStatus = GatewayStatus.UNKNOWN; | ||
// Act | ||
const result = computeFlowParameters(state, computedInternalStatus); | ||
// Assert | ||
expect(result).to.be.null; | ||
@@ -74,19 +69,2 @@ }); | ||
// Arrange | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
}, | ||
chainImplementation: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
did: 'did', | ||
}, | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
}, | ||
} as unknown as GatewayCoreState; | ||
const computedInternalStatus = GatewayStatus.CHECKING; | ||
@@ -106,18 +84,2 @@ // Act | ||
it('should return the action from gatewayStatusToCivicPassAction', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
}, | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
expect(computeFlowParameters(state, computedInternalStatus)).to.containSubset({ | ||
@@ -136,20 +98,6 @@ action: CivicPassMessageAction.TOKEN_IN_REVIEW, | ||
context('with an input flowIdPrefix', () => { | ||
beforeEach(() => { | ||
state = R.assocPath(['inputs', 'parameters', 'flowIdPrefix'], 'TEST_CORE')(state) as GatewayCoreState; | ||
}); | ||
it('should return the flowId from getFlowId with the input prefix', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
}, | ||
flowIdPrefix: 'TEST_CORE', | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
expect(computeFlowParameters(state, computedInternalStatus)?.flowId).to.match(/TEST_CORE_issuance_/); | ||
@@ -161,18 +109,2 @@ }); | ||
it('should return the default flowId prefix', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
}, | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
expect(computeFlowParameters(state, computedInternalStatus)?.flowId).to.match( | ||
@@ -186,20 +118,2 @@ new RegExp(`${DEFAULT_FLOW_ID_PREFIX}_issuance_`, 'gi') | ||
context('referrer and domain', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
}, | ||
referrer: 'referrer', | ||
domain: 'domain', | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
it('should return the referrer from the parameters', () => { | ||
@@ -218,23 +132,6 @@ expect(computeFlowParameters(state, GatewayStatus.ACTIVE)).to.containSubset({ | ||
context('hideWalletPrompts', () => { | ||
beforeEach(() => { | ||
state = R.assocPath(['inputs', 'parameters', 'options', 'hideWalletPrompts'], true)(state) as GatewayCoreState; | ||
}); | ||
it('should be null if the payer is not present', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
options: { | ||
hideWalletPrompts: true, | ||
}, | ||
wallet: { | ||
address: 'address', | ||
}, | ||
referrer: 'referrer', | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)).to.not.containSubset({ | ||
@@ -246,23 +143,3 @@ hideWalletPrompts: true, | ||
it('should be null if the payer is equal to the wallet', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
options: { | ||
hideWalletPrompts: true, | ||
}, | ||
wallet: { | ||
address: 'address', | ||
}, | ||
payer: 'address', | ||
referrer: 'referrer', | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
state = R.assocPath(['inputs', 'parameters', 'payer'], 'address')(state) as GatewayCoreState; | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)).to.not.containSubset({ | ||
@@ -274,23 +151,3 @@ hideWalletPrompts: true, | ||
it('should be returned if the payer is different from the wallet', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
options: { | ||
hideWalletPrompts: true, | ||
}, | ||
wallet: { | ||
address: 'address', | ||
}, | ||
payer: 'payer-address', | ||
referrer: 'referrer', | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
state = R.assocPath(['inputs', 'parameters', 'payer'], 'payer-address')(state) as GatewayCoreState; | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)).to.containSubset({ | ||
@@ -302,30 +159,11 @@ hideWalletPrompts: true, | ||
context('civicClient version', () => { | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
options: { | ||
hideWalletPrompts: true, | ||
}, | ||
wallet: { | ||
address: 'address', | ||
}, | ||
payer: 'payer-address', | ||
referrer: 'referrer', | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
}, | ||
}, | ||
} as unknown as GatewayCoreState; | ||
context('with xCivicClientHeader param passed in', () => { | ||
it('should use the passed-in version', () => { | ||
const stateWithClientVersion: GatewayCoreState = R.assocPath<string, GatewayCoreState>( | ||
beforeEach(() => { | ||
state = R.assocPath<string, GatewayCoreState>( | ||
['inputs', 'parameters', 'xCivicClientHeader'], | ||
'@civic/gateway-client-react:1.1.1' | ||
)(state); | ||
expect(computeFlowParameters(stateWithClientVersion, GatewayStatus.ACTIVE)?.civicClient).to.equal( | ||
}); | ||
it('should use the passed-in version', () => { | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)?.civicClient).to.equal( | ||
'@civic/gateway-client-react:1.1.1' | ||
@@ -342,8 +180,7 @@ ); | ||
context('with empty xCivicClientHeader param passed in', () => { | ||
beforeEach(() => { | ||
state = R.assocPath<string, GatewayCoreState>(['inputs', 'parameters', 'xCivicClientHeader'], '')(state); | ||
}); | ||
it('should use the core package version', () => { | ||
const stateWithClientVersion: GatewayCoreState = R.assocPath<string, GatewayCoreState>( | ||
['inputs', 'parameters', 'xCivicClientHeader'], | ||
'' | ||
)(state); | ||
expect(computeFlowParameters(stateWithClientVersion, GatewayStatus.ACTIVE)?.civicClient).to.equal(CORE_VERSION); | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)?.civicClient).to.equal(CORE_VERSION); | ||
}); | ||
@@ -350,0 +187,0 @@ }); |
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
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
2026771
24537