smbcloud-auth 0.7.6-x86_64-darwin
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 +7 -0
- data/CHANGELOG.md +5 -0
- data/README.md +61 -0
- data/Rakefile +16 -0
- data/ext/.keep +0 -0
- data/lib/auth/3.1/auth.bundle +0 -0
- data/lib/auth/3.2/auth.bundle +0 -0
- data/lib/auth/3.3/auth.bundle +0 -0
- data/lib/auth/3.4/auth.bundle +0 -0
- data/lib/auth/4.0/auth.bundle +0 -0
- data/lib/auth/version.rb +5 -0
- data/lib/auth.rb +132 -0
- data/sig/auth.rbs +37 -0
- metadata +77 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0c28a3c4f04075a67aabf214860aa266e96a927f340a9b4e1130b09e149dafe7
|
|
4
|
+
data.tar.gz: 4badca4ca07dcf129cfe40408afae622e234709eaf07fcef929355b7998b9f32
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 06a74fb4c5a432076954250eb0ab480eac371c2610ec487f964779d09517aa9ae4abfdd0de694f02efa1459601d667abac2b209a1ce9cb282d72080c52b384d8
|
|
7
|
+
data.tar.gz: 4f0278816f110f536b0df2f6f2b5504f456f8b9279a3e88d86ac3a7c69e6ac16d0e94c71d5c6bab297b336432549ae162eee0d46f968fcaea66b2ba69d59efe0
|
data/CHANGELOG.md
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# smbcloud-auth Gem
|
|
2
|
+
|
|
3
|
+
Ruby bindings for smbCloud Auth.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gem install smbcloud-auth
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
require "auth"
|
|
15
|
+
|
|
16
|
+
client = SmbCloud::Auth::Client.new(
|
|
17
|
+
environment: SmbCloud::Auth::Environment::PRODUCTION,
|
|
18
|
+
app_id: "app-id",
|
|
19
|
+
app_secret: "app-secret"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
signup = client.signup(
|
|
23
|
+
email: "name@example.com",
|
|
24
|
+
password: "password123"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
login = client.login(
|
|
28
|
+
email: "name@example.com",
|
|
29
|
+
password: "password123"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
me = client.me(access_token: login[:access_token])
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
`SmbCloud::Auth::Client` exposes:
|
|
38
|
+
|
|
39
|
+
- `signup(email:, password:)`
|
|
40
|
+
- `login(email:, password:)`
|
|
41
|
+
- `me(access_token:)`
|
|
42
|
+
- `logout(access_token:)`
|
|
43
|
+
- `remove(access_token:)`
|
|
44
|
+
|
|
45
|
+
Module-level helpers are also available:
|
|
46
|
+
|
|
47
|
+
- `SmbCloud::Auth.signup_with_client(...)`
|
|
48
|
+
- `SmbCloud::Auth.login_with_client(...)`
|
|
49
|
+
- `SmbCloud::Auth.me_with_client(...)`
|
|
50
|
+
- `SmbCloud::Auth.logout_with_client(...)`
|
|
51
|
+
- `SmbCloud::Auth.remove_with_client(...)`
|
|
52
|
+
|
|
53
|
+
More auth and SDK notes are in the [smbCloud docs](https://smbcloud.xyz/posts).
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
|
58
|
+
|
|
59
|
+
## Copyright
|
|
60
|
+
|
|
61
|
+
© 2026 [Splitfire AB](https://5mb.app) ([smbCloud](https://smbcloud.xyz)).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rb_sys/extensiontask'
|
|
5
|
+
|
|
6
|
+
task build: :compile
|
|
7
|
+
|
|
8
|
+
GEMSPEC = Gem::Specification.load('auth.gemspec')
|
|
9
|
+
|
|
10
|
+
RbSys::ExtensionTask.new('auth', GEMSPEC) do |ext|
|
|
11
|
+
ext.lib_dir = 'lib/auth'
|
|
12
|
+
ext.cross_compile = true
|
|
13
|
+
ext.cross_platform = %w[x86_64-linux aarch64-linux arm64-darwin x86_64-darwin]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
task default: :compile
|
data/ext/.keep
ADDED
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/auth/version.rb
ADDED
data/lib/auth.rb
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require_relative 'auth/version'
|
|
5
|
+
# Fat native gems ship one extension per Ruby minor (lib/auth/3.4/auth.bundle);
|
|
6
|
+
# source and single-ABI builds put it directly under lib/auth/.
|
|
7
|
+
begin
|
|
8
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
|
9
|
+
require_relative "auth/#{Regexp.last_match(1)}/auth"
|
|
10
|
+
rescue LoadError
|
|
11
|
+
require_relative 'auth/auth'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Auth
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module SmbCloud
|
|
18
|
+
module Auth
|
|
19
|
+
class Error < StandardError
|
|
20
|
+
attr_reader :error_code, :payload
|
|
21
|
+
|
|
22
|
+
def initialize(message = nil, error_code: nil, payload: nil)
|
|
23
|
+
super(message)
|
|
24
|
+
@error_code = error_code
|
|
25
|
+
@payload = payload
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
module Environment
|
|
30
|
+
DEV = 'dev'
|
|
31
|
+
PRODUCTION = 'production'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class Client
|
|
35
|
+
attr_reader :environment, :app_id, :app_secret
|
|
36
|
+
|
|
37
|
+
def initialize(environment:, app_id:, app_secret:)
|
|
38
|
+
@environment = environment
|
|
39
|
+
@app_id = app_id
|
|
40
|
+
@app_secret = app_secret
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def signup(email:, password:)
|
|
44
|
+
Auth.send(:parse_json, Auth.__signup_with_client(environment, app_id, app_secret, email, password))
|
|
45
|
+
rescue RuntimeError => e
|
|
46
|
+
raise Auth.send(:normalize_error, e)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def login(email:, password:)
|
|
50
|
+
Auth.send(:parse_json, Auth.__login_with_client(environment, app_id, app_secret, email, password))
|
|
51
|
+
rescue RuntimeError => e
|
|
52
|
+
raise Auth.send(:normalize_error, e)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Requests password-reset instructions for the given email. The endpoint
|
|
56
|
+
# never reveals whether the account exists (no enumeration), and calling
|
|
57
|
+
# it again re-issues the token, so this also serves the "resend reset
|
|
58
|
+
# instructions" flow. Returns { code:, message: }.
|
|
59
|
+
def reset_password(email:)
|
|
60
|
+
Auth.send(:parse_json, Auth.__reset_password_with_client(environment, app_id, app_secret, email))
|
|
61
|
+
rescue RuntimeError => e
|
|
62
|
+
raise Auth.send(:normalize_error, e)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def me(access_token:)
|
|
66
|
+
Auth.send(:parse_json, Auth.__me_with_client(environment, app_id, app_secret, access_token))
|
|
67
|
+
rescue RuntimeError => e
|
|
68
|
+
raise Auth.send(:normalize_error, e)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def logout(access_token:)
|
|
72
|
+
Auth.__logout_with_client(environment, app_id, app_secret, access_token)
|
|
73
|
+
rescue RuntimeError => e
|
|
74
|
+
raise Auth.send(:normalize_error, e)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def remove(access_token:)
|
|
78
|
+
Auth.__remove_with_client(environment, app_id, app_secret, access_token)
|
|
79
|
+
rescue RuntimeError => e
|
|
80
|
+
raise Auth.send(:normalize_error, e)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
class << self
|
|
85
|
+
def client(environment:, app_id:, app_secret:)
|
|
86
|
+
Client.new(environment:, app_id:, app_secret:)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def signup_with_client(environment:, app_id:, app_secret:, email:, password:)
|
|
90
|
+
client(environment:, app_id:, app_secret:).signup(email:, password:)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def login_with_client(environment:, app_id:, app_secret:, email:, password:)
|
|
94
|
+
client(environment:, app_id:, app_secret:).login(email:, password:)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def reset_password_with_client(environment:, app_id:, app_secret:, email:)
|
|
98
|
+
client(environment:, app_id:, app_secret:).reset_password(email:)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def me_with_client(environment:, app_id:, app_secret:, access_token:)
|
|
102
|
+
client(environment:, app_id:, app_secret:).me(access_token:)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def logout_with_client(environment:, app_id:, app_secret:, access_token:)
|
|
106
|
+
client(environment:, app_id:, app_secret:).logout(access_token:)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def remove_with_client(environment:, app_id:, app_secret:, access_token:)
|
|
110
|
+
client(environment:, app_id:, app_secret:).remove(access_token:)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
private
|
|
114
|
+
|
|
115
|
+
def parse_json(payload)
|
|
116
|
+
return payload unless payload.is_a?(String)
|
|
117
|
+
|
|
118
|
+
JSON.parse(payload, symbolize_names: true)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def normalize_error(error)
|
|
122
|
+
payload = parse_json(error.message)
|
|
123
|
+
error_hash = payload[:error] || payload
|
|
124
|
+
message = error_hash[:message] || error.message
|
|
125
|
+
error_code = error_hash[:error_code]
|
|
126
|
+
Error.new(message, error_code: error_code, payload: payload)
|
|
127
|
+
rescue JSON::ParserError, NoMethodError, TypeError
|
|
128
|
+
Error.new(error.message)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
data/sig/auth.rbs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Auth
|
|
2
|
+
VERSION: String
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
module SmbCloud
|
|
6
|
+
module Auth
|
|
7
|
+
class Error < StandardError
|
|
8
|
+
attr_reader error_code: Integer?
|
|
9
|
+
attr_reader payload: untyped
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module Environment
|
|
13
|
+
DEV: String
|
|
14
|
+
PRODUCTION: String
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Client
|
|
18
|
+
attr_reader environment: String
|
|
19
|
+
attr_reader app_id: String
|
|
20
|
+
attr_reader app_secret: String
|
|
21
|
+
|
|
22
|
+
def initialize: (environment: String, app_id: String, app_secret: String) -> void
|
|
23
|
+
def signup: (email: String, password: String) -> Hash[Symbol, untyped]
|
|
24
|
+
def login: (email: String, password: String) -> Hash[Symbol, untyped]
|
|
25
|
+
def me: (access_token: String) -> Hash[Symbol, untyped]
|
|
26
|
+
def logout: (access_token: String) -> bool
|
|
27
|
+
def remove: (access_token: String) -> bool
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.client: (environment: String, app_id: String, app_secret: String) -> Client
|
|
31
|
+
def self.signup_with_client: (environment: String, app_id: String, app_secret: String, email: String, password: String) -> Hash[Symbol, untyped]
|
|
32
|
+
def self.login_with_client: (environment: String, app_id: String, app_secret: String, email: String, password: String) -> Hash[Symbol, untyped]
|
|
33
|
+
def self.me_with_client: (environment: String, app_id: String, app_secret: String, access_token: String) -> Hash[Symbol, untyped]
|
|
34
|
+
def self.logout_with_client: (environment: String, app_id: String, app_secret: String, access_token: String) -> bool
|
|
35
|
+
def self.remove_with_client: (environment: String, app_id: String, app_secret: String, access_token: String) -> bool
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: smbcloud-auth
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.6
|
|
5
|
+
platform: x86_64-darwin
|
|
6
|
+
authors:
|
|
7
|
+
- Seto Elkahfi
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-10-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: json
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: Ruby bindings for smbCloud Auth, powered by the shared Rust SDK and a
|
|
28
|
+
native Magnus extension.
|
|
29
|
+
email:
|
|
30
|
+
- seto@smbcloud.xyz
|
|
31
|
+
executables: []
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- CHANGELOG.md
|
|
36
|
+
- README.md
|
|
37
|
+
- Rakefile
|
|
38
|
+
- ext/.keep
|
|
39
|
+
- lib/auth.rb
|
|
40
|
+
- lib/auth/3.1/auth.bundle
|
|
41
|
+
- lib/auth/3.2/auth.bundle
|
|
42
|
+
- lib/auth/3.3/auth.bundle
|
|
43
|
+
- lib/auth/3.4/auth.bundle
|
|
44
|
+
- lib/auth/4.0/auth.bundle
|
|
45
|
+
- lib/auth/version.rb
|
|
46
|
+
- sig/auth.rbs
|
|
47
|
+
homepage: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth
|
|
48
|
+
licenses:
|
|
49
|
+
- MIT
|
|
50
|
+
metadata:
|
|
51
|
+
allowed_push_host: https://rubygems.org
|
|
52
|
+
homepage_uri: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth
|
|
53
|
+
source_code_uri: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth
|
|
54
|
+
changelog_uri: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth/CHANGELOG.md
|
|
55
|
+
post_install_message:
|
|
56
|
+
rdoc_options: []
|
|
57
|
+
require_paths:
|
|
58
|
+
- lib
|
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '3.1'
|
|
64
|
+
- - "<"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: 4.1.dev
|
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: 3.3.11
|
|
72
|
+
requirements: []
|
|
73
|
+
rubygems_version: 3.5.23
|
|
74
|
+
signing_key:
|
|
75
|
+
specification_version: 4
|
|
76
|
+
summary: Ruby bindings for the smbCloud Auth SDK.
|
|
77
|
+
test_files: []
|