-
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.
Merge pull request #432 from ERC725Alliance/feat/encoding-features-wi…
…th-docs feat: export methods `getVerificationMethod(..)` and `isDataAuthentic(...)` related to `VerifiableURI` encoding
- Loading branch information
Showing
4 changed files
with
134 additions
and
24 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
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,18 @@ import { | |
convertIPFSGatewayUrl, | ||
generateSchemasFromDynamicKeys, | ||
duplicateMultiTypeERC725SchemaEntry, | ||
getVerificationMethod, | ||
isDataAuthentic, | ||
} 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 | ||
|
@@ -87,7 +94,12 @@ export { | |
}; | ||
|
||
export { ERC725Config, KeyValuePair, ProviderTypes } from './types'; | ||
export { encodeData, encodeArrayKey } from './lib/utils'; | ||
export { | ||
encodeData, | ||
encodeArrayKey, | ||
getVerificationMethod, | ||
isDataAuthentic, | ||
} from './lib/utils'; | ||
export { decodeData } from './lib/decodeData'; | ||
export { encodeKeyName, isDynamicKeyName } from './lib/encodeKeyName'; | ||
export { decodeMappingKey } from './lib/decodeMappingKey'; | ||
|
@@ -684,27 +696,8 @@ export class ERC725 { | |
return mapPermission(permission); | ||
} | ||
|
||
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 | ||
|
@@ -765,6 +758,65 @@ 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); | ||
} | ||
|
||
static isDataAuthentic( | ||
data: string | Uint8Array, | ||
verificationOptions: Verification, | ||
): boolean { | ||
return isDataAuthentic(data, verificationOptions); | ||
} | ||
|
||
isDataAuthentic( | ||
data: string | Uint8Array, | ||
verificationOptions: Verification, | ||
): boolean { | ||
return isDataAuthentic(data, verificationOptions); | ||
} | ||
} | ||
|
||
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
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