MCPcopy
hub / github.com/ticarpi/jwt_tool / buildSubclaim

Function buildSubclaim

jwt_tool.py:634–678  ·  view source on GitHub ↗
(newVal, claimList, selection)

Source from the content-addressed store, hash-verified

632 return newInput
633
634def buildSubclaim(newVal, claimList, selection):
635 while True:
636 subList = [0]
637 s = 0
638 for subclaim in newVal:
639 subNum = s+1
640 cprintc("["+str(subNum)+"] "+subclaim+" = "+str(newVal[subclaim]), "white")
641 s += 1
642 subList.append(subclaim)
643 cprintc("["+str(s+1)+"] *ADD A VALUE*", "white")
644 cprintc("["+str(s+2)+"] *DELETE A VALUE*", "white")
645 cprintc("[0] Continue to next step", "white")
646 try:
647 subSel = int(input("> "))
648 except:
649 cprintc("Invalid selection", "red")
650 exit(1)
651 if subSel<=len(newVal) and subSel>0:
652 selClaim = subList[subSel]
653 cprintc("\nCurrent value of "+selClaim+" is: "+str(newVal[selClaim]), "white")
654 cprintc("Please enter new value and hit ENTER", "white")
655 newVal[selClaim] = castInput(input("> "))
656 cprintc("", "white")
657 elif subSel == s+1:
658 cprintc("Please enter new Key and hit ENTER", "white")
659 newPair = input("> ")
660 cprintc("Please enter new value for "+newPair+" and hit ENTER", "white")
661 newVal[newPair] = castInput(input("> "))
662 elif subSel == s+2:
663 cprintc("Please select a Key to DELETE and hit ENTER", "white")
664 s = 0
665 for subclaim in newVal:
666 subNum = s+1
667 cprintc("["+str(subNum)+"] "+subclaim+" = "+str(newVal[subclaim]), "white")
668 subList.append(subclaim)
669 s += 1
670 try:
671 selSub = int(input("> "))
672 except:
673 cprintc("Invalid selection", "red")
674 exit(1)
675 delSub = subList[selSub]
676 del newVal[delSub]
677 elif subSel == 0:
678 return newVal
679
680def testKey(key, sig, contents, headDict, quiet):
681 if headDict["alg"] == "HS256":

Callers 1

tamperTokenFunction · 0.85

Calls 2

cprintcFunction · 0.85
castInputFunction · 0.85

Tested by

no test coverage detected