Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssb-uri2

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssb-uri2 - npm Package Compare versions

Comparing version 1.8.1 to 1.9.0

1

lib/index.d.ts

@@ -39,2 +39,3 @@ import { BlobId, FeedId, MsgId } from 'ssb-typescript';

data: string;
extraData?: string;
};

@@ -41,0 +42,0 @@ declare type CanonicalParts = PartsFor<FeedTF> | PartsFor<MessageTF> | PartsFor<BlobTF> | PartsFor<AddressTF> | PartsFor<EncryptionKeyTF> | PartsFor<IdentityTF>;

39

lib/index.js

@@ -170,7 +170,19 @@ "use strict";

const type = 'feed';
const format = ['ed25519', 'bendybutt-v1', 'gabbygrove-v1', 'buttwoo-v1'];
return new RegExp(`ssb:(\/\/)?` +
const formatsWith3Parts = [
'ed25519',
'bendybutt-v1',
'gabbygrove-v1',
'buttwoo-v1',
];
const formatsWith4Parts = ['buttwoo-v1'];
const ruleWith3 = `ssb:(\/\/)?` +
`${type}(\/|:)` +
`(${format.join('|')})(\/|:)` +
`[a-zA-Z0-9_\-]{43}=`);
`(${formatsWith3Parts.join('|')})(\/|:)` +
`[a-zA-Z0-9_\-]{43}=`;
const ruleWith4 = `ssb:(\/\/)?` +
`${type}(\/|:)` +
`(${formatsWith4Parts.join('|')})(\/|:)` +
`[a-zA-Z0-9_\-]{43}=(\/|:)` +
`[a-zA-Z0-9_\-]{43}=`;
return new RegExp(`(${ruleWith4}|${ruleWith3})`);
}

@@ -184,3 +196,3 @@ exports.getFeedSSBURIRegex = getFeedSSBURIRegex;

'gabbygrove-v1',
'buttwoo-v1'
'buttwoo-v1',
];

@@ -251,4 +263,11 @@ return new RegExp(`ssb:(\/\/)?` +

validateParts(parts);
const { type, format, data } = parts;
return `ssb:${type}/${format}/${Base64.unsafeToSafe(data)}`;
const { type, format, data, extraData } = parts;
const safeData = Base64.unsafeToSafe(data);
if (extraData) {
const safeExtraData = Base64.unsafeToSafe(extraData);
return `ssb:${type}/${format}/${safeData}/${safeExtraData}`;
}
else {
return `ssb:${type}/${format}/${safeData}`;
}
}

@@ -261,8 +280,10 @@ exports.compose = compose;

}
let [type, format, data] = pathname.split('/');
data = Base64.safeToUnsafe(data);
const [type, format, safeData, safeExtraData] = pathname.split('/');
const data = Base64.safeToUnsafe(safeData);
const parts = { type, format, data };
validateParts(parts);
if (safeExtraData)
parts.extraData = Base64.safeToUnsafe(safeExtraData);
return parts;
}
exports.decompose = decompose;
{
"name": "ssb-uri2",
"version": "1.8.1",
"version": "1.9.0",
"description": "Utilities for recognizing and converting SSB URIs",

@@ -30,3 +30,3 @@ "repository": {

"ssb-ref": "^2.14.3",
"tap-spec": "^5.0.0",
"tap-arc": "^0.3.4",
"tape": "^5.2.0",

@@ -38,5 +38,6 @@ "typescript": "~4.2.4"

"test": "npm run compile && npm run tape",
"tape": "tape test/*.js | tap-spec",
"tape": "tape test/*.js | tap-arc --bail",
"coverage": "nyc npm run test"
}
}
},
"readme": "# ssb-uri2\n\n> An SSB utility library for handling and converting SSB URIs\n\nThis library provides utilities that recognize SSB URIs according to the [spec](https://github.com/ssb-ngi-pointer/ssb-uri-spec), and is compatible with [ssb-uri](https://github.com/fraction/ssb-uri) (prior work), while adding more support and more utilities.\n\n## Install\n\n```\nnpm install ssb-uri2\n```\n\n## Example\n\n```js\nconst ssbUri = require('ssb-uri2');\n\nconst exampleURI =\n 'ssb:message/sha256/g3hPVPDEO1Aj_uPl0-J2NlhFB2bbFLIHlty-YuqFZ3w=';\n\nssbUri.isMessageSSBURI(exampleURI);\n// true\n\nssbUri.toMessageSigil(exampleURI);\n// '%g3hPVPDEO1Aj/uPl0+J2NlhFB2bbFLIHlty+YuqFZ3w=.sha256'\n```\n\n## Boolean APIs\n\n### `isSSBURI(uri: string | uri): boolean`\n\n### `isFeedSSBURI(uri: string | null): boolean`\n\n### `isBendyButtV1FeedSSBURI(uri: string | null): boolean`\n\n### `isGabbyGroveV1FeedSSBURI(uri: string | null): boolean`\n\n### `isMessageSSBURI(uri: string | null): boolean`\n\n### `isBendyButtV1MessageSSBURI(uri: string | null): boolean`\n\n### `isGabbyGroveV1MessageSSBURI(uri: string | null): boolean`\n\n### `isBlobSSBURI(uri: string | null): boolean`\n\n### `isAddressSSBURI(uri: string | null): boolean`\n\n### `isEncryptionKeyBox2DMDiffieHellmanSSBURI(uri: string | null): boolean`\n\n### `isIdentityPOBoxSSBURI(uri: string | null): boolean`\n\n### `isIdentityFusionSSBURI(uri: string | null): boolean`\n\n### `isExperimentalSSBURI(uri: string | null): boolean`\n\n### `isExperimentalSSBURIWithAction(action: string): (uri: string) => boolean`\n\n## Regular Expressions\n\n### `getFeedSSBURIRegex() => RegExp`\n\n### `getMessageSSBURIRegex() => RegExp`\n\n## Conversion APIs\n\n### `fromFeedSigil(sigil: string): string`\n\n### `fromMessageSigil(sigil: string): string`\n\n### `fromBlobSigil(sigil: string): string`\n\n### `fromMultiserverAddress(msaddr: string): string`\n\n### `toFeedSigil(uri: string): string | null`\n\n### `toMessageSigil(uri: string): string | null`\n\n### `toBlobSigil(uri: string): string | null`\n\n### `toMultiserverAddress(uri: string): string | null`\n\n### `compose(parts: {type, format, data, extraData}): string`\n\n### `decompose(uri: string): {type, format, data, extraData}`\n\nThe object `{type, format, data}` is such that it matches `ssb:${type}/${format}/${data}`, except the `data` is always in normal Base64 (i.e. **not** URI safe).\n\nThere is also the case of `extraData` for special URIs such as `ssb:feed/buttwoo-v1/${data}/${extraData}`.\n\n## License\n\nLGPL-3.0\n"
}

@@ -82,10 +82,12 @@ # ssb-uri2

### `compose(parts: {type, format, data}): string`
### `compose(parts: {type, format, data, extraData}): string`
### `decompose(uri: string): {type, format, data}`
### `decompose(uri: string): {type, format, data, extraData}`
The object `{type, format, data}` is such that it matches `ssb:${type}/${format}/${data}`, except the `data` is always in normal Base64 (i.e. **not** URI safe).
There is also the case of `extraData` for special URIs such as `ssb:feed/buttwoo-v1/${data}/${extraData}`.
## License
LGPL-3.0
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc