smbcloud-auth 0.4.2-x86_64-darwin-22
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/.rubocop.yml +21 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +61 -0
- data/Rakefile +14 -0
- data/ext/.keep +0 -0
- data/lib/auth/auth.bundle +0 -0
- data/lib/auth/version.rb +5 -0
- data/lib/auth.rb +111 -0
- data/sig/auth.rbs +37 -0
- metadata +72 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 35b8360b6f599324e3c80ca67891984294a42b67a49b48c138e97edc589e682a
|
|
4
|
+
data.tar.gz: 807ec4c053ffc0aadc5f49ca2c7605c01dd22efb8dcc8f6926e75f9aafc83155
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a1cccea2610141886943ddc6b689c180524d189b71bbb46e7c341ecc75ebcf08e07fe8d0f6c383aaf750803f389d879bca51ff30cc58af2a70d84967190f75ae
|
|
7
|
+
data.tar.gz: dac0f183557752ad146edd66eeeeef78fe8c29f766a59a96f80f09b002a98f9053aebab5aee3e866bec12f06cd23c42905272dd34cce9061391ddf169c080667
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.1
|
|
3
|
+
NewCops: enable
|
|
4
|
+
Exclude:
|
|
5
|
+
- "vendor/**/*"
|
|
6
|
+
- "tmp/**/*"
|
|
7
|
+
- "target/**/*"
|
|
8
|
+
- "pkg/**/*"
|
|
9
|
+
|
|
10
|
+
# Native extension wrapper gems use a bare `module Auth; end` stub at the
|
|
11
|
+
# top level so Magnus can register the native methods into the right namespace.
|
|
12
|
+
# Having both that stub and the real `SmbCloud::Auth` implementation in one
|
|
13
|
+
# file is intentional — splitting them would break the require chain.
|
|
14
|
+
Style/OneClassPerFile:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
# Yard / CHANGELOG serve as the documentation source for this gem.
|
|
18
|
+
# Requiring top-level doc comments on every module and class adds noise
|
|
19
|
+
# without benefit for a thin wrapper library.
|
|
20
|
+
Style/Documentation:
|
|
21
|
+
Enabled: false
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.4.2
|
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 [smbCloud](https://smbcloud.xyz) (Splitfire AB).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
end
|
|
13
|
+
|
|
14
|
+
task default: :compile
|
data/ext/.keep
ADDED
|
File without changes
|
|
Binary file
|
data/lib/auth/version.rb
ADDED
data/lib/auth.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require_relative 'auth/version'
|
|
5
|
+
require_relative 'auth/auth'
|
|
6
|
+
|
|
7
|
+
module Auth
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module SmbCloud
|
|
11
|
+
module Auth
|
|
12
|
+
class Error < StandardError
|
|
13
|
+
attr_reader :error_code, :payload
|
|
14
|
+
|
|
15
|
+
def initialize(message = nil, error_code: nil, payload: nil)
|
|
16
|
+
super(message)
|
|
17
|
+
@error_code = error_code
|
|
18
|
+
@payload = payload
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
module Environment
|
|
23
|
+
DEV = 'dev'
|
|
24
|
+
PRODUCTION = 'production'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class Client
|
|
28
|
+
attr_reader :environment, :app_id, :app_secret
|
|
29
|
+
|
|
30
|
+
def initialize(environment:, app_id:, app_secret:)
|
|
31
|
+
@environment = environment
|
|
32
|
+
@app_id = app_id
|
|
33
|
+
@app_secret = app_secret
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def signup(email:, password:)
|
|
37
|
+
Auth.send(:parse_json, Auth.__signup_with_client(environment, app_id, app_secret, email, password))
|
|
38
|
+
rescue RuntimeError => e
|
|
39
|
+
raise Auth.send(:normalize_error, e)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def login(email:, password:)
|
|
43
|
+
Auth.send(:parse_json, Auth.__login_with_client(environment, app_id, app_secret, email, password))
|
|
44
|
+
rescue RuntimeError => e
|
|
45
|
+
raise Auth.send(:normalize_error, e)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def me(access_token:)
|
|
49
|
+
Auth.send(:parse_json, Auth.__me_with_client(environment, app_id, app_secret, access_token))
|
|
50
|
+
rescue RuntimeError => e
|
|
51
|
+
raise Auth.send(:normalize_error, e)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def logout(access_token:)
|
|
55
|
+
Auth.__logout_with_client(environment, app_id, app_secret, access_token)
|
|
56
|
+
rescue RuntimeError => e
|
|
57
|
+
raise Auth.send(:normalize_error, e)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def remove(access_token:)
|
|
61
|
+
Auth.__remove_with_client(environment, app_id, app_secret, access_token)
|
|
62
|
+
rescue RuntimeError => e
|
|
63
|
+
raise Auth.send(:normalize_error, e)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class << self
|
|
68
|
+
def client(environment:, app_id:, app_secret:)
|
|
69
|
+
Client.new(environment:, app_id:, app_secret:)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def signup_with_client(environment:, app_id:, app_secret:, email:, password:)
|
|
73
|
+
client(environment:, app_id:, app_secret:).signup(email:, password:)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def login_with_client(environment:, app_id:, app_secret:, email:, password:)
|
|
77
|
+
client(environment:, app_id:, app_secret:).login(email:, password:)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def me_with_client(environment:, app_id:, app_secret:, access_token:)
|
|
81
|
+
client(environment:, app_id:, app_secret:).me(access_token:)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def logout_with_client(environment:, app_id:, app_secret:, access_token:)
|
|
85
|
+
client(environment:, app_id:, app_secret:).logout(access_token:)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def remove_with_client(environment:, app_id:, app_secret:, access_token:)
|
|
89
|
+
client(environment:, app_id:, app_secret:).remove(access_token:)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def parse_json(payload)
|
|
95
|
+
return payload unless payload.is_a?(String)
|
|
96
|
+
|
|
97
|
+
JSON.parse(payload, symbolize_names: true)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def normalize_error(error)
|
|
101
|
+
payload = parse_json(error.message)
|
|
102
|
+
error_hash = payload[:error] || payload
|
|
103
|
+
message = error_hash[:message] || error.message
|
|
104
|
+
error_code = error_hash[:error_code]
|
|
105
|
+
Error.new(message, error_code: error_code, payload: payload)
|
|
106
|
+
rescue JSON::ParserError, NoMethodError, TypeError
|
|
107
|
+
Error.new(error.message)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
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,72 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: smbcloud-auth
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.4.2
|
|
5
|
+
platform: x86_64-darwin-22
|
|
6
|
+
authors:
|
|
7
|
+
- Seto Elkahfi
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-05-24 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: json
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
description: Ruby bindings for smbCloud Auth, powered by the shared Rust SDK and a
|
|
27
|
+
native Magnus extension.
|
|
28
|
+
email:
|
|
29
|
+
- hej@setoelkahfi.se
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- ".rubocop.yml"
|
|
35
|
+
- ".ruby-version"
|
|
36
|
+
- CHANGELOG.md
|
|
37
|
+
- README.md
|
|
38
|
+
- Rakefile
|
|
39
|
+
- ext/.keep
|
|
40
|
+
- lib/auth.rb
|
|
41
|
+
- lib/auth/auth.bundle
|
|
42
|
+
- lib/auth/version.rb
|
|
43
|
+
- sig/auth.rbs
|
|
44
|
+
homepage: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth
|
|
45
|
+
licenses:
|
|
46
|
+
- MIT
|
|
47
|
+
metadata:
|
|
48
|
+
allowed_push_host: https://rubygems.org
|
|
49
|
+
homepage_uri: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth
|
|
50
|
+
source_code_uri: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth
|
|
51
|
+
changelog_uri: https://github.com/smbcloudXYZ/smbcloud-cli/tree/main/sdk/gems/auth/CHANGELOG.md
|
|
52
|
+
rdoc_options: []
|
|
53
|
+
require_paths:
|
|
54
|
+
- lib
|
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '3.4'
|
|
60
|
+
- - "<"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: 3.5.dev
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: 3.3.11
|
|
68
|
+
requirements: []
|
|
69
|
+
rubygems_version: 3.6.2
|
|
70
|
+
specification_version: 4
|
|
71
|
+
summary: Ruby bindings for the smbCloud Auth SDK.
|
|
72
|
+
test_files: []
|