@civic/gateway-client-core
Advanced tools
Comparing version 1.0.7 to 1.0.8-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 | ||
@@ -10,0 +4,0 @@ - Fix events so we can distinguish between tx failed, dropped, timed out, rejected |
@@ -25,3 +25,4 @@ import { GatekeeperHttpConfig } from './parameters'; | ||
ETHEREUM = "ethereum", | ||
CASPER = "casper" | ||
CASPER = "casper", | ||
ICP = "icp" | ||
} | ||
@@ -28,0 +29,0 @@ export interface ChainImplementationProps { |
@@ -41,3 +41,2 @@ import { GknData } from '../../src/gatekeeperNetworkService'; | ||
stage?: string; | ||
gatewayStatus?: InternalGatewayStatus | null; | ||
}; | ||
@@ -44,0 +43,0 @@ export type ClientCoreOutput = { |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "@civic/gateway-client-core:1.0.7-beta.0"; | ||
export declare const VERSION = "@civic/gateway-client-core:1.0.5"; |
{ | ||
"name": "@civic/gateway-client-core", | ||
"version": "1.0.7", | ||
"version": "1.0.8-beta.0", | ||
"description": "Sample project for creating typescript library with support of iife and types.", | ||
@@ -68,4 +68,3 @@ "main": "dist/civic-gateway-client-core.min.js", | ||
}, | ||
"license": "MIT", | ||
"gitHead": "97a1c0a6df02167e28076967168122c074c3bfc1" | ||
"license": "MIT" | ||
} |
@@ -403,8 +403,4 @@ /** | ||
.catch((error) => { | ||
// If the error does not have an errorCode default to POWO_ERROR, | ||
this.gatewayCoreStore.setState((draft) => { | ||
const useError = !!error.errorCode | ||
? error | ||
: new ChainError('handleRemoteSignEvent failed', ErrorCode.POWO_ERROR); | ||
draft.inputs.civicSign.error = useError; | ||
draft.inputs.civicSign.error = error; | ||
draft.inputs.civicSign.status = InputStatus.ERROR; | ||
@@ -411,0 +407,0 @@ }); |
@@ -30,2 +30,3 @@ import { GatekeeperHttpConfig } from './parameters'; | ||
CASPER = 'casper', | ||
ICP = 'icp', | ||
} | ||
@@ -32,0 +33,0 @@ |
@@ -45,3 +45,2 @@ import { GknData } from '../../src/gatekeeperNetworkService'; | ||
stage?: string; | ||
gatewayStatus?: InternalGatewayStatus | null; // Helps when debugging null errorCodes in analytics events. | ||
}; | ||
@@ -48,0 +47,0 @@ |
import logger from '../logger'; | ||
import { Stage } from '../types/parameters'; | ||
// Auto-generated by 'yarn generate-version' from package.json | ||
// Done on prepublish and pretest | ||
// Done on preinstall, prebuild 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.7'; | ||
export const VERSION = '@civic/gateway-client-core:1.0.5'; |
@@ -10,3 +10,3 @@ import * as R from 'ramda'; | ||
// Auto-generated by 'yarn generate-version' from package.json | ||
// Done on prepublish and pretest. | ||
// Done on preinstall, prebuild and pretest. | ||
import { VERSION as CORE_VERSION } from '../../src/version'; | ||
@@ -17,37 +17,23 @@ | ||
const { expect } = chai; | ||
describe('computeFlowParameters', () => { | ||
let state: GatewayCoreState; | ||
beforeEach(() => { | ||
state = { | ||
inputs: { | ||
parameters: { | ||
wallet: { | ||
address: 'address', | ||
afterEach(sandbox.restore); | ||
context('with no wallet, chainDetails, or instanceId', () => { | ||
it('should return null', () => { | ||
// Arrange | ||
const state = { | ||
inputs: { | ||
parameters: { | ||
wallet: undefined, | ||
}, | ||
referrer: 'referrer', | ||
domain: 'domain', | ||
dynamicParameters: {}, | ||
}, | ||
}, | ||
internal: { | ||
instanceId: 'instanceId', | ||
chainDetails: { | ||
chainType: 'chainType', | ||
chainNetwork: 'chainNetwork', | ||
internal: { | ||
instanceId: undefined, | ||
chainDetails: undefined, | ||
}, | ||
}, | ||
} 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', () => { | ||
} as unknown as GatewayCoreState; | ||
const computedInternalStatus = GatewayStatus.UNKNOWN; | ||
// Act | ||
const result = computeFlowParameters(state, computedInternalStatus); | ||
// Assert | ||
expect(result).to.be.null; | ||
@@ -59,4 +45,23 @@ }); | ||
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; | ||
@@ -69,2 +74,19 @@ }); | ||
// 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; | ||
@@ -84,2 +106,18 @@ // 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({ | ||
@@ -98,6 +136,20 @@ 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_/); | ||
@@ -109,2 +161,18 @@ }); | ||
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( | ||
@@ -118,2 +186,20 @@ 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', () => { | ||
@@ -132,6 +218,23 @@ 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({ | ||
@@ -143,3 +246,23 @@ hideWalletPrompts: true, | ||
it('should be null if the payer is equal to the wallet', () => { | ||
state = R.assocPath(['inputs', 'parameters', 'payer'], 'address')(state) as GatewayCoreState; | ||
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; | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)).to.not.containSubset({ | ||
@@ -151,3 +274,23 @@ hideWalletPrompts: true, | ||
it('should be returned if the payer is different from the wallet', () => { | ||
state = R.assocPath(['inputs', 'parameters', 'payer'], 'payer-address')(state) as GatewayCoreState; | ||
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; | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)).to.containSubset({ | ||
@@ -159,11 +302,30 @@ 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', () => { | ||
beforeEach(() => { | ||
state = R.assocPath<string, GatewayCoreState>( | ||
it('should use the passed-in version', () => { | ||
const stateWithClientVersion: GatewayCoreState = R.assocPath<string, GatewayCoreState>( | ||
['inputs', 'parameters', 'xCivicClientHeader'], | ||
'@civic/gateway-client-react:1.1.1' | ||
)(state); | ||
}); | ||
it('should use the passed-in version', () => { | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)?.civicClient).to.equal( | ||
expect(computeFlowParameters(stateWithClientVersion, GatewayStatus.ACTIVE)?.civicClient).to.equal( | ||
'@civic/gateway-client-react:1.1.1' | ||
@@ -180,7 +342,8 @@ ); | ||
context('with empty xCivicClientHeader param passed in', () => { | ||
beforeEach(() => { | ||
state = R.assocPath<string, GatewayCoreState>(['inputs', 'parameters', 'xCivicClientHeader'], '')(state); | ||
}); | ||
it('should use the core package version', () => { | ||
expect(computeFlowParameters(state, GatewayStatus.ACTIVE)?.civicClient).to.equal(CORE_VERSION); | ||
const stateWithClientVersion: GatewayCoreState = R.assocPath<string, GatewayCoreState>( | ||
['inputs', 'parameters', 'xCivicClientHeader'], | ||
'' | ||
)(state); | ||
expect(computeFlowParameters(stateWithClientVersion, GatewayStatus.ACTIVE)?.civicClient).to.equal(CORE_VERSION); | ||
}); | ||
@@ -187,0 +350,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
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
2029124
187
24688
2