has_secure_passkey 0.3.1 → 0.3.3

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: 8fc5a0356ffd3d9052c4d81a6c91b9ef060531c28ab5a5ec4d8d8d70d61c59a2
4
- data.tar.gz: c89cea72c38724457df06994965ee62146c1859024c21935dd8ec3e94f6ddeed
3
+ metadata.gz: 3eab5ee70ccfea08186b833b0518cdc01465849e56359884c0833f70749ffcfb
4
+ data.tar.gz: 3dd388e2837c0a5f4778c593b1de856700512f62421d31d3969d1e08fe89ab57
5
5
  SHA512:
6
- metadata.gz: 47b745ced4af0092045f64c8384a6c6e41286894c211d6aff8927cc7401ef05c26cc440aaf033f4e0aaa8b5274e96f0bfae4aa8a9d96f57fbd8fe9803f786462
7
- data.tar.gz: 0727d730d7c6428a25eab0c8a1430ccf76d5f1c89c280e6ea278c303c49a59dff5dd3a691a5b60298edfcf23a8d9c466bb9efb8e9f464305245c0601976e55a6
6
+ metadata.gz: cf56aac96bbc8be0b1e8b3b2d563ce7641af0f3da39f7e31237f5a0fd9e3e983d4a21c1e7ed6a4d527729bbf07e2a090302ca8e8679934f2dee99fb58780563d
7
+ data.tar.gz: 0aa13ccf4937a16b28577efbbe608d23c7a457b33a430abf630173161ad72005ce1c8dc08d2e1036027135bf2d86e86be9eaed257d7dad847ac49a240cd947cf
@@ -1,7 +1,7 @@
1
1
  import { post } from "@rails/request.js"
2
2
 
3
3
  export default class WebAuthn extends HTMLElement {
4
- static observedAttributes = ["action", "callback", "options"];
4
+ static observedAttributes = ["action", "callback", "options", "delay"];
5
5
 
6
6
  constructor() {
7
7
  super();
@@ -11,7 +11,11 @@ export default class WebAuthn extends HTMLElement {
11
11
  this.progressBar = Turbo.navigator.delegate.adapter.progressBar
12
12
  this.setAttribute("data-turbo-temporary", 1)
13
13
  this.setAttribute("data-turbo-track", "reload")
14
- this.run()
14
+ if (this.delay) {
15
+ setTimeout(() => this.run(), Number(this.delay))
16
+ } else {
17
+ this.run()
18
+ }
15
19
  }
16
20
 
17
21
  run() {
@@ -70,6 +74,10 @@ export default class WebAuthn extends HTMLElement {
70
74
  return this.getAttribute('callback');
71
75
  }
72
76
 
77
+ get delay() {
78
+ return this.getAttribute('delay');
79
+ }
80
+
73
81
  get options() {
74
82
  return JSON.parse(this.getAttribute('options'));
75
83
  }
@@ -80,7 +88,7 @@ export default class WebAuthn extends HTMLElement {
80
88
 
81
89
  get publicKey() {
82
90
  if (this.action === "create") {
83
- return PublicKeyCredential.parseCreationOptionsFromJSON(this.options);
91
+ return PublicKeyCredential.parseCreationOptionsFromJSON(this.options.publicKey);
84
92
  } else {
85
93
  return PublicKeyCredential.parseRequestOptionsFromJSON(this.options);
86
94
  }
@@ -286,7 +286,7 @@ async function post(url, options) {
286
286
 
287
287
  // app/assets/javascripts/components/web_authn.js
288
288
  class WebAuthn extends HTMLElement {
289
- static observedAttributes = ["action", "callback", "options"];
289
+ static observedAttributes = ["action", "callback", "options", "delay"];
290
290
  constructor() {
291
291
  super();
292
292
  }
@@ -294,7 +294,11 @@ class WebAuthn extends HTMLElement {
294
294
  this.progressBar = Turbo.navigator.delegate.adapter.progressBar;
295
295
  this.setAttribute("data-turbo-temporary", 1);
296
296
  this.setAttribute("data-turbo-track", "reload");
297
- this.run();
297
+ if (this.delay) {
298
+ setTimeout(() => this.run(), Number(this.delay));
299
+ } else {
300
+ this.run();
301
+ }
298
302
  }
299
303
  run() {
300
304
  navigator.credentials[this.action]({ publicKey: this.publicKey }).then(async (credential) => {
@@ -343,6 +347,9 @@ class WebAuthn extends HTMLElement {
343
347
  get callback() {
344
348
  return this.getAttribute("callback");
345
349
  }
350
+ get delay() {
351
+ return this.getAttribute("delay");
352
+ }
346
353
  get options() {
347
354
  return JSON.parse(this.getAttribute("options"));
348
355
  }
@@ -351,7 +358,7 @@ class WebAuthn extends HTMLElement {
351
358
  }
352
359
  get publicKey() {
353
360
  if (this.action === "create") {
354
- return PublicKeyCredential.parseCreationOptionsFromJSON(this.options);
361
+ return PublicKeyCredential.parseCreationOptionsFromJSON(this.options.publicKey);
355
362
  } else {
356
363
  return PublicKeyCredential.parseRequestOptionsFromJSON(this.options);
357
364
  }
@@ -28,7 +28,7 @@ class HasSecurePasskey::OptionsForCreate
28
28
  end
29
29
 
30
30
  def as_json
31
- credential.as_json
31
+ options
32
32
  end
33
33
 
34
34
  def challenge
@@ -1,3 +1,3 @@
1
1
  module HasSecurePasskey
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_secure_passkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza