canvas-embed 0.1.7 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45b64ffaefba9ed0079b7d68ce049ea9b13f43e33b1b16af374eece5f2d602c2
4
- data.tar.gz: 06712ec1051c757a7835ab7df4c6d47728a4bc99f6a0054d2d42b4fb606d162e
3
+ metadata.gz: f735aee500f5d61c293d26bc4af5bf12eecc52628a8f32683e651e1131e2465d
4
+ data.tar.gz: 70770e330bae3d7e19ef98f9fddc2b1654d5bd56a040018d4e7e4470eb97558e
5
5
  SHA512:
6
- metadata.gz: dd3ee766aff62d4420fda59ab2e4a274a3cf28ebb00d5364b186c9476141fa350679db9506c45abab458c1f948d95409fa731300ff4c8700a982d3ae68d9992c
7
- data.tar.gz: 8eb0765d2c8be6e8a5fd51e15637ad1a0c3692175a0ae3d89f1759ad093c40bf4d8503b2fbd1bedb41271c060503570d6726a1c30d1e88c46e41bb5728dcad3f
6
+ metadata.gz: e26e1535711c89c1cec38e8916b99ce7c948dae5cb84436b033931bad0896d02e8db28c829bbdee341292b46065496ea1b9155fefa690a1e3fad3aa4e5faa2ce
7
+ data.tar.gz: 73de4bd638b1615e5d67ce9b1eb3e61e93a1f6a349a33996259da03dc56acc1d035507e3e847e22adff1b75dbe5cda0ba7397f3b2689dbf56af74e9743a8c1ad
data/example/Gemfile CHANGED
@@ -7,7 +7,7 @@ ruby '3.2.2'
7
7
  # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
8
8
  gem 'rails', '~> 7.1.1'
9
9
 
10
- gem 'canvas-embed', '~> 0.1.6'
10
+ gem 'canvas-embed', '~> 0.1.7'
11
11
 
12
12
  gem 'rack-cors'
13
13
 
data/example/Gemfile.lock CHANGED
@@ -82,7 +82,7 @@ GEM
82
82
  bootsnap (1.17.0)
83
83
  msgpack (~> 1.2)
84
84
  builder (3.2.4)
85
- canvas-embed (0.1.6)
85
+ canvas-embed (0.1.7)
86
86
  rbnacl (~> 7.1.1)
87
87
  capybara (3.39.2)
88
88
  addressable
@@ -251,7 +251,7 @@ PLATFORMS
251
251
 
252
252
  DEPENDENCIES
253
253
  bootsnap
254
- canvas-embed (~> 0.1.6)
254
+ canvas-embed (~> 0.1.7)
255
255
  capybara
256
256
  debug
257
257
  importmap-rails
@@ -1345,3 +1345,52 @@ Completed 500 Internal Server Error in 0ms (ActiveRecord: 0.0ms | Allocations: 4
1345
1345
  NoMethodError (undefined method `generate_login_token' for Canvas::Embed:Module):
1346
1346
 
1347
1347
  app/controllers/application_controller.rb:21:in `generate_login_token'
1348
+ Started GET "/generate_login_token?email=wsp260+testerman@gmail.com" for ::1 at 2023-11-09 17:56:17 -0800
1349
+ Processing by ApplicationController#generate_login_token as HTML
1350
+ Parameters: {"email"=>"wsp260 testerman@gmail.com"}
1351
+ Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms | Allocations: 460)
1352
+
1353
+
1354
+
1355
+ NoMethodError (undefined method `generate_login_token' for Canvas::Embed:Module):
1356
+
1357
+ app/controllers/application_controller.rb:21:in `generate_login_token'
1358
+ Started GET "/generate_login_token?email=wsp260+testerman@gmail.com" for ::1 at 2023-11-09 17:56:18 -0800
1359
+ Processing by ApplicationController#generate_login_token as HTML
1360
+ Parameters: {"email"=>"wsp260 testerman@gmail.com"}
1361
+ Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.0ms | Allocations: 460)
1362
+
1363
+
1364
+
1365
+ NoMethodError (undefined method `generate_login_token' for Canvas::Embed:Module):
1366
+
1367
+ app/controllers/application_controller.rb:21:in `generate_login_token'
1368
+ Started GET "/generate_login_token?email=wsp260+testerman@gmail.com" for ::1 at 2023-11-09 17:56:29 -0800
1369
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
1370
+ Processing by ApplicationController#generate_login_token as HTML
1371
+ Parameters: {"email"=>"wsp260 testerman@gmail.com"}
1372
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 1148)
1373
+
1374
+
1375
+ Started GET "/favicon.ico" for ::1 at 2023-11-09 17:56:29 -0800
1376
+
1377
+ ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
1378
+
1379
+ Started GET "/generate_login_token?email=wsp260_testerman@gmail.com" for ::1 at 2023-11-09 18:04:09 -0800
1380
+ Processing by ApplicationController#generate_login_token as HTML
1381
+ Parameters: {"email"=>"wsp260_testerman@gmail.com"}
1382
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 133)
1383
+
1384
+
1385
+ Started GET "/generate_login_token?email=wsp260_testerman@gmail.com" for ::1 at 2023-11-09 18:04:27 -0800
1386
+ Processing by ApplicationController#generate_login_token as HTML
1387
+ Parameters: {"email"=>"wsp260_testerman@gmail.com"}
1388
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 133)
1389
+
1390
+
1391
+ Started GET "/generate_login_token?email=wsp260_testerman@gmail.com" for ::1 at 2023-11-09 18:20:00 -0800
1392
+ Processing by ApplicationController#generate_login_token as HTML
1393
+ Parameters: {"email"=>"wsp260_testerman@gmail.com"}
1394
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 133)
1395
+
1396
+
@@ -1 +1 @@
1
- 92342
1
+ 89256
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Canvas
4
4
  module Embed
