@dfinity/identity
Advanced tools
@@ -54,2 +54,3 @@ "use strict"; | ||
const partial_1 = require("./partial"); | ||
const candid_1 = require("@dfinity/candid"); | ||
const domainSeparator = new TextEncoder().encode('\x1Aic-request-auth-delegation'); | ||
@@ -78,3 +79,3 @@ const requestDomainSeparator = new TextEncoder().encode('\x0Aic-request'); | ||
return cbor.value.map(Object.assign({ pubkey: cbor.value.bytes(this.pubkey), expiration: cbor.value.u64(this.expiration.toString(16), 16) }, (this.targets && { | ||
targets: cbor.value.array(this.targets.map(t => cbor.value.bytes(t.toUint8Array()))), | ||
targets: cbor.value.array(this.targets.map(t => cbor.value.bytes((0, candid_1.bufFromBufLike)(t.toUint8Array())))), | ||
}))); | ||
@@ -109,3 +110,3 @@ } | ||
]); | ||
const signature = await from.sign(challenge); | ||
const signature = await from.sign((0, candid_1.bufFromBufLike)(challenge)); | ||
return { | ||
@@ -251,3 +252,3 @@ delegation, | ||
content: body, | ||
sender_sig: await this.sign(new Uint8Array([...requestDomainSeparator, ...new Uint8Array(requestId)])), | ||
sender_sig: await this.sign((0, candid_1.bufFromBufLike)(new Uint8Array([...requestDomainSeparator, ...new Uint8Array(requestId)]))), | ||
sender_delegation: this._delegation.delegations, | ||
@@ -254,0 +255,0 @@ sender_pubkey: this._delegation.publicKey, |
@@ -30,3 +30,3 @@ "use strict"; | ||
} | ||
__classPrivateFieldSet(this, _Ed25519PublicKey_rawKey, key, "f"); | ||
__classPrivateFieldSet(this, _Ed25519PublicKey_rawKey, (0, agent_2.bufFromBufLike)(key), "f"); | ||
__classPrivateFieldSet(this, _Ed25519PublicKey_derKey, Ed25519PublicKey.derEncode(key), "f"); | ||
@@ -84,3 +84,3 @@ } | ||
} | ||
return unwrapped; | ||
return (0, agent_2.bufFromBufLike)(unwrapped); | ||
} | ||
@@ -209,7 +209,7 @@ get rawKey() { | ||
if (x instanceof Uint8Array) { | ||
x = x.buffer; | ||
x = (0, agent_2.bufFromBufLike)(x.buffer); | ||
} | ||
return new Uint8Array(x); | ||
}); | ||
return ed25519_1.ed25519.verify(message, signature, publicKey); | ||
return ed25519_1.ed25519.verify(signature, message, publicKey); | ||
} | ||
@@ -216,0 +216,0 @@ } |
@@ -53,3 +53,6 @@ "use strict"; | ||
getPrincipal() { | ||
return principal_1.Principal.from(__classPrivateFieldGet(this, _PartialIdentity_inner, "f").rawKey); | ||
if (!__classPrivateFieldGet(this, _PartialIdentity_inner, "f").rawKey) { | ||
throw new Error('Cannot get principal from a public key without a raw key.'); | ||
} | ||
return principal_1.Principal.fromUint8Array(new Uint8Array(__classPrivateFieldGet(this, _PartialIdentity_inner, "f").rawKey)); | ||
} | ||
@@ -56,0 +59,0 @@ /** |
@@ -28,2 +28,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
import { PartialIdentity } from './partial'; | ||
import { bufFromBufLike } from '@dfinity/candid'; | ||
const domainSeparator = new TextEncoder().encode('\x1Aic-request-auth-delegation'); | ||
@@ -52,3 +53,3 @@ const requestDomainSeparator = new TextEncoder().encode('\x0Aic-request'); | ||
return cbor.value.map(Object.assign({ pubkey: cbor.value.bytes(this.pubkey), expiration: cbor.value.u64(this.expiration.toString(16), 16) }, (this.targets && { | ||
targets: cbor.value.array(this.targets.map(t => cbor.value.bytes(t.toUint8Array()))), | ||
targets: cbor.value.array(this.targets.map(t => cbor.value.bytes(bufFromBufLike(t.toUint8Array())))), | ||
}))); | ||
@@ -82,3 +83,3 @@ } | ||
]); | ||
const signature = await from.sign(challenge); | ||
const signature = await from.sign(bufFromBufLike(challenge)); | ||
return { | ||
@@ -223,3 +224,3 @@ delegation, | ||
content: body, | ||
sender_sig: await this.sign(new Uint8Array([...requestDomainSeparator, ...new Uint8Array(requestId)])), | ||
sender_sig: await this.sign(bufFromBufLike(new Uint8Array([...requestDomainSeparator, ...new Uint8Array(requestId)]))), | ||
sender_delegation: this._delegation.delegations, | ||
@@ -226,0 +227,0 @@ sender_pubkey: this._delegation.publicKey, |
@@ -27,3 +27,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
} | ||
__classPrivateFieldSet(this, _Ed25519PublicKey_rawKey, key, "f"); | ||
__classPrivateFieldSet(this, _Ed25519PublicKey_rawKey, bufFromBufLike(key), "f"); | ||
__classPrivateFieldSet(this, _Ed25519PublicKey_derKey, Ed25519PublicKey.derEncode(key), "f"); | ||
@@ -81,3 +81,3 @@ } | ||
} | ||
return unwrapped; | ||
return bufFromBufLike(unwrapped); | ||
} | ||
@@ -205,7 +205,7 @@ get rawKey() { | ||
if (x instanceof Uint8Array) { | ||
x = x.buffer; | ||
x = bufFromBufLike(x.buffer); | ||
} | ||
return new Uint8Array(x); | ||
}); | ||
return ed25519.verify(message, signature, publicKey); | ||
return ed25519.verify(signature, message, publicKey); | ||
} | ||
@@ -212,0 +212,0 @@ } |
@@ -50,3 +50,6 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
getPrincipal() { | ||
return Principal.from(__classPrivateFieldGet(this, _PartialIdentity_inner, "f").rawKey); | ||
if (!__classPrivateFieldGet(this, _PartialIdentity_inner, "f").rawKey) { | ||
throw new Error('Cannot get principal from a public key without a raw key.'); | ||
} | ||
return Principal.fromUint8Array(new Uint8Array(__classPrivateFieldGet(this, _PartialIdentity_inner, "f").rawKey)); | ||
} | ||
@@ -53,0 +56,0 @@ /** |
{ | ||
"name": "@dfinity/identity", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"author": "DFINITY Stiftung <sdk@dfinity.org>", | ||
@@ -48,4 +48,4 @@ "license": "Apache-2.0", | ||
"peerDependencies": { | ||
"@dfinity/agent": "^2.4.0", | ||
"@dfinity/principal": "^2.4.0" | ||
"@dfinity/agent": "^2.4.1", | ||
"@dfinity/principal": "^2.4.1" | ||
}, | ||
@@ -52,0 +52,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
333603
0.59%2608
0.31%