Skip to content

Commit 1b35dd1

Browse files
committed
feat(n8n): implement login JSON RPC method
1 parent 544ce05 commit 1b35dd1

File tree

1 file changed

+314
-2
lines changed

1 file changed

+314
-2
lines changed

n8n/workflows.json

Lines changed: 314 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13722,6 +13722,28 @@
1372213722
]
1372313723
]
1372413724
},
13725+
"Edit Fields7": {
13726+
"main": [
13727+
[
13728+
{
13729+
"index": 0,
13730+
"node": "Save Account ID and Private Key",
13731+
"type": "main"
13732+
}
13733+
]
13734+
]
13735+
},
13736+
"Generate Key Pair": {
13737+
"main": [
13738+
[
13739+
{
13740+
"index": 0,
13741+
"node": "Respond to Webhook1",
13742+
"type": "main"
13743+
}
13744+
]
13745+
]
13746+
},
1372513747
"Get Account Balance": {
1372613748
"main": [
1372713749
[
@@ -13982,9 +14004,42 @@
1398214004
]
1398314005
]
1398414006
},
14007+
"Respond to Webhook1": {
14008+
"main": [
14009+
[
14010+
{
14011+
"index": 0,
14012+
"node": "Wait for Signing",
14013+
"type": "main"
14014+
}
14015+
]
14016+
]
14017+
},
14018+
"Save Account ID and Private Key": {
14019+
"main": [
14020+
[
14021+
]
14022+
]
14023+
},
14024+
"Sign Message": {
14025+
"main": [
14026+
[
14027+
{
14028+
"index": 0,
14029+
"node": "Edit Fields7",
14030+
"type": "main"
14031+
}
14032+
]
14033+
]
14034+
},
1398514035
"Switch": {
1398614036
"main": [
1398714037
[
14038+
{
14039+
"index": 0,
14040+
"node": "Generate Key Pair",
14041+
"type": "main"
14042+
}
1398814043
],
1398914044
[
1399014045
{
@@ -14119,6 +14174,17 @@
1411914174
]
1412014175
]
1412114176
},
14177+
"Wait for Signing": {
14178+
"main": [
14179+
[
14180+
{
14181+
"index": 0,
14182+
"node": "Sign Message",
14183+
"type": "main"
14184+
}
14185+
]
14186+
]
14187+
},
1412214188
"Webhook": {
1412314189
"main": [
1412414190
[
@@ -16057,6 +16123,252 @@
1605716123
],
1605816124
"type": "n8n-nodes-base.postgres",
1605916125
"typeVersion": 2.6
16126+
},
16127+
{
16128+
"id": "34fa1c97-ac0f-4cdb-a716-a8468edfc508",
16129+
"name": "Generate Key Pair",
16130+
"parameters": {
16131+
},
16132+
"position": [
16133+
2280,
16134+
-540
16135+
],
16136+
"type": "@dapplets/n8n-nodes-near-protocol.generateKeyPair",
16137+
"typeVersion": 1
16138+
},
16139+
{
16140+
"id": "6639d8e0-d163-4248-903d-74177b7c535b",
16141+
"name": "Wait for Signing",
16142+
"parameters": {
16143+
"options": {
16144+
"responseHeaders": {
16145+
"entries": [
16146+
{
16147+
"name": "Location",
16148+
"value": "https://t.me/dapplets_receiver_bot"
16149+
}
16150+
]
16151+
},
16152+
"webhookSuffix": "webhook"
16153+
},
16154+
"responseCode": 307,
16155+
"resume": "webhook"
16156+
},
16157+
"position": [
16158+
2700,
16159+
-540
16160+
],
16161+
"type": "n8n-nodes-base.wait",
16162+
"typeVersion": 1.1,
16163+
"webhookId": "2e40ae99-751e-462e-853a-3a3f324ff191"
16164+
},
16165+
{
16166+
"credentials": {
16167+
"postgres": {
16168+
"id": "8ZOLCkWqvhw8gGkU",
16169+
"name": "Postgres account"
16170+
}
16171+
},
16172+
"id": "bea8f86b-2613-44f4-89ea-cf86fddc7cdb",
16173+
"name": "Save Account ID and Private Key",
16174+
"parameters": {
16175+
"columns": {
16176+
"attemptToConvertTypes": false,
16177+
"convertFieldsToString": false,
16178+
"mappingMode": "defineBelow",
16179+
"matchingColumns": [
16180+
"id"
16181+
],
16182+
"schema": [
16183+
{
16184+
"canBeUsedToMatch": true,
16185+
"defaultMatch": true,
16186+
"display": true,
16187+
"displayName": "id",
16188+
"id": "id",
16189+
"removed": false,
16190+
"required": false,
16191+
"type": "number"
16192+
},
16193+
{
16194+
"canBeUsedToMatch": false,
16195+
"defaultMatch": false,
16196+
"display": true,
16197+
"displayName": "username",
16198+
"id": "username",
16199+
"removed": false,
16200+
"required": true,
16201+
"type": "string"
16202+
},
16203+
{
16204+
"canBeUsedToMatch": false,
16205+
"defaultMatch": false,
16206+
"display": true,
16207+
"displayName": "status",
16208+
"id": "status",
16209+
"removed": true,
16210+
"required": false,
16211+
"type": "boolean"
16212+
},
16213+
{
16214+
"canBeUsedToMatch": false,
16215+
"defaultMatch": false,
16216+
"display": true,
16217+
"displayName": "near_account_id",
16218+
"id": "near_account_id",
16219+
"removed": false,
16220+
"required": false,
16221+
"type": "string"
16222+
},
16223+
{
16224+
"canBeUsedToMatch": false,
16225+
"defaultMatch": false,
16226+
"display": true,
16227+
"displayName": "private_key",
16228+
"id": "private_key",
16229+
"required": false,
16230+
"type": "string"
16231+
},
16232+
{
16233+
"canBeUsedToMatch": false,
16234+
"defaultMatch": false,
16235+
"display": true,
16236+
"displayName": "network_id",
16237+
"id": "network_id",
16238+
"removed": true,
16239+
"required": false,
16240+
"type": "string"
16241+
},
16242+
{
16243+
"canBeUsedToMatch": false,
16244+
"defaultMatch": false,
16245+
"display": true,
16246+
"displayName": "nearai_token",
16247+
"id": "nearai_token",
16248+
"removed": false,
16249+
"required": false,
16250+
"type": "string"
16251+
}
16252+
],
16253+
"value": {
16254+
"id": "={{ $('Parse Auth Token').item.json.authToken.user.id }}",
16255+
"near_account_id": "={{ $('Sign Message').item.json.query.account_id }}",
16256+
"nearai_token": "={{ $json.toJsonString() }}",
16257+
"private_key": "={{ $('Generate Key Pair').item.json.privateKey }}",
16258+
"username": "={{ $('Parse Auth Token').item.json.authToken.user.username }}"
16259+
}
16260+
},
16261+
"operation": "upsert",
16262+
"options": {
16263+
},
16264+
"schema": {
16265+
"__rl": true,
16266+
"mode": "list",
16267+
"value": "public"
16268+
},
16269+
"table": {
16270+
"__rl": true,
16271+
"cachedResultName": "users",
16272+
"mode": "list",
16273+
"value": "users"
16274+
}
16275+
},
16276+
"position": [
16277+
3360,
16278+
-540
16279+
],
16280+
"type": "n8n-nodes-base.postgres",
16281+
"typeVersion": 2.6
16282+
},
16283+
{
16284+
"id": "8d1f8f91-5814-4c45-bbbe-d50efa439771",
16285+
"name": "Sign Message",
16286+
"parameters": {
16287+
"message": "Welcome to NEAR AI Hub!",
16288+
"privateKey": "={{ $('Generate Key Pair').item.json.privateKey }}"
16289+
},
16290+
"position": [
16291+
2920,
16292+
-540
16293+
],
16294+
"type": "@dapplets/n8n-nodes-near-protocol.signMessage",
16295+
"typeVersion": 1
16296+
},
16297+
{
16298+
"id": "6186257e-9532-4388-9a10-ba32e93c8226",
16299+
"name": "Edit Fields7",
16300+
"parameters": {
16301+
"assignments": {
16302+
"assignments": [
16303+
{
16304+
"id": "44766888-4895-43b4-9e15-c4aa934b1c7b",
16305+
"name": "account_id",
16306+
"type": "string",
16307+
"value": "={{ $json.query.account_id }}"
16308+
},
16309+
{
16310+
"id": "b80aa3dd-85b2-4b7a-9f93-1306630d691a",
16311+
"name": "public_key",
16312+
"type": "string",
16313+
"value": "={{ $json.publicKey }}"
16314+
},
16315+
{
16316+
"id": "9ddbac24-29ed-48e9-9168-40b07806e7b3",
16317+
"name": "signature",
16318+
"type": "string",
16319+
"value": "={{ $json.signature }}"
16320+
},
16321+
{
16322+
"id": "b38ea797-9597-4e7b-9390-f283727c8a0f",
16323+
"name": "callback_url",
16324+
"type": "string",
16325+
"value": "https://app.near.ai/sign-in/callback"
16326+
},
16327+
{
16328+
"id": "e1f8cb48-3939-4fd9-b2e7-07939314d48a",
16329+
"name": "message",
16330+
"type": "string",
16331+
"value": "Welcome to NEAR AI Hub!"
16332+
},
16333+
{
16334+
"id": "b77ac086-6f8b-4291-a3b5-441c8848f7d2",
16335+
"name": "recipient",
16336+
"type": "string",
16337+
"value": "ai.near"
16338+
},
16339+
{
16340+
"id": "3bebdee3-f363-447f-8a76-92ff2255353f",
16341+
"name": "nonce",
16342+
"type": "string",
16343+
"value": "=0000000000000000000{{ $now.toMillis() }}"
16344+
}
16345+
]
16346+
},
16347+
"options": {
16348+
}
16349+
},
16350+
"position": [
16351+
3140,
16352+
-540
16353+
],
16354+
"type": "n8n-nodes-base.set",
16355+
"typeVersion": 3.4
16356+
},
16357+
{
16358+
"id": "3ed0ae92-0563-4c28-af1c-b262e6aa7ff0",
16359+
"name": "Respond to Webhook1",
16360+
"parameters": {
16361+
"options": {
16362+
},
16363+
"respondWith": "json",
16364+
"responseBody": "={{({\n \"jsonrpc\": \"2.0\", \n \"result\": {\n \"url\": \"https://app.mynearwallet.com/login/?title=Xen+Bot&public_key=\" + $json.publicKey.urlEncode() + \"&contract_id=social.dapplets.near&success_url=\" + $execution.resumeUrl.urlEncode() + \"/webhook\"\n },\n \"error\": $json.error ? { \"message\": $json.error } : undefined,\n \"id\": $('Webhook').item.json.body.id\n})}}"
16365+
},
16366+
"position": [
16367+
2480,
16368+
-540
16369+
],
16370+
"type": "n8n-nodes-base.respondToWebhook",
16371+
"typeVersion": 1.1
1606016372
}
1606116373
],
1606216374
"pinData": {
@@ -16068,8 +16380,8 @@
1606816380
"tags": [
1606916381
],
1607016382
"triggerCount": 1,
16071-
"updatedAt": "2025-04-24T15:29:16.000Z",
16072-
"versionId": "42bab524-945b-4858-b39f-da4543299b00"
16383+
"updatedAt": "2025-04-24T15:33:29.000Z",
16384+
"versionId": "85b3533e-29e0-4f55-bf4c-8bb75da923d3"
1607316385
},
1607416386
{
1607516387
"active": true,

0 commit comments

Comments
 (0)