Class: Dommy::CryptoKey

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/crypto.rb

Overview

‘CryptoKey` — opaque key handle returned by SubtleCrypto. `extractable: false` keys reject export attempts; the raw bytes are reachable only through the `dommy_bytes` ecosystem accessor, never the public (Web-mirroring) API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, algorithm_name, hash_name, bytes, extractable: true, usages: []) ⇒ CryptoKey

Returns a new instance of CryptoKey.



368
369
370
371
372
373
374
375
# File 'lib/dommy/crypto.rb', line 368

def initialize(type, algorithm_name, hash_name, bytes, extractable: true, usages: [])
  @type = type
  @algorithm_name = algorithm_name
  @hash_name = hash_name
  @bytes = bytes
  @extractable = extractable
  @usages = usages.map(&:to_s).freeze
end

Instance Attribute Details

#algorithm_nameObject (readonly)

Returns the value of attribute algorithm_name.



366
367
368
# File 'lib/dommy/crypto.rb', line 366

def algorithm_name
  @algorithm_name
end

#extractableObject (readonly)

Returns the value of attribute extractable.



366
367
368
# File 'lib/dommy/crypto.rb', line 366

def extractable
  @extractable
end

#hash_nameObject (readonly)

Returns the value of attribute hash_name.



366
367
368
# File 'lib/dommy/crypto.rb', line 366

def hash_name
  @hash_name
end

#typeObject (readonly)

Returns the value of attribute type.



366
367
368
# File 'lib/dommy/crypto.rb', line 366

def type
  @type
end

#usagesObject (readonly)

Returns the value of attribute usages.



366
367
368
# File 'lib/dommy/crypto.rb', line 366

def usages
  @usages
end

Instance Method Details

#__dommy_bytes__Object

Low-level ecosystem accessor (see _dommy convention) — the public Web API never exposes raw key bytes.



379
380
381
# File 'lib/dommy/crypto.rb', line 379

def __dommy_bytes__
  @bytes
end

#__js_get__(key) ⇒ Object



383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/dommy/crypto.rb', line 383

def __js_get__(key)
  case key
  when "type"
    @type.to_s
  when "extractable"
    @extractable
  when "algorithm"
    {"name" => @algorithm_name, "hash" => {"name" => @hash_name}}
  when "usages"
    @usages
  end
end