@celo/contractkit
Advanced tools
Comparing version 3.2.0 to 4.0.0-beta.1
import * as t from 'io-ts'; | ||
import { ContractKit } from '../../kit'; | ||
import { AccountClaim } from './account'; | ||
import { AttestationServiceURLClaim } from './attestation-service-url'; | ||
import { ClaimTypes } from './types'; | ||
@@ -28,7 +26,3 @@ export declare const KeybaseClaimType: t.TypeC<{ | ||
}>; | ||
export declare const ClaimType: t.UnionC<[t.TypeC<{ | ||
type: t.LiteralC<ClaimTypes.ATTESTATION_SERVICE_URL>; | ||
timestamp: t.NumberC; | ||
url: t.Type<string, string, unknown>; | ||
}>, t.Type<{ | ||
export declare const ClaimType: t.UnionC<[t.Type<{ | ||
type: ClaimTypes.ACCOUNT; | ||
@@ -57,7 +51,3 @@ timestamp: number; | ||
export declare const SignedClaimType: t.TypeC<{ | ||
claim: t.UnionC<[t.TypeC<{ | ||
type: t.LiteralC<ClaimTypes.ATTESTATION_SERVICE_URL>; | ||
timestamp: t.NumberC; | ||
url: t.Type<string, string, unknown>; | ||
}>, t.Type<{ | ||
claim: t.UnionC<[t.Type<{ | ||
type: ClaimTypes.ACCOUNT; | ||
@@ -91,14 +81,6 @@ timestamp: number; | ||
export declare type StorageClaim = t.TypeOf<typeof StorageClaimType>; | ||
export declare type Claim = AttestationServiceURLClaim | DomainClaim | KeybaseClaim | NameClaim | AccountClaim | StorageClaim; | ||
export declare type ClaimPayload<K extends ClaimTypes> = K extends typeof ClaimTypes.DOMAIN ? DomainClaim : K extends typeof ClaimTypes.NAME ? NameClaim : K extends typeof ClaimTypes.KEYBASE ? KeybaseClaim : K extends typeof ClaimTypes.ATTESTATION_SERVICE_URL ? AttestationServiceURLClaim : K extends typeof ClaimTypes.ACCOUNT ? AccountClaim : StorageClaim; | ||
export declare type Claim = DomainClaim | KeybaseClaim | NameClaim | AccountClaim | StorageClaim; | ||
export declare type ClaimPayload<K extends ClaimTypes> = K extends typeof ClaimTypes.DOMAIN ? DomainClaim : K extends typeof ClaimTypes.NAME ? NameClaim : K extends typeof ClaimTypes.KEYBASE ? KeybaseClaim : K extends typeof ClaimTypes.ACCOUNT ? AccountClaim : StorageClaim; | ||
/** @internal */ | ||
export declare const isOfType: <K extends ClaimTypes>(type: K) => (data: Claim) => data is ClaimPayload<K>; | ||
/** | ||
* Validates a claim made by an account, i.e. whether the claim is usable | ||
* @param kit The ContractKit object | ||
* @param claim The claim to validate | ||
* @param address The address that is making the claim | ||
* @returns If valid, returns undefined. If invalid or unable to validate, returns a string with the error | ||
*/ | ||
export declare function validateClaim(kit: ContractKit, claim: Claim, address: string): Promise<string | undefined>; | ||
export declare function hashOfClaim(claim: Claim): string; | ||
@@ -105,0 +87,0 @@ export declare function hashOfClaims(claims: Claim[]): string; |
@@ -25,44 +25,7 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createStorageClaim = exports.createDomainClaim = exports.createNameClaim = exports.serializeClaim = exports.hashOfClaims = exports.hashOfClaim = exports.validateClaim = exports.isOfType = exports.DOMAIN_TXT_HEADER = exports.SignedClaimType = exports.ClaimType = exports.KeybaseClaimType = void 0; | ||
exports.createStorageClaim = exports.createDomainClaim = exports.createNameClaim = exports.serializeClaim = exports.hashOfClaims = exports.hashOfClaim = exports.isOfType = exports.DOMAIN_TXT_HEADER = exports.SignedClaimType = exports.ClaimType = exports.KeybaseClaimType = void 0; | ||
var signatureUtils_1 = require("@celo/utils/lib/signatureUtils"); | ||
var t = __importStar(require("io-ts")); | ||
var account_1 = require("./account"); | ||
var attestation_service_url_1 = require("./attestation-service-url"); | ||
var types_1 = require("./types"); | ||
@@ -92,3 +55,2 @@ exports.KeybaseClaimType = t.type({ | ||
exports.ClaimType = t.union([ | ||
attestation_service_url_1.AttestationServiceURLClaimType, | ||
account_1.AccountClaimType, | ||
@@ -110,23 +72,2 @@ DomainClaimType, | ||
exports.isOfType = isOfType; | ||
/** | ||
* Validates a claim made by an account, i.e. whether the claim is usable | ||
* @param kit The ContractKit object | ||
* @param claim The claim to validate | ||
* @param address The address that is making the claim | ||
* @returns If valid, returns undefined. If invalid or unable to validate, returns a string with the error | ||
*/ | ||
function validateClaim(kit, claim, address) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (claim.type) { | ||
case types_1.ClaimTypes.ATTESTATION_SERVICE_URL: | ||
return [2 /*return*/, (0, attestation_service_url_1.validateAttestationServiceUrl)(kit, claim, address)]; | ||
default: | ||
break; | ||
} | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
} | ||
exports.validateClaim = validateClaim; | ||
function hashOfClaim(claim) { | ||
@@ -133,0 +74,0 @@ return (0, signatureUtils_1.hashMessage)(serializeClaim(claim)); |
@@ -7,3 +7,2 @@ import * as t from 'io-ts'; | ||
export declare enum ClaimTypes { | ||
ATTESTATION_SERVICE_URL = "ATTESTATION_SERVICE_URL", | ||
ACCOUNT = "ACCOUNT", | ||
@@ -18,3 +17,2 @@ DOMAIN = "DOMAIN", | ||
export declare const VERIFIABLE_CLAIM_TYPES: ClaimTypes[]; | ||
export declare const VALIDATABLE_CLAIM_TYPES: ClaimTypes[]; | ||
export declare const SINGULAR_CLAIM_TYPES: ClaimTypes[]; |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SINGULAR_CLAIM_TYPES = exports.VALIDATABLE_CLAIM_TYPES = exports.VERIFIABLE_CLAIM_TYPES = exports.ClaimTypes = exports.now = exports.TimestampType = exports.SignatureType = void 0; | ||
exports.SINGULAR_CLAIM_TYPES = exports.VERIFIABLE_CLAIM_TYPES = exports.ClaimTypes = exports.now = exports.TimestampType = exports.SignatureType = void 0; | ||
var t = __importStar(require("io-ts")); | ||
@@ -36,3 +36,2 @@ exports.SignatureType = t.string; | ||
(function (ClaimTypes) { | ||
ClaimTypes["ATTESTATION_SERVICE_URL"] = "ATTESTATION_SERVICE_URL"; | ||
ClaimTypes["ACCOUNT"] = "ACCOUNT"; | ||
@@ -47,5 +46,3 @@ ClaimTypes["DOMAIN"] = "DOMAIN"; | ||
exports.VERIFIABLE_CLAIM_TYPES = [ClaimTypes.KEYBASE, ClaimTypes.ACCOUNT, ClaimTypes.DOMAIN]; | ||
// Claims whose status can be validated | ||
exports.VALIDATABLE_CLAIM_TYPES = [ClaimTypes.ATTESTATION_SERVICE_URL]; | ||
exports.SINGULAR_CLAIM_TYPES = [ClaimTypes.NAME, ClaimTypes.ATTESTATION_SERVICE_URL]; | ||
exports.SINGULAR_CLAIM_TYPES = [ClaimTypes.NAME]; | ||
//# sourceMappingURL=types.js.map |
@@ -11,7 +11,3 @@ import { Address } from '@celo/base/lib/address'; | ||
export declare const IdentityMetadataType: t.TypeC<{ | ||
claims: t.ArrayC<t.UnionC<[t.TypeC<{ | ||
type: t.LiteralC<ClaimTypes.ATTESTATION_SERVICE_URL>; | ||
timestamp: t.NumberC; | ||
url: t.Type<string, string, unknown>; | ||
}>, t.Type<{ | ||
claims: t.ArrayC<t.UnionC<[t.Type<{ | ||
type: ClaimTypes.ACCOUNT; | ||
@@ -60,6 +56,2 @@ timestamp: number; | ||
} | { | ||
type: ClaimTypes.ATTESTATION_SERVICE_URL; | ||
timestamp: number; | ||
url: string; | ||
} | { | ||
type: ClaimTypes.KEYBASE; | ||
@@ -66,0 +58,0 @@ timestamp: number; |
@@ -162,4 +162,2 @@ "use strict"; | ||
base_1.CeloContract.Attestations, | ||
// TODO ASv2 | ||
// CeloContract.FederatedAttestations, | ||
base_1.CeloContract.Governance, | ||
@@ -166,0 +164,0 @@ base_1.CeloContract.LockedGold, |
@@ -8,21 +8,2 @@ import { StableToken } from '@celo/base'; | ||
import { StableTokenWrapper } from './StableTokenWrapper'; | ||
import { Validator } from './Validators'; | ||
export declare function getSecurityCodePrefix(issuerAddress: Address): string; | ||
interface AttestationRequest { | ||
phoneNumber: string; | ||
account: string; | ||
issuer: string; | ||
salt: string | undefined; | ||
smsRetrieverAppSig: string | undefined; | ||
securityCodePrefix: string | undefined; | ||
language: string | undefined; | ||
phoneNumberSignature: string | undefined; | ||
} | ||
interface GetAttestationRequest { | ||
phoneNumber: string; | ||
account: string; | ||
issuer: string; | ||
salt: string | undefined; | ||
securityCode: string | undefined; | ||
} | ||
export interface AttestationStat { | ||
@@ -51,9 +32,2 @@ completed: number; | ||
} | ||
export interface ActionableAttestation { | ||
issuer: Address; | ||
blockNumber: number; | ||
attestationServiceURL: string; | ||
name: string | undefined; | ||
version: string; | ||
} | ||
export interface UnselectedRequest { | ||
@@ -101,8 +75,2 @@ blockNumber: number; | ||
/** | ||
* @notice Waits for appropriate block numbers for before issuer can be selected | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
waitForSelectingIssuers: (identifier: string, account: Address, timeoutSeconds?: number, pollDurationSeconds?: number) => Promise<void>; | ||
/** | ||
* Returns the issuers of attestations for a phoneNumber/account combo | ||
@@ -135,3 +103,8 @@ * @param identifier Attestation identifier (e.g. phone hash) | ||
*/ | ||
getVerifiedStatus(identifier: string, account: Address, numAttestationsRequired?: number, attestationThreshold?: number): Promise<import("@celo/base").AttestationsStatus>; | ||
getVerifiedStatus(identifier: string, account: Address, numAttestationsRequired?: number, attestationThreshold?: number): Promise<{ | ||
isVerified: boolean; | ||
numAttestationsRemaining: number; | ||
total: number; | ||
completed: number; | ||
}>; | ||
/** | ||
@@ -148,24 +121,2 @@ * Calculates the amount of StableToken required to request Attestations | ||
/** | ||
* Returns an array of attestations that can be completed, along with the issuers' attestation | ||
* service urls | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
getActionableAttestations(identifier: string, account: Address, tries?: number): Promise<ActionableAttestation[]>; | ||
/** | ||
* Returns an array of issuer addresses that were found to not run the attestation service | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
getNonCompliantIssuers(identifier: string, account: Address, tries?: number): Promise<Address[]>; | ||
private makeIsIssuerRunningAttestationService; | ||
/** | ||
* Completes an attestation with the corresponding code | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
* @param issuer The issuer of the attestation | ||
* @param code The code received by the validator | ||
*/ | ||
complete(identifier: string, account: Address, issuer: Address, code: string): Promise<import("@celo/connect").CeloTransactionObject<void>>; | ||
/** | ||
* Returns the attestation signer for the specified account. | ||
@@ -183,10 +134,2 @@ * @param account The address of token rewards are accumulated in. | ||
/** | ||
* Given a list of issuers, finds the matching issuer for a given code | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
* @param code The code received by the validator | ||
* @param issuers The list of potential issuers | ||
*/ | ||
findMatchingIssuer(identifier: string, account: Address, code: string, issuers: string[]): Promise<string | null>; | ||
/** | ||
* Returns the current configuration parameters for the contract. | ||
@@ -216,104 +159,5 @@ * @param tokens List of tokens used for attestation fees. use CeloTokens.getAddresses() to get | ||
lookupIdentifiers(identifiers: string[]): Promise<IdentifierLookupResult>; | ||
/** | ||
* Requests a new attestation | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param attestationsRequested The number of attestations to request | ||
*/ | ||
request(identifier: string, attestationsRequested: number): Promise<import("@celo/connect").CeloTransactionObject<void>>; | ||
/** | ||
* Updates sender's approval status on whether to allow an attestation identifier | ||
* mapping to be transfered from one address to another. | ||
* @param identifier The identifier for this attestation. | ||
* @param index The index of the account in the accounts array. | ||
* @param from The current attestation address to which the identifier is mapped. | ||
* @param to The new address to map to identifier. | ||
* @param status The approval status | ||
*/ | ||
approveTransfer: (identifier: string | number[], index: string | number, from: string, to: string, status: boolean) => import("@celo/connect").CeloTransactionObject<void>; | ||
/** | ||
* Selects the issuers for previously requested attestations for a phone number | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
*/ | ||
selectIssuers(identifier: string): import("@celo/connect").CeloTransactionObject<void>; | ||
/** | ||
* Waits appropriate number of blocks, then selects issuers for previously requested phone number attestations | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
selectIssuersAfterWait(identifier: string, account: string, timeoutSeconds?: number, pollDurationSeconds?: number): Promise<import("@celo/connect").CeloTransactionObject<void>>; | ||
/** | ||
* Reveal phone number to issuer | ||
* @param serviceURL: validator's attestation service URL | ||
* @param body | ||
*/ | ||
revealPhoneNumberToIssuer(serviceURL: string, requestBody: AttestationRequest): Promise<Response>; | ||
/** | ||
* Returns reveal status from validator's attestation service | ||
* @param phoneNumber: attestation's phone number | ||
* @param account: attestation's account | ||
* @param issuer: validator's address | ||
* @param serviceURL: validator's attestation service URL | ||
* @param pepper: phone number privacy pepper | ||
*/ | ||
getRevealStatus(phoneNumber: string, account: Address, issuer: Address, serviceURL: string, pepper?: string): Promise<Response>; | ||
/** | ||
* Returns attestation code for provided security code from validator's attestation service | ||
* @param serviceURL: validator's attestation service URL | ||
* @param body | ||
*/ | ||
getAttestationForSecurityCode(serviceURL: string, requestBody: GetAttestationRequest, signer: Address): Promise<string>; | ||
/** | ||
* Validates a given code by the issuer on-chain | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account The address of the account which requested attestation | ||
* @param issuer The address of the issuer of the attestation | ||
* @param code The code send by the issuer | ||
*/ | ||
validateAttestationCode(identifier: string, account: Address, issuer: Address, code: string): Promise<boolean>; | ||
/** | ||
* Gets the relevant attestation service status for a validator | ||
* @param validator Validator to get the attestation service status for | ||
*/ | ||
getAttestationServiceStatus(validator: Validator): Promise<AttestationServiceStatusResponse>; | ||
revoke(identifer: string, account: Address): Promise<import("@celo/connect").CeloTransactionObject<void>>; | ||
} | ||
export declare enum AttestationServiceStatusState { | ||
NoAttestationSigner = "NoAttestationSigner", | ||
NoMetadataURL = "NoMetadataURL", | ||
InvalidMetadata = "InvalidMetadata", | ||
NoAttestationServiceURL = "NoAttestationServiceURL", | ||
InvalidAttestationServiceURL = "InvalidAttestationServiceURL", | ||
UnreachableAttestationService = "UnreachableAttestationService", | ||
Valid = "Valid", | ||
UnreachableHealthz = "UnreachableHealthz", | ||
Unhealthy = "Unhealthy", | ||
WrongAccount = "WrongAccount", | ||
MetadataTimeout = "MetadataTimeout" | ||
} | ||
export interface AttestationServiceStatusResponse { | ||
name: string; | ||
address: Address; | ||
ecdsaPublicKey: string; | ||
blsPublicKey: string; | ||
affiliation: string | null; | ||
score: BigNumber; | ||
hasAttestationSigner: boolean; | ||
attestationSigner: string; | ||
attestationServiceURL: string | null; | ||
metadataURL: string | null; | ||
okStatus: boolean; | ||
error: null | Error; | ||
smsProviders: string[]; | ||
blacklistedRegionCodes: string[] | null; | ||
rightAccount: boolean; | ||
signer: string; | ||
state: AttestationServiceStatusState; | ||
version: string | null; | ||
ageOfLatestBlock: number | null; | ||
smsProvidersRandomized: boolean | null; | ||
maxDeliveryAttempts: number | null; | ||
maxRerequestMins: number | null; | ||
twilioVerifySidProvided: boolean | null; | ||
} | ||
export declare type AttestationsWrapperType = AttestationsWrapper; | ||
export {}; |
@@ -17,13 +17,2 @@ "use strict"; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -69,23 +58,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AttestationServiceStatusState = exports.AttestationsWrapper = exports.AttestationState = exports.getSecurityCodePrefix = void 0; | ||
exports.AttestationsWrapper = exports.AttestationState = void 0; | ||
var base_1 = require("@celo/base"); | ||
var address_1 = require("@celo/base/lib/address"); | ||
var async_1 = require("@celo/base/lib/async"); | ||
var collections_1 = require("@celo/base/lib/collections"); | ||
var parsing_1 = require("@celo/base/lib/parsing"); | ||
var string_1 = require("@celo/base/lib/string"); | ||
var connect_1 = require("@celo/connect"); | ||
var lib_1 = require("@celo/utils/lib"); | ||
var typed_data_constructors_1 = require("@celo/utils/lib/typed-data-constructors"); | ||
var bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
var cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
var identity_1 = require("../identity"); | ||
var BaseWrapper_1 = require("./BaseWrapper"); | ||
function hashAddressToSingleDigit(address) { | ||
return new bignumber_js_1.default(address.toLowerCase()).modulo(10).toNumber(); | ||
} | ||
function getSecurityCodePrefix(issuerAddress) { | ||
return "".concat(hashAddressToSingleDigit(issuerAddress)); | ||
} | ||
exports.getSecurityCodePrefix = getSecurityCodePrefix; | ||
/** | ||
@@ -100,9 +74,2 @@ * Contract for managing identities | ||
})(AttestationState = exports.AttestationState || (exports.AttestationState = {})); | ||
function parseGetCompletableAttestations(response) { | ||
var metadataURLs = (0, parsing_1.parseSolidityStringArray)(response[2].map(BaseWrapper_1.valueToInt), response[3]); | ||
return (0, collections_1.zip3)(response[0].map(BaseWrapper_1.valueToInt), response[1], metadataURLs).map(function (_a) { | ||
var blockNumber = _a[0], issuer = _a[1], metadataURL = _a[2]; | ||
return ({ blockNumber: blockNumber, issuer: issuer, metadataURL: metadataURL }); | ||
}); | ||
} | ||
var AttestationsWrapper = /** @class */ (function (_super) { | ||
@@ -155,43 +122,2 @@ __extends(AttestationsWrapper, _super); | ||
/** | ||
* @notice Waits for appropriate block numbers for before issuer can be selected | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
_this.waitForSelectingIssuers = function (identifier, account, timeoutSeconds, pollDurationSeconds) { | ||
if (timeoutSeconds === void 0) { timeoutSeconds = 120; } | ||
if (pollDurationSeconds === void 0) { pollDurationSeconds = 1; } | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var startTime, unselectedRequest, waitBlocks, blockNumber; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
startTime = Date.now(); | ||
return [4 /*yield*/, this.getUnselectedRequest(identifier, account)]; | ||
case 1: | ||
unselectedRequest = _a.sent(); | ||
return [4 /*yield*/, this.selectIssuersWaitBlocks()]; | ||
case 2: | ||
waitBlocks = _a.sent(); | ||
if (unselectedRequest.blockNumber === 0) { | ||
throw new Error('No unselectedRequest to wait for'); | ||
} | ||
_a.label = 3; | ||
case 3: | ||
if (!(Date.now() - startTime < timeoutSeconds * 1000)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, this.connection.getBlockNumber()]; | ||
case 4: | ||
blockNumber = _a.sent(); | ||
if (blockNumber >= unselectedRequest.blockNumber + waitBlocks) { | ||
return [2 /*return*/]; | ||
} | ||
return [4 /*yield*/, (0, async_1.sleep)(pollDurationSeconds * 1000)]; | ||
case 5: | ||
_a.sent(); | ||
return [3 /*break*/, 3]; | ||
case 6: throw new Error('Timeout while waiting for selecting issuers'); | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Returns the issuers of attestations for a phoneNumber/account combo | ||
@@ -214,51 +140,2 @@ * @param identifier Attestation identifier (e.g. phone hash) | ||
_this.getAttestationStat = (0, BaseWrapper_1.proxyCall)(_this.contract.methods.getAttestationStats, undefined, function (stat) { return ({ completed: (0, BaseWrapper_1.valueToInt)(stat[0]), total: (0, BaseWrapper_1.valueToInt)(stat[1]) }); }); | ||
_this.makeIsIssuerRunningAttestationService = function (tries) { | ||
if (tries === void 0) { tries = 3; } | ||
return function (arg) { return __awaiter(_this, void 0, void 0, function () { | ||
var metadata, _a, _b, attestationServiceURLClaim, nameClaim, resp, _c, status_1, version, error_1; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
_d.trys.push([0, 5, , 6]); | ||
_b = (_a = identity_1.IdentityMetadataWrapper).fetchFromURL; | ||
return [4 /*yield*/, this.contracts.getAccounts()]; | ||
case 1: return [4 /*yield*/, _b.apply(_a, [_d.sent(), arg.metadataURL, | ||
tries])]; | ||
case 2: | ||
metadata = _d.sent(); | ||
attestationServiceURLClaim = metadata.findClaim(identity_1.ClaimTypes.ATTESTATION_SERVICE_URL); | ||
if (attestationServiceURLClaim === undefined) { | ||
throw new Error("No attestation service URL registered for ".concat(arg.issuer)); | ||
} | ||
nameClaim = metadata.findClaim(identity_1.ClaimTypes.NAME); | ||
return [4 /*yield*/, (0, cross_fetch_1.default)("".concat(attestationServiceURLClaim.url).concat(attestationServiceURLClaim.url.substr(-1) === '/' ? '' : '/', "status"))]; | ||
case 3: | ||
resp = _d.sent(); | ||
if (!resp.ok) { | ||
throw new Error("Request failed with status ".concat(resp.status)); | ||
} | ||
return [4 /*yield*/, resp.json()]; | ||
case 4: | ||
_c = _d.sent(), status_1 = _c.status, version = _c.version; | ||
if (status_1 !== 'ok') { | ||
return [2 /*return*/, { isValid: false, issuer: arg.issuer }]; | ||
} | ||
return [2 /*return*/, { | ||
isValid: true, | ||
result: { | ||
blockNumber: arg.blockNumber, | ||
issuer: arg.issuer, | ||
attestationServiceURL: attestationServiceURLClaim.url, | ||
name: nameClaim ? nameClaim.name : undefined, | ||
version: version, | ||
}, | ||
}]; | ||
case 5: | ||
error_1 = _d.sent(); | ||
return [2 /*return*/, { isValid: false, issuer: arg.issuer }]; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
}; | ||
/** | ||
@@ -281,12 +158,2 @@ * Returns the attestation signer for the specified account. | ||
_this.lookupAccountsForIdentifier = (0, BaseWrapper_1.proxyCall)(_this.contract.methods.lookupAccountsForIdentifier); | ||
/** | ||
* Updates sender's approval status on whether to allow an attestation identifier | ||
* mapping to be transfered from one address to another. | ||
* @param identifier The identifier for this attestation. | ||
* @param index The index of the account in the accounts array. | ||
* @param from The current attestation address to which the identifier is mapped. | ||
* @param to The new address to map to identifier. | ||
* @param status The approval status | ||
*/ | ||
_this.approveTransfer = (0, BaseWrapper_1.proxySend)(_this.connection, _this.contract.methods.approveTransfer); | ||
return _this; | ||
@@ -305,4 +172,6 @@ } | ||
AttestationsWrapper.prototype.getVerifiedStatus = function (identifier, account, numAttestationsRequired, attestationThreshold) { | ||
if (numAttestationsRequired === void 0) { numAttestationsRequired = 3; } | ||
if (attestationThreshold === void 0) { attestationThreshold = 0.25; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var attestationStats; | ||
var stats, numAttestationsRemaining, fractionAttestation, isVerified; | ||
return __generator(this, function (_a) { | ||
@@ -312,4 +181,20 @@ switch (_a.label) { | ||
case 1: | ||
attestationStats = _a.sent(); | ||
return [2 /*return*/, lib_1.AttestationUtils.isAccountConsideredVerified(attestationStats, numAttestationsRequired, attestationThreshold)]; | ||
stats = _a.sent(); | ||
if (!stats) { | ||
return [2 /*return*/, { | ||
isVerified: false, | ||
numAttestationsRemaining: 0, | ||
total: 0, | ||
completed: 0, | ||
}]; | ||
} | ||
numAttestationsRemaining = numAttestationsRequired - stats.completed; | ||
fractionAttestation = stats.total < 1 ? 0 : stats.completed / stats.total; | ||
isVerified = numAttestationsRemaining <= 0 && fractionAttestation >= attestationThreshold; | ||
return [2 /*return*/, { | ||
isVerified: isVerified, | ||
numAttestationsRemaining: numAttestationsRemaining, | ||
total: stats.total, | ||
completed: stats.completed, | ||
}]; | ||
} | ||
@@ -362,116 +247,2 @@ }); | ||
/** | ||
* Returns an array of attestations that can be completed, along with the issuers' attestation | ||
* service urls | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
AttestationsWrapper.prototype.getActionableAttestations = function (identifier, account, tries) { | ||
if (tries === void 0) { tries = 3; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result, results; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.contract.methods | ||
.getCompletableAttestations(identifier, account) | ||
.call()]; | ||
case 1: | ||
result = _a.sent(); | ||
return [4 /*yield*/, (0, async_1.concurrentMap)(5, parseGetCompletableAttestations(result), this.makeIsIssuerRunningAttestationService(tries))]; | ||
case 2: | ||
results = _a.sent(); | ||
return [2 /*return*/, results.map(function (_) { return (_.isValid ? _.result : null); }).filter(collections_1.notEmpty)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Returns an array of issuer addresses that were found to not run the attestation service | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
AttestationsWrapper.prototype.getNonCompliantIssuers = function (identifier, account, tries) { | ||
if (tries === void 0) { tries = 3; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result, withAttestationServiceURLs; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.contract.methods | ||
.getCompletableAttestations(identifier, account) | ||
.call()]; | ||
case 1: | ||
result = _a.sent(); | ||
return [4 /*yield*/, (0, async_1.concurrentMap)(5, parseGetCompletableAttestations(result), this.makeIsIssuerRunningAttestationService(tries))]; | ||
case 2: | ||
withAttestationServiceURLs = _a.sent(); | ||
return [2 /*return*/, withAttestationServiceURLs.map(function (_) { return (_.isValid ? null : _.issuer); }).filter(collections_1.notEmpty)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Completes an attestation with the corresponding code | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
* @param issuer The issuer of the attestation | ||
* @param code The code received by the validator | ||
*/ | ||
AttestationsWrapper.prototype.complete = function (identifier, account, issuer, code) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var accounts, attestationSigner, expectedSourceMessage, _a, r, s, v; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.contracts.getAccounts()]; | ||
case 1: | ||
accounts = _b.sent(); | ||
return [4 /*yield*/, accounts.getAttestationSigner(issuer)]; | ||
case 2: | ||
attestationSigner = _b.sent(); | ||
expectedSourceMessage = lib_1.AttestationUtils.getAttestationMessageToSignFromIdentifier(identifier, account); | ||
_a = lib_1.SignatureUtils.parseSignature(expectedSourceMessage, code, attestationSigner), r = _a.r, s = _a.s, v = _a.v; | ||
return [2 /*return*/, (0, connect_1.toTransactionObject)(this.connection, this.contract.methods.complete(identifier, v, r, s))]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Given a list of issuers, finds the matching issuer for a given code | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
* @param code The code received by the validator | ||
* @param issuers The list of potential issuers | ||
*/ | ||
AttestationsWrapper.prototype.findMatchingIssuer = function (identifier, account, code, issuers) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var accounts, expectedSourceMessage, _i, issuers_1, issuer, attestationSigner; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.contracts.getAccounts()]; | ||
case 1: | ||
accounts = _a.sent(); | ||
expectedSourceMessage = lib_1.AttestationUtils.getAttestationMessageToSignFromIdentifier(identifier, account); | ||
_i = 0, issuers_1 = issuers; | ||
_a.label = 2; | ||
case 2: | ||
if (!(_i < issuers_1.length)) return [3 /*break*/, 5]; | ||
issuer = issuers_1[_i]; | ||
return [4 /*yield*/, accounts.getAttestationSigner(issuer)]; | ||
case 3: | ||
attestationSigner = _a.sent(); | ||
try { | ||
lib_1.SignatureUtils.parseSignature(expectedSourceMessage, code, attestationSigner); | ||
return [2 /*return*/, issuer]; | ||
} | ||
catch (error) { | ||
return [3 /*break*/, 4]; | ||
} | ||
_a.label = 4; | ||
case 4: | ||
_i++; | ||
return [3 /*break*/, 2]; | ||
case 5: return [2 /*return*/, null]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Returns the current configuration parameters for the contract. | ||
@@ -573,290 +344,2 @@ * @param tokens List of tokens used for attestation fees. use CeloTokens.getAddresses() to get | ||
}; | ||
/** | ||
* Requests a new attestation | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param attestationsRequested The number of attestations to request | ||
*/ | ||
AttestationsWrapper.prototype.request = function (identifier, attestationsRequested) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var contract; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.contracts.getStableToken(base_1.StableToken.cUSD)]; | ||
case 1: | ||
contract = _a.sent(); | ||
return [2 /*return*/, (0, connect_1.toTransactionObject)(this.connection, this.contract.methods.request(identifier, attestationsRequested, contract.address))]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Selects the issuers for previously requested attestations for a phone number | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
*/ | ||
AttestationsWrapper.prototype.selectIssuers = function (identifier) { | ||
return (0, connect_1.toTransactionObject)(this.connection, this.contract.methods.selectIssuers(identifier)); | ||
}; | ||
/** | ||
* Waits appropriate number of blocks, then selects issuers for previously requested phone number attestations | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account Address of the account | ||
*/ | ||
AttestationsWrapper.prototype.selectIssuersAfterWait = function (identifier, account, timeoutSeconds, pollDurationSeconds) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.waitForSelectingIssuers(identifier, account, timeoutSeconds, pollDurationSeconds)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, this.selectIssuers(identifier)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Reveal phone number to issuer | ||
* @param serviceURL: validator's attestation service URL | ||
* @param body | ||
*/ | ||
AttestationsWrapper.prototype.revealPhoneNumberToIssuer = function (serviceURL, requestBody) { | ||
return (0, cross_fetch_1.default)((0, string_1.appendPath)(serviceURL, 'attestations'), { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(requestBody), | ||
}); | ||
}; | ||
/** | ||
* Returns reveal status from validator's attestation service | ||
* @param phoneNumber: attestation's phone number | ||
* @param account: attestation's account | ||
* @param issuer: validator's address | ||
* @param serviceURL: validator's attestation service URL | ||
* @param pepper: phone number privacy pepper | ||
*/ | ||
AttestationsWrapper.prototype.getRevealStatus = function (phoneNumber, account, issuer, serviceURL, pepper) { | ||
var urlParams = new URLSearchParams({ | ||
phoneNumber: phoneNumber, | ||
salt: pepper !== null && pepper !== void 0 ? pepper : '', | ||
issuer: issuer, | ||
account: account, | ||
}); | ||
return (0, cross_fetch_1.default)((0, string_1.appendPath)(serviceURL, 'get_attestations') + '?' + urlParams, { | ||
method: 'GET', | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
}; | ||
/** | ||
* Returns attestation code for provided security code from validator's attestation service | ||
* @param serviceURL: validator's attestation service URL | ||
* @param body | ||
*/ | ||
AttestationsWrapper.prototype.getAttestationForSecurityCode = function (serviceURL, requestBody, signer) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var urlParams, additionalHeaders, signature, response, ok, status, body, _a, _b, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
urlParams = new URLSearchParams({ | ||
phoneNumber: requestBody.phoneNumber, | ||
account: requestBody.account, | ||
issuer: requestBody.issuer, | ||
}); | ||
additionalHeaders = {}; | ||
if (requestBody.salt) { | ||
urlParams.set('salt', requestBody.salt); | ||
} | ||
if (!requestBody.securityCode) return [3 /*break*/, 2]; | ||
urlParams.set('securityCode', requestBody.securityCode); | ||
return [4 /*yield*/, this.connection.signTypedData(signer, (0, typed_data_constructors_1.attestationSecurityCode)(requestBody.securityCode))]; | ||
case 1: | ||
signature = _d.sent(); | ||
additionalHeaders = { | ||
Authentication: lib_1.SignatureUtils.serializeSignature(signature), | ||
}; | ||
_d.label = 2; | ||
case 2: return [4 /*yield*/, (0, cross_fetch_1.default)((0, string_1.appendPath)(serviceURL, 'get_attestations') + '?' + urlParams, { | ||
method: 'GET', | ||
headers: __assign({ 'Content-Type': 'application/json' }, additionalHeaders), | ||
})]; | ||
case 3: | ||
response = _d.sent(); | ||
ok = response.ok, status = response.status; | ||
if (!ok) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, response.json()]; | ||
case 4: | ||
body = _d.sent(); | ||
if (body.attestationCode) { | ||
return [2 /*return*/, body.attestationCode]; | ||
} | ||
_d.label = 5; | ||
case 5: | ||
_a = Error.bind; | ||
_c = (_b = "Error getting security code for ".concat(requestBody.issuer, ". ").concat(status, ": ")).concat; | ||
return [4 /*yield*/, response.text()]; | ||
case 6: throw new (_a.apply(Error, [void 0, _c.apply(_b, [_d.sent()])]))(); | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Validates a given code by the issuer on-chain | ||
* @param identifier Attestation identifier (e.g. phone hash) | ||
* @param account The address of the account which requested attestation | ||
* @param issuer The address of the issuer of the attestation | ||
* @param code The code send by the issuer | ||
*/ | ||
AttestationsWrapper.prototype.validateAttestationCode = function (identifier, account, issuer, code) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var accounts, attestationSigner, expectedSourceMessage, _a, r, s, v, result; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.contracts.getAccounts()]; | ||
case 1: | ||
accounts = _b.sent(); | ||
return [4 /*yield*/, accounts.getAttestationSigner(issuer)]; | ||
case 2: | ||
attestationSigner = _b.sent(); | ||
expectedSourceMessage = lib_1.AttestationUtils.getAttestationMessageToSignFromIdentifier(identifier, account); | ||
_a = lib_1.SignatureUtils.parseSignature(expectedSourceMessage, code, attestationSigner), r = _a.r, s = _a.s, v = _a.v; | ||
return [4 /*yield*/, this.contract.methods | ||
.validateAttestationCode(identifier, account, v, r, s) | ||
.call()]; | ||
case 3: | ||
result = _b.sent(); | ||
return [2 /*return*/, result.toLowerCase() !== address_1.NULL_ADDRESS]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Gets the relevant attestation service status for a validator | ||
* @param validator Validator to get the attestation service status for | ||
*/ | ||
AttestationsWrapper.prototype.getAttestationServiceStatus = function (validator) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var accounts, hasAttestationSigner, attestationSigner, attestationServiceURL, ret, metadataURL, metadata, _a, _b, attestationServiceURLClaim, error_2, statusResponse, statusResponseBody, healthzResponse, healthzResponseBody, error_3, error_4; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, this.contracts.getAccounts()]; | ||
case 1: | ||
accounts = _c.sent(); | ||
return [4 /*yield*/, accounts.hasAuthorizedAttestationSigner(validator.address)]; | ||
case 2: | ||
hasAttestationSigner = _c.sent(); | ||
return [4 /*yield*/, accounts.getAttestationSigner(validator.address)]; | ||
case 3: | ||
attestationSigner = _c.sent(); | ||
ret = __assign(__assign({}, validator), { hasAttestationSigner: hasAttestationSigner, attestationSigner: attestationSigner, attestationServiceURL: null, okStatus: false, error: null, smsProviders: [], blacklistedRegionCodes: [], rightAccount: false, metadataURL: null, state: AttestationServiceStatusState.NoAttestationSigner, version: null, ageOfLatestBlock: null, smsProvidersRandomized: null, maxDeliveryAttempts: null, maxRerequestMins: null, twilioVerifySidProvided: null }); | ||
if (!hasAttestationSigner) { | ||
return [2 /*return*/, ret]; | ||
} | ||
return [4 /*yield*/, accounts.getMetadataURL(validator.address)]; | ||
case 4: | ||
metadataURL = _c.sent(); | ||
ret.metadataURL = metadataURL; | ||
if (!metadataURL) { | ||
ret.state = AttestationServiceStatusState.NoMetadataURL; | ||
return [2 /*return*/, ret]; | ||
} | ||
if (metadataURL.startsWith('http://')) { | ||
ret.state = AttestationServiceStatusState.InvalidAttestationServiceURL; | ||
return [2 /*return*/, ret]; | ||
} | ||
_c.label = 5; | ||
case 5: | ||
_c.trys.push([5, 8, , 9]); | ||
_b = (_a = identity_1.IdentityMetadataWrapper).fetchFromURL; | ||
return [4 /*yield*/, this.contracts.getAccounts()]; | ||
case 6: return [4 /*yield*/, _b.apply(_a, [_c.sent(), metadataURL])]; | ||
case 7: | ||
metadata = _c.sent(); | ||
attestationServiceURLClaim = metadata.findClaim(identity_1.ClaimTypes.ATTESTATION_SERVICE_URL); | ||
if (!attestationServiceURLClaim) { | ||
ret.state = AttestationServiceStatusState.NoAttestationServiceURL; | ||
return [2 /*return*/, ret]; | ||
} | ||
attestationServiceURL = attestationServiceURLClaim.url; | ||
return [3 /*break*/, 9]; | ||
case 8: | ||
error_2 = _c.sent(); | ||
ret.state = | ||
error_2.type === 'system' | ||
? AttestationServiceStatusState.MetadataTimeout | ||
: AttestationServiceStatusState.InvalidMetadata; | ||
ret.error = error_2; | ||
return [2 /*return*/, ret]; | ||
case 9: | ||
ret.attestationServiceURL = attestationServiceURL; | ||
_c.label = 10; | ||
case 10: | ||
_c.trys.push([10, 20, , 21]); | ||
return [4 /*yield*/, (0, cross_fetch_1.default)((0, string_1.appendPath)(attestationServiceURL, 'status'))]; | ||
case 11: | ||
statusResponse = _c.sent(); | ||
if (!statusResponse.ok) { | ||
ret.state = AttestationServiceStatusState.UnreachableAttestationService; | ||
return [2 /*return*/, ret]; | ||
} | ||
ret.okStatus = true; | ||
return [4 /*yield*/, statusResponse.json()]; | ||
case 12: | ||
statusResponseBody = _c.sent(); | ||
ret.smsProviders = statusResponseBody.smsProviders; | ||
ret.rightAccount = (0, address_1.eqAddress)(validator.address, statusResponseBody.accountAddress); | ||
ret.state = ret.rightAccount | ||
? AttestationServiceStatusState.Valid | ||
: AttestationServiceStatusState.WrongAccount; | ||
ret.ageOfLatestBlock = statusResponseBody.ageOfLatestBlock; | ||
ret.smsProvidersRandomized = statusResponseBody.smsProvidersRandomized; | ||
ret.maxDeliveryAttempts = statusResponseBody.maxDeliveryAttempts; | ||
ret.maxRerequestMins = statusResponseBody.maxRerequestMins; | ||
ret.twilioVerifySidProvided = statusResponseBody.twilioVerifySidProvided; | ||
if (!statusResponseBody.version) return [3 /*break*/, 18]; | ||
ret.version = statusResponseBody.version; | ||
_c.label = 13; | ||
case 13: | ||
_c.trys.push([13, 16, , 17]); | ||
return [4 /*yield*/, (0, cross_fetch_1.default)((0, string_1.appendPath)(attestationServiceURL, 'healthz'))]; | ||
case 14: | ||
healthzResponse = _c.sent(); | ||
return [4 /*yield*/, healthzResponse.json()]; | ||
case 15: | ||
healthzResponseBody = _c.sent(); | ||
if (!healthzResponse.ok) { | ||
ret.state = AttestationServiceStatusState.Unhealthy; | ||
if (healthzResponseBody.error) { | ||
ret.error = healthzResponseBody.error; | ||
} | ||
} | ||
return [3 /*break*/, 17]; | ||
case 16: | ||
error_3 = _c.sent(); | ||
ret.state = AttestationServiceStatusState.UnreachableHealthz; | ||
return [3 /*break*/, 17]; | ||
case 17: | ||
// Whether or not health check is reachable, also check full node status | ||
// (overrides UnreachableHealthz status) | ||
if ((statusResponseBody.ageOfLatestBlock !== null && | ||
statusResponseBody.ageOfLatestBlock > 10) || | ||
statusResponseBody.isNodeSyncing === true) { | ||
ret.state = AttestationServiceStatusState.Unhealthy; | ||
} | ||
return [3 /*break*/, 19]; | ||
case 18: | ||
// No version implies 1.0.0 | ||
ret.version = '1.0.0'; | ||
_c.label = 19; | ||
case 19: return [3 /*break*/, 21]; | ||
case 20: | ||
error_4 = _c.sent(); | ||
ret.state = AttestationServiceStatusState.UnreachableAttestationService; | ||
ret.error = error_4; | ||
return [3 /*break*/, 21]; | ||
case 21: return [2 /*return*/, ret]; | ||
} | ||
}); | ||
}); | ||
}; | ||
AttestationsWrapper.prototype.revoke = function (identifer, account) { | ||
@@ -882,16 +365,2 @@ return __awaiter(this, void 0, void 0, function () { | ||
exports.AttestationsWrapper = AttestationsWrapper; | ||
var AttestationServiceStatusState; | ||
(function (AttestationServiceStatusState) { | ||
AttestationServiceStatusState["NoAttestationSigner"] = "NoAttestationSigner"; | ||
AttestationServiceStatusState["NoMetadataURL"] = "NoMetadataURL"; | ||
AttestationServiceStatusState["InvalidMetadata"] = "InvalidMetadata"; | ||
AttestationServiceStatusState["NoAttestationServiceURL"] = "NoAttestationServiceURL"; | ||
AttestationServiceStatusState["InvalidAttestationServiceURL"] = "InvalidAttestationServiceURL"; | ||
AttestationServiceStatusState["UnreachableAttestationService"] = "UnreachableAttestationService"; | ||
AttestationServiceStatusState["Valid"] = "Valid"; | ||
AttestationServiceStatusState["UnreachableHealthz"] = "UnreachableHealthz"; | ||
AttestationServiceStatusState["Unhealthy"] = "Unhealthy"; | ||
AttestationServiceStatusState["WrongAccount"] = "WrongAccount"; | ||
AttestationServiceStatusState["MetadataTimeout"] = "MetadataTimeout"; | ||
})(AttestationServiceStatusState = exports.AttestationServiceStatusState || (exports.AttestationServiceStatusState = {})); | ||
//# sourceMappingURL=Attestations.js.map |
{ | ||
"name": "@celo/contractkit", | ||
"version": "3.2.0", | ||
"version": "4.0.0-beta.1", | ||
"description": "Celo's ContractKit to interact with Celo network", | ||
@@ -19,4 +19,5 @@ "main": "./lib/index.js", | ||
"build:ts": "tsc -b .", | ||
"build:gen": "BUILD_DIR=./build/$RELEASE_TAG yarn --cwd ../../protocol ts-node ./scripts/build.ts --web3Types ../sdk/contractkit/src/generated", | ||
"build:gen": "yarn --cwd ../../protocol ts-node ./scripts/build.ts --web3Types ../sdk/contractkit/src/generated", | ||
"build": "yarn build:gen && yarn build:ts", | ||
"build:releasetag": "BUILD_DIR=./build/$RELEASE_TAG yarn build", | ||
"clean": "tsc -b . --clean", | ||
@@ -32,6 +33,6 @@ "clean:all": "yarn clean && rm -rf src/generated", | ||
"dependencies": { | ||
"@celo/base": "3.2.0", | ||
"@celo/connect": "3.2.0", | ||
"@celo/utils": "3.2.0", | ||
"@celo/wallet-local": "3.2.0", | ||
"@celo/base": "4.0.0-beta.1", | ||
"@celo/connect": "4.0.0-beta.1", | ||
"@celo/utils": "4.0.0-beta.1", | ||
"@celo/wallet-local": "4.0.0-beta.1", | ||
"@types/bn.js": "^5.1.0", | ||
@@ -48,3 +49,3 @@ "@types/debug": "^4.1.5", | ||
"devDependencies": { | ||
"@celo/phone-utils": "3.2.0", | ||
"@celo/phone-utils": "4.0.0-beta.1", | ||
"@celo/dev-utils": "0.0.1-dev", | ||
@@ -51,0 +52,0 @@ "@celo/flake-tracker": "0.0.1-dev", |
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
1613504
203
39057
1
+ Added@celo/base@4.0.0-beta.1(transitive)
+ Added@celo/connect@4.0.0-beta.1(transitive)
+ Added@celo/utils@4.0.0-beta.1(transitive)
+ Added@celo/wallet-base@4.0.0-beta.1(transitive)
+ Added@celo/wallet-local@4.0.0-beta.1(transitive)
- Removed@celo/base@3.2.0(transitive)
- Removed@celo/connect@3.2.0(transitive)
- Removed@celo/utils@3.2.0(transitive)
- Removed@celo/wallet-base@3.2.0(transitive)
- Removed@celo/wallet-local@3.2.0(transitive)
Updated@celo/base@4.0.0-beta.1
Updated@celo/connect@4.0.0-beta.1
Updated@celo/utils@4.0.0-beta.1