keeper_secrets_manager 17.0.4 → 17.2.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +100 -16
  3. data/Gemfile +6 -3
  4. data/README.md +75 -270
  5. data/Rakefile +1 -1
  6. data/bin/console +47 -0
  7. data/keeper_secrets_manager.gemspec +36 -0
  8. data/lib/keeper_secrets_manager/cache.rb +139 -0
  9. data/lib/keeper_secrets_manager/config_keys.rb +4 -2
  10. data/lib/keeper_secrets_manager/core.rb +993 -452
  11. data/lib/keeper_secrets_manager/crypto.rb +101 -116
  12. data/lib/keeper_secrets_manager/dto/payload.rb +7 -6
  13. data/lib/keeper_secrets_manager/dto.rb +374 -38
  14. data/lib/keeper_secrets_manager/errors.rb +13 -2
  15. data/lib/keeper_secrets_manager/field_types.rb +3 -3
  16. data/lib/keeper_secrets_manager/folder_manager.rb +25 -29
  17. data/lib/keeper_secrets_manager/keeper_globals.rb +11 -17
  18. data/lib/keeper_secrets_manager/notation.rb +202 -93
  19. data/lib/keeper_secrets_manager/notation_enhancements.rb +24 -24
  20. data/lib/keeper_secrets_manager/storage.rb +38 -38
  21. data/lib/keeper_secrets_manager/totp.rb +27 -27
  22. data/lib/keeper_secrets_manager/utils.rb +85 -18
  23. data/lib/keeper_secrets_manager/version.rb +2 -2
  24. data/lib/keeper_secrets_manager.rb +11 -3
  25. metadata +39 -22
  26. data/DEVELOPER_SETUP.md +0 -0
  27. data/MANUAL_TESTING_GUIDE.md +0 -332
  28. data/RUBY_SDK_COMPLETE_DOCUMENTATION.md +0 -354
  29. data/RUBY_SDK_COMPREHENSIVE_SUMMARY.md +0 -192
  30. data/examples/01_quick_start.rb +0 -45
  31. data/examples/02_authentication.rb +0 -82
  32. data/examples/03_retrieve_secrets.rb +0 -81
  33. data/examples/04_create_update_delete.rb +0 -104
  34. data/examples/05_field_types.rb +0 -135
  35. data/examples/06_files.rb +0 -137
  36. data/examples/07_folders.rb +0 -145
  37. data/examples/08_notation.rb +0 -103
  38. data/examples/09_totp.rb +0 -100
  39. data/examples/README.md +0 -89
