ox 0.9.13 → 0.9.15
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/CHANGELOG.md +12 -0
- package/Cbor/package.json +6 -0
- package/_cjs/core/AbiConstructor.js +1 -1
- package/_cjs/core/AbiConstructor.js.map +1 -1
- package/_cjs/core/AbiError.js +1 -1
- package/_cjs/core/AbiError.js.map +1 -1
- package/_cjs/core/AbiFunction.js +1 -1
- package/_cjs/core/AbiFunction.js.map +1 -1
- package/_cjs/core/Cbor.js +690 -0
- package/_cjs/core/Cbor.js.map +1 -0
- package/_cjs/core/Errors.js +38 -4
- package/_cjs/core/Errors.js.map +1 -1
- package/_cjs/index.js +3 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/AbiConstructor.js +1 -1
- package/_esm/core/AbiConstructor.js.map +1 -1
- package/_esm/core/AbiError.js +1 -1
- package/_esm/core/AbiError.js.map +1 -1
- package/_esm/core/AbiFunction.js +1 -1
- package/_esm/core/AbiFunction.js.map +1 -1
- package/_esm/core/Cbor.js +771 -0
- package/_esm/core/Cbor.js.map +1 -0
- package/_esm/core/Errors.js +38 -4
- package/_esm/core/Errors.js.map +1 -1
- package/_esm/index.js +32 -0
- package/_esm/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/Cbor.d.ts +187 -0
- package/_types/core/Cbor.d.ts.map +1 -0
- package/_types/core/Errors.d.ts +22 -0
- package/_types/core/Errors.d.ts.map +1 -1
- package/_types/core/WebAuthnP256.d.ts +1 -0
- package/_types/core/WebAuthnP256.d.ts.map +1 -1
- package/_types/index.d.ts +32 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/AbiConstructor.ts +1 -1
- package/core/AbiError.ts +1 -1
- package/core/AbiFunction.ts +1 -1
- package/core/Cbor.ts +912 -0
- package/core/Errors.ts +43 -4
- package/core/WebAuthnP256.ts +28 -0
- package/index.ts +33 -0
- package/package.json +6 -1
- package/version.ts +1 -1
package/core/Errors.ts
CHANGED
|
@@ -18,13 +18,31 @@ export class BaseError<
|
|
|
18
18
|
> extends Error {
|
|
19
19
|
details: string
|
|
20
20
|
docs?: string | undefined
|
|
21
|
+
docsOrigin?: string | undefined
|
|
21
22
|
docsPath?: string | undefined
|
|
22
23
|
shortMessage: string
|
|
24
|
+
showVersion?: boolean | undefined
|
|
23
25
|
version?: string | undefined
|
|
24
26
|
|
|
25
27
|
override cause: cause
|
|
26
28
|
override name = 'BaseError'
|
|
27
29
|
|
|
30
|
+
static defaultStaticOptions = {
|
|
31
|
+
docsOrigin: 'https://oxlib.sh',
|
|
32
|
+
showVersion: false,
|
|
33
|
+
version: `ox@${getVersion()}`,
|
|
34
|
+
} satisfies BaseError.GlobalOptions
|
|
35
|
+
|
|
36
|
+
static setStaticOptions(options: BaseError.GlobalOptions) {
|
|
37
|
+
BaseError.prototype.docsOrigin = options.docsOrigin
|
|
38
|
+
BaseError.prototype.showVersion = options.showVersion
|
|
39
|
+
BaseError.prototype.version = options.version
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static {
|
|
43
|
+
BaseError.setStaticOptions(BaseError.defaultStaticOptions)
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
constructor(shortMessage: string, options: BaseError.Options<cause> = {}) {
|
|
29
47
|
const details = (() => {
|
|
30
48
|
if (options.cause instanceof BaseError) {
|
|
@@ -46,18 +64,22 @@ export class BaseError<
|
|
|
46
64
|
return options.docsPath
|
|
47
65
|
})()
|
|
48
66
|
|
|
49
|
-
const docsBaseUrl = options.docsOrigin ??
|
|
67
|
+
const docsBaseUrl = options.docsOrigin ?? BaseError.prototype.docsOrigin
|
|
50
68
|
const docs = `${docsBaseUrl}${docsPath ?? ''}`
|
|
69
|
+
const showVersion = Boolean(
|
|
70
|
+
options.version ?? BaseError.prototype.showVersion,
|
|
71
|
+
)
|
|
72
|
+
const version = options.version ?? BaseError.prototype.version
|
|
51
73
|
|
|
52
74
|
const message = [
|
|
53
75
|
shortMessage || 'An error occurred.',
|
|
54
76
|
...(options.metaMessages ? ['', ...options.metaMessages] : []),
|
|
55
|
-
...(details || docsPath ||
|
|
77
|
+
...(details || docsPath || showVersion
|
|
56
78
|
? [
|
|
57
79
|
'',
|
|
58
80
|
details ? `Details: ${details}` : undefined,
|
|
59
81
|
docsPath ? `See: ${docs}` : undefined,
|
|
60
|
-
|
|
82
|
+
showVersion ? `Version: ${version}` : undefined,
|
|
61
83
|
]
|
|
62
84
|
: []),
|
|
63
85
|
]
|
|
@@ -69,9 +91,11 @@ export class BaseError<
|
|
|
69
91
|
this.cause = options.cause as any
|
|
70
92
|
this.details = details
|
|
71
93
|
this.docs = docs
|
|
94
|
+
this.docsOrigin = docsBaseUrl
|
|
72
95
|
this.docsPath = docsPath
|
|
73
96
|
this.shortMessage = shortMessage
|
|
74
|
-
this.
|
|
97
|
+
this.showVersion = showVersion
|
|
98
|
+
this.version = version
|
|
75
99
|
}
|
|
76
100
|
|
|
77
101
|
walk(): Error
|
|
@@ -83,11 +107,26 @@ export class BaseError<
|
|
|
83
107
|
|
|
84
108
|
export declare namespace BaseError {
|
|
85
109
|
type Options<cause extends Error | undefined = Error | undefined> = {
|
|
110
|
+
/** Cause of the error. */
|
|
86
111
|
cause?: cause | undefined
|
|
112
|
+
/** Details of the error. */
|
|
87
113
|
details?: string | undefined
|
|
114
|
+
/** Origin of the docs. */
|
|
88
115
|
docsOrigin?: string | undefined
|
|
116
|
+
/** Path of the docs. */
|
|
89
117
|
docsPath?: string | undefined
|
|
118
|
+
/** Meta messages to add to the error. */
|
|
90
119
|
metaMessages?: (string | undefined)[] | undefined
|
|
120
|
+
/** Version of the library to attribute the error to. */
|
|
121
|
+
version?: string | undefined
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type GlobalOptions = {
|
|
125
|
+
/** Origin of the docs. */
|
|
126
|
+
docsOrigin?: string | undefined
|
|
127
|
+
/** Whether to show the version of the library in the error message. */
|
|
128
|
+
showVersion?: boolean | undefined
|
|
129
|
+
/** Version of the library to attribute the error to. */
|
|
91
130
|
version?: string | undefined
|
|
92
131
|
}
|
|
93
132
|
}
|
package/core/WebAuthnP256.ts
CHANGED
|
@@ -783,3 +783,31 @@ export class CredentialRequestFailedError extends Errors.BaseError<Error> {
|
|
|
783
783
|
})
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
|
+
|
|
787
|
+
// Export types required for inference.
|
|
788
|
+
export type {
|
|
789
|
+
AttestationConveyancePreference,
|
|
790
|
+
AuthenticationExtensionsClientInputs,
|
|
791
|
+
AuthenticatorAttachment,
|
|
792
|
+
AuthenticatorSelectionCriteria,
|
|
793
|
+
AuthenticatorTransport,
|
|
794
|
+
BufferSource,
|
|
795
|
+
COSEAlgorithmIdentifier,
|
|
796
|
+
Credential,
|
|
797
|
+
CredentialCreationOptions,
|
|
798
|
+
CredentialMediationRequirement,
|
|
799
|
+
CredentialRequestOptions,
|
|
800
|
+
LargeBlobSupport,
|
|
801
|
+
PrfExtension,
|
|
802
|
+
PublicKeyCredential,
|
|
803
|
+
PublicKeyCredentialCreationOptions,
|
|
804
|
+
PublicKeyCredentialDescriptor,
|
|
805
|
+
PublicKeyCredentialEntity,
|
|
806
|
+
PublicKeyCredentialParameters,
|
|
807
|
+
PublicKeyCredentialRequestOptions,
|
|
808
|
+
PublicKeyCredentialRpEntity,
|
|
809
|
+
PublicKeyCredentialType,
|
|
810
|
+
PublicKeyCredentialUserEntity,
|
|
811
|
+
ResidentKeyRequirement,
|
|
812
|
+
UserVerificationRequirement,
|
|
813
|
+
} from './internal/webauthn.js'
|
package/index.ts
CHANGED
|
@@ -1298,6 +1298,39 @@ export * as Bytes from './core/Bytes.js'
|
|
|
1298
1298
|
|
|
1299
1299
|
export * as Caches from './core/Caches.js'
|
|
1300
1300
|
|
|
1301
|
+
/**
|
|
1302
|
+
* Functions for encoding and decoding CBOR (Concise Binary Object Representation) data.
|
|
1303
|
+
*
|
|
1304
|
+
* CBOR is a binary data format designed for compact data representation and efficient parsing.
|
|
1305
|
+
* It supports all JSON data types plus additional types like byte strings, tags, and simple values.
|
|
1306
|
+
*
|
|
1307
|
+
* @example
|
|
1308
|
+
* ### Encoding Values to CBOR
|
|
1309
|
+
*
|
|
1310
|
+
* Values can be encoded to CBOR using {@link ox#Cbor.(encode:function)}:
|
|
1311
|
+
*
|
|
1312
|
+
* ```ts twoslash
|
|
1313
|
+
* import { Cbor } from 'ox'
|
|
1314
|
+
*
|
|
1315
|
+
* Cbor.encode({ foo: 'bar', baz: [1, 2, 3] })
|
|
1316
|
+
* // @log: '0xa263666f6f636261726362617a83010203'
|
|
1317
|
+
* ```
|
|
1318
|
+
*
|
|
1319
|
+
* ### Decoding CBOR to Values
|
|
1320
|
+
*
|
|
1321
|
+
* Values can be decoded from CBOR using {@link ox#Cbor.(decode:function)}:
|
|
1322
|
+
*
|
|
1323
|
+
* ```ts twoslash
|
|
1324
|
+
* import { Cbor } from 'ox'
|
|
1325
|
+
*
|
|
1326
|
+
* Cbor.decode('0xa263666f6f636261726362617a83010203')
|
|
1327
|
+
* // @log: { foo: 'bar', baz: [1, 2, 3] }
|
|
1328
|
+
* ```
|
|
1329
|
+
*
|
|
1330
|
+
* @category Data
|
|
1331
|
+
*/
|
|
1332
|
+
export * as Cbor from './core/Cbor.js'
|
|
1333
|
+
|
|
1301
1334
|
/**
|
|
1302
1335
|
* Utility functions for computing Contract Addresses.
|
|
1303
1336
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ox",
|
|
3
3
|
"description": "Ethereum Standard Library",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.15",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -168,6 +168,11 @@
|
|
|
168
168
|
"import": "./_esm/core/Caches.js",
|
|
169
169
|
"default": "./_cjs/core/Caches.js"
|
|
170
170
|
},
|
|
171
|
+
"./Cbor": {
|
|
172
|
+
"types": "./_types/core/Cbor.d.ts",
|
|
173
|
+
"import": "./_esm/core/Cbor.js",
|
|
174
|
+
"default": "./_cjs/core/Cbor.js"
|
|
175
|
+
},
|
|
171
176
|
"./ContractAddress": {
|
|
172
177
|
"types": "./_types/core/ContractAddress.d.ts",
|
|
173
178
|
"import": "./_esm/core/ContractAddress.js",
|
package/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '0.9.
|
|
2
|
+
export const version = '0.9.15'
|