@solarpunkltd/swarm-id 0.8.0 → 0.8.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.
@@ -77,6 +77,7 @@ export interface WithWriteOptions {
77
77
  wait?: "block" | "skip";
78
78
  }
79
79
  export interface BatchWriteCoordinatorDeps {
80
+ /** Read on every use, so a getter here follows a change of node. */
80
81
  bee: Bee;
81
82
  /** Postage batch id (hex) — the `withBatchWriteLock` key. */
82
83
  batchId: string;
@@ -43,8 +43,9 @@ export declare const DeviceStateSnapshotSchemaV1: z.ZodObject<{
43
43
  appDescription: z.ZodOptional<z.ZodString>;
44
44
  connectedUntil: z.ZodOptional<z.ZodNumber>;
45
45
  appSecret: z.ZodOptional<z.ZodString>;
46
- postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<BatchId, string>>>;
46
+ postageStampBatchID: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodPipe<z.ZodString, z.ZodTransform<BatchId, string>>]>>;
47
47
  postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
48
+ stampPending: z.ZodOptional<z.ZodLiteral<true>>;
48
49
  revokedAt: z.ZodOptional<z.ZodNumber>;
49
50
  disconnectedAt: z.ZodOptional<z.ZodNumber>;
50
51
  chatBinding: z.ZodOptional<z.ZodObject<{
package/dist/types.d.ts CHANGED
@@ -537,8 +537,10 @@ export type UploadMode = z.infer<typeof UploadModeSchema>;
537
537
  /**
538
538
  * Why a session cannot upload, when `uploadMode` is `"unavailable"`.
539
539
  *
540
- * - `no-stamp` — no stamp resolved: the account has no drive, or its pointers
541
- * name one that is gone
540
+ * - `no-stamp`: the site has no stamp to use. The account has no drive (or
541
+ * its pointers name only drives that are gone), the person set this site to
542
+ * no drive, or the person has not yet confirmed the site's drive in the
543
+ * connect window since the site signed in.
542
544
  * - `stamper-failed` — the stamp resolved and the stamper still did not build.
543
545
  * `initializeStamper` logs and returns rather than throwing, so without this
544
546
  * the symptom is indistinguishable from having no stamp at all.
@@ -653,6 +655,8 @@ export declare const ConnectionInfoSchema: z.ZodObject<{
653
655
  message: z.ZodString;
654
656
  signature: z.ZodString;
655
657
  }, z.core.$strip>>;
658
+ beeApiUrl: z.ZodOptional<z.ZodString>;
659
+ postageBatchId: z.ZodOptional<z.ZodString>;
656
660
  }, z.core.$strip>;
657
661
  export type ConnectionInfo = z.infer<typeof ConnectionInfoSchema>;
658
662
  export declare const AppMetadataSchema: z.ZodObject<{
@@ -762,6 +766,15 @@ export declare const DeriveAppSecretMessageSchema: z.ZodObject<{
762
766
  requestId: z.ZodString;
763
767
  label: z.ZodString;
764
768
  }, z.core.$strip>;
769
+ /**
770
+ * The site's own Bee address for this frame from now on, replacing the one
771
+ * `parentIdentify` gave, for the site's session alone.
772
+ */
773
+ export declare const SetBeeApiUrlMessageSchema: z.ZodObject<{
774
+ type: z.ZodLiteral<"setBeeApiUrl">;
775
+ requestId: z.ZodString;
776
+ beeApiUrl: z.ZodString;
777
+ }, z.core.$strip>;
765
778
  export declare const GetChatKeyMessageSchema: z.ZodObject<{
766
779
  type: z.ZodLiteral<"getChatKey">;
767
780
  requestId: z.ZodString;
@@ -1366,6 +1379,10 @@ export declare const ParentToIframeMessageSchema: z.ZodDiscriminatedUnion<[z.Zod
1366
1379
  }, z.core.$strip>, z.ZodObject<{
1367
1380
  type: z.ZodLiteral<"getChatKey">;
1368
1381
  requestId: z.ZodString;
1382
+ }, z.core.$strip>, z.ZodObject<{
1383
+ type: z.ZodLiteral<"setBeeApiUrl">;
1384
+ requestId: z.ZodString;
1385
+ beeApiUrl: z.ZodString;
1369
1386
  }, z.core.$strip>, z.ZodObject<{
1370
1387
  type: z.ZodLiteral<"stampChunk">;
1371
1388
  requestId: z.ZodString;
@@ -1833,6 +1850,7 @@ export type UploadDataMessage = z.infer<typeof UploadDataMessageSchema>;
1833
1850
  export type DownloadDataMessage = z.infer<typeof DownloadDataMessageSchema>;
1834
1851
  export type DeriveAppSecretMessage = z.infer<typeof DeriveAppSecretMessageSchema>;
1835
1852
  export type GetChatKeyMessage = z.infer<typeof GetChatKeyMessageSchema>;
1853
+ export type SetBeeApiUrlMessage = z.infer<typeof SetBeeApiUrlMessageSchema>;
1836
1854
  export type StampChunkSigner = z.infer<typeof StampChunkSignerSchema>;
1837
1855
  export type StampChunkRequest = z.infer<typeof StampChunkRequestSchema>;
1838
1856
  export type StampChunkMessage = z.infer<typeof StampChunkMessageSchema>;
@@ -1917,6 +1935,11 @@ export declare const GetChatKeyResponseMessageSchema: z.ZodObject<{
1917
1935
  requestId: z.ZodString;
1918
1936
  chatKey: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
1919
1937
  }, z.core.$strip>;
1938
+ export declare const SetBeeApiUrlResponseMessageSchema: z.ZodObject<{
1939
+ type: z.ZodLiteral<"setBeeApiUrlResponse">;
1940
+ requestId: z.ZodString;
1941
+ beeApiUrl: z.ZodString;
1942
+ }, z.core.$strip>;
1920
1943
  export declare const StampChunkResponseMessageSchema: z.ZodObject<{
1921
1944
  type: z.ZodLiteral<"stampChunkResponse">;
1922
1945
  requestId: z.ZodString;
@@ -2122,6 +2145,8 @@ export declare const ConnectionInfoChangedMessageSchema: z.ZodObject<{
2122
2145
  message: z.ZodString;
2123
2146
  signature: z.ZodString;
2124
2147
  }, z.core.$strip>>;
2148
+ beeApiUrl: z.ZodOptional<z.ZodString>;
2149
+ postageBatchId: z.ZodOptional<z.ZodString>;
2125
2150
  }, z.core.$strip>;
2126
2151
  export declare const ConnectResponseMessageSchema: z.ZodObject<{
2127
2152
  type: z.ZodLiteral<"connectResponse">;
@@ -2365,6 +2390,10 @@ export declare const IframeToParentMessageSchema: z.ZodDiscriminatedUnion<[z.Zod
2365
2390
  type: z.ZodLiteral<"getChatKeyResponse">;
2366
2391
  requestId: z.ZodString;
2367
2392
  chatKey: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
2393
+ }, z.core.$strip>, z.ZodObject<{
2394
+ type: z.ZodLiteral<"setBeeApiUrlResponse">;
2395
+ requestId: z.ZodString;
2396
+ beeApiUrl: z.ZodString;
2368
2397
  }, z.core.$strip>, z.ZodObject<{
2369
2398
  type: z.ZodLiteral<"stampChunkResponse">;
2370
2399
  requestId: z.ZodString;
@@ -2485,6 +2514,8 @@ export declare const IframeToParentMessageSchema: z.ZodDiscriminatedUnion<[z.Zod
2485
2514
  message: z.ZodString;
2486
2515
  signature: z.ZodString;
2487
2516
  }, z.core.$strip>>;
2517
+ beeApiUrl: z.ZodOptional<z.ZodString>;
2518
+ postageBatchId: z.ZodOptional<z.ZodString>;
2488
2519
  }, z.core.$strip>, z.ZodObject<{
2489
2520
  type: z.ZodLiteral<"connectResponse">;
2490
2521
  requestId: z.ZodString;
@@ -2671,6 +2702,7 @@ export type AuthSuccessMessage = z.infer<typeof AuthSuccessMessageSchema>;
2671
2702
  export type UploadDataResponseMessage = z.infer<typeof UploadDataResponseMessageSchema>;
2672
2703
  export type DownloadDataResponseMessage = z.infer<typeof DownloadDataResponseMessageSchema>;
2673
2704
  export type GetChatKeyResponseMessage = z.infer<typeof GetChatKeyResponseMessageSchema>;
2705
+ export type SetBeeApiUrlResponseMessage = z.infer<typeof SetBeeApiUrlResponseMessageSchema>;
2674
2706
  export type DeriveAppSecretResponseMessage = z.infer<typeof DeriveAppSecretResponseMessageSchema>;
2675
2707
  export type StampChunkResponseMessage = z.infer<typeof StampChunkResponseMessageSchema>;
2676
2708
  export type UploadFileResponseMessage = z.infer<typeof UploadFileResponseMessageSchema>;
@@ -2739,8 +2771,9 @@ export declare const AuthDataSchema: z.ZodObject<{
2739
2771
  appDescription: z.ZodOptional<z.ZodString>;
2740
2772
  connectedUntil: z.ZodOptional<z.ZodNumber>;
2741
2773
  appSecret: z.ZodOptional<z.ZodString>;
2742
- postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@ethersphere/core-sdk").BatchId, string>>>;
2774
+ postageStampBatchID: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodPipe<z.ZodString, z.ZodTransform<import("@ethersphere/core-sdk").BatchId, string>>]>>;
2743
2775
  postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
2776
+ stampPending: z.ZodOptional<z.ZodLiteral<true>>;
2744
2777
  revokedAt: z.ZodOptional<z.ZodNumber>;
2745
2778
  disconnectedAt: z.ZodOptional<z.ZodNumber>;
2746
2779
  chatBinding: z.ZodOptional<z.ZodObject<{
@@ -2779,6 +2812,7 @@ export declare const AuthDataSchema: z.ZodObject<{
2779
2812
  message: z.ZodString;
2780
2813
  signature: z.ZodString;
2781
2814
  }, z.core.$strip>>;
2815
+ stampPending: z.ZodOptional<z.ZodLiteral<true>>;
2782
2816
  }, z.core.$strip>;
2783
2817
  export type AuthData = z.infer<typeof AuthDataSchema>;
2784
2818
  /**
@@ -2852,8 +2886,9 @@ export declare const SetSecretMessageSchema: z.ZodObject<{
2852
2886
  appDescription: z.ZodOptional<z.ZodString>;
2853
2887
  connectedUntil: z.ZodOptional<z.ZodNumber>;
2854
2888
  appSecret: z.ZodOptional<z.ZodString>;
2855
- postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@ethersphere/core-sdk").BatchId, string>>>;
2889
+ postageStampBatchID: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodPipe<z.ZodString, z.ZodTransform<import("@ethersphere/core-sdk").BatchId, string>>]>>;
2856
2890
  postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
2891
+ stampPending: z.ZodOptional<z.ZodLiteral<true>>;
2857
2892
  revokedAt: z.ZodOptional<z.ZodNumber>;
2858
2893
  disconnectedAt: z.ZodOptional<z.ZodNumber>;
2859
2894
  chatBinding: z.ZodOptional<z.ZodObject<{
@@ -2892,6 +2927,7 @@ export declare const SetSecretMessageSchema: z.ZodObject<{
2892
2927
  message: z.ZodString;
2893
2928
  signature: z.ZodString;
2894
2929
  }, z.core.$strip>>;
2930
+ stampPending: z.ZodOptional<z.ZodLiteral<true>>;
2895
2931
  }, z.core.$strip>;
2896
2932
  }, z.core.$strip>;
2897
2933
  export declare const PopupToIframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -2927,8 +2963,9 @@ export declare const PopupToIframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodO
2927
2963
  appDescription: z.ZodOptional<z.ZodString>;
2928
2964
  connectedUntil: z.ZodOptional<z.ZodNumber>;
2929
2965
  appSecret: z.ZodOptional<z.ZodString>;
2930
- postageStampBatchID: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@ethersphere/core-sdk").BatchId, string>>>;
2966
+ postageStampBatchID: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"none">, z.ZodPipe<z.ZodString, z.ZodTransform<import("@ethersphere/core-sdk").BatchId, string>>]>>;
2931
2967
  postageStampBatchIDAt: z.ZodOptional<z.ZodNumber>;
2968
+ stampPending: z.ZodOptional<z.ZodLiteral<true>>;
2932
2969
  revokedAt: z.ZodOptional<z.ZodNumber>;
2933
2970
  disconnectedAt: z.ZodOptional<z.ZodNumber>;
2934
2971
  chatBinding: z.ZodOptional<z.ZodObject<{
@@ -2967,6 +3004,7 @@ export declare const PopupToIframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodO
2967
3004
  message: z.ZodString;
2968
3005
  signature: z.ZodString;
2969
3006
  }, z.core.$strip>>;
3007
+ stampPending: z.ZodOptional<z.ZodLiteral<true>>;
2970
3008
  }, z.core.$strip>;
2971
3009
  }, z.core.$strip>], "type">;
2972
3010
  export type SetSecretMessage = z.infer<typeof SetSecretMessageSchema>;
@@ -2990,6 +3028,14 @@ export interface ClientOptions {
2990
3028
  containerId?: string;
2991
3029
  /** URL of a subsidised gateway for users without postage stamps. Gateway handles stamping server-side. */
2992
3030
  subsidisedGatewayUrl?: string;
3031
+ /**
3032
+ * The Bee node this site's content reads and stamped uploads go through, in
3033
+ * place of the node the person set in Swarm ID, which keeps applying on
3034
+ * every other site. The person's account and device coordination stay on
3035
+ * their own node. An http(s) URL, optionally with a path. Change it later
3036
+ * with `setBeeApiUrl`. Held by this site's frame alone and never stored.
3037
+ */
3038
+ beeApiUrl?: string;
2993
3039
  }
2994
3040
  export interface AuthOptions {
2995
3041
  masterKeyStorageKey?: string;
@@ -1,10 +1,11 @@
1
- import type { ConnectedApp, PostageStamp, SignedInAccount } from "../schemas";
1
+ import { type ConnectedApp, type PostageStamp, type SignedInAccount } from "../schemas";
2
2
  /**
3
3
  * Resolve which postage stamp an app should upload with.
4
4
  *
5
5
  * An app may carry its own batch override (`postageStampBatchID`); otherwise it
6
6
  * falls back to the account's default stamp. The account owns the stamp set, so
7
- * these pointers are the single source of truth.
7
+ * these pointers are the single source of truth. An app set to
8
+ * `NO_POSTAGE_STAMP` resolves to no stamp, the default included.
8
9
  *
9
10
  * The lookup is existence-checked: a pointer whose stamp is missing (e.g. a
10
11
  * removed or replaced batch) is skipped so resolution falls through to the next
@@ -36,4 +37,4 @@ export declare function resolveStampForApp(app: Pick<ConnectedApp, "postageStamp
36
37
  * cannot upload at all. Tombstones its pointers still name are kept too — a
37
38
  * tombstone is how the session learns the stamp it was spending is deleted.
38
39
  */
39
- export declare function stampsReachableByApp(app: Pick<ConnectedApp, "postageStampBatchID">, account: Pick<SignedInAccount, "defaultPostageStampBatchID">, stamps: PostageStamp[]): PostageStamp[];
40
+ export declare function stampsReachableByApp(app: Pick<ConnectedApp, "postageStampBatchID" | "stampPending">, account: Pick<SignedInAccount, "defaultPostageStampBatchID">, stamps: PostageStamp[]): PostageStamp[];
@@ -11,6 +11,14 @@ export declare function normalizeUrl(url: string): string;
11
11
  * dialog so a broken Bee/RPC endpoint can't be saved or persisted.
12
12
  */
13
13
  export declare function isHttpUrl(value: string): boolean;
14
+ /**
15
+ * True for an address a site may name as its Bee node: an `http:` or
16
+ * `https:` URL, optionally with a path, the way a gateway in front of Bee is
17
+ * often mounted. Refused besides what `isHttpUrl` refuses: credentials, which
18
+ * `fetch` will not send from a URL and throws on, and a query or fragment,
19
+ * which bee-js would put in the middle of every request path it appends.
20
+ */
21
+ export declare function isBeeApiUrl(value: string): boolean;
14
22
  /**
15
23
  * Configuration options for building the authentication URL.
16
24
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solarpunkltd/swarm-id",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "description": "Swarm ID library for authentication and Bee API operations",
6
6
  "main": "dist/swarm-id.esm.js",
@@ -19,6 +19,25 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
+ "scripts": {
23
+ "build": "rollup -c",
24
+ "build:watch": "rollup -c -w",
25
+ "clean": "rm -rf dist",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "test:integration": "vitest run --config vitest.integration.config.ts",
29
+ "test:live": "vitest run --config vitest.live.config.ts",
30
+ "test:ui": "vitest --ui",
31
+ "test:coverage": "vitest run --coverage",
32
+ "lint": "eslint .",
33
+ "lint:fix": "eslint . --fix",
34
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
35
+ "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
36
+ "typecheck": "tsc --noEmit -p tsconfig.check.json",
37
+ "check:all": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test",
38
+ "prepack": "npm run clean && npm run build",
39
+ "check:pack": "node dev/check-pack.js"
40
+ },
22
41
  "keywords": [
23
42
  "swarm",
24
43
  "identity",
@@ -52,6 +71,8 @@
52
71
  "@rollup/plugin-replace": "6.0.3",
53
72
  "@rollup/plugin-terser": "0.4.4",
54
73
  "@rollup/plugin-typescript": "12.3.0",
74
+ "@swarm-id/eslint-rules": "workspace:*",
75
+ "@swarm-id/signaling": "workspace:*",
55
76
  "@types/node": "24.10.1",
56
77
  "@typescript-eslint/eslint-plugin": "8.69.0",
57
78
  "@typescript-eslint/parser": "8.69.0",
@@ -62,9 +83,7 @@
62
83
  "rollup": "4.53.3",
63
84
  "tslib": "2.8.1",
64
85
  "typescript": "5.8.3",
65
- "vitest": "4.0.14",
66
- "@swarm-id/signaling": "0.1.0",
67
- "@swarm-id/eslint-rules": "0.0.0"
86
+ "vitest": "4.0.14"
68
87
  },
69
88
  "engines": {
70
89
  "node": ">=22",
@@ -72,23 +91,5 @@
72
91
  },
73
92
  "publishConfig": {
74
93
  "access": "public"
75
- },
76
- "scripts": {
77
- "build": "rollup -c",
78
- "build:watch": "rollup -c -w",
79
- "clean": "rm -rf dist",
80
- "test": "vitest run",
81
- "test:watch": "vitest",
82
- "test:integration": "vitest run --config vitest.integration.config.ts",
83
- "test:live": "vitest run --config vitest.live.config.ts",
84
- "test:ui": "vitest --ui",
85
- "test:coverage": "vitest run --coverage",
86
- "lint": "eslint .",
87
- "lint:fix": "eslint . --fix",
88
- "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
89
- "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
90
- "typecheck": "tsc --noEmit -p tsconfig.check.json",
91
- "check:all": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test",
92
- "check:pack": "node dev/check-pack.js"
93
94
  }
94
- }
95
+ }