5
- VERSION = '0.1.7'
5
+ VERSION = '0.1.8'
6
6
  end
7
7
  end
data/lib/canvas/embed.rb CHANGED
@@ -47,8 +47,10 @@ module Canvas
47
47
  # email - String, the email of the user to login. This should match a user or invite in one of your accounts.
48
48
  # expiration_seconds - Optional Integer, how long the token should be valid for. Default to 10 minutes.
49
49
  # user_id - Optional String, identifier for the user, used in logging in Canvas.
50
+ # first_name - Optional String, first name of the user
51
+ # last_name - Optional String, last name of the user
50
52
  #
51
- def generate_login_token(private_key, email, expiration_seconds = 600, user_id = nil)
53
+ def generate_login_token(private_key, email, expiration_seconds = 600, user_id = nil, first_name = nil, last_name = nil)
52
54
  # token consists of an id and the signing key
53
55
  key_id, key = private_key.split('.')
54
56
  # transform signing key hex into bytes
@@ -60,6 +62,12 @@ module Canvas
60
62
  if user_id != nil
61
63
  message['userId'] = user_id
62
64
  end
65
+ if first_name != nil
66
+ message['firstName'] = first_name
67
+ end
68
+ if last_name != nil
69
+ message['lastName'] = last_name
70
+ end
63
71
  ciphertext = secret_box.encrypt(nonce, message.to_json)
64
72
  # transform bytes into hex
65
73
  unpacked_message = ciphertext.unpack1('H*')
Binary file
@@ -72,7 +72,7 @@ RSpec.describe Canvas::Embed do
72
72
  it 'generates login token' do
73
73
  key = RbNaCl::Random.random_bytes(RbNaCl::SecretBox.key_bytes)
74
74
  unpacked_key = "emk_ZRzQbE9d.#{key.unpack1('H*')}"
75
- token = Canvas::Embed.generate_login_token(unpacked_key, "will@cooldata.com", 300)
75
+ token = Canvas::Embed.generate_login_token(unpacked_key, "will@cooldata.com", 300, nil, 'Will', 'Pride')
76
76
  expect(token).not_to be nil
77
77
  decoded = JSON.parse(Base64.decode64(token))
78
78
  expect(decoded['keyId']).to eq('emk_ZRzQbE9d')
@@ -88,5 +88,7 @@ RSpec.describe Canvas::Embed do
88
88
 
89
89
  expect(context['exp']).to eq(Time.now.to_i + 300)
90
90
  expect(context['email']).to eq("will@cooldata.com")
91
+ expect(context['firstName']).to eq("Will")
92
+ expect(context['lastName']).to eq("Pride")
91
93
  end
92
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas-embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Pride
@@ -750,6 +750,7 @@ files:
750
750
  - example/tmp/cache/bootsnap/compile-cache-iseq/58/ce4e5a5616a378
751
751
  - example/tmp/cache/bootsnap/compile-cache-iseq/58/d83fa9153995fa
752
752
  - example/tmp/cache/bootsnap/compile-cache-iseq/58/ebec9d8d82e685
753
+ - example/tmp/cache/bootsnap/compile-cache-iseq/59/0d65aeae3bfcf5
753
754
  - example/tmp/cache/bootsnap/compile-cache-iseq/59/0fa877068d7b7a
754
755
  - example/tmp/cache/bootsnap/compile-cache-iseq/59/37dbe610324b9a
755
756
  - example/tmp/cache/bootsnap/compile-cache-iseq/59/74af0c851db4e1
@@ -811,6 +812,7 @@ files:
811
812
  - example/tmp/cache/bootsnap/compile-cache-iseq/5e/6ac5205eb89cd4
812
813
  - example/tmp/cache/bootsnap/compile-cache-iseq/5e/c3be5d2d8bffba
813
814
  - example/tmp/cache/bootsnap/compile-cache-iseq/5e/d9ad893e8820e2
815
+ - example/tmp/cache/bootsnap/compile-cache-iseq/5f/1d2d46bdaad8f0
814
816
  - example/tmp/cache/bootsnap/compile-cache-iseq/5f/35699ef0fc15b7
815
817
  - example/tmp/cache/bootsnap/compile-cache-iseq/5f/48b67093a26f34
816
818
  - example/tmp/cache/bootsnap/compile-cache-iseq/5f/68581e6b78f6b1
@@ -2016,6 +2018,7 @@ files:
2016
2018
  - lib/canvas/embed/version.rb
2017
2019
  - pkg/canvas-embed-0.1.5.gem
2018
2020
  - pkg/canvas-embed-0.1.6.gem
2021
+ - pkg/canvas-embed-0.1.7.gem
2019
2022
  - sig/canvas/embed.rbs
2020
2023
  - spec/canvas/embed_spec.rb
2021
2024
  - spec/spec_helper.rb