repl_identity 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 94e3cf9e6e07ce65449951c81b1c935abe08bea7e523d81f8f6e7d16fc6f1c54
4
+ data.tar.gz: 3dedc6bf3191cd170cda9cc123dcbdbf9fd9119fef1e115f59ff2e2f8f0f57db
5
+ SHA512:
6
+ metadata.gz: 4aa3be040fbc10722c1a05a9d548eaa64b38191bb143735209736936b362422b575cf830b6311360208dec4afc8c9574af5f41b9f9408f0b8a893961b1416dc8
7
+ data.tar.gz: b667b0d76c894083f933589a800e12f7eb99d756770bc884847558cba92e8f1ef1afc93b2ba11782743149332730be6981a73d00cac5aabba0077339cc5c3673
@@ -0,0 +1,30 @@
1
+ module ReplIdentity
2
+ class Identity
3
+ attr_reader :audience, :repl_slug, :repl_id, :username
4
+
5
+ def initialize(token)
6
+ stdout, status = Open3.capture2(
7
+ REPLIT_CLI_PATH, "identity", "verify",
8
+ "-audience=#{REPL_ID}",
9
+ "-token=#{token}",
10
+ "-json"
11
+ )
12
+ print "\r" + "\e[A\e[K" unless status.success? # Remove error message from replit process
13
+
14
+ identity = status.success? ? JSON.parse(stdout) : {}
15
+
16
+ @verified = status.success?
17
+ @audience = identity["aud"]
18
+ @repl_slug = identity["slug"]
19
+ @username = identity["user"]
20
+ @repl_id = identity["replid"]
21
+ @origin = identity["origin"]
22
+ @ephemeral = identity["ephemeral"]
23
+ @origin_repl_id = identity["originReplid"]
24
+ end
25
+
26
+ def verified?
27
+ @verified
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ module ReplIdentity
2
+ class Token
3
+ def initialize(audience)
4
+ token, status = Open3.capture2(
5
+ REPLIT_CLI_PATH, "identity", "create",
6
+ "-audience=#{audience}"
7
+ )
8
+
9
+ raise "Something went wrong" unless status.success?
10
+
11
+ @token = token.strip
12
+ end
13
+
14
+ def to_s
15
+ @token
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ require "json"
2
+ require "open3"
3
+
4
+ require_relative "repl_identity/token"
5
+ require_relative "repl_identity/identity"
6
+
7
+ module ReplIdentity
8
+ VERSION = "0.1.0"
9
+ REPL_ID = ENV["REPL_ID"]
10
+ REPLIT_CLI_PATH = ENV.fetch("REPLIT_CLI", "replit")
11
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: repl_identity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - CodingCactus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: With this gem, you can easily create and verify Repl Identity functions
14
+ for use in your secure cover page console repls.
15
+ email: codingcactus.cc@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/repl_identity.rb
21
+ - lib/repl_identity/identity.rb
22
+ - lib/repl_identity/token.rb
23
+ homepage: https://github.com/Coding-Cactus/repl_identityrb
24
+ licenses:
25
+ - MIT
26
+ metadata:
27
+ source_code_uri: https://github.com/Coding-Cactus/repl_identityrb
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.2.24
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: A simple gem for working with Repl Identites
47
+ test_files: []