@dfinity/identity
Advanced tools
Comparing version 0.8.9 to 0.9.0
@@ -1,2 +0,4 @@ | ||
import { BinaryBlob, DerEncodedBlob, HttpAgentRequest, Principal, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { HttpAgentRequest, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { BinaryBlob, DerEncodedBlob } from '@dfinity/candid'; | ||
import { Principal } from '@dfinity/principal'; | ||
import * as cbor from 'simple-cbor'; | ||
@@ -3,0 +5,0 @@ /** |
@@ -35,2 +35,4 @@ "use strict"; | ||
const agent_1 = require("@dfinity/agent"); | ||
const candid_1 = require("@dfinity/candid"); | ||
const principal_1 = require("@dfinity/principal"); | ||
const buffer_1 = require("buffer/"); | ||
@@ -44,3 +46,3 @@ const cbor = __importStar(require("simple-cbor")); | ||
} | ||
return agent_1.blobFromHex(value); | ||
return candid_1.blobFromHex(value); | ||
} | ||
@@ -62,3 +64,3 @@ /** | ||
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.toBlob()))), | ||
targets: cbor.value.array(this.targets.map(t => cbor.value.bytes(t.toUint8Array()))), | ||
}))); | ||
@@ -70,3 +72,3 @@ } | ||
// After de-hex, if it's not obvious what it is, it's an ArrayBuffer. | ||
return Object.assign({ expiration: this.expiration.toString(16), pubkey: this.pubkey.toString('hex') }, (this.targets && { targets: this.targets.map(p => p.toBlob().toString('hex')) })); | ||
return Object.assign({ expiration: this.expiration.toString(16), pubkey: this.pubkey.toString('hex') }, (this.targets && { targets: this.targets.map(p => p.toHex()) })); | ||
} | ||
@@ -92,3 +94,3 @@ } | ||
const challenge = new Uint8Array([...domainSeparator, ...agent_1.requestIdOf(delegation)]); | ||
const signature = await from.sign(agent_1.blobFromUint8Array(challenge)); | ||
const signature = await from.sign(candid_1.blobFromUint8Array(challenge)); | ||
return { | ||
@@ -168,3 +170,3 @@ delegation, | ||
} | ||
return agent_1.Principal.fromHex(t); | ||
return principal_1.Principal.fromHex(t); | ||
})), | ||
@@ -174,3 +176,3 @@ signature: _parseBlob(signature), | ||
}); | ||
return new this(parsedDelegations, agent_1.derBlobFromBlob(_parseBlob(publicKey))); | ||
return new this(parsedDelegations, candid_1.derBlobFromBlob(_parseBlob(publicKey))); | ||
} | ||
@@ -193,3 +195,3 @@ /** | ||
delegation: Object.assign({ expiration: delegation.expiration.toString(16), pubkey: delegation.pubkey.toString('hex') }, (targets && { | ||
targets: targets.map(t => t.toBlob().toString('hex')), | ||
targets: targets.map(t => t.toHex()), | ||
})), | ||
@@ -241,3 +243,3 @@ signature: signature.toString('hex'), | ||
content: body, | ||
sender_sig: await this.sign(agent_1.blobFromUint8Array(buffer_1.Buffer.concat([requestDomainSeparator, requestId]))), | ||
sender_sig: await this.sign(candid_1.blobFromUint8Array(buffer_1.Buffer.concat([requestDomainSeparator, requestId]))), | ||
sender_delegation: this._delegation.delegations, | ||
@@ -244,0 +246,0 @@ sender_pubkey: this._delegation.publicKey, |
@@ -1,2 +0,3 @@ | ||
import { BinaryBlob, DerEncodedBlob, KeyPair, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { KeyPair, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { BinaryBlob, DerEncodedBlob } from '@dfinity/candid'; | ||
export declare class Ed25519PublicKey implements PublicKey { | ||
@@ -3,0 +4,0 @@ static from(key: PublicKey): Ed25519PublicKey; |
@@ -24,2 +24,3 @@ "use strict"; | ||
const agent_1 = require("@dfinity/agent"); | ||
const candid_1 = require("@dfinity/candid"); | ||
const buffer_1 = require("buffer/"); | ||
@@ -52,3 +53,3 @@ const tweetnacl = __importStar(require("tweetnacl")); | ||
]); | ||
return agent_1.derBlobFromBlob(agent_1.blobFromUint8Array(derPublicKey)); | ||
return candid_1.derBlobFromBlob(candid_1.blobFromUint8Array(derPublicKey)); | ||
} | ||
@@ -61,3 +62,3 @@ static derDecode(key) { | ||
} | ||
const rawKey = agent_1.blobFromUint8Array(key.subarray(Ed25519PublicKey.DER_PREFIX.length)); | ||
const rawKey = candid_1.blobFromUint8Array(key.subarray(Ed25519PublicKey.DER_PREFIX.length)); | ||
if (!this.derEncode(rawKey).equals(key)) { | ||
@@ -102,7 +103,7 @@ throw new TypeError('Ed25519 DER-encoded public key is invalid. A valid Ed25519 DER-encoded public key ' + | ||
const { publicKey, secretKey } = seed === undefined ? tweetnacl.sign.keyPair() : tweetnacl.sign.keyPair.fromSeed(seed); | ||
return new this(Ed25519PublicKey.fromRaw(agent_1.blobFromUint8Array(publicKey)), agent_1.blobFromUint8Array(secretKey)); | ||
return new this(Ed25519PublicKey.fromRaw(candid_1.blobFromUint8Array(publicKey)), candid_1.blobFromUint8Array(secretKey)); | ||
} | ||
static fromParsedJson(obj) { | ||
const [publicKeyDer, privateKeyRaw] = obj; | ||
return new Ed25519KeyIdentity(Ed25519PublicKey.fromDer(agent_1.blobFromHex(publicKeyDer)), agent_1.blobFromHex(privateKeyRaw)); | ||
return new Ed25519KeyIdentity(Ed25519PublicKey.fromDer(candid_1.blobFromHex(publicKeyDer)), candid_1.blobFromHex(privateKeyRaw)); | ||
} | ||
@@ -122,9 +123,9 @@ static fromJSON(json) { | ||
const pk = publicKey | ||
? Ed25519PublicKey.fromRaw(agent_1.blobFromUint8Array(new Uint8Array(publicKey.data))) | ||
: Ed25519PublicKey.fromDer(agent_1.blobFromUint8Array(new Uint8Array(_publicKey.data))); | ||
? Ed25519PublicKey.fromRaw(candid_1.blobFromUint8Array(new Uint8Array(publicKey.data))) | ||
: Ed25519PublicKey.fromDer(candid_1.blobFromUint8Array(new Uint8Array(_publicKey.data))); | ||
if (publicKey && secretKey && secretKey.data) { | ||
return new Ed25519KeyIdentity(pk, agent_1.blobFromUint8Array(new Uint8Array(secretKey.data))); | ||
return new Ed25519KeyIdentity(pk, candid_1.blobFromUint8Array(new Uint8Array(secretKey.data))); | ||
} | ||
else if (_publicKey && _privateKey && _privateKey.data) { | ||
return new Ed25519KeyIdentity(pk, agent_1.blobFromUint8Array(new Uint8Array(_privateKey.data))); | ||
return new Ed25519KeyIdentity(pk, candid_1.blobFromUint8Array(new Uint8Array(_privateKey.data))); | ||
} | ||
@@ -139,3 +140,3 @@ } | ||
const keyPair = tweetnacl.sign.keyPair.fromSecretKey(new Uint8Array(secretKey)); | ||
const identity = Ed25519KeyIdentity.fromKeyPair(agent_1.blobFromUint8Array(keyPair.publicKey), agent_1.blobFromUint8Array(keyPair.secretKey)); | ||
const identity = Ed25519KeyIdentity.fromKeyPair(candid_1.blobFromUint8Array(keyPair.publicKey), candid_1.blobFromUint8Array(keyPair.secretKey)); | ||
return identity; | ||
@@ -147,3 +148,3 @@ } | ||
toJSON() { | ||
return [agent_1.blobToHex(this._publicKey.toDer()), agent_1.blobToHex(this._privateKey)]; | ||
return [candid_1.blobToHex(this._publicKey.toDer()), candid_1.blobToHex(this._privateKey)]; | ||
} | ||
@@ -155,3 +156,3 @@ /** | ||
return { | ||
secretKey: agent_1.blobFromUint8Array(new Uint8Array(this._privateKey)), | ||
secretKey: candid_1.blobFromUint8Array(new Uint8Array(this._privateKey)), | ||
publicKey: this._publicKey, | ||
@@ -172,6 +173,6 @@ }; | ||
const blob = challenge instanceof buffer_1.Buffer | ||
? agent_1.blobFromBuffer(challenge) | ||
: agent_1.blobFromUint8Array(new Uint8Array(challenge)); | ||
? candid_1.blobFromBuffer(challenge) | ||
: candid_1.blobFromUint8Array(new Uint8Array(challenge)); | ||
const signature = tweetnacl.sign.detached(blob, this._privateKey); | ||
return agent_1.blobFromUint8Array(signature); | ||
return candid_1.blobFromUint8Array(signature); | ||
} | ||
@@ -178,0 +179,0 @@ } |
@@ -1,2 +0,3 @@ | ||
import { BinaryBlob, DerEncodedBlob, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { BinaryBlob, DerEncodedBlob } from '@dfinity/candid'; | ||
export declare class CosePublicKey implements PublicKey { | ||
@@ -3,0 +4,0 @@ protected _cose: BinaryBlob; |
@@ -27,2 +27,3 @@ "use strict"; | ||
const agent_1 = require("@dfinity/agent"); | ||
const candid_1 = require("@dfinity/candid"); | ||
const borc_1 = __importDefault(require("borc")); | ||
@@ -45,3 +46,3 @@ const tweetnacl = __importStar(require("tweetnacl")); | ||
]); | ||
return agent_1.derBlobFromBlob(agent_1.blobFromUint8Array(der)); | ||
return candid_1.derBlobFromBlob(candid_1.blobFromUint8Array(der)); | ||
} | ||
@@ -156,3 +157,3 @@ /** | ||
} | ||
return new this(agent_1.blobFromHex(rawId), agent_1.blobFromHex(publicKey)); | ||
return new this(candid_1.blobFromHex(rawId), candid_1.blobFromHex(publicKey)); | ||
} | ||
@@ -174,3 +175,3 @@ /** | ||
const attObject = borc_1.default.decodeFirst(new Uint8Array(response.attestationObject)); | ||
return new this(agent_1.blobFromUint8Array(new Uint8Array(creds.rawId)), agent_1.blobFromUint8Array(new Uint8Array(_authDataToCose(attObject.authData)))); | ||
return new this(candid_1.blobFromUint8Array(new Uint8Array(creds.rawId)), candid_1.blobFromUint8Array(new Uint8Array(_authDataToCose(attObject.authData)))); | ||
} | ||
@@ -204,3 +205,3 @@ getPublicKey() { | ||
} | ||
return agent_1.blobFromUint8Array(new Uint8Array(cbor)); | ||
return candid_1.blobFromUint8Array(new Uint8Array(cbor)); | ||
} | ||
@@ -207,0 +208,0 @@ else { |
export { Ed25519KeyIdentity, Ed25519PublicKey } from './identity/ed25519'; | ||
export { Delegation, DelegationIdentity, DelegationChain, SignedDelegation } from './identity/delegation'; | ||
export { Delegation, DelegationIdentity, DelegationChain, SignedDelegation, } from './identity/delegation'; | ||
export { WebAuthnIdentity } from './identity/webauthn'; |
@@ -1,2 +0,4 @@ | ||
import { BinaryBlob, DerEncodedBlob, HttpAgentRequest, Principal, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { HttpAgentRequest, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { BinaryBlob, DerEncodedBlob } from '@dfinity/candid'; | ||
import { Principal } from '@dfinity/principal'; | ||
import * as cbor from 'simple-cbor'; | ||
@@ -3,0 +5,0 @@ /** |
@@ -12,3 +12,5 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
}; | ||
import { blobFromHex, blobFromUint8Array, derBlobFromBlob, Principal, requestIdOf, SignIdentity, } from '@dfinity/agent'; | ||
import { requestIdOf, SignIdentity } from '@dfinity/agent'; | ||
import { blobFromHex, blobFromUint8Array, derBlobFromBlob, } from '@dfinity/candid'; | ||
import { Principal } from '@dfinity/principal'; | ||
import { Buffer } from 'buffer/'; | ||
@@ -39,3 +41,3 @@ import * as cbor from 'simple-cbor'; | ||
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.toBlob()))), | ||
targets: cbor.value.array(this.targets.map(t => cbor.value.bytes(t.toUint8Array()))), | ||
}))); | ||
@@ -47,3 +49,3 @@ } | ||
// After de-hex, if it's not obvious what it is, it's an ArrayBuffer. | ||
return Object.assign({ expiration: this.expiration.toString(16), pubkey: this.pubkey.toString('hex') }, (this.targets && { targets: this.targets.map(p => p.toBlob().toString('hex')) })); | ||
return Object.assign({ expiration: this.expiration.toString(16), pubkey: this.pubkey.toString('hex') }, (this.targets && { targets: this.targets.map(p => p.toHex()) })); | ||
} | ||
@@ -166,3 +168,3 @@ } | ||
delegation: Object.assign({ expiration: delegation.expiration.toString(16), pubkey: delegation.pubkey.toString('hex') }, (targets && { | ||
targets: targets.map(t => t.toBlob().toString('hex')), | ||
targets: targets.map(t => t.toHex()), | ||
})), | ||
@@ -169,0 +171,0 @@ signature: signature.toString('hex'), |
@@ -1,2 +0,3 @@ | ||
import { BinaryBlob, DerEncodedBlob, KeyPair, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { KeyPair, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { BinaryBlob, DerEncodedBlob } from '@dfinity/candid'; | ||
export declare class Ed25519PublicKey implements PublicKey { | ||
@@ -3,0 +4,0 @@ static from(key: PublicKey): Ed25519PublicKey; |
@@ -1,2 +0,3 @@ | ||
import { blobFromHex, blobFromUint8Array, blobToHex, derBlobFromBlob, SignIdentity, blobFromBuffer, } from '@dfinity/agent'; | ||
import { SignIdentity } from '@dfinity/agent'; | ||
import { blobFromHex, blobFromUint8Array, blobToHex, derBlobFromBlob, blobFromBuffer, } from '@dfinity/candid'; | ||
import { Buffer } from 'buffer/'; | ||
@@ -3,0 +4,0 @@ import * as tweetnacl from 'tweetnacl'; |
@@ -1,2 +0,3 @@ | ||
import { BinaryBlob, DerEncodedBlob, PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { PublicKey, SignIdentity } from '@dfinity/agent'; | ||
import { BinaryBlob, DerEncodedBlob } from '@dfinity/candid'; | ||
export declare class CosePublicKey implements PublicKey { | ||
@@ -3,0 +4,0 @@ protected _cose: BinaryBlob; |
@@ -1,2 +0,3 @@ | ||
import { blobFromHex, blobFromUint8Array, derBlobFromBlob, SignIdentity, } from '@dfinity/agent'; | ||
import { SignIdentity } from '@dfinity/agent'; | ||
import { blobFromHex, blobFromUint8Array, derBlobFromBlob, } from '@dfinity/candid'; | ||
import borc from 'borc'; | ||
@@ -3,0 +4,0 @@ import * as tweetnacl from 'tweetnacl'; |
export { Ed25519KeyIdentity, Ed25519PublicKey } from './identity/ed25519'; | ||
export { Delegation, DelegationIdentity, DelegationChain, SignedDelegation } from './identity/delegation'; | ||
export { Delegation, DelegationIdentity, DelegationChain, SignedDelegation, } from './identity/delegation'; | ||
export { WebAuthnIdentity } from './identity/webauthn'; |
export { Ed25519KeyIdentity, Ed25519PublicKey } from './identity/ed25519'; | ||
export { Delegation, DelegationIdentity, DelegationChain } from './identity/delegation'; | ||
export { Delegation, DelegationIdentity, DelegationChain, } from './identity/delegation'; | ||
export { WebAuthnIdentity } from './identity/webauthn'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@dfinity/identity", | ||
"version": "0.8.9", | ||
"version": "0.9.0", | ||
"author": "DFINITY Stiftung <sdk@dfinity.org>", | ||
@@ -32,15 +32,16 @@ "license": "Apache-2.0", | ||
"bundle": "npm run build", | ||
"ci": "npm run prettier && npm run lint && npm run test", | ||
"lint": "eslint 'src' --ext '.js,.jsx,.ts,.tsx'", | ||
"lint:fix": "npm run lint -- --fix", | ||
"make:docs/reference": "typedoc src/index.ts --out docs/reference", | ||
"prettier": "prettier --check \"src/**/*.ts\"", | ||
"prettier:write": "npm run prettier -- --write", | ||
"release": "npm publish", | ||
"test": "jest", | ||
"test:coverage": "jest --verbose --collectCoverage" | ||
}, | ||
"peerDependencies": { | ||
"@dfinity/agent": "^0.9.0", | ||
"@dfinity/principal": "^0.9.0" | ||
}, | ||
"dependencies": { | ||
"@dfinity/agent": "^0.8.9", | ||
"borc": "^2.1.1", | ||
"buffer": "^5.4.3", | ||
"buffer": "^6.0.3", | ||
"buffer-pipe": "0.0.4", | ||
@@ -58,3 +59,2 @@ "tweetnacl": "^1.0.1" | ||
"jest-expect-message": "^1.0.2", | ||
"prettier": "^2.0.5", | ||
"text-encoding": "^0.7.0", | ||
@@ -61,0 +61,0 @@ "ts-jest": "^26.5.4", |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
300275
14
1703
6
+ Added@dfinity/agent@0.9.3(transitive)
+ Added@dfinity/candid@0.9.3(transitive)
+ Added@dfinity/principal@0.9.3(transitive)
+ Addedbuffer@6.0.3(transitive)
- Removed@dfinity/agent@^0.8.9
- Removed@dfinity/agent@0.8.9(transitive)
Updatedbuffer@^6.0.3