1 module libwasm.bindings.PushSubscription; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.PushSubscriptionOptions; 7 8 @safe: 9 nothrow: 10 11 enum PushEncryptionKeyName { 12 p256dh, 13 auth 14 } 15 struct PushSubscription { 16 nothrow: 17 JsHandle handle; 18 alias handle this; 19 this(Handle h) { 20 this.handle = JsHandle(h); 21 } 22 string endpoint()() { 23 return Object_Getter__string(this.handle, "endpoint"); 24 } 25 auto options()() { 26 return PushSubscriptionOptions(Object_Getter__Handle(this.handle, "options")); 27 } 28 auto getKey()(PushEncryptionKeyName name) { 29 return recastOpt!(ArrayBuffer)(Serialize_Object_VarArgCall!(Optional!Handle)(this.handle, "getKey", "Enum", tuple(name))); 30 } 31 auto unsubscribe()() { 32 return JsPromise!(bool)(Object_Getter__Handle(this.handle, "unsubscribe")); 33 } 34 auto toJSON()() { 35 return PushSubscriptionJSON(Object_Getter__Handle(this.handle, "toJSON")); 36 } 37 } 38 struct PushSubscriptionInit { 39 nothrow: 40 JsHandle handle; 41 alias handle this; 42 this(Handle h) { 43 this.handle = JsHandle(h); 44 } 45 static auto create() { 46 return PushSubscriptionInit(libwasm_add__object()); 47 } 48 void endpoint()(string endpoint) { 49 Object_Call_string__void(this.handle, "endpoint", endpoint); 50 } 51 string endpoint()() { 52 return Object_Getter__string(this.handle, "endpoint"); 53 } 54 void scope_()(string scope_) { 55 Object_Call_string__void(this.handle, "scope", scope_); 56 } 57 string scope_()() { 58 return Object_Getter__string(this.handle, "scope"); 59 } 60 void p256dhKey(T0)(scope auto ref Optional!(T0) p256dhKey) if (isTOrPointer!(T0, ArrayBuffer)) { 61 Serialize_Object_VarArgCall!void(this.handle, "p256dhKey", "Optional!Handle", tuple(!p256dhKey.empty, cast(Handle)p256dhKey.front.handle)); 62 } 63 auto p256dhKey()() { 64 return recastOpt!(ArrayBuffer)(Object_Getter__OptionalHandle(this.handle, "p256dhKey")); 65 } 66 void authSecret(T0)(scope auto ref Optional!(T0) authSecret) if (isTOrPointer!(T0, ArrayBuffer)) { 67 Serialize_Object_VarArgCall!void(this.handle, "authSecret", "Optional!Handle", tuple(!authSecret.empty, cast(Handle)authSecret.front.handle)); 68 } 69 auto authSecret()() { 70 return recastOpt!(ArrayBuffer)(Object_Getter__OptionalHandle(this.handle, "authSecret")); 71 } 72 void appServerKey(T0)(scope auto ref Optional!(T0) appServerKey) if (isTOrPointer!(T0, BufferSource)) { 73 Serialize_Object_VarArgCall!void(this.handle, "appServerKey", "Optional!Handle", tuple(!appServerKey.empty, cast(Handle)appServerKey.front.handle)); 74 } 75 auto appServerKey()() { 76 return recastOpt!(BufferSource)(Object_Getter__OptionalHandle(this.handle, "appServerKey")); 77 } 78 } 79 struct PushSubscriptionJSON { 80 nothrow: 81 JsHandle handle; 82 alias handle this; 83 this(Handle h) { 84 this.handle = JsHandle(h); 85 } 86 static auto create() { 87 return PushSubscriptionJSON(libwasm_add__object()); 88 } 89 void endpoint()(string endpoint) { 90 Object_Call_string__void(this.handle, "endpoint", endpoint); 91 } 92 string endpoint()() { 93 return Object_Getter__string(this.handle, "endpoint"); 94 } 95 void keys()(scope ref PushSubscriptionKeys keys) { 96 Object_Call_Handle__void(this.handle, "keys", keys.handle); 97 } 98 auto keys()() { 99 return PushSubscriptionKeys(Object_Getter__Handle(this.handle, "keys")); 100 } 101 } 102 struct PushSubscriptionKeys { 103 nothrow: 104 JsHandle handle; 105 alias handle this; 106 this(Handle h) { 107 this.handle = JsHandle(h); 108 } 109 static auto create() { 110 return PushSubscriptionKeys(libwasm_add__object()); 111 } 112 void p256dh()(string p256dh) { 113 Object_Call_string__void(this.handle, "p256dh", p256dh); 114 } 115 string p256dh()() { 116 return Object_Getter__string(this.handle, "p256dh"); 117 } 118 void auth()(string auth) { 119 Object_Call_string__void(this.handle, "auth", auth); 120 } 121 string auth()() { 122 return Object_Getter__string(this.handle, "auth"); 123 } 124 } 125 126