magic-admin 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/magic-admin/resource/token.rb +28 -0
- data/lib/magic-admin/resource/user.rb +23 -8
- data/lib/magic-admin/resource/wallet.rb +30 -0
- data/lib/magic-admin/version.rb +1 -1
- data/lib/magic-admin.rb +24 -2
- data/test/magic_test.rb +56 -5
- data/test/resource/token_test.rb +28 -1
- data/test/resource/user_test.rb +86 -34
- data/test/spec_helper.rb +3 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ede94b2b390f884340868e4617be9079e5c826cc87a7b9987b306c065dcd631e
|
4
|
+
data.tar.gz: 9357a383e855816df3b594f30ae6638ec3d1c2a469d9f6697fed8fe8cae64020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2230ff87ba679e82c4f040a313ee73c272e758fa339c0614565510872a44461d0903fae6c76b61417b7eb366bb531d78268d7fdcab8ef6f3b8ed097bee95beff
|
7
|
+
data.tar.gz: a5cea3c3dba4ac26e75d987e185c9fde47d7c21f4ae4ea01de930139e87ec5b20260576ad360b47715382667f2759ec473178115011accbf7299a76e4d210515
|
data/CHANGELOG.md
CHANGED
@@ -16,6 +16,20 @@
|
|
16
16
|
|
17
17
|
- <PR-#ISSUE> ...
|
18
18
|
|
19
|
+
## `1.0.0` - 7/5/2023
|
20
|
+
|
21
|
+
#### Added
|
22
|
+
|
23
|
+
- <PR-#20> Add Magic Connect Admin SDK support for Token Resource
|
24
|
+
- [Security Enhancement]: Validate `aud` using Magic client ID.
|
25
|
+
- Pull client ID from Magic servers if not provided in constructor.
|
26
|
+
|
27
|
+
## `0.2.0` - 11/23/2022
|
28
|
+
|
29
|
+
#### Added
|
30
|
+
|
31
|
+
- <PR-#18> Support mult-chain wallets in get_metadata calls
|
32
|
+
|
19
33
|
## `0.1.4` - 04/05/2022
|
20
34
|
|
21
35
|
#### Changed
|
@@ -9,6 +9,24 @@ module MagicAdmin
|
|
9
9
|
# It provides methods to interact with the DID Token.
|
10
10
|
class Token
|
11
11
|
|
12
|
+
# attribute reader for magic client object
|
13
|
+
attr_reader :magic
|
14
|
+
|
15
|
+
# The constructor allows you to create a token object
|
16
|
+
# when your application interacting with the Magic API
|
17
|
+
#
|
18
|
+
# Arguments:
|
19
|
+
# magic: A Magic object.
|
20
|
+
#
|
21
|
+
# Returns:
|
22
|
+
# A token object that provides access to all the supported resources.
|
23
|
+
#
|
24
|
+
# Examples:
|
25
|
+
# Token.new(<magic>)
|
26
|
+
def initialize(magic)
|
27
|
+
@magic = magic
|
28
|
+
end
|
29
|
+
|
12
30
|
# Description:
|
13
31
|
# Method validate did_token
|
14
32
|
#
|
@@ -26,6 +44,7 @@ module MagicAdmin
|
|
26
44
|
validate_claim_fields!(claim)
|
27
45
|
validate_claim_ext!(time, claim["ext"])
|
28
46
|
validate_claim_nbf!(time, claim["nbf"])
|
47
|
+
validate_claim_aud!(magic.client_id, claim["aud"])
|
29
48
|
end
|
30
49
|
|
31
50
|
# Description:
|
@@ -141,6 +160,15 @@ module MagicAdmin
|
|
141
160
|
raise DIDTokenError, message
|
142
161
|
end
|
143
162
|
|
163
|
+
def validate_claim_aud!(client_id, claim_aud)
|
164
|
+
|
165
|
+
return true unless client_id != claim_aud
|
166
|
+
|
167
|
+
message = "Audience does not match client ID. Please ensure your secret key matches the application which generated the DID token."
|
168
|
+
raise DIDTokenError, message
|
169
|
+
end
|
170
|
+
|
144
171
|
end
|
145
172
|
end
|
146
173
|
end
|
174
|
+
|
@@ -34,43 +34,58 @@ module MagicAdmin
|
|
34
34
|
# Arguments:
|
35
35
|
# issuer: Extracted iss component of DID Token generated by a Magic user
|
36
36
|
# on the client-side.
|
37
|
+
# wallet_type: The type of wallet to retrieve. To query specific wallet(s),
|
38
|
+
# the value passed must be consistent with the enumerated values in
|
39
|
+
# MagicAdmin::Resource::WalletType. ALL wallets will be returned if wallet_type=ANY
|
40
|
+
# is passed. If the wallet_type is None or does not match any WalletType
|
41
|
+
# enums, then no wallets are returned.
|
37
42
|
#
|
38
43
|
# Returns:
|
39
44
|
# Metadata information about the user
|
40
|
-
def get_metadata_by_issuer(issuer)
|
45
|
+
def get_metadata_by_issuer(issuer, wallet_type=MagicAdmin::Resource::WalletType::NONE)
|
41
46
|
headers = MagicAdmin::Util.headers(magic.secret_key)
|
42
|
-
options = { params: { issuer: issuer }, headers: headers }
|
47
|
+
options = { params: { issuer: issuer , wallet_type: wallet_type }, headers: headers }
|
43
48
|
magic.http_client
|
44
49
|
.call(:get, "/v1/admin/auth/user/get", options)
|
45
50
|
end
|
46
51
|
|
47
52
|
# Description:
|
48
53
|
# Method Retrieves information about the user by
|
49
|
-
# the supplied public_address
|
54
|
+
# the supplied public_address and wallet type
|
50
55
|
#
|
51
56
|
# Arguments:
|
52
57
|
# public_address: Extracted The user's Ethereum public address component
|
53
58
|
# of DID Token generated by a Magic user on the client-side.
|
59
|
+
# wallet_type: The type of wallet to retrieve. To query specific wallet(s),
|
60
|
+
# the value passed must be consistent with the enumerated values in
|
61
|
+
# MagicAdmin::Resource::WalletType. ALL wallets will be returned if wallet_type=ANY
|
62
|
+
# is passed. If the wallet_type is None or does not match any WalletType
|
63
|
+
# enums, then no wallets are returned.
|
54
64
|
#
|
55
65
|
# Returns:
|
56
66
|
# Metadata information about the user
|
57
|
-
def get_metadata_by_public_address(public_address)
|
67
|
+
def get_metadata_by_public_address(public_address, wallet_type=MagicAdmin::Resource::WalletType::NONE)
|
58
68
|
issuer = token.construct_issuer_with_public_address(public_address)
|
59
|
-
get_metadata_by_issuer(issuer)
|
69
|
+
get_metadata_by_issuer(issuer, wallet_type)
|
60
70
|
end
|
61
71
|
|
62
72
|
# Description:
|
63
73
|
# Method Retrieves information about the user by
|
64
|
-
# the supplied DID Token
|
74
|
+
# the supplied DID Token and wallet type
|
65
75
|
#
|
66
76
|
# Arguments:
|
67
77
|
# did_token: A DID Token generated by a Magic user on the client-side.
|
78
|
+
# wallet_type: The type of wallet to retrieve. To query specific wallet(s),
|
79
|
+
# the value passed must be consistent with the enumerated values in
|
80
|
+
# MagicAdmin::Resource::WalletType. ALL wallets will be returned if wallet_type=ANY
|
81
|
+
# is passed. If the wallet_type is None or does not match any WalletType
|
82
|
+
# enums, then no wallets are returned.
|
68
83
|
#
|
69
84
|
# Returns:
|
70
85
|
# Metadata information about the user
|
71
|
-
def get_metadata_by_token(did_token)
|
86
|
+
def get_metadata_by_token(did_token, wallet_type=MagicAdmin::Resource::WalletType::NONE)
|
72
87
|
issuer = token.get_issuer(did_token)
|
73
|
-
get_metadata_by_issuer(issuer)
|
88
|
+
get_metadata_by_issuer(issuer, wallet_type)
|
74
89
|
end
|
75
90
|
|
76
91
|
# Description:
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MagicAdmin
|
4
|
+
module Resource
|
5
|
+
class WalletType
|
6
|
+
ETH = "ETH"
|
7
|
+
HARMONY = "HARMONY"
|
8
|
+
ICON = "ICON"
|
9
|
+
FLOW = "FLOW"
|
10
|
+
TEZOS = "TEZOS"
|
11
|
+
ZILLIQA = "ZILLIQA"
|
12
|
+
POLKADOT = "POLKADOT"
|
13
|
+
SOLANA = "SOLANA"
|
14
|
+
AVAX = "AVAX"
|
15
|
+
ALGOD = "ALGOD"
|
16
|
+
COSMOS = "COSMOS"
|
17
|
+
CELO = "CELO"
|
18
|
+
BITCOIN = "BITCOIN"
|
19
|
+
NEAR = "NEAR"
|
20
|
+
HELIUM = "HELIUM"
|
21
|
+
CONFLUX = "CONFLUX"
|
22
|
+
TERRA = "TERRA"
|
23
|
+
TAQUITO = "TAQUITO"
|
24
|
+
ED = "ED"
|
25
|
+
HEDERA = "HEDERA"
|
26
|
+
NONE = "NONE"
|
27
|
+
ANY = "ANY"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/magic-admin/version.rb
CHANGED
data/lib/magic-admin.rb
CHANGED
@@ -24,6 +24,7 @@ require "magic-admin/http/response"
|
|
24
24
|
# Magic Resource Classes
|
25
25
|
require "magic-admin/resource/token"
|
26
26
|
require "magic-admin/resource/user"
|
27
|
+
require "magic-admin/resource/wallet"
|
27
28
|
|
28
29
|
# Magic Class to access resources
|
29
30
|
class Magic
|
@@ -37,6 +38,9 @@ class Magic
|
|
37
38
|
# attribute reader for magic http client
|
38
39
|
attr_reader :http_client
|
39
40
|
|
41
|
+
# attribute reader for magic client id
|
42
|
+
attr_reader :client_id
|
43
|
+
|
40
44
|
# The constructor allows you to specify your own API secret key
|
41
45
|
# and HTTP request strategy when your application interacting
|
42
46
|
# with the Magic API.
|
@@ -71,9 +75,11 @@ class Magic
|
|
71
75
|
def initialize(api_secret_key: nil,
|
72
76
|
retries: nil,
|
73
77
|
timeout: nil,
|
74
|
-
backoff: nil
|
78
|
+
backoff: nil,
|
79
|
+
client_id: nil)
|
75
80
|
secret_key!(api_secret_key)
|
76
81
|
http_client!(retries, timeout, backoff)
|
82
|
+
client_id!(client_id, api_secret_key)
|
77
83
|
end
|
78
84
|
|
79
85
|
# Description:
|
@@ -97,7 +103,7 @@ class Magic
|
|
97
103
|
# all the supported resources.
|
98
104
|
|
99
105
|
def token
|
100
|
-
MagicAdmin::Resource::Token.new
|
106
|
+
MagicAdmin::Resource::Token.new(self)
|
101
107
|
end
|
102
108
|
|
103
109
|
private
|
@@ -132,4 +138,20 @@ class Magic
|
|
132
138
|
configure_timeout(timeout),
|
133
139
|
configure_backoff(backoff))
|
134
140
|
end
|
141
|
+
|
142
|
+
def client_id!(client_id, secret_key)
|
143
|
+
@client_id = client_id || ENV["MAGIC_CLIENT_ID"]
|
144
|
+
if !@client_id
|
145
|
+
headers = MagicAdmin::Util.headers(secret_key)
|
146
|
+
options = { headers: headers }
|
147
|
+
response = self.http_client
|
148
|
+
.call(:get, "/v1/admin/client/get", options)
|
149
|
+
|
150
|
+
message = "Magic api secret key is not valid."
|
151
|
+
raise MagicAdmin::MagicError, message unless response.data[:data][:client_id]
|
152
|
+
|
153
|
+
@client_id = response.data[:data][:client_id]
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
135
157
|
end
|
data/test/magic_test.rb
CHANGED
@@ -4,7 +4,17 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
describe Magic do
|
6
6
|
let(:env_secret_key) { "<ENV_MAGIC_API_SECRET_KEY>" }
|
7
|
-
let(:
|
7
|
+
let(:arg_secret_key) { "<ARG_MAGIC_API_SECRET_KEY>" }
|
8
|
+
|
9
|
+
let(:env_client_id) { "<ENV_MAGIC_CLIENT_ID>" }
|
10
|
+
let(:arg_client_id) { "<ARG_MAGIC_CLIENT_ID>" }
|
11
|
+
let(:returned_client_id) { "<RETURNED_CLIENT_ID>" }
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
allow_any_instance_of(MagicAdmin::Http::Client).to receive(:call).and_return(
|
15
|
+
double(data: { data: { client_id: returned_client_id } })
|
16
|
+
)
|
17
|
+
end
|
8
18
|
|
9
19
|
describe "magic object without arguments and environment variables" do
|
10
20
|
it "should raise an error" do
|
@@ -20,14 +30,14 @@ describe Magic do
|
|
20
30
|
end
|
21
31
|
|
22
32
|
it "should be set with arguments" do
|
23
|
-
magic = Magic.new(api_secret_key:
|
24
|
-
expect(magic.secret_key).to eq(
|
33
|
+
magic = Magic.new(api_secret_key: arg_secret_key)
|
34
|
+
expect(magic.secret_key).to eq(arg_secret_key)
|
25
35
|
end
|
26
36
|
|
27
37
|
it "should be set with arguments ignore environment variable" do
|
28
38
|
ENV["MAGIC_API_SECRET_KEY"] = env_secret_key
|
29
|
-
magic = Magic.new(api_secret_key:
|
30
|
-
expect(magic.secret_key).to eq(
|
39
|
+
magic = Magic.new(api_secret_key: arg_secret_key)
|
40
|
+
expect(magic.secret_key).to eq(arg_secret_key)
|
31
41
|
expect(magic.secret_key).not_to eq(env_secret_key)
|
32
42
|
end
|
33
43
|
end
|
@@ -121,4 +131,45 @@ describe Magic do
|
|
121
131
|
end
|
122
132
|
end
|
123
133
|
end
|
134
|
+
|
135
|
+
describe "magic object set client_id" do
|
136
|
+
|
137
|
+
let(:api_secret_key) { "<API_SECRET_KEY>" }
|
138
|
+
|
139
|
+
before(:each) do
|
140
|
+
ENV["MAGIC_API_SECRET_KEY"] = api_secret_key
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should be set with environment variable" do
|
144
|
+
ENV["MAGIC_CLIENT_ID"] = env_client_id
|
145
|
+
magic = Magic.new
|
146
|
+
expect(magic.client_id).to eq(env_client_id)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should be set with argument" do
|
150
|
+
ENV["MAGIC_CLIENT_ID"] = nil
|
151
|
+
magic = Magic.new(client_id: arg_client_id)
|
152
|
+
expect(magic.client_id).to eq(arg_client_id)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should be set with argument ignore environment variable" do
|
156
|
+
ENV["MAGIC_CLIENT_ID"] = env_client_id
|
157
|
+
magic = Magic.new(client_id: arg_client_id)
|
158
|
+
expect(magic.client_id).to eq(arg_client_id)
|
159
|
+
expect(magic.client_id).not_to eq(env_client_id)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should retrieve from API if not set" do
|
163
|
+
ENV["MAGIC_CLIENT_ID"] = nil
|
164
|
+
magic = Magic.new
|
165
|
+
expect(magic.client_id).to eq(returned_client_id)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should raise an error if API key is invalid" do
|
169
|
+
allow_any_instance_of(MagicAdmin::Http::Client).to receive(:call).and_return(
|
170
|
+
double(data: { data: { } })
|
171
|
+
)
|
172
|
+
expect { Magic.new }.to raise_exception MagicAdmin::MagicError
|
173
|
+
end
|
174
|
+
end
|
124
175
|
end
|
data/test/resource/token_test.rb
CHANGED
@@ -3,10 +3,15 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe MagicAdmin::Resource::Token do
|
6
|
+
let(:client_id) {'did:magic:testtest-test-test-test-testtesttest'}
|
7
|
+
let(:magic) { instance_double("MagicAdmin::Magic", client_id: client_id) }
|
8
|
+
|
9
|
+
subject(:token) { described_class.new(magic) }
|
10
|
+
|
6
11
|
describe "instance methods" do
|
7
12
|
describe "public methods" do
|
8
13
|
it "#validate" do
|
9
|
-
claim = { "ext" => 1000, "nbf" => "nbf" }
|
14
|
+
claim = { "ext" => 1000, "nbf" => "nbf", "aud" => client_id }
|
10
15
|
rec_address = double("rec_address").to_s
|
11
16
|
proof = double("proof")
|
12
17
|
time_now = 1_202_020
|
@@ -27,6 +32,9 @@ describe MagicAdmin::Resource::Token do
|
|
27
32
|
|
28
33
|
expect(subject).to receive(:validate_claim_nbf!)
|
29
34
|
.with(time_now, claim["nbf"])
|
35
|
+
|
36
|
+
expect(subject).to receive(:validate_claim_aud!)
|
37
|
+
.with(client_id, claim["aud"])
|
30
38
|
|
31
39
|
subject.validate(spec_did_token)
|
32
40
|
end
|
@@ -182,6 +190,25 @@ describe MagicAdmin::Resource::Token do
|
|
182
190
|
end .to raise_error(MagicAdmin::DIDTokenError, msg)
|
183
191
|
end
|
184
192
|
end
|
193
|
+
|
194
|
+
context "#validate_claim_aud!" do
|
195
|
+
it "return true when aud matches" do
|
196
|
+
claim_aud = 'aud'
|
197
|
+
client_id = 'aud'
|
198
|
+
expect(subject.send(:validate_claim_ext!,
|
199
|
+
client_id,
|
200
|
+
claim_aud)).to be_truthy
|
201
|
+
end
|
202
|
+
|
203
|
+
it "raise error when aud does not match" do
|
204
|
+
claim_aud = 'audDiff'
|
205
|
+
client_id = 'aud'
|
206
|
+
msg = "Audience does not match client ID. Please ensure your secret key matches the application which generated the DID token."
|
207
|
+
expect do
|
208
|
+
subject.send(:validate_claim_aud!, client_id, claim_aud)
|
209
|
+
end .to raise_error(MagicAdmin::DIDTokenError, msg)
|
210
|
+
end
|
211
|
+
end
|
185
212
|
end
|
186
213
|
end
|
187
214
|
end
|
data/test/resource/user_test.rb
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe MagicAdmin::Resource::User do
|
6
|
-
let(:magic) { Magic.new(api_secret_key: spec_api_secret_key) }
|
6
|
+
let(:magic) { Magic.new(api_secret_key: spec_api_secret_key, client_id: spec_client_id) }
|
7
7
|
let(:public_address) do
|
8
|
-
MagicAdmin::Resource::Token.new.get_public_address(spec_did_token)
|
8
|
+
MagicAdmin::Resource::Token.new(magic).get_public_address(spec_did_token)
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:issuer) do
|
12
|
-
MagicAdmin::Resource::Token.new.get_issuer(spec_did_token)
|
12
|
+
MagicAdmin::Resource::Token.new(magic).get_issuer(spec_did_token)
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:construct_issuer_with_public_address) do
|
16
|
-
MagicAdmin::Resource::Token.new.construct_issuer_with_public_address(public_address)
|
16
|
+
MagicAdmin::Resource::Token.new(magic).construct_issuer_with_public_address(public_address)
|
17
17
|
end
|
18
18
|
|
19
19
|
let(:stub_response_body) do
|
@@ -26,19 +26,47 @@ describe MagicAdmin::Resource::User do
|
|
26
26
|
expect(subject).to respond_to(:magic)
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
describe "#get_metadata_by_issuer with or without wallet" do
|
30
|
+
before(:each) do
|
31
31
|
allow(MagicAdmin::Util).to receive(:headers)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
.with(magic.secret_key)
|
33
|
+
.and_return({})
|
34
|
+
end
|
35
|
+
|
36
|
+
context "#get_metadata_by_issuer no wallet" do
|
37
|
+
it "send request with options" do
|
38
|
+
expect(magic.http_client).to receive(:call)
|
39
|
+
.with(:get,
|
40
|
+
"/v1/admin/auth/user/get",
|
41
|
+
{
|
42
|
+
params: { issuer: issuer, wallet_type: MagicAdmin::Resource::WalletType::NONE }, headers: {}
|
43
|
+
})
|
44
|
+
subject.get_metadata_by_issuer(issuer)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "#get_metadata_by_issuer with wallet that does not exist" do
|
49
|
+
it "send request with options" do
|
50
|
+
expect(magic.http_client).to receive(:call)
|
51
|
+
.with(:get,
|
52
|
+
"/v1/admin/auth/user/get",
|
53
|
+
{
|
54
|
+
params: { issuer: issuer, wallet_type: "dne" }, headers: {}
|
55
|
+
})
|
56
|
+
subject.get_metadata_by_issuer(issuer, "dne")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "#get_metadata_by_issuer with wallet" do
|
61
|
+
it "send request with options" do
|
62
|
+
expect(magic.http_client).to receive(:call)
|
63
|
+
.with(:get,
|
64
|
+
"/v1/admin/auth/user/get",
|
65
|
+
{
|
66
|
+
params: { issuer: issuer, wallet_type: MagicAdmin::Resource::WalletType::ALGOD }, headers: {}
|
67
|
+
})
|
68
|
+
subject.get_metadata_by_issuer(issuer, MagicAdmin::Resource::WalletType::ALGOD)
|
69
|
+
end
|
42
70
|
end
|
43
71
|
end
|
44
72
|
|
@@ -46,6 +74,7 @@ describe MagicAdmin::Resource::User do
|
|
46
74
|
it "return response" do
|
47
75
|
url = "https://api.magic.link/v1/admin/auth/user/get?issuer="
|
48
76
|
url += construct_issuer_with_public_address
|
77
|
+
url += "&wallet_type=" + MagicAdmin::Resource::WalletType::NONE
|
49
78
|
stub_request(:get, url)
|
50
79
|
.to_return(status: 200, body: stub_response_body.to_json, headers: {})
|
51
80
|
reps = subject.get_metadata_by_public_address(public_address)
|
@@ -53,46 +82,69 @@ describe MagicAdmin::Resource::User do
|
|
53
82
|
end
|
54
83
|
end
|
55
84
|
|
56
|
-
context "#
|
85
|
+
context "#get_metadata_by_public_address" do
|
57
86
|
it "return response" do
|
58
87
|
url = "https://api.magic.link/v1/admin/auth/user/get?issuer="
|
59
|
-
url +=
|
88
|
+
url += construct_issuer_with_public_address
|
89
|
+
url += "&wallet_type=" + MagicAdmin::Resource::WalletType::SOLANA
|
60
90
|
stub_request(:get, url)
|
61
91
|
.to_return(status: 200, body: stub_response_body.to_json, headers: {})
|
62
|
-
reps = subject.
|
63
|
-
|
92
|
+
reps = subject.get_metadata_by_public_address(public_address, MagicAdmin::Resource::WalletType::SOLANA)
|
64
93
|
expect(reps.status_code).to eq(200)
|
65
94
|
end
|
66
95
|
end
|
67
96
|
|
68
|
-
context "#
|
97
|
+
context "#get_metadata_by_token" do
|
69
98
|
it "return response" do
|
70
|
-
url = "https://api.magic.link/
|
71
|
-
|
99
|
+
url = "https://api.magic.link/v1/admin/auth/user/get?issuer="
|
100
|
+
url += issuer
|
101
|
+
url += "&wallet_type=" + MagicAdmin::Resource::WalletType::NONE
|
102
|
+
stub_request(:get, url)
|
72
103
|
.to_return(status: 200, body: stub_response_body.to_json, headers: {})
|
73
|
-
reps = subject.
|
104
|
+
reps = subject.get_metadata_by_token(spec_did_token)
|
74
105
|
|
75
106
|
expect(reps.status_code).to eq(200)
|
76
107
|
end
|
77
108
|
end
|
78
109
|
|
79
|
-
context "#
|
110
|
+
context "#get_metadata_by_token" do
|
80
111
|
it "return response" do
|
81
|
-
url = "https://api.magic.link/
|
82
|
-
|
112
|
+
url = "https://api.magic.link/v1/admin/auth/user/get?issuer="
|
113
|
+
url += issuer
|
114
|
+
url += "&wallet_type=" + MagicAdmin::Resource::WalletType::ANY
|
115
|
+
stub_request(:get, url)
|
83
116
|
.to_return(status: 200, body: stub_response_body.to_json, headers: {})
|
84
|
-
reps = subject.
|
117
|
+
reps = subject.get_metadata_by_token(spec_did_token, MagicAdmin::Resource::WalletType::ANY)
|
118
|
+
|
85
119
|
expect(reps.status_code).to eq(200)
|
86
120
|
end
|
87
121
|
end
|
88
122
|
|
89
|
-
|
90
|
-
|
123
|
+
describe "#get_metadata_by_issuer object network strategy" do
|
124
|
+
before(:each) do
|
91
125
|
url = "https://api.magic.link/v2/admin/auth/user/logout"
|
92
|
-
stub_request(:post, url)
|
93
|
-
|
94
|
-
|
95
|
-
|
126
|
+
stub_request(:post, url).to_return(status: 200, body: stub_response_body.to_json, headers: {})
|
127
|
+
end
|
128
|
+
|
129
|
+
context "#logout_by_issuer" do
|
130
|
+
it "return response" do
|
131
|
+
reps = subject.logout_by_issuer(issuer)
|
132
|
+
expect(reps.status_code).to eq(200)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "#logout_by_public_address" do
|
137
|
+
it "return response" do
|
138
|
+
reps = subject.logout_by_public_address(public_address)
|
139
|
+
expect(reps.status_code).to eq(200)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "#logout_by_token" do
|
144
|
+
it "return response" do
|
145
|
+
reps = subject.logout_by_token(spec_did_token)
|
146
|
+
expect(reps.status_code).to eq(200)
|
147
|
+
end
|
96
148
|
end
|
97
149
|
end
|
98
150
|
end
|
data/test/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magic-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magic Labs Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eth
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/magic-admin/http/response.rb
|
124
124
|
- lib/magic-admin/resource/token.rb
|
125
125
|
- lib/magic-admin/resource/user.rb
|
126
|
+
- lib/magic-admin/resource/wallet.rb
|
126
127
|
- lib/magic-admin/util.rb
|
127
128
|
- lib/magic-admin/version.rb
|
128
129
|
- magic-admin.gemspec
|
@@ -138,7 +139,7 @@ homepage: https://docs.magic.link/admin-sdk/ruby
|
|
138
139
|
licenses:
|
139
140
|
- MIT
|
140
141
|
metadata: {}
|
141
|
-
post_install_message:
|
142
|
+
post_install_message:
|
142
143
|
rdoc_options: []
|
143
144
|
require_paths:
|
144
145
|
- lib
|
@@ -153,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
154
|
- !ruby/object:Gem::Version
|
154
155
|
version: '0'
|
155
156
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
157
|
-
signing_key:
|
157
|
+
rubygems_version: 3.4.10
|
158
|
+
signing_key:
|
158
159
|
specification_version: 4
|
159
160
|
summary: Ruby bindings for the Magic Admin API
|
160
161
|
test_files:
|