@ocap/mcrypto 1.29.22 → 1.29.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_virtual/rolldown_runtime.mjs +18 -0
- package/esm/index.d.mts +2 -1
- package/esm/index.mjs +2 -1
- package/esm/signer/ethereum.d.mts +1 -1
- package/esm/signer/ethereum.mjs +25 -9
- package/esm/signer/passkey.d.mts +1 -1
- package/esm/signer/passkey.mjs +2 -2
- package/esm/signer/secp256k1.d.mts +1 -1
- package/esm/signer/secp256k1.mjs +21 -25
- package/esm/webauthn.d.mts +210 -0
- package/esm/webauthn.mjs +512 -0
- package/lib/_virtual/rolldown_runtime.cjs +14 -0
- package/lib/index.cjs +8 -1
- package/lib/index.d.cts +2 -1
- package/lib/signer/ethereum.cjs +25 -11
- package/lib/signer/ethereum.d.cts +1 -1
- package/lib/signer/passkey.cjs +7 -7
- package/lib/signer/passkey.d.cts +1 -1
- package/lib/signer/secp256k1.cjs +20 -25
- package/lib/signer/secp256k1.d.cts +1 -1
- package/lib/webauthn.cjs +533 -0
- package/lib/webauthn.d.cts +210 -0
- package/package.json +5 -9
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
declare namespace webauthn_d_exports {
|
|
2
|
+
export { COSEALG, COSECRV, COSEKEYS, COSEKTY, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, ParsedAuthenticatorData, RegistrationResponseJSON, VerifiedRegistrationResponse, cose, decodeClientDataJSON, generateAuthenticationOptions, generateChallenge, generateRegistrationOptions, isoBase64URL, isoCBOR, isoUint8Array, parseAuthenticatorData, toHash, verifyRegistrationResponse, verifySignature };
|
|
3
|
+
}
|
|
4
|
+
declare const COSEKEYS: {
|
|
5
|
+
readonly kty: 1;
|
|
6
|
+
readonly alg: 3;
|
|
7
|
+
readonly crv: -1;
|
|
8
|
+
readonly x: -2;
|
|
9
|
+
readonly y: -3;
|
|
10
|
+
readonly n: -1;
|
|
11
|
+
readonly e: -2;
|
|
12
|
+
};
|
|
13
|
+
declare const COSEKTY: {
|
|
14
|
+
readonly OKP: 1;
|
|
15
|
+
readonly EC2: 2;
|
|
16
|
+
readonly RSA: 3;
|
|
17
|
+
};
|
|
18
|
+
declare const COSEALG: {
|
|
19
|
+
readonly ES256: -7;
|
|
20
|
+
readonly EdDSA: -8;
|
|
21
|
+
readonly ES384: -35;
|
|
22
|
+
readonly ES512: -36;
|
|
23
|
+
readonly PS256: -37;
|
|
24
|
+
readonly PS384: -38;
|
|
25
|
+
readonly PS512: -39;
|
|
26
|
+
readonly ES256K: -47;
|
|
27
|
+
readonly RS256: -257;
|
|
28
|
+
readonly RS384: -258;
|
|
29
|
+
readonly RS512: -259;
|
|
30
|
+
readonly RS1: -65535;
|
|
31
|
+
};
|
|
32
|
+
declare const COSECRV: {
|
|
33
|
+
readonly P256: 1;
|
|
34
|
+
readonly P384: 2;
|
|
35
|
+
readonly P521: 3;
|
|
36
|
+
readonly ED25519: 6;
|
|
37
|
+
readonly SECP256K1: 8;
|
|
38
|
+
};
|
|
39
|
+
declare const cose: {
|
|
40
|
+
COSEKEYS: {
|
|
41
|
+
readonly kty: 1;
|
|
42
|
+
readonly alg: 3;
|
|
43
|
+
readonly crv: -1;
|
|
44
|
+
readonly x: -2;
|
|
45
|
+
readonly y: -3;
|
|
46
|
+
readonly n: -1;
|
|
47
|
+
readonly e: -2;
|
|
48
|
+
};
|
|
49
|
+
COSEKTY: {
|
|
50
|
+
readonly OKP: 1;
|
|
51
|
+
readonly EC2: 2;
|
|
52
|
+
readonly RSA: 3;
|
|
53
|
+
};
|
|
54
|
+
COSEALG: {
|
|
55
|
+
readonly ES256: -7;
|
|
56
|
+
readonly EdDSA: -8;
|
|
57
|
+
readonly ES384: -35;
|
|
58
|
+
readonly ES512: -36;
|
|
59
|
+
readonly PS256: -37;
|
|
60
|
+
readonly PS384: -38;
|
|
61
|
+
readonly PS512: -39;
|
|
62
|
+
readonly ES256K: -47;
|
|
63
|
+
readonly RS256: -257;
|
|
64
|
+
readonly RS384: -258;
|
|
65
|
+
readonly RS512: -259;
|
|
66
|
+
readonly RS1: -65535;
|
|
67
|
+
};
|
|
68
|
+
COSECRV: {
|
|
69
|
+
readonly P256: 1;
|
|
70
|
+
readonly P384: 2;
|
|
71
|
+
readonly P521: 3;
|
|
72
|
+
readonly ED25519: 6;
|
|
73
|
+
readonly SECP256K1: 8;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
declare const isoBase64URL: {
|
|
77
|
+
toBuffer(base64url: string): Uint8Array;
|
|
78
|
+
fromBuffer(buffer: Uint8Array, to?: "base64url" | "base64"): string;
|
|
79
|
+
toUTF8String(base64url: string): string;
|
|
80
|
+
fromUTF8String(utf8String: string): string;
|
|
81
|
+
};
|
|
82
|
+
declare const isoUint8Array: {
|
|
83
|
+
concat(arrays: Uint8Array[]): Uint8Array;
|
|
84
|
+
areEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
85
|
+
toDataView(array: Uint8Array): DataView;
|
|
86
|
+
fromHex(hex: string): Uint8Array;
|
|
87
|
+
};
|
|
88
|
+
declare const isoCBOR: {
|
|
89
|
+
decodeFirst<T = any>(input: Uint8Array): T;
|
|
90
|
+
encode(input: any): Uint8Array;
|
|
91
|
+
};
|
|
92
|
+
declare function toHash(data: Uint8Array | string, algorithm?: number): Promise<Uint8Array>;
|
|
93
|
+
declare function decodeClientDataJSON(data: string): {
|
|
94
|
+
type: string;
|
|
95
|
+
challenge: string;
|
|
96
|
+
origin: string;
|
|
97
|
+
crossOrigin?: boolean;
|
|
98
|
+
};
|
|
99
|
+
interface ParsedAuthenticatorData {
|
|
100
|
+
rpIdHash: Uint8Array;
|
|
101
|
+
flagsBuf: Uint8Array;
|
|
102
|
+
flags: {
|
|
103
|
+
up: boolean;
|
|
104
|
+
uv: boolean;
|
|
105
|
+
be: boolean;
|
|
106
|
+
bs: boolean;
|
|
107
|
+
at: boolean;
|
|
108
|
+
ed: boolean;
|
|
109
|
+
flagsInt: number;
|
|
110
|
+
};
|
|
111
|
+
counter: number;
|
|
112
|
+
counterBuf: Uint8Array;
|
|
113
|
+
aaguid?: Uint8Array;
|
|
114
|
+
credentialID?: Uint8Array;
|
|
115
|
+
credentialPublicKey?: Uint8Array;
|
|
116
|
+
extensionsData?: any;
|
|
117
|
+
extensionsDataBuffer?: Uint8Array;
|
|
118
|
+
}
|
|
119
|
+
declare function parseAuthenticatorData(authData: Uint8Array): ParsedAuthenticatorData;
|
|
120
|
+
declare function verifySignature(opts: {
|
|
121
|
+
signature: Uint8Array;
|
|
122
|
+
data: Uint8Array;
|
|
123
|
+
credentialPublicKey: Uint8Array;
|
|
124
|
+
}): Promise<boolean>;
|
|
125
|
+
declare function generateChallenge(): Uint8Array;
|
|
126
|
+
type GenerateRegistrationOptionsOpts = {
|
|
127
|
+
rpName: string;
|
|
128
|
+
rpID: string;
|
|
129
|
+
userName: string;
|
|
130
|
+
userID?: Uint8Array;
|
|
131
|
+
challenge?: string | Uint8Array;
|
|
132
|
+
userDisplayName?: string;
|
|
133
|
+
timeout?: number;
|
|
134
|
+
attestationType?: 'direct' | 'enterprise' | 'none';
|
|
135
|
+
excludeCredentials?: {
|
|
136
|
+
id: string;
|
|
137
|
+
transports?: string[];
|
|
138
|
+
}[];
|
|
139
|
+
authenticatorSelection?: {
|
|
140
|
+
authenticatorAttachment?: string;
|
|
141
|
+
residentKey?: string;
|
|
142
|
+
requireResidentKey?: boolean;
|
|
143
|
+
userVerification?: string;
|
|
144
|
+
};
|
|
145
|
+
extensions?: Record<string, any>;
|
|
146
|
+
supportedAlgorithmIDs?: number[];
|
|
147
|
+
};
|
|
148
|
+
declare function generateRegistrationOptions(options: GenerateRegistrationOptionsOpts): Promise<Record<string, any>>;
|
|
149
|
+
type GenerateAuthenticationOptionsOpts = {
|
|
150
|
+
rpID: string;
|
|
151
|
+
allowCredentials?: {
|
|
152
|
+
id: string;
|
|
153
|
+
transports?: string[];
|
|
154
|
+
}[];
|
|
155
|
+
challenge?: string | Uint8Array;
|
|
156
|
+
timeout?: number;
|
|
157
|
+
userVerification?: 'required' | 'preferred' | 'discouraged';
|
|
158
|
+
extensions?: Record<string, any>;
|
|
159
|
+
};
|
|
160
|
+
declare function generateAuthenticationOptions(options: GenerateAuthenticationOptionsOpts): Promise<Record<string, any>>;
|
|
161
|
+
type RegistrationResponseJSON = {
|
|
162
|
+
id: string;
|
|
163
|
+
rawId: string;
|
|
164
|
+
type: string;
|
|
165
|
+
response: {
|
|
166
|
+
attestationObject: string;
|
|
167
|
+
clientDataJSON: string;
|
|
168
|
+
transports?: string[];
|
|
169
|
+
publicKey?: string;
|
|
170
|
+
publicKeyAlgorithm?: number;
|
|
171
|
+
authenticatorData?: string;
|
|
172
|
+
};
|
|
173
|
+
clientExtensionResults?: Record<string, any>;
|
|
174
|
+
};
|
|
175
|
+
type VerifiedRegistrationResponse = {
|
|
176
|
+
verified: false;
|
|
177
|
+
registrationInfo?: never;
|
|
178
|
+
} | {
|
|
179
|
+
verified: true;
|
|
180
|
+
registrationInfo: {
|
|
181
|
+
fmt: string;
|
|
182
|
+
aaguid: string;
|
|
183
|
+
credential: {
|
|
184
|
+
id: string;
|
|
185
|
+
publicKey: Uint8Array;
|
|
186
|
+
counter: number;
|
|
187
|
+
transports?: string[];
|
|
188
|
+
};
|
|
189
|
+
credentialType: 'public-key';
|
|
190
|
+
attestationObject: Uint8Array;
|
|
191
|
+
userVerified: boolean;
|
|
192
|
+
credentialDeviceType: 'singleDevice' | 'multiDevice';
|
|
193
|
+
credentialBackedUp: boolean;
|
|
194
|
+
origin: string;
|
|
195
|
+
rpID?: string;
|
|
196
|
+
authenticatorExtensionResults?: any;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
declare function verifyRegistrationResponse(options: {
|
|
200
|
+
response: RegistrationResponseJSON;
|
|
201
|
+
expectedChallenge: string | ((challenge: string) => boolean | Promise<boolean>);
|
|
202
|
+
expectedOrigin: string | string[];
|
|
203
|
+
expectedRPID?: string | string[];
|
|
204
|
+
expectedType?: string | string[];
|
|
205
|
+
requireUserPresence?: boolean;
|
|
206
|
+
requireUserVerification?: boolean;
|
|
207
|
+
supportedAlgorithmIDs?: number[];
|
|
208
|
+
}): Promise<VerifiedRegistrationResponse>;
|
|
209
|
+
//#endregion
|
|
210
|
+
export { COSEALG, COSECRV, COSEKEYS, COSEKTY, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, ParsedAuthenticatorData, RegistrationResponseJSON, VerifiedRegistrationResponse, cose, decodeClientDataJSON, generateAuthenticationOptions, generateChallenge, generateRegistrationOptions, isoBase64URL, isoCBOR, isoUint8Array, parseAuthenticatorData, toHash, verifyRegistrationResponse, verifySignature, webauthn_d_exports };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/mcrypto",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Crypto lib that provides signer,crypter,hasher interface",
|
|
6
6
|
"keywords": [
|
|
@@ -48,9 +48,8 @@
|
|
|
48
48
|
"esm"
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@ocap/e2e-test": "1.29.
|
|
51
|
+
"@ocap/e2e-test": "1.29.23",
|
|
52
52
|
"@types/crypto-js": "^4.2.2",
|
|
53
|
-
"@types/elliptic": "^6.4.18",
|
|
54
53
|
"@types/node": "^22.7.5",
|
|
55
54
|
"@types/randombytes": "^2.0.3",
|
|
56
55
|
"tsdown": "^0.18.4",
|
|
@@ -74,19 +73,16 @@
|
|
|
74
73
|
"url": "https://github.com/ArcBlock/blockchain/issues"
|
|
75
74
|
},
|
|
76
75
|
"dependencies": {
|
|
76
|
+
"@noble/curves": "^1.4.0",
|
|
77
77
|
"@noble/ed25519": "^3.0.0",
|
|
78
78
|
"@noble/hashes": "^2.0.1",
|
|
79
|
-
"@ocap/util": "1.29.
|
|
80
|
-
"@simplewebauthn/server": "^13.0.0",
|
|
79
|
+
"@ocap/util": "1.29.23",
|
|
81
80
|
"bn.js": "5.2.3",
|
|
82
81
|
"crypto-js": "^4.2.0",
|
|
83
|
-
"elliptic": "^6.6.1",
|
|
84
|
-
"eth-lib": "^0.2.8",
|
|
85
82
|
"interface": "^1.2.1",
|
|
86
83
|
"randombytes": "^2.1.0"
|
|
87
84
|
},
|
|
88
85
|
"resolutions": {
|
|
89
|
-
"bn.js": "5.2.3"
|
|
90
|
-
"elliptic": "6.5.3"
|
|
86
|
+
"bn.js": "5.2.3"
|
|
91
87
|
}
|
|
92
88
|
}
|