-
Notifications
You must be signed in to change notification settings - Fork 5
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 #49 from walt-id/feat/polkadot-support
feat: add polkadot support
- Loading branch information
Showing
12 changed files
with
460 additions
and
268 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package id.walt.idp.siwe | ||
|
||
import id.walt.idp.config.IDPConfig | ||
import id.walt.idp.oidc.OIDCSession | ||
import io.ktor.client.* | ||
import io.ktor.client.call.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.plugins.contentnegotiation.* | ||
import io.ktor.client.plugins.logging.* | ||
import io.ktor.client.request.* | ||
import io.ktor.serialization.kotlinx.json.* | ||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.serialization.json.Json | ||
import java.net.URLEncoder | ||
import java.nio.charset.StandardCharsets | ||
|
||
object SiwpManager { | ||
val client = HttpClient(CIO.create { requestTimeout = 0 }) { | ||
install(ContentNegotiation) { | ||
json(Json { | ||
ignoreUnknownKeys = true | ||
}) | ||
} | ||
install(Logging) { | ||
logger = Logger.SIMPLE | ||
level = LogLevel.ALL | ||
} | ||
expectSuccess = false | ||
} | ||
fun verifySignature(session: OIDCSession, message: String, publicKey: String, signature: String): Boolean{ | ||
val nonce= getNonce(message) | ||
if (session.siweSession?.nonce != nonce) { | ||
return false; | ||
} | ||
if (SiweManager.nonceBlacklists.contains(nonce)) { | ||
return false | ||
} | ||
SiweManager.nonceBlacklists.add(nonce) | ||
|
||
|
||
return runBlocking { | ||
val result = client.get("${IDPConfig.config.jsProjectExternalUrl}/Polkadot/test?publicKey=${publicKey}&signature=${signature}&message=${URLEncoder.encode(message, StandardCharsets.UTF_8)}") { | ||
}.body<Boolean>() | ||
return@runBlocking result | ||
} | ||
} | ||
|
||
|
||
fun getAddress(message:String): String{ | ||
val address= message.split(" .").get(0).split(":").last().trim() | ||
return address | ||
} | ||
|
||
fun getNonce(message: String): String{ | ||
val nonce= message.split(".").last().split(":").last().trim() | ||
|
||
return nonce | ||
} | ||
|
||
fun getPublicKey(message: String): String{ | ||
val startIndex = message.indexOf("Public Key: ") | ||
|
||
|
||
val endIndex = message.indexOf(" ", startIndex + 12) | ||
|
||
return message.substring(startIndex + 12, endIndex) | ||
} | ||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,57 @@ | ||
{ | ||
"name": "waltid-idpkit-ui", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"generate": "nuxt generate" | ||
}, | ||
"dependencies": { | ||
"@airgap/beacon-sdk": "^3.3.0", | ||
"@nuxtjs/axios": "^5.13.6", | ||
"@taquito/beacon-wallet": "^15.0.0", | ||
"@taquito/taquito": "^15.0.0", | ||
"@walletconnect/web3-provider": "^1.8.0", | ||
"bootstrap": "^4.6.2", | ||
"bootstrap-vue": "^2.23.1", | ||
"core-js": "^3.26.0", | ||
"ethers": "^5.7.2", | ||
"nuxt": "^2.15.8", | ||
"qrious": "^4.0.2", | ||
"vue": "2.7.14", | ||
"vue-server-renderer": "2.7.14", | ||
"vue-template-compiler": "2.7.14", | ||
"web3modal": "^1.9.9", | ||
"webpack": "^4.46.0", | ||
"@near-wallet-selector/coin98-wallet": "^7.6.0", | ||
"@near-wallet-selector/core": "^7.6.0", | ||
"@near-wallet-selector/default-wallets": "^7.6.0", | ||
"@near-wallet-selector/here-wallet": "^7.6.0", | ||
"@near-wallet-selector/ledger": "^7.6.0", | ||
"@near-wallet-selector/math-wallet": "^7.6.0", | ||
"@near-wallet-selector/meteor-wallet": "^7.6.0", | ||
"@near-wallet-selector/modal-ui": "^7.6.0", | ||
"@near-wallet-selector/my-near-wallet": "^7.6.0", | ||
"@near-wallet-selector/narwallets": "^7.6.0", | ||
"@near-wallet-selector/near-wallet": "^7.6.0", | ||
"@near-wallet-selector/nearfi": "^7.6.0", | ||
"@near-wallet-selector/neth": "^7.6.0", | ||
"@near-wallet-selector/nightly": "^7.6.0", | ||
"@near-wallet-selector/nightly-connect": "^7.6.0", | ||
"@near-wallet-selector/opto-wallet": "^7.6.0", | ||
"@near-wallet-selector/sender": "^7.6.0", | ||
"@near-wallet-selector/wallet-connect": "^7.6.0", | ||
"@near-wallet-selector/welldone-wallet": "^7.6.0", | ||
"@near-wallet-selector/xdefi": "^7.6.0", | ||
"near-api-js": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/types": "~2.15.8" | ||
} | ||
"name": "waltid-idpkit-ui", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "nuxt", | ||
"build": "nuxt build", | ||
"start": "nuxt start", | ||
"generate": "nuxt generate" | ||
}, | ||
"dependencies": { | ||
"@airgap/beacon-sdk": "^3.3.0", | ||
"@near-wallet-selector/coin98-wallet": "^7.6.0", | ||
"@near-wallet-selector/core": "^7.6.0", | ||
"@near-wallet-selector/default-wallets": "^7.6.0", | ||
"@near-wallet-selector/here-wallet": "^7.6.0", | ||
"@near-wallet-selector/ledger": "^7.6.0", | ||
"@near-wallet-selector/math-wallet": "^7.6.0", | ||
"@near-wallet-selector/meteor-wallet": "^7.6.0", | ||
"@near-wallet-selector/modal-ui": "^7.6.0", | ||
"@near-wallet-selector/my-near-wallet": "^7.6.0", | ||
"@near-wallet-selector/narwallets": "^7.6.0", | ||
"@near-wallet-selector/near-wallet": "^7.6.0", | ||
"@near-wallet-selector/nearfi": "^7.6.0", | ||
"@near-wallet-selector/neth": "^7.6.0", | ||
"@near-wallet-selector/nightly": "^7.6.0", | ||
"@near-wallet-selector/nightly-connect": "^7.6.0", | ||
"@near-wallet-selector/opto-wallet": "^7.6.0", | ||
"@near-wallet-selector/sender": "^7.6.0", | ||
"@near-wallet-selector/wallet-connect": "^7.6.0", | ||
"@near-wallet-selector/welldone-wallet": "^7.6.0", | ||
"@near-wallet-selector/xdefi": "^7.6.0", | ||
"@nuxtjs/axios": "^5.13.6", | ||
"@open-wc/webpack-import-meta-loader": "^0.4.7", | ||
"@polkadot/api": "^10.3.2", | ||
"@polkadot/extension-dapp": "^0.45.5", | ||
"@taquito/beacon-wallet": "^15.0.0", | ||
"@taquito/taquito": "^15.0.0", | ||
"@vue/cli-plugin-babel": "^5.0.8", | ||
"@walletconnect/web3-provider": "^1.8.0", | ||
"bootstrap": "^4.6.2", | ||
"bootstrap-vue": "^2.23.1", | ||
"core-js": "^3.26.0", | ||
"ethers": "^5.7.2", | ||
"near-api-js": "^1.1.0", | ||
"nuxt": "^2.15.8", | ||
"qrious": "^4.0.2", | ||
"vue": "2.7.14", | ||
"vue-server-renderer": "2.7.14", | ||
"vue-template-compiler": "2.7.14", | ||
"web3modal": "^1.9.9", | ||
"webpack": "^4.46.0" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/types": "~2.15.8" | ||
} | ||
} |
Oops, something went wrong.