oydid 0.2.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/oydid.rb +56 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fdd0883f0c8f620e7e0df179e0665ce3e5833dc50571e29ca9f2035a7336168
|
4
|
+
data.tar.gz: 65588a5899cd069a8bd35d1ab56cf28753e3e3ec7ffcc0781820a1cd253fa701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d8ed1a2114b02c387ad6db5602b82f5b2732be81072ed3f9ea294c036c3e0344eadd93a1aebac9c1321ff406d9e56d63f4e6e2bd126f34575ae64d7c6e092d7
|
7
|
+
data.tar.gz: 6e635a8121304254b70f17a08315e9be4fc654d818e49be1246e2bea9aae24ab0d27548fb697c62dcc7eae6ba0ce9d6c09f75da291b6831dd603683a68c67639
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2
|
1
|
+
0.3.2
|
data/lib/oydid.rb
CHANGED
@@ -139,9 +139,9 @@ class Oydid
|
|
139
139
|
|
140
140
|
def self.generate_base(content, did, mode, options)
|
141
141
|
# input validation
|
142
|
-
did_doc = JSON.parse(content.to_json) rescue
|
143
|
-
if did_doc
|
144
|
-
return [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "
|
142
|
+
did_doc = JSON.parse(content.to_json) rescue nil
|
143
|
+
if did_doc.nil?
|
144
|
+
return [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "invalid payload"]
|
145
145
|
end
|
146
146
|
did_old = nil
|
147
147
|
log_old = nil
|
@@ -275,7 +275,7 @@ class Oydid
|
|
275
275
|
pubRevoKey_old = public_key(revocationKey_old).first
|
276
276
|
did_key_old = publicKey_old + ":" + pubRevoKey_old
|
277
277
|
subDid = {"doc": did_old_doc, "key": did_key_old}.to_json
|
278
|
-
subDidHash = hash(subDid)
|
278
|
+
subDidHash = hash(canonical(subDid))
|
279
279
|
signedSubDidHash = sign(subDidHash, revocationKey_old).first
|
280
280
|
revocationLog = {
|
281
281
|
"ts": ts_old,
|
@@ -467,7 +467,7 @@ class Oydid
|
|
467
467
|
end
|
468
468
|
end
|
469
469
|
|
470
|
-
def self.
|
470
|
+
def self.revoke_base(did, options)
|
471
471
|
did_orig = did.dup
|
472
472
|
doc_location = options[:doc_location]
|
473
473
|
if options[:ts].nil?
|
@@ -498,25 +498,40 @@ class Oydid
|
|
498
498
|
did_old = did.dup
|
499
499
|
did10_old = did10.dup
|
500
500
|
log_old = did_info["log"]
|
501
|
-
privateKey_old = read_private_storage(did10_old + "_private_key.b58")
|
502
|
-
revocationKey_old = read_private_storage(did10_old + "_revocation_key.b58")
|
503
501
|
|
504
|
-
if options[:
|
505
|
-
if options[:
|
506
|
-
if options[:
|
507
|
-
|
502
|
+
if options[:old_doc_key].nil?
|
503
|
+
if options[:old_doc_enc].nil?
|
504
|
+
if options[:old_doc_pwd].nil?
|
505
|
+
privateKey_old = read_private_storage(did10_old + "_private_key.b58")
|
508
506
|
else
|
509
|
-
|
507
|
+
privateKey_old, msg = generate_private_key(options[:old_doc_pwd].to_s, 'ed25519-priv')
|
508
|
+
end
|
509
|
+
else
|
510
|
+
privateKey_old, msg = decode_private_key(options[:old_doc_enc].to_s)
|
511
|
+
end
|
512
|
+
else
|
513
|
+
privateKey_old, msg = read_private_key(options[:old_doc_key].to_s)
|
514
|
+
end
|
515
|
+
if privateKey_old.nil?
|
516
|
+
return [nil, "invalid or missing old private document key"]
|
517
|
+
end
|
518
|
+
if options[:old_rev_key].nil?
|
519
|
+
if options[:old_rev_enc].nil?
|
520
|
+
if options[:old_rev_pwd].nil?
|
521
|
+
revocationKey_old = read_private_storage(did10_old + "_revocation_key.b58")
|
522
|
+
else
|
523
|
+
revocationKey_old, msg = generate_private_key(options[:old_rev_pwd].to_s, 'ed25519-priv')
|
510
524
|
end
|
511
525
|
else
|
512
|
-
|
526
|
+
revocationKey_old, msg = decode_private_key(options[:old_rev_enc].to_s)
|
513
527
|
end
|
514
528
|
else
|
515
|
-
|
529
|
+
revocationKey_old, msg = read_private_key(options[:old_rev_key].to_s)
|
516
530
|
end
|
517
|
-
if
|
518
|
-
return [nil, "private key
|
531
|
+
if revocationKey_old.nil?
|
532
|
+
return [nil, "invalid or missing old private revocation key"]
|
519
533
|
end
|
534
|
+
|
520
535
|
if options[:rev_key].nil? && options[:rev_pwd].nil? && options[:rev_enc].nil?
|
521
536
|
revocationKey, msg = read_private_key(did10 + "_revocation_key.b58")
|
522
537
|
revocationLog = read_private_storage(did10 + "_revocation.json")
|
@@ -537,8 +552,8 @@ class Oydid
|
|
537
552
|
pubRevoKey_old = public_key(revocationKey_old).first
|
538
553
|
did_key_old = publicKey_old + ":" + pubRevoKey_old
|
539
554
|
subDid = {"doc": did_old_doc, "key": did_key_old}.to_json
|
540
|
-
subDidHash = hash(subDid)
|
541
|
-
signedSubDidHash = sign(subDidHash,
|
555
|
+
subDidHash = hash(canonical(subDid))
|
556
|
+
signedSubDidHash = sign(subDidHash, revocationKey_old).first
|
542
557
|
revocationLog = {
|
543
558
|
"ts": ts_old,
|
544
559
|
"op": 1, # REVOKE
|
@@ -555,7 +570,18 @@ class Oydid
|
|
555
570
|
hash(canonical(log_old[did_info["doc_log_id"].to_i])),
|
556
571
|
hash(canonical(log_old[did_info["termination_log_id"].to_i]))
|
557
572
|
]
|
573
|
+
return [revoc_log, ""]
|
574
|
+
end
|
558
575
|
|
576
|
+
def self.revoke_publish(did, revoc_log, options)
|
577
|
+
did_hash = did.delete_prefix("did:oyd:")
|
578
|
+
did10 = did_hash[0,10]
|
579
|
+
doc_location = options[:doc_location]
|
580
|
+
if did_hash.include?(LOCATION_PREFIX)
|
581
|
+
hash_split = did_hash.split(LOCATION_PREFIX)
|
582
|
+
did_hash = hash_split[0]
|
583
|
+
doc_location = hash_split[1]
|
584
|
+
end
|
559
585
|
if doc_location.to_s == ""
|
560
586
|
doc_location = DEFAULT_LOCATION
|
561
587
|
end
|
@@ -563,22 +589,29 @@ class Oydid
|
|
563
589
|
# publish revocation log based on location
|
564
590
|
case doc_location.to_s
|
565
591
|
when /^http/
|
566
|
-
retVal = HTTParty.post(doc_location.to_s + "/log/" +
|
592
|
+
retVal = HTTParty.post(doc_location.to_s + "/log/" + did_hash.to_s,
|
567
593
|
headers: { 'Content-Type' => 'application/json' },
|
568
594
|
body: {"log": revoc_log}.to_json )
|
569
595
|
if retVal.code != 200
|
570
|
-
msg = retVal.parsed_response("error").to_s rescue "invalid response from " + doc_location.to_s + "/log/" +
|
596
|
+
msg = retVal.parsed_response("error").to_s rescue "invalid response from " + doc_location.to_s + "/log/" + did_hash.to_s
|
571
597
|
return [nil, msg]
|
572
598
|
end
|
573
599
|
else
|
574
|
-
File.write(did10 + ".log",
|
600
|
+
File.write(did10 + ".log", revoc_log.to_json)
|
575
601
|
if !did_old.nil?
|
576
|
-
File.write(did10_old + ".log",
|
602
|
+
File.write(did10_old + ".log", revoc_log.to_json)
|
577
603
|
end
|
578
604
|
end
|
579
605
|
|
580
|
-
return [
|
606
|
+
return [did, ""]
|
607
|
+
end
|
581
608
|
|
609
|
+
def self.revoke(did, options)
|
610
|
+
revoc_log, msg = revoke_base(did, options)
|
611
|
+
if revoc_log.nil?
|
612
|
+
return [nil, msg]
|
613
|
+
end
|
614
|
+
success, msg = revoke_publish(did, revoc_log, options)
|
582
615
|
end
|
583
616
|
|
584
617
|
def self.clone(did, options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oydid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Fabianek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dag
|