code0-license 0.1.0.pre.release.testing → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 +1 -1
- data/LICENSE.txt +0 -0
- data/README.md +51 -0
- data/Rakefile +0 -0
- data/keys/.keep +0 -0
- data/lib/code0/license/boundary.rb +1 -1
- data/lib/code0/license/encryptor.rb +1 -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 +5 -5
- 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: 5a281a7c0e54d55b72eaf40910fe789b9cb96418b57611fe1e26cefc1601867a
|
4
|
+
data.tar.gz: 4e286be7e8834df304decea922f0c94ddd63f2db2f2359a1c4eabc4dc2e6d547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e279582f67cb3fd5169f12b6f29f59806a54cbe12efaab812cd251ea59ebc1f84f5af6e49e0987c489dabd64bd19e33e3800ba8e06a4321e1212f937ced43f1
|
7
|
+
data.tar.gz: ca090b9bd571ca362d3cf86eeed045aceb8f600e7adb72587f39dd65d7352df2c415c2990f7c4f74895a5a3f844bd68cbd10e1bb22074b2185b4c529daae4222
|
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
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
|
data/keys/.keep
ADDED
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code0-license
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niklas van Schrick
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -95,7 +95,7 @@ files:
|
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
|
-
-
|
98
|
+
- keys/.keep
|
99
99
|
- lib/code0/license.rb
|
100
100
|
- lib/code0/license/boundary.rb
|
101
101
|
- lib/code0/license/encryptor.rb
|
@@ -122,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: 3.0.0
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- - "
|
125
|
+
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
127
|
+
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubygems_version: 3.4.10
|
130
130
|
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
|