This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.sh
executable file
·53 lines (42 loc) · 1.65 KB
/
login.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
function login {
if [ -z "$FCLI_TLS_PATH" ]; then
echo "Please define path to cert folder: export FCLI_TLS_PATH=\"/path/to/findy-wallet-pwa/tools/env/config/cert\""
exit 1
fi
user="$1"
bot_yaml="$2"
issue="$3"
echo "Login user $user"
export FCLI_CONFIG="./config.yaml"
register_res=$(findy-agent-cli authn register -u $user 2> /dev/null || echo "$register_res")
if [ -z "$register_res" ]; then
# registration failed: no need for registration or cred-def creation
issue=
fi
export FCLI_JWT=$(findy-agent-cli authn login -u $user)
cred_def_id=""
if [ -z "$issue" ]; then
echo "Skipping credential definition creation"
cred_def_id=$(cat cred_def_id)
else
echo "Create schema"
sch_id=$(findy-agent-cli agent create-schema \
--name="degree" \
--version=1.0 name date degree birthdate_dateint timestamp)
# read schema - make sure it's found in ledger
echo "Read schema $sch_id"
schema=$(findy-agent-cli agent get-schema --schema-id $sch_id)
# create cred def
echo "Create cred def with schema id $sch_id"
cred_def_id=$(findy-agent-cli agent create-cred-def \
--id $sch_id --tag "$user")
# read cred def - make sure it's found in ledger
echo "Read cred def $cred_def_id"
cred_def=$(findy-agent-cli agent get-cred-def --id $cred_def_id)
echo $cred_def_id > "./cred_def_id"
fi
# replace cred def id in bot config
sub_cmd='{sub("<CRED_DEF_ID>","'$cred_def_id'")}1'
awk "$sub_cmd" "$bot_yaml.template.yaml" > $bot_yaml
}