code0-license 0.1.0.pre.release.testing → 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 +4 -4
- data/.rspec +0 -0
- data/.rubocop.yml +3 -0
- data/.tool-versions +1 -1
- data/Gemfile +0 -0
- data/Gemfile.lock +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +51 -0
- data/Rakefile +0 -0
- data/lib/code0/license/boundary.rb +0 -0
- data/lib/code0/license/encryptor.rb +0 -0
- data/lib/code0/license/version.rb +1 -1
- data/lib/code0/license.rb +1 -1
- data/sig/code0/license/boundary.rbs +16 -16
- data/sig/code0/license/encryptor.rbs +0 -0
- data/sig/code0/license.rbs +1 -1
- metadata +3 -4
- data/code0-license.gemspec +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8dfaf3a42ef1ce5ff31278efad3b056e7b1ddddea1f7efd2127a1cfe40a84def
|
|
4
|
+
data.tar.gz: 7c8677d8ac90e245476b4693759325046383f59cf81ea2dc44e30b11e855984c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0196591d15caf009be98dd60b476a2642fcd8ae4bc2535b00406eaf134c48a003c4605d1c9999b89db62db1091a50423dabaa18543cbb9e94058dfaa29358689'
|
|
7
|
+
data.tar.gz: f509897df098ea964896d6edf7e08a49de6e1ea113c315d5c620d039b4a62acad09e4b58122b68ea23e9178b4e842c11722eb3733adf18bb587122db5572795e
|
data/.rspec
CHANGED
|
File without changes
|
data/.rubocop.yml
CHANGED
data/.tool-versions
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby 3.2.2
|
|
1
|
+
ruby 3.2.2
|
data/Gemfile
CHANGED
|
File without changes
|
data/Gemfile.lock
CHANGED
|
File without changes
|
data/LICENSE.txt
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
@@ -15,3 +15,54 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
To start using the gem, you need to have a public and private RSA key.
|
|
18
|
+
If you don't have a key pair, you can generate one by running `bin/create_key`
|
|
19
|
+
|
|
20
|
+
To generate a license, use the private key as encryption key:
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
require "code0/license"
|
|
24
|
+
|
|
25
|
+
# read private key from file
|
|
26
|
+
private_key_file = File.read('license_key.key')
|
|
27
|
+
private_key = OpenSSL::PKey::RSA.new(private_key_file)
|
|
28
|
+
|
|
29
|
+
# set private key as encryption key
|
|
30
|
+
Code0::License.encryption_key = private_key
|
|
31
|
+
|
|
32
|
+
# create a license
|
|
33
|
+
license = Code0::License.new(
|
|
34
|
+
{
|
|
35
|
+
'licensee' => { 'company' => 'Code0' }, # content of licensee can be as you want, it just can't be empty
|
|
36
|
+
'start_date' => '2024-05-01', # when is the first date where this license is valid?
|
|
37
|
+
'end_date' => '2025-05-01', # until when is the license valid?
|
|
38
|
+
'restrictions' => {}, # content can be as you wish, can be used to semantically store some restrictions that are evaluated by your application
|
|
39
|
+
'options' => {}, # content can be as you wish, can be used to semantically provide some options of this license
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# export the license
|
|
44
|
+
File.write('license.txt', Code0::License.export(license, 'CODE0'))
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To verify the license in your application, use the public key
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
require "code0/license"
|
|
51
|
+
|
|
52
|
+
# read public key from file
|
|
53
|
+
public_key_file = File.read('license_key.pub')
|
|
54
|
+
public_key = OpenSSL::PKey::RSA.new(public_key_file)
|
|
55
|
+
|
|
56
|
+
# set public key as encryption key
|
|
57
|
+
Code0::License.encryption_key = public_key
|
|
58
|
+
|
|
59
|
+
# load the license
|
|
60
|
+
license = Code0::License.load(File.read('license.txt'))
|
|
61
|
+
|
|
62
|
+
# exit if license is valid or outside of the valid time
|
|
63
|
+
exit unless license.valid?
|
|
64
|
+
exit unless license.in_active_time?
|
|
65
|
+
|
|
66
|
+
# for example, exit if users exceed licensed amount
|
|
67
|
+
exit if User.count > license.restrictions['user_count']
|
|
68
|
+
```
|
data/Rakefile
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/code0/license.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
module Code0
|
|
2
|
-
class License
|
|
3
|
-
module Boundary
|
|
4
|
-
BOUNDARY_END: Regexp
|
|
5
|
-
BOUNDARY_START: Regexp
|
|
6
|
-
|
|
7
|
-
def self.add_boundary: (String, String) -> String
|
|
8
|
-
|
|
9
|
-
def self.pad: (String, Integer) -> String
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def self.remove_boundary: (String) -> String
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
1
|
+
module Code0
|
|
2
|
+
class License
|
|
3
|
+
module Boundary
|
|
4
|
+
BOUNDARY_END: Regexp
|
|
5
|
+
BOUNDARY_START: Regexp
|
|
6
|
+
|
|
7
|
+
def self.add_boundary: (String, String) -> String
|
|
8
|
+
|
|
9
|
+
def self.pad: (String, Integer) -> String
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def self.remove_boundary: (String) -> String
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
File without changes
|
data/sig/code0/license.rbs
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: code0-license
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Niklas van Schrick
|
|
@@ -95,7 +95,6 @@ files:
|
|
|
95
95
|
- LICENSE.txt
|
|
96
96
|
- README.md
|
|
97
97
|
- Rakefile
|
|
98
|
-
- code0-license.gemspec
|
|
99
98
|
- lib/code0/license.rb
|
|
100
99
|
- lib/code0/license/boundary.rb
|
|
101
100
|
- lib/code0/license/encryptor.rb
|
|
@@ -122,9 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
122
121
|
version: 3.0.0
|
|
123
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
123
|
requirements:
|
|
125
|
-
- - "
|
|
124
|
+
- - ">="
|
|
126
125
|
- !ruby/object:Gem::Version
|
|
127
|
-
version:
|
|
126
|
+
version: '0'
|
|
128
127
|
requirements: []
|
|
129
128
|
rubygems_version: 3.4.10
|
|
130
129
|
signing_key:
|
data/code0-license.gemspec
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "lib/code0/license/version"
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = "code0-license"
|
|
7
|
-
spec.version = Code0::License::VERSION
|
|
8
|
-
spec.authors = ["Niklas van Schrick"]
|
|
9
|
-
spec.email = ["mc.taucher2003@gmail.com"]
|
|
10
|
-
|
|
11
|
-
spec.summary = "code0-license is used to validate software licenses"
|
|
12
|
-
spec.homepage = "https://github.com/code0-tech/code0-license"
|
|
13
|
-
spec.license = "MIT"
|
|
14
|
-
spec.required_ruby_version = ">= 3.0.0"
|
|
15
|
-
|
|
16
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
|
18
|
-
spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"
|
|
19
|
-
|
|
20
|
-
# Specify which files should be added to the gem when it is released.
|
|
21
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
-
spec.files = Dir.chdir(__dir__) do
|
|
23
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
|
24
|
-
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ spec/ .git .github])
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
spec.bindir = "exe"
|
|
28
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
29
|
-
spec.require_paths = ["lib"]
|
|
30
|
-
|
|
31
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
|
32
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
|
33
|
-
spec.add_development_dependency "rubocop", "~> 1.21"
|
|
34
|
-
spec.add_development_dependency "rubocop-rake", "~> 0.6"
|
|
35
|
-
spec.add_development_dependency "rubocop-rspec", "~> 2.29"
|
|
36
|
-
spec.metadata["rubygems_mfa_required"] = "true"
|
|
37
|
-
end
|