mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-23 06:59:29 -07:00
change proof format
This commit is contained in:
parent
cbeefbc909
commit
9d3b8f8508
1 changed files with 11 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2021 Yarmo Mackenbach
|
Copyright 2022 Maximilian Siling
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -15,7 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
const E = require('../enums')
|
const E = require('../enums')
|
||||||
|
|
||||||
const reURI = /https:\/\/t.me\/([A-Za-z0-9_]{5,32})\?user=([A-Za-z0-9_]{5,32})/
|
const reURI = /https:\/\/t.me\/([A-Za-z0-9_]{5,32})\?proof=([A-Za-z0-9_]{5,32})/
|
||||||
|
|
||||||
const processURI = (uri) => {
|
const processURI = (uri) => {
|
||||||
const match = uri.match(reURI)
|
const match = uri.match(reURI)
|
||||||
|
@ -30,8 +30,8 @@ const processURI = (uri) => {
|
||||||
isAmbiguous: false
|
isAmbiguous: false
|
||||||
},
|
},
|
||||||
profile: {
|
profile: {
|
||||||
display: `@${match[2]}`,
|
display: `@${match[1]}`,
|
||||||
uri: `https://t.me/${match[2]}`,
|
uri: `https://t.me/${match[1]}`,
|
||||||
qr: null
|
qr: null
|
||||||
},
|
},
|
||||||
proof: {
|
proof: {
|
||||||
|
@ -41,13 +41,13 @@ const processURI = (uri) => {
|
||||||
access: E.ProofAccess.GRANTED,
|
access: E.ProofAccess.GRANTED,
|
||||||
format: E.ProofFormat.JSON,
|
format: E.ProofFormat.JSON,
|
||||||
data: {
|
data: {
|
||||||
chat: match[1],
|
user: match[1],
|
||||||
user: match[2]
|
chat: match[2]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
claim: {
|
claim: {
|
||||||
format: E.ClaimFormat.FINGERPRINT,
|
format: E.ClaimFormat.URI,
|
||||||
relation: E.ClaimRelation.EQUALS,
|
relation: E.ClaimRelation.EQUALS,
|
||||||
path: ['text']
|
path: ['text']
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,11 @@ const processURI = (uri) => {
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
uri: 'https://t.me/foobar?user=alice',
|
uri: 'https://t.me/alice?proof=foobar',
|
||||||
shouldMatch: true
|
shouldMatch: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uri: 'https://t.me/complex_chat_1234?user=complex_user_1234',
|
uri: 'https://t.me/complex_user_1234?proof=complex_chat_1234',
|
||||||
shouldMatch: true
|
shouldMatch: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -68,11 +68,11 @@ const tests = [
|
||||||
shouldMatch: false
|
shouldMatch: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uri: 'https://t.me/foobar?user=',
|
uri: 'https://t.me/foobar?proof=',
|
||||||
shouldMatch: false
|
shouldMatch: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uri: 'https://t.me/?user=foobar',
|
uri: 'https://t.me/?proof=foobar',
|
||||||
shouldMatch: false
|
shouldMatch: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue