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.



374
375
376
377
378
379
380
381
# File 'lib/dommy/crypto.rb', line 374

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.



372
373
374
# File 'lib/dommy/crypto.rb', line 372

def algorithm_name
  @algorithm_name
end

#extractableObject (readonly)

Returns the value of attribute extractable.



372
373
374
# File 'lib/dommy/crypto.rb', line 372

def extractable
  @extractable
end

#hash_nameObject (readonly)

Returns the value of attribute hash_name.



372
373
374
# File 'lib/dommy/crypto.rb', line 372

def hash_name
  @hash_name
end

#typeObject (readonly)

Returns the value of attribute type.



372
373
374
# File 'lib/dommy/crypto.rb', line 372

def type
  @type
end

#usagesObject (readonly)

Returns the value of attribute usages.



372
373
374
# File 'lib/dommy/crypto.rb', line 372

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.



385
386
387
# File 'lib/dommy/crypto.rb', line 385

def __dommy_bytes__
  @bytes
end

#__js_get__(key) ⇒ Object



389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/dommy/crypto.rb', line 389

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