-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export function to get verification method
- Loading branch information
Showing
3 changed files
with
115 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
* @author Robert McLeod <@robertdavid010> | ||
* @author Fabian Vogelsteller <[email protected]> | ||
* @author Hugo Masclet <@Hugoo> | ||
* @author Jean Cavallera <@CJ42> | ||
* @date 2020 | ||
*/ | ||
|
||
|
@@ -30,12 +31,17 @@ import { | |
convertIPFSGatewayUrl, | ||
generateSchemasFromDynamicKeys, | ||
duplicateMultiTypeERC725SchemaEntry, | ||
getVerificationMethod, | ||
} from './lib/utils'; | ||
|
||
import { getSchema } from './lib/schemaParser'; | ||
import { isValidSignature } from './lib/isValidSignature'; | ||
|
||
import { DEFAULT_GAS_VALUE } from './constants/constants'; | ||
import { | ||
DEFAULT_GAS_VALUE, | ||
SUPPORTED_VERIFICATION_METHODS, | ||
SUPPORTED_VERIFICATION_METHOD_STRINGS, | ||
} from './constants/constants'; | ||
import { encodeKeyName, isDynamicKeyName } from './lib/encodeKeyName'; | ||
|
||
// Types | ||
|
@@ -82,7 +88,7 @@ export { | |
}; | ||
|
||
export { ERC725Config, KeyValuePair, ProviderTypes } from './types'; | ||
export { encodeData, encodeArrayKey } from './lib/utils'; | ||
export { encodeData, encodeArrayKey, getVerificationMethod } from './lib/utils'; | ||
export { decodeData } from './lib/decodeData'; | ||
export { encodeKeyName, isDynamicKeyName } from './lib/encodeKeyName'; | ||
export { decodeMappingKey } from './lib/decodeMappingKey'; | ||
|
@@ -664,27 +670,8 @@ export class ERC725 { | |
return checkPermissions(requiredPermissions, grantedPermissions); | ||
} | ||
|
||
encodeDataSourceWithHash( | ||
verification: undefined | Verification, | ||
dataSource: string, | ||
): string { | ||
return encodeDataSourceWithHash(verification, dataSource); | ||
} | ||
|
||
static encodeDataSourceWithHash( | ||
verification: undefined | Verification, | ||
dataSource: string, | ||
): string { | ||
return encodeDataSourceWithHash(verification, dataSource); | ||
} | ||
|
||
decodeDataSourceWithHash(value: string): URLDataWithHash { | ||
return decodeDataSourceWithHash(value); | ||
} | ||
|
||
static decodeDataSourceWithHash(value: string): URLDataWithHash { | ||
return decodeDataSourceWithHash(value); | ||
} | ||
// Encoding methods | ||
// ---------------- | ||
|
||
/** | ||
* @param type The valueType to encode the value as | ||
|
@@ -745,6 +732,51 @@ export class ERC725 { | |
): string | URLDataWithHash | number | boolean | null { | ||
return decodeValueContent(valueContent, value); | ||
} | ||
|
||
// External Data Source utilities (`VerifiableURI` and `JSONURI`) | ||
// ---------------------------------------------------------------- | ||
|
||
encodeDataSourceWithHash( | ||
verification: undefined | Verification, | ||
dataSource: string, | ||
): string { | ||
return encodeDataSourceWithHash(verification, dataSource); | ||
} | ||
|
||
static encodeDataSourceWithHash( | ||
verification: undefined | Verification, | ||
dataSource: string, | ||
): string { | ||
return encodeDataSourceWithHash(verification, dataSource); | ||
} | ||
|
||
decodeDataSourceWithHash(value: string): URLDataWithHash { | ||
return decodeDataSourceWithHash(value); | ||
} | ||
|
||
static decodeDataSourceWithHash(value: string): URLDataWithHash { | ||
return decodeDataSourceWithHash(value); | ||
} | ||
|
||
static getVerificationMethod(nameOrSig: string): | ||
| { | ||
method: (data: string | object | Uint8Array | null) => string; | ||
name: SUPPORTED_VERIFICATION_METHOD_STRINGS; | ||
sig: SUPPORTED_VERIFICATION_METHODS; | ||
} | ||
| undefined { | ||
return getVerificationMethod(nameOrSig); | ||
} | ||
|
||
getVerificationMethod(nameOrSig: string): | ||
| { | ||
method: (data: string | object | Uint8Array | null) => string; | ||
name: SUPPORTED_VERIFICATION_METHOD_STRINGS; | ||
sig: SUPPORTED_VERIFICATION_METHODS; | ||
} | ||
| undefined { | ||
return getVerificationMethod(nameOrSig); | ||
} | ||
} | ||
|
||
export default ERC725; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters