@astrox/identity 0.0.20 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/package.json +2 -2
  2. package/lib/cjs/buffer.d.ts +0 -10
  3. package/lib/cjs/buffer.js +0 -21
  4. package/lib/cjs/buffer.js.map +0 -1
  5. package/lib/cjs/identity/delegation.d.ts +0 -131
  6. package/lib/cjs/identity/delegation.js +0 -244
  7. package/lib/cjs/identity/delegation.js.map +0 -1
  8. package/lib/cjs/identity/der.d.ts +0 -26
  9. package/lib/cjs/identity/der.js +0 -145
  10. package/lib/cjs/identity/der.js.map +0 -1
  11. package/lib/cjs/identity/ed25519.d.ts +0 -45
  12. package/lib/cjs/identity/ed25519.js +0 -134
  13. package/lib/cjs/identity/ed25519.js.map +0 -1
  14. package/lib/cjs/identity/webauthn.d.ts +0 -40
  15. package/lib/cjs/identity/webauthn.js +0 -205
  16. package/lib/cjs/identity/webauthn.js.map +0 -1
  17. package/lib/cjs/index.d.ts +0 -4
  18. package/lib/cjs/index.js +0 -17
  19. package/lib/cjs/index.js.map +0 -1
  20. package/lib/esm/buffer.d.ts +0 -10
  21. package/lib/esm/buffer.js +0 -16
  22. package/lib/esm/buffer.js.map +0 -1
  23. package/lib/esm/identity/delegation.d.ts +0 -131
  24. package/lib/esm/identity/delegation.js +0 -219
  25. package/lib/esm/identity/delegation.js.map +0 -1
  26. package/lib/esm/identity/der.d.ts +0 -35
  27. package/lib/esm/identity/der.js +0 -168
  28. package/lib/esm/identity/der.js.map +0 -1
  29. package/lib/esm/identity/ed25519.d.ts +0 -45
  30. package/lib/esm/identity/ed25519.js +0 -110
  31. package/lib/esm/identity/ed25519.js.map +0 -1
  32. package/lib/esm/identity/secp256k1.d.ts +0 -73
  33. package/lib/esm/identity/secp256k1.js +0 -148
  34. package/lib/esm/identity/secp256k1.js.map +0 -1
  35. package/lib/esm/identity/webauthn.d.ts +0 -40
  36. package/lib/esm/identity/webauthn.js +0 -178
  37. package/lib/esm/identity/webauthn.js.map +0 -1
  38. package/lib/esm/index.d.ts +0 -4
  39. package/lib/esm/index.js +0 -5
  40. package/lib/esm/index.js.map +0 -1
  41. package/lib/tsconfig-cjs.tsbuildinfo +0 -1744
  42. package/lib/tsconfig.tsbuildinfo +0 -2508
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrox/identity",
3
- "version": "0.0.20",
3
+ "version": "0.0.24",
4
4
  "author": "DFINITY Stiftung <sdk@astrox.org>",
5
5
  "license": "Apache-2.0",
6
6
  "description": "JavaScript and TypeScript library to manage identity with the Internet Computer",
@@ -50,5 +50,5 @@
50
50
  "typescript": "^4.2.3",
51
51
  "whatwg-fetch": "^3.0.0"
52
52
  },
53
- "gitHead": "3856f14d314efd33983e030fe79355bd8be8779a"
53
+ "gitHead": "d30a12d7f9c700aff21fea4a3e9909fbf86dbce2"
54
54
  }