data/examples/09_totp.rb DELETED
@@ -1,100 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # TOTP Example - Generate Time-based One-Time Passwords
4
-
5
- require 'keeper_secrets_manager'
6
-
7
- # Initialize
8
- config = ENV['KSM_CONFIG'] || 'YOUR_BASE64_CONFIG'
9
- secrets_manager = KeeperSecretsManager.from_config(config)
10
-
11
- puts "=== TOTP (2FA) Example ==="
12
-
13
- # Note: TOTP functionality requires the 'base32' gem
14
- # Install with: gem install base32
15
-
16
- begin
17
- # Check if TOTP is available
18
- unless defined?(KeeperSecretsManager::Totp)
19
- puts "\nTOTP functionality requires the 'base32' gem."
20
- puts "Install it with: gem install base32"
21
- puts "\nWithout TOTP, you can still:"
22
- puts "- Store TOTP seeds in oneTimeCode fields"
23
- puts "- Use external authenticator apps"
24
- puts "- Access the seed for manual setup"
25
- exit
26
- end
27
-
28
- puts "\n1. Finding records with TOTP:"
29
- secrets = secrets_manager.get_secrets
30
- totp_records = secrets.select do |s|
31
- s.fields.any? { |f| f['type'] == 'oneTimeCode' }
32
- end
33
-
34
- if totp_records.empty?
35
- puts " No records with TOTP found."
36
-
37
- # Example of creating a record with TOTP
38
- puts "\n2. Example: Creating a record with TOTP"
39
- puts " record_data = {"
40
- puts " type: 'login',"
41
- puts " title: '2FA Example',"
42
- puts " fields: ["
43
- puts " { type: 'login', value: ['user@example.com'] },"
44
- puts " { type: 'password', value: ['password123'] },"
45
- puts " { type: 'oneTimeCode', value: ['JBSWY3DPEHPK3PXP'] }"
46
- puts " ]"
47
- puts " }"
48
- else
49
- puts " Found #{totp_records.length} records with TOTP"
50
-
51
- # Generate TOTP codes
52
- puts "\n2. Generating TOTP codes:"
53
- totp_records.each do |record|
54
- totp_field = record.fields.find { |f| f['type'] == 'oneTimeCode' }
55
- if totp_field && totp_field['value']
56
- seed = totp_field['value'].first
57
-
58
- # Generate current code
59
- code = KeeperSecretsManager::Totp.generate(seed)
60
- puts " #{record.title}: #{code}"
61
-
62
- # Show time remaining
63
- time_remaining = 30 - (Time.now.to_i % 30)
64
- puts " Valid for: #{time_remaining} seconds"
65
- end
66
- end
67
- end
68
-
69
- puts "\n3. Using TOTP via notation:"
70
- if totp_records.any?
71
- uid = totp_records.first.uid
72
- begin
73
- totp_url = secrets_manager.get_notation("keeper://#{uid}/field/oneTimeCode")
74
- puts " TOTP URL: #{totp_url}"
75
- rescue => e
76
- puts " Error: #{e.message}"
77
- end
78
- end
79
-
80
- puts "\n4. TOTP URL format:"
81
- puts " Standard TOTP seeds can be imported from URLs:"
82
- puts " otpauth://totp/Example:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
83
-
84
- puts "\n5. Manual TOTP setup:"
85
- puts " If base32 gem is not available:"
86
- puts " 1. Store the seed in a oneTimeCode field"
87
- puts " 2. Use the seed with Google Authenticator or similar"
88
- puts " 3. Or install base32 gem for SDK generation"
89
-
90
- rescue => e
91
- puts "Error: #{e.message}"
92
- puts "\nMake sure 'base32' gem is installed for TOTP support"
93
- end
94
-
95
- puts "\n=== TOTP Tips ==="
96
- puts "- TOTP codes change every 30 seconds"
97
- puts "- Store TOTP seeds in oneTimeCode fields"
98
- puts "- Seeds are typically base32 encoded"
99
- puts "- Compatible with Google Authenticator"
100
- puts "- Keep TOTP seeds secure like passwords"
data/examples/README.md DELETED
@@ -1,89 +0,0 @@
1
- # Keeper Secrets Manager Ruby SDK Examples
2
-
3
- This directory contains examples demonstrating various features of the Keeper Secrets Manager Ruby SDK.
4
-
5
- ## Prerequisites
6
-
7
- 1. Set up your configuration using one of these methods:
8
- - Token: `export KSM_TOKEN='your_token_here'`
9
- - Base64 Config: `export KSM_CONFIG='your_base64_config_here'`
10
-
11
- 2. Install the SDK:
12
- ```bash
13
- gem install keeper_secrets_manager
14
- ```
15
-
16
- ## Examples
17
-
18
- ### 01_quick_start.rb
19
- Basic connection and simple secret retrieval. Start here if you're new to the SDK.
20
-
21
- ### 02_authentication.rb
22
- Different ways to authenticate with Keeper Secrets Manager:
23
- - Using token authentication
24
- - Using base64 configuration string
25
-
26
- ### 03_retrieve_secrets.rb
27
- Various methods to retrieve secrets:
28
- - Get all secrets
29
- - Get by UID
30
- - Get by title
31
- - Access specific fields
32
- - Using Keeper Notation
33
-
34
- ### 04_create_update_delete.rb
35
- CRUD operations for managing secrets:
36
- - Create new records
37
- - Update existing records
38
- - Delete records
39
- - Batch operations tips
40
-
41
- ### 05_field_types.rb
42
- Working with different Keeper field types:
43
- - Standard fields (login, password, URL)
44
- - Complex fields (name, address, phone)
45
- - Custom fields
46
- - Special fields (payment cards, bank accounts)
47
-
48
- ### 06_files.rb
49
- File attachment operations:
50
- - Download files from records
51
- - Upload files to records
52
- - Handle different file types
53
-
54
- ### 07_folders.rb
55
- Folder management:
56
- - List folders
57
- - Create folders and subfolders
58
- - Move records between folders
59
- - Get folder hierarchy
60
- - Delete folders
61
-
62
- ### 08_notation.rb
63
- Using Keeper Notation for quick access:
64
- - Access fields with URI-style notation
65
- - Use in configuration templates
66
- - Access custom fields and files
67
-
68
- ### 09_totp.rb
69
- Time-based One-Time Passwords (2FA):
70
- - Generate TOTP codes
71
- - Store TOTP seeds
72
- - Integration with authenticator apps
73
-
74
- ## Running Examples
75
-
76
- Each example can be run directly:
77
-
78
- ```bash
79
- ruby 01_quick_start.rb
80
- ```
81
-
82
- Make sure your environment variables are set before running the examples.
83
-
84
- ## Security Notes
85
-
86
- - Never hardcode credentials in your code
87
- - Use environment variables for configuration
88
- - Keep your tokens and configurations secure
89
- - Don't commit credentials to version control