Skip to content

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Aug 20, 2024
1 parent c0206d8 commit a5648da
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 31 deletions.
54 changes: 27 additions & 27 deletions site/vocs.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,33 +413,33 @@ export default defineConfig({
},
],
},
// {
// text: 'Siwe (ERC-4361) 🚧',
// collapsed: true,
// link: '/api/siwe',
// items: [
// {
// text: '.createMessage',
// link: '/api/siwe/createMessage',
// },
// {
// text: '.generateNonce',
// link: '/api/siwe/generateNonce',
// },
// {
// text: '.isUri',
// link: '/api/siwe/isUri',
// },
// {
// text: '.parseMessage',
// link: '/api/siwe/parseMessage',
// },
// {
// text: '.validateMessage',
// link: '/api/siwe/validateMessage',
// },
// ],
// },
{
text: 'Siwe (ERC-4361) 🚧',
collapsed: true,
link: '/api/siwe',
items: [
{
text: '.createMessage',
link: '/api/siwe/createMessage',
},
{
text: '.generateNonce',
link: '/api/siwe/generateNonce',
},
{
text: '.isUri',
link: '/api/siwe/isUri',
},
{
text: '.parseMessage',
link: '/api/siwe/parseMessage',
},
{
text: '.validateMessage',
link: '/api/siwe/validateMessage',
},
],
},
{
text: 'Transaction 🚧',
collapsed: true,
Expand Down
18 changes: 18 additions & 0 deletions src/Siwe.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from 'vitest'
import * as exports from './Siwe.js'

test('exports', () => {
expect(Object.keys(exports)).toMatchInlineSnapshot(`
[
"createMessage",
"createSiweMessage",
"generateNonce",
"generateSiweNonce",
"isUri",
"parseMessage",
"parseSiweMessage",
"validateMessage",
"validateSiweMessage",
]
`)
})
2 changes: 2 additions & 0 deletions src/Siwe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export {
generateSiweNonce,
} from './internal/siwe/generateSiweNonce.js'

export { isUri } from './internal/siwe/isUri.js'

export {
parseSiweMessage as parseMessage,
parseSiweMessage,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/siwe/createSiweMessage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GlobalErrorType } from 'src/Errors.js'

Check failure on line 1 in src/internal/siwe/createSiweMessage.ts

View workflow job for this annotation

GitHub Actions / Verify / Types

Cannot find module 'src/Errors.js' or its corresponding type declarations.
import { toAddress } from '../address/from.js'
import { SiweInvalidMessageFieldError } from '../errors/siwe.js'
import { isUri } from '../isUri.js'
import { isUri } from './isUri.js'
import type { SiweMessage } from '../types/siwe.js'

/**
Expand Down
File renamed without changes.
18 changes: 15 additions & 3 deletions src/internal/isUri.ts → src/internal/siwe/isUri.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/** @internal */
export function isUri(value: string) {
// based on https://github.com/ogt/valid-url
// based on https://github.com/ogt/valid-url

/**
* Check if the given URI is a valid URI.
*
* - Docs: https://oxlib.sh/api/siwe/isUri
* - Spec: https://www.rfc-editor.org/rfc/rfc3986
*
* @example
* import { Siwe } from 'ox'
*
* Siwe.isUri('https://example.com/foo')
* // true
*/

export function isUri(value: string) {

Check failure on line 16 in src/internal/siwe/isUri.ts

View workflow job for this annotation

GitHub Actions / Verify / Lint

Missing JSDoc comment
// check for illegal characters
if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(value))
return false
Expand Down

0 comments on commit a5648da

Please sign in to comment.