pushnow-sdk 0.1.0

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.
@@ -0,0 +1,145 @@
1
+ export interface Archive {
2
+ id: string;
3
+ public_key: string;
4
+ certificate: string;
5
+ }
6
+ /** Secret-bearing authorization. Never log or put this in a URL. */
7
+ export interface AuthorizedConfig {
8
+ api_url: string;
9
+ user_id: string;
10
+ source_id: string;
11
+ source_key: string;
12
+ identity_public_key: string;
13
+ sender_private_key: string;
14
+ archive: Archive;
15
+ }
16
+ export interface PendingLogin {
17
+ api_url: string;
18
+ key: {
19
+ privateKey: string;
20
+ publicKey: string;
21
+ };
22
+ authorization: {
23
+ id: string;
24
+ device_code: string;
25
+ user_code: string;
26
+ expires_at: string;
27
+ interval: number;
28
+ };
29
+ /** Sender fingerprint for comparison on the approving device, not the account fingerprint. */
30
+ fingerprint: string;
31
+ }
32
+ export interface RequestEvent {
33
+ method: 'GET' | 'POST' | 'PUT';
34
+ /** Endpoint template only; identifiers, query strings and API credentials are omitted. */
35
+ path: string;
36
+ status: number | null;
37
+ durationMs: number;
38
+ outcome: 'success' | 'http_error' | 'network_error' | 'aborted';
39
+ }
40
+ export interface RequestOptions {
41
+ signal?: AbortSignal;
42
+ fetcher?: typeof fetch;
43
+ onRequest?: (event: Readonly<RequestEvent>) => void | Promise<void>;
44
+ }
45
+ export type IdentityVerification = {
46
+ expectedIdentityFingerprint: string;
47
+ confirmIdentity?: never;
48
+ } | {
49
+ expectedIdentityFingerprint?: never;
50
+ confirmIdentity: (identity: {
51
+ fingerprint: string;
52
+ userID: string;
53
+ }) => boolean | Promise<boolean>;
54
+ };
55
+ export type FinishLoginOptions = RequestOptions & IdentityVerification;
56
+ export interface RecipientDevice {
57
+ id: string;
58
+ user_id: string;
59
+ name: string;
60
+ platform: string;
61
+ public_key: string;
62
+ certificate: string;
63
+ status: 'active';
64
+ notifications_enabled: boolean;
65
+ system_version?: string | null;
66
+ app_version?: string | null;
67
+ model?: string | null;
68
+ }
69
+ export interface RecipientDirectory {
70
+ user_id: string;
71
+ source_id: string;
72
+ identity_public_key: string;
73
+ source_public_key: string;
74
+ source_certificate: string;
75
+ archive: Archive;
76
+ devices: RecipientDevice[];
77
+ }
78
+ export interface AttachmentDescriptor {
79
+ id: string;
80
+ name: string;
81
+ mime: string;
82
+ size: number;
83
+ read_token: string;
84
+ key: string;
85
+ nonce: string;
86
+ sha256: string;
87
+ }
88
+ export type AttachmentData = Blob | Uint8Array | ArrayBuffer;
89
+ export interface AttachmentMetadata {
90
+ name: string;
91
+ mime?: string;
92
+ id?: string;
93
+ }
94
+ export interface UploadFile extends AttachmentMetadata {
95
+ data: AttachmentData;
96
+ }
97
+ export interface MessageContent {
98
+ title: string;
99
+ body: string;
100
+ links?: string[];
101
+ attachments?: AttachmentDescriptor[];
102
+ image_id?: string;
103
+ icon_id?: string;
104
+ }
105
+ export type NotificationSound = 'default' | 'silent' | 'chime';
106
+ export interface MessageOptions {
107
+ /** Public routing metadata; omitted keeps legacy default behavior. */
108
+ sound?: NotificationSound;
109
+ deviceIds?: string[];
110
+ inboxOnly?: boolean;
111
+ scheduledAt?: string;
112
+ expiresAt?: string;
113
+ sourceKind?: "web" | "cli" | "api" | "subscription";
114
+ messageID?: string;
115
+ }
116
+ export interface NotificationInput extends MessageContent {
117
+ files?: UploadFile[];
118
+ image?: UploadFile;
119
+ icon?: UploadFile;
120
+ }
121
+ export type SendOptions = MessageOptions & RequestOptions;
122
+ export interface Envelope {
123
+ enc: string;
124
+ ciphertext: string;
125
+ }
126
+ /** Keep this exact object for idempotent retries. Preparing again creates fresh ciphertext. */
127
+ export interface PreparedMessage extends Envelope {
128
+ source_kind?: "web" | "cli" | "api" | "subscription";
129
+ sound?: NotificationSound;
130
+ message_id: string;
131
+ archive_id: string;
132
+ preview: Envelope;
133
+ attachment_ids: string[];
134
+ notify_device_ids?: string[];
135
+ scheduled_at?: string;
136
+ expires_at?: string;
137
+ }
138
+ export interface SubmitResult {
139
+ message_id: string;
140
+ deduplicated: boolean;
141
+ }
142
+ export interface PendingAccountLogin extends PendingLogin {
143
+ accountUserID: string;
144
+ expectedIdentityFingerprint: string;
145
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "pushnow-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Browser-compatible end-to-end encrypted PushNow v2 notification SDK",
5
+ "keywords": ["pushnow", "notifications", "e2ee", "hpke", "sdk", "automation", "ai-agents"],
6
+ "homepage": "https://github.com/pushnow-dev/pushnow-js#readme",
7
+ "bugs": { "url": "https://github.com/pushnow-dev/pushnow-js/issues" },
8
+ "repository": { "type": "git", "url": "git+https://github.com/pushnow-dev/pushnow-js.git" },
9
+ "license": "UNLICENSED",
10
+ "type": "module",
11
+ "sideEffects": false,
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "default": "./dist/index.js" },
17
+ "./browser": { "types": "./dist/index.d.ts", "default": "./dist/browser.js" },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": ["dist", "README.md", "README.zh-CN.md"],
21
+ "scripts": {
22
+ "check": "tsc --noEmit",
23
+ "build": "tsc && node scripts/build.mjs",
24
+ "test": "npm run build && node --test --test-concurrency=1 test/*.test.mjs",
25
+ "test:browser": "npm run build && node --test test/browser.test.mjs",
26
+ "prepack": "npm run build"
27
+ },
28
+ "dependencies": { "@hpke/core": "1.9.0" },
29
+ "devDependencies": { "typescript": "~5.9.2", "esbuild": "^0.28.2", "playwright": "^1.58.0" },
30
+ "engines": { "node": ">=22" }
31
+ }