@atcute/identity 1.1.1 → 1.1.2

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/dist/did.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { AtprotoDid, Did } from '@atcute/lexicons/syntax';
1
+ import type { AtprotoAudience, AtprotoDid, Did } from '@atcute/lexicons/syntax';
2
2
  /**
3
3
  * checks if it's a DID identifier that is supported by atproto
4
4
  */
5
5
  export declare const isAtprotoDid: (input: string) => input is AtprotoDid;
6
+ export declare const isAtprotoAudience: (input: string) => input is AtprotoAudience;
6
7
  /**
7
8
  * returns the DID's method
8
9
  */
package/dist/did.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAK/D;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,UAErD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,KAAG,CAIhE,CAAC"}
1
+ {"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAOhF;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,UAErD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,eAY1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,KAAG,CAIhE,CAAC"}
package/dist/did.js CHANGED
@@ -1,11 +1,23 @@
1
1
  import { isPlcDid } from './methods/plc.js';
2
2
  import { isAtprotoWebDid } from './methods/web.js';
3
+ const FRAGMENT_RE = /^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f]{2})*$/;
3
4
  /**
4
5
  * checks if it's a DID identifier that is supported by atproto
5
6
  */
6
7
  export const isAtprotoDid = (input) => {
7
8
  return isPlcDid(input) || isAtprotoWebDid(input);
8
9
  };
10
+ export const isAtprotoAudience = (input) => {
11
+ // 'did:web:a.co#f'
12
+ if (input.length < 14) {
13
+ return false;
14
+ }
15
+ const isep = input.indexOf('#', 12);
16
+ if (isep === -1) {
17
+ return false;
18
+ }
19
+ return FRAGMENT_RE.test(input.slice(isep + 1)) && isAtprotoAudience(input.slice(0, isep));
20
+ };
9
21
  /**
10
22
  * returns the DID's method
11
23
  */
package/dist/did.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"did.js","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAuB,EAAE;IAClE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAmB,GAAW,EAAK,EAAE;IACpE,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,MAAW,CAAC;AACpB,CAAC,CAAC"}
1
+ {"version":3,"file":"did.js","sourceRoot":"","sources":["../lib/did.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,GAAG,yDAAyD,CAAC;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAuB,EAAE;IAClE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAA4B,EAAE;IAC5E,mBAAmB;IACnB,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACpC,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3F,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAmB,GAAW,EAAK,EAAE;IACpE,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAClC,OAAO,MAAW,CAAC;AACpB,CAAC,CAAC"}
package/lib/did.ts CHANGED
@@ -1,8 +1,10 @@
1
- import type { AtprotoDid, Did } from '@atcute/lexicons/syntax';
1
+ import type { AtprotoAudience, AtprotoDid, Did } from '@atcute/lexicons/syntax';
2
2
 
3
3
  import { isPlcDid } from './methods/plc.js';
4
4
  import { isAtprotoWebDid } from './methods/web.js';
5
5
 
6
+ const FRAGMENT_RE = /^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f]{2})*$/;
7
+
6
8
  /**
7
9
  * checks if it's a DID identifier that is supported by atproto
8
10
  */
@@ -10,6 +12,20 @@ export const isAtprotoDid = (input: string): input is AtprotoDid => {
10
12
  return isPlcDid(input) || isAtprotoWebDid(input);
11
13
  };
12
14
 
15
+ export const isAtprotoAudience = (input: string): input is AtprotoAudience => {
16
+ // 'did:web:a.co#f'
17
+ if (input.length < 14) {
18
+ return false;
19
+ }
20
+
21
+ const isep = input.indexOf('#', 12);
22
+ if (isep === -1) {
23
+ return false;
24
+ }
25
+
26
+ return FRAGMENT_RE.test(input.slice(isep + 1)) && isAtprotoAudience(input.slice(0, isep));
27
+ };
28
+
13
29
  /**
14
30
  * returns the DID's method
15
31
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@atcute/identity",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "description": "syntax, type definitions and schemas for atproto handles, DIDs and DID documents",
6
6
  "keywords": [
7
7
  "atproto",
@@ -23,11 +23,11 @@
23
23
  },
24
24
  "sideEffects": false,
25
25
  "devDependencies": {
26
- "@types/bun": "^1.2.21"
26
+ "@types/bun": "^1.3.1"
27
27
  },
28
28
  "dependencies": {
29
29
  "@badrap/valita": "^0.4.6",
30
- "@atcute/lexicons": "^1.2.2"
30
+ "@atcute/lexicons": "^1.2.3"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsc --project tsconfig.build.json",