@@ -1,10 +0,0 @@
1
- /**
2
- * Return an array buffer from its hexadecimal representation.
3
- * @param hexString The hexadecimal string.
4
- */
5
- export declare function fromHexString(hexString: string): ArrayBuffer;
6
- /**
7
- * Returns an hexadecimal representation of an array buffer.
8
- * @param bytes The array buffer.
9
- */
10
- export declare function toHexString(bytes: ArrayBuffer): string;
package/lib/cjs/buffer.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toHexString = exports.fromHexString = void 0;
4
- /**
5
- * Return an array buffer from its hexadecimal representation.
6
- * @param hexString The hexadecimal string.
7
- */
8
- function fromHexString(hexString) {
9
- var _a;
10
- return new Uint8Array(((_a = hexString.match(/.{1,2}/g)) !== null && _a !== void 0 ? _a : []).map(byte => parseInt(byte, 16))).buffer;
11
- }
12
- exports.fromHexString = fromHexString;
13
- /**
14
- * Returns an hexadecimal representation of an array buffer.
15
- * @param bytes The array buffer.
16
- */
17
- function toHexString(bytes) {
18
- return new Uint8Array(bytes).reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
19
- }
20
- exports.toHexString = toHexString;
21
- //# sourceMappingURL=buffer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/buffer.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,SAAgB,aAAa,CAAC,SAAiB;;IAC7C,OAAO,IAAI,UAAU,CAAC,OAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACnG,CAAC;AAFD,sCAEC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAkB;IAC5C,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;AACnG,CAAC;AAFD,kCAEC"}
@@ -1,131 +0,0 @@
1
- import { DerEncodedPublicKey, HttpAgentRequest, PublicKey, Signature, SignIdentity } from '@astrox/agent';
2
- import { Principal } from '@astrox/principal';
3
- import * as cbor from 'simple-cbor';
4
- /**
5
- * A single delegation object that is signed by a private key. This is constructed by
6
- * `DelegationChain.create()`.
7
- *
8
- * {@see DelegationChain}
9
- */
10
- export declare class Delegation {
11
- readonly pubkey: ArrayBuffer;
12
- readonly expiration: bigint;
13
- readonly targets?: Principal[] | undefined;
14
- constructor(pubkey: ArrayBuffer, expiration: bigint, targets?: Principal[] | undefined);
15
- toCBOR(): cbor.CborValue;
16
- toJSON(): JsonnableDelegation;
17
- }
18
- /**
19
- * Type of ReturnType<Delegation.toJSON>.
20
- * The goal here is to stringify all non-JSON-compatible types to some bytes representation we can
21
- * stringify as hex.
22
- * (Hex shouldn't be ambiguous ever, because you can encode as DER with semantic OIDs).
23
- */
24
- interface JsonnableDelegation {
25
- expiration: string;
26
- pubkey: string;
27
- targets?: string[];
28
- }
29
- /**
30
- * A signed delegation, which lends its identity to the public key in the delegation
31
- * object. This is constructed by `DelegationChain.create()`.
32
- *
33
- * {@see DelegationChain}
34
- */
35
- export interface SignedDelegation {
36
- delegation: Delegation;
37
- signature: Signature;
38
- }
39
- export interface JsonnableDelegationChain {
40
- publicKey: string;
41
- delegations: Array<{
42
- signature: string;
43
- delegation: {
44
- pubkey: string;
45
- expiration: string;
46
- targets?: string[];
47
- };
48
- }>;
49
- }
50
- /**
51
- * A chain of delegations. This is JSON Serializable.
52
- * This is the object to serialize and pass to a DelegationIdentity. It does not keep any
53
- * private keys.
54
- */
55
- export declare class DelegationChain {
56
- readonly delegations: SignedDelegation[];
57
- readonly publicKey: DerEncodedPublicKey;
58
- /**
59
- * Create a delegation chain between two (or more) keys. By default, the expiration time
60
- * will be very short (15 minutes).
61
- *
62
- * To build a chain of more than 2 identities, this function needs to be called multiple times,
63
- * passing the previous delegation chain into the options argument. For example:
64
- *
65
- * @example
66
- * const rootKey = createKey();
67
- * const middleKey = createKey();
68
- * const bottomeKey = createKey();
69
- *
70
- * const rootToMiddle = await DelegationChain.create(
71
- * root, middle.getPublicKey(), Date.parse('2100-01-01'),
72
- * );
73
- * const middleToBottom = await DelegationChain.create(
74
- * middle, bottom.getPublicKey(), Date.parse('2100-01-01'), { previous: rootToMiddle },
75
- * );
76
- *
77
- * // We can now use a delegation identity that uses the delegation above:
78
- * const identity = DelegationIdentity.fromDelegation(bottomKey, middleToBottom);
79
- *
80
- * @param from The identity that will delegate.
81
- * @param to The identity that gets delegated. It can now sign messages as if it was the
82
- * identity above.
83
- * @param expiration The length the delegation is valid. By default, 15 minutes from calling
84
- * this function.
85
- * @param options A set of options for this delegation. expiration and previous
86
- * @param options.previous - Another DelegationChain that this chain should start with.
87
- * @param options.targets - targets that scope the delegation (e.g. Canister Principals)
88
- */
89
- static create(from: SignIdentity, to: PublicKey, expiration?: Date, options?: {
90
- previous?: DelegationChain;
91
- targets?: Principal[];
92
- }): Promise<DelegationChain>;
93
- /**
94
- * Creates a DelegationChain object from a JSON string.
95
- *
96
- * @param json The JSON string to parse.
97
- */
98
- static fromJSON(json: string | JsonnableDelegationChain): DelegationChain;
99
- /**
100
- * Creates a DelegationChain object from a list of delegations and a DER-encoded public key.
101
- *
102
- * @param delegations The list of delegations.
103
- * @param publicKey The DER-encoded public key of the key-pair signing the first delegation.
104
- */
105
- static fromDelegations(delegations: SignedDelegation[], publicKey: DerEncodedPublicKey): DelegationChain;
106
- protected constructor(delegations: SignedDelegation[], publicKey: DerEncodedPublicKey);
107
- toJSON(): JsonnableDelegationChain;
108
- }
109
- /**
110
- * An Identity that adds delegation to a request. Everywhere in this class, the name
111
- * innerKey refers to the SignIdentity that is being used to sign the requests, while
112
- * originalKey is the identity that is being borrowed. More identities can be used
113
- * in the middle to delegate.
114
- */
115
- export declare class DelegationIdentity extends SignIdentity {
116
- private _inner;
117
- private _delegation;
118
- /**
119
- * Create a delegation without having access to delegateKey.
120
- *
121
- * @param key The key used to sign the reqyests.
122
- * @param delegation A delegation object created using `createDelegation`.
123
- */
124
- static fromDelegation(key: Pick<SignIdentity, 'sign'>, delegation: DelegationChain): DelegationIdentity;
125
- protected constructor(_inner: Pick<SignIdentity, 'sign'>, _delegation: DelegationChain);
126
- getDelegation(): DelegationChain;
127
- getPublicKey(): PublicKey;
128
- sign(blob: ArrayBuffer): Promise<Signature>;
129
- transformRequest(request: HttpAgentRequest): Promise<unknown>;
130
- }
131
- export {};
@@ -1,244 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.DelegationIdentity = exports.DelegationChain = exports.Delegation = void 0;
34
- const agent_1 = require("@astrox/agent");
35
- const principal_1 = require("@astrox/principal");
36
- const cbor = __importStar(require("simple-cbor"));
37
- const buffer_1 = require("../buffer");
38
- const domainSeparator = new TextEncoder().encode('\x1Aic-request-auth-delegation');
39
- const requestDomainSeparator = new TextEncoder().encode('\x0Aic-request');
40
- function _parseBlob(value) {
41
- if (typeof value !== 'string' || value.length < 64) {
42
- throw new Error('Invalid public key.');
43
- }
44
- return buffer_1.fromHexString(value);
45
- }
46
- /**
47
- * A single delegation object that is signed by a private key. This is constructed by
48
- * `DelegationChain.create()`.
49
- *
50
- * {@see DelegationChain}
51
- */
52
- class Delegation {
53
- constructor(pubkey, expiration, targets) {
54
- this.pubkey = pubkey;
55
- this.expiration = expiration;
56
- this.targets = targets;
57
- }
58
- toCBOR() {
59
- // Expiration field needs to be encoded as a u64 specifically.
60
- return cbor.value.map(Object.assign({ pubkey: cbor.value.bytes(this.pubkey), expiration: cbor.value.u64(this.expiration.toString(16), 16) }, (this.targets && {
61
- targets: cbor.value.array(this.targets.map(t => cbor.value.bytes(t.toUint8Array()))),
62
- })));
63
- }
64
- toJSON() {
65
- // every string should be hex and once-de-hexed,
66
- // discoverable what it is (e.g. de-hex to get JSON with a 'type' property, or de-hex to DER
67
- // with an OID). After de-hex, if it's not obvious what it is, it's an ArrayBuffer.
68
- return Object.assign({ expiration: this.expiration.toString(16), pubkey: buffer_1.toHexString(this.pubkey) }, (this.targets && { targets: this.targets.map(p => p.toHex()) }));
69
- }
70
- }
71
- exports.Delegation = Delegation;
72
- /**
73
- * Sign a single delegation object for a period of time.
74
- *
75
- * @param from The identity that lends its delegation.
76
- * @param to The identity that receives the delegation.
77
- * @param expiration An expiration date for this delegation.
78
- * @param targets Limit this delegation to the target principals.
79
- */
80
- async function _createSingleDelegation(from, to, expiration, targets) {
81
- const delegation = new Delegation(to.toDer(), BigInt(+expiration) * BigInt(1000000), // In nanoseconds.
82
- targets);
83
- // The signature is calculated by signing the concatenation of the domain separator
84
- // and the message.
85
- // Note: To ensure Safari treats this as a user gesture, ensure to not use async methods
86
- // besides the actualy webauthn functionality (such as `sign`). Safari will de-register
87
- // a user gesture if you await an async call thats not fetch, xhr, or setTimeout.
88
- const challenge = new Uint8Array([
89
- ...domainSeparator,
90
- ...new Uint8Array(agent_1.requestIdOf(delegation)),
91
- ]);
92
- const signature = await from.sign(challenge);
93
- return {
94
- delegation,
95
- signature,
96
- };
97
- }
98
- /**
99
- * A chain of delegations. This is JSON Serializable.
100
- * This is the object to serialize and pass to a DelegationIdentity. It does not keep any
101
- * private keys.
102
- */
103
- class DelegationChain {
104
- constructor(delegations, publicKey) {
105
- this.delegations = delegations;
106
- this.publicKey = publicKey;
107
- }
108
- /**
109
- * Create a delegation chain between two (or more) keys. By default, the expiration time
110
- * will be very short (15 minutes).
111
- *
112
- * To build a chain of more than 2 identities, this function needs to be called multiple times,
113
- * passing the previous delegation chain into the options argument. For example:
114
- *
115
- * @example
116
- * const rootKey = createKey();
117
- * const middleKey = createKey();
118
- * const bottomeKey = createKey();
119
- *
120
- * const rootToMiddle = await DelegationChain.create(
121
- * root, middle.getPublicKey(), Date.parse('2100-01-01'),
122
- * );
123
- * const middleToBottom = await DelegationChain.create(
124
- * middle, bottom.getPublicKey(), Date.parse('2100-01-01'), { previous: rootToMiddle },
125
- * );
126
- *
127
- * // We can now use a delegation identity that uses the delegation above:
128
- * const identity = DelegationIdentity.fromDelegation(bottomKey, middleToBottom);
129
- *
130
- * @param from The identity that will delegate.
131
- * @param to The identity that gets delegated. It can now sign messages as if it was the
132
- * identity above.
133
- * @param expiration The length the delegation is valid. By default, 15 minutes from calling
134
- * this function.
135
- * @param options A set of options for this delegation. expiration and previous
136
- * @param options.previous - Another DelegationChain that this chain should start with.
137
- * @param options.targets - targets that scope the delegation (e.g. Canister Principals)
138
- */
139
- static async create(from, to, expiration = new Date(Date.now() + 15 * 60 * 1000), options = {}) {
140
- var _a, _b;
141
- const delegation = await _createSingleDelegation(from, to, expiration, options.targets);
142
- return new DelegationChain([...(((_a = options.previous) === null || _a === void 0 ? void 0 : _a.delegations) || []), delegation], ((_b = options.previous) === null || _b === void 0 ? void 0 : _b.publicKey) || from.getPublicKey().toDer());
143
- }
144
- /**
145
- * Creates a DelegationChain object from a JSON string.
146
- *
147
- * @param json The JSON string to parse.
148
- */
149
- static fromJSON(json) {
150
- const { publicKey, delegations } = typeof json === 'string' ? JSON.parse(json) : json;
151
- if (!Array.isArray(delegations)) {
152
- throw new Error('Invalid delegations.');
153
- }
154
- const parsedDelegations = delegations.map(signedDelegation => {
155
- const { delegation, signature } = signedDelegation;
156
- const { pubkey, expiration, targets } = delegation;
157
- if (targets !== undefined && !Array.isArray(targets)) {
158
- throw new Error('Invalid targets.');
159
- }
160
- return {
161
- delegation: new Delegation(_parseBlob(pubkey), BigInt(`0x${expiration}`), // expiration in JSON is an hexa string (See toJSON() below).
162
- targets &&
163
- targets.map((t) => {
164
- if (typeof t !== 'string') {
165
- throw new Error('Invalid target.');
166
- }
167
- return principal_1.Principal.fromHex(t);
168
- })),
169
- signature: _parseBlob(signature),
170
- };
171
- });
172
- return new this(parsedDelegations, _parseBlob(publicKey));
173
- }
174
- /**
175
- * Creates a DelegationChain object from a list of delegations and a DER-encoded public key.
176
- *
177
- * @param delegations The list of delegations.
178
- * @param publicKey The DER-encoded public key of the key-pair signing the first delegation.
179
- */
180
- static fromDelegations(delegations, publicKey) {
181
- return new this(delegations, publicKey);
182
- }
183
- toJSON() {
184
- return {
185
- delegations: this.delegations.map(signedDelegation => {
186
- const { delegation, signature } = signedDelegation;
187
- const { targets } = delegation;
188
- return {
189
- delegation: Object.assign({ expiration: delegation.expiration.toString(16), pubkey: buffer_1.toHexString(delegation.pubkey) }, (targets && {
190
- targets: targets.map(t => t.toHex()),
191
- })),
192
- signature: buffer_1.toHexString(signature),
193
- };
194
- }),
195
- publicKey: buffer_1.toHexString(this.publicKey),
196
- };
197
- }
198
- }
199
- exports.DelegationChain = DelegationChain;
200
- /**
201
- * An Identity that adds delegation to a request. Everywhere in this class, the name
202
- * innerKey refers to the SignIdentity that is being used to sign the requests, while
203
- * originalKey is the identity that is being borrowed. More identities can be used
204
- * in the middle to delegate.
205
- */
206
- class DelegationIdentity extends agent_1.SignIdentity {
207
- constructor(_inner, _delegation) {
208
- super();
209
- this._inner = _inner;
210
- this._delegation = _delegation;
211
- }
212
- /**
213
- * Create a delegation without having access to delegateKey.
214
- *
215
- * @param key The key used to sign the reqyests.
216
- * @param delegation A delegation object created using `createDelegation`.
217
- */
218
- static fromDelegation(key, delegation) {
219
- return new this(key, delegation);
220
- }
221
- getDelegation() {
222
- return this._delegation;
223
- }
224
- getPublicKey() {
225
- return {
226
- toDer: () => this._delegation.publicKey,
227
- };
228
- }
229
- sign(blob) {
230
- return this._inner.sign(blob);
231
- }
232
- async transformRequest(request) {
233
- const { body } = request, fields = __rest(request, ["body"]);
234
- const requestId = await agent_1.requestIdOf(body);
235
- return Object.assign(Object.assign({}, fields), { body: {
236
- content: body,
237
- sender_sig: await this.sign(new Uint8Array([...requestDomainSeparator, ...new Uint8Array(requestId)])),
238
- sender_delegation: this._delegation.delegations,
239
- sender_pubkey: this._delegation.publicKey,
240
- } });
241
- }
242
- }
243
- exports.DelegationIdentity = DelegationIdentity;
244
- //# sourceMappingURL=delegation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../../src/identity/delegation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAOuB;AACvB,iDAA8C;AAC9C,kDAAoC;AACpC,sCAAuD;AAEvD,MAAM,eAAe,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;AACnF,MAAM,sBAAsB,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE1E,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE;QAClD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;KACxC;IAED,OAAO,sBAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAa,UAAU;IACrB,YACkB,MAAmB,EACnB,UAAkB,EAClB,OAAqB;QAFrB,WAAM,GAAN,MAAM,CAAa;QACnB,eAAU,GAAV,UAAU,CAAQ;QAClB,YAAO,GAAP,OAAO,CAAc;IACpC,CAAC;IAEG,MAAM;QACX,8DAA8D;QAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,iBACnB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EACrC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC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AAI,CACzB,IAAI,UAAU,CAAC,CAAC,GAAG,sBAAsB,EAAE,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAC1E;gBACD,iBAAiB,EAAE,IAAI,CAAC,WAAW,CAAC,WAAW;gBAC/C,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS;aAC1C,IACD;IACJ,CAAC;CACF;AAjDD,gDAiDC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * A DER encoded `SEQUENCE(OID)` for DER-encoded-COSE
3
- */
4
- export declare const DER_COSE_OID: Uint8Array;
5
- /**
6
- * A DER encoded `SEQUENCE(OID)` for the Ed25519 algorithm
7
- */
8
- export declare const ED25519_OID: Uint8Array;
9
- /**
10
- * Wraps the given `payload` in a DER encoding tagged with the given encoded `oid` like so:
11
- * `SEQUENCE(oid, BITSTRING(payload))`
12
- *
13
- * @param payload The payload to encode as the bit string
14
- * @param oid The DER encoded (and SEQUENCE wrapped!) OID to tag the payload with
15
- */
16
- export declare function wrapDER(payload: ArrayBuffer, oid: Uint8Array): Uint8Array;
17
- /**
18
- * Extracts a payload from the given `derEncoded` data, and checks that it was tagged with the given `oid`.
19
- *
20
- * `derEncoded = SEQUENCE(oid, BITSTRING(payload))`
21
- *
22
- * @param derEncoded The DER encoded and tagged data
23
- * @param oid The DER encoded (and SEQUENCE wrapped!) expected OID
24
- * @returns The unwrapped payload
25
- */
26
- export declare const unwrapDER: (derEncoded: ArrayBuffer, oid: Uint8Array) => Uint8Array;
@@ -1,145 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unwrapDER = exports.wrapDER = exports.ED25519_OID = exports.DER_COSE_OID = void 0;
4
- const bufEquals = (b1, b2) => {
5
- if (b1.byteLength !== b2.byteLength)
6
- return false;
7
- const u1 = new Uint8Array(b1);
8
- const u2 = new Uint8Array(b2);
9
- for (let i = 0; i < u1.length; i++) {
10
- if (u1[i] !== u2[i])
11
- return false;
12
- }
13
- return true;
14
- };
15
- const encodeLenBytes = (len) => {
16
- if (len <= 0x7f) {
17
- return 1;
18
- }
19
- else if (len <= 0xff) {
20
- return 2;
21
- }
22
- else if (len <= 0xffff) {
23
- return 3;
24
- }
25
- else if (len <= 0xffffff) {
26
- return 4;
27
- }
28
- else {
29
- throw new Error('Length too long (> 4 bytes)');
30
- }
31
- };
32
- const encodeLen = (buf, offset, len) => {
33
- if (len <= 0x7f) {
34
- buf[offset] = len;
35
- return 1;
36
- }
37
- else if (len <= 0xff) {
38
- buf[offset] = 0x81;
39
- buf[offset + 1] = len;
40
- return 2;
41
- }
42
- else if (len <= 0xffff) {
43
- buf[offset] = 0x82;
44
- buf[offset + 1] = len >> 8;
45
- buf[offset + 2] = len;
46
- return 3;
47
- }
48
- else if (len <= 0xffffff) {
49
- buf[offset] = 0x83;
50
- buf[offset + 1] = len >> 16;
51
- buf[offset + 2] = len >> 8;
52
- buf[offset + 3] = len;
53
- return 4;
54
- }
55
- else {
56
- throw new Error('Length too long (> 4 bytes)');
57
- }
58
- };
59
- const decodeLenBytes = (buf, offset) => {
60
- if (buf[offset] < 0x80)
61
- return 1;
62
- if (buf[offset] === 0x80)
63
- throw new Error('Invalid length 0');
64
- if (buf[offset] === 0x81)
65
- return 2;
66
- if (buf[offset] === 0x82)
67
- return 3;
68
- if (buf[offset] === 0x83)
69
- return 4;
70
- throw new Error('Length too long (> 4 bytes)');
71
- };
72
- /**
73
- * A DER encoded `SEQUENCE(OID)` for DER-encoded-COSE
74
- */
75
- exports.DER_COSE_OID = Uint8Array.from([
76
- ...[0x30, 0x0c],
77
- ...[0x06, 0x0a],
78
- ...[0x2b, 0x06, 0x01, 0x04, 0x01, 0x83, 0xb8, 0x43, 0x01, 0x01],
79
- ]);
80
- /**
81
- * A DER encoded `SEQUENCE(OID)` for the Ed25519 algorithm
82
- */
83
- exports.ED25519_OID = Uint8Array.from([
84
- ...[0x30, 0x05],
85
- ...[0x06, 0x03],
86
- ...[0x2b, 0x65, 0x70],
87
- ]);
88
- /**
89
- * Wraps the given `payload` in a DER encoding tagged with the given encoded `oid` like so:
90
- * `SEQUENCE(oid, BITSTRING(payload))`
91
- *
92
- * @param payload The payload to encode as the bit string
93
- * @param oid The DER encoded (and SEQUENCE wrapped!) OID to tag the payload with
94
- */
95
- function wrapDER(payload, oid) {
96
- // The Bit String header needs to include the unused bit count byte in its length
97
- const bitStringHeaderLength = 2 + encodeLenBytes(payload.byteLength + 1);
98
- const len = oid.byteLength + bitStringHeaderLength + payload.byteLength;
99
- let offset = 0;
100
- const buf = new Uint8Array(1 + encodeLenBytes(len) + len);
101
- // Sequence
102
- buf[offset++] = 0x30;
103
- // Sequence Length
104
- offset += encodeLen(buf, offset, len);
105
- // OID
106
- buf.set(oid, offset);
107
- offset += oid.byteLength;
108
- // Bit String Header
109
- buf[offset++] = 0x03;
110
- offset += encodeLen(buf, offset, payload.byteLength + 1);
111
- // 0 padding
112
- buf[offset++] = 0x00;
113
- buf.set(new Uint8Array(payload), offset);
114
- return buf;
115
- }
116
- exports.wrapDER = wrapDER;
117
- /**
118
- * Extracts a payload from the given `derEncoded` data, and checks that it was tagged with the given `oid`.
119
- *
120
- * `derEncoded = SEQUENCE(oid, BITSTRING(payload))`
121
- *
122
- * @param derEncoded The DER encoded and tagged data
123
- * @param oid The DER encoded (and SEQUENCE wrapped!) expected OID
124
- * @returns The unwrapped payload
125
- */
126
- exports.unwrapDER = (derEncoded, oid) => {
127
- let offset = 0;
128
- const expect = (n, msg) => {
129
- if (buf[offset++] !== n) {
130
- throw new Error('Expected: ' + msg);
131
- }
132
- };
133
- const buf = new Uint8Array(derEncoded);
134
- expect(0x30, 'sequence');
135
- offset += decodeLenBytes(buf, offset);
136
- if (!bufEquals(buf.slice(offset, offset + oid.byteLength), oid)) {
137
- throw new Error('Not the expected OID.');
138
- }
139
- offset += oid.byteLength;
140
- expect(0x03, 'bit string');
141
- offset += decodeLenBytes(buf, offset);
142
- expect(0x00, '0 padding');
143
- return buf.slice(offset);
144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CAAC;IAC1B,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC"}
@@ -1,45 +0,0 @@
1
- import { DerEncodedPublicKey, KeyPair, PublicKey, Signature, SignIdentity } from '@astrox/agent';
2
- export declare class Ed25519PublicKey implements PublicKey {
3
- static from(key: PublicKey): Ed25519PublicKey;
4
- static fromRaw(rawKey: ArrayBuffer): Ed25519PublicKey;
5
- static fromDer(derKey: DerEncodedPublicKey): Ed25519PublicKey;
6
- private static RAW_KEY_LENGTH;
7
- private static derEncode;
8
- private static derDecode;
9
- private readonly rawKey;
10
- private readonly derKey;
11
- private constructor();
12
- toDer(): DerEncodedPublicKey;
13
- toRaw(): ArrayBuffer;
14
- }
15
- export declare class Ed25519KeyIdentity extends SignIdentity {
16
- protected _privateKey: ArrayBuffer;
17
- static generate(seed?: Uint8Array): Ed25519KeyIdentity;
18
- static fromParsedJson(obj: JsonnableEd25519KeyIdentity): Ed25519KeyIdentity;
19
- static fromJSON(json: string): Ed25519KeyIdentity;
20
- static fromKeyPair(publicKey: ArrayBuffer, privateKey: ArrayBuffer): Ed25519KeyIdentity;
21
- static fromSecretKey(secretKey: ArrayBuffer): Ed25519KeyIdentity;
22
- protected _publicKey: Ed25519PublicKey;
23
- protected constructor(publicKey: PublicKey, _privateKey: ArrayBuffer);
24
- /**
25
- * Serialize this key to JSON.
26
- */
27
- toJSON(): JsonnableEd25519KeyIdentity;
28
- /**
29
- * Return a copy of the key pair.
30
- */
31
- getKeyPair(): KeyPair;
32
- /**
33
- * Return the public key.
34
- */
35
- getPublicKey(): PublicKey;
36
- /**
37
- * Signs a blob of data, with this identity's private key.
38
- * @param challenge - challenge to sign with this identity's secretKey, producing a signature
39
- */
40
- sign(challenge: ArrayBuffer): Promise<Signature>;
41
- }
42
- declare type PublicKeyHex = string;
43
- declare type SecretKeyHex = string;
44
- export declare type JsonnableEd25519KeyIdentity = [PublicKeyHex, SecretKeyHex];
45
- export {};