source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/fir.rb | Ruby | bsd-2-clause | 19 | master | 14,037 | module MB
module Sound
class Filter
# A simple implementation of FIR filtering using the FFT to perform
# convolution. Filter parameters are specified either as a Hash from
# frequency to gain values, or as a Numo::NArray with positive FFT
# coefficients of the desired frequency response.... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/filter/butterworth.rb | Ruby | bsd-2-clause | 19 | master | 2,249 | module MB
module Sound
class Filter
# Implements low- and high-pass filters with a maximally flat Butterworth
# response.
class Butterworth < FilterChain
attr_reader :sample_rate, :center_frequency
def initialize(filter_type, order, f_samp, f_center)
raise 'Invalid fil... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/midi/graph_voice.rb | Ruby | bsd-2-clause | 19 | master | 11,366 | require 'forwardable'
module MB
module Sound
module MIDI
# A single MIDI synthesizer voice based on an arbitrary signal graph.
# Every envelope and ArrayInput is restarted when the voice is triggered,
# and every oscillator with a constant frequency, or a constant value
# added somewhere ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/midi/voice_pool.rb | Ruby | bsd-2-clause | 19 | master | 6,563 | require 'forwardable'
module MB
module Sound
module MIDI
# A pool of oscillators managed by MIDI note-on and note-off events,
# initially based on code from bin/ep2_syn.rb.
class VoicePool
extend Forwardable
include GraphNode
include GraphNode::SampleRateHelper
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/midi/parameter.rb | Ruby | bsd-2-clause | 19 | master | 14,645 | module MB
module Sound
module MIDI
# Represents a parameter controllable by MIDI message (e.g. control
# change, pitch bend), with smoothing of the output.
#
# Filtering/smoothing is updated for every call to #value.
class Parameter
# MIDI event ranges for different MIDI even... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/midi/manager.rb | Ruby | bsd-2-clause | 19 | master | 17,385 | require 'nibbler'
module MB
module Sound
module MIDI
# Creates a MIDI input port and reads MIDI data from jackd using
# MB::Sound::JackFFI, smooths control values using
# MB::Sound::MIDI::Parameter, and sends smoothed parameter data to
# callbacks. The #update method should be called 60 ... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/midi/midi_file.rb | Ruby | bsd-2-clause | 19 | master | 18,081 | require 'midilib'
module MB
module Sound
module MIDI
# Reads from a MIDI file, returning MIDI data at the appropriate times
# for each MIDI event. Can be used by MB::Sound::MIDI::Manager to play a
# MIDI file.
#
# This implements just enough compatibility with
# MB::Sound::Ja... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/midi/voice.rb | Ruby | bsd-2-clause | 19 | master | 8,262 | require 'forwardable'
module MB
module Sound
module MIDI
# An oscillator, filter, and amplifier section, forming one polyphonic
# voice of a synthesizer.
class Voice
extend Forwardable
DEFAULT_AMP_ENVELOPE = {
attack_time: 0.005,
decay_time: 0.05,
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/cosine_sum.rb | Ruby | bsd-2-clause | 19 | master | 1,067 | module MB
module Sound
class Window
# A generic summed cosine window (e.g. Hann, Hamming, flat-top). This
# class is usually not used directly, but rather inherited by specific
# cosine sum window classes.
module CosineSum
# Window generation function for use outside of a Window c... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/bartlett_hann.rb | Ruby | bsd-2-clause | 19 | master | 521 | module MB
module Sound
class Window
class BartlettHann < Window
def initialize(length)
super(length, (length * 0.75).round)
end
private
def gen_pre_window(length)
n = length # Use length - 1 for "symmetric" version
window = length.times.map { |... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/hann.rb | Ruby | bsd-2-clause | 19 | master | 332 | require_relative 'cosine_sum'
module MB
module Sound
class Window
# The Hann or Hanning raised cosine window.
class Hann < Window
include CosineSum
def initialize(length)
@coefficients = [0.5, -0.5]
super(length, (length * 0.75).round)
end
end
en... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/pad_hann.rb | Ruby | bsd-2-clause | 19 | master | 622 | require_relative 'cosine_sum'
module MB
module Sound
class Window
# A Hann window zero-padded to twice its starting width.
class PadHann < Window
# Initializes a padded Hann pre-window of width +length+/2, zero-padded
# (centered) to +length+.
def initialize(length)
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/pad_double_hann.rb | Ruby | bsd-2-clause | 19 | master | 883 | require_relative 'cosine_sum'
module MB
module Sound
class Window
# The Hann or Hanning raised cosine window, used for both pre and post
# windows. The pre window is half the width of the post window, centered
# and zero-padded.
class PadDoubleHann < Window
def initialize(length)... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/triangular.rb | Ruby | bsd-2-clause | 19 | master | 1,722 | module MB
module Sound
class Window
# A triangular window function that ramps from 0 to 1 at the given midpoint
# (in fractional samples from 0 to length - 1, so 2.5 is the natural
# midpoint of a length 6 window), then from 1 to 0 until the window end.
# The first and last samples will be... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/sft4f.rb | Ruby | bsd-2-clause | 19 | master | 409 | require_relative 'cosine_sum'
module MB
module Sound
class Window
# The Salvatore 1988 4-term fast decay flat-top window as described in
# Heinzel 2002.
class SFT4F < Window
include CosineSum
def initialize(length)
@coefficients = [0.21706, -0.42103, 0.28294, -0.07897... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/sft3f.rb | Ruby | bsd-2-clause | 19 | master | 395 | require_relative 'cosine_sum'
module MB
module Sound
class Window
# The Salvatore 1988 3-term fast decay flat-top window as described in
# Heinzel 2002.
class SFT3F < Window
include CosineSum
def initialize(length)
@coefficients = [0.26526, -0.5, 0.23474]
su... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/double_hann.rb | Ruby | bsd-2-clause | 19 | master | 542 | require_relative 'cosine_sum'
module MB
module Sound
class Window
# The Hann or Hanning raised cosine window, used for both pre and post
# windows.
class DoubleHann < Window
include CosineSum
def initialize(length)
@coefficients = [0.5, -0.5]
super(length, (... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/hann_post.rb | Ruby | bsd-2-clause | 19 | master | 535 | require_relative 'cosine_sum'
module MB
module Sound
class Window
# The Hann or Hanning raised cosine window, applied after processing
# instead of before.
class HannPost < Window
include CosineSum
def initialize(length)
@rectwin = MB::Sound::Window::Rectangular.new(l... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/rectangular.rb | Ruby | bsd-2-clause | 19 | master | 408 | module MB
module Sound
class Window
# A rectangular window function that always has a value of 1.0 and an
# overlap of 3/4ths the length.
class Rectangular < Window
def initialize(length)
super(length, (length * 0.75).round)
end
private
def gen_pre_win... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/hft116d.rb | Ruby | bsd-2-clause | 19 | master | 360 | module MB
module Sound
class Window
# The HFT116D flat-top window from Heinzel 2002.
class HFT116D < Window
include CosineSum
def initialize(length)
@coefficients = [1, -1.9575375, 1.4780705, -0.6367431, 0.1228389, -0.0066288]
super(length, (length * 0.875).round)
... |
github | mike-bourgeous/mb-sound | https://github.com/mike-bourgeous/mb-sound | lib/mb/sound/window/planck.rb | Ruby | bsd-2-clause | 19 | master | 1,462 | module MB
module Sound
class Window
# The Planck-taper window, with a flat middle region and an infinitely
# differentiable rise and fall on the edges.
#
# See https://en.wikipedia.org/wiki/Window_function#Planck-taper_window
class Planck < Window
attr_reader :taper
... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | airb.gemspec | Ruby | mit | 19 | main | 2,077 | # frozen_string_literal: true
require_relative "lib/airb/version"
Gem::Specification.new do |spec|
spec.name = "airb"
spec.version = Airb::VERSION
spec.authors = ["Scott Werner"]
spec.email = ["scott@sublayer.com"]
spec.summary = "CLI-based programming agent for Ruby with VSM architecture"
spec.descripti... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb.rb | Ruby | mit | 19 | main | 757 | # frozen_string_literal: true
require "vsm"
require_relative "airb/organism"
require_relative "airb/ports/chat_tty"
module Airb
class CLI
def self.start
$stdout.sync = true
$stderr.sync = true
capsule = Airb::Organism.build
hub = nil
# Optional: live visualizer (Lens) from VSM
... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/organism.rb | Ruby | mit | 19 | main | 1,857 | # frozen_string_literal: true
require_relative "systems/intelligence"
require_relative "systems/governance"
require_relative "systems/coordination"
require_relative "systems/identity"
require_relative "systems/monitoring"
require_relative "tools/fs/list_files"
require_relative "tools/fs/read_file"
require_relative "too... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/ports/chat_tty.rb | Ruby | mit | 19 | main | 2,695 | # frozen_string_literal: true
require "json"
require "securerandom"
module Airb
module Ports
class ChatTTY < VSM::Port
def should_render?(message)
[:assistant_delta, :assistant, :tool_call, :tool_result, :confirm_request].include?(message.kind)
end
def loop
session_id = SecureRa... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/systems/governance.rb | Ruby | mit | 19 | main | 2,622 | # frozen_string_literal: true
module Airb
module Systems
class Governance < VSM::Governance
def initialize(workspace_root:)
@workspace_root = File.expand_path(workspace_root)
@pending = {} # corr_id => original :tool_call message
end
# Capture bus reference for emitting confir... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/systems/identity.rb | Ruby | mit | 19 | main | 221 | # frozen_string_literal: true
module Airb
module Systems
class Identity < VSM::Identity
def initialize(name:, invariants: [])
super(identity: name, invariants: invariants)
end
end
end
end |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/systems/intelligence.rb | Ruby | mit | 19 | main | 432 | # frozen_string_literal: true
module Airb
module Systems
class Intelligence < VSM::Intelligence
SYSTEM_PROMPT = <<~PROMPT
You are "airb", a careful coding assistant inside a git workspace.
Use tools when needed. Prefer minimal, reversible edits and concise explanations.
PROMPT
d... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/tools/fs/list_files.rb | Ruby | mit | 19 | main | 757 | # frozen_string_literal: true
module Airb
module Tools
module FS
class ListFiles < VSM::ToolCapsule
tool_name "list_files"
tool_description "List files/directories under a path (default: .). Directories end with '/'."
tool_schema({
type: "object",
properties: { pa... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/tools/fs/read_file.rb | Ruby | mit | 19 | main | 521 | # frozen_string_literal: true
module Airb
module Tools
module FS
class ReadFile < VSM::ToolCapsule
tool_name "read_file"
tool_description "Read a UTF-8 text file at relative path."
tool_schema({
type: "object",
properties: { path: { type: "string" } },
r... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | lib/airb/tools/fs/edit_file.rb | Ruby | mit | 19 | main | 1,226 | # frozen_string_literal: true
require "fileutils"
module Airb
module Tools
module FS
class EditFile < VSM::ToolCapsule
tool_name "edit_file"
tool_description "Replace old_str with new_str in file (create if old_str is empty). Returns 'OK'."
tool_schema({
type: "object",
... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | spec/airb_spec.rb | Ruby | mit | 19 | main | 203 | # frozen_string_literal: true
RSpec.describe Airb do
it "has a version number" do
expect(Airb::VERSION).not_to be nil
end
it "does something useful" do
expect(true).to eq(true)
end
end |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | spec/integration_spec.rb | Ruby | mit | 19 | main | 1,956 | # frozen_string_literal: true
require "airb"
class FakeDriver
def run!(conversation:, tools:, policy: {})
# On first user input, request tool; after tool_result arrives, respond
last = conversation.last
if last && last[:role] == "user" && last[:content] =~ /create file/i
yield :tool_calls, [{ id: "... |
github | sublayerapp/airb | https://github.com/sublayerapp/airb | spec/spec_helper.rb | Ruby | mit | 19 | main | 1,458 | # frozen_string_literal: true
require "airb"
require "async/rspec"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
... |
github | bannable/paseto | https://github.com/bannable/paseto | paseto.gemspec | Ruby | mit | 19 | main | 1,688 | # frozen_string_literal: true
require_relative 'lib/paseto/version'
Gem::Specification.new do |spec|
spec.name = 'ruby-paseto'
spec.version = Paseto::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ['Joe Truba']
spec.email = ['joe@bannable.net']
spec.summary = 'A ruby implementation of PASETO ... |
github | bannable/paseto | https://github.com/bannable/paseto | Rakefile | Ruby | mit | 19 | main | 1,128 | # typed: ignore
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
require 'rubocop/rake_task'
RuboCop::RakeTask.new
desc 'Execute specs in parallel and generate a coverage report'
task default: %i[parallel coverage:report]
desc 'Execute specs... |
github | bannable/paseto | https://github.com/bannable/paseto | Gemfile | Ruby | mit | 19 | main | 592 | # frozen_string_literal: true
source 'https://rubygems.org'
gemspec
group :development do
gem 'bundler', '~> 2'
gem 'debug', '>= 1.0'
gem 'parlour', '~> 9'
gem 'tapioca', '~> 0.19'
end
gem 'oj'
gem 'parallel_tests'
gem 'rake', '~> 13'
gem 'reek'
gem 'rspec', '~> 3'
gem 'rspec_junit_formatter'
gem 'rubocop',... |
github | bannable/paseto | https://github.com/bannable/paseto | sorbet/tapioca/require.rb | Ruby | mit | 19 | main | 239 | # typed: true
# frozen_string_literal: true
require 'fileutils'
require 'json'
require 'multi_json'
require 'openssl'
begin
require 'rbnacl'
rescue LoadError
nil
end
require 'securerandom'
require 'simplecov'
require 'sorbet-runtime' |
github | bannable/paseto | https://github.com/bannable/paseto | spec/spec_helper.rb | Ruby | mit | 19 | main | 865 | # typed: false
# frozen_string_literal: true
require 'oj'
require 'timecop'
require 'simplecov'
SimpleCov.start do
if ENV['CI']
require 'simplecov_json_formatter'
formatter SimpleCov::Formatter::JSONFormatter
elsif ENV['BUNDLE_GEMFILE']
formatter SimpleCov::Formatter::SimpleFormatter
coverage_dir ... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/shared_examples_for_keys.rb | Ruby | mit | 19 | main | 4,415 | # typed: false
# frozen_string_literal: true
RSpec.shared_examples 'SymmetricKey' do
include_examples 'Key'
describe '.new' do
context 'when the ikm is the wrong length' do
let(:key_material) { "\x00" * 31 }
it 'raises an ArgumentError' do
expect { key }.to raise_error(ArgumentError, 'ikm... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/generate_vectors.rb | Ruby | mit | 19 | main | 6,603 | # typed: false
# frozen_string_literal: true
require 'fileutils'
require 'json'
require 'erb'
def erb_for(name)
ERB.new(File.read(File.join('vectors', 'templates', "#{name}_example.erb")), trim_mode: '-')
end
module Spec
def example
@template.result(binding)
end
end
class LocalSpec
include Spec
attr_... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/verify_spec.rb | Ruby | mit | 19 | main | 8,308 | # typed: false
# frozen_string_literal: true
RSpec.describe Paseto::Verify do
subject(:verify) do
described_class.verify(result, options)
end
let(:options) do
{
verify_exp: true,
verify_iat: true,
verify_nbf: true,
verify_aud: aud,
verify_iss: iss,
verify_sub: sub,
... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/util_spec.rb | Ruby | mit | 19 | main | 3,008 | # encoding: binary
# typed: false
# frozen_string_literal: true
RSpec.describe Paseto::Util do
describe '.encode64' do
it 'does not include padding' do
expect(described_class.encode64('asdf')).to eq('YXNkZg')
end
it 'uses _ instead of /' do
expect(described_class.encode64('Who am I?')).to eq... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/paserk_spec.rb | Ruby | mit | 19 | main | 5,426 | # encoding: binary
# typed: false
# frozen_string_literal: true
RSpec.describe Paseto::Paserk do
subject(:key) do
described_class.from_paserk(paserk:, wrapping_key:, password:, unsealing_key:)
end
let(:wrapping_key) { nil }
let(:password) { nil }
let(:unsealing_key) { nil }
describe 'key wrapping' do... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/token_spec.rb | Ruby | mit | 19 | main | 5,185 | # typed: false
# frozen_string_literal: true
RSpec.describe Paseto::Token do
describe '.new' do
subject(:token) { described_class.new(version:, purpose:, payload:, footer:) }
let(:version) { 'v3' }
let(:purpose) { 'local' }
let(:payload) { 'asdfASDF' }
let(:footer) { '' }
it 'is comparable ... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/paseto_spec.rb | Ruby | mit | 19 | main | 628 | # typed: false
# frozen_string_literal: true
RSpec.describe Paseto do
it 'has a version number' do
expect(described_class::VERSION).not_to be_nil
end
describe '.configure' do
after { described_class.config.reset! }
it 'yields the config' do
expect do |blk|
described_class.configure(&b... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/sodium/curve_25519_spec.rb | Ruby | mit | 19 | main | 1,015 | # encoding: binary
# typed: false
# frozen_string_literal: true
RSpec.describe 'Paseto::Sodium::Curve25519', :sodium do
let(:described_class) { Paseto::Sodium::Curve25519 }
let(:ed25519_keypair) do
['b18e1d0045995ec3d010c387ccfeb984d783af8fbb0f40fa7db126d889f6dadd' \
'77f48b59caeda77751ed138b0ec667ff50f8... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/sodium/stream/x_cha_cha20_xor_spec.rb | Ruby | mit | 19 | main | 5,284 | # encoding: binary
# typed: false
# frozen_string_literal: true
# rubocop:disable Layout/LineLength, Style/WordArray, Style/MutableConstant
# https://github.com/jedisct1/libsodium/blob/a972fe6498942900981d15d5b7a21259394f2805/test/default/xchacha20.c#L92
# [[key, nonce, output], ...]
TEST_VECTORS = [
['79c99798ac67... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/v3/local_spec.rb | Ruby | mit | 19 | main | 3,103 | # typed: false
# frozen_string_literal: true
require 'shared_examples_for_keys'
RSpec.describe Paseto::V3::Local do
subject(:key) { described_class.new(ikm: key_material) }
let(:key_material) { Paseto::Util.decode_hex(%(707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f)) }
let(:message) { %({"da... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/v3/public_spec.rb | Ruby | mit | 19 | main | 10,141 | # typed: false
# frozen_string_literal: true
require 'shared_examples_for_keys'
RSpec.describe Paseto::V3::Public do
subject(:key) { described_class.new(priv_pem) }
let(:priv_pem) do
# secp384r1 private key
<<~PKEY
-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDCc5XO3mKvqE9kiiBFtlr9rP9t0bm3qM+l3NuM... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/v4/public_spec.rb | Ruby | mit | 19 | main | 9,993 | # typed: false
# frozen_string_literal: true
require 'shared_examples_for_keys'
RSpec.describe 'Paseto::V4::Public', :sodium do
let(:described_class) { Paseto::V4::Public }
let(:priv_pem) do
<<~PRIV
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIGjBa8BaTU0rxTfIaVzVYtHRQho3qV6z3pvfhGjg2jRI
... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/v4/local_spec.rb | Ruby | mit | 19 | main | 4,118 | # typed: false
# frozen_string_literal: true
require 'shared_examples_for_keys'
RSpec.describe 'Paseto::V4::Local', :sodium do
subject(:key) { described_class.new(ikm: key_material) }
let(:described_class) { Paseto::V4::Local }
let(:key_material) { Paseto::Util.decode_hex(%(707172737475767778797a7b7c7d7e7f808... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/serializer/raw_spec.rb | Ruby | mit | 19 | main | 214 | # typed: false
# frozen_string_literal: true
RSpec.describe Paseto::Serializer::Raw do
subject(:result) { described_class.deserialize(value, {}) }
let(:value) { 'foo' }
it { is_expected.to eq(value) }
end |
github | bannable/paseto | https://github.com/bannable/paseto | spec/paseto/serializer/optional_json_spec.rb | Ruby | mit | 19 | main | 1,088 | # typed: false
# frozen_string_literal: true
RSpec.describe Paseto::Serializer::OptionalJson do
describe '.deserialize' do
subject(:result) { described_class.deserialize(value, {}) }
context 'when the input is not valid json' do
let(:value) { 'foo' }
it { is_expected.to eq(value) }
end
... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_local-pw_spec.rb | Ruby | mit | 19 | main | 4,782 | # frozen_string_literal: true
RSpec.describe "PASERK k3.local-pw Test Vectors" do
it 'k3.local-pw-1', :slow do
unwrapped = '707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f'
unwrapped_raw = Paseto::Util.decode_hex(unwrapped)
password = '636f727265637420686f72736520626174746572792073746170... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_local-wrap_pie_spec.rb | Ruby | mit | 19 | main | 2,376 | # frozen_string_literal: true
RSpec.describe "PASERK k3.local-wrap.pie Test Vectors" do
it 'k3.local-wrap.pie-1' do
unwrapped = '0000000000000000000000000000000000000000000000000000000000000000'
wrapping_key = Paseto::V3::Local.new(ikm: Paseto::Util.decode_hex('707172737475767778797a7b7c7d7e7f808182838485868... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_pid_spec.rb | Ruby | mit | 19 | main | 933 | # frozen_string_literal: true
RSpec.describe "PASERK k3.pid Test Vectors" do
it 'k3.pid-1' do
ikm = Paseto::Util.decode_hex('02000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')
paserk = %[k3.pid.mL4lGxNG7cz128frmpn83_76V9C7LmV2sHAMtJ8vIdwG]
key = Paseto::V3::Publ... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_secret-pw_spec.rb | Ruby | mit | 19 | main | 5,235 | # frozen_string_literal: true
RSpec.describe "PASERK k4.secret-pw Test Vectors" do
it 'k4.secret-pw-1', :sodium do
unwrapped = '707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f1ce56a48c82ff99162a14bc544612674e5d61fb9317e65d4055780fdbcb4dc35'
unwrapped_raw = Paseto::Util.decode_hex(unwrapped)
... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_sid_spec.rb | Ruby | mit | 19 | main | 1,109 | # frozen_string_literal: true
RSpec.describe "PASERK k3.sid Test Vectors" do
it 'k3.sid-1' do
ikm = Paseto::Util.decode_hex('000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
paserk = %[k3.sid.DjlX1m4BBFtsnbwzw1zv_x0yRcrZpsvdr_gIxh_hg_Rv]
key = Paseto::V3::Public... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_secret-pw_spec.rb | Ruby | mit | 19 | main | 4,708 | # frozen_string_literal: true
RSpec.describe "PASERK k3.secret-pw Test Vectors" do
it 'k3.secret-pw-1', :slow do
unwrapped = '707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f'
unwrapped_raw = Paseto::Util.decode_hex(unwrapped)
password = '636f72726563742068... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/v3_spec.rb | Ruby | mit | 19 | main | 18,478 | # frozen_string_literal: true
RSpec.describe "PASETO v3 Test Vectors" do
it '3-E-1' do
nonce = Paseto::Util.decode_hex('0000000000000000000000000000000000000000000000000000000000000000')
key = Paseto::Util.decode_hex('707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f')
tok = %[v3.local.AAA... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_local-pw_spec.rb | Ruby | mit | 19 | main | 4,552 | # frozen_string_literal: true
RSpec.describe "PASERK k4.local-pw Test Vectors" do
it 'k4.local-pw-1', :sodium, :slow do
unwrapped = '707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f'
password = '636f727265637420686f727365206261747465727920737461706c65'
options = {:memlimit=>67108864, :ops... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_lid_spec.rb | Ruby | mit | 19 | main | 1,029 | # frozen_string_literal: true
RSpec.describe "PASERK k4.lid Test Vectors" do
it 'k4.lid-1', :sodium do
ikm = Paseto::Util.decode_hex('0000000000000000000000000000000000000000000000000000000000000000')
paserk = %[k4.lid.bqltbNc4JLUAmc9Xtpok-fBuI0dQN5_m3CD9W_nbh559]
key = Paseto::V4::Local.new(ikm: ikm)
... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_local-wrap_pie_spec.rb | Ruby | mit | 19 | main | 2,390 | # frozen_string_literal: true
RSpec.describe "PASERK k4.local-wrap.pie Test Vectors" do
it 'k4.local-wrap.pie-1', :sodium do
unwrapped = Paseto::Util.decode_hex('0000000000000000000000000000000000000000000000000000000000000000')
wrapping_key = Paseto::V4::Local.new(ikm: Paseto::Util.decode_hex('7071727374757... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_pid_spec.rb | Ruby | mit | 19 | main | 1,180 | # frozen_string_literal: true
RSpec.describe "PASERK k4.pid Test Vectors" do
it 'k4.pid-1', :sodium do
ikm = Paseto::Util.decode_hex('0000000000000000000000000000000000000000000000000000000000000000')
paserk = %[k4.pid.S_XQmeEwHbbvRmiyfXfHYpLGjXGzjTRSDoT1YtTakWFE]
key = Paseto::V4::Public.from_public_bytes(ikm)... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_sid_spec.rb | Ruby | mit | 19 | main | 1,226 | # frozen_string_literal: true
RSpec.describe "PASERK k4.sid Test Vectors" do
it 'k4.sid-1', :sodium do
ikm = Paseto::Util.decode_hex('00000000000000000000000000000000000000000000000000000000000000003b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29')
paserk = %[k4.sid.YujQ-NvcGquQ0Q-arRf8iYEcXiSOKg2V... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_seal_spec.rb | Ruby | mit | 19 | main | 3,145 | # frozen_string_literal: true
RSpec.describe "PASERK k4.seal Test Vectors" do
it 'k4.seal-1', :sodium do
paserk = %[k4.seal.OPFn-AEUsKUWtAUZrutVvd9YaZ4CmV4_lk6ii8N72l5gTnl8RlL_zRFqWTZZV9gSnPzARQ_QklrZ2Qs6cJGKOENNOnsDXL5haXcr-QbTXgoLVBvT4ruJ8MdjWXGRTVc9]
secret_key = Paseto::Util.decode_hex("407796f4bc4b8184e... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k4_secret-wrap_pie_spec.rb | Ruby | mit | 19 | main | 3,273 | # frozen_string_literal: true
RSpec.describe "PASERK k4.secret-wrap.pie Test Vectors" do
it 'k4.secret-wrap.pie-1', :sodium do
unwrapped = '00000000000000000000000000000000000000000000000000000000000000003b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29'
wrapping_key = Paseto::V4::Local.new(ik... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_seal_spec.rb | Ruby | mit | 19 | main | 3,938 | # frozen_string_literal: true
RSpec.describe "PASERK k3.seal Test Vectors" do
it 'k3.seal-1' do
paserk = %[k3.seal.NsI9NFzAouTSs7V5mejAeyBLYcoeNlbb9eY8C2KnkPTsARsPLen9KfMFfgqeI50FAnuRCdcb4HmXPaY3i-ZdBXwfdqSiB_65lmIHosVOJ7chmqqscnBkA7vc3mEAXxM05hSytjBYFxwlUnfFE3Sq3YHUZrOELF7PM87K6FFOMqc6]
secret_key = "-----B... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_lid_spec.rb | Ruby | mit | 19 | main | 993 | # frozen_string_literal: true
RSpec.describe "PASERK k3.lid Test Vectors" do
it 'k3.lid-1' do
ikm = Paseto::Util.decode_hex('0000000000000000000000000000000000000000000000000000000000000000')
paserk = %[k3.lid.c2Wpke9KunV6-Tow8dV1wsvVFRkjcTYt_7ZzOtIDRFpM]
key = Paseto::V3::Local.new(ikm: ikm)
expect... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/k3_secret-wrap_pie_spec.rb | Ruby | mit | 19 | main | 3,801 | # frozen_string_literal: true
RSpec.describe "PASERK k3.secret-wrap.pie Test Vectors" do
it 'k3.secret-wrap.pie-1' do
unwrapped = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'
wrapping_key = Paseto::V3::Local.new(ikm: Paseto::Util.decode_hex('7071727374757... |
github | bannable/paseto | https://github.com/bannable/paseto | spec/vectors/v4_spec.rb | Ruby | mit | 19 | main | 17,164 | # frozen_string_literal: true
RSpec.describe "PASETO v4 Test Vectors" do
it '4-E-1', :sodium do
nonce = Paseto::Util.decode_hex('0000000000000000000000000000000000000000000000000000000000000000')
key = Paseto::Util.decode_hex('707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f')
tok = %[v4.... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto.rb | Ruby | mit | 19 | main | 2,731 | # encoding: binary
# typed: strict
# frozen_string_literal: true
require 'multi_json'
require 'openssl'
begin
require 'rbnacl'
rescue LoadError
raise if defined?(RbNaCl)
end
require 'securerandom'
require 'sorbet-runtime'
T::Configuration.enable_final_checks_on_hooks
require 'time'
require 'zeitwerk'
loader = Zei... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/versions.rb | Ruby | mit | 19 | main | 546 | # typed: strict
# frozen_string_literal: true
module Paseto
class Versions < T::Enum
extend T::Sig
enums do
V3Version = new(Protocol::Version3)
V4Version = new(Protocol::Version4)
V3Str = new('v3')
V4Str = new('v4')
K3Str = new('k3')
K4Str = new('k4')
end
sig { r... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/verify.rb | Ruby | mit | 19 | main | 995 | # typed: strict
# frozen_string_literal: true
module Paseto
class Verify
extend T::Sig
sig { returns(Result) }
attr_reader :result
sig do
params(
result: Result,
options: T::Hash[Symbol, T.untyped]
).returns(Result)
end
def self.verify(result, options = {})
... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/util.rb | Ruby | mit | 19 | main | 3,254 | # encoding: binary
# typed: strict
# frozen_string_literal: true
module Paseto
module Util
extend T::Sig
sig { params(str: String).returns(String) }
def self.encode64(str)
[str].pack('m0').tr('+/', '-_').delete('=')
end
sig { params(str: String).returns(String) }
def self.decode64(str... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/result.rb | Ruby | mit | 19 | main | 228 | # typed: strict
# frozen_string_literal: true
module Paseto
class Result < T::Struct
prop :claims, T::Hash[String, T.untyped]
prop :footer, T.nilable(T.any(String, T::Hash[String, T.untyped])), default: nil
end
end |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/token_types.rb | Ruby | mit | 19 | main | 589 | # typed: strict
# frozen_string_literal: true
module Paseto
class TokenTypes < T::Enum
extend T::Sig
enums do
V3Local = new('v3.local')
V3Public = new('v3.public')
V4Local = new('v4.local')
V4Public = new('v4.public')
end
sig { returns(T.nilable(T.class_of(Interface::Key))) ... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/token.rb | Ruby | mit | 19 | main | 3,685 | # typed: strict
# frozen_string_literal: true
module Paseto
class Token
extend T::Sig
include Comparable
sig { returns(String) }
attr_reader :version, :purpose, :raw_payload, :raw_footer
sig { returns(T.any(String, T::Hash[String, T.untyped])) }
attr_reader :footer
sig { returns(T.clas... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/configuration.rb | Ruby | mit | 19 | main | 409 | # typed: strict
# frozen_string_literal: true
module Paseto
module Configuration
extend T::Sig
sig { params(blk: T.proc.params(config: Paseto::Configuration::Box).void).void }
def configure(&blk)
yield(config)
end
sig { returns(Paseto::Configuration::Box) }
def config
@config ||... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/paserk_types.rb | Ruby | mit | 19 | main | 1,524 | # typed: true
# frozen_string_literal: true
module Paseto
class PaserkTypes < T::Enum
extend T::Sig
enums do
K3Local = new('k3.local')
K3Secret = new('k3.secret')
K3Public = new('k3.public')
K3LocalWrap = new('k3.local-wrap')
K3SecretWrap = new('k3.secret-wrap')
K3LocalPB... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/symmetric_key.rb | Ruby | mit | 19 | main | 4,866 | # typed: strict
# frozen_string_literal: true
module Paseto
class SymmetricKey < Interface::Key
extend T::Sig
extend T::Helpers
abstract!
sig(:final) { returns(String) }
attr_reader :key, :lid
sig(:final) { override.returns(String) }
attr_reader :paserk
sig { params(ikm: String).v... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/paserk.rb | Ruby | mit | 19 | main | 1,940 | # typed: strict
# frozen_string_literal: true
module Paseto
module Paserk
extend T::Sig
extend T::Helpers
requires_ancestor { Kernel }
sig do
params(
paserk: String,
wrapping_key: T.nilable(SymmetricKey),
password: T.nilable(String),
unsealing_key: T.nilable(As... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asymmetric_key.rb | Ruby | mit | 19 | main | 3,168 | # typed: strict
# frozen_string_literal: true
module Paseto
class AsymmetricKey < Interface::Key
extend T::Sig
extend T::Helpers
abstract!
sig(:final) { override.returns(String) }
attr_reader :id, :paserk
sig(:final) { returns(String) }
attr_reader :pid, :public_paserk
sig { param... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1.rb | Ruby | mit | 19 | main | 3,233 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
# References:
# https://www.rfc-editor.org/rfc/rfc5208 PKCS #8: Private-Key Information Syntax Specification Version 1.2
# https://www.rfc-editor.org/rfc/rfc5480 Elliptic Curve Cryptography Subject Public Key Information
# ... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/validator.rb | Ruby | mit | 19 | main | 3,900 | # typed: strict
# frozen_string_literal: true
module Paseto
class Validator
extend T::Sig
extend T::Helpers
abstract!
sig { returns(T::Hash[String, T.untyped]) }
attr_reader :payload
sig { returns(T::Hash[Symbol, T.untyped]) }
attr_reader :options
sig { params(payload: T::Hash[Str... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/configuration/box.rb | Ruby | mit | 19 | main | 418 | # typed: strict
# frozen_string_literal: true
module Paseto
module Configuration
class Box
extend T::Sig
sig { returns(DecodeConfiguration) }
attr_accessor :decode
sig { void }
def initialize
@decode = T.let(DecodeConfiguration.new, DecodeConfiguration)
end
si... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/configuration/decode_configuration.rb | Ruby | mit | 19 | main | 2,034 | # typed: strict
# frozen_string_literal: true
module Paseto
module Configuration
class DecodeConfiguration
extend T::Sig
sig { returns(Interface::Serializer) }
attr_accessor :footer_serializer
sig { returns(T::Boolean) }
attr_accessor :verify_exp, :verify_nbf, :verify_iat
s... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/sodium/safe_ed25519_loader.rb | Ruby | mit | 19 | main | 464 | # typed: strict
# frozen_string_literal: true
module Paseto
module Sodium
module SafeEd25519Loader
extend T::Sig
include Kernel
sig(:final) { params(keypair: String).returns(RbNaCl::SigningKey) }
def self.from_keypair(keypair)
RbNaCl::SigningKey.new(keypair[0, 32]).tap do |key|
... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/sodium/curve_25519.rb | Ruby | mit | 19 | main | 1,284 | # typed: false
# frozen_string_literal: true
module Paseto
module Sodium
class Curve25519
extend T::Sig
extend RbNaCl::Sodium
sodium_type :sign
sodium_primitive :ed25519
sodium_function :to_x25519_private_key,
:crypto_sign_ed25519_sk_to_curve25519,
... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/sodium/stream/base.rb | Ruby | mit | 19 | main | 2,014 | # encoding: binary
# typed: strict
# frozen_string_literal: true
module Paseto
module Sodium
module Stream
# Abstract base class for Stream ciphers
class Base
extend T::Sig
extend T::Helpers
abstract!
# Number of bytes in a valid key
KEYBYTES = 0
# N... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/sodium/stream/x_cha_cha20_xor.rb | Ruby | mit | 19 | main | 869 | # encoding: binary
# typed: false
# frozen_string_literal: true
module Paseto
module Sodium
module Stream
class XChaCha20Xor < Paseto::Sodium::Stream::Base
extend RbNaCl::Sodium
sodium_type :stream
sodium_primitive :xchacha20
sodium_constant :KEYBYTES
sodium_const... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/private_key.rb | Ruby | mit | 19 | main | 346 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class PrivateKey < T::Struct
extend T::Sig
const :private_key, T.any(ECPrivateKey, CurvePrivateKey)
sig { returns(OpenSSL::ASN1::OctetString) }
def build
OpenSSL::ASN1::OctetString.new(private_key.to_der)
... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/private_key_algorithm_identifier.rb | Ruby | mit | 19 | main | 356 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class PrivateKeyAlgorithmIdentifier < T::Struct
extend T::Sig
const :parameters, T.any(Ed25519Identifier, NamedCurve)
sig { returns(OpenSSL::ASN1::Sequence) }
def build
OpenSSL::ASN1::Sequence.new(parameters... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/named_curve.rb | Ruby | mit | 19 | main | 369 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class NamedCurve < T::Struct
extend T::Sig
const :curve_name, String
sig { returns([OpenSSL::ASN1::ObjectId, OpenSSL::ASN1::ObjectId]) }
def build
[OpenSSL::ASN1::ObjectId('id-ecPublicKey'), OpenSSL::ASN1::O... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/subject_public_key_info.rb | Ruby | mit | 19 | main | 540 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class SubjectPublicKeyInfo < T::Struct
extend T::Sig
const :algorithm_identifier, AlgorithmIdentifier
const :public_key, PublicKey
sig { returns(OpenSSL::ASN1::Sequence) }
def build
OpenSSL::ASN1::Sequ... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/ed25519_identifier.rb | Ruby | mit | 19 | main | 274 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class Ed25519Identifier < T::Struct
extend T::Sig
sig { returns([OpenSSL::ASN1::ObjectId]) }
def build
[OpenSSL::ASN1::ObjectId('ED25519')]
end
end
end
end |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/curve_private_key.rb | Ruby | mit | 19 | main | 393 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class CurvePrivateKey < T::Struct
extend T::Sig
const :private_key, String
sig { returns(OpenSSL::ASN1::OctetString) }
def build
OpenSSL::ASN1::OctetString.new(private_key)
end
sig { returns(Str... |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/algorithm_identifier.rb | Ruby | mit | 19 | main | 318 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class AlgorithmIdentifier < T::Struct
extend T::Sig
const :algorithm, NamedCurve
sig { returns(OpenSSL::ASN1::Sequence) }
def build
OpenSSL::ASN1::Sequence.new(algorithm.build)
end
end
end
end |
github | bannable/paseto | https://github.com/bannable/paseto | lib/paseto/asn1/public_key.rb | Ruby | mit | 19 | main | 302 | # typed: strict
# frozen_string_literal: true
module Paseto
module ASN1
class PublicKey < T::Struct
extend T::Sig
const :public_key, String
sig { returns(OpenSSL::ASN1::BitString) }
def build
OpenSSL::ASN1::BitString.new(public_key)
end
end
